|
Thomas Oulevey |
79d958 |
#!/bin/bash
|
|
Thomas Oulevey |
79d958 |
|
|
Thomas Oulevey |
79d958 |
usage()
|
|
Thomas Oulevey |
79d958 |
{
|
|
Thomas Oulevey |
79d958 |
cat << EOF
|
|
Thomas Oulevey |
79d958 |
usage: $0 -d <distribution> -s <signame(s)> -t <tag(s)>
|
|
Thomas Oulevey |
79d958 |
|
|
Thomas Oulevey |
79d958 |
This script generate new build target in koji for SIGS.
|
|
Thomas Oulevey |
79d958 |
|
|
Thomas Oulevey |
79d958 |
OPTIONS:
|
|
Thomas Oulevey |
79d958 |
-d Distribution : 5 6 7
|
|
Thomas Oulevey |
79d958 |
-s SIG name : bananas, storage
|
|
Thomas Oulevey |
79d958 |
-t DISTTAGS : "el7 el7.centos el7_0"
|
|
Thomas Oulevey |
3946d6 |
-c COLLECTION : mariadb100 (a single collection can be used at this time)
|
|
Thomas Oulevey |
79d958 |
EOF
|
|
Thomas Oulevey |
79d958 |
}
|
|
Thomas Oulevey |
79d958 |
|
|
Thomas Oulevey |
79d958 |
optiond=false
|
|
Thomas Oulevey |
79d958 |
options=false
|
|
Thomas Oulevey |
79d958 |
optiont=false
|
|
Thomas Oulevey |
3946d6 |
optionc=false
|
|
Thomas Oulevey |
79d958 |
|
|
Thomas Oulevey |
3946d6 |
while getopts ":hd:s:t:c:" OPTION
|
|
Thomas Oulevey |
79d958 |
do
|
|
Thomas Oulevey |
79d958 |
case $OPTION in
|
|
Thomas Oulevey |
79d958 |
h)
|
|
Thomas Oulevey |
79d958 |
usage
|
|
Thomas Oulevey |
79d958 |
exit 0
|
|
Thomas Oulevey |
79d958 |
;;
|
|
Thomas Oulevey |
79d958 |
d)
|
|
Thomas Oulevey |
79d958 |
optiond=true
|
|
Thomas Oulevey |
79d958 |
DISTS="${OPTARG}"
|
|
Thomas Oulevey |
79d958 |
;;
|
|
Thomas Oulevey |
79d958 |
s)
|
|
Thomas Oulevey |
79d958 |
options=true
|
|
Thomas Oulevey |
79d958 |
SIGS="${OPTARG}"
|
|
Thomas Oulevey |
79d958 |
;;
|
|
Thomas Oulevey |
79d958 |
t)
|
|
Thomas Oulevey |
79d958 |
optiont=true
|
|
Thomas Oulevey |
79d958 |
TAGS="${OPTARG}"
|
|
Thomas Oulevey |
79d958 |
;;
|
|
Thomas Oulevey |
3946d6 |
c)
|
|
Thomas Oulevey |
3946d6 |
optionc=true
|
|
Thomas Oulevey |
3946d6 |
COLLECTIONS="${OPTARG}"
|
|
Thomas Oulevey |
3946d6 |
;;
|
|
Thomas Oulevey |
79d958 |
?)
|
|
Thomas Oulevey |
79d958 |
exit 0
|
|
Thomas Oulevey |
79d958 |
;;
|
|
Thomas Oulevey |
79d958 |
:)
|
|
Thomas Oulevey |
79d958 |
echo "Option -$OPTARG requires an argument."
|
|
Thomas Oulevey |
79d958 |
exit 1
|
|
Thomas Oulevey |
79d958 |
;;
|
|
Thomas Oulevey |
79d958 |
esac
|
|
Thomas Oulevey |
79d958 |
done
|
|
Thomas Oulevey |
79d958 |
|
|
Thomas Oulevey |
79d958 |
shift $(($OPTIND - 1))
|
|
Thomas Oulevey |
79d958 |
|
|
Thomas Oulevey |
79d958 |
if ! ( $optiond && $options && $optiont )
|
|
Thomas Oulevey |
79d958 |
then
|
|
Thomas Oulevey |
79d958 |
usage
|
|
Thomas Oulevey |
79d958 |
exit 0
|
|
Thomas Oulevey |
79d958 |
fi
|
|
Thomas Oulevey |
79d958 |
|
|
Thomas Oulevey |
79d958 |
# Check if user is allowed to send command to koji and has 'admin' permission
|
|
Thomas Oulevey |
79d958 |
KOJI=`which koji`
|
|
Thomas Oulevey |
79d958 |
PERM=`$KOJI list-permissions --mine`
|
|
Thomas Oulevey |
79d958 |
if [ "$PERM" != "admin" ]
|
|
Thomas Oulevey |
79d958 |
then
|
|
Thomas Oulevey |
79d958 |
echo "[ERROR] Koji misconfigure/missing admin privilege for creating SIG tags"
|
|
Thomas Oulevey |
79d958 |
exit 1
|
|
Thomas Oulevey |
79d958 |
fi
|
|
Thomas Oulevey |
79d958 |
|
|
Thomas Oulevey |
79d958 |
for DIST in $DISTS
|
|
Thomas Oulevey |
79d958 |
do
|
|
Thomas Oulevey |
79d958 |
|
|
Thomas Oulevey |
79d958 |
case $DIST in
|
|
Thomas Oulevey |
79d958 |
5) echo "* Checking distribution el$DIST configuration..."; ARCHES="i386 x86_64"; DEFAULT_DISTTAG="el5"
|
|
Thomas Oulevey |
79d958 |
;;
|
|
Thomas Oulevey |
79d958 |
6) echo "* Checking distribution el$DIST configuration..."; ARCHES="i686 x86_64"; DEFAULT_DISTTAG="el6"
|
|
Thomas Oulevey |
79d958 |
;;
|
|
Thomas Oulevey |
79d958 |
7) echo "* Checking distribution el$DIST configuration..."; ARCHES="x86_64"; DEFAULT_DISTTAG="el7.centos"
|
|
Thomas Oulevey |
79d958 |
;;
|
|
Thomas Oulevey |
79d958 |
*) echo "It seems your distribution el${DIST} is unsupported" && continue
|
|
Thomas Oulevey |
79d958 |
;;
|
|
Thomas Oulevey |
79d958 |
esac
|
|
Thomas Oulevey |
79d958 |
|
|
Thomas Oulevey |
79d958 |
$KOJI list-tags | grep buildsys${DIST} &> /dev/null
|
|
Thomas Oulevey |
79d958 |
[ $? -gt 0 ] && echo " -> [ERROR] Something is wrong buildsys${DIST} tag not found." && continue
|
|
Thomas Oulevey |
79d958 |
|
|
Thomas Oulevey |
79d958 |
$KOJI list-external-repos | grep ^centos${DIST}-os &> /dev/null
|
|
Thomas Oulevey |
79d958 |
[ $? -gt 0 ] && echo " -> [ERROR] centos${DIST}-os external repo not configured in koji." && continue
|
|
Thomas Oulevey |
79d958 |
|
|
Thomas Oulevey |
79d958 |
$KOJI list-external-repos | grep ^centos${DIST}-updates &> /dev/null
|
|
Thomas Oulevey |
79d958 |
[ $? -gt 0 ] && echo " -> [ERROR] centos${DIST}-updates external repo not configured in koji." && continue
|
|
Thomas Oulevey |
79d958 |
|
|
Thomas Oulevey |
79d958 |
for SIG in $SIGS
|
|
Thomas Oulevey |
79d958 |
do
|
|
Thomas Oulevey |
79d958 |
echo " -> Checking $SIG config..."
|
|
Thomas Oulevey |
79d958 |
$KOJI add-user $SIG &> /dev/null
|
|
Thomas Oulevey |
79d958 |
[ $? -eq 0 ] && echo "Creating user : ${SIG}"
|
|
Thomas Oulevey |
79d958 |
SIG="${SIG}${DIST}"
|
|
Thomas Oulevey |
79d958 |
$KOJI list-tags | grep $SIG-testing &> /dev/null
|
|
Thomas Oulevey |
79d958 |
[ $? -gt 0 ] && echo "Creating tag : ${SIG}-testing" && $KOJI add-tag $SIG-testing
|
|
Thomas Oulevey |
79d958 |
$KOJI list-tags | grep $SIG-release &> /dev/null
|
|
Thomas Oulevey |
79d958 |
[ $? -gt 0 ] && echo "Creating tag : ${SIG}-release" && $KOJI add-tag $SIG-release
|
|
Thomas Oulevey |
79d958 |
|
|
Thomas Oulevey |
79d958 |
for TAG in $TAGS
|
|
Thomas Oulevey |
79d958 |
do
|
|
Thomas Oulevey |
3946d6 |
# Add collection support abuse TAG variable
|
|
Thomas Oulevey |
3946d6 |
REALTAG=$TAG
|
|
Thomas Oulevey |
3946d6 |
if ( $optionc )
|
|
Thomas Oulevey |
3946d6 |
then
|
|
Thomas Oulevey |
3946d6 |
TAG="$TAG-$COLLECTIONS"
|
|
Thomas Oulevey |
3946d6 |
fi
|
|
Thomas Oulevey |
79d958 |
$KOJI list-tags | grep $SIG-$TAG-build &> /dev/null
|
|
Thomas Oulevey |
79d958 |
[ $? -eq 0 ] && echo " -> $SIG-$TAG target already exists. skipping." && continue
|
|
Thomas Oulevey |
79d958 |
echo " -> creating $SIG-$TAG"
|
|
Thomas Oulevey |
79d958 |
$KOJI add-tag --arches "$ARCHES" $SIG-$TAG-build
|
|
Thomas Oulevey |
79d958 |
$KOJI add-target $SIG-$TAG $SIG-$TAG-build $SIG-testing
|
|
Thomas Oulevey |
79d958 |
$KOJI add-external-repo --tag=$SIG-$TAG-build centos${DIST}-updates
|
|
Thomas Oulevey |
3946d6 |
$KOJI add-external-repo --tag=$SIG-$TAG-build centos${DIST}-os
|
|
Thomas Oulevey |
79d958 |
$KOJI add-group $SIG-$TAG-build build
|
|
Thomas Oulevey |
79d958 |
$KOJI add-group $SIG-$TAG-build srpm-build
|
|
Thomas Oulevey |
3946d6 |
# Add <collection>-build to the buildroot if collection enabled
|
|
Thomas Oulevey |
3946d6 |
if ( $optionc )
|
|
Thomas Oulevey |
3946d6 |
then
|
|
Thomas Oulevey |
743abd |
$KOJI add-group-pkg $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
|
|
Thomas Oulevey |
3946d6 |
$KOJI add-group-pkg $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
|
|
Thomas Oulevey |
3946d6 |
else
|
|
Thomas Oulevey |
743abd |
$KOJI add-group-pkg $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
|
|
Thomas Oulevey |
3946d6 |
$KOJI add-group-pkg $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
|
|
Thomas Oulevey |
3946d6 |
fi
|
|
Thomas Oulevey |
79d958 |
$KOJI add-tag-inheritance --priority 1 $SIG-$TAG-build buildsys${DIST}
|
|
Thomas Oulevey |
79d958 |
$KOJI add-tag-inheritance --priority 2 $SIG-$TAG-build $SIG-testing
|
|
Thomas Oulevey |
3946d6 |
$KOJI list-tagged buildsys${DIST} | grep buildsys-macros-$REALTAG &> /dev/null
|
|
Thomas Oulevey |
79d958 |
if [ $? -gt 0 ]
|
|
Thomas Oulevey |
79d958 |
then
|
|
Thomas Oulevey |
3946d6 |
if [ "x$REALTAG" != "x$DEFAULT_DISTTAG" ]
|
|
Thomas Oulevey |
79d958 |
then
|
|
Thomas Oulevey |
3946d6 |
echo " -> [WARN] buildsys-macros-$REALTAG rpm not found. Please build it within koji."
|
|
Thomas Oulevey |
79d958 |
[ -f $PWD/etc/buildsys.spec.template ] && echo " -> Generating buildsys-macros-$TAG.spec"
|
|
Thomas Oulevey |
79d958 |
fi
|
|
Thomas Oulevey |
79d958 |
fi
|
|
Thomas Oulevey |
79d958 |
done
|
|
Thomas Oulevey |
79d958 |
done
|
|
Thomas Oulevey |
79d958 |
done
|