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'
21 BUILDSYSDIR=`dirname $0`
23 MOCKWORK="$BUILDSYSDIR/mockwork"
25 #MOCKARGS='--autocache'
26 MOCKARGS="--configdir=$BUILDSYSDIR/mock --resultdir=$MOCKWORK"
28 if [ -f $BUILDSYSDIR/buildsysrc ]; then
29 #chmod a+x $BUILDSYSDIR/buildsysrc
30 #echo $BUILDSYSDIR/buildsysrc
31 . $BUILDSYSDIR/buildsysrc
33 if [ -f $HOME/buildsysrc ]; then
34 #chmod a+x $HOME/buildsysrc
35 #echo $HOME/buildsysrc
39 EXPECT_ADDSIGN=$BUILDSYSDIR/expect-addsign
40 if [ -f /usr/local/bin/expect-addsign ]; then
41 EXPECT_ADDSIGN=/usr/local/bin/expect-addsign
45 echo "build-freeside: build RPMs for all target distros and architectures using mock"
47 echo " -a <archs>: change architectures (currently: $ARCHS)"
48 echo " -b <branch>: change branch (currently: $BRANCH)"
49 echo " -d <distros>: change distributions (currently: $DISTROS)"
50 echo " -m <arguments>: change arguments passed to 'mock' (currently: $MOCKARGS)"
51 echo " -r <repo>: change repositories (currently: $REPO)"
52 echo " -s <srpms>: build these SRPMs instead of new ones in staging area"
53 echo " -v <versions>: change versions (currently: $VERSIONS)"
54 echo " -w <distvers>: change distro version (currently: $WHICHVERS)"
58 while getopts "a:b:d:hm:r:s:v:w:" flag
62 echo "Changing architectures from $ARCHS to $OPTARG"
65 echo "Changing branch from $BRANCH to $OPTARG"
68 echo "Changing distros from $DISTROS to $OPTARG"
71 echo "Changing mock arguments from $MOCKARGS to $OPTARG"
74 echo "Changing repository from $REPO to $OPTARG"
77 echo "Changing SRPMS from $SRPMS to $OPTARG"
80 echo "Changing versions from $VERSIONS to $OPTARG"
83 echo "Changing which distro versions from $WHICHVERS to $OPTARG"
90 if [ "${SRCFOLDER}x" = "x" ]; then
92 echo "No source folder defined! (BUILDSYSDIR=$BUILDSYSDIR pwd=$PWD)"
96 if [ "${REFFOLDER}x" = "x" ]; then
97 echo "No reference folder defined!"
101 if [ "${SRPMS}x" = "x" ]; then
102 # Work out the new SRPMs on grosbeak
103 SRPMS=`/usr/bin/rsync -Cavz --dry-run $SRCFOLDER/ $REFFOLDER | grep .src.rpm | grep -v safecat | tr '\n' ' '`
105 # Go and get the SRPMs
106 /usr/bin/rsync -Cavz $SRCFOLDER/ $REFFOLDER
109 # Make sure the SRPMs are there
112 if [ ! -f $REFFOLDER/${srpm} ]
114 echo "No such file: $REFFOLDER/${srpm}"
119 # Build all the SRPMs
122 for distro in $DISTROS
124 if [ "${WHICHVERS}x" = "x" ]; then
125 if [ "$distro" = "centos" ]; then
128 if [ "$distro" = "sles" ]; then
134 for distver in $DISTVERS
136 os=${distro}-${distver}
139 echo "$os - $arch: $srpm"
140 echo mock $MOCKARGS -r ${os}-${arch} $REFFOLDER/${srpm}
141 time mock $MOCKARGS -r ${os}-${arch} $REFFOLDER/${srpm}
142 if true #[ -f $MOCKWORK/${os}-${arch}/state/status ] && grep done $MOCKWORK/${os}-${arch}/state/status
144 for VERSION in $VERSIONS
147 if [ "${BRANCH}x" != "x" ]
151 # Copy freeside RPMs for this version only
152 #FILES=`ls -1 $MOCKWORK/${os}-${arch}/result/freeside*-${VERSION}-*.rpm | grep -v .src.rpm | tr '\n' ' '`
153 FILES=`ls -1 $MOCKWORK/freeside*-${VERSION}-*.rpm | grep -v .src.rpm | tr '\n' ' '`
155 if [ "${FILES}x" != "x" ]
159 $EXPECT_ADDSIGN $FILE
161 if [ "${REPOMACHINE}x" != "x" ]
163 scp -p $FILES $REPOUSER@$REPOMACHINE:$REPOFOLDER/repo/${distro}/${distver}/freeside-${DEST}/${REPO}/${arch}
165 cp -p $FILES $REPOFOLDER/repo/${distro}/${distver}/freeside-${DEST}/${REPO}/${arch}
168 # Copy non-freeside RPMs to all versions
169 #FILES=`ls -1 $MOCKWORK/${os}-${arch}/result/*.rpm | grep -v freeside | grep -v .src.rpm | tr '\n' ' '`
170 FILES=`ls -1 $MOCKWORK/*.rpm | grep -v freeside | grep -v .src.rpm | tr '\n' ' '`
172 if [ "${FILES}x" != "x" ]
176 $EXPECT_ADDSIGN $FILE
178 if [ "${REPOMACHINE}x" != "x" ]
180 scp -p $FILES $REPOUSER@$REPOMACHINE:$REPOFOLDER/repo/${distro}/${distver}/freeside-${DEST}/${REPO}/${arch}
182 cp -p $FILES $REPOFOLDER/repo/${distro}/${distver}/freeside-${DEST}/${REPO}/${arch}
192 echo "build-freeside done"