From 4e2a9158a88663a984fbf9824b5e76b4adac104a Mon Sep 17 00:00:00 2001 From: Jason Mehring Date: Thu, 16 Oct 2014 16:05:28 -0400 Subject: [PATCH] Added snapshot for debootstrap completion and when system is updated with extra packages before Whonix is installed for debugging only (SNAPSHOT must be set to "1" Tweaked Whonix configurations some more so it should now run without errors --- scripts_debian/00_prepare.sh | 6 ++-- .../custom_wheezy_whonix/00_prepare_pre.sh | 10 +++--- .../01_install_core_post.sh | 10 +++--- .../02_install_groups_packages_installed.sh | 34 +++++++++++++++---- 4 files changed, 40 insertions(+), 20 deletions(-) diff --git a/scripts_debian/00_prepare.sh b/scripts_debian/00_prepare.sh index c35aa05..03edeb5 100755 --- a/scripts_debian/00_prepare.sh +++ b/scripts_debian/00_prepare.sh @@ -10,15 +10,15 @@ # ------------------------------------------------------------------------------ # Configurations # ------------------------------------------------------------------------------ -INSTALLDIR="$(readlink -m mnt)" -umount_kill "$INSTALLDIR" || : - if [ "$VERBOSE" -ge 2 -o "$DEBUG" == "1" ]; then set -x else set -e fi +INSTALLDIR="$(readlink -m mnt)" +umount_kill "$INSTALLDIR" || : + # ------------------------------------------------------------------------------ # Execute any custom pre configuration scripts # ------------------------------------------------------------------------------ diff --git a/scripts_debian/custom_wheezy_whonix/00_prepare_pre.sh b/scripts_debian/custom_wheezy_whonix/00_prepare_pre.sh index 8916154..3c81ee6 100755 --- a/scripts_debian/custom_wheezy_whonix/00_prepare_pre.sh +++ b/scripts_debian/custom_wheezy_whonix/00_prepare_pre.sh @@ -13,10 +13,10 @@ ################################################################################ # ------------------------------------------------------------------------------ -# Return if DEBUG is not "1" +# Return if SNAPSHOT is not "1" # ------------------------------------------------------------------------------ -# This script is only used if DEBUG is set -if [ ! "$DEBUG" == "1" ]; then +# This script is only used if SNAPSHOT is set +if [ ! "$SNAPSHOT" == "1" ]; then exit 0 fi @@ -39,10 +39,10 @@ INSTALLDIR="$(readlink -m mnt)" umount_kill "$INSTALLDIR" || : # ------------------------------------------------------------------------------ -# Use an already prepared debian image to install Whonix (for DEBUGGING) +# Use a snapshot of the debootstraped debian image to install Whonix (for DEBUGGING) # ------------------------------------------------------------------------------ splitPath "$IMG" path_parts -PREPARED_IMG="${path_parts[dir]}${path_parts[base]}-prepared${path_parts[dotext]}" +PREPARED_IMG="${path_parts[dir]}${path_parts[base]}-debootstrap${path_parts[dotext]}" if [ -f "$PREPARED_IMG" ]; then warn "Copying $PREPARED_IMG to $IMG" diff --git a/scripts_debian/custom_wheezy_whonix/01_install_core_post.sh b/scripts_debian/custom_wheezy_whonix/01_install_core_post.sh index 2590b59..db7ec1b 100755 --- a/scripts_debian/custom_wheezy_whonix/01_install_core_post.sh +++ b/scripts_debian/custom_wheezy_whonix/01_install_core_post.sh @@ -2,10 +2,10 @@ # vim: set ts=4 sw=4 sts=4 et : # ------------------------------------------------------------------------------ -# Return if DEBUG is not "1" +# Return if SNAPSHOT is not "1" # ------------------------------------------------------------------------------ -# This script is only used if DEBUG is set -if [ ! "$DEBUG" == "1" ]; then +# This script is only used if SNAPSHOT is set +if [ ! "$SNAPSHOT" == "1" ]; then exit 0 fi @@ -25,10 +25,10 @@ else fi # ------------------------------------------------------------------------------ -# Create a copy of an already prepared bootstraped image if it does not exist +# Create a snapshot of the already debootstraped image # ------------------------------------------------------------------------------ splitPath "$IMG" path_parts -PREPARED_IMG="${path_parts[dir]}${path_parts[base]}-prepared${path_parts[dotext]}" +PREPARED_IMG="${path_parts[dir]}${path_parts[base]}-debootstrap${path_parts[dotext]}" if ! [ -f "$PREPARED_IMG" ]; then umount_kill "$INSTALLDIR" || : diff --git a/scripts_debian/custom_wheezy_whonix/02_install_groups_packages_installed.sh b/scripts_debian/custom_wheezy_whonix/02_install_groups_packages_installed.sh index 6258a1c..f9074f2 100755 --- a/scripts_debian/custom_wheezy_whonix/02_install_groups_packages_installed.sh +++ b/scripts_debian/custom_wheezy_whonix/02_install_groups_packages_installed.sh @@ -16,6 +16,24 @@ else set -e fi +# ------------------------------------------------------------------------------ +# XXX: Create a snapshot - Only for DEBUGGING! +# ------------------------------------------------------------------------------ +# Only execute if SNAPSHOT is set +if [ "$SNAPSHOT" == "1" ]; then + splitPath "$IMG" path_parts + PREPARED_IMG="${path_parts[dir]}${path_parts[base]}-updated${path_parts[dotext]}" + + if ! [ -f "$PREPARED_IMG" ]; then + umount_kill "$INSTALLDIR" || : + warn "Copying $IMG to $PREPARED_IMG" + cp -f "$IMG" "$PREPARED_IMG" + mount -o loop "$IMG" "$INSTALLDIR" || exit 1 + for fs in /dev /dev/pts /proc /sys /run; do mount -B $fs "$INSTALLDIR/$fs"; done + fi +fi + + # ------------------------------------------------------------------------------ # chroot Whonix build script (Make sure set -e is not set) # ------------------------------------------------------------------------------ @@ -166,13 +184,6 @@ if ! [ -f "$INSTALLDIR/tmp/.prepared_whonix" ]; then # Patch anon-meta-packages to not depend on grub-pc # XXX: Seems like the error disappears, but then whonix updates to original code? - pushd "$WHONIX_DIR/packages/anon-meta-packages/debian" - { - sed -i 's/ grub-pc,//g' control || :; - su $USER -c "git commit -am 'removed grub-pc depend'" || :; - } - popd - pushd "$WHONIX_DIR" { sed -i 's/grub-pc//g' grml_packages || :; @@ -180,9 +191,18 @@ if ! [ -f "$INSTALLDIR/tmp/.prepared_whonix" ]; then } popd + pushd "$WHONIX_DIR/packages/anon-meta-packages/debian" + { + sed -i 's/ grub-pc,//g' control || :; + su $USER -c "dpkg-source --commit" || :; + su $USER -c "git commit -am 'removed grub-pc depend'" || :; + } + popd + pushd "$WHONIX_DIR/packages/anon-shared-build-fix-grub/usr/lib/anon-dist/chroot-scripts-post.d" { sed -i 's/update-grub/:/g' 85_update_grub || :; + su $USER -c "dpkg-source --commit" || :; su $USER -c "git commit -am 'removed grub-pc depend'" || :; } popd