smeserver-koji/koji-setup/koji-bootstrap-build.sh
2024-09-29 20:22:50 +10:00

274 lines
17 KiB
Bash
Executable File

#!/bin/bash
# SPDX-License-Identifier: Apache-2.0
set -e
DEBUG=
SILENT="-s"
QUIET="-q"
for param in $1 $2 ; do
if [ $param ] ; then
case $param in
debug )
DEBUG="debug" ;;
esac
else
break
fi
done
if [ $DEBUG ] ; then
set -xe
SILENT=
QUIET="-v"
fi
# load required parameters
SCRIPT_DIR="$(dirname "$(realpath "$0")")"
if [ ! -f "$SCRIPT_DIR"/koji-parameters.sh ] ; then
echo "$SCRIPT_DIR/koji-parameters.sh NOT found - aborting"
exit 1
fi
source "$SCRIPT_DIR"/koji-parameters.sh
STAGING_RPM_DIR="$KOJI_DIR/work/imported-rpms"
STAGING_RPM_SRC_DIR="$STAGING_RPM_DIR/src"
STAGING_RPM_BIN_DIR="$STAGING_RPM_DIR/bin"
STAGING_RPM_DEBUG_DIR="$STAGING_RPM_DIR/debug"
import_koji_pkg() {
local src_dir="$1"
local dst_dir="$2"
local search_pattern="$3"
cp -r "$src_dir" "$dst_dir"
chown -R "$HTTPD_USER":"$HTTPD_USER" "$dst_dir"
find "$dst_dir" -name "$search_pattern" -exec koji import --link {} + > /dev/null
}
if [[ -n "$SRC_RPM_DIR" && -n "$BIN_RPM_DIR" ]]; then
ADMIN_KOJI_DIR="$(echo ~kojiadmin)/.koji"
cp -r "$ADMIN_KOJI_DIR" "$HOME/.koji"
mkdir -p "$STAGING_RPM_DIR"
chown -R "$HTTPD_USER":"$HTTPD_USER" "$STAGING_RPM_DIR"
import_koji_pkg "$SRC_RPM_DIR" "$STAGING_RPM_SRC_DIR" "*.src.rpm"
import_koji_pkg "$BIN_RPM_DIR" "$STAGING_RPM_BIN_DIR" "*.$RPM_ARCH.rpm"
if [[ -n "$DEBUG_RPM_DIR" ]]; then
import_koji_pkg "$DEBUG_RPM_DIR" "$STAGING_RPM_DEBUG_DIR" "*.$RPM_ARCH.rpm"
fi
rm -rf "$STAGING_RPM_DIR" "$HOME/.koji"
fi
# Koozali is the Packager and Vendor
PACKAGER="Koozali.org <http://www.koozali.org>"
VENDOR="Koozali.org <http://www.koozali.org>"
# Setup sme10 for building - based on centos 7 (el7)
# sme10-os is the parent - all other sme10 repos will inherit most of this...
RELEASE="sme10"
DISTRIBUTION="SME Server v$RELEASE"
TAG="dist-$RELEASE-os"
PARENT="$TAG"
DIST=".el7.sme"
PKGMANAGER="yum"
BOOTSTRAPIMAGE="centos:7"
sudo -u kojiadmin koji add-tag --arches="$RPM_ARCH" "$TAG"
sudo -u kojiadmin koji edit-tag "$TAG" -x mock.package_manager=$PKGMANAGER
sudo -u kojiadmin koji edit-tag -x mock.bootstrap_image="$BOOTSTRAPIMAGE" "$TAG"
sudo -u kojiadmin koji edit-tag -x mock.chroot_setup_cmd="$CHROOTSETUPCMD" "$TAG"
sudo -u kojiadmin koji edit-tag -x rpm.macro.distribution="$DISTRIBUTION" "$TAG"
sudo -u kojiadmin koji edit-tag -x rpm.macro.dist="$DIST" "$TAG"
sudo -u kojiadmin koji edit-tag -x rpm.macro.packager="$PACKAGER" "$TAG"
sudo -u kojiadmin koji edit-tag -x rpm.macro.vendor="$VENDOR" "$TAG"
# add build tag for all $RELEASE targets
BUILDTAG="dist-$RELEASE-build"
sudo -u kojiadmin koji add-tag --parent "$PARENT" --arches="$RPM_ARCH" "$BUILDTAG"
sudo -u kojiadmin koji add-group "$BUILDTAG" build
sudo -u kojiadmin koji add-group "$BUILDTAG" srpm-build
sudo -u kojiadmin koji add-group-pkg "$BUILDTAG" build install scl-utils-build python27-build epel-rpm-macros bash bzip2 coreutils cpio diffutils findutils gawk gcc gcc-c++ grep gzip info make patch redhat-rpm-config rpm-build sed shadow-utils tar unzip util-linux which yum-utils xz
sudo -u kojiadmin koji add-group-pkg "$BUILDTAG" srpm-build rpm-build coreutils cpio curl-bin elfutils file git git-lfs glibc-utils grep gzip make pigz plzip rpm sed shadow tar unzip wget xz
sudo -u kojiadmin koji add-external-repo -t "$BUILDTAG" os http://buildsys.koozali.org/build/7/os/\$arch/
sudo -u kojiadmin koji add-external-repo -t "$BUILDTAG" updates http://buildsys.koozali.org/build/7/updates/\$arch/
sudo -u kojiadmin koji add-external-repo -t "$BUILDTAG" smeos http://buildsys.koozali.org/build/10/smeos/\$arch/
sudo -u kojiadmin koji add-external-repo -t "$BUILDTAG" smeupdates http://buildsys.koozali.org/build/10/smeupdates/\$arch/
sudo -u kojiadmin koji add-external-repo -t "$BUILDTAG" fastrack http://buildsys.koozali.org/build/7/fastrack/\$arch/
sudo -u kojiadmin koji add-external-repo -t "$BUILDTAG" opt1 http://buildsys.koozali.org/build/7/opt1/\$arch/
sudo -u kojiadmin koji add-external-repo -t "$BUILDTAG" opt2 http://buildsys.koozali.org/build/7/opt2/\$arch/
sudo -u kojiadmin koji add-external-repo -t "$BUILDTAG" opt3 http://buildsys.koozali.org/build/7/opt3/\$arch/
sudo -u kojiadmin koji add-external-repo -t "$BUILDTAG" epel http://download.fedoraproject.org/pub/epel/7/\$arch/
sudo -u kojiadmin koji add-external-repo -t "$BUILDTAG" openfusion http://repo.openfusion.net/centos7-\$arch/
sudo -u kojiadmin koji add-external-repo -t "$BUILDTAG" rpmfusion http://download1.rpmfusion.org/free/el/updates/7/\$arch/
sudo -u kojiadmin koji add-external-repo -t "$BUILDTAG" sclo-sclo http://mirror.centos.org/centos/7/sclo/\$arch/sclo
sudo -u kojiadmin koji add-external-repo -t "$BUILDTAG" sclo-rh http://mirror.centos.org/centos/7/sclo/\$arch/rh
sudo -u kojiadmin koji add-external-repo -t "$BUILDTAG" buildsys-core http://buildsys.koozali.org/build/10/smeserver-core/\$arch/
sudo -u kojiadmin koji add-external-repo -t "$BUILDTAG" buildsys-contribs http://buildsys.koozali.org/build/10/smeserver-contribs/\$arch/
sudo -u kojiadmin koji add-external-repo -t "$BUILDTAG" groups http://buildsys.koozali.org/build/10/smeserver-groups/\$arch/
sudo -u kojiadmin koji regen-repo "$BUILDTAG" --nowait
# Add in all packages that make up this repo
# do an api call against gitea to list all the repos in smeserver organisation
# sudo -u kojiadmin koji add-pkg "$TAG" $pkglist
# setup the rest of the sme10 repos
for REPO in contribs contribs-testing addons updates updates-testing testing ; do
TAG="dist-$RELEASE-$REPO"
sudo -u kojiadmin koji add-tag --parent "$PARENT" "$TAG"
done
# set up the smeserver and smecontribs targets (i.e. Only build to testing for smeos and smecontribs - others are staging)
sudo -u kojiadmin koji add-target $RELEASE-test "$BUILDTAG" "dist-$RELEASE-testing"
sudo -u kojiadmin koji add-target $RELEASE-contribs-test "$BUILDTAG" "dist-$RELEASE-contribs-testing"
# Release sme11 is based on Rocky 8 (EL8)
RELEASE="11"
DISTRIBUTION="SME Server v$RELEASE"
EL="8"
DIST=".el$EL.sme"
PKGMANAGER="dnf"
BOOTSTRAPIMAGE="rockylinux:$EL"
# setup the external repositories referenced in builds
sudo -u kojiadmin koji add-external-repo smeserver$RELEASE http://koji.koozali.org/kojifiles/repos-dist/$TAG/latest/\$arch/
sudo -u kojiadmin koji add-external-repo os$EL https://dl.rockylinux.org/pub/rocky/$EL/BaseOS/\$arch/os/
# mirrorList=http://mirrors.rockylinux.org/mirrorlist?release=$EL&arch=\$arch&repo=BaseOS-$EL
sudo -u kojiadmin koji add-external-repo appstream$EL https://dl.rockylinux.org/pub/rocky/$EL/AppStream/\$arch/os/
# mirrorlist = https://mirrors.rockylinux.org/mirrorlist?arch=\$arch&repo=AppStream-$EL
sudo -u kojiadmin koji add-external-repo powertools$EL https://dl.rockylinux.org/pub/rocky/$EL/PowerTools/\$arch/os/
# mirrorlist = https://mirrors.rockylinux.org/mirrorlist?arch=\$arch&repo=PowerTools-$EL
sudo -u kojiadmin koji add-external-repo epel$EL https://muug.ca/mirror/fedora-epel/$EL/Everything/\$arch/
# mirrorList=http://mirrors.fedoraproject.org/mirrorlist?repo=epel-$EL&arch=\$arch
sudo -u kojiadmin koji add-external-repo openfusion$EL http://repo.openfusion.net/centos$EL-\$arch/
sudo -u kojiadmin koji add-external-repo rpmfusion$EL http://download1.rpmfusion.org/free/el/updates/$EL/\$arch/
sudo -u kojiadmin koji add-external-repo remi$EL http://rpms.remirepo.net/enterprise/$EL/remi/\$arch/
sudo -u kojiadmin koji add-external-repo remi-modular$EL http://rpms.remirepo.net/enterprise/$EL/modular/\$arch/
sudo -u kojiadmin koji add-external-repo remi-safe$EL http://rpms.remirepo.net/enterprise/$EL/safe/\$arch/
# Setup the os repo - parent of build and testing who will inherit most properties
TAG="smeserver$RELEASE"
PARENT="$TAG"
sudo -u kojiadmin koji add-tag --arches="$RPM_ARCH" "$PARENT"
sudo -u kojiadmin koji edit-tag -x mock.package_manager="$PKGMANAGER" "$PARENT"
sudo -u kojiadmin koji edit-tag -x mock.bootstrap_image="$BOOTSTRAPIMAGE" "$PARENT"
sudo -u kojiadmin koji edit-tag -x rpm.macro.distribution="$DISTRIBUTION" "$PARENT"
sudo -u kojiadmin koji edit-tag -x rpm.macro.dist="$DIST" "$PARENT"
sudo -u kojiadmin koji edit-tag -x rpm.macro.packager="$PACKAGER" "$PARENT"
sudo -u kojiadmin koji edit-tag -x rpm.macro.vendor="$VENDOR" "$PARENT"
# add build tag for smeseserver$RELEASE targets
BUILDTAG="smeserver$RELEASE-build"
sudo -u kojiadmin koji add-tag --parent "$PARENT" --arches="$RPM_ARCH" "$BUILDTAG"
sudo -u kojiadmin koji add-group "$BUILDTAG" build
sudo -u kojiadmin koji add-group-pkg "$BUILDTAG" build epel-rpm-macros bash bzip2 coreutils cpio diffutils findutils gawk gcc gcc-c++ grep gzip info make patch redhat-rpm-config rpm-build sed shadow-utils tar unzip util-linux which yum-utils xz
sudo -u kojiadmin koji add-group "$BUILDTAG" srpm-build
sudo -u kojiadmin koji add-group-pkg "$BUILDTAG" srpm-build coreutils cpio elfutils file grep gzip make pigz rpm rpm-build sed tar unzip wget xz
sudo -u kojiadmin koji add-group "$BUILDTAG" livemedia-build
sudo -u kojiadmin koji add-group-pkg "$BUILDTAG" livemedia-build anaconda bash coreutils dracut-live glibc-all-langpacks lorax-lmc-nonvirt python3-kickstart python3-pycdio selinuc-policy-targeted shadow-utils util-linux
for each repo in os$EL remi-safe$EL remi-modular$EL appstream$EL powertools$EL epel$EL openfusion$EL rpmfusion$EL remi$EL ; do
sudo -u kojiadmin koji add-external-repo -t "$BUILDTAG" -m bare $repo
done
sudo -u kojiadmin koji regen-repo "$BUILDTAG" --nowait
# setup the testing repo - inherit values from os
TAG="smeserver$RELEASE-testing"
sudo -u kojiadmin koji add-tag --parent "$PARENT" "$TAG"
# set up the smeserver targets
sudo -u kojiadmin koji add-target smeserver$RELEASE "$BUILDTAG" "smeserver$RELEASE-testing"
# Setup the contribs repo - parent of build and testing who will inherit most properties
TAG="smecontribs$RELEASE"
PARENT="$TAG"
sudo -u kojiadmin koji add-tag --arches="$RPM_ARCH" "$PARENT"
sudo -u kojiadmin koji edit-tag -x mock.package_manager="$PKGMANAGER" "$PARENT"
sudo -u kojiadmin koji edit-tag -x mock.bootstrap_image="$BOOTSTRAPIMAGE" "$PARENT"
sudo -u kojiadmin koji edit-tag -x rpm.macro.distribution="$DISTRIBUTION" "$PARENT"
sudo -u kojiadmin koji edit-tag -x rpm.macro.dist="$DIST" "$PARENT"
sudo -u kojiadmin koji edit-tag -x rpm.macro.packager="$PACKAGER" "$PARENT"
sudo -u kojiadmin koji edit-tag -x rpm.macro.vendor="$VENDOR" "$PARENT"
# add build tag for smecontribs$RELEASE targets
BUILDTAG="smecontribs$RELEASE-build"
sudo -u kojiadmin koji add-tag --parent "$PARENT" --arches="$RPM_ARCH" "$BUILDTAG"
sudo -u kojiadmin koji add-group "$BUILDTAG" build
sudo -u kojiadmin koji add-group-pkg "$BUILDTAG" build epel-rpm-macros bash bzip2 coreutils cpio diffutils findutils gawk gcc gcc-c++ grep gzip info make patch redhat-rpm-config rpm-build sed shadow-utils tar unzip util-linux which yum-utils xz
sudo -u kojiadmin koji add-group "$BUILDTAG" srpm-build
sudo -u kojiadmin koji add-group-pkg "$BUILDTAG" srpm-build coreutils cpio elfutils file grep gzip make pigz rpm rpm-build sed tar unzip wget xz
sudo -u kojiadmin koji add-group "$BUILDTAG" livemedia-build
sudo -u kojiadmin koji add-group-pkg "$BUILDTAG" livemedia-build anaconda bash coreutils dracut-live glibc-all-langpacks lorax-lmc-nonvirt python3-kickstart python3-pycdio selinuc-policy-targeted shadow-utils util-linux
for each repo in smeserver$RELEASE os$EL remi-safe$EL remi-modular$EL appstream$EL powertools$EL epel$EL openfusion$EL rpmfusion$EL remi$EL ; do
sudo -u kojiadmin koji add-external-repo -t "$BUILDTAG" -m bare $repo
done
sudo -u kojiadmin koji regen-repo "$BUILDTAG" --nowait
# setup the testing repo - inherit values from os
TAG="smecontribs$RELEASE-testing"
sudo -u kojiadmin koji add-tag --parent "$PARENT" "$TAG"
# set up the smecontribs targets
sudo -u kojiadmin koji add-target smecontribs$RELEASE "$BUILDTAG" "smecontribs$RELEASE-testing"
# Release sme12 is based on Rocky 9 (EL9)
RELEASE="12"
DISTRIBUTION="SME Server v$RELEASE"
EL="9"
DIST=".el$EL.sme"
PKGMANAGER="dnf"
BOOTSTRAPIMAGE="rockylinux:$EL"
sudo -u kojiadmin koji add-external-repo smeserver$RELEASE http://koji.koozali.org/kojifiles/repos-dist/$TAG/latest/\$arch/
sudo -u kojiadmin koji add-external-repo os$EL https://dl.rockylinux.org/pub/rocky/$EL/BaseOS/\$arch/os/
# mirrorList=http://mirrors.rockylinux.org/mirrorlist?release=$EL&arch=\$arch&repo=BaseOS-$EL
sudo -u kojiadmin koji add-external-repo appstream$EL https://dl.rockylinux.org/pub/rocky/$EL/AppStream/\$arch/os/
# mirrorlist = https://mirrors.rockylinux.org/mirrorlist?arch=\$arch&repo=AppStream-$EL
sudo -u kojiadmin koji add-external-repo powertools$EL https://dl.rockylinux.org/pub/rocky/$EL/PowerTools/\$arch/os/
# mirrorlist = https://mirrors.rockylinux.org/mirrorlist?arch=\$arch&repo=PowerTools-$EL
sudo -u kojiadmin koji add-external-repo epel$EL https://muug.ca/mirror/fedora-epel/$EL/Everything/\$arch/
# mirrorList=http://mirrors.fedoraproject.org/mirrorlist?repo=epel-$EL&arch=\$arch
sudo -u kojiadmin koji add-external-repo openfusion$EL http://repo.openfusion.net/centos$EL-\$arch/
sudo -u kojiadmin koji add-external-repo rpmfusion$EL http://download1.rpmfusion.org/free/el/updates/$EL/\$arch/
# Setup the os repo - parent of others who will inherit most properties
TAG="smeserver$RELEASE"
PARENT="$TAG"
sudo -u kojiadmin koji add-tag --arches="$RPM_ARCH" "$TAG"
sudo -u kojiadmin koji edit-tag "$TAG" -x mock.package_manager="$PKGMANAGER"
sudo -u kojiadmin koji edit-tag -x mock.bootstrap_image="$BOOTSTRAPIMAGE" "$TAG"
sudo -u kojiadmin koji edit-tag -x rpm.macro.distribution="$DISTRIBUTION" "$TAG"
sudo -u kojiadmin koji edit-tag -x rpm.macro.dist="$DIST" "$TAG"
sudo -u kojiadmin koji edit-tag -x rpm.macro.packager="$PACKAGER" "$TAG"
sudo -u kojiadmin koji edit-tag -x rpm.macro.vendor="$VENDOR" "$TAG"
# add build tag for all $RELEASE targets
BUILDTAG="smeserver$RELEASE-build"
sudo -u kojiadmin koji add-tag --parent "$PARENT" --arches="$RPM_ARCH" "$BUILDTAG"
sudo -u kojiadmin koji add-group "$BUILDTAG" build
sudo -u kojiadmin koji add-group-pkg "$BUILDTAG" build epel-rpm-macros bash bzip2 coreutils cpio diffutils findutils gawk gcc gcc-c++ grep gzip info make patch redhat-rpm-config rpm-build sed shadow-utils tar unzip util-linux which yum-utils xz
sudo -u kojiadmin koji add-group "$BUILDTAG" srpm-build
sudo -u kojiadmin koji add-group-pkg "$BUILDTAG" srpm-build coreutils cpio elfutils file grep gzip make pigz rpm rpm-build sed tar unzip wget xz
sudo -u kojiadmin koji add-group "$BUILDTAG" livemedia-build
sudo -u kojiadmin koji add-group-pkg "$BUILDTAG" livemedia-build anaconda bash coreutils dracut-live glibc-all-langpacks lorax-lmc-nonvirt python3-kickstart python3-pycdio selinuc-policy-targeted shadow-utils util-linux
for each repo in os$EL appstream$EL epel$EL openfusion$EL rpmfusion$EL ; do
sudo -u kojiadmin koji add-external-repo -t "$BUILDTAG" -m bare $repo
done
sudo -u kojiadmin koji regen-repo "$BUILDTAG" --nowait
# setup the rest of the repos - all inherit values from os
TAG="smeserver$RELEASE-testing"
sudo -u kojiadmin koji add-tag --parent "$PARENT" "$TAG"
# set up the smeserver targets
sudo -u kojiadmin koji add-target smeserver$RELEASE "$BUILDTAG" "smeserver$RELEASE-testing"
# Setup the contribs repo - parent of others who will inherit most properties
TAG="smecontribs$RELEASE"
PARENT="$TAG"
sudo -u kojiadmin koji add-tag --arches="$RPM_ARCH" "$TAG"
sudo -u kojiadmin koji edit-tag "$TAG" -x mock.package_manager="$PKGMANAGER"
sudo -u kojiadmin koji edit-tag -x mock.bootstrap_image="$BOOTSTRAPIMAGE" "$TAG"
sudo -u kojiadmin koji edit-tag -x rpm.macro.distribution="$DISTRIBUTION" "$TAG"
sudo -u kojiadmin koji edit-tag -x rpm.macro.dist="$DIST" "$TAG"
sudo -u kojiadmin koji edit-tag -x rpm.macro.packager="$PACKAGER" "$TAG"
sudo -u kojiadmin koji edit-tag -x rpm.macro.vendor="$VENDOR" "$TAG"
# add build tag for all $RELEASE targets
BUILDTAG="smecontribs$RELEASE-build"
sudo -u kojiadmin koji add-tag --parent "$PARENT" --arches="$RPM_ARCH" "$BUILDTAG"
sudo -u kojiadmin koji add-group "$BUILDTAG" build
sudo -u kojiadmin koji add-group-pkg "$BUILDTAG" build epel-rpm-macros bash bzip2 coreutils cpio diffutils findutils gawk gcc gcc-c++ grep gzip info make patch redhat-rpm-config rpm-build sed shadow-utils tar unzip util-linux which yum-utils xz
sudo -u kojiadmin koji add-group "$BUILDTAG" srpm-build
sudo -u kojiadmin koji add-group-pkg "$BUILDTAG" srpm-build coreutils cpio elfutils file grep gzip make pigz rpm rpm-build sed tar unzip wget xz
sudo -u kojiadmin koji add-group "$BUILDTAG" livemedia-build
sudo -u kojiadmin koji add-group-pkg "$BUILDTAG" livemedia-build anaconda bash coreutils dracut-live glibc-all-langpacks lorax-lmc-nonvirt python3-kickstart python3-pycdio selinuc-policy-targeted shadow-utils util-linux
for each repo in smeserver$RELEASE os$EL appstream$EL epel$EL openfusion$EL rpmfusion$EL ; do
sudo -u kojiadmin koji add-external-repo -t "$BUILDTAG" -m bare $repo
done
sudo -u kojiadmin koji regen-repo "$BUILDTAG" --nowait
# setup the rest of the repos - all inherit values from os
TAG="smecontribs$RELEASE-testing"
sudo -u kojiadmin koji add-tag --parent "$PARENT" "$TAG"
# set up the smecontribs targets
sudo -u kojiadmin koji add-target smecontribs$RELEASE "$BUILDTAG" "smecontribs$RELEASE-testing"