diff --git a/debian/scripts/networking.sh b/debian/scripts/networking.sh index 3ca4ee0c..74169ff9 100644 --- a/debian/scripts/networking.sh +++ b/debian/scripts/networking.sh @@ -41,10 +41,6 @@ rm -f /etc/cloud/cloud.cfg.d/subiquity-disable-cloudinit-networking.cfg rm -f /etc/cloud/cloud.cfg.d/99-installer.cfg rm -f /etc/cloud/ds-identify.cfg -rm -f /var/log/cloud-init*.log -rm -rf /var/lib/cloud/instances \ - /var/lib/cloud/instance - # Install a dpkg-query wrapper to bypass MAAS netplan.io check cat > /usr/local/bin/dpkg-query <| "$ROOT_MOUNT/etc/machine-id" +fi + +if [ -f "$ROOT_MOUNT/var/lib/cloud/instance" ]; then + echo 'cleaning cloud-init state...' + rm -f "$ROOT_MOUNT/var/log/cloud-init*.log" \ + "$ROOT_MOUNT/var/lib/cloud/instance" + rm -rf "$ROOT_MOUNT/var/lib/cloud/instances" +fi if [ -d curtin ] || [ -d "$CURTIN_HOOKS" ]; then echo 'Adding Curtin hooks...' @@ -35,7 +46,10 @@ fi echo "Creating MAAS image ${OUTPUT}..." TARFILE=${OUTPUT%*.gz} -tar -Scpf "${TARFILE}" --acls --selinux --xattrs -C "$ROOT_MOUNT" . +tar -Scpf "${TARFILE}" --acls --selinux --xattrs \ + --one-file-system \ + --exclude-backups \ + -C "$ROOT_MOUNT" . if [ "${DETECT_BLS_BOOT}" -eq 1 ]; then echo "auto-detecting 'bls_boot' partition" diff --git a/ubuntu/scripts/cloudimg/cleanup.sh b/ubuntu/scripts/cloudimg/cleanup.sh index 4a3a2574..4c0247fd 100644 --- a/ubuntu/scripts/cloudimg/cleanup.sh +++ b/ubuntu/scripts/cloudimg/cleanup.sh @@ -21,10 +21,6 @@ # cloud-init put networking in place on initial boot. Let's remove that, to # allow MAAS to configure the networking on deploy. rm /etc/netplan/50-cloud-init.yaml -: >| /etc/machine-id -rm -f /var/log/cloud-init*.log -rm -rf /var/lib/cloud/instances \ - /var/lib/cloud/instance # Everything in /run/packer_backup should be restored. find /run/packer_backup diff --git a/ubuntu/scripts/networking.sh b/ubuntu/scripts/networking.sh index 180adb2c..c1cc45db 100644 --- a/ubuntu/scripts/networking.sh +++ b/ubuntu/scripts/networking.sh @@ -31,8 +31,3 @@ rm -f /etc/cloud/cloud.cfg.d/subiquity-disable-cloudinit-networking.cfg rm -f /etc/cloud/cloud.cfg.d/99-installer.cfg rm -f /etc/cloud/ds-identify.cfg rm -f /etc/netplan/00-installer-config.yaml -: >| /etc/machine-id - -rm -f /var/log/cloud-init*.log -rm -rf /var/lib/cloud/instances \ - /var/lib/cloud/instance