summaryrefslogtreecommitdiff
path: root/build-recipe-kiwi
diff options
context:
space:
mode:
authorshuai.fu <shuai01.fu@samsung.com>2017-04-22 13:43:02 +0800
committershuai.fu <shuai01.fu@samsung.com>2017-04-22 13:44:05 +0800
commit794c348d0165d1406fd603d958bcbfc1fe62fa49 (patch)
tree7a54881bcad7dcc862eec79ada03b9e3500909c0 /build-recipe-kiwi
parente3da5fcdb300a12c57e4b0828f9fcc50140f48fd (diff)
downloadbuild-794c348d0165d1406fd603d958bcbfc1fe62fa49.tar.gz
build-794c348d0165d1406fd603d958bcbfc1fe62fa49.tar.bz2
build-794c348d0165d1406fd603d958bcbfc1fe62fa49.zip
Update to upstream 20160629
Change-Id: Idc31c269aec94e852b30885dee65a827b318b7a3 Signed-off-by: shuai.fu <shuai01.fu@samsung.com>
Diffstat (limited to 'build-recipe-kiwi')
-rw-r--r--build-recipe-kiwi139
1 files changed, 117 insertions, 22 deletions
diff --git a/build-recipe-kiwi b/build-recipe-kiwi
index 6f8e6a1..206dc94 100644
--- a/build-recipe-kiwi
+++ b/build-recipe-kiwi
@@ -259,10 +259,16 @@ kiwi_post_unknown() {
recipe_setup_kiwi() {
TOPDIR=/usr/src/packages
+ test "$DO_INIT_TOPDIR" = false || rm -rf "$BUILD_ROOT$TOPDIR"
mkdir -p "$BUILD_ROOT$TOPDIR"
mkdir -p "$BUILD_ROOT$TOPDIR/OTHER"
mkdir -p "$BUILD_ROOT$TOPDIR/SOURCES"
mkdir -p "$BUILD_ROOT$TOPDIR/KIWI"
+ # compat, older build versions did not clean TOPDIR ...
+ mkdir -p "$BUILD_ROOT$TOPDIR/BUILD"
+ mkdir -p "$BUILD_ROOT$TOPDIR/RPMS"
+ mkdir -p "$BUILD_ROOT$TOPDIR/SRPMS"
+
chown -R "$ABUILD_UID:$ABUILD_GID" "$BUILD_ROOT$TOPDIR"
if test "$MYSRCDIR" = $BUILD_ROOT/.build-srcdir ; then
mv "$MYSRCDIR"/* $BUILD_ROOT$TOPDIR/SOURCES/
@@ -319,10 +325,10 @@ build_kiwi_product() {
fi
# move created product to correct destination
- for i in $BUILD_ROOT/$TOPDIR/KIWIROOT/main/* ; do
+ pushd $BUILD_ROOT/$TOPDIR/KIWIROOT/main
+ for i in * ; do
test -e "$i" || continue
- f=${i##*/}
- case $f in
+ case $i in
*.iso) if [ -x /usr/bin/sha256sum ]; then
/usr/bin/sha256sum "$i" > "$i.sha256"
mv "$i.sha256" $BUILD_ROOT/$TOPDIR/KIWI/.
@@ -335,26 +341,115 @@ build_kiwi_product() {
*) test -d $i -a "$drop_repo" != true && mv $i $BUILD_ROOT/$TOPDIR/KIWI/. ;;
esac
done
+ popd
+}
+
+perform_image_build() {
+ local imgtype=$1
+ local legacy=$2
+ local prepare_call
+ local create_call
+ # When people test mixed build with legacy and new kiwi version
+ # The zypper cache was used in different ways. Therefore this
+ # needs a cleanup before the build starts
+ echo "Cleanup zypper image build cache"
+ if [ -d "$BUILD_ROOT/var/cache/kiwi/zypper" ];then
+ rm -rf $BUILD_ROOT/var/cache/kiwi/zypper
+ fi
+ echo "running kiwi --prepare for $imgtype..."
+ # Do not use $BUILD_USER here, since we always need root permissions
+ prepare_call="cd $TOPDIR/SOURCES && rm -rf $TOPDIR/KIWIROOT-$imgtype"
+ if [ "$legacy" = "true" ]; then
+ prepare_call="$prepare_call && /usr/sbin/kiwi --logfile terminal"
+ else
+ prepare_call="$prepare_call && LANG=en_US.UTF-8 /usr/bin/kiwi"
+ prepare_call="$prepare_call --compat -- --debug"
+ fi
+ prepare_call="$prepare_call --prepare $TOPDIR/SOURCES"
+ prepare_call="$prepare_call --root $TOPDIR/KIWIROOT-$imgtype"
+ prepare_call="$prepare_call $KIWI_PARAMETERS"
+ chroot $BUILD_ROOT \
+ su -c "$prepare_call" - root < /dev/null || cleanup_and_exit 1
+
+ echo "running kiwi --create for $imgtype..."
+ mkdir -p $BUILD_ROOT/$TOPDIR/KIWI-$imgtype
+ create_call="cd $TOPDIR/SOURCES"
+ if [ "$legacy" = "true" ]; then
+ create_call="$create_call && LANG=en_US.UTF-8 /usr/sbin/kiwi"
+ create_call="$create_call --logfile terminal"
+ else
+ create_call="$create_call && /usr/bin/kiwi --compat -- --debug"
+ fi
+ create_call="$create_call --create $TOPDIR/KIWIROOT-$imgtype"
+ create_call="$create_call --type $imgtype"
+ create_call="$create_call -d $TOPDIR/KIWI-$imgtype"
+ create_call="$create_call $KIWI_PARAMETERS"
+ chroot $BUILD_ROOT \
+ su -c "$create_call" - root < /dev/null || cleanup_and_exit 1
+
+ rm -rf "/$TOPDIR/KIWI.bundle"
+}
+
+perform_image_bundle() {
+ local imgtype=$1
+ local legacy=$2
+ local bundle_call
+ if [ "$legacy" = "true" ]; then
+ bundle_call="/usr/sbin/kiwi --bundle-build $TOPDIR/KIWI-$imgtype"
+ bundle_call="$bundle_call -d /$TOPDIR/KIWI.bundle/"
+ bundle_call="$bundle_call --bundle-id Build$RELEASE"
+ else
+ bundle_call="LANG=en_US.UTF-8 /usr/bin/kiwi result bundle"
+ bundle_call="$bundle_call --target-dir $TOPDIR/KIWI-$imgtype"
+ bundle_call="$bundle_call --id Build$RELEASE"
+ bundle_call="$bundle_call --bundle-dir /$TOPDIR/KIWI.bundle/"
+ fi
+ if chroot $BUILD_ROOT su -c "$bundle_call" - root < /dev/null; then
+ mv "$BUILD_ROOT/$TOPDIR/KIWI.bundle/"* \
+ "$BUILD_ROOT/$TOPDIR/KIWI/" || cleanup_and_exit 1
+ rmdir "$BUILD_ROOT/$TOPDIR/KIWI.bundle"
+ # success
+ return 0
+ fi
+ # need another way to bundle
+ return 1
+}
+
+is_legacy_kiwi() {
+ if [ -L "$BUILD_ROOT/usr/bin/kiwi" ];then
+ # The next generation of kiwi is installed to /usr/bin
+ # If this file is found we expect the new kiwi to be
+ # installed
+ return 1
+ fi
+ # in any other case stick to the legacy kiwi
+ return 0
}
build_kiwi_appliance() {
if test -z "$RUNNING_IN_VM" ; then
- # NOTE: this must be done with the outer system, because it loads the dm-mod kernel modules, which needs to fit to the kernel.
- echo "starting device mapper for kiwi..."
- test -x /etc/init.d/boot.device-mapper && /etc/init.d/boot.device-mapper start
+ # NOTE: this must be done with the outer system, because it loads
+ # the dm-mod kernel modules, which needs to fit to the kernel.
+ echo "starting device mapper for kiwi..."
+ test -x /etc/init.d/boot.device-mapper && \
+ /etc/init.d/boot.device-mapper start
+ fi
+ KIWI_PROFILE=$(queryconfig \
+ --dist "$BUILD_DIST" --configdir "$CONFIG_DIR" \
+ --archpath "$BUILD_ARCH" buildflags kiwiprofile
+ )
+ if test -n "$KIWI_PROFILE"; then
+ KIWI_PARAMETERS="$KIWI_PARAMETERS --add-profile $KIWI_PROFILE"
+ fi
+ local legacy=false
+ if is_legacy_kiwi; then
+ legacy=true
fi
RUN_BUNDLE="true"
for imgtype in $imagetype ; do
- echo "running kiwi --prepare for $imgtype..."
- # Do not use $BUILD_USER here, since we always need root permissions
- chroot $BUILD_ROOT su -c "cd $TOPDIR/SOURCES && rm -rf $TOPDIR/KIWIROOT-$imgtype && kiwi --prepare $TOPDIR/SOURCES --logfile terminal --root $TOPDIR/KIWIROOT-$imgtype $KIWI_PARAMETERS" - root < /dev/null || cleanup_and_exit 1
- echo "running kiwi --create for $imgtype..."
- mkdir -p $BUILD_ROOT/$TOPDIR/KIWI-$imgtype
- chroot $BUILD_ROOT su -c "cd $TOPDIR/SOURCES && kiwi --create $TOPDIR/KIWIROOT-$imgtype --logfile terminal --type $imgtype -d $TOPDIR/KIWI-$imgtype $KIWI_PARAMETERS" - root < /dev/null || cleanup_and_exit 1
- rm -rf "/$TOPDIR/KIWI.bundle"
- if chroot $BUILD_ROOT su -c "kiwi --bundle-build $TOPDIR/KIWI-$imgtype -d /$TOPDIR/KIWI.bundle/ --bundle-id Build$RELEASE" - root < /dev/null; then
- mv "$BUILD_ROOT/$TOPDIR/KIWI.bundle/"* "$BUILD_ROOT/$TOPDIR/KIWI/" || cleanup_and_exit 1
- rmdir "$BUILD_ROOT/$TOPDIR/KIWI.bundle"
+ perform_image_build $imagetype $legacy
+ if perform_image_bundle $imagetype $legacy; then
+ # bundling successful, skip alternative bundlers
unset RUN_BUNDLE
fi
done
@@ -415,18 +510,18 @@ recipe_build_kiwi() {
# prepare rpms as source and createrepo on the repositories
ln -sf $TOPDIR/SOURCES/repos $BUILD_ROOT/repos
cd $BUILD_ROOT/$TOPDIR/SOURCES/repos
- for r in */* ; do
+ for r in *[^:]/* ; do
test -L $r && continue
test -d $r || continue
repo="$TOPDIR/SOURCES/repos/$r/"
# create compatibility link for old kiwi versions
rc="${r//:/:/}"
if test "$rc" != "$r" ; then
- rl="${rc//[^\/]}"
- rl="${rl//?/../}"
- mkdir -p "${rc%/*}"
- ln -s $rl$r "${rc%/*}/${rc##*/}"
- repo="$TOPDIR/SOURCES/repos/${rc%/*}/${rc##*/}/"
+ rl="${rc//[^\/]}"
+ rl="${rl//?/../}"
+ mkdir -p "${rc%/*}"
+ ln -s $rl$r "${rc%/*}/${rc##*/}"
+ repo="$TOPDIR/SOURCES/repos/${rc%/*}/${rc##*/}/"
fi
if test "$imagetype" != product -a "$DO_INIT" != "false" ; then
echo "creating repodata for $repo"