| #!/bin/bash |
| |
| usage() |
| { |
| cat << EOF |
| usage: $0 -d <distribution> -s <signame(s)> -t <tag(s)> |
| |
| This script generate new build target in koji for SIGS. |
| |
| OPTIONS: |
| -a ARCHES : Force arches e.g : "x86_64","aarch64 i686", etc... |
| -b : Enable non public bootstrap repo (SCLO SIG only) |
| -c COLLECTION : Enable collection in the buildroot |
| e.g : mariadb100 |
| A single collection can be used at this time. |
| -d DISTRIBUTION : 5 6 7 |
| -p SIG PROJECT NAME : cloud6-<openstack>, sclo-<mariadb100>, etc... |
| -r SIG PROJECT RELEASE NAME : cloud6-openstack-<juno> |
| -s SIG NAME : cloud |
| -t DISTTAGS : "el7 el7.centos el7_0" |
| -x : delete old -build tag and then recreate. |
| EOF |
| } |
| |
| optiona=false |
| optionb=false |
| optiond=false |
| options=false |
| optiont=false |
| optionc=false |
| optionp=false |
| optionr=false |
| optionx=false |
| |
| while getopts ":hxba:d:s:t:c:p:r:" OPTION |
| do |
| case $OPTION in |
| h) |
| usage |
| exit 0 |
| ;; |
| a) |
| optiona=true |
| ARCHES="${OPTARG}" |
| ;; |
| b) |
| optionb=true |
| ;; |
| d) |
| optiond=true |
| DISTS="${OPTARG}" |
| ;; |
| s) |
| options=true |
| SIGS="${OPTARG}" |
| ;; |
| r) |
| optionr=true |
| RELEASES="${OPTARG}" |
| ;; |
| p) |
| optionp=true |
| PROJECTS="${OPTARG}" |
| ;; |
| t) |
| optiont=true |
| TAGS="${OPTARG}" |
| ;; |
| c) |
| optionc=true |
| COLLECTIONS="${OPTARG}" |
| ;; |
| x) |
| optionx=true |
| ;; |
| ?) |
| exit 0 |
| ;; |
| :) |
| echo "Option -$OPTARG requires an argument." |
| exit 1 |
| ;; |
| esac |
| done |
| |
| shift $(($OPTIND - 1)) |
| |
| if ! ( $optiond && $options && $optiont ) |
| then |
| usage |
| exit 0 |
| fi |
| |
| |
| KOJI=`which koji` |
| PERMS=`$KOJI list-permissions --mine` |
| ADMIN=false |
| |
| for P in $PERMS |
| do |
| [[ $P == 'admin' ]] && ADMIN=true; break |
| done |
| |
| if [ "$ADMIN" != true ] |
| then |
| echo "[ERROR] Koji misconfigure/missing admin privilege for creating SIG tags" |
| exit 1 |
| fi |
| |
| for DIST in $DISTS |
| do |
| |
| case $DIST in |
| 5) echo "* Checking distribution el$DIST configuration..."; ( ! $optiona ) && ARCHES="i386 x86_64"; DEFAULT_DISTTAG="el5" |
| ;; |
| 6) echo "* Checking distribution el$DIST configuration..."; ( ! $optiona ) && ARCHES="i686 x86_64"; DEFAULT_DISTTAG="el6" |
| ;; |
| 7) echo "* Checking distribution el$DIST configuration..."; ( ! $optiona ) && ARCHES="x86_64"; DEFAULT_DISTTAG="el7.centos" |
| ;; |
| *) echo "It seems your distribution el${DIST} is unsupported" && continue |
| ;; |
| esac |
| |
| $KOJI list-tags | grep buildsys${DIST} &> /dev/null |
| [ $? -gt 0 ] && echo " -> [ERROR] Something is wrong buildsys${DIST} tag not found." && continue |
| |
| $KOJI list-external-repos | grep ^centos${DIST}-os &> /dev/null |
| [ $? -gt 0 ] && echo " -> [ERROR] centos${DIST}-os external repo not configured in koji." && continue |
| |
| $KOJI list-external-repos | grep ^centos${DIST}-updates &> /dev/null |
| [ $? -gt 0 ] && echo " -> [ERROR] centos${DIST}-updates external repo not configured in koji." && continue |
| |
| for SIG in $SIGS |
| do |
| echo " -> Checking $SIG config..." |
| $KOJI add-user $SIG &> /dev/null |
| [ $? -eq 0 ] && echo "Creating user : ${SIG}" && $KOJI grant-permission --new build-${SIG} $SIG |
| SIGNAME="${SIG}" |
| SIG="${SIG}${DIST}" |
| for PROJECT in $PROJECTS |
| do |
| P_SIG="${SIG}-${PROJECT}" |
| |
| |
| |
| |
| |
| |
| |
| |
| for RELEASE in $RELEASES |
| do |
| R_SIG="${P_SIG}-${RELEASE}" |
| $KOJI list-tags | grep $R_SIG-candidate &> /dev/null |
| [ $? -gt 0 ] && echo "Creating tag : ${R_SIG}-candidate" && $KOJI add-tag $R_SIG-candidate |
| $KOJI list-tags | grep $R_SIG-testing &> /dev/null |
| [ $? -gt 0 ] && echo "Creating tag : ${R_SIG}-testing" && $KOJI add-tag $R_SIG-testing |
| $KOJI list-tags | grep $R_SIG-release &> /dev/null |
| [ $? -gt 0 ] && echo "Creating tag : ${R_SIG}-release" && $KOJI add-tag $R_SIG-release |
| |
| for TAG in $TAGS |
| do |
| |
| REALTAG=$TAG |
| if ( $optionc ) |
| then |
| |
| |
| TAG="$TAG" |
| fi |
| $KOJI list-tags | grep $R_SIG-$TAG-build &> /dev/null |
| if [ $? -eq 0 ] |
| then |
| if ( $optionx ) |
| then |
| echo " -> deleting buildroot $R_SIG-$TAG-build" |
| $KOJI remove-tag $R_SIG-$TAG-build |
| else |
| echo " -> $R_SIG-$TAG-build tag already exists. skipping." && continue |
| fi |
| fi |
| echo " -> creating $R_SIG-$TAG" |
| $KOJI add-tag --arches "$ARCHES" $R_SIG-$TAG-build |
| $KOJI add-target $R_SIG-$TAG $R_SIG-$TAG-build $R_SIG-candidate |
| |
| $KOJI add-external-repo --tag=$R_SIG-$TAG-build centos${DIST}-updates |
| |
| $KOJI add-external-repo --tag=$R_SIG-$TAG-build centos${DIST}-os |
| |
| if ( $optionb ) |
| then |
| |
| if [ "x${SIGNAME}" == "xsclo" ] |
| then |
| |
| $KOJI add-external-repo --tag=$R_SIG-$TAG-build sclo${DIST}-bootstrap |
| fi |
| |
| |
| |
| |
| fi |
| |
| $KOJI add-group $R_SIG-$TAG-build build |
| $KOJI add-group $R_SIG-$TAG-build srpm-build |
| |
| if ( $optionc ) |
| then |
| $KOJI add-group-pkg $R_SIG-$TAG-build build bash bzip2 coreutils cpio diffutils redhat-release findutils gawk gcc gcc-c++ grep gzip info make patch redhat-rpm-config rpm-build sed shadow-utils tar unzip util-linux-ng which buildsys-macros-$REALTAG tar buildsys-tools $COLLECTIONS-build scl-utils-build |
| $KOJI add-group-pkg $R_SIG-$TAG-build srpm-build bash buildsys-macros curl cvs redhat-release gnupg make redhat-rpm-config rpm-build shadow-utils buildsys-macros-$REALTAG tar buildsys-tools $COLLECTIONS-build scl-utils-build |
| else |
| $KOJI add-group-pkg $R_SIG-$TAG-build build bash bzip2 coreutils cpio diffutils redhat-release findutils gawk gcc gcc-c++ grep gzip info make patch redhat-rpm-config rpm-build sed shadow-utils tar unzip util-linux-ng which buildsys-macros-$REALTAG tar buildsys-tools |
| $KOJI add-group-pkg $R_SIG-$TAG-build srpm-build bash buildsys-macros curl cvs redhat-release gnupg make redhat-rpm-config rpm-build shadow-utils buildsys-macros-$REALTAG tar buildsys-tools |
| fi |
| $KOJI add-tag-inheritance --priority 5 $R_SIG-$TAG-build buildsys${DIST} |
| $KOJI add-tag-inheritance --priority 10 $R_SIG-$TAG-build $R_SIG-candidate |
| |
| if [ "x$RELEASE" != "xcommon" ] |
| then |
| $KOJI list-tags | grep $P_SIG-common-candidate &> /dev/null |
| [ $? -eq 0 ] && echo "Adding $P_SIG-common-candidate as inheritance" && $KOJI add-tag-inheritance --priority 15 $R_SIG-$TAG-build $P_SIG-common-candidate |
| fi |
| |
| $KOJI list-tags | grep $SIG-common-candidate &> /dev/null |
| [ $? -eq 0 ] && echo "Adding $SIG-common-candidate as inheritance" && $KOJI add-tag-inheritance --priority 20 $R_SIG-$TAG-build $SIG-common-candidate |
| |
| $KOJI list-tagged buildsys${DIST} | grep buildsys-macros-$REALTAG &> /dev/null |
| if [ $? -gt 0 ] |
| then |
| if [ "x$REALTAG" != "x$DEFAULT_DISTTAG" ] |
| then |
| echo " -> [WARN] buildsys-macros-$REALTAG rpm not found. Please build it within koji on target buildsys${DIST}" |
| |
| [ -f $PWD/etc/buildsys.spec.template ] && echo " -> Generating buildsys-macros-$TAG.spec" |
| fi |
| fi |
| done |
| done |
| done |
| done |
| done |