From f82aa51adf4ea5317ef37669319bc9651692e738 Mon Sep 17 00:00:00 2001 From: Holger Levsen Date: Sun, 26 Oct 2014 00:14:19 +0200 Subject: refactor code into new publish_changes_to_userContent() This new function is used to publish both the Debian Edu manuals as well as the Debian Installer installation-guide to https://jenkins.debian.net/userContent/debian-edu-doc/ and https://jenkins.debian.net/userContent/installation-guide/ --- bin/chroot-run.sh | 20 ++------------------ bin/common-functions.sh | 34 ++++++++++++++++++++++++++++++++++ bin/d-i_manual.sh | 13 ++++++++++--- 3 files changed, 46 insertions(+), 21 deletions(-) diff --git a/bin/chroot-run.sh b/bin/chroot-run.sh index 19beabea..62d35dfe 100755 --- a/bin/chroot-run.sh +++ b/bin/chroot-run.sh @@ -80,27 +80,11 @@ cleanup() { fi # - # special case debian-edu-doc + # special case: publish debian-edu-doc on the webserver # CHANGES=$(ls -1 $CHROOT_TARGET/tmp/debian-edu-doc_*.changes 2>/dev/null|| true) if [ ! -z "$CHANGES" ] ; then - echo "Extracting contents from .deb files..." - NEWDOC=$(mktemp -d) - for DEB in $(dcmd --deb $CHANGES) ; do - dpkg --extract $DEB $NEWDOC 2>/dev/null - done - EDUDOC="/var/lib/jenkins/userContent/debian-edu-doc" - rm -rf $EDUDOC - mkdir $EDUDOC - mv $NEWDOC/usr/share/doc/debian-edu-doc-* $EDUDOC/ - VERSION=$(echo $CHANGES | cut -d "_" -f2) - touch "$EDUDOC/${VERSION}_git${GIT_COMMIT:0:7}" - rm -r $NEWDOC - MESSAGE="https://jenkins.debian.net/userContent/debian-edu-doc/ has been updated from ${GIT_COMMIT:0:7}" - kgb-client --conf /srv/jenkins/kgb/debian-edu.conf --relay-msg "$MESSAGE" - echo - echo $MESSAGE - echo + publish_changes_to_userContent $CHANGES debian-edu "git${GIT_COMMIT:0:7}" fi if [ -d $CHROOT_TARGET/proc ]; then diff --git a/bin/common-functions.sh b/bin/common-functions.sh index c68d4170..b8631473 100755 --- a/bin/common-functions.sh +++ b/bin/common-functions.sh @@ -69,3 +69,37 @@ else fi } +publish_changes_to_userContent(){ + echo "Extracting contents from .deb files..." + CHANGES=$1 + CHANNEL=$2 + SRCPKG=$(basename $CHANGES | cut -d "_" -f1) + if [ -z "$SRCPKG" ] ; then + exit 1 + fi + VERSION=$(basename $CHANGES | cut -d "_" -f2) + TARGET="/var/lib/jenkins/userContent/$SRCPKG" + NEW_CONTENT=$(mktemp -d) + for DEB in $(dcmd --deb $CHANGES) ; do + dpkg --extract $DEB ${NEW_CONTENT} 2>/dev/null + done + rm -rf $TARGET + mkdir $TARGET + mv ${NEW_CONTENT}/usr/share/doc/${SRCPKG}-* $TARGET/ + rm -r ${NEW_CONTENT} + if [ -z "$3" ] ; then + touch "$TARGET/${VERSION}" + FROM="" + else + touch "$TARGET/${VERSION}_$3" + FROM=" from $3" + fi + MESSAGE="https://jenkins.debian.net/userContent/$SRCPKG/ has been updated${FROM}." + echo + echo $MESSAGE + echo + if [ ! -z "$CHANNEL" ] ; then + kgb-client --conf /srv/jenkins/kgb/$CHANNEL.conf --relay-msg "$MESSAGE" + fi +} + diff --git a/bin/d-i_manual.sh b/bin/d-i_manual.sh index fa014e50..6c9c7e22 100755 --- a/bin/d-i_manual.sh +++ b/bin/d-i_manual.sh @@ -20,6 +20,10 @@ init_workspace() { } pdebuild_package() { + # + # only used to build the installation-guide package + # + SOURCE=installation-guide # # prepare build # @@ -35,9 +39,12 @@ pdebuild_package() { cd manual NUM_CPU=$(cat /proc/cpuinfo |grep ^processor|wc -l) pdebuild --use-pdebuild-internal --debbuildopts "-j$NUM_CPU" - # cleanup - SOURCE=$(grep "^Source: " debian/control |cut -d " " -f2) - sudo dcmd rm /var/cache/pbuilder/result/${SOURCE}_*changes + # + # publish and cleanup + # + CHANGES=$(ls /var/cache/pbuilder/result/${SOURCE}_*changes) + publish_changes_to_userContent $CHANGES debian-boot "svn-r$SVN_REVISION" + sudo dcmd rm $CHANGES cd .. } -- cgit v1.2.3-54-g00ecf