+++ /dev/null
-#/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
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',
--- /dev/null
+=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:
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):
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
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
)
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(
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)
)
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