Refactoring commit_changes in partman
Hey all,
most of the partman-* packages provide their own slightly
different version of commit_changes.
I've carefully gone through them and noted the differences,
hoping to replace them all with a common commit_changes in
partman-base/definition.sh
o I plan to apply the attached path if noone voices
objections. I've carefully read the code to make sure
that the changes are safe and given the changed
packages basic testing.
o Shrinks the scripts in partman-* by a bit more than
1k (1257 bytes) in total size.
o Some error templates were previously shown with high
priority, while others used critical for essentially
the same error condition. This change makes them
consistently use priority critical.
The only problem I see is that it is not possible to
add a versioned depends on -base (>= 113) in -partitioning,
because -base depends on -partitioning and this would
introduce a circular dependency.
I'm attaching my more detailed notes in case anyone wants
to review or double-check.
Max
Index: partman-crypto/debian/control
===================================================================
--- partman-crypto/debian/control (Revision 50294)
+++ partman-crypto/debian/control (Arbeitskopie)
@@ -9,7 +9,7 @@
Package: partman-crypto
XC-Package-Type: udeb
Architecture: any
-Depends: partman-base (>= 106), ${shlibs:Depends}, ${misc:Depends}
+Depends: partman-base (>= 113), ${shlibs:Depends}, ${misc:Depends}
Description: Add to partman support for block device encryption
Package: partman-crypto-dm
Index: partman-crypto/debian/changelog
===================================================================
--- partman-crypto/debian/changelog (Revision 50294)
+++ partman-crypto/debian/changelog (Arbeitskopie)
@@ -1,3 +1,9 @@
+partman-crypto (24) UNRELEASED; urgency=low
+
+ * Use commit_changes from partman-base (>= 113)
+
+ -- Max Vozeler <xam@debian.org> Sun, 02 Dec 2007 13:31:49 +0100
+
partman-crypto (23) unstable; urgency=low
[ Colin Watson ]
Index: partman-crypto/crypto_tools.sh
===================================================================
--- partman-crypto/crypto_tools.sh (Revision 50294)
+++ partman-crypto/crypto_tools.sh (Arbeitskopie)
@@ -721,21 +721,7 @@
interactive="yes"
fi
- # Commit the changes
- for s in /lib/partman/commit.d/*; do
- if [ -x $s ]; then
- $s || {
- db_input high partman-crypto/commit_failed || true
- db_go || true
- for s in /lib/partman/init.d/*; do
- if [ -x $s ]; then
- $s || return 255
- fi
- done
- return 0
- }
- fi
- done
+ commit_changes partman-crypto/commit_failed || return $?
if ! swap_is_safe; then
db_fset partman-crypto/unsafe_swap seen false
Index: partman-auto-raid/debian/control
===================================================================
--- partman-auto-raid/debian/control (Revision 50293)
+++ partman-auto-raid/debian/control (Arbeitskopie)
@@ -9,5 +9,5 @@
Package: partman-auto-raid
XC-Package-Type: udeb
Architecture: all
-Depends: ${misc:Depends}, partman-base (>= 99), partman-basicfilesystems, partman-ext3, partman-auto (>= 58), partman-md
+Depends: ${misc:Depends}, partman-base (>= 113), partman-basicfilesystems, partman-ext3, partman-auto (>= 58), partman-md
Description: Allow preseeded RAID installs
Index: partman-auto-raid/debian/changelog
===================================================================
--- partman-auto-raid/debian/changelog (Revision 50293)
+++ partman-auto-raid/debian/changelog (Arbeitskopie)
@@ -1,3 +1,9 @@
+partman-auto-raid (7) UNRELEASED; urgency=low
+
+ * Use commit_changes from partman-base (>= 113)
+
+ -- Max Vozeler <xam@debian.org> Sun, 02 Dec 2007 13:34:18 +0100
+
partman-auto-raid (6) unstable; urgency=low
[ Frans Pop ]
Index: partman-auto-raid/display.d/initial_auto_raid
===================================================================
--- partman-auto-raid/display.d/initial_auto_raid (Revision 50293)
+++ partman-auto-raid/display.d/initial_auto_raid (Arbeitskopie)
@@ -35,21 +35,7 @@
confirm_changes "partman-md" || exit 1
-# Commit the changes
-for s in /lib/partman/commit.d/*; do
- if [ -x $s ]; then
- $s || {
- db_input critical partman/text/commit_failed || true
- db_go || true
- for s in /lib/partman/init.d/*; do
- if [ -x $s ]; then
- $s || exit 255
- fi
- done
- exit 1
- }
- fi
-done
+commit_changes partman/text/commit_failed || exit $?
stop_parted_server
Index: partman-lvm/debian/control
===================================================================
--- partman-lvm/debian/control (Revision 50293)
+++ partman-lvm/debian/control (Arbeitskopie)
@@ -9,6 +9,6 @@
Package: partman-lvm
XC-Package-Type: udeb
Architecture: all
-Depends: ${misc:Depends}, partman-base (>= 87), di-utils (>= 1.14), md-modules, lvm2-udeb
+Depends: ${misc:Depends}, partman-base (>= 113), di-utils (>= 1.14), md-modules, lvm2-udeb
Description: Adds support for LVM to partman
Index: partman-lvm/debian/changelog
===================================================================
--- partman-lvm/debian/changelog (Revision 50293)
+++ partman-lvm/debian/changelog (Arbeitskopie)
@@ -1,5 +1,6 @@
partman-lvm (56) UNRELEASED; urgency=low
+ [ Frans Pop ]
* Only check partition flags if we've not already determined the device is
used for LVM.
* Don't create label and partition for LVM volumes if they already have a
@@ -7,8 +8,11 @@
additional changes will be needed for that to be properly supported.
Closes: #451970.
- -- Frans Pop <fjp@debian.org> Mon, 19 Nov 2007 21:27:51 +0100
+ [ Max Vozeler ]
+ * Use commit_changes from partman-base (>= 113)
+ -- Max Vozeler <xam@debian.org> Sun, 02 Dec 2007 13:35:58 +0100
+
partman-lvm (55) unstable; urgency=low
[ Frans Pop ]
Index: partman-lvm/choose_partition/lvm/do_option
===================================================================
--- partman-lvm/choose_partition/lvm/do_option (Revision 50293)
+++ partman-lvm/choose_partition/lvm/do_option (Arbeitskopie)
@@ -27,20 +27,7 @@
# Commit the changes
confirm_changes "partman-lvm" || exit 0
- for s in /lib/partman/commit.d/*; do
- if [ -x $s ]; then
- $s || {
- db_input critical partman-lvm/commit_failed || true
- db_go || true
- for s in /lib/partman/init.d/*; do
- if [ -x $s ]; then
- $s || exit 255
- fi
- done
- exit 0
- }
- fi
- done
+ commit_changes partman-lvm/commit_failed || exit $?
# initialize (pvcreate) all volumes that are not already prepared
for pv in $(pv_list); do
Index: partman-md/debian/control
===================================================================
--- partman-md/debian/control (Revision 50293)
+++ partman-md/debian/control (Arbeitskopie)
@@ -9,5 +9,5 @@
Package: partman-md
XC-Package-Type: udeb
Architecture: all
-Depends: ${misc:Depends}, mdadm-udeb, mdcfg-utils, partman-base (>= 87)
+Depends: ${misc:Depends}, mdadm-udeb, mdcfg-utils, partman-base (>= 113)
Description: Add to partman support for MD
Index: partman-md/debian/changelog
===================================================================
--- partman-md/debian/changelog (Revision 50293)
+++ partman-md/debian/changelog (Arbeitskopie)
@@ -1,3 +1,9 @@
+partman-md (38) UNRELEASED; urgency=low
+
+ * Use commit_changes from partman-base (>= 113)
+
+ -- Max Vozeler <xam@debian.org> Sun, 02 Dec 2007 13:36:37 +0100
+
partman-md (37) unstable; urgency=low
[ Christian Perrier ]
Index: partman-md/choose_partition/md/do_option
===================================================================
--- partman-md/choose_partition/md/do_option (Revision 50293)
+++ partman-md/choose_partition/md/do_option (Arbeitskopie)
@@ -4,23 +4,8 @@
confirm_changes "partman-md" || exit 0
-# Commit the changes
+commit_changes partman-md/commit_failed || exit $?
-for s in /lib/partman/commit.d/*; do
- if [ -x $s ]; then
- $s || {
- db_input high partman-md/commit_failed || true
- db_go || true
- for s in /lib/partman/init.d/*; do
- if [ -x $s ]; then
- $s || exit 255
- fi
- done
- exit 0
- }
- fi
-done
-
stop_parted_server
mdcfg
Index: partman-dmraid/debian/control
===================================================================
--- partman-dmraid/debian/control (Revision 50293)
+++ partman-dmraid/debian/control (Arbeitskopie)
@@ -9,5 +9,5 @@
Package: partman-dmraid
XC-Package-Type: udeb
Architecture: all
-Depends: ${misc:Depends}, partman-base, di-utils (>= 1.14), dmraid-udeb, dmsetup-udeb
+Depends: ${misc:Depends}, partman-base (>= 113), di-utils (>= 1.14), dmraid-udeb, dmsetup-udeb
Description: Adds support for Serial ATA RAID (dmraid) to partman
Index: partman-dmraid/debian/changelog
===================================================================
--- partman-dmraid/debian/changelog (Revision 50293)
+++ partman-dmraid/debian/changelog (Arbeitskopie)
@@ -7,8 +7,11 @@
[ Colin Watson ]
* Remove unnecessary test.
- -- Frans Pop <fjp@debian.org> Wed, 18 Jul 2007 04:12:24 +0200
+ [ Max Vozeler ]
+ * Use commit_changes from partman-base (>= 113)
+ -- Max Vozeler <xam@debian.org> Sun, 02 Dec 2007 13:35:18 +0100
+
partman-dmraid (1) unstable; urgency=low
* Initial version.
Index: partman-dmraid/choose_partition/dmraid/do_option
===================================================================
--- partman-dmraid/choose_partition/dmraid/do_option (Revision 50293)
+++ partman-dmraid/choose_partition/dmraid/do_option (Arbeitskopie)
@@ -43,20 +43,7 @@
# Commit the changes
confirm_changes "partman-dmraid" || exit 0
-for s in /lib/partman/commit.d/*; do
- if [ -x $s ]; then
- $s || {
- db_input critical partman-dmraid/commit_failed || true
- db_go || true
- for s in /lib/partman/init.d/*; do
- if [ -x $s ]; then
- $s || exit 255
- fi
- done
- exit 0
- }
- fi
-done
+commit_changes partman-dmraid/commit_failed || exit $ret
# Reset signal handling to defaults
trap - HUP INT QUIT PIPE TERM EXIT
Index: partman-partitioning/debian/changelog
===================================================================
--- partman-partitioning/debian/changelog (Revision 50293)
+++ partman-partitioning/debian/changelog (Arbeitskopie)
@@ -1,3 +1,9 @@
+partman-partitioning (53) UNRELEASED; urgency=low
+
+ * Use commit_changes from partman-base (>= 113)
+
+ -- Max Vozeler <xam@debian.org> Sun, 02 Dec 2007 13:36:52 +0100
+
partman-partitioning (52) unstable; urgency=low
* Use 'mkdir -p' rather than more awkward test-then-create constructions.
Index: partman-partitioning/active_partition/copy/do_option
===================================================================
--- partman-partitioning/active_partition/copy/do_option (Revision 50293)
+++ partman-partitioning/active_partition/copy/do_option (Arbeitskopie)
@@ -42,20 +42,7 @@
}
perform_copying () {
- for s in /lib/partman/commit.d/*; do
- if [ -x $s ]; then
- $s || {
- db_input high partman-partitioning/copy_commit_failed || true
- db_go || true
- for s in /lib/partman/init.d/*; do
- if [ -x $s ]; then
- $s || exit 0
- fi
- done
- exit 0
- }
- fi
- done
+ commit_changes partman-partitioning/copy_commit_failed || exit 0
name_progress_bar partman-partitioning/progress_copying
open_dialog COPY_PARTITION $id $source_dev $source_id
Index: partman-partitioning/resize.sh
===================================================================
--- partman-partitioning/resize.sh (Revision 50293)
+++ partman-partitioning/resize.sh (Arbeitskopie)
@@ -149,20 +149,7 @@
perform_resizing () {
if [ "$virtual" = no ]; then
- for s in /lib/partman/commit.d/*; do
- if [ -x $s ]; then
- $s || {
- db_input high partman-partitioning/new_size_commit_failed || true
- db_go || true
- for s in /lib/partman/init.d/*; do
- if [ -x $s ]; then
- $s || exit 100
- fi
- done
- exit 100
- }
- fi
- done
+ commit_changes partman-partitioning/new_size_commit_failed || exit 100
fi
disable_swap
Index: partman-base/debian/changelog
===================================================================
--- partman-base/debian/changelog (Revision 50293)
+++ partman-base/debian/changelog (Arbeitskopie)
@@ -1,3 +1,9 @@
+partman-base (113) UNRELEASED; urgency=low
+
+ * definitions.sh: Provide commit_changes
+
+ -- Max Vozeler <xam@debian.org> Sun, 02 Dec 2007 13:33:05 +0100
+
partman-base (112) unstable; urgency=low
* Add support for the Orion (ARM) platform.
Index: partman-base/definitions.sh
===================================================================
--- partman-base/definitions.sh (Revision 50293)
+++ partman-base/definitions.sh (Arbeitskopie)
@@ -1151,6 +1151,28 @@
fi
}
+commit_changes () {
+ local template
+ template=$1
+
+ for s in /lib/partman/commit.d/*; do
+ if [ -x $s ]; then
+ $s || {
+ db_input critical $template || true
+ db_go || true
+ for s in /lib/partman/init.d/*; do
+ if [ -x $s ]; then
+ $s || return 255
+ fi
+ done
+ return 1
+ }
+ fi
+ done
+
+ return 0
+}
+
log '*******************************************************'
# Local Variables:
Existing versions:
script priority exit_commit exit_init
--------------------------------------------------
auto_raid critical 1 255
crypto high 0 255
dmraid critical 0 255
lvm critical 0 255
md high 0 255
partitioning_1 high 0 0
partitioning_2 high 100 100
--------------------------------------------------
Callers:
-------------------
partman-base/partman
-> partman-auto/display.d/initial_auto
-> partman-auto-raid/display.d/initial_auto_raid
Current behaviour:
commit.d failure -> exit 1
init.d failure -> exit 255
---> No change
-------------------
partman-base/partman
-> partman-base/display.d/manual_partitioning
-> partman-md/choose_partition/md/do_option
-> partman-lvm/choose_partition/lvm/do_option
-> partman-dmread/choose_partition/dmread/do_option
-> partman-crypto/choose_partition/crypto/do_option
Current behaviour:
commit.d failure -> exit 0
init.d failure -> exit 255
Called by partman-base/partman in display.d loop
via partman-base/display.d/manual_partitioning. The
exit code is propagated all the way up to partman.
Exception: exit 0 is changed into 99
(exit 255 causes partman to exit)
(exit 0 (really 99) causes repeat of display.d loop)
Treating commit.d as error and exiting 1 means no
change in behaviour since partman in the display.d
loop treats all of 1 <= x <= 99 the same way.
---> No change in behavour
-------------------
partman-base/partman
-> partman-auto/display.d/initial_auto
-> partman-auto-crypto/autopartition-crypto
-> partman-crypt/crypto_tools.sh crypto_setup
Current behaviour:
commit.d failure -> exit 0
init.d failure -> exit 255
Previously commit.d failure was ignored. Now it
propagates to initial_auto via autopartition-crypto.
initial_auto ignores exit code.
---> No change
-------------------
partman-base/choose_partition/partitiom_tree/do_option
-> partman-partitioning/active_partition/copy/do_option
Existing code exits with 0 on any errors.
Called by partman-base/choose_partition/partition_tree/do_option.
Any exit code < 100 is ignored. >= 100 stops loop. Error is
not further propagated.
--> No change
-------------------
partitioning_2: commit in resize.sh
Existing code exits with 100 on any errors.
--> No change
-------------------
Reply to: