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

[PATCH] fix LH_BOOTAPPEND_INSTALL expansion



Hi,

since live-helper 1.0.6, and also in LH2, I'm getting a very long
content in LH_BOOTAPPEND_INSTALL because LH_BOOTAPPEND_LIVE is
expanded each time "lh config" is executed.

For example:
$ lh config
$ lh config --bootappend-live "locale=pt keyb=pt utc=no
timezone=Europe/Lisbon quickreboot quiet"
$ lh config --binary-images usb-hdd
$ lh_config --linux-flavours "686"

At this point the last "lh config" has expanded the content of the
variable LH_BOOTAPPEND_LIVE inside the line "LH_BOOTAPPEND_INSTALL="
-- \${LH_BOOTAPPEND_LIVE}" (done in line 840 in functions/defaults.sh)
and does it each time "lh config" is executed. "cdrom-detect/try-usb"
is getting duplicated too.

In live-helper 1.0.5 and earlier versions, LH_BOOTAPPEND_INSTALL was
only updated if it was unset.

To avoid a regression on this, I'd like to propose this patch. The
main changes are the following: before starting to update
LH_BOOTAPPEND_INSTALL, it removes the "LH_BOOTAPPEND_LIVE content from
it to avoid duplications. It also removes any previous
"cdrom-detect/try-usb" option before applying another one. Also,
leading/trailing spaces are removed.

Please remove any comments that you consider superfluous and  make any
necessary changes to make it simpler.


Regards,

Rui M. P. Bernardo
diff --git a/functions/defaults.sh b/functions/defaults.sh
index 3179df0..218eb8a 100755
--- a/functions/defaults.sh
+++ b/functions/defaults.sh
@@ -799,8 +799,13 @@ Set_defaults ()
 		esac
 	fi
 
+	# remove the expanded LH_BOOTAPPEND_LIVE option after -- (it's added again later)
+	LH_BOOTAPPEND_INSTALL="$(echo "${LH_BOOTAPPEND_INSTALL}" | sed -e 's| --.*$||')"
+
 	if [ "${LH_BINARY_IMAGES}" = "usb-hdd" ]
 	then
+		# Remove any previously added cdrom-detect option. No duplication.
+		LH_BOOTAPPEND_INSTALL="$(echo "${LH_BOOTAPPEND_INSTALL}" | sed -e 's|cdrom-detect\/try-usb=true||')"
 		# Try USB block devices for install media
 		LH_BOOTAPPEND_INSTALL="cdrom-detect/try-usb=true ${LH_BOOTAPPEND_INSTALL}"
 	fi
@@ -810,6 +815,9 @@ Set_defaults ()
 		LH_BOOTAPPEND_INSTALL="${LH_BOOTAPPEND_INSTALL} ${_LH_BOOTAPPEND_PRESEED}"
 	fi
 
+	# Remove any leading and/or trailing space
+	LH_BOOTAPPEND_INSTALL="$(echo "${LH_BOOTAPPEND_INSTALL}" | sed -e 's|^ *||g;s| *$||g')"
+
 	if [ -n "${LH_BOOTAPPEND_LIVE}" ]
 	then
 		LH_BOOTAPPEND_INSTALL="${LH_BOOTAPPEND_INSTALL} -- \${LH_BOOTAPPEND_LIVE}"

Reply to: