Skip to contentSkip to conversation

master - tests: aux.sh check for already present config

PATCH Zdenek Kabelac 1 participant 1 message Jul 10, 2017

lore
Share & tools
lore
#0 lore raw
Gitweb:        https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=d426d7e7099b23d169e396292a25ab97cbfc2000
Commit:        d426d7e7099b23d169e396292a25ab97cbfc2000
Parent:        32c0dc35493c36b1f4d79264af1ad09a6150b198
Author:        Zdenek Kabelac <[email protected]>
AuthorDate:    Fri Jul 7 23:03:08 2017 +0200
Committer:     Zdenek Kabelac <[email protected]>
CommitterDate: Mon Jul 10 14:23:53 2017 +0200

tests: aux.sh check for already present config

'aux lvmconf' detects if new config needs to be regenerated.

---
 test/lib/aux.sh |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)
test/lib/aux.sh +12 -0
index 3f54dbb..13be7c5 100644
@@ -1226,6 +1226,18 @@ EOF
 
 lvmconf() {
 	unset profile_name
+	test $# -eq 0 || {
+		# Compare if passed args aren't already all in generated lvm.conf
+		local needed=0
+		for i in "$@"; do
+			val=$(grep "${i%%[={ ]*}" CONFIG_VALUES 2>/dev/null | tail -1) || { needed=1; break; }
+			test "$val" = "$i" || { needed=1; break; }
+		done
+		test "$needed" -eq 0 && {
+			echo "## LVMCONF: values are already there, skipping."
+			return 0 # not needed
+		}
+	}
 	generate_config "$@"
 	mv -f CONFIG "$LVM_SYSTEM_DIR/lvm.conf"
 }