Blame SOURCES/0016-New-lens-Anaconda-597.patch

ee1b47
From affbc1187de0ca5f9c0cc23ba75da7b8d09402e4 Mon Sep 17 00:00:00 2001
ee1b47
From: Pino Toscano <ptoscano@redhat.com>
ee1b47
Date: Wed, 12 Dec 2018 13:54:06 +0100
ee1b47
Subject: [PATCH] New lens: Anaconda (#597)
ee1b47
ee1b47
Introduce a new lens to parse the INI-like `/etc/sysconfig/anaconda` instead of using `Shellvars`.
ee1b47
---
ee1b47
 lenses/anaconda.aug               | 30 +++++++++++
ee1b47
 lenses/shellvars.aug              |  1 +
ee1b47
 lenses/tests/test_anaconda.aug    | 89 +++++++++++++++++++++++++++++++
ee1b47
 tests/Makefile.am                 |  1 +
ee1b47
 tests/root/etc/sysconfig/anaconda |  5 ++
ee1b47
 5 files changed, 126 insertions(+)
ee1b47
 create mode 100644 lenses/anaconda.aug
ee1b47
 create mode 100644 lenses/tests/test_anaconda.aug
ee1b47
 create mode 100644 tests/root/etc/sysconfig/anaconda
ee1b47
ee1b47
diff --git a/lenses/anaconda.aug b/lenses/anaconda.aug
ee1b47
new file mode 100644
ee1b47
index 00000000..8f618db2
ee1b47
--- /dev/null
ee1b47
+++ b/lenses/anaconda.aug
ee1b47
@@ -0,0 +1,30 @@
ee1b47
+(*
ee1b47
+Module: Anaconda
ee1b47
+    Parses Anaconda's user interaction configuration files.
ee1b47
+
ee1b47
+Author: Pino Toscano <ptoscano@redhat.com>
ee1b47
+
ee1b47
+About: Reference
ee1b47
+    https://anaconda-installer.readthedocs.io/en/latest/user-interaction-config-file-spec.html
ee1b47
+
ee1b47
+About: Configuration file
ee1b47
+    This lens applies to /etc/sysconfig/anaconda.
ee1b47
+
ee1b47
+About: License
ee1b47
+  This file is licensed under the LGPL v2+, like the rest of Augeas.
ee1b47
+*)
ee1b47
+module Anaconda =
ee1b47
+autoload xfm
ee1b47
+
ee1b47
+let comment = IniFile.comment "#" "#"
ee1b47
+let sep     = IniFile.sep "=" "="
ee1b47
+
ee1b47
+let entry   = IniFile.entry IniFile.entry_re sep comment
ee1b47
+let title   = IniFile.title IniFile.record_re
ee1b47
+let record  = IniFile.record title entry
ee1b47
+
ee1b47
+let lns     = IniFile.lns record comment
ee1b47
+
ee1b47
+let filter  = incl "/etc/sysconfig/anaconda"
ee1b47
+
ee1b47
+let xfm     = transform lns filter
ee1b47
diff --git a/lenses/shellvars.aug b/lenses/shellvars.aug
ee1b47
index c92d56ea..467e9643 100644
ee1b47
--- a/lenses/shellvars.aug
ee1b47
+++ b/lenses/shellvars.aug
ee1b47
@@ -252,6 +252,7 @@ module Shellvars =
ee1b47
 
ee1b47
   let filter_sysconfig =
ee1b47
       sc_incl "*" .
ee1b47
+      sc_excl "anaconda" .
ee1b47
       sc_excl "bootloader" .
ee1b47
       sc_excl "hw-uuid" .
ee1b47
       sc_excl "hwconf" .
ee1b47
diff --git a/lenses/tests/test_anaconda.aug b/lenses/tests/test_anaconda.aug
ee1b47
new file mode 100644
ee1b47
index 00000000..50b0ac22
ee1b47
--- /dev/null
ee1b47
+++ b/lenses/tests/test_anaconda.aug
ee1b47
@@ -0,0 +1,89 @@
ee1b47
+(*
ee1b47
+Module: Test_Anaconda
ee1b47
+  Provides unit tests and examples for the <Anaconda> lens.
ee1b47
+
ee1b47
+  - 'exampleN' snippets are taken from the documentation:
ee1b47
+    https://anaconda-installer.readthedocs.io/en/latest/user-interaction-config-file-spec.html
ee1b47
+  - 'installedN' snippets are taken from the resulting files after
ee1b47
+    a successful installation
ee1b47
+*)
ee1b47
+
ee1b47
+module Test_Anaconda =
ee1b47
+
ee1b47
+let example1 = "# comment example - before the section headers
ee1b47
+
ee1b47
+[section_1]
ee1b47
+# comment example - inside section 1
ee1b47
+key_a_in_section1=some_value
ee1b47
+key_b_in_section1=some_value
ee1b47
+
ee1b47
+[section_2]
ee1b47
+# comment example - inside section 2
ee1b47
+key_a_in_section2=some_value
ee1b47
+"
ee1b47
+
ee1b47
+test Anaconda.lns get example1 =
ee1b47
+  { "#comment" = "comment example - before the section headers" }
ee1b47
+  { }
ee1b47
+  { "section_1"
ee1b47
+    { "#comment" = "comment example - inside section 1" }
ee1b47
+    { "key_a_in_section1" = "some_value" }
ee1b47
+    { "key_b_in_section1" = "some_value" }
ee1b47
+    { }
ee1b47
+  }
ee1b47
+  { "section_2"
ee1b47
+    { "#comment" = "comment example - inside section 2" }
ee1b47
+    { "key_a_in_section2" = "some_value" }
ee1b47
+  }
ee1b47
+
ee1b47
+let example2 = "# this is the user interaction config file
ee1b47
+
ee1b47
+[General]
ee1b47
+post_install_tools_disabled=0
ee1b47
+
ee1b47
+[DatetimeSpoke]
ee1b47
+# the date and time spoke has been visited
ee1b47
+visited=1
ee1b47
+changed_timezone=1
ee1b47
+changed_ntp=0
ee1b47
+changed_timedate=1
ee1b47
+
ee1b47
+[KeyboardSpoke]
ee1b47
+# the keyboard spoke has not been visited
ee1b47
+visited=0
ee1b47
+"
ee1b47
+
ee1b47
+test Anaconda.lns get example2 =
ee1b47
+  { "#comment" = "this is the user interaction config file" }
ee1b47
+  { }
ee1b47
+  { "General"
ee1b47
+    { "post_install_tools_disabled" = "0" }
ee1b47
+    { }
ee1b47
+  }
ee1b47
+  { "DatetimeSpoke"
ee1b47
+    { "#comment" = "the date and time spoke has been visited" }
ee1b47
+    { "visited" = "1" }
ee1b47
+    { "changed_timezone" = "1" }
ee1b47
+    { "changed_ntp" = "0" }
ee1b47
+    { "changed_timedate" = "1" }
ee1b47
+    { }
ee1b47
+  }
ee1b47
+  { "KeyboardSpoke"
ee1b47
+    { "#comment" = "the keyboard spoke has not been visited" }
ee1b47
+    { "visited" = "0" }
ee1b47
+  }
ee1b47
+
ee1b47
+let installed1 = "# This file has been generated by the Anaconda Installer 21.48.22.134-1
ee1b47
+
ee1b47
+[ProgressSpoke]
ee1b47
+visited = 1
ee1b47
+
ee1b47
+"
ee1b47
+
ee1b47
+test Anaconda.lns get installed1 =
ee1b47
+  { "#comment" = "This file has been generated by the Anaconda Installer 21.48.22.134-1" }
ee1b47
+  { }
ee1b47
+  { "ProgressSpoke"
ee1b47
+    { "visited" = "1" }
ee1b47
+    { }
ee1b47
+  }
ee1b47
diff --git a/tests/Makefile.am b/tests/Makefile.am
ee1b47
index 2b87c1c7..7aa1f14c 100644
ee1b47
--- a/tests/Makefile.am
ee1b47
+++ b/tests/Makefile.am
ee1b47
@@ -22,6 +22,7 @@ lens_tests =			\
ee1b47
   lens-activemq_xml.sh		\
ee1b47
   lens-afs_cellalias.sh			\
ee1b47
   lens-aliases.sh		\
ee1b47
+  lens-anaconda.sh		\
ee1b47
   lens-anacron.sh		\
ee1b47
   lens-approx.sh		\
ee1b47
   lens-apt_update_manager.sh		\
ee1b47
diff --git a/tests/root/etc/sysconfig/anaconda b/tests/root/etc/sysconfig/anaconda
ee1b47
new file mode 100644
ee1b47
index 00000000..73318cf6
ee1b47
--- /dev/null
ee1b47
+++ b/tests/root/etc/sysconfig/anaconda
ee1b47
@@ -0,0 +1,5 @@
ee1b47
+# This file has been generated by the Anaconda Installer 21.48.22.134-1
ee1b47
+
ee1b47
+[ProgressSpoke]
ee1b47
+visited = 1
ee1b47
+
ee1b47
-- 
ee1b47
2.17.2
ee1b47