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
112
113
114
115
116
117
118
119
120
121
122
123
124
|
#!/bin/sh
set -e
unmount_virtual()
{
umount "$1/proc" || true
umount "$1/sys" || true
umount "$1/tree/proc" || true
umount "$1/tree/sys" || true
}
export LC_ALL=C
if [ "x$1" = x ]
then
echo "Usage: $0 chroot-dir" 1>&2
exit 1
fi
mkdir -p "$1"
dir="$1/squeeze-chroot"
snapshot=true
snapshotdir="$1"
cat >"./do-squeeze-chroot" <<EOF
#!/bin/sh
if mount -t proc proc "$dir/proc"; then
trap "umount \"$dir/proc\"" INT TERM EXIT
if mount -t sysfs sysfs "$dir/sys"; then
trap "umount \"$dir/proc\" \"$dir/sys\"" INT TERM EXIT
chroot "$dir" "\$@"
fi
fi
EOF
chmod +x "./do-squeeze-chroot"
if ([ "x$DEBIAN_MIRROR" = x ] && echo DEBIAN_MIRROR is unspecified >&2) ||
([ "x$GIT_BUNDLES" = x ] && echo GIT_BUNDLES is unspecified >&2) ||
([ "x$LFS_MIRROR" = x ] && echo LFS_MIRROR is unspecified >&2)
then
echo You have to set DEBIAN_MIRROR and other environment variables 1>&2
exit 1
fi
#DEBIAN_MIRROR="http://192.168.1.185/debian"
#LFS_MIRROR=http://192.168.1.185/lfs/
unmount_virtual "$dir"
rm -rf "$dir"
mkdir "$dir"
chrootsnapshot="$snapshotdir/squeeze.tar"
if "$snapshot" && [ -e "$chrootsnapshot" ]
then
tar -C "$dir" -xf "$chrootsnapshot"
else
debootstrap \
--include=build-essential,\
gawk,bison,python,autoconf,autopoint,automake,gettext,libtool,\
help2man,texinfo,sudo,qemu-utils,parted,kpartx,mbr,extlinux \
squeeze "$dir" "$DEBIAN_MIRROR"
if "$snapshot"
then
tar -caf "$chrootsnapshot" -C "$dir" .
fi
fi
hostname > "$dir/etc/hostname"
cat <<EOF > "$dir/etc/hosts"
127.0.0.1 localhost
127.0.1.1 `hostname`
EOF
if [ "x$LFS_MIRROR" = x ]; then
cp wget-list "$dir/wget-list"
else
perl -M'Env' -lpe 's|^.*/|$LFS_MIRROR|' wget-list >"$dir/wget-list"
#gawk -v m="$LFS_MIRROR" '{gsub(/^.*\//, m)}; 1' wget-list >"$dir/wget-list"
#sed "s,^.*/,$LFS_MIRROR," wget-list > "$dir/wget-list"
fi
# Unpack existing snapshot, or run pass1 of bootstrap and then make snapshot.
pass1snapshot="$snapshotdir/pass1-snapshot.tar.gz"
if "$snapshot" && [ -e "$pass1snapshot" ]
then
tar -C "$dir" -xf "$pass1snapshot"
cp baserock-bootstrap "$dir/." #update bootstrap script
else
cp baserock-bootstrap "$dir/."
"./do-squeeze-chroot" bash -x baserock-bootstrap pass1 || exit 1
if "$snapshot"
then
tar -C "$dir" -caf "$pass1snapshot" .
fi
fi
# Update the git repos.
mkdir -p "$dir/tree/baserock"
rm -rf "$dir/tree/baserock/gits"
mkdir "$dir/tree/baserock/gits"
mkdir "$dir/tree/baserock/gits/morph"
cp -r . "$dir/tree/baserock/gits/morph/."
# Unpack existing snapshot, or run pass2 of bootstrap and then make snapshot.
pass2snapshot="$snapshotdir/pass2-snapshot.tar.gz"
if "$snapshot" && [ -e "$pass2snapshot" ]
then
tar -C "$dir" -xf "$pass2snapshot"
cp baserock-bootstrap "$dir/." #update bootstrap script
else
cp baserock-bootstrap "$dir/."
"./do-squeeze-chroot" bash -x baserock-bootstrap pass2 || exit 1
if "$snapshot"
then
tar -C "$dir" -caf "$pass2snapshot" .
fi
fi
# Run pass3 of bootstrap.
"./do-squeeze-chroot" bash -x baserock-bootstrap pass3 || exit 1
echo "Passes 1, 2, and 3 of bootstrap done (possibly cached)."
|