Skip to content

Commit

Permalink
STAGE3: Don't keep stage3 filesystems unpacked in /var/... Instead
Browse files Browse the repository at this point in the history
unpack them when needed, where needed.
  • Loading branch information
specing committed Jun 8, 2013
1 parent 1ce660f commit 73be0e6
Showing 1 changed file with 21 additions and 39 deletions.
60 changes: 21 additions & 39 deletions lxc-gentoo
Expand Up @@ -408,17 +408,8 @@ fetch_stage3()
fi
printf " => saved to: %s\n" "$output_file"

# make sure we are operating on a clear rootfs cache
rm -Rf "${TEMPLATE}"
mkdir -p "${TEMPLATE}"

echo -n "Extracting stage3 archive..."
tar -xpf "$output_file" -C "$TEMPLATE"
if [[ $? -ne 0 ]]; then
echo "failed!"
exit 1
fi
echo "done."
# used by calling function
STAGE3_TARBALL="$output_file"
}

fetch_portage()
Expand Down Expand Up @@ -570,39 +561,30 @@ create() {
return 1
fi

if [[ -n "${STAGE3_TARBALL}" ]]; then
# variable is nonzero, try to unpack
printf "Unpacking filesystem from %s to %s ... " "$STAGE3_TARBALL" "$ROOTFS"
mkdir -p "${ROOTFS}"

# also exclude redundant .keep files
tar --exclude .keep -xpf "${STAGE3_TARBALL}" -C "${ROOTFS}"
if [ $? -ne 0 ]; then
echo "FAILED."
return 1
else
echo "done."
fi
else
# check the mini distro was not already downloaded
TEMPLATE="${CACHE}/${ARCH}_${SUBARCH}_${ARCHVARIANT}_rootfs"
fetch_template
if [ ! $? -eq 0 ]; then
echo "ERROR: Failed to fetch template."
return ${RETVAL}
fi
if [[ -z "$STAGE3_TARBALL" ]]; then
# Fetch us a stage3
TEMPLATE="$CACHE/${ARCH}_${SUBARCH}_${ARCHVARIANT}_rootfs"

# make a local copy of the mini
echo -n "Copying filesystem from ${TEMPLATE} to ${ROOTFS}..."
cp -a "${TEMPLATE}" ${ROOTFS}
if [ ! $? -eq 0 ]; then
echo "FAILED."
execute_exclusively "${ARCH}_${SUBARCH}_${ARCHVARIANT}_rootfs" fetch_stage3
if [[ $? -ne 0 ]]; then
printf "ERROR: Failed to fetch stage3.\n"
return 1
else
echo "done."
fi
fi

# variable is nonzero, try to unpack
printf "Unpacking filesystem from %s to %s ... " "$STAGE3_TARBALL" "$ROOTFS"
mkdir -p "$ROOTFS"

# also exclude redundant .keep files
tar --exclude .keep -xpf "$STAGE3_TARBALL" -C "$ROOTFS"
if [[ $? -ne 0 ]]; then
printf "FAILED.\n"
return 1
else
printf "done.\n"
fi

if [[ ! -d "$ROOTFS/usr/portage" ]]; then
# The portage tree is not present, get and unpack it (temporary solution)

Expand Down

0 comments on commit 73be0e6

Please sign in to comment.