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.)
19 MOCKARGS='--autocache'
21 BUILDSYSDIR=`dirname $0`
23 if [ -f $HOME/buildsysrc ]; then
28 echo "build-freeside: build RPMs for all target distros and architectures using mock"
30 echo " -a <archs>: change architectures (currently: $ARCHS)"
31 echo " -b <branch>: change branch (currently: $BRANCH)"
32 echo " -d <distros>: change distributions (currently: $DISTROS)"
33 echo " -m <arguments>: change arguments passed to 'mock' (currently: $MOCKARGS)"
34 echo " -r <repo>: change repositories (currently: $REPO)"
35 echo " -s <srpms>: build these SRPMs instead of new ones in staging area"
36 echo " -v <versions>: change versions (currently: $VERSIONS)"
37 echo " -w <distvers>: change distro version (currently: $WHICHVERS)"
41 while getopts "a:b:d:hm:r:s:v:w:" flag
45 echo "Changing architectures from $ARCHS to $OPTARG"
48 echo "Changing branch from $BRANCH to $OPTARG"
51 echo "Changing distros from $DISTROS to $OPTARG"
54 echo "Changing mock arguments from $MOCKARGS to $OPTARG"
57 echo "Changing repository from $REPO to $OPTARG"
60 echo "Changing SRPMS from $SRPMS to $OPTARG"
63 echo "Changing versions from $VERSIONS to $OPTARG"
66 echo "Changing which distro versions from $WHICHVERS to $OPTARG"
73 if [ "${SRCFOLDER}x" = "x" ]; then
74 echo "No source folder defined!"
78 if [ "${REFFOLDER}x" = "x" ]; then
79 echo "No reference folder defined!"
83 if [ "${SRPMS}x" = "x" ]; then
84 # Work out the new SRPMs on grosbeak
85 SRPMS=`/usr/bin/rsync -Cavz --dry-run $SRCFOLDER/ $REFFOLDER | grep .src.rpm | grep -v safecat | tr '\n' ' '`
87 # Go and get the SRPMs
88 /usr/bin/rsync -Cavz $SRCFOLDER/ $REFFOLDER
91 # Make sure the SRPMs are there
94 if [ ! -f $REFFOLDER/${srpm} ]
96 echo "No such file: $REFFOLDER/${srpm}"
101 # Build all the SRPMs
104 for distro in $DISTROS
106 if [ "${WHICHVERS}x" = "x" ]; then
107 if [ "$distro" = "centos" ]; then
110 if [ "$distro" = "sles" ]; then
116 for distver in $DISTVERS
118 os=${distro}-${distver}
121 echo "$os - $arch: $srpm"
122 time mock $MOCKARGS -r ${os}-${arch} $REFFOLDER/${srpm}
123 if [ -f /var/lib/mock/${os}-${arch}/state/status ] && grep done /var/lib/mock/${os}-${arch}/state/status
125 for VERSION in $VERSIONS
128 if [ "${BRANCH}x" != "x" ]
132 # Copy freeside RPMs for this version only
133 FILES=`ls -1 /var/lib/mock/${os}-${arch}/result/freeside*-${VERSION}-*.rpm | grep -v .src.rpm | tr '\n' ' '`
135 if [ "${FILES}x" != "x" ]
139 $BUILDSYSDIR/expect-addsign $FILE
141 if [ "${REPOMACHINE}x" != "x" ]
143 scp -p $FILES $REPOUSER@$REPOMACHINE:$REPOFOLDER/repo/${distro}/${distver}/freeside-${DEST}/${REPO}/${arch}
145 cp -p $FILES $REPOFOLDER/repo/${distro}/${distver}/freeside-${DEST}/${REPO}/${arch}
148 # Copy non-freeside RPMs to all versions
149 FILES=`ls -1 /var/lib/mock/${os}-${arch}/result/*.rpm | grep -v freeside | grep -v .src.rpm | tr '\n' ' '`
151 if [ "${FILES}x" != "x" ]
155 $BUILDSYSDIR/expect-addsign $FILE
157 if [ "${REPOMACHINE}x" != "x" ]
159 scp -p $FILES $REPOUSER@$REPOMACHINE:$REPOFOLDER/repo/${distro}/${distver}/freeside-${DEST}/${REPO}/${arch}
161 cp -p $FILES $REPOFOLDER/repo/${distro}/${distver}/freeside-${DEST}/${REPO}/${arch}