Mailinglist Archive: opensuse-autoinstall (99 mails)

< Previous Next >
Re: [opensuse-autoinstall] yast2 autoyast
  • From: Uwe Gansert <ug@xxxxxxx>
  • Date: Tue, 29 May 2007 16:31:49 +0200
  • Message-id: <200705291631.49504.ug@xxxxxxx>
On Tuesday 29 May 2007 15:47, Alan Mosca wrote:

>  I'm trying to write a script to make life easier for me and ideally I
> would like to open 'yast2 autoyast' and tell it to read in my
> autoyast.xml. Is this supported somehow?

hm. Why not? Sounds reasonable.
I have attached a patch for the autoyast client in /usr/share/YaST2/clients/
It's not tested very well though (just tested with a quick
"yast2 autoyast file filename=/tmp/small_lvm.xml"
and no smoke was seen but the file was loaded).

-- 
ciao, Uwe Gansert

Uwe Gansert, Server Technologies Team
SUSE LINUX Products GmbH, GF: Markus Rex, HRB 16746 (AG Nürnberg)
Business: http://www.suse.de/~ug
now playing Faderhead - Friday Night Binge
--- /usr/share/YaST2/clients/autoyast.ycp       2006-11-29 10:36:56.000000000 +0100
+++ src/clients/autoyast.ycp    2007-05-29 16:23:42.052305428 +0200
@@ -18,6 +18,7 @@
     import "Sequencer";
     import "Popup";
     import "AddOnProduct";
+    import "CommandLine";
 
     include "autoinstall/dialogs.ycp";
     include "autoinstall/conftree.ycp";
@@ -37,6 +38,63 @@
     Pkg::CallbackAcceptFileWithoutChecksum("AutoInstall::callbackTrue");
     Pkg::CallbackAcceptUnsignedFile("AutoInstall::callbackTrue");
 
+    void openFile( map <string, any> options ) {
+        if( !Profile::ReadXML( options["filename"]:"" ) ) {
+            Popup::Error(_("Error while parsing the control file.
+Check the log files for more details or fix the
+control file and try again.
+"));
+        }
+    }
+
+
+    map cmdline = $[
+        "id"        : "autoyast2",
+        "help"      : _("autoyast"),
+        "actions"   : $[
+            "file" :   $[ "handler":openFile, "help":"sure" ]
+        ],
+        "options"       : $[
+            "filename": $[
+                "type":"string",
+                "help":"no help"
+            ]
+        ],
+        "mappings"      : $[
+            "file"  :   ["filename"]
+        ]
+    ];
+    if(!CommandLine::Init(cmdline, WFM::Args()))
+    {
+        y2error("Commandline init failed");
+        return (symbol)AutoSequence ();
+    }
+    // command line options
+    /* Init variables */
+    string command = "";
+    list flags = [];
+    map<string,any> options = $[];
+    string exit = "";
+    list l = [];
+
+    while(!CommandLine::Done())
+    {
+        map m = CommandLine::Command();
+        command = m["command"]:"exit";
+        options = m["options"]:$[];
+
+        if( command == "file" ) {
+            openFile(options);
+        } else {
+            /* maybe we got "exit" or "quit" */
+            if( !CommandLine::Done() ) {
+                CommandLine::Print("Unknown command (should not happen)");
+                continue;
+            }
+        }
+    }
+
+
     symbol ret = (symbol)AutoSequence ();
     AddOnProduct::CleanModeConfigSources();
     return ret;
< Previous Next >
This Thread
References