Revision 2187080b
b/snf-image-host/Makefile.am | ||
---|---|---|
22 | 22 |
-e 's|@osname[@]|$(osname)|g' \ |
23 | 23 |
-e 's|@defaultdir[@]|$(defaultdir)|g' \ |
24 | 24 |
-e 's|@HELPER_DIR[@]|$(HELPER_DIR)|g' \ |
25 |
-e 's|@HELPER_CACHE_DIR[@]|$(HELPER_CACHE_DIR)|g' \ |
|
26 | 25 |
-e 's|@HELPER_IMG[@]|$(HELPER_IMG)|g' \ |
27 | 26 |
-e 's|@HELPER_KERNEL[@]|$(HELPER_KERNEL)|g' \ |
28 | 27 |
-e 's|@HELPER_INITRD[@]|$(HELPER_INITRD)|g' \ |
b/snf-image-host/common.sh.in | ||
---|---|---|
345 | 345 |
EOF |
346 | 346 |
chmod +x "$target/usr/sbin/policy-rc.d" |
347 | 347 |
|
348 |
multistrap -d "$target" -a $(dpkg --print-architecture) \ |
|
349 |
-f "$MULTISTRAP_CONFIG" 2>&1 | sed -u -e 's/^/MULTISTRAP: /g' |
|
350 |
|
|
351 |
# Save the package list |
|
352 |
chroot "$target" dpkg-query -W -f "\${Package}\n" > "$pkgs" |
|
348 |
multistrap -d "$target" -f "$MULTISTRAP_CONFIG" 2>&1 | sed -u -e 's/^/MULTISTRAP: /g' |
|
353 | 349 |
|
354 | 350 |
rm "$target/usr/sbin/policy-rc.d" |
355 |
|
|
356 |
local tmp_cache=$(mktemp "$cache.XXXXXX") |
|
357 |
tar cf "$tmp_cache" --one-file-system -C "$target" . || \ |
|
358 |
{ rm "$tmp_cache"; false; } |
|
359 |
# Overwrite the default cache file. Not the user specified if present. |
|
360 |
mv -f "$tmp_cache" "$cache" |
|
351 |
rm -rf "$target/etc/apt/preferences.d" |
|
361 | 352 |
} |
362 | 353 |
|
363 | 354 |
report_and_cleanup(){ |
... | ... | |
409 | 400 |
: ${IMAGE_DIR:="@localstatedir@/lib/snf-image"} |
410 | 401 |
: ${IMAGE_DEBUG:="no"} |
411 | 402 |
: ${HELPER_DIR:="@HELPER_DIR@"} |
412 |
: ${HELPER_CACHE_DIR:="@HELPER_CACHE_DIR@"} |
|
413 | 403 |
: ${HELPER_IMG:="@HELPER_IMG@"} |
414 | 404 |
: ${HELPER_KERNEL:="@HELPER_KERNEL@"} |
415 | 405 |
: ${HELPER_INITRD:="@HELPER_INITRD@"} |
b/snf-image-host/configure.ac | ||
---|---|---|
81 | 81 |
[helper_dir="$localstatedir/lib/snf-image/helper"]) |
82 | 82 |
AC_SUBST(HELPER_DIR, $helper_dir) |
83 | 83 |
|
84 |
# --with-helper-cache-dir |
|
85 |
AC_ARG_WITH([helper-cache-dir], |
|
86 |
[AS_HELP_STRING([--with-helper-cache-dir=DIR], |
|
87 |
[top-level directory to host the helper VM cache files |
|
88 |
[LOCALSTATEDIR/cache/snf-image/helper]] |
|
89 |
)], |
|
90 |
[helper_cache_dir="$withval"], |
|
91 |
[helper_cache_dir="$localstatedir/cache/snf-image/helper"]) |
|
92 |
AC_SUBST(HELPER_CACHE_DIR, $helper_cache_dir) |
|
93 |
|
|
94 | 84 |
# --with-helper-img |
95 | 85 |
AC_ARG_WITH([helper-img], |
96 | 86 |
[AS_HELP_STRING([--with-helper-img=IMG_PATH], |
b/snf-image-host/snf-image-update-helper.in | ||
---|---|---|
140 | 140 |
mount "$root_dev" "$target" |
141 | 141 |
add_cleanup umount "$root_dev" |
142 | 142 |
|
143 |
echo -n "Checking for cached root filesystem in \`$HELPER_CACHE_DIR'..." |
|
144 |
if [ "$NO_CACHE" == "yes" ]; then |
|
145 |
echo "don't use cache (option -r applied)" |
|
146 |
do_multistrap "$target" "$HELPER_CACHE_DIR/root.tar" "$HELPER_CACHE_DIR/packages" |
|
147 |
elif [ -f "$HELPER_CACHE_DIR/root.tar" ]; then |
|
148 |
echo "found" |
|
149 |
|
|
150 |
missing_pkgs="no" |
|
151 |
echo -n "Checking if needed packages are present..." |
|
152 |
if [ ! -f "$HELPER_CACHE_DIR/packages" ]; then |
|
153 |
missing_pkgs="yes" |
|
154 |
echo "packages file: \`$HELPER_CACHE_DIR/packages' does not exist" |
|
155 |
else |
|
156 |
extra_pkgs=$(grep ^packages= "$MULTISTRAP_CONFIG" | cut -d= -f2 | tr '\n' ' ') |
|
157 |
for pkg in $extra_pkgs; do |
|
158 |
if ! grep "^$pkg\$" "$HELPER_CACHE_DIR/packages" > /dev/null; then |
|
159 |
missing_pkgs="yes" |
|
160 |
echo "$pkg is missing." |
|
161 |
break |
|
162 |
fi |
|
163 |
done |
|
164 |
if [ "$missing_pkgs" == "no" ]; then |
|
165 |
echo "done" |
|
166 |
fi |
|
167 |
fi |
|
168 |
if [ "$missing_pkgs" == "yes" ]; then |
|
169 |
do_multistrap "$target" "$HELPER_CACHE_DIR/root.tar" "$HELPER_CACHE_DIR/packages" |
|
170 |
fi |
|
143 |
do_multistrap "$target" |
|
171 | 144 |
|
172 |
test "$missing_pkgs" == "no" && while [[ 1 ]]; do |
|
173 |
echo -n "Use the cached file [Y/n]? " |
|
174 |
if [ "x$NO_PROMPT" = "xyes" ]; then |
|
175 |
echo "y"; |
|
176 |
break; |
|
177 |
fi |
|
178 |
|
|
179 |
read answer |
|
180 |
|
|
181 |
if [ -z "$answer" -o "$(tr [A-Z] [a-z] <<< "$answer")" = "y" ]; then |
|
182 |
break; |
|
183 |
elif [ "$(tr [A-Z] [a-z] <<< "$answer" )" = "n" ]; then |
|
184 |
do_multistrap "$target" "$HELPER_CACHE_DIR/root.tar" "$HELPER_CACHE_DIR/packages" |
|
185 |
break; |
|
186 |
fi |
|
187 |
done |
|
188 |
|
|
189 |
else |
|
190 |
echo "not found" |
|
191 |
do_multistrap "$target" "$HELPER_CACHE_DIR/root.tar" "$HELPER_CACHE_DIR/packages" |
|
192 |
fi |
|
193 |
|
|
194 |
tar xf "$HELPER_CACHE_DIR/root.tar" -C "$target" |
|
145 |
# Save the package list |
|
146 |
chroot "$target" dpkg-query -W > "$HELPER_DIR/packages" |
|
195 | 147 |
|
196 | 148 |
echo -n "Configuring the helper image..." |
197 | 149 |
echo snf-image-helper > "$target/etc/hostname" |
... | ... | |
228 | 180 |
rm "$target/vmlinuz" "$target/initrd.img" |
229 | 181 |
|
230 | 182 |
|
231 |
pkg_installed=$(grep snf-image-helper "$HELPER_CACHE_DIR/packages" > /dev/null && echo yes)
|
|
183 |
pkg_installed=$(grep snf-image-helper "$HELPER_DIR/packages" > /dev/null && echo yes) |
|
232 | 184 |
|
233 | 185 |
if [ ! -r "$HELPER_PKG" -a -z "$pkg_installed" ]; then |
234 | 186 |
log_error "ERROR:" |
... | ... | |
243 | 195 |
pkg_name=$(basename "$HELPER_PKG") |
244 | 196 |
add_cleanup rm "$target/tmp/$pkg_name" |
245 | 197 |
chroot "$target" dpkg -i "/tmp/$pkg_name" 2>&1 | sed -e 's/^/DPKG: /g' |
198 |
|
|
199 |
# Recreate package list |
|
200 |
chroot "$target" dpkg-query -W > "$HELPER_DIR/packages" |
|
246 | 201 |
else |
247 | 202 |
echo "snf-image-helper pkg was installed from the apt repository." |
248 | 203 |
fi |
Also available in: Unified diff