From: Holger Levsen Date: Thu, 3 Nov 2011 13:43:45 +0000 (+0100) Subject: write commit id into changelog. provide meaningful changelog for kernels. save commit... X-Git-Url: https://git.uhu-banane.de/?a=commitdiff_plain;h=d3598d4b8f3b89850d588db246542f81176bf4e5;p=profitbricks%2Fjenkins-build-scripts.git write commit id into changelog. provide meaningful changelog for kernels. save commit id in persistance instead the name --- diff --git a/build-oot.sh b/build-oot.sh deleted file mode 100755 index 90adb92..0000000 --- a/build-oot.sh +++ /dev/null @@ -1,88 +0,0 @@ -#/bin/sh - -# Holger Levsen 2011 - -# FIXME: the way ssh is used below is just wrong. but it's also used like this in other parts of the -# jenkins builds scripts, so we'll need to cleanup anyway... - -set -e - -if [ -z "$1" ] ; then - echo "need OOT_MODULE!" - exit 1 -else - OOT_MODULE=$1 -fi - -if [ -z "$2" ] ; then - echo "need PB_FLAVOUR!" - exit 1 -else - PB_FLAVOUR=$2 -fi - -if [ -z "$3" ] ; then - echo "need DIST!" - exit 1 -else - export DIST=$3 -fi - -if [ -z "$4" ] ; then - echo "need PB_SUITE!" - exit 1 -else - export PB_SUITE=$4 -fi - -TMPFILE=$(mktemp) - -echo "Building $OOT_MODULE for kernel profitbricks-$PB_FLAVOUR for $DIST and $PB_SUITE using script in $TMPFILE which has this content:" - -cat > $TMPFILE << EOF -#!/bin/sh -# this is $TMPFILE - - set +x - set -e - apt-get update - apt-get -y upgrade - apt-get -y install openssh-client linux-source-profitbricks-$PB_FLAVOUR $OOT_MODULE-source linux-image-profitbricks-$PB_FLAVOUR dctrl-tools - cd /usr/src/ - tar xjf linux-source-*-$PB_FLAVOUR.tar.bz2 - export KDIR=\$(find /usr/src -maxdepth 1 -name "linux-source-*profitbricks-$PB_FLAVOUR*" -type d) - export KVERS=\$(echo \$KDIR |cut -d "-" -f3-) - - cd /usr/share/doc/linux-image-*profitbricks-$PB_FLAVOUR - zcat changelog.Debian.gz > changelog - our_version=\$(dpkg-parsechangelog -l./changelog|grep-dctrl -n -s Version ''|cut -d "-" -f4) - cat > /etc/kernel-pkg.conf << EFO -maintainer := Profitbricks GmbH -email := support@profitbricks.com -priority := Low -EFO - echo "debian = \\\$(version)-\$our_version" >> /etc/kernel-pkg.conf - - cd /usr/src/ - tar xjvf $OOT_MODULE.tar.bz2 - # the next line is only useful if its also applied to jenkins_build_script.git/kernel_inpbuilder.py:install_extra_modules() - # sed -i -s "s#^Provides: $OOT_MODULE-modules#Provides: $OOT_MODULE-modules, $OOT_MODULE-modules-profitbrick-$PB_FLAVOUR#g" modules/$OOT_MODULE/debian/control.modules.in - - cd \$KDIR - cp /boot/config-*-$PB_FLAVOUR .config - make prepare - make modules_prepare - /usr/bin/make-kpkg -j \$(grep processor /proc/cpuinfo |wc -l) --arch amd64 --rootcmd fakeroot --append-to-version -profitbricks-$PB_FLAVOUR --initrd --arch_in_name modules - - cd /usr/src/ - ls *deb - # FIXME: this is soooo just wrong... - scp -o "StrictHostKeyChecking no" -i /root/.ssh/id_rsa_jenkins *.deb reprepro@alexandria.profitbricks.localdomain:/srv/profitbricks-repository/incoming/$PB_SUITE/ - - -EOF -cat $TMPFILE - -sudo pbuilder --execute --bindmounts "/root" -- $TMPFILE - -rm $TMPFILE diff --git a/debian_build.py b/debian_build.py index cb6c669..9abbcbd 100755 --- a/debian_build.py +++ b/debian_build.py @@ -389,7 +389,7 @@ if __name__ == '__main__': else: version = '%s~develop%s' %(version, daily_date) - new_log = 'Generated by jenkins build of %s' % GIT_NEW_ID + new_log = 'Generated by jenkins build of %s' % git_helper.git_get_commit_id() cmd = [ '/usr/bin/dch', diff --git a/kernel-package-overlay/changelog b/kernel-package-overlay/changelog new file mode 100644 index 0000000..37a0cc5 --- /dev/null +++ b/kernel-package-overlay/changelog @@ -0,0 +1,10 @@ +=ST-source-=V (=D) unstable; urgency=low + + * Generated by jenkins build of DUMMY_ENTRY + + -- Holger Levsen DUMMY_DATE + + +Local variables: +mode: debian-changelog +End: diff --git a/kernel_build.py b/kernel_build.py index 6b7610e..ad21534 100644 --- a/kernel_build.py +++ b/kernel_build.py @@ -139,6 +139,7 @@ def exit_error(): if __name__ == '__main__': logger.debug('running with this enviroment: %s', os.environ) atexit.register(remove_git_target_workspace) + kernel_revision_obj = kernel_persistence.get_last_kernel_revision_obj(PB_SUITE) new_version = kernel_revision_obj.last_version + 1 if not kernel_persistence.update_kernel_revision_obj(kernel_revision_obj, new_version): diff --git a/kernel_inpbuilder.py b/kernel_inpbuilder.py index 5277e9b..c81b767 100644 --- a/kernel_inpbuilder.py +++ b/kernel_inpbuilder.py @@ -324,6 +324,9 @@ def install_extra_modules(): logger.info( 'module-assistant unpacked successfully.' ) + # FIXME: should also do: + # sed -i -s "s#^Provides: $OOT_MODULE-modules#Provides: $OOT_MODULE-modules, $OOT_MODULE-modules-profitbrick-$PB_FLAVOUR#g" modules/$OOT_MODULE/debian/control.modules.in + # use os.system("sed -i -s ...") return True @@ -383,6 +386,7 @@ if __name__ == '__main__': PB_SUITE = os.environ.get('PB_SUITE') + update_kernel_branch = False GIT_BRANCH_NAME = ( os.environ.get('GIT_BRANCH_NAME') or options.git_branch_name ) @@ -395,16 +399,13 @@ if __name__ == '__main__': logger.error('No git branch name given and no persistence for %s neither' % PB_SUITE) exit(ERROR) else: - kernel_revision_obj = kernel_persistence.get_last_kernel_revision_obj(PB_SUITE) - kernel_persistence.update_kernel_branch_obj(kernel_revision_obj, GIT_BRANCH_NAME) - + update_kernel_branch = True REVISION = os.environ.get('REVISION') or options.revision if not REVISION: logger.error('No revision given') exit(ERROR) - GIT_REPO_NAME = os.path.basename(GIT_REPO_PATH) GIT_REMOTE_BRANCH_NAME = os.path.join('origin', '%s' %(GIT_BRANCH_NAME)) GIT_TARGET_WORKSPACE = os.path.join( @@ -438,6 +439,13 @@ if __name__ == '__main__': logger.debug('changing dir to %s' %(GIT_TARGET_DIR)) os.chdir(GIT_TARGET_DIR) + if update_kernel_branch: + # save commit id in persistence so we can get it from there if triggered without a branch name + kernel_revision_obj = kernel_persistence.get_last_kernel_revision_obj(PB_SUITE) + kernel_persistence.update_kernel_branch_obj(kernel_revision_obj, git_helper.git_get_commit_id()) + + # update changelog + os.system('sed -i -e "s#DUMMY_ENTRY#%s#" -e "s#DUMMY_DATE#%s#" %s' % (git_helper.git_get_commit_id(),git_helper.git_get_commit_date(),os.path.join(OVERLAY_DIR,'changelog'))) if not build_kernel(kernel_flavour, REVISION, OVERLAY_DIR, [ 'kernel_debug', 'kernel_image' ]): exit(ERROR) diff --git a/lib/git_helper.py b/lib/git_helper.py index 1fed691..6ffa06b 100644 --- a/lib/git_helper.py +++ b/lib/git_helper.py @@ -300,4 +300,76 @@ def git_get_treeish(refname): ) return stdout_str[0] +def git_get_commit_id(): + """ + Get current commit id + + """ + cmd = [ + GIT, + 'log', + '-n 1', + '--pretty=format:"%H"', + ] + cmdobj = subprocess.Popen( + cmd, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + shell=False, + env={'':''}, + cwd=os.getcwd(), + close_fds=True + ) + + ret = cmdobj.wait() + if ret: + error_str = cmdobj.stderr.read() + if not error_str: + error_str = cmdobj.stdout.read() + if not error_str: + error_str = 'No Error Msg found' + logger.error( + '%s returned with %s. Output was: %s' + %(' '.join(cmd), ret, error_str) + ) + return False + logger.debug('current commit id is %s' % stdout_str[0]) + return stdout_str[0] + +def git_get_commit_date(): + """ + Get current commit date + + """ + cmd = [ + GIT, + 'log', + '-n 1', + '--pretty=format:"%cD"', + ] + cmdobj = subprocess.Popen( + cmd, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + shell=False, + env={'':''}, + cwd=os.getcwd(), + close_fds=True + ) + + ret = cmdobj.wait() + if ret: + error_str = cmdobj.stderr.read() + if not error_str: + error_str = cmdobj.stdout.read() + if not error_str: + error_str = 'No Error Msg found' + logger.error( + '%s returned with %s. Output was: %s' + %(' '.join(cmd), ret, error_str) + ) + return False + logger.debug('current commit date is %s' % stdout_str[0]) + return stdout_str[0] + # vim: autoindent smartindent tabstop=4 expandtab shiftwidth=4 softtabstop=4 nu enc=utf-8 cinwords=if,elif,else,for,while,try,except,finally,def,class