Commit d259b27c authored by Nikos Skalkotos's avatar Nikos Skalkotos
Browse files

Create a package list file after every debootstrap

This file is used to check if the cache file contains every package
defined in HELPER_EXTRA_PKGS.
parent 2f43ca2e
......@@ -254,7 +254,7 @@ ganeti_os_main() {
}
do_debootstrap() {
local target=$1
local target="$1"
echo "Debootstraping to create a new root filesystem:"
......@@ -270,6 +270,9 @@ EOF
--include "$HELPER_EXTRA_PKGS" --variant=minbase stable "$target" \
"$HELPER_MIRROR" 2>&1 | sed -e 's/^/DEBOOTSTRAP: /g'
# Save the package list
chroot "$target" dpkg-query -W -f "\${Package}\n" > "$HELPER_CACHE_PKGS"
rm "$target/usr/sbin/policy-rc.d"
# remove the downloaded debs, as they are no longer needed
......@@ -332,6 +335,7 @@ fi
: ${HELPER_HARD_TIMEOUT:=5}
: ${HELPER_USER:="nobody"}
: ${HELPER_CACHE_FILE:="@HELPER_DIR@/cache.tar"}
: ${HELPER_CACHE_PKGS:="@HELPER_DIR@/packages"}
: ${HELPER_EXTRA_PKGS:="linux-image-amd64,e2fsprogs,ntfs-3g,ntfsprogs,xmlstarlet,python,parted,reglookup,chntpw,util-linux"}
: ${HELPER_MIRROR:=""}
: ${PITHOS_DB:="sqlite:////@localstatedir@/lib/pithos/backend.db"}
......
......@@ -45,8 +45,12 @@
# `debootstrap' all the time.
# HELPER_CACHE_FILE="${HELPER_DIR}/cache.tar"
# HELPER_CACHE_PKGS: Debian Packages the cache file contains.
# HELPER_CACHE_PKGS="${HELPER_DIR}/packages"
# HELPER_EXTRA_PKGS: Extra packages that will need to be supplied
# to debootstrap to make the resulting helper image workable
# to debootstrap to make the resulting helper image workable.
# DO NOT OVERWRITE THIS UNLESS YOU KNOW WHAT YOU ARE DOING
# HELPER_EXTRA_PKGS="linux-image-amd64,e2fsprogs,ntfs-3g,ntfsprogs,xmlstarlet,python,parted,reglookup,chntpw,util-linux"
# HELPER_MIRROR: Debian mirror to use with debootstrap. Using a mirror close to
......
......@@ -149,10 +149,37 @@ mount "$root_dev" "$target"
add_cleanup umount "$root_dev"
echo -n "Checking for cached root filesystem file \`$CACHE_FILE'..."
if [ -f "$CACHE_FILE" ]; then
if [ -f "$CACHE_FILE" ]; then
echo "found"
while [[ 1 ]]; do
missing_pkgs="no"
if [ "$CACHE_FILE" == "$HELPER_CACHE_FILE" ]; then
echo -n "Checking if needed packages are present..."
if [ ! -f "$HELPER_CACHE_PKGS" ]; then
missing_pkgs="yes"
echo "packages file: \`$HELPER_CACHE_PKGS' does not exist"
else
OLD_IFS="$IFS"
IFS=,; for pkg in $HELPER_EXTRA_PKGS; do
if ! grep "^$pkg\$" "$HELPER_CACHE_PKGS" > /dev/null; then
missing_pkgs="yes"
echo "$pkg is missing."
break
fi
done
IFS="$OLD_IFS"
if [ "$missing_pkgs" == "no" ]; then
echo "done"
fi
fi
if [ "$missing_pkgs" == "yes" ]; then
do_debootstrap "$target"
fi
fi
test "$missing_pkgs" == "no" && while [[ 1 ]]; do
echo -n "Use the cached file [Y/n]? "
if [ "x$NO_PROMPT" = "xyes" ]; then
echo "y";
......@@ -168,6 +195,7 @@ if [ -f "$CACHE_FILE" ]; then
break;
fi
done
else
echo "not found"
do_debootstrap "$target"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment