3 # Copyright 2008, Elirion, Inc. All rights reserved.
4 # This software is licensed under the same terms as Freeside itself.
6 # This script rebuilds SRPMs of Freeside builds or the required Perl modules on all the target
7 # distributions and versions using mock. After a successful build, it signs the resulting RPMs
8 # and scp's them to the server where the yum repositories are hosted.
9 # (Of course, koji is supposed to do all this, including updating the repo.)
12 #VERSIONS='1.7 1.9 2.1'
20 MOCKARGS='--autocache'
22 BUILDSYSDIR=`dirname $0`
24 if [ -f $HOME/buildsysrc ]; then
29 echo "build-freeside: build RPMs for all target distros and architectures using mock"
31 echo " -a <archs>: change architectures (currently: $ARCHS)"
32 echo " -b <branch>: change branch (currently: $BRANCH)"
33 echo " -d <distros>: change distributions (currently: $DISTROS)"
34 echo " -m <arguments>: change arguments passed to 'mock' (currently: $MOCKARGS)"
35 echo " -r <repo>: change repositories (currently: $REPO)"
36 echo " -s <srpms>: build these SRPMs instead of new ones in staging area"
37 echo " -v <versions>: change versions (currently: $VERSIONS)"
38 echo " -w <distvers>: change distro version (currently: $WHICHVERS)"
42 while getopts "a:b:d:hm:r:s:v:w:" flag
46 echo "Changing architectures from $ARCHS to $OPTARG"
49 echo "Changing branch from $BRANCH to $OPTARG"
52 echo "Changing distros from $DISTROS to $OPTARG"
55 echo "Changing mock arguments from $MOCKARGS to $OPTARG"
58 echo "Changing repository from $REPO to $OPTARG"
61 echo "Changing SRPMS from $SRPMS to $OPTARG"
64 echo "Changing versions from $VERSIONS to $OPTARG"
67 echo "Changing which distro versions from $WHICHVERS to $OPTARG"
74 if [ "${SRCFOLDER}x" = "x" ]; then
75 echo "No source folder defined!"
79 if [ "${REFFOLDER}x" = "x" ]; then
80 echo "No reference folder defined!"
84 if [ "${SRPMS}x" = "x" ]; then
85 # Work out the new SRPMs on grosbeak
86 SRPMS=`/usr/bin/rsync -Cavz --dry-run $SRCFOLDER/ $REFFOLDER | grep .src.rpm | grep -v safecat | tr '\n' ' '`
88 # Go and get the SRPMs
89 /usr/bin/rsync -Cavz $SRCFOLDER/ $REFFOLDER
92 # Make sure the SRPMs are there
95 if [ ! -f $REFFOLDER/${srpm} ]
97 echo "No such file: $REFFOLDER/${srpm}"
102 # Build all the SRPMs
105 for distro in $DISTROS
107 if [ "${WHICHVERS}x" = "x" ]; then
108 if [ "$distro" = "centos" ]; then
111 if [ "$distro" = "sles" ]; then
117 for distver in $DISTVERS
119 os=${distro}-${distver}
122 echo "$os - $arch: $srpm"
123 time mock $MOCKARGS -r ${os}-${arch} $REFFOLDER/${srpm}
124 if [ -f /var/lib/mock/${os}-${arch}/state/status ] && grep done /var/lib/mock/${os}-${arch}/state/status
126 for VERSION in $VERSIONS
129 if [ "${BRANCH}x" != "x" ]
133 # Copy freeside RPMs for this version only
134 FILES=`ls -1 /var/lib/mock/${os}-${arch}/result/freeside*-${VERSION}-*.rpm | grep -v .src.rpm | tr '\n' ' '`
136 if [ "${FILES}x" != "x" ]
140 $BUILDSYSDIR/expect-addsign $FILE
142 if [ "${REPOMACHINE}x" != "x" ]
144 scp -p $FILES $REPOUSER@$REPOMACHINE:$REPOFOLDER/repo/${distro}/${distver}/freeside-${DEST}/${REPO}/${arch}
146 cp -p $FILES $REPOFOLDER/repo/${distro}/${distver}/freeside-${DEST}/${REPO}/${arch}
149 # Copy non-freeside RPMs to all versions
150 FILES=`ls -1 /var/lib/mock/${os}-${arch}/result/*.rpm | grep -v freeside | grep -v .src.rpm | tr '\n' ' '`
152 if [ "${FILES}x" != "x" ]
156 $BUILDSYSDIR/expect-addsign $FILE
158 if [ "${REPOMACHINE}x" != "x" ]
160 scp -p $FILES $REPOUSER@$REPOMACHINE:$REPOFOLDER/repo/${distro}/${distver}/freeside-${DEST}/${REPO}/${arch}
162 cp -p $FILES $REPOFOLDER/repo/${distro}/${distver}/freeside-${DEST}/${REPO}/${arch}