File build-recipe-simpleimage of Package build
################################################################
#
# 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 SOURCES OTHER ; do
mkdir -p "$BUILD_ROOT$TOPDIR/$i"
done
if test "$MYSRCDIR" = $BUILD_ROOT/.build-srcdir ; then
mv "$MYSRCDIR"/* $BUILD_ROOT$TOPDIR/SOURCES/
else
copy_sources "$MYSRCDIR" "$BUILD_ROOT$TOPDIR/SOURCES/"
fi
chown -hR "$ABUILD_UID:$ABUILD_GID" "$BUILD_ROOT$TOPDIR"
}
recipe_prepare_simpleimage() {
BUILD_USER="root"
}
recipe_build_simpleimage() {
TOPDIR=/usr/src/packages
rm -f $BUILD_ROOT/.build.packages
ln -s ${TOPDIR#/} $BUILD_ROOT/.build.packages
echo "creating simple image..."
cd $BUILD_ROOT || cleanup_and_exit 1
export SRCDIR="$BUILD_ROOT$TOPDIR/SOURCES"
NAME="`sed -n 's|Name:[[:blank:]]*||p' $SRCDIR/simpleimage`"
[ -n "$NAME" ] || NAME="simpleimage"
VERSION="`sed -n 's|Version:[[:blank:]]*||p' $SRCDIR/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$' $SRCDIR/simpleimage`" ]; then
echo "Running integration script..."
sed -n '/%build/,$ p' $SRCDIR/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
mkdir -p .tmp/{proc,sys}
if ! grep -q "^#!NoSquashfs" $SRCDIR/simpleimage; then
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
fi
if ! grep -q "^#!NoTarBall" $SRCDIR/simpleimage; then
if ! $TAR -cvzf .simpleimage.tar.gz --one-file-system $TOPDIRS -C .tmp proc sys; then
cleanup_and_exit 1
fi
fi
echo "simple image created."
DEST="$BUILD_ROOT$TOPDIR/OTHER"
mkdir -p "$DEST"
if [ -r "$BUILD_ROOT/.simpleimage.tar.gz" ]; then
mv "$BUILD_ROOT/.simpleimage.tar.gz" "$DEST/$NAME-${VERSION}_${BUILD_ARCH%%:*}.tar.gz"
fi
if [ -r .simpleimage.squashfs ]; then
mv $BUILD_ROOT/.simpleimage.squashfs $DEST/$NAME-${VERSION}_${BUILD_ARCH%%:*}.squashfs
fi
test -d "$SRCDIR" && cd "$SRCDIR"
BUILD_SUCCEEDED=true
}
recipe_resultdirs_simpleimage() {
:
}
recipe_cleanup_simpleimage() {
:
}