From e2c20c4b404291c8b79d1c142e8087c9f6ea322e Mon Sep 17 00:00:00 2001 From: Zhang Qiang Date: Fri, 22 Nov 2013 10:25:06 +0800 Subject: [PATCH] Add option --keep-packs to keep packages already in build root with --keep-packs, unused packages will not be removed while resusing buildroot. This can speed up build hundred of packages significantly. This option also usefull to create a single buildroot to share with other developers to build all packages. Change-Id: Ibcb68e49b8eed0bdf695485c2ec79a8eb4efb824 --- build | 8 ++++++-- init_buildsystem | 41 ++++++++++++++++++++++++----------------- 2 files changed, 30 insertions(+), 19 deletions(-) diff --git a/build b/build index 82b435f..5643628 100755 --- a/build +++ b/build @@ -77,6 +77,7 @@ DO_LINT= DO_CHECKS=true CLEAN_BUILD= USE_SYSTEM_QEMU= +KEEP_PACKS= SPECFILES=() SRCDIR= BUILD_JOBS= @@ -1188,6 +1189,9 @@ while test -n "$1"; do *-use-system-qemu) USE_SYSTEM_QEMU="--use-system-qemu" ;; + --keep-packs) + KEEP_PACKS="--keep-packs" + ;; *-root) needarg BUILD_ROOT="$ARG" @@ -2073,7 +2077,7 @@ for SPECFILE in "${SPECFILES[@]}" ; do if test "$DO_INIT" = true ; then # do first stage of init_buildsystem rm -f $BUILD_ROOT/.build.success - set -- init_buildsystem --configdir "$CONFIG_DIR" --cachedir "$CACHE_DIR" --prepare "${definesnstuff[@]}" "${repos[@]}" $CLEAN_BUILD $USE_SYSTEM_QEMU $USEUSEDFORBUILD $RPMLIST "$MYSRCDIR/$SPECFILE" $ADDITIONAL_PACKS + set -- init_buildsystem --configdir "$CONFIG_DIR" --cachedir "$CACHE_DIR" --prepare "${definesnstuff[@]}" "${repos[@]}" $CLEAN_BUILD $USE_SYSTEM_QEMU $KEEP_PACKS $USEUSEDFORBUILD $RPMLIST "$MYSRCDIR/$SPECFILE" $ADDITIONAL_PACKS echo "$* ..." start_time=`date +%s` "$@" || cleanup_and_exit 1 @@ -2598,7 +2602,7 @@ for SPECFILE in "${SPECFILES[@]}" ; do CREATE_BUILD_BINARIES= test "$BUILDTYPE" = preinstallimage && mkdir -p $BUILD_ROOT/.preinstall_image egrep '^#[ ]*needsbinariesforbuild[ ]*$' >/dev/null <$MYSRCDIR/$SPECFILE && CREATE_BUILD_BINARIES=--create-build-binaries - set -- init_buildsystem --configdir "$CONFIG_DIR" --cachedir "$CACHE_DIR" "${definesnstuff[@]}" "${repos[@]}" $CLEAN_BUILD $USE_SYSTEM_QEMU $USEUSEDFORBUILD $CREATE_BUILD_BINARIES $RPMLIST "$MYSRCDIR/$SPECFILE" $ADDITIONAL_PACKS + set -- init_buildsystem --configdir "$CONFIG_DIR" --cachedir "$CACHE_DIR" "${definesnstuff[@]}" "${repos[@]}" $CLEAN_BUILD $USE_SYSTEM_QEMU $KEEP_PACKS $USEUSEDFORBUILD $CREATE_BUILD_BINARIES $RPMLIST "$MYSRCDIR/$SPECFILE" $ADDITIONAL_PACKS echo "$* ..." start_time=`date +%s` "$@" || cleanup_and_exit 1 diff --git a/init_buildsystem b/init_buildsystem index ff0bddd..c7dc95a 100755 --- a/init_buildsystem +++ b/init_buildsystem @@ -35,6 +35,7 @@ RPMIDFMT="%{NAME}-%{VERSION}-%{RELEASE} %{BUILDTIME}\n" PREPARE_VM= USE_SYSTEM_QEMU= +KEEP_PACKS= USEUSEDFORBUILD= LIST_STATE= RPMLIST= @@ -51,6 +52,10 @@ while test -n "$1" ; do shift USE_SYSTEM_QEMU=true ;; + --keep-packs) + shift + KEEP_PACKS=true + ;; --create-build-binaries) shift CREATE_BUILD_BINARIES=true @@ -906,23 +911,25 @@ rpm_e() # # delete all packages we don't want # -mkdir -p $BUILD_ROOT/.init_b_cache/todelete -for PKG in $BUILD_ROOT/.init_b_cache/alreadyinstalled/* ; do - PKG=${PKG##*/} - test "$PKG" = "*" && continue - ln $BUILD_ROOT/.init_b_cache/alreadyinstalled/$PKG $BUILD_ROOT/.init_b_cache/todelete/$PKG -done -for PKG in $PACKAGES_TO_INSTALL; do - rm -f $BUILD_ROOT/.init_b_cache/todelete/$PKG -done -for PKG in $BUILD_ROOT/.init_b_cache/todelete/* ; do - PKG=${PKG##*/} - test "$PKG" = "*" && continue - echo "deleting $PKG" - rpm_e "$PKG" - check_exit -done -rm -rf "$BUILD_ROOT/.init_b_cache/todelete" +if [ -z "$KEEP_PACKS" ]; then + mkdir -p $BUILD_ROOT/.init_b_cache/todelete + for PKG in $BUILD_ROOT/.init_b_cache/alreadyinstalled/* ; do + PKG=${PKG##*/} + test "$PKG" = "*" && continue + ln $BUILD_ROOT/.init_b_cache/alreadyinstalled/$PKG $BUILD_ROOT/.init_b_cache/todelete/$PKG + done + for PKG in $PACKAGES_TO_INSTALL; do + rm -f $BUILD_ROOT/.init_b_cache/todelete/$PKG + done + for PKG in $BUILD_ROOT/.init_b_cache/todelete/* ; do + PKG=${PKG##*/} + test "$PKG" = "*" && continue + echo "deleting $PKG" + rpm_e "$PKG" + check_exit + done + rm -rf "$BUILD_ROOT/.init_b_cache/todelete" +fi rm -rf "$BUILD_ROOT/.init_b_cache/preinstalls" mkdir -p "$BUILD_ROOT/.init_b_cache/preinstalls" -- 2.34.1