forked from openSUSE/obs-build
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-recipe-simpleimage
112 lines (101 loc) · 3.58 KB
/
build-recipe-simpleimage
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
################################################################
#
# 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
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"
BUILD_SUCCEEDED=true
}
recipe_resultdirs_simpleimage() {
:
}
recipe_cleanup_simpleimage() {
:
}