################################################################ # # Copyright (c) 1995-2014 SUSE Linux Products GmbH # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 or 3 as # published by the Free Software Foundation. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program (see the file COPYING); if not, write to the # Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA # ################################################################ recipe_setup_simpleimage() { TOPDIR=/usr/src/packages rm -rf "$BUILD_ROOT$TOPDIR" for i in OTHER SOURCES LIVEBUILD_ROOT ; do mkdir -p "$BUILD_ROOT$TOPDIR/$i" done chown -R "$ABUILD_UID:$ABUILD_GID" "$BUILD_ROOT$TOPDIR" if test "$MYSRCDIR" = $BUILD_ROOT/.build-srcdir ; then mv "$MYSRCDIR"/* $BUILD_ROOT$TOPDIR/SOURCES/ else cp -p "$MYSRCDIR"/* $BUILD_ROOT$TOPDIR/SOURCES/ fi } recipe_prepare_simpleimage() { BUILD_USER="root" } recipe_build_simpleimage() { TOPDIR=/usr/src/packages echo "creating simple image..." cd $BUILD_ROOT || cleanup_and_exit 1 export SRCDIR="$TOPDIR/SOURCES" NAME="`sed -n 's|Name:[[:blank:]]*||p' $BUILD_ROOT$TOPDIR/SOURCES/simpleimage`" [ -n "$NAME" ] || NAME="simpleimage" VERSION="`sed -n 's|Version:[[:blank:]]*||p' $BUILD_ROOT$TOPDIR/SOURCES/simpleimage`" [ -n "$VERSION" ] || VERSION="`date -u +%y.%m.%d-%H.%M.%S`" SHELL="/bin/sh" [ -x $BUILD_ROOT/bin/bash ] && SHELL="/bin/bash" if [ "`grep '^%build$' $BUILD_ROOT$TOPDIR/SOURCES/simpleimage`" ]; then echo "Running integration script..." sed -n '/%build/,$ p' $BUILD_ROOT$TOPDIR/SOURCES/simpleimage | tail -n +2 | chroot $BUILD_ROOT $SHELL -x || cleanup_and_exit 1 echo "Integration script finished." fi echo "Compresing the final image, this can take a while..." echo TAR="tar" if test -x /usr/bin/bsdtar; then TAR="/usr/bin/bsdtar --format gnutar --chroot" fi TOPDIRS= for DIR in .* * ; do case "$DIR" in .|..) continue ;; .build*) continue ;; .simpleimage*) continue ;; .srcfiles*) continue ;; .pkgs) continue ;; .rpm-cache) continue ;; .tmp) continue ;; installed-pkg) continue ;; proc|sys) continue ;; esac TOPDIRS="$TOPDIRS $DIR" done rm -rf "$BUILD_ROOT$TOPDIR" mkdir -p .tmp/{proc,sys} if ! $TAR -cvzf .simpleimage.tar.gz --one-file-system $TOPDIRS -C .tmp proc sys; then cleanup_and_exit 1 fi if [ -x "`which mksquashfs 2> /dev/null`" ]; then echo echo "Tarball done, creating squashfs image as well" echo mksquashfs $TOPDIRS .tmp/proc .tmp/sys .simpleimage.squashfs -info -keep-as-directory -no-progress || cleanup_and_exit 1 fi echo "simple image created." DEST="$BUILD_ROOT$TOPDIR/OTHER" mkdir -p "$DEST" mv $BUILD_ROOT/.simpleimage.tar.gz $DEST/$NAME-${VERSION}_${BUILD_ARCH%%:*}.tar.gz if [ -r .simpleimage.squashfs ]; then mv $BUILD_ROOT/.simpleimage.squashfs $DEST/$NAME-${VERSION}_${BUILD_ARCH%%:*}.squashfs fi rm -f $BUILD_ROOT/.build.packages ln -s ${TOPDIR#/} $BUILD_ROOT/.build.packages test -d "$SRCDIR" && cd "$SRCDIR" cleanup_and_exit } recipe_resultdirs_simpleimage() { : } recipe_cleanup_simpleimage() { : }