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

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