]> Frank Brehm's Git Trees - profitbricks/jenkins-build-scripts.git/commitdiff
write commit id into changelog. provide meaningful changelog for kernels. save commit...
authorHolger Levsen <holger@layer-acht.org>
Thu, 3 Nov 2011 13:43:45 +0000 (14:43 +0100)
committerHolger Levsen <holger@layer-acht.org>
Thu, 3 Nov 2011 13:43:45 +0000 (14:43 +0100)
build-oot.sh [deleted file]
debian_build.py
kernel-package-overlay/changelog [new file with mode: 0644]
kernel_build.py
kernel_inpbuilder.py
lib/git_helper.py

diff --git a/build-oot.sh b/build-oot.sh
deleted file mode 100755 (executable)
index 90adb92..0000000
+++ /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
index cb6c6695a1317e0a0ff55b726513038568dbf955..9abbcbde74a48e10c27740a7ffd0f027c100ee47 100755 (executable)
@@ -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 (file)
index 0000000..37a0cc5
--- /dev/null
@@ -0,0 +1,10 @@
+=ST-source-=V (=D) unstable; urgency=low
+
+  * Generated by jenkins build of DUMMY_ENTRY
+
+ -- Holger Levsen <holger.levsen@profitbricks.com>  DUMMY_DATE
+
+
+Local variables:
+mode: debian-changelog
+End:
index 6b7610e0f73992b6e1df8950ea42516225b34973..ad21534a556945e9680b9b0b34e0e5ef008ee865 100644 (file)
@@ -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):
index 5277e9bfa709dafff8011f4ea7cd2c6987eb59c7..c81b767c031252d8cdaf4fa6c262594803828cc2 100644 (file)
@@ -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)
index 1fed6910715e3ffa6ed35e0fe43196d07530292b..6ffa06bde3aa532695fe47ec11e4dd901d16bba5 100644 (file)
@@ -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