|
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 |
83c282 |
-d Distribution : 5 6 7
|
|
Thomas Oulevey |
83c282 |
-s SIG name : cloud
|
|
Thomas Oulevey |
83c282 |
-p SIG project name : cloud6-<openstack>, sclo-<mariadb100>, etc...
|
|
Thomas Oulevey |
83c282 |
-r SIG project release name : cloud6-openstack-<juno>
|
|
Thomas Oulevey |
83c282 |
-t DISTTAGS : "el7 el7.centos el7_0"
|
|
Thomas Oulevey |
83c282 |
-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 |
83c282 |
optionp=false
|
|
Thomas Oulevey |
83c282 |
optionr=false
|
|
Thomas Oulevey |
79d958 |
|
|
Thomas Oulevey |
83c282 |
while getopts ":hd:s:t:c:p:r:" 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 |
83c282 |
r)
|
|
Thomas Oulevey |
83c282 |
optionr=true
|
|
Thomas Oulevey |
83c282 |
RELEASES="${OPTARG}"
|
|
Thomas Oulevey |
83c282 |
;;
|
|
Thomas Oulevey |
83c282 |
p)
|
|
Thomas Oulevey |
83c282 |
optionp=true
|
|
Thomas Oulevey |
83c282 |
PROJECTS="${OPTARG}"
|
|
Thomas Oulevey |
83c282 |
;;
|
|
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 |
83c282 |
for PROJECT in $PROJECTS
|
|
Thomas Oulevey |
79d958 |
do
|
|
Thomas Oulevey |
83c282 |
P_SIG="${SIG}-${PROJECT}"
|
|
Thomas Oulevey |
83c282 |
# Check for -common
|
|
Thomas Oulevey |
83c282 |
#$KOJI list-tags | grep $P_SIG-common-candidate &> /dev/null
|
|
Thomas Oulevey |
83c282 |
#if [ $? -gt 0 ]
|
|
Thomas Oulevey |
83c282 |
#then
|
|
Thomas Oulevey |
83c282 |
# echo "Creating tag : ${P_SIG}-common"
|
|
Thomas Oulevey |
83c282 |
# $KOJI add-tag $P_SIG-common-candidate
|
|
Thomas Oulevey |
83c282 |
#
|
|
Thomas Oulevey |
83c282 |
#fi
|
|
Thomas Oulevey |
83c282 |
for RELEASE in $RELEASES
|
|
Thomas Oulevey |
83c282 |
do
|
|
Thomas Oulevey |
83c282 |
R_SIG="${P_SIG}-${RELEASE}"
|
|
Thomas Oulevey |
83c282 |
$KOJI list-tags | grep $R_SIG-candidate &> /dev/null
|
|
Thomas Oulevey |
83c282 |
[ $? -gt 0 ] && echo "Creating tag : ${R_SIG}-candidate" && $KOJI add-tag $R_SIG-testing
|
|
Thomas Oulevey |
83c282 |
$KOJI list-tags | grep $R_SIG-testing &> /dev/null
|
|
Thomas Oulevey |
83c282 |
[ $? -gt 0 ] && echo "Creating tag : ${R_SIG}-testing" && $KOJI add-tag $R_SIG-testing
|
|
Thomas Oulevey |
83c282 |
$KOJI list-tags | grep $R_SIG-release &> /dev/null
|
|
Thomas Oulevey |
83c282 |
[ $? -gt 0 ] && echo "Creating tag : ${R_SIG}-release" && $KOJI add-tag $R_SIG-release
|
|
Thomas Oulevey |
83c282 |
|
|
Thomas Oulevey |
83c282 |
for TAG in $TAGS
|
|
Thomas Oulevey |
83c282 |
do
|
|
Thomas Oulevey |
83c282 |
# Add collection support abuse TAG variable
|
|
Thomas Oulevey |
83c282 |
REALTAG=$TAG
|
|
Thomas Oulevey |
83c282 |
if ( $optionc )
|
|
Thomas Oulevey |
83c282 |
then
|
|
Thomas Oulevey |
83c282 |
TAG="$TAG-$COLLECTIONS"
|
|
Thomas Oulevey |
83c282 |
fi
|
|
Thomas Oulevey |
83c282 |
$KOJI list-tags | grep $R_SIG-$TAG-build &> /dev/null
|
|
Thomas Oulevey |
83c282 |
[ $? -eq 0 ] && echo " -> $R_SIG-$TAG target already exists. skipping." && continue
|
|
Thomas Oulevey |
83c282 |
echo " -> creating $R_SIG-$TAG"
|
|
Thomas Oulevey |
83c282 |
$KOJI add-tag --arches "$ARCHES" $R_SIG-$TAG-build
|
|
Thomas Oulevey |
83c282 |
$KOJI add-target $R_SIG-$TAG $R_SIG-$TAG-build $R_SIG-candidate
|
|
Thomas Oulevey |
83c282 |
$KOJI add-external-repo --tag=$R_SIG-$TAG-build centos${DIST}-updates
|
|
Thomas Oulevey |
83c282 |
$KOJI add-external-repo --tag=$R_SIG-$TAG-build centos${DIST}-os
|
|
Thomas Oulevey |
83c282 |
$KOJI add-group $R_SIG-$TAG-build build
|
|
Thomas Oulevey |
83c282 |
$KOJI add-group $R_SIG-$TAG-build srpm-build
|
|
Thomas Oulevey |
83c282 |
# Add <collection>-build to the buildroot if collection enabled
|
|
Thomas Oulevey |
83c282 |
if ( $optionc )
|
|
Thomas Oulevey |
83c282 |
then
|
|
Thomas Oulevey |
83c282 |
$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
|
|
Thomas Oulevey |
83c282 |
$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
|
|
Thomas Oulevey |
83c282 |
else
|
|
Thomas Oulevey |
83c282 |
$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
|
|
Thomas Oulevey |
83c282 |
$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
|
|
Thomas Oulevey |
83c282 |
fi
|
|
Thomas Oulevey |
83c282 |
$KOJI add-tag-inheritance --priority 5 $R_SIG-$TAG-build buildsys${DIST}
|
|
Thomas Oulevey |
83c282 |
$KOJI add-tag-inheritance --priority 10 $R_SIG-$TAG-build $R_SIG-candidate
|
|
Thomas Oulevey |
83c282 |
# If -common exists for the project add it
|
|
Thomas Oulevey |
83c282 |
if [ "x$RELEASE" != "xcommon" ]
|
|
Thomas Oulevey |
83c282 |
then
|
|
Thomas Oulevey |
6558fb |
$KOJI list-tags | grep $P_SIG-common-candidate &> /dev/null
|
|
Thomas Oulevey |
83c282 |
[ $? -gt 0 ] && echo "Adding $P_SIG-common-candidate as inheritance" && $KOJI add-tag-inheritance --priority 15 $R_SIG-$TAG-build $P_SIG-common-candidate
|
|
Thomas Oulevey |
83c282 |
fi
|
|
Thomas Oulevey |
83c282 |
$KOJI list-tagged buildsys${DIST} | grep buildsys-macros-$REALTAG &> /dev/null
|
|
Thomas Oulevey |
83c282 |
if [ $? -gt 0 ]
|
|
Thomas Oulevey |
83c282 |
then
|
|
Thomas Oulevey |
83c282 |
if [ "x$REALTAG" != "x$DEFAULT_DISTTAG" ]
|
|
Thomas Oulevey |
83c282 |
then
|
|
Thomas Oulevey |
83c282 |
echo " -> [WARN] buildsys-macros-$REALTAG rpm not found. Please build it within koji."
|
|
Thomas Oulevey |
83c282 |
[ -f $PWD/etc/buildsys.spec.template ] && echo " -> Generating buildsys-macros-$TAG.spec"
|
|
Thomas Oulevey |
83c282 |
fi
|
|
Thomas Oulevey |
83c282 |
fi
|
|
Thomas Oulevey |
83c282 |
done
|
|
Thomas Oulevey |
83c282 |
done
|
|
Thomas Oulevey |
79d958 |
done
|
|
Thomas Oulevey |
79d958 |
done
|
|
Thomas Oulevey |
79d958 |
done
|