[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: [PATCH] Generate /etc/initramfs-tools/conf.d/resume during install





On Tue, Jul 28, 2009 at 5:18 PM, Daniel Baumann <daniel@debian.org> wrote:
<snip>

+if [ "$resume_devfs" ] && [ -e "$resume_devfs" ]; then

simplify: if $resume_defs exists, it's also never empty.

+               sed -e "s@^#* *RESUME=.*@RESUME=$resume@" < $resumeconf >
$resumeconf.new &&
+                       mv $resumeconf.new $resumeconf

simplify: busybox's sed understands -i

otherwise looks good from the first look, will have a look and generate
a test image later.

There are a lot of things that could be done to make the script look prettier. My original intent was to try and keep the code as close as possible to that of base-installer's. However, I certainly have no strong feelings about this and so I'm happy to make the requested changes; updated patch attached.

Cheers,

--
Cody A.W. Somerville
Software Systems Release Engineer
Foundations Team
Custom Engineering Solutions Group
Canonical OEM Services
Phone: +1-781-850-2087
Cell: +1-506-471-8402
Email: cody.somerville@canonical.com
diff -Nur a/live-installer.d/initramfs-tools b/live-installer.d/initramfs-tools
--- a/live-installer.d/initramfs-tools	1969-12-31 20:00:00.000000000 -0400
+++ b/live-installer.d/initramfs-tools	2009-07-28 18:27:53.000000000 -0300
@@ -0,0 +1,29 @@
+#!/bin/sh -e
+
+# Detect resume partition and write it to configuration file.
+
+. /usr/lib/base-installer/library.sh
+
+resumeconf=$IT_CONFDIR/resume
+
+resume_devfs="$(get_resume_partition)" || resume_devfs=
+if [ -e "$resume_devfs" ]; then
+	resume="$(mapdevfs "$resume_devfs")" || resume=
+else
+	resume=
+fi
+
+if [ "$resume" ]; then
+	resume_uuid="$(block-attr --uuid "$resume" || true)"
+	if [ "$resume_uuid" ]; then
+		resume="UUID=$resume_uuid"
+	fi
+fi
+
+if [ -n "$resumeconf" ] && [ "$resume" ]; then
+	if [ -f $resumeconf ] ; then
+		sed -i "s@^#* *RESUME=.*@RESUME=$resume@" $resumeconf
+	else
+		echo "RESUME=$resume" >> $resumeconf
+	fi
+fi

Reply to: