summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-x[-rw-r--r--]koji-build.py107
-rwxr-xr-xsssd-nightly.sh216
2 files changed, 184 insertions, 139 deletions
diff --git a/koji-build.py b/koji-build.py
index 487449c..2a1c99d 100644..100755
--- a/koji-build.py
+++ b/koji-build.py
@@ -1,4 +1,8 @@
+#! /usr/bin/env python
+
import os
+import sys
+import errno
import koji
import optparse
import time
@@ -7,6 +11,18 @@ import string
import urlgrabber
import urlgrabber.progress
+HOME = os.getenv('HOME')
+BASEURL = 'http://kojipkgs.fedoraproject.org/work/'
+workingdir = os.getcwd()
+
+def mkdir_p(path):
+ try:
+ os.makedirs(path)
+ except OSError as exc:
+ if exc.errno == errno.EEXIST:
+ pass
+ else: raise
+
def _unique_path(prefix):
"""Create a unique path fragment by appending a path component
to prefix. The path component will consist of a string of letter and numbers
@@ -19,34 +35,11 @@ def _unique_path(prefix):
''.join([random.choice(string.ascii_letters) for i in range(8)]))
-HOME = os.getenv('HOME')
-BASEURL = 'http://kojipkgs.fedoraproject.org/work/'
-
-usage = 'usage: %prog [options] <srpm> <target>'
-parser = optparse.OptionParser(usage=usage)
-parser.add_option('--verbose', action='store_true',
- default=False,
- help = "Display verbose progress")
-parser.add_option('--quiet', action='store_true',
- default=False,
- help = "Only print errors")
-
-opts, args = parser.parse_args()
-
-if len(args) < 1:
- parser.error('Must specify SRPM to build')
-
-srpm = args[0]
-
-target = 'dist-rawhide'
-if len(args) == 2:
- target=args[1]
-
-if __name__ == "__main__":
+def _build_srpm(opts, srpm):
session = koji.ClientSession('http://koji.fedoraproject.org/kojihub')
- session.ssl_login(HOME+'/.fedora.cert',
- HOME+'/.fedora-upload-ca.cert',
- HOME+'/.fedora-server-ca.cert')
+ session.ssl_login(HOME + '/.fedora.cert',
+ HOME + '/.fedora-upload-ca.cert',
+ HOME + '/.fedora-server-ca.cert')
serverdir = _unique_path('cli-build')
if not opts.quiet:
@@ -56,7 +49,7 @@ if __name__ == "__main__":
if not opts.quiet:
print "Upload complete. Building."
- task_id = session.build(source, target, {'scratch': True})
+ task_id = session.build(source, opts.target, {'scratch': True})
'''Wait for it to finish'''
finished = False
@@ -74,11 +67,12 @@ if __name__ == "__main__":
if not succeeded:
print "Build %d failed" % task_id
- os.exit(1)
+ return 1
# Download the finished build
tasks = session.listTasks(opts={'parent': task_id,
'method': 'buildArch',
+ 'arch': ['i386', 'x86_64'],
'state': [koji.TASK_STATES['CLOSED']],
'decode': True})
@@ -87,6 +81,14 @@ if __name__ == "__main__":
prog_meter = None
for task in tasks:
+ if (opts.build_id):
+ basepath = '%s/%s' % (workingdir, opts.build_id)
+ else:
+ basepath = '%s/output' % workingdir
+ outputpath = '%s/%s' % (basepath, task['arch'])
+ mkdir_p(outputpath)
+ os.chdir(outputpath)
+
if not opts.quiet:
print 'Downloading rpms from task %i: %s' % (task['id'], koji.taskLabel(task))
@@ -94,8 +96,55 @@ if __name__ == "__main__":
output = session.listTaskOutput(task['id'])
for filename in output:
download = False
+
if filename.endswith('.rpm'):
download = True
+ if (filename.find('debuginfo') != -1):
+ debugpath = '%s/%s' % (outputpath, 'DEBUGINFO')
+ mkdir_p(debugpath)
+ os.chdir(debugpath)
+ else:
+ if filename.endswith('.src.rpm'):
+ srpmpath = '%s/%s' % (basepath, 'SRPMS')
+ mkdir_p(srpmpath)
+ os.chdir(srpmpath)
+ else:
+ rpmpath = '%s/%s' % (outputpath, 'RPMS')
+ mkdir_p(rpmpath)
+ os.chdir(rpmpath)
+ if filename.endswith('.log'):
+ download = True
+ logpath = '%s/%s' % (outputpath, 'logs')
+ mkdir_p(logpath)
+ os.chdir(logpath)
+
if download:
urlgrabber.grabber.urlgrab(BASEURL + base_path + '/' + filename,
progress_obj=prog_meter)
+ # Return to our original working directory
+ os.chdir(workingdir)
+ return 0
+
+if __name__ == "__main__":
+ usage = 'usage: %prog [options] <srpm> <target>'
+ parser = optparse.OptionParser(usage=usage)
+ parser.add_option('--verbose', action='store_true',
+ default=False,
+ help="Display verbose progress")
+ parser.add_option('--quiet', action='store_true',
+ default=False,
+ help="Only print errors")
+ parser.add_option('--build_id', dest='build_id', default=None,
+ help='Specify a build_id for the output')
+ parser.add_option('--target', dest='target', default='dist-rawhide',
+ help='Specify the target platform (default: dist-rawhide)')
+
+ opts, args = parser.parse_args()
+
+ if len(args) < 1:
+ parser.error('Must specify SRPM to build')
+
+ srpm = args[0]
+
+ ret = _build_srpm(opts, srpm)
+ sys.exit(ret)
diff --git a/sssd-nightly.sh b/sssd-nightly.sh
index 268708e..d9b993b 100755
--- a/sssd-nightly.sh
+++ b/sssd-nightly.sh
@@ -15,34 +15,28 @@ function finish { #(exit code)
successful="unsuccessfully"
fi
- echo "Build completed $successful" | /bin/mailx -a $LOGFILE -s "SSSD automated build report for $datestamp" $recipients
+ finishtime=`date`
+
+ echo "Build completed $successful at $finishtime" | /bin/mailx -a $LOGFILE -s "SSSD automated build report for $datestamp" $recipients
exit $1
}
if [ -e "/local/sgallagh/.sssd-build.lock" ]; then
- exit -1
+ echo "Previous build still running. Is it stuck?"
+ exit 0
fi
touch /local/sgallagh/.sssd-build.lock
mkdir -p /local/sgallagh/logs
-cd /local/sgallagh
-nextversion=$1
-if [ x$nextversion == x ]; then
- nextversion=0.0.1
-fi
-datestamp=`date +%Y%m%d%H`
-today=`date +%Y%m%d`
-git_repo=$2
-if [ x$git_repo == x ]; then
- git_repo=git://git.fedorahosted.org/sssd.git
- repodir=/local/sgallagh/repos
-else
- scratch_build=1
- repodir=/local/sgallagh/repos/scratch
-fi
-if [ x$3 == x ]; then
- gitbranch=$3
+
+datestamp=`date +%Y%m%d.%H%M`
+
+repodir=/local/sgallagh/repos
+mkdir -p $repodir
+
+if [ x$1 != x ]; then
+ gitbranch=$1
else
gitbranch=master
fi
@@ -52,129 +46,131 @@ LOGFILE=/local/sgallagh/logs/nightly-$datestamp.log
echo "===== BUILD STARTED AT `date` =====" >> $LOGFILE
echo "===== CHECKING OUT CODE =====" >> $LOGFILE
-rm -Rf sssd-$datestamp #Remove an incomplete previous run
-git clone $git_repo sssd-$datestamp >> $LOGFILE 2>&1
-cd sssd-$datestamp
-if [ x$gitbranch != x ]; then
- git branch $gitbranch origin/$gitbranch >> $LOGFILE 2>&1 || finish 96
- git checkout $gitbranch >> $LOGFILE 2>&1 || finish 97
-fi
-commit_id=`git log -1 --pretty=format:%h`
-# If this is a scratch build, always run it
-if [ x$scratch_build == x ]; then
- # See if the commit_id is different from the last run
- old_commit_id=`cat /local/sgallagh/.commit`
- if [ x$commit_id == x$old_commit_id ]; then
- cd /local/sgallagh && rm -Rf sssd-$datestamp
- rm -f $LOGFILE
- rm -f /local/sgallagh/.sssd-build.lock
- exit 0
- fi
-fi
+cd /local/sgallagh/sssd
+git remote update >> $LOGFILE 2>&1 || finish 95
+git reset --hard origin/$gitbranch >> $LOGFILE 2>&1 || finish 96
-echo "===== Summary of Commits =====" >> $LOGFILE
-git shortlog HEAD ^$old_commit_id >> $LOGFILE
+commit_id=`git log -1 --pretty=format:%h`
-cd /local/sgallagh/sssd-$datestamp
-prereleaseversion=".${datestamp}git${commit_id}"
-echo $nextversion > VERSION
-echo $prereleaseversion >> VERSION
-rpmversion=$nextversion-0$prereleaseversion
+fullversion=`grep "\[VERSION_NUMBER\]" version.m4`
-mv contrib/sssd.spec.in contrib/sssd.spec.in.orig && \
-sed -e "s/make %/make CFLAGS=\"-ggdb3 -O0\" %/" < contrib/sssd.spec.in.orig > contrib/sssd.spec.in
+# Try X.Y.ZZ first
+version=${fullversion:29:6}
-echo "===== CONFIGURING CODE =====" >> $LOGFILE
-autoreconf -i -f >> $LOGFILE 2>&1 || finish 1
-./configure >> $LOGFILE 2>&1 || finish 2
-make srpms >> $LOGFILE 2>&1 || finish 3
-cd rpmbuild/SRPMS
-
-echo "===== BUILDING RHEL 6 i386 =====" >> $LOGFILE
-cd /local/sgallagh/sssd-$datestamp/rpmbuild/SRPMS
-mv sssd-$rpmversion.fc11.src.rpm \
- sssd-$rpmversion.el6.src.rpm
-mock -r epel-6-i386 sssd-$rpmversion.el6.src.rpm >> $LOGFILE 2>&1 || failed=1
-if [ $failed ]; then
- cat /var/lib/mock/epel-6-i386/result/build.log >> $LOGFILE
- finish 6
+# Try X.Y.Z
+if [ "${version:5}" == "]" ]; then
+ version=${fullversion:29:5}
fi
-echo "===== BUILDING RHEL 6 x86_64 =====" >> $LOGFILE
-mock -r epel-6-x86_64 sssd-$rpmversion.el6.src.rpm >> $LOGFILE 2>&1 || failed=1
-if [ $failed ]; then
- cat /var/lib/mock/epel-6-x86_64/result/build.log >> $LOGFILE
- finish 7
+# See if the commit_id is different from the last run
+old_commit_id=`cat /local/sgallagh/.commit_$gitbranch 2> /dev/null`
+if [ x$commit_id == x$old_commit_id ]; then
+ cd /local/sgallagh && rm -Rf sssd-$datestamp
+ rm -f $LOGFILE
+ rm -f /local/sgallagh/.sssd-build.lock
+ exit 0
fi
-echo "===== CREATING RHEL 6 i586 YUM REPOSITORY ====" >> $LOGFILE
-mkdir -p $repodir/rhel6/SRPMS
-mkdir -p $repodir/rhel6/i386/DEBUGINFO
-mkdir -p $repodir/rhel6/i386/RPMS
-cp /var/lib/mock/epel-6-i386/result/sssd-$rpmversion.el6.src.rpm $repodir/rhel6/SRPMS
-cp /var/lib/mock/epel-6-i386/result/sssd-debuginfo-$rpmversion.el6.i386.rpm $repodir/rhel6/i386/DEBUGINFO
-cp /var/lib/mock/epel-6-i386/result/*.el6.i386.rpm $repodir/rhel6/i386/RPMS
-rm -f $repodir/rhel6/i386/RPMS/sssd-debuginfo-$rpmversion.el6.i386.rpm
-
-echo "===== CREATING RHEL 6 x86_86 YUM REPOSITORY ====" >> $LOGFILE
-mkdir -p $repodir/rhel6/x86_64/DEBUGINFO
-mkdir -p $repodir/rhel6/x86_64/RPMS
-cp /var/lib/mock/epel-6-x86_64/result/sssd-debuginfo-$rpmversion.el6.x86_64.rpm $repodir/rhel6/x86_64/DEBUGINFO
-cp /var/lib/mock/epel-6-i386/result/sssd-debuginfo-$rpmversion.el6.i386.rpm $repodir/rhel6/x86_64/DEBUGINFO
-cp /var/lib/mock/epel-6-x86_64/result/*.el6.x86_64.rpm $repodir/rhel6/x86_64/RPMS
-rm -f $repodir/rhel6/x86_64/RPMS/sssd-debuginfo-$rpmversion.el6.i386.rpm
-cp /var/lib/mock/epel-6-i386/result/sssd-client-$rpmversion.el6.i386.rpm $repodir/rhel6/x86_64/RPMS
-
-echo "===== Removing Source Tree =====" >> $LOGFILE
-cd /local/sgallagh && rm -Rf sssd-$datestamp
-
-#Save the commit id for the next time
-if [ x$scratch_build == x ]; then
- echo $commit_id > /local/sgallagh/.commit
-fi
+echo "===== Summary of Commits =====" >> $LOGFILE
+git shortlog --no-merges HEAD ^$old_commit_id >> $LOGFILE 2>&1
-echo "===== Cleaning old logs =====" >> $LOGFILE
-find /local/sgallagh/logs -type f -daystart -ctime +6 -name "nightly-*.log" -exec rm -f {} \;
+# Disable optimizations
+mv contrib/sssd.spec.in contrib/sssd.spec.in.orig && \
+sed -e "s/make %/make CFLAGS=\"-ggdb3 -O0\" %/" < contrib/sssd.spec.in.orig > contrib/sssd.spec.in
-echo "===== Cleaning old RPMS =====" >> $LOGFILE
-rm -f `repomanage -k2 --old /repos/rhel6`
+echo "===== CONFIGURING CODE =====" >> $LOGFILE
+mv version.m4 version.m4.orig &&
+sed -e "s/m4_define(\[PRERELEASE_VERSION_NUMBER\], \[.*\])/m4_define(\[PRERELEASE_VERSION_NUMBER\], \[.$datestamp.git`git log -1 --pretty=format:%h`\])/" < version.m4.orig > version.m4 2>> $LOGFILE
+autoreconf -if >> $LOGFILE 2>&1 || finish 1
+./configure >> $LOGFILE 2>&1 || finish 2
+make srpm >> $LOGFILE 2>&1 || finish 3
-createrepo --update -s sha1 $repodir/rhel6/SRPMS > /dev/null
+echo "===== BUILDING FEDORA 15 =====" >> $LOGFILE
+rm -Rf ${datestamp}_${gitbranch}_15
+cd /local/sgallagh
+/local/sgallagh/build_tools/koji-build.py --build_id=${datestamp}_${gitbranch}_15 \
+ /local/sgallagh/sssd/rpmbuild/SRPMS/sssd-$version-0.$datestamp.git$commit_id.el6.src.rpm >> $LOGFILE 2>&1 || finish 4
+
+echo "===== Creating Fedora 15 Repository =====" >> $LOGFILE
+mkdir -p $repodir/$gitbranch/15/SRPMS
+mkdir -p $repodir/$gitbranch/15/i386/DEBUGINFO
+mkdir -p $repodir/$gitbranch/15/i386/RPMS
+mkdir -p $repodir/$gitbranch/15/i386/logs
+mkdir -p $repodir/$gitbranch/15/x86_64/DEBUGINFO
+mkdir -p $repodir/$gitbranch/15/x86_64/RPMS
+mkdir -p $repodir/$gitbranch/15/x86_64/logs
+
+cp ${datestamp}_${gitbranch}_15/SRPMS/* \
+ $repodir/$gitbranch/15/SRPMS
+
+cp ${datestamp}_${gitbranch}_15/i386/DEBUGINFO/* \
+ $repodir/$gitbranch/15/i386/DEBUGINFO
+
+cp ${datestamp}_${gitbranch}_15/i386/RPMS/* \
+ $repodir/$gitbranch/15/i386/RPMS
+cp ${datestamp}_${gitbranch}_15/i386/RPMS/* \
+ $repodir/$gitbranch/15/x86_64/RPMS
+
+cp ${datestamp}_${gitbranch}_15/i386/logs/* \
+ $repodir/$gitbranch/15/i386/logs
+
+cp ${datestamp}_${gitbranch}_15/x86_64/DEBUGINFO/* \
+ $repodir/$gitbranch/15/x86_64/DEBUGINFO
+
+cp ${datestamp}_${gitbranch}_15/x86_64/RPMS/* \
+ $repodir/$gitbranch/15/x86_64/RPMS
+
+cp ${datestamp}_${gitbranch}_15/x86_64/logs/* \
+ $repodir/$gitbranch/15/x86_64/logs
+
+# Clean up old RPMs
+rm -f `repomanage -k4 --old $repodir/$gitbranch/15`
+
+createrepo $repodir/$gitbranch/15/SRPMS > /dev/null
if [ $? -eq 0 ]; then
- echo "RHEL6 SRPM Repo updated" >> $LOGFILE
+ echo "Fedora 15 SRPM Repo updated" >> $LOGFILE
else
- echo "RHEL6 SRPM Repo not updated" >> $LOGFILE
+ echo "Fedora 15 SRPM Repo not updated" >> $LOGFILE
fi
-createrepo --update -s sha1 $repodir/rhel6/i386/DEBUGINFO > /dev/null
+createrepo $repodir/$gitbranch/15/i386/DEBUGINFO > /dev/null
if [ $? -eq 0 ]; then
- echo "RHEL6 i386 DEBUGINFO Repo updated" >> $LOGFILE
+ echo "Fedora 15 i386/DEBUGINFO Repo updated" >> $LOGFILE
else
- echo "RHEL6 i386 DEBUGINFO Repo not updated" >> $LOGFILE
+ echo "Fedora 15 i386/DEBUGINFO Repo not updated" >> $LOGFILE
fi
-createrepo --update -s sha1 $repodir/rhel6/i386/RPMS > /dev/null
+createrepo $repodir/$gitbranch/15/i386/RPMS > /dev/null
if [ $? -eq 0 ]; then
- echo "RHEL6 i386 RPM Repo updated" >> $LOGFILE
+ echo "Fedora 15 i386/RPMS Repo updated" >> $LOGFILE
else
- echo "RHEL6 i386 RPM Repo not updated" >> $LOGFILE
+ echo "Fedora 15 i386/RPMS Repo not updated" >> $LOGFILE
fi
-createrepo --update -s sha1 $repodir/rhel6/x86_64/DEBUGINFO > /dev/null
+createrepo $repodir/$gitbranch/15/x86_64/DEBUGINFO > /dev/null
if [ $? -eq 0 ]; then
- echo "RHEL6 x86_64 DEBUGINFO Repo updated" >> $LOGFILE
+ echo "Fedora 15 x86_64/DEBUGINFO Repo updated" >> $LOGFILE
else
- echo "RHEL6 x86_64 DEBUGINFO Repo not updated" >> $LOGFILE
+ echo "Fedora 15 x86_64/DEBUGINFO Repo not updated" >> $LOGFILE
fi
-createrepo --update -s sha1 $repodir/rhel6/x86_64/RPMS > /dev/null
+createrepo $repodir/$gitbranch/15/x86_64/RPMS > /dev/null
if [ $? -eq 0 ]; then
- echo "RHEL6 x86_64 RPM Repo updated" >> $LOGFILE
+ echo "Fedora 15 x86_64/RPMS Repo updated" >> $LOGFILE
else
- echo "RHEL6 x86_64 RPM Repo not updated" >> $LOGFILE
+ echo "Fedora 15 x86_64/RPMS Repo not updated" >> $LOGFILE
fi
+echo "===== Cleaning old logs and RPMs =====" >> $LOGFILE
+find /local/sgallagh/logs -type f -daystart -ctime +6 -name "nightly-*.log" -exec rm -f {} \;
+rm -Rf /local/sgallagh/${datestamp}_${gitbranch}_15
+
+echo "===== RSYNC the repositories =====" >> $LOGFILE
+rsync -avz /local/sgallagh/repos/* sgallagh@fedorapeople.org:/srv/repos/gitsssd/sssd >> $LOGFILE 2>&1
+
+echo $commit_id > /local/sgallagh/.commit_$gitbranch
+
echo "===== BUILD CONCLUDED AT `date` =====" >> $LOGFILE
finish 0