/lib/partman/finish.d/01apt_clone_save is in ubiquity 2.18.7.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | #!/bin/sh
set -e
. /lib/partman/lib/base.sh
mountpoint="$(mktemp -d)"
root=
var=
fail () {
if [ -n "$var" ] && [ -e "$mountpoint/var" ]; then
umount "$mountpoint/var" || true
fi
if [ -e "$mountpoint" ]; then
umount "$mountpoint" && rmdir "$mountpoint" || true
fi
db_progress STOP
# TODO input an error question.
exit 1
}
for dev in $DEVICES/*; do
[ -d "$dev" ] || continue
cd $dev
open_dialog PARTITIONS
while { read_line num id size type fs path name; [ "$id" ]; }; do
[ -f "$id/method" ] || continue
[ -f "$id/use_filesystem" ] || continue
[ -f "$id/mountpoint" ] || continue
[ "$fs" != free ] || continue
[ -f "$id/format" ] && continue
[ -f "$id/formatted" ] && continue
if [ "$(cat "$id/mountpoint")" = "/" ]; then
root="$path"
elif [ "$(cat "$id/mountpoint")" = "/var" ]; then
var="$path"
fi
done
close_dialog
done
if [ -z "$root" ]; then
# The partition is going to be formatted; there's nothing to preserve.
exit 0
fi
db_progress START 0 1 ubiquity/install/title
db_progress INFO ubiquity/install/apt_clone_save
mount "$root" "$mountpoint"
[ -n "$var" ] && mount "$var" "$mountpoint/var"
working="$mountpoint/ubiquity-apt-clone"
mkdir -p "$working"
if ! apt-clone clone --with-dpkg-repack --source "$mountpoint" "$working"; then
# TODO: if the above fails, ask a debconf error question.
fail
fi
db_progress STEP 1
if [ -n "$var" ] && [ -e "$mountpoint/var" ]; then
umount "$mountpoint/var" || true
fi
if [ -e "$mountpoint" ]; then
umount "$mountpoint" && rmdir "$mountpoint" || true
fi
db_progress STOP
|