forked from pikhq/sabotage
-
Notifications
You must be signed in to change notification settings - Fork 68
/
build-stage0
executable file
·64 lines (55 loc) · 1.55 KB
/
build-stage0
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
#!/bin/sh
set -e
### test and create prerequisites
[ -z "$CONFIG" ] && CONFIG=./config
if [ ! -r "$CONFIG" ] ; then
echo "error: config missing. please read README."
exit 1
fi
. "$CONFIG"
for i in sed wget patch bzip2 tar wc xz make ; do
if ! type "$i" >/dev/null 2>&1 ; then
echo "error: prerequisite $i not found in PATH" >&2
exit 1
fi
done
[ -z "$CC" ] && CC=gcc
tmpc=/tmp/tmp$$.c
cat <<- EOF > "$tmpc"
#include <stdlib.h>
int main () { exit(0); }
EOF
if ! "$CC" -static "$tmpc" -o "$tmpc".out ; then
rm -f "$tmpc"
echo "error: could not create static binaries (install glibc-static if on fedora or suse?)" >&2
exit 1
fi
rm -f "$tmpc" "$tmpc".out
mkdir -p "$C"
### initialize chroot, if missing
if [ ! -d "$R"/bin ] ; then
echo "$(date +'%F %T') initializing root system"
. "$H"/utils/setup-rootfs.sh
ln -s /proc/mounts "$R"/etc/mtab
"$H"/utils/update-chroot.sh
# on ARM, gcc 3.4.6 is not sufficient to build for EABI
if [ "$A" = "arm" ] ; then
cat <<- EOF > "$S"/pkg/stage0-gcc
[deps.stage0]
stage0-gcc424
EOF
cat <<- EOF > "$S"/pkg/stage1-g++
[deps.stage1]
stage1-gcc424
EOF
fi
fi
### install stage0, if missing. note the space in "stage0 "
if ! grep -q "stage0 " "$R"/var/lib/butch.db 2>/dev/null ; then
echo "$(date +'%F %T') installing stage0"
CONFIG="$H"/config BUTCHDB="$R"/var/lib/butch.db DEPS=build:stage0 \
"$K"/bin/butch install stage0
echo "export A=$A" > "$R"/src/config
cat "$K"/config.stage1 >> "$R"/src/config
[ -z "$MAKE_THREADS" ] || sed -i "s@MAKE_THREADS=1@MAKE_THREADS=$MAKE_THREADS@" "$R"/src/config
fi