diff options
author | Michael Schroeder <mls@suse.de> | 2014-07-10 14:37:03 +0200 |
---|---|---|
committer | Michael Schroeder <mls@suse.de> | 2014-07-10 14:37:03 +0200 |
commit | f7deea488a8e2cbf1959cc84ecb8b21efa3e1b69 (patch) | |
tree | 536db4ed9cbdc3eb8716067f5d7763ba2caae679 | |
parent | e26ecdccd4fe0164771696f73a366614a12f8115 (diff) | |
parent | b6843f33786e56b55bad2a7903cf6d64c6bc70b2 (diff) |
Merge pull request #116 from jblunck/livebuild-build-binaries
Requested changes to use /.build.binaries as a repository path
-rw-r--r-- | Build/LiveBuild.pm | 23 | ||||
-rwxr-xr-x | build | 1 | ||||
-rw-r--r-- | build-recipe-livebuild | 137 | ||||
-rw-r--r-- | build-vm | 2 | ||||
-rwxr-xr-x | t/live-build | 11 | ||||
-rw-r--r-- | t/standard.livebuild | bin | 40960 -> 40960 bytes |
6 files changed, 136 insertions, 38 deletions
diff --git a/Build/LiveBuild.pm b/Build/LiveBuild.pm index d5bebcf..55c060d 100644 --- a/Build/LiveBuild.pm +++ b/Build/LiveBuild.pm @@ -73,19 +73,24 @@ sub parse { # check that directory layout matches live-build directory structure - # TODO: add dependency injection package based on $LB_DISTRIBUTION - my @packages = ( 'live-build-desc-wheezy' ); - + # defaults live-build package dependencies base on 4.0~a26 gathered with: + # $ grep Check_package -r /usr/lib/live/build my @lb4_requirements = ( - 'live-boot', 'live-config', 'e2fsprogs', 'squashfs-tools', 'mtd-tools', - 'dosfstools', 'parted', 'grub', 'syslinux', 'syslinux-common', - 'librsvg2-bin', 'xorriso', 'zsync', 'apt-utils', 'dctrl-tools', - 'debconf', 'wget' ); + 'apt-utils', 'dctrl-tools', 'debconf', 'dosfstools', 'e2fsprogs', 'grub', + 'librsvg2-bin', 'live-boot', 'live-config', 'mtd-tools', 'parted', + 'squashfs-tools', 'syslinux', 'syslinux-common', 'wget', 'xorriso', + 'zsync' ); + + # dependency injection based on live-build version + my @packages = @{$config->{'substitute'}->{'build-packages:livebuild'} || []}; + push @packages, @lb4_requirements unless @packages; - push @packages, @lb4_requirements; + # always require the list of packages required by live-boot for + # bootstrapping the target distribution image (e.g. with debootstrap) + push @packages, ( 'live-build-desc' ); for my $file ($tar->list_files('')) { - next unless $file =~ /^config\/package-lists\/.*/; + next unless $file =~ /^config\/package-lists\/.*\.list.*/; push @packages, parse_package_list($tar->get_content($file)); } @@ -1071,6 +1071,7 @@ for RECIPEFILE in "${RECIPEFILES[@]}" ; do test "$BUILDTYPE" = preinstallimage && mkdir -p $BUILD_ROOT/.preinstall_image egrep '^#[ ]*needsbinariesforbuild[ ]*$' >/dev/null <$MYSRCDIR/$RECIPEFILE && CREATE_BUILD_BINARIES=--create-build-binaries test "$BUILDTYPE" = mock && CREATE_BUILD_BINARIES=--create-build-binaries + test "$BUILDTYPE" = livebuild && CREATE_BUILD_BINARIES=--create-build-binaries set -- init_buildsystem --configdir "$CONFIG_DIR" --cachedir "$CACHE_DIR" "${definesnstuff[@]}" "${repos[@]}" $CLEAN_BUILD $USEUSEDFORBUILD $CREATE_BUILD_BINARIES $RPMLIST "$MYSRCDIR/$RECIPEFILE" $ADDITIONAL_PACKS echo "$* ..." start_time=`date +%s` diff --git a/build-recipe-livebuild b/build-recipe-livebuild index 7b6f095..dc9dfad 100644 --- a/build-recipe-livebuild +++ b/build-recipe-livebuild @@ -30,15 +30,7 @@ recipe_setup_livebuild() { if test "$MYSRCDIR" = $BUILD_ROOT/.build-srcdir ; then mv "$MYSRCDIR"/* $BUILD_ROOT$TOPDIR/SOURCES/ else - if test -z "$LINKSOURCES" ; then - cp -dLR "$MYSRCDIR"/* $BUILD_ROOT$TOPDIR/SOURCES/ - else - cp -lR "$MYSRCDIR"/* $BUILD_ROOT$TOPDIR/SOURCES/ - fi - if test "$?" != 0 ; then - echo "source copy failed" - cleanup_and_exit 1 - fi + cp -p "$MYSRCDIR"/* $BUILD_ROOT$TOPDIR/SOURCES/ fi } @@ -46,6 +38,73 @@ recipe_prepare_livebuild() { : } +createrepo_debian() +{ + local DIR=${1} + local ARCH=${2} + local DIST=${3} + + if [ -z "${DIR}" -o ! -d ${DIR} -o ${DIR} = ${DIR##${BUILD_ROOT}} ] ; then + return + fi + + pushd ${DIR} >/dev/null + + # cleanup existing repository files + rm -f Packages Packages.gz Release + rm -fr dists + + mkdir -p dists/${DIST} + # Suite is symlinked to Codename + ln -s ${DIST} dists/stable + + # create Packages and Sources files + mkdir -p dists/${DIST}/main/binary-${ARCH} + mkdir -p dists/${DIST}/main/source + cat > ${BUILD_ROOT}/.createrepo_debian.tmp.sh <<EOF +cd /.build.binaries || exit 1 +dpkg-scanpackages -m . > dists/${DIST}/main/binary-${ARCH}/Packages +gzip -c9 < dists/${DIST}/main/binary-${ARCH}/Packages \ + > dists/${DIST}/main/binary-${ARCH}/Packages.gz +dpkg-scansources . > dists/${DIST}/main/source/Sources +gzip -c9 dists/${DIST}/main/source/Sources \ + > dists/${DIST}/main/source/Sources.gz +EOF + chroot $BUILD_ROOT su -c "sh /.createrepo_debian.tmp.sh" - root + local RESULT=$? + rm -f $BUILD_ROOT/.createrepo_debian.tmp.sh + [ "${RESULT}" != 0 ] && return + + # create Release file + pushd dists/${DIST} >/dev/null + cat > Release <<EOF +Origin: Debian +Label: Debian +Suite: stable +Version: 7.1 +Codename: ${DIST} +Date: Sat, 15 Jun 2013 10:55:26 UTC +Description: Debian repository created by build-recipe-livebuild +Components: main +EOF + echo "SHA256:" >> Release + for file in main/binary-${ARCH}/Packages* ; do + local SUM=( $(sha256sum ${file}) ) + local SIZE=$(stat -c '%s' ${file}) + echo " ${SUM} ${SIZE} ${file}" >> Release + done + for file in main/source/Sources* ; do + local SUM=( $(sha256sum ${file}) ) + local SIZE=$(stat -c '%s' ${file}) + echo " ${SUM} ${SIZE} ${file}" >> Release + done + popd >/dev/null + + # TODO: this is missing the signature with the private key + + popd >/dev/null +} + # This script expects that the $BUILD_ROOT is a Debian installation with # live-build already installed! # @@ -56,26 +115,58 @@ recipe_prepare_livebuild() { # $RECIPEFILE the name of the live-build config tarball recipe_build_livebuild() { + local ARCH=$(chroot $BUILD_ROOT su -c "dpkg-architecture -qDEB_BUILD_ARCH") + local DIST=$(chroot $BUILD_ROOT su -c "lsb_release --codename" | awk '{ print $2 }') + + [ -z "${ARCH}" -o -z "${DIST}" ] && cleanup_and_exit 1 + + test -d $BUILD_ROOT/.build.binaries || cleanup_and_exit 1 + if test "$DO_INIT" = true -o ! -d "$BUILD_ROOT/.build.binaries/dists" ; then + echo "creating repository metadata..." + createrepo_debian $BUILD_ROOT/.build.binaries ${ARCH} ${DIST} + fi - echo "Creating repository metadata" - cat > $BUILD_ROOT/.build.run_livebuild.tmp.sh <<EOF -cd $TOPDIR/SOURCES/repos || exit 1 -apt-ftparchive packages . > Packages -gzip -c9 Packages > Packages.gz -apt-ftparchive sources . > Sources -gzip -c9 Sources > Sources.gz -apt-ftparchive release . > Release + # Write our default configuration variables + mkdir -p $BUILD_ROOT/etc/live + cat > $BUILD_ROOT/etc/live/build.conf <<EOF +LB_DEBIAN_INSTALLER_DISTRIBUTION="${DIST}" +LB_DISTRIBUTION="${DIST}" +LB_PARENT_DISTRIBUTION="${DIST}" +LB_PARENT_DEBIAN_INSTALLER_DISTRIBUTION="${DIST}" +LB_PARENT_MIRROR_BOOTSTRAP="file:/.build.binaries/" +LB_PARENT_MIRROR_CHROOT="file:/.build.binaries/" +LB_PARENT_MIRROR_CHROOT_SECURITY="file:/.build.binaries/" +LB_PARENT_MIRROR_BINARY="file:/.build.binaries/" +LB_PARENT_MIRROR_BINARY_SECURITY="file:/.build.binaries/" +LB_PARENT_MIRROR_DEBIAN_INSTALLER="file:/.build.binaries/" +LB_MIRROR_BOOTSTRAP="file:/.build.binaries/" +LB_MIRROR_CHROOT="file:/.build.binaries/" +LB_MIRROR_CHROOT_SECURITY="file:/.build.binaries/" +LB_MIRROR_BINARY="file:/.build.binaries/" +LB_MIRROR_BINARY_SECURITY="file:/.build.binaries/" +LB_MIRROR_DEBIAN_INSTALLER="file:/.build.binaries/" +LB_APT_SECURE="false" EOF - chroot $BUILD_ROOT su -c "sh /.build.run_livebuild.tmp.sh" - root - local RESULT=$? - rm -f $BUILD_ROOT/.build.run_livebuild.tmp.sh - [ "${RESULT}" != 0 ] && cleanup_and_exit 1 # Expand live-build configuration to $TOPDIR/LIVEBUILD_ROOT echo "Expanding live-build configuration" tar -xvf $BUILD_ROOT/$TOPDIR/SOURCES/$RECIPEFILE \ -C $BUILD_ROOT/$TOPDIR/LIVEBUILD_ROOT || cleanup_and_exit 1 + # Sanity check to not configure archives inside configuration + local files=($BUILD_ROOT/$TOPDIR/LIVEBUILD_ROOT/config/archives/*) + [ ${#files[@]} -gt 0 ] && cleanup_and_exit 1 + + # TODO: Add the repository public key + # cp ... $BUILD_ROOT/$TOPDIR/LIVEBUILD_ROOT/config/archives/debian.key + + if [ -x $BUILD_ROOT/usr/lib/build/livebuild_pre_run ] ; then + echo "Running OBS build livebuild_pre_run hook" + chroot $BUILD_ROOT su -c "/usr/lib/build/livebuild_pre_run" - root \ + < /dev/null || cleanup_and_exit 1 + fi + + # TODO: this might move to lb auto/config file if [ -f $BUILD_ROOT/$TOPDIR/SOURCES/livebuild_pre_run ] ; then cp $BUILD_ROOT/$TOPDIR/SOURCES/livebuild_pre_run \ $BUILD_ROOT/.build.livebuild_pre_run @@ -83,10 +174,6 @@ EOF echo "Running package livebuild_pre_run hook" chroot $BUILD_ROOT su -c "/.build.livebuild_pre_run" - root \ < /dev/null || cleanup_and_exit 1 - elif [ -x $BUILD_ROOT/usr/lib/build/livebuild_pre_run ] ; then - echo "Running OBS build livebuild_pre_run hook" - chroot $BUILD_ROOT su -c "/usr/lib/build/livebuild_pre_run" - root \ - < /dev/null || cleanup_and_exit 1 fi chroot $BUILD_ROOT su -c "cd $TOPDIR/LIVEBUILD_ROOT && lb build" - root \ @@ -599,8 +599,6 @@ vm_first_stage() { mkdir "$BUILD_ROOT/.build-srcdir" if test "$BUILDTYPE" = kiwi ; then cp -pRL "$MYSRCDIR"/* $BUILD_ROOT/.build-srcdir - elif test "$BUILDTYPE" = livebuild ; then - cp -pRL "$MYSRCDIR"/* $BUILD_ROOT/.build-srcdir else cp -p "$MYSRCDIR"/* $BUILD_ROOT/.build-srcdir fi diff --git a/t/live-build b/t/live-build index 022f9d3..7e49b4f 100755 --- a/t/live-build +++ b/t/live-build @@ -1,7 +1,7 @@ #!/usr/bin/perl -w -I .. use strict; -use Test::More tests => 3; +use Test::More tests => 4; use Build::LiveBuild; use Data::Dumper; @@ -37,6 +37,13 @@ is(Dumper(Build::LiveBuild::parse_archive($DEB_ARCHIVE)), $DEB_ARCHIVE_RESULT); my $config = {}; $Data::Dumper::Sortkeys = 1; is(md5_hex(Dumper(Build::LiveBuild::parse( $config, 'standard.livebuild'))), - '0e68b6473bc8dbf00e0c6f1b53af3efd'); + 'dc387355614be68eaee570929ec5b14b'); + +#print Dumper(Build::LiveBuild::parse( $config, 'standard.livebuild')); + +$config->{'substitute'}->{'build-packages:livebuild'} = [ 'test-test' ]; +$Data::Dumper::Sortkeys = 1; +is(md5_hex(Dumper(Build::LiveBuild::parse( $config, 'standard.livebuild'))), + 'bec5a5bb552eaef5ef8f4caa55f0a4cc'); #print Dumper(Build::LiveBuild::parse( $config, 'standard.livebuild')); diff --git a/t/standard.livebuild b/t/standard.livebuild Binary files differindex af0d4ed..ae2cae0 100644 --- a/t/standard.livebuild +++ b/t/standard.livebuild |