diff --git a/src/common.sh b/src/common.sh index 2672ca30..a50955e3 100755 --- a/src/common.sh +++ b/src/common.sh @@ -125,15 +125,20 @@ function unpack() { then owner=$3 fi - + mkdir -p /tmp/unpack/ # $from/. may look funny, but does exactly what we want, copy _contents_ # from $from to $to, but not $from itself, without the need to glob -- see # http://stackoverflow.com/a/4645159/2028598 - cp -v -r --preserve=mode,timestamps $from/. $to + cp -v -r --preserve=mode,timestamps $from/. /tmp/unpack/ + if [ -n "$owner" ] then - chown -hR $owner:$owner $to + chown -hR $owner:$owner /tmp/unpack/ fi + + cp -v -r --preserve=mode,ownership,timestamps /tmp/unpack/. $to + rm -r /tmp/unpack + } function detach_all_loopback(){ diff --git a/src/variants/armbian/pre_chroot_script b/src/variants/armbian/pre_chroot_script index 0db0ccd6..ecd4c9e7 100755 --- a/src/variants/armbian/pre_chroot_script +++ b/src/variants/armbian/pre_chroot_script @@ -40,7 +40,11 @@ yes 1234 | passwd #cleanup mkdir -p /var/cache/apt/archives -apt-get clean +if [ -n "$BASE_APT_CACHE" ] && [ "$BASE_APT_CACHE" != "no" ]; then + apt-get autoclean +else + apt-get clean +fi apt-get update --allow-releaseinfo-change apt-get -y --force-yes install avahi-daemon || true apt-get -y --force-yes install python python-distutils-extra || true diff --git a/src/variants/bananapi-m1/pre_chroot_script b/src/variants/bananapi-m1/pre_chroot_script index f24455be..5ad3e002 100755 --- a/src/variants/bananapi-m1/pre_chroot_script +++ b/src/variants/bananapi-m1/pre_chroot_script @@ -9,4 +9,8 @@ unpack /filesystem/root / #cleanup mkdir -p /var/cache/apt/archives -apt-get clean +if [ -n "$BASE_APT_CACHE" ] && [ "$BASE_APT_CACHE" != "no" ]; then + apt-get autoclean +else + apt-get clean +fi diff --git a/src/variants/example/post_chroot_script b/src/variants/example/post_chroot_script index da988bb9..2f3237a1 100755 --- a/src/variants/example/post_chroot_script +++ b/src/variants/example/post_chroot_script @@ -8,4 +8,8 @@ install_chroot_fail_on_error_trap unpack /filesystem/root / #cleanup -apt-get clean +if [ -n "$BASE_APT_CACHE" ] && [ "$BASE_APT_CACHE" != "no" ]; then + apt-get autoclean +else + apt-get clean +fi