From 8bf0629749ac4947762b5307b8048087f928ff13 Mon Sep 17 00:00:00 2001 From: Vasyl Saienko Date: Wed, 25 Oct 2017 17:41:11 +0300 Subject: [PATCH] Update tiny-instance image to contain branch name With this patch branch is added to tiny-instance image name. Also fixed a problem with BRANCH_PATH was set to refs/heads/master after migration to zuulv3 Change-Id: I490e2d51a7c3fbc2cc0fa78a95b984874ab934f7 --- imagebuild/tinyipa/Makefile | 4 ++-- imagebuild/tinyipa/build-instance-images.sh | 11 +++++------ imagebuild/tinyipa/common.sh | 8 ++++++++ imagebuild/tinyipa/finalise-tinyipa.sh | 19 ++++++------------- .../run.yaml | 3 ++- .../run.yaml | 5 +++-- 6 files changed, 26 insertions(+), 24 deletions(-) diff --git a/imagebuild/tinyipa/Makefile b/imagebuild/tinyipa/Makefile index 0a4febb63..6e5a7ef21 100644 --- a/imagebuild/tinyipa/Makefile +++ b/imagebuild/tinyipa/Makefile @@ -31,11 +31,11 @@ clean_build: rm -f build_files/vmlinuz64 rm -f build_files/*.tcz rm -f build_files/*.tcz.* + rm -f tiny-instance-part*.img + rm -f tiny-instance-uec*.tar.gz clean_iso: rm -rf newiso rm -f build_files/syslinux-4.06.tar.gz rm -rf build_files/syslinux-4.06 rm -f tinyipa.iso - rm -f tiny-instance-part.img - rm -f tiny-instance-uec.tar.gz diff --git a/imagebuild/tinyipa/build-instance-images.sh b/imagebuild/tinyipa/build-instance-images.sh index 977b7b4ba..120377166 100755 --- a/imagebuild/tinyipa/build-instance-images.sh +++ b/imagebuild/tinyipa/build-instance-images.sh @@ -3,11 +3,10 @@ set -ex WORKDIR=$(readlink -f $0 | xargs dirname) DST_DIR=$(mktemp -d) -PARTIMG="$WORKDIR/tiny-instance-part.img" -UECFILE="$WORKDIR/tiny-instance-uec.tar.gz" -fs_type='ext4' - source ${WORKDIR}/common.sh +PARTIMG="$WORKDIR/tiny-instance-part${BRANCH_EXT}.img" +UECFILE="$WORKDIR/tiny-instance-uec${BRANCH_EXT}.tar.gz" +fs_type='ext4' sudo rm -rf $PARTIMG $UECFILE sudo truncate --size=150M $PARTIMG @@ -26,8 +25,8 @@ cleanup_tce $DST_DIR sudo umount $DST_DIR/ pushd $DST_DIR/ -cp $WORKDIR/tinyipa.gz $DST_DIR/tinyipa-initrd -cp $WORKDIR/tinyipa.vmlinuz $DST_DIR/tinyipa-vmlinuz +cp $WORKDIR/tinyipa${BRANCH_EXT}.gz $DST_DIR/tinyipa-initrd +cp $WORKDIR/tinyipa${BRANCH_EXT}.vmlinuz $DST_DIR/tinyipa-vmlinuz cp $PARTIMG $DST_DIR/ tar -czf $UECFILE ./ diff --git a/imagebuild/tinyipa/common.sh b/imagebuild/tinyipa/common.sh index 983554b90..44d9d0877 100755 --- a/imagebuild/tinyipa/common.sh +++ b/imagebuild/tinyipa/common.sh @@ -3,6 +3,14 @@ WORKDIR=$(readlink -f $0 | xargs dirname) source ${WORKDIR}/tc-mirror.sh +# Allow an extension to be added to the generated files by specifying +# $BRANCH_PATH e.g. export BRANCH_PATH=master results in tinyipa-master.gz etc +BRANCH_EXT='' +if [ -n "$BRANCH_PATH" ]; then + BRANCH_EXT="-$BRANCH_PATH" +fi +export BRANCH_EXT + TC=1001 STAFF=50 diff --git a/imagebuild/tinyipa/finalise-tinyipa.sh b/imagebuild/tinyipa/finalise-tinyipa.sh index 86d0ea3a5..590837ac3 100755 --- a/imagebuild/tinyipa/finalise-tinyipa.sh +++ b/imagebuild/tinyipa/finalise-tinyipa.sh @@ -148,30 +148,23 @@ fi # Delete unnecessary Babel .dat files find $FINALDIR -path "*babel/locale-data/*.dat" -not -path "*en_US*" | sudo xargs --no-run-if-empty rm -# Allow an extension to be added to the generated files by specifying -# $BRANCH_PATH e.g. export BRANCH_PATH=master results in tinyipa-master.gz etc -branch_ext='' -if [ -n "$BRANCH_PATH" ]; then - branch_ext="-$BRANCH_PATH" -fi - # Rebuild build directory into gz file -( cd "$FINALDIR" && sudo find | sudo cpio -o -H newc | gzip -9 > "$WORKDIR/tinyipa${branch_ext}.gz" ) +( cd "$FINALDIR" && sudo find | sudo cpio -o -H newc | gzip -9 > "$WORKDIR/tinyipa${BRANCH_EXT}.gz" ) # Copy vmlinuz to new name -cp "$WORKDIR/build_files/vmlinuz64" "$WORKDIR/tinyipa${branch_ext}.vmlinuz" +cp "$WORKDIR/build_files/vmlinuz64" "$WORKDIR/tinyipa${BRANCH_EXT}.vmlinuz" # Create tar.gz containing tinyipa files -tar czf tinyipa${branch_ext}.tar.gz tinyipa${branch_ext}.gz tinyipa${branch_ext}.vmlinuz +tar czf tinyipa${BRANCH_EXT}.tar.gz tinyipa${BRANCH_EXT}.gz tinyipa${BRANCH_EXT}.vmlinuz # Create sha256 files which will be uploaded by the publish jobs along with # the tinyipa ones in order to provide a way to verify the integrity of the tinyipa # builds. -for f in tinyipa${branch_ext}.{gz,tar.gz,vmlinuz}; do +for f in tinyipa${BRANCH_EXT}.{gz,tar.gz,vmlinuz}; do sha256sum $f > $f.sha256 done # Output files with sizes created by this script echo "Produced files:" -du -h tinyipa${branch_ext}.gz tinyipa${branch_ext}.tar.gz tinyipa${branch_ext}.vmlinuz -echo "Checksums: " tinyipa${branch_ext}.*sha256 +du -h tinyipa${BRANCH_EXT}.gz tinyipa${BRANCH_EXT}.tar.gz tinyipa${BRANCH_EXT}.vmlinuz +echo "Checksums: " tinyipa${BRANCH_EXT}.*sha256 diff --git a/playbooks/legacy/ironic-python-agent-buildimage-coreos/run.yaml b/playbooks/legacy/ironic-python-agent-buildimage-coreos/run.yaml index f16933f5c..ee3f0111d 100644 --- a/playbooks/legacy/ironic-python-agent-buildimage-coreos/run.yaml +++ b/playbooks/legacy/ironic-python-agent-buildimage-coreos/run.yaml @@ -47,7 +47,8 @@ set -e set -x BRANCH=$ZUUL_REFNAME - export BRANCH_PATH=`echo $BRANCH | tr / -` + # After migration to zuulv3 BRANCH now looks like refs/heads/master + export BRANCH_PATH=`echo $BRANCH | sed -e "s/refs\/heads\///" | tr / -` mkdir UPLOAD_RAW mkdir UPLOAD_TAR diff --git a/playbooks/legacy/ironic-python-agent-buildimage-tinyipa/run.yaml b/playbooks/legacy/ironic-python-agent-buildimage-tinyipa/run.yaml index aebb39f48..feeb4874f 100644 --- a/playbooks/legacy/ironic-python-agent-buildimage-tinyipa/run.yaml +++ b/playbooks/legacy/ironic-python-agent-buildimage-tinyipa/run.yaml @@ -47,7 +47,8 @@ set -e set -x BRANCH=$ZUUL_REFNAME - export BRANCH_PATH=`echo $BRANCH | tr / -` + # After migration to zuulv3 BRANCH now looks like refs/heads/master + export BRANCH_PATH=`echo $BRANCH | sed -e "s/refs\/heads\///" | tr / -` mkdir UPLOAD_RAW mkdir UPLOAD_TAR @@ -82,7 +83,7 @@ (cd imagebuild/tinyipa && make) mv imagebuild/tinyipa/tinyipa*.tar.gz* UPLOAD_TAR mv imagebuild/tinyipa/tinyipa*.* UPLOAD_RAW - mv imagebuild/tinyipa/tiny-instance-uec.tar.gz UPLOAD_RAW + mv imagebuild/tinyipa/tiny-instance-uec*.tar.gz UPLOAD_TAR # NOTE(sambetts) Must clean up chroot directories before # publisher rsync command tries and fails to read them (cd imagebuild/tinyipa && make clean)