Revision 448a829f snf-image-host/snf-image-update-helper.in
b/snf-image-host/snf-image-update-helper.in | ||
---|---|---|
57 | 57 |
|
58 | 58 |
while getopts "c:d:hp:y" opt; do |
59 | 59 |
case $opt in |
60 |
c) HELPER_CACHE_FILE="$OPTARG" |
|
60 |
c) CACHE_FILE="$OPTARG" |
|
61 |
OVERWRITTEN_CACHE_FILE="yes" |
|
61 | 62 |
;; |
62 | 63 |
d) HELPER_DIR="$OPTARG" |
63 | 64 |
;; |
... | ... | |
72 | 73 |
esac |
73 | 74 |
done |
74 | 75 |
|
76 |
if [ x"$OVERWRITTEN_CACHE_FILE" != "xyes" ] ; then |
|
77 |
CACHE_FILE="$HELPER_CACHE_FILE" |
|
78 |
fi |
|
79 |
|
|
75 | 80 |
echo |
76 | 81 |
echo "This is the update helper image script for snf-image." |
77 | 82 |
echo "If you don't know what to do, use \`-h'." |
... | ... | |
143 | 148 |
mount "$root_dev" "$target" |
144 | 149 |
add_cleanup umount "$root_dev" |
145 | 150 |
|
146 |
echo -n "Checking for cached root filesystem file \`$HELPER_CACHE_FILE'..."
|
|
147 |
if [ -f "$HELPER_CACHE_FILE" ]; then
|
|
151 |
echo -n "Checking for cached root filesystem file \`$CACHE_FILE'..."
|
|
152 |
if [ -f "$CACHE_FILE" ]; then |
|
148 | 153 |
echo "found" |
149 |
tar xf "$HELPER_CACHE_FILE" -C "$target" |
|
150 |
else |
|
151 |
echo "not found" |
|
152 |
echo "Debootstraping to create a new root filesystem:" |
|
153 | 154 |
|
154 |
# Create a policy-rc.d file to deny init script execution |
|
155 |
mkdir -p "$target/usr/sbin" |
|
156 |
cat > "$target/usr/sbin/policy-rc.d" <<EOF |
|
157 |
#!/bin/sh |
|
158 |
exit 101 |
|
159 |
EOF |
|
160 |
chmod +x "$target/usr/sbin/policy-rc.d" |
|
155 |
while [[ 1 ]]; do |
|
156 |
echo -n "Use the cached file [Y/n]? " |
|
157 |
if [ "x$NO_PROMPT" = "xyes" ]; then |
|
158 |
echo "y"; |
|
159 |
break; |
|
160 |
fi |
|
161 | 161 |
|
162 |
debootstrap --arch $(dpkg --print-architecture) \ |
|
163 |
--include "$HELPER_EXTRA_PKGS" --variant=minbase stable "$target" \ |
|
164 |
"$HELPER_MIRROR" 2>&1 | sed -e 's/^/DEBOOTSTRAP: /g' |
|
165 |
|
|
166 |
rm "$target/usr/sbin/policy-rc.d" |
|
162 |
read answer |
|
167 | 163 |
|
168 |
# remove the downloaded debs, as they are no longer needed |
|
169 |
find "$target/var/cache/apt/archives" -type f -name '*.deb' -print0 | \ |
|
170 |
xargs -r0 rm -f |
|
171 |
|
|
172 |
tmp_cache=$(mktemp "$HELPER_CACHE_FILE.XXXXXX") |
|
173 |
tar cf "$tmp_cache" --one-file-system -C "$target" . || \ |
|
174 |
{ rm "$tmp_cache"; false; } |
|
175 |
mv -f "$tmp_cache" "$HELPER_CACHE_FILE" |
|
164 |
if [ -z "$answer" -o "$(tr [A-Z] [a-z] <<< "$answer")" = "y" ]; then |
|
165 |
break; |
|
166 |
elif [ "$(tr [A-Z] [a-z] <<< "$answer" )" = "n" ]; then |
|
167 |
do_debootstrap "$target" |
|
168 |
break; |
|
169 |
fi |
|
170 |
done |
|
171 |
else |
|
172 |
echo "not found" |
|
173 |
do_debootstrap "$target" |
|
176 | 174 |
fi |
177 | 175 |
|
176 |
tar xf "$HELPER_CACHE_FILE" -C "$target" |
|
177 |
|
|
178 | 178 |
echo -n "Configuring the helper image..." |
179 | 179 |
echo snf-image-helper > "$target/etc/hostname" |
180 | 180 |
|
Also available in: Unified diff