Debian Codegraph @

build-recipe-simpleimage

raw
1 ################################################################
2 #
3 # Copyright (c) 1995-2014 SUSE Linux Products GmbH
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License version 2 or 3 as
7 # published by the Free Software Foundation.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program (see the file COPYING); if not, write to the
16 # Free Software Foundation, Inc.,
17 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
18 #
19 ################################################################
20
21 recipe_setup_simpleimage() {
22 TOPDIR=/usr/src/packages
23 rm -rf "$BUILD_ROOT$TOPDIR"
24 for i in SOURCES OTHER ; do
25 mkdir -p "$BUILD_ROOT$TOPDIR/$i"
26 done
27 chown -R "$ABUILD_UID:$ABUILD_GID" "$BUILD_ROOT$TOPDIR"
28 if test "$MYSRCDIR" = $BUILD_ROOT/.build-srcdir ; then
29 mv "$MYSRCDIR"/* $BUILD_ROOT$TOPDIR/SOURCES/
30 else
31 cp -p "$MYSRCDIR"/* $BUILD_ROOT$TOPDIR/SOURCES/
32 fi
33 }
34
35 recipe_prepare_simpleimage() {
36 BUILD_USER="root"
37 }
38
39 recipe_build_simpleimage() {
40 TOPDIR=/usr/src/packages
41
42 echo "creating simple image..."
43 cd $BUILD_ROOT || cleanup_and_exit 1
44 export SRCDIR="$TOPDIR/SOURCES"
45
46 NAME="`sed -n 's|Name:[[:blank:]]*||p' $BUILD_ROOT$TOPDIR/SOURCES/simpleimage`"
47 [ -n "$NAME" ] || NAME="simpleimage"
48 VERSION="`sed -n 's|Version:[[:blank:]]*||p' $BUILD_ROOT$TOPDIR/SOURCES/simpleimage`"
49 [ -n "$VERSION" ] || VERSION="`date -u +%y.%m.%d-%H.%M.%S`"
50
51 SHELL="/bin/sh"
52 [ -x $BUILD_ROOT/bin/bash ] && SHELL="/bin/bash"
53 if [ "`grep '^%build$' $BUILD_ROOT$TOPDIR/SOURCES/simpleimage`" ]; then
54 echo "Running integration script..."
55 sed -n '/%build/,$ p' $BUILD_ROOT$TOPDIR/SOURCES/simpleimage | tail -n +2 | chroot $BUILD_ROOT $SHELL -x || cleanup_and_exit 1
56 echo "Integration script finished."
57 fi
58
59 echo "Compresing the final image, this can take a while..."
60 echo
61 TAR="tar"
62 if test -x /usr/bin/bsdtar; then
63 TAR="/usr/bin/bsdtar --format gnutar --chroot"
64 fi
65 TOPDIRS=
66 for DIR in .* * ; do
67 case "$DIR" in
68 .|..) continue ;;
69 .build*) continue ;;
70 .simpleimage*) continue ;;
71 .srcfiles*) continue ;;
72 .pkgs) continue ;;
73 .rpm-cache) continue ;;
74 .tmp) continue ;;
75 installed-pkg) continue ;;
76 proc|sys) continue ;;
77 esac
78 TOPDIRS="$TOPDIRS $DIR"
79 done
80 rm -rf "$BUILD_ROOT$TOPDIR"
81 mkdir -p .tmp/{proc,sys}
82 if ! $TAR -cvzf .simpleimage.tar.gz --one-file-system $TOPDIRS -C .tmp proc sys; then
83 cleanup_and_exit 1
84 fi
85 if [ -x "`which mksquashfs 2> /dev/null`" ]; then
86 echo
87 echo "Tarball done, creating squashfs image as well"
88 echo
89 mksquashfs $TOPDIRS .tmp/proc .tmp/sys .simpleimage.squashfs -info -keep-as-directory -no-progress || cleanup_and_exit 1
90 fi
91 echo "simple image created."
92
93 DEST="$BUILD_ROOT$TOPDIR/OTHER"
94 mkdir -p "$DEST"
95 mv $BUILD_ROOT/.simpleimage.tar.gz $DEST/$NAME-${VERSION}_${BUILD_ARCH%%:*}.tar.gz
96 if [ -r .simpleimage.squashfs ]; then
97 mv $BUILD_ROOT/.simpleimage.squashfs $DEST/$NAME-${VERSION}_${BUILD_ARCH%%:*}.squashfs
98 fi
99 rm -f $BUILD_ROOT/.build.packages
100 ln -s ${TOPDIR#/} $BUILD_ROOT/.build.packages
101 test -d "$SRCDIR" && cd "$SRCDIR"
102 BUILD_SUCCEEDED=true
103 }
104
105 recipe_resultdirs_simpleimage() {
106 :
107 }
108
109 recipe_cleanup_simpleimage() {
110 :
111 }
112