Author: jsuchome
Date: Thu Jul 19 13:52:47 2007
New Revision: 39527
URL: http://svn.opensuse.org/viewcvs/yast?rev=39527&view=rev
Log:
added possibility to run only kiwi UI
Added:
trunk/product-creator/src/kiwi_dialogs.ycp (with props)
Modified:
trunk/product-creator/src/Kiwi.ycp
trunk/product-creator/src/Makefile.am
trunk/product-creator/src/kiwi.ycp
trunk/product-creator/src/wizards.ycp
Modified: trunk/product-creator/src/Kiwi.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/product-creator/src/Kiwi.ycp?rev=39527&r1=39526&r2=39527&view=diff
==============================================================================
--- trunk/product-creator/src/Kiwi.ycp (original)
+++ trunk/product-creator/src/Kiwi.ycp Thu Jul 19 13:52:47 2007
@@ -27,6 +27,8 @@
global string images_dir = "/usr/share/kiwi/image";
+ list<map> all_sources = [];
+
// where the kiwi configuration files are stored
string config_dir = "";
@@ -57,11 +59,44 @@
if (substring (source, 0, 6) == "dir://")
return substring (source, 6);
- //FIXME plaindir -> rpm-dir
return source;
}
/**
+ * generate the 'repository' tag
+ */
+ map get_source_value (string source) {
+
+ string type = "yast2";
+ string source_path = source;
+ if (substring (source, 0, 1) == "/")
+ source_path = "dir://" + source;
+
+ foreach (map sourcemap, all_sources, {
+ integer srcid = sourcemap["SrcId"]:-1;
+ map data = Pkg::SourceGeneralData (srcid);
+ string url = data["url"]:"";
+ if (url == source || url == source_path)
+ {
+ if (data["type"]:"" == "Plaindir")
+ type = "rpm-dir";
+ if (data["type"]:"" == "YUM")
+ type = "rpm-md";
+ }
+ });
+ return $[
+ "__key" : "repository",
+ "type" : type,
+ "__children": [
+ $[
+ "__key" : "source",
+ "path" : source
+ ]
+ ]
+ ];
+ }
+
+ /**
* generate the name of directory with kiwi configuration
*/
string get_config_dir (string name, string task) {
@@ -86,6 +121,21 @@
}
/**
+ * generate the list of packages/patterns for image
+ */
+ map get_image_packages (map config, list packages, list patterns,list ignored)
+ {
+ map ret = $[
+ "__key" : "packages",
+ "type" : "image",
+ "__children": union (union (packages, patterns), ignored)
+ ];
+ if (config["image_patternType"]:"" != "")
+ ret["patternType"] = config["image_patternType"]:"";
+ return ret;
+ }
+
+ /**
* which keys in config.xml are not unique
*/
map non_unique_key = $[
@@ -150,30 +200,48 @@
map config = (map) SCR::Read (.kiwi, base_path + "/config.xml");
map packages = config["packages"]:$[];
// rest parts of "packages" are saved in product-creator map
- ret["ignore"] = maplist (map p, (list<map>)packages["image","ignore"]:[], ``(p["name"]:""));
+ ret["ignore"] = maplist (map p,
+ (list<map>)packages["image","ignore"]:[], ``(p["name"]:""));
// value of "arch" is currently ignored...
foreach (string section, [ "boot", "xen" ], {
- ret[section + "_packages"] =
- maplist (map p, (list<map>)packages[section, "package"]:[], ``(p["name"]:""));
- ret[section + "_patterns"] =
- maplist (map p, (list<map>)packages[section, "opensusePattern"]:[], ``(p["name"]:""));
- ret[section + "_ignore"] =
- maplist (map p, (list<map>)packages[section, "ignore"]:[], ``(p["name"]:""));
- });
+ ret[section + "_packages"] = maplist (map p,
+ (list<map>)packages[section, "package"]:[], ``(p["name"]:""));
+ ret[section + "_patterns"] = maplist (map p,
+ (list<map>)packages[section,"opensusePattern"]:[],``(p["name"]:""));
+ ret[section + "_ignore"] = maplist (map p,
+ (list<map>)packages[section, "ignore"]:[], ``(p["name"]:""));
+ });
+ // list of packages and patterns is needed for import, not for new image
+ ret["addons"] = maplist (map p,
+ (list<map>)packages["image","opensusePattern"]:[], ``(p["name"]:""));
+ ret["packages"] = maplist (map p,
+ (list<map>)packages["image","package"]:[], ``(p["name"]:""));
+ if (packages["image","patternType"]:"" != "")
+ ret["image_patternType"] = packages["image","patternType"]:"";
if (packages["xen","disk"]:"" != "")
ret["xen_disk"] = packages["xen","disk"]:"";
if (packages["xen","memory"]:"" != "")
ret["xen_memory"] = tointeger (packages["xen","memory"]:"512");
-// FIXME read list of packages and patterns???? -> only for non-default!
- foreach (string key, [ "author", "contact", "specification", "packagemanager", "version",
- "rpm-check-signatures", "rpm-force", "sizeunit", "type" ], {
+ foreach (string key, [ "author", "contact", "specification",
+ "packagemanager", "version", "rpm-check-signatures", "rpm-force",
+ "sizeunit", "type", "name", "repository" ],
+ {
if (config[key]:nil != nil)
ret[key] = config[key]:nil;
});
if (haskey (config, "size"))
ret["size"] = tointeger (config["size"]:"2700");
-
+ foreach (string user, map usermap, (map) config["users"]:$[], {
+ if (!haskey (ret, "users"))
+ ret["users"] = $[];
+ if (haskey (usermap, "group"))
+ ret["group"] = usermap["group"]:"";
+ ret["users",user] = $[
+ "home" : usermap["home"]:sformat ("/home/%1", user),
+ "pwd" : user
+ ];
+ });
return ret;
}
@@ -182,6 +250,8 @@
*/
global boolean WriteConfigXML (map KiwiConfig, string kiwi_task) {
+ all_sources = Pkg::SourceEditGet();
+
tmp_dir = Directory::tmpdir;
list packages_list = [];
@@ -317,27 +387,13 @@
]);
}
write_list[0,"__children"] = union (write_list[0,"__children"]:[],
- maplist (string source, (list<string>) KiwiConfig["sources"]:[], {
- return $[
- "__key" : "repository",
- "type" : "yast2", //FIXME rpm-dir?
- "__children": [
- $[
- "__key" : "source",
- "path" : adapt_source_path (source),
- ]
- ]
- ];
- })
+ maplist (string source, (list<string>) KiwiConfig["sources"]:[],
+ ``(get_source_value (source))
+ )
);
write_list[0,"__children"] = union (write_list[0,"__children"]:[], [
- $[
- "__key" : "packages",
- "type" : "image",
-// "patternType" : "onlyRequired". // FIXME what does this mean?
-// "patternType" : "plusRecommended",
- "__children": union (union (packages_list, patterns_list), ignored_list)
- ],
+ get_image_packages (
+ KiwiConfig, packages_list, patterns_list, ignored_list),
$[
"__key" : "packages",
"type" : "boot",
Modified: trunk/product-creator/src/Makefile.am
URL: http://svn.opensuse.org/viewcvs/yast/trunk/product-creator/src/Makefile.am?rev=39527&r1=39526&r2=39527&view=diff
==============================================================================
--- trunk/product-creator/src/Makefile.am (original)
+++ trunk/product-creator/src/Makefile.am Thu Jul 19 13:52:47 2007
@@ -8,7 +8,8 @@
YCPCFLAGS = -I ./include
client_DATA = \
- product-creator.ycp
+ product-creator.ycp \
+ kiwi.ycp
ynclude_DATA = \
helps.ycp \
@@ -17,8 +18,7 @@
complex.ycp \
routines.ycp \
commandline.ycp \
- kiwi.ycp
-
+ kiwi_dialogs.ycp
desktop_DATA = \
product-creator.desktop
Modified: trunk/product-creator/src/kiwi.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/product-creator/src/kiwi.ycp?rev=39527&r1=39526&r2=39527&view=diff
==============================================================================
--- trunk/product-creator/src/kiwi.ycp (original)
+++ trunk/product-creator/src/kiwi.ycp Thu Jul 19 13:52:47 2007
@@ -1,1370 +1,78 @@
/**
- * File: include/product-creator/kiwi.ycp
+ * File: clients/kiwi.ycp
* Package: Configuration of product-creator
- * Summary: Dialogs for kiwi configuration
+ * Summary: Client to start the kiwi UI
* Authors: Jiri Suchomel
*
* $Id$
+ *
*/
-{
- textdomain "product-creator";
-
- import "CWM";
- import "CWMTab";
- import "ProductCreator";
- import "FileUtils";
- import "Label";
- import "Kiwi";
- import "Popup";
- import "Summary";
- import "Wizard";
-
- include "product-creator/dialogs.ycp";
-
- // map of current Live ISO configuration
- map KiwiConfig = $[];
-
- // what are we configuring now ("iso"/"xen"/...)
- string kiwi_task = "";
-
- // directory with kiwi images
- string images_dir = "";
-
- // return the id of actual widget for boot image
- string boot_image_widget () {
- return kiwi_task + "boot";
- }
-
- string get_name () {
- return KiwiConfig["name"]:"";
- }
-
-
- // read available the images under /usr/share/kiwi/image/ directory
- list<term> GetAvailableImages (string subdir) {
-
- list<term> ret = [];
- map out = (map) SCR::Execute (.target.bash_output, sformat ("ls %1/%2", images_dir, subdir));
- if (out["exit"]:0 != 0)
- return ret;
- foreach (string file, splitstring (out["stdout"]:"", "\n"), {
- if (file != "" && FileUtils::IsDirectory (sformat ("%1/%2/%3", images_dir, subdir, file)))
- {
- ret = add (ret, `item (`id(file), file, file == KiwiConfig[subdir]:""));
- }
- });
- return ret;
- }
-
- /********************************************************************************************
- * widget handlers
- *******************************************************************************************/
-
- /**
- * Initialize the widget with ignored packages
- */
- define void InitSWIgnore (string id) {
- string sw_selection = KiwiConfig["sw_selection"]:"image";
- string ignore_key = sw_selection == "image" ? "ignore" : (sw_selection + "_ignore");
- UI::ChangeWidget (`id (id), `Value, mergestring (KiwiConfig[ignore_key]:[], "\n"));
- }
-
- define void StoreSWIgnore (string key, map event) {
- string sw_selection = KiwiConfig["sw_selection"]:"image";
- string ignore_key = sw_selection == "image" ? "ignore" : (sw_selection + "_ignore");
- KiwiConfig[ignore_key] = filter (string p,
- splitstring ((string) UI::QueryWidget(`id(key), `Value), "\n"), ``(p != ""));
- }
-
- define symbol HandleSWIgnore (string key, map event) {
- if (event["ID"]:nil == `next) StoreSWIgnore (key, event);
- return nil;
- }
-
-
- /**
- * Initialize the contents of richtext with selected software
- */
- define void InitSWRichText (string id) {
-
- string sw_selection = KiwiConfig["sw_selection"]:"image";
- string pattern_key = sw_selection == "image" ? "addons" : (sw_selection + "_patterns");
- string rt = "";
- if (KiwiConfig[pattern_key]:[] != [])
- {
- // richtext header
- rt = Summary::AddHeader ("", _("Patterns"));
- foreach (string pattern, (list<string>) KiwiConfig[pattern_key]:[], {
- rt = Summary::AddListItem (rt, pattern);
- });
- }
- string package_key = sw_selection == "image" ? "packages" : (sw_selection + "_packages");
- if (KiwiConfig[package_key]:[] != [])
- {
- // richtext header
- rt = Summary::AddHeader (rt, _("Packages"));
- foreach (string package, (list<string>) KiwiConfig[package_key]:[], {
- rt = Summary::AddListItem (rt, package);
- });
- }
- UI::ChangeWidget (`id (id), `Value, rt);
- }
-
- /**
- * Handler for software selection
- */
- define symbol HandleSWSelection (string key, map event) {
- if (event["ID"]:nil == key)
- {
- string sw_selection = KiwiConfig["sw_selection"]:"image";
- if (sw_selection == "image" && packageSelector () != `cancel)
- {
- KiwiConfig["addons"] = ProductCreator::Config["addons"]:[];
- KiwiConfig["packages"] = ProductCreator::Config["packages"]:[];
- InitSWRichText ("rt_sw");
- //FIXME will replace current tags...
- if (ProductCreator::Config["taboo"]:[] != nil)
- {
- KiwiConfig["ignore"] = ProductCreator::Config["taboo"]:[];
- InitSWIgnore ("ignore");
- }
- }
- else if (sw_selection != "image")
- {
- map selected = runPackageSelector ("",
- KiwiConfig[sw_selection + "_patterns"]:[],
- KiwiConfig[sw_selection + "_packages"]:[],
- KiwiConfig[sw_selection + "_ignore"]:[],
- `packages
- );
- KiwiConfig[sw_selection + "_patterns"] = selected["addons"]:[];
- KiwiConfig[sw_selection + "_packages"] = selected["packages"]:[];
- InitSWRichText ("rt_sw");
- if (ProductCreator::Config["taboo"]:[] != nil)
- {
- KiwiConfig["ignore"] = ProductCreator::Config["taboo"]:[];
- InitSWIgnore ("ignore");
- }
- }
- }
- return nil;
- }
-
- /**
- * initialize the combo box with package selection groups
- */
- define void InitSWSelectionCombo (string id) {
- string sw_selection = KiwiConfig["sw_selection"]:"image";
- list items = [
- `item (`id ("image"), _("Image"), sw_selection == "image"),
- ];
- if (kiwi_task == "xen")
- items = add (items, `item (`id ("xen"), _("Xen Specific"), sw_selection == "xen"));
- UI::ChangeWidget (`id (id), `Items, items);
- }
-
- define void StoreSWSelectionCombo (string key, map event) {
- KiwiConfig[key] = (string) UI::QueryWidget(`id(key), `Value);
- }
-
- /**
- * handler for combo box with isoboot items
- */
- define symbol HandleSWSelectionCombo (string key, map event) {
- any id = event["ID"]:nil;
- // store the value on exiting
- if (id == `next) StoreSWSelectionCombo (key, event);
- else if (event["ID"]:nil == key)
- {
- string selected = (string) UI::QueryWidget(`id(key), `Value);
- if (selected != KiwiConfig["sw_selection"]:"image")
- {
- StoreSWIgnore ("ignore", event);
- StoreSWSelectionCombo (key, event);
- InitSWRichText ("rt_sw");
- InitSWIgnore ("ignore");
- }
- }
- return nil;
- }
-
-
- /**
- * initialize the value of combo box with isoboot items
- */
- define void InitBootCombo (string id) {
- UI::ChangeWidget (`id (id), `Items, GetAvailableImages (id));
- }
-
- /**
- * store the value of current isoboot image
- */
- define void StoreBootCombo (string key, map event) {
- KiwiConfig[key] = (string) UI::QueryWidget(`id(key), `Value);
- }
- /**
- * handler for combo box with isoboot items
- */
- define symbol HandleBootCombo (string key, map event) {
- // store the value on exiting
- if (event["ID"]:nil == `next) StoreBootCombo (key, event);
- return nil;
- }
- /**
- * initialize the value of compress checkbox
- */
- define void InitCompressCheckBox (string id) {
- UI::ChangeWidget (`id (id), `Enabled, false);// FIXME squashfs not available?
- UI::ChangeWidget (`id (id), `Value, KiwiConfig["compressed"]:false);
- }
-
- /**
- * store the value of compress checkbox
- */
- define void StoreCompressCheckBox (string key, map event) {
- KiwiConfig["compressed"] = (boolean) UI::QueryWidget(`id(key), `Value);
- }
- /**
- * handler for compress checkbox
- */
- define symbol HandleCompressCheckBox (string key, map event) {
- // store the value on exiting
- if (event["ID"]:nil == `next) StoreCompressCheckBox (key, event);
- return nil;
- }
-
- /**
- * initialize the value of version
- */
- define void InitVersion (string id) {
- UI::ChangeWidget (`id (id), `Value, sformat ("%1", KiwiConfig[id]:"1"));
- }
-
- /**
- * store the value of current version
- */
- define void StoreVersion (string key, map event) {
- KiwiConfig[key] = sformat ("%1", UI::QueryWidget(`id(key), `Value));
- }
-
- /**
- * handler for version
- */
- define symbol HandleVersion (string key, map event) {
- // store the value on exiting
- if (event["ID"]:nil == `next) StoreVersion (key, event);
- return nil;
- }
-
- /**
- * initialize the value of combo box with isoboot items
- */
- define void InitSizeUnitCombo (string id) {
- UI::ChangeWidget (`id (id), `Items, maplist (string u, [ "M", "G" ], ``(
- `item (`id (u), u + "B", KiwiConfig[id]:"M" == u))
- ));
- }
-
- /**
- * initialize the value of version
- */
- define void InitSize (string id) {
- UI::ChangeWidget (`id (id), `Value, KiwiConfig[id]:2700);
- }
-
- /**
- * initialize the product label
- */
- define void InitLabel (string id) {
- UI::ChangeWidget (`id ("name"), `Value, KiwiConfig["name"]:"");
- }
-
-
- /**
- * universal widget: initialize the string value of widget @param
- */
- define void InitDescription (string id) {
- UI::ChangeWidget (`id (id), `Value, KiwiConfig[id]:"");
- }
-
- /**
- * store the string value of given widget
- */
- define void StoreDescription (string key, map event) {
- KiwiConfig[key] = UI::QueryWidget (`id(key), `Value);
- }
-
- /**
- * handler for general string-value widgets: store their value on exit/save
- */
- define symbol HandleDescription (string key, map event) {
- // store the value on exiting
- if (event["ID"]:nil == `next) StoreDescription (key, event);
- return nil;
- }
-
- define void InitOutputDir (string id) {
- UI::ChangeWidget (`id (id), `Value, KiwiConfig["iso-directory"]:"");
- }
-
- /**
- * initialize the table with users
- */
- define void InitUsersTable (string id) {
-
- list items = maplist (string user, map usermap, (map) KiwiConfig["users"]:$[],
- ``(`item (`id (user), user, usermap["home"]:"")));
- UI::ChangeWidget (`id ("table"), `Items, items);
- UI::ChangeWidget (`id ("edituser"), `Enabled, size (items) > 0);
- UI::ChangeWidget (`id ("deleteuser"), `Enabled, size (items) > 0);
- }
-
- /**
- * Handle changes in users table
- */
- define symbol HandleAddEditUser (string key, map event) {
- if (event["ID"]:nil != key && (key != "userstable" || event["ID"]:nil != "table")) return nil;
-
- if (key == "userstable") key = "edituser";
- string current_user = (string) UI::QueryWidget (`id ("table"), `CurrentItem);
-
- UI::OpenDialog (`opt(`decorated), `HBox (`HSpacing (0.5), `VBox (
- `VSpacing (0.5),
- // popup label
- `Label (`id (`label), _("Add new user")),
- // text entry label
- `TextEntry (`id (`username), _("&Name")),
- `Password (`id (`pw1), Label::Password(), ""),
- `Password (`id(`pw2), Label::ConfirmPassword(), ""),
- `TextEntry (`id (`home), _("&Home Directory")),
- `HBox (
- `PushButton (`id(`ok),`opt(`key_F10), Label::OKButton()),
- `PushButton (`id(`cancel),`opt(`key_F9), Label::CancelButton())
- ),
- `VSpacing (0.5)), `HSpacing (0.5))
- );
- if (key == "edituser")
- {
- UI::ChangeWidget (`id (`username), `Value, current_user);
- UI::ChangeWidget (`id (`home), `Value, KiwiConfig["users", current_user, "home"]:"");
- UI::ChangeWidget (`id (`pw1), `Value, "*****");
- UI::ChangeWidget (`id (`pw2), `Value, "*****");
- // popup label
- UI::ChangeWidget (`id (`label), `Value, _("Edit User"));
- }
- any ret = nil;
- repeat
- {
- ret = UI::UserInput ();
- if (ret == `ok)
- {
- string username = (string) UI::QueryWidget (`id(`username), `Value);
- string pwd = (string) UI::QueryWidget (`id(`pw1), `Value);
- if (username == "")
- {
- // popup message
- Report::Error (_("Enter the user name."));
- ret = `notnext;
- continue;
- }
- if (pwd != UI::QueryWidget (`id(`pw2), `Value))
- {
- // popup message
- Report::Error (_("The passwords do not match.
-Try again."));
- ret = `notnext;
- continue;
- }
- if (pwd == "")
- {
- // popup message
- Report::Error (_("Enter the user password."));
- ret = `notnext;
- continue;
- }
- if (! haskey (KiwiConfig, "users"))
- KiwiConfig["users"] = $[];
- else if (key == "edituser" && username != current_user)
- KiwiConfig["users"] = remove (KiwiConfig["users"]:$[], current_user);
- KiwiConfig["users", username] = $[
- "pwd" : pwd,
- "home" : UI::QueryWidget (`id(`home), `Value)
- ];
- }
- } until (ret == `ok || ret == `cancel);
-
- UI::CloseDialog ();
- if (ret == `ok) InitUsersTable ("table");
- return nil;
- }
-
- /**
- * handle delete user button
- */
- define symbol HandleDeleteUser (string key, map event) {
- if (event["ID"]:nil != key) return nil;
-
- string current_user = (string) UI::QueryWidget (`id ("table"), `CurrentItem);
- KiwiConfig["users"] = remove (KiwiConfig["users"]:$[], current_user);
- InitUsersTable ("table");
- return nil;
- }
-
- /**
- * initialize the table with root dir contents
- */
- define void InitRootDirTable (string id) {
-
- list items = maplist (string file, (list<string>) KiwiConfig["root_dir"]:[], {
-// return `item (`id (file), substring (file, findlastof (file, "/") + 1));
- return `item (`id (file), file);
- });
- UI::ChangeWidget (`id ("roottable"), `Items, items);
- UI::ChangeWidget (`id ("root_dir_delete"), `Enabled, size (items) > 0);
- }
-
- // add new subdir to the 'root' directory
- define symbol HandleAddToRootDir (string key, map event) {
-
- if (event["ID"]:nil != key) return nil;
- // popup for file selection dialog
- string dir = UI::AskForExistingDirectory ("", _("Directory to Import"));
- if (dir!= nil)
- {
- KiwiConfig["root_dir"] = union (KiwiConfig["root_dir"]:[], [dir]);
- InitRootDirTable ("roottable");
- }
- return nil;
- }
-
- // delete subdir from the 'root' directory
- define symbol HandleDeleteFromRootDir (string key, map event) {
- if (event["ID"]:nil != key) return nil;
- string current = (string) UI::QueryWidget (`id ("roottable"), `Value);
- KiwiConfig["root_dir"] = filter (string f, KiwiConfig["root_dir"]:[], ``(f != current));
- InitRootDirTable ("roottable");
- return nil;
- }
-
- /**
- * initialize the table with config dir contents
- */
- define void InitConfigDirTable (string id) {
-
- list items = maplist (string file, (list<string>) KiwiConfig["config_dir"]:[], {
-// return `item (`id (file), substring (file, findlastof (file, "/") + 1));
- return `item (`id (file), file);
- });
- UI::ChangeWidget (`id ("configtable"), `Items, items);
- UI::ChangeWidget (`id ("config_dir_delete"), `Enabled, size (items) > 0);
- }
-
- // add new subdir to the 'config' directory
- define symbol HandleAddToConfigDir (string key, map event) {
-
- if (event["ID"]:nil != key) return nil;
- // popup for file selection dialog
- string dir = UI::AskForExistingFile ("", "", _("Script to Import"));
- if (dir!= nil)
- {
- KiwiConfig["config_dir"] = union (KiwiConfig["config_dir"]:[], [dir]);
- InitConfigDirTable ("configtable");
- }
- return nil;
- }
-
- // delete subdir from the 'config' directory
- define symbol HandleDeleteFromConfigDir (string key, map event) {
- if (event["ID"]:nil != key) return nil;
- string current = (string) UI::QueryWidget (`id ("configtable"), `Value);
- KiwiConfig["config_dir"] = filter (string f, KiwiConfig["config_dir"]:[], ``(f != current));
- InitConfigDirTable ("configtable");
- return nil;
- }
-
- /**
- * universal handler for directory browsing
- */
- string BrowseDirectoryHandler (string key, string label) {
-
- string current = (string) UI::QueryWidget (`id (key), `Value);
- if (current == nil) current = "";
- string dir = UI::AskForExistingDirectory (current, label);
- if (dir!= nil)
- {
- UI::ChangeWidget (`id (key), `Value, dir);
- StoreDescription (key, $[]);
- }
- return dir;
- }
-
- /**
- * handler for 'root' directory browse
- */
- symbol HandleBrowseRootDirectory (string key, map event) {
- if (event["ID"]:nil != key) return nil;
- // popup for file selection dialog ('root' is a name, do not translate)
- BrowseDirectoryHandler ("root_dir", _("Path to root Directory"));
- return nil;
- }
-
- /**
- * handler for 'config' directory browse
- */
- symbol HandleBrowseConfigDirectory (string key, map event) {
- if (event["ID"]:nil != key) return nil;
- // popup for file selection dialog ('config' is a name, do not translate)
- BrowseDirectoryHandler ("config_dir", _("Path to config Directory"));
- return nil;
- }
-
- /**
- * handler for output directory browse
- */
- symbol HandleBrowseOutputDirectory (string key, map event) {
- if (event["ID"]:nil != key) return nil;
- // popup for file selection dialog
- BrowseDirectoryHandler ("output_dir", _("Path to the Output Directory"));
- return nil;
- }
-
- /**
- * universal handler for file browsing
- */
- string BrowseFileHandler (string key, string label) {
-
- string current = (string) UI::QueryWidget (`id (key), `Value);
- if (current == nil) current = "";
- string file = UI::AskForExistingFile (current, "", label);
- if (file != nil && key != "config.sh")
- {
- UI::ChangeWidget (`id (key), `Value, file);
- StoreDescription (key, $[]);
- }
- return file;
- }
-
- /**
- * Handler for browsing for images.sh file
- */
- symbol HandleBrowseImagesFile (string key, map event) {
- if (event["ID"]:nil != key) return nil;
- // popup for file selection dialog
- BrowseFileHandler ("images_path", _("Path to images.sh File"));
- return nil;
- }
-
- /**
- * Handler for browsing for autoyast profile
- */
- symbol HandleBrowseAutoYaSTFile (string key, map event) {
- if (event["ID"]:nil != key) return nil;
- // popup for file selection dialog
- BrowseFileHandler ("autoyast_path", _("Path to AutoYaST Profile"));
- return nil;
- }
-
- /**
- * Handler for importing config.sh file
- */
- symbol HandleImportConfigFile (string key, map event) {
- if (event["ID"]:nil != key) return nil;
- // popup for file selection dialog
- string file = BrowseFileHandler ("config.sh", _("Path to config.sh File"));
- if (file != nil)
- {
- if (FileUtils::Exists (file))
- {
- string configsh = (string) SCR::Read (.target.string, file);
- if (configsh != nil)
- {
- UI::ChangeWidget (`id ("config.sh"), `Value, configsh);
- StoreDescription ("config.sh", event);
- }
- }
- }
- return nil;
- }
-
- /**
- * Handler for importing images.sh file
- * TODO same function as HandleImportConfigFile
- */
- symbol HandleImportImagesFile (string key, map event) {
- if (event["ID"]:nil != key) return nil;
- // popup for file selection dialog
- string file = BrowseFileHandler ("images.sh", _("Path to images.sh File"));
- if (file != nil)
- {
- if (FileUtils::Exists (file))
- {
- string imagessh = (string) SCR::Read (.target.string, file);
- if (imagessh != nil)
- {
- UI::ChangeWidget (`id ("images.sh"), `Value, imagessh);
- StoreDescription ("images.sh", event);
- }
- }
- }
- return nil;
- }
-
- // generic popup
- define symbol NotImplementedHandler (string key, map event) {
- if (event["ID"]:nil == key)
- {
- Popup::Message (_("Feature not implemented yet."));
- }
- return nil;
- }
-
- /**
- * handler for main action: create the iso image with kiwi
- */
- define boolean CreateImage (string key, map event) {
- if (event["ID"]:nil != `next)
- return true;
- boolean ret = false;
-
- map question = $[
- // popup question
- "iso" : _("Create ISO image now?"),
- // popup question
- "xen" : _("Create Xen image now?"),
- // popup question
- "usb" : _("Create USB stick image now?"),
- // popup question
- "vmx" : _("Create virtual disk image now?"),
- ];
-
- map success = $[
- // popup message, %1 is a dir
- "iso" : _("ISO image successfully created in
-%1
-directory."),
- // popup message, %1 is a dir
- "xen" : _("Xen image files successfully created in
-%1
-directory.
-"),
- // popup message, %1 is a dir
- "usb" : _("USB stick image successfully created in
-%1
-directory."),
- // popup message, %1 is a dir
- "vmx" : _("Virtual disk image successfully created in
-%1
-directory."),
- ];
-
- if (Popup::YesNo (question[kiwi_task]:""))
- {
- if (Kiwi::WriteConfigXML (KiwiConfig, kiwi_task))
- {
- string out_dir = KiwiConfig["iso-directory"]:"";
- if (FileUtils::CheckAndCreatePath (out_dir) && Kiwi::PrepareAndCreate (out_dir))
- {
- if (kiwi_task == "usb" && false)
- {
- // additional question (yes/no)
- if (Popup::YesNo (sformat (success[kiwi_task]:"", out_dir) + _("
-Save the image to the stick now?")))
- {
- NotImplementedHandler ("", $[ "ID" : ""]);
- }
- }
- else
- {
- Popup::Message (sformat (success[kiwi_task]:"", out_dir));
- }
- ret = true;
- }
- }
- }
- if (ret)
- {
- string dir = Kiwi::SaveConfiguration (KiwiConfig, kiwi_task);
- if (dir != nil && dir != "")
- {
- ProductCreator::Config["kiwi_configuration_" + kiwi_task] = dir;
- }
- }
- return ret;
- }
-
- /**
- * Global init function for Kiwi image dialog
- * - read saved settings and fill in defaults
- */
- define void InitImageConfiguration () {
-
- kiwi_task = ProductCreator::kiwi_task;
- images_dir = Kiwi::images_dir;
-
- // read the information from the base product
- integer src_id = ProductCreator::checkProductDependency ();
- map content = ProductCreator::ReadContentFile(src_id);
-
- KiwiConfig = ProductCreator::Config;
+{
- // busy popup
- Popup::ShowFeedback (_("Reading current live image configuration..."), _("Please wait..."));
+textdomain "product-creator";
- map default_dirmap = $[
- "iso" : sformat ("%1/kwliveDVD-suse-10.3", images_dir),
- "xen" : sformat ("%1/buildhost-suse-10.1", images_dir),
- "usb" : sformat ("%1/kwliveDVD-suse-10.3", images_dir),
- "vmx" : sformat ("%1/kwliveDVD-suse-10.3", images_dir),
- ];
+include "product-creator/kiwi_dialogs.ycp";
- // path to current config directory
- string default_dir = default_dirmap[kiwi_task]:"";
- string kiwi_configuration = KiwiConfig["kiwi_configuration_" + kiwi_task]:default_dir;
+import "CommandLine";
+import "PackageCallbacksInit";
+import "Sequencer";
- if (!FileUtils::Exists (kiwi_configuration))
- {
- y2warning ("directory %1 is not available, using %2", kiwi_configuration, default_dir);
- kiwi_configuration = default_dir;
- }
-
- if (FileUtils::Exists (kiwi_configuration + "/root"))
- {
- // read all entries from root_dir and save to list
- map out = (map) SCR::Execute (.target.bash_output,
- sformat ("ls -A1 -d %1/root/* 2>/dev/null", kiwi_configuration));
- KiwiConfig["root_dir"] = filter (string f, splitstring(out["stdout"]:"", "\n"), ``(f!=""));
- }
- if (FileUtils::Exists (kiwi_configuration + "/config"))
- {
- map out = (map) SCR::Execute (.target.bash_output,
- sformat ("ls -A1 -d %1/config/* 2>/dev/null", kiwi_configuration));
- KiwiConfig["config_dir"] = filter (string f, splitstring(out["stdout"]:"", "\n"),``(f!=""));
- }
-
- foreach (string file, [ "images.sh", "config.sh" ], {
- string file_path = kiwi_configuration + "/" + file;
- if (FileUtils::Exists (file_path))
- {
- string contents = (string) SCR::Read (.target.string, file_path);
- if (contents != nil)
- KiwiConfig[file] = contents;
- }
- });
- KiwiConfig = (map)union(KiwiConfig, Kiwi::ReadConfigXML (kiwi_configuration));
+/**
+ * configuration workflow for kiwi
+ * @return sequence result
+ */
+define boolean KiwiSequence() {
- map label2boot = $[
- "openSUSE 10.2" : "suse-10.2",
- "openSUSE 10.3" : "suse-10.3",
- "SUSE Linux 10.1" : "suse-10.1",
- "SUSE Linux Enterprise Server 10" : "suse-SLES10",
- "SUSE Linux Enterprise Desktop 10" : "suse-SLED10"
- ];
- map distproduct2boot = $[
- "openSUSE-10.2-CD-download" : "suse-10.2",
- "openSUSE-10.2-dvd5-download" : "suse-10.2",
- "openSUSE-10.3-dvd5-download" : "suse-10.3",
- "openSUSE-10.3-CD-download" : "suse-10.3",
- "SUSE-Linux-10.1-CD-download-x86" : "suse-10.1",
- "SUSE-Linux-Enterprise-Server-i386" : "suse-SLES10",
- "SUSE-Linux-Enterprise-Desktop-i386" : "suse-SLED10",
- "SUSE-Linux-Enterprise-Server-SP1" : "suse-SLES10-SP1",
- "SUSE-Linux-Enterprise-Desktop-SP1" : "suse-SLED10-SP1"
+ map aliases = $[
+ "prepare" : ``( PrepareDialog() ),
+ "kiwi" : ``( KiwiDialog () ),
+ ];
+ map sequence = $[
+ "ws_start" : "prepare",
+ "prepare" : $[
+ `abort : `abort,
+ `next : "kiwi"
+ ],
+ "kiwi" : $[
+ `abort : `abort,
+ `next : `next
+ ]
];
- string boot_image = label2boot[content["LABEL"]:""]:"";
- if (boot_image == "")
- boot_image = distproduct2boot[content["DISTPRODUCT"]:""]:"";
- // guess some default boot image value
- if (kiwi_task == "iso" && !haskey (KiwiConfig, "isoboot") && boot_image != "")
- {
- KiwiConfig["isoboot"] = boot_image;
- }
- else if (kiwi_task == "usb")
- {
- if (!haskey (KiwiConfig, "usbboot") && boot_image != "")
- KiwiConfig["usbboot"] = boot_image;
- }
- else if (kiwi_task == "vmx")
+ Wizard::CreateDialog();
+ Wizard::SetDesktopIcon("cd-creator");
+ if (!Package::Install ("kiwi"))
{
- if (!haskey (KiwiConfig, "vmxboot") && boot_image != "")
- KiwiConfig["vmxboot"] = boot_image;
+ Popup::Error(_("Installation of required packages
+failed."));
+ return false;
}
- else if (kiwi_task == "xen")
- {
- if (!haskey (KiwiConfig, "xenboot"))
- KiwiConfig["xenboot"] = boot_image;
- }
- string name = KiwiConfig["name"]:"";
- if (!haskey (KiwiConfig, "specification"))
- KiwiConfig["specification"] = KiwiConfig["name"]:"";
- Popup::ClearFeedback ();
- }
+ PackageCallbacksInit::InitPackageCallbacks();
- /********************************************************************************************
- * widget descriptions
- *******************************************************************************************/
+ symbol ret = Sequencer::Run(aliases, sequence);
+ UI::CloseDialog();
+ return ret == `next;
+}
- // return map with description of tabs
- // it is a function, to be able to adapt to actual state (e.g. boot_image_widget ())
- map tabs_descr () {
+map cmdline_description = $[
+ "id" : "kiwi",
+ // command line help text for the kiwi module
+ "help" : _("Configuration of Kiwi"),
+ "guihandler" : KiwiSequence,
+ "actions" : $[],
+];
- return $[
- "config.xml" : $[
- // tab header
- "header" : _("Image Configuration"),
- "contents" : `HBox (`HSpacing(1),
- `VBox (
- `VSpacing (0.2),
- /*
- `HBox (
- `HWeight (1, `HBox (
- boot_image_widget ()
-// `VBox (`Label (""), "configure_boot")
- )),
- `HWeight (1, `VBox (`Label (""), `Left ("compressed")))
- ),
- */
- `VSpacing (0.2),
- `HBox (
- `HWeight (1, "version"),
- `HWeight (1, `HBox ("size", "sizeunit"))
- ),
- "sw_selection",
- `HBox (
- `HWeight (1, `VBox (
- `Left (`Label (_("Installed Software"))), "rt_sw", `Right ("configure_sw")
- )),
- `HWeight (1, "ignore")
- ),
- `VSpacing (0.2)
- ), `HSpacing(1)),
- "widget_names" : [
- "version",
- "size", "sizeunit",
- "sw_selection",
- "rt_sw", "configure_sw",
- "ignore",
- ],
- ],
- "description" : $[
- // tab header
- "header" : _("Description"),
- "contents" : `HBox (`HSpacing(1),
- `VBox (
- `VSpacing (0.2),
- "author",
- `VSpacing (0.2),
- "contact",
- `VSpacing (0.2),
- "specification",
- `VStretch ()
- ), `HSpacing (1)),
- "widget_names" : [ "author", "contact", "specification" ],
- ],
- "users" : $[
- // tab header
- "header" : _("Users"),
- "contents" : `HBox (`HSpacing(1),
- `VBox (
- "general_users",
- `VSpacing (0.2),
- "group",
- `VSpacing (0.2),
- "userstable",
- `VSpacing (0.2),
- `HBox ("adduser", "edituser", "deleteuser", `HStretch ()),
- `VSpacing (0.2)
- ), `HSpacing (1)),
- "widget_names" : [
- "general_users", "group", "userstable", "adduser", "edituser", "deleteuser"
- ]
- ],
- "scripts" : $[
- // tab header
- "header" : _("Scripts"),
- "contents" : `HBox (`HSpacing(1),
- `VBox (
- "general_scripts",
- `VSpacing (0.2),
- `HBox ("config.sh", `Bottom ("import_config.sh")),
- `HBox ("images.sh", `Bottom ("import_images.sh")),
- `VSpacing (0.2)
- ), `HSpacing (1)),
- "widget_names" : [
- "general_scripts",
- "config.sh", "import_config.sh",
- "images.sh", "import_images.sh",
- ],
- ],
- "directories" : $[
- // tab header
- "header" : _("Directories"),
- "contents" : `HBox (`HSpacing(1),
- `VBox (
- "general_directories",
- `VSpacing (0.2),
- "root_dir_table",
- `VSpacing (0.2),
- `HBox ("root_dir_add", `Left ("root_dir_delete")),
- `VSpacing (0.2),
- "config_dir_table",
- `VSpacing (0.2),
- `HBox ("config_dir_add", `Left ("config_dir_delete")),
- `VSpacing (0.2),
- `VSpacing (0.2)
- ), `HSpacing (1)),
- "widget_names" : [
- "general_directories",
- "root_dir_table", "root_dir_add", "root_dir_delete",
- "config_dir_table", "config_dir_add", "config_dir_delete",
- ],
- ],
- ];
- }
+y2milestone ("----------------------------------------");
+y2milestone ("ProductCreator-kiwi module started");
- map get_widget_description () {
- return $[
- // global widgets
- "global" :$[
- "widget" : `empty,
- "validate_type" : `function,
- "validate_function" : CreateImage,
- "no_help" : true,
- ],
- // widgets for config.xml tab
- "isoboot" : $[
- "widget" : `combobox,
- "opt" : [ `hstretch, `notify ],
- // combo box label
- "label" : _("C&D Boot Image"),
- // help text for "C&D Boot Image", %1/%2 is path (on extra line)
- "help" : sformat (_("<p>Choose one <b>CD Boot Image</b> from the<br>
-<tt>%1/%2</tt><br>
-directory.</p>
-"),
- Kiwi::images_dir, boot_image_widget ()),
- "items" : [],
- "init" : InitBootCombo,
- "store" : StoreBootCombo,
- "handle" : HandleBootCombo,
- ],
- "xenboot" : $[
- "widget" : `combobox,
- "opt" : [ `hstretch, `notify ],
- // combo box label
- "label" : _("&Xen Boot Image"),
- // help text for "XEN Boot Image"
- "help" : sformat (_("<p>Choose one <b>Xen Boot Image</b> from the<br>
-<tt>%1/%2</tt><br>
-directory.</p>
-"),
- Kiwi::images_dir, boot_image_widget ()),
- "items" : [],
- "init" : InitBootCombo,
- "store" : StoreBootCombo,
- "handle" : HandleBootCombo,
- ],
- "usbboot" : $[
- "widget" : `combobox,
- "opt" : [ `hstretch, `notify ],
- // combo box label
- "label" : _("&USB Stick Boot Image"),
- // help text for "XEN Boot Image"
- "help" : sformat (_("<p>Choose one <b>USB stick Boot Image</b> from the<br>
-<tt>%1/%2</tt><br>
-directory.</p>
-"),
- Kiwi::images_dir, boot_image_widget ()),
- "items" : [],
- "init" : InitBootCombo,
- "store" : StoreBootCombo,
- "handle" : HandleBootCombo,
- ],
- "vmxboot" : $[
- "widget" : `combobox,
- "opt" : [ `hstretch, `notify ],
- // combo box label
- "label" : _("&Virtual Disk Boot Image"),
- // help text for "XEN Boot Image"
- "help" : sformat (_("<p>Choose one <b>Virtual Disk Boot Image</b> from the<br>
-<tt>%1/%2</tt><br>
-directory.</p>
-"),
- Kiwi::images_dir, boot_image_widget ()),
- "items" : [],
- "init" : InitBootCombo,
- "store" : StoreBootCombo,
- "handle" : HandleBootCombo,
- ],
- "configure_boot" : $[
- "widget" : `push_button,
- // pusbutton label
- "label" : _("C&onfigure..."),
- "help" : _("<p>Create a new boot image with <b>Configure</b>.</p>"),
- "handle" : NotImplementedHandler
- ],
- "compressed" : $[
- "widget" : `checkbox,
- // textentry label
- "label" : _("Co&mpress"),
- "help" : _("<p>Check <b>Compress</b> if the final image should be based \non the squashfs compressed file system."),
- "init" : InitCompressCheckBox,
- "store" : StoreCompressCheckBox,
- "handle" : HandleCompressCheckBox,
- ],
- "sw_selection" : kiwi_task == "xen" ? $[
- "widget" : `combobox,
- "opt" : [ `hstretch, `notify ],
- // combo box label
- "label" : _("So&ftware Selection"),
- // help text for "So&ftware selection"
- "help" : "",
- "items" : [],
- "init" : InitSWSelectionCombo,
- "store" : StoreSWSelectionCombo,
- "handle" : HandleSWSelectionCombo,
- ] : $[
- "widget" : `empty,
- "no_help" : true,
- ],
- "rt_sw" : $[
- "widget" : `richtext,
- "init" : InitSWRichText,
- "help" : "",
- "label" : "&L",
- ],
- "configure_sw" : $[
- "widget" : `push_button,
- // pusbutton label
- "label" : _("Ch&ange..."),
- "help" : _("<p>Adapt the software selection with <b>Change</b>.</p>"),
- "handle" : HandleSWSelection
- ],
- "ignore" : $[
- "widget" : `multi_line_edit,
- // label
- "label" : _("&Ignored Software"),
- "init" : InitSWIgnore,
- "store" : StoreSWIgnore,
- "handle" : HandleSWIgnore,
- // help text for "&Ignored software"
- "help" : _("<p>For <b>ignored software</b>, enter each entry (like 'smtp_daemon') on new line</p>"),
- ],
- "output_dir" : $[
- "widget" : `textentry,
- // textentry label
- "label" : _("O&utput Directory"),
- "help" : _("help for output dir"),
- "init" : InitOutputDir,
- ],
- "browse_output_dir" : $[
- "widget" : `push_button,
- "label" : Label::BrowseButton (),
- "help" : "",
- "handle" : HandleBrowseOutputDirectory
- ],
- "version" : $[
- "widget" : `textentry,
- // textentry label
- "label" : _("&Version"),
- "help" : _("<p>Enter the <b>Version</b> of your image configuration.</p>"),
- "valid_chars" : String::CDigit () + ".",
- "init" : InitVersion,
- "store" : StoreVersion,
- "handle" : HandleVersion,
- ],
- "size" : $[
- "widget" : `intfield,
- "opt" : [ `hstretch ],
- // textentry label
- "label" : _("&Size"),
- "help" : _("<p>Set the image <b>Size</b> in the specified <b>Unit</b>.</p>"),
- "init" : InitSize,
- "store" : StoreDescription,
- "handle" : HandleDescription,
- ],
- "sizeunit" : $[
- "widget" : `combobox,
- // textentry label
- "label" : _("&Unit"),
- "no_help" : true,
- "items" : [],
- "init" : InitSizeUnitCombo,
- "store" : StoreDescription,
- "handle" : HandleDescription,
- ],
- // ---------------- widgtes for directory structure
- "general_scripts" : $[
- "widget" : `empty,
- // general help for directory structure tab
- "help" : _("<p>Here, edit the configuration scripts used to build your image.</p>"),
- ],
- "general_directories" : $[
- "widget" : `empty,
- // general help for directory structure tab
- "help" : _("<p>Here, point to the configuration directories that should help to build your image.</p>"),
- ],
- "root_dir" : $[
- "widget" : `textentry,
- // textentry label
- "label" : _("Directory with System Configur&ation"),
- // help text
- "help" : _("<p>Define the path to the <b>Directory with System Configuration</b> (the <tt>root</tt> directory). The entire directory is copied into the root of the image tree using <tt>cp -a</tt>.</p>"),
- "init" : InitDescription,
- "store" : StoreDescription,
- "handle" : HandleDescription,
- ],
- "browse_root_dir" : $[
- "widget" : `push_button,
- "label" : Label::BrowseButton (),
- "help" : "",
- "handle" : HandleBrowseRootDirectory
- ],
- "root_dir_table" : $[
- "widget" : `custom,
- "custom_widget" : `VBox (
- // label (above table)
- `Left (`Label (_("Directory with System Configuration"))),
- `Table (`id("roottable"), `header (
- // table header
- _("Path to Directory"))
- )
- ),
- // help for table with users
- "help" : _("<p>Configure the <b>Directory with System Configuration</b> (the <tt>root</tt> directory). The entire directory is copied into the root of the image tree using <tt>cp -a</tt>.</p>"),
- "init" : InitRootDirTable,
- ],
- "root_dir_add" : $[
- "widget" : `push_button,
- "label" : Label::AddButton (),
- "no_help" : true,
- "handle" : HandleAddToRootDir,
- ],
- "root_dir_delete" : $[
- "widget" : `push_button,
- "label" : Label::DeleteButton (),
- "no_help" : true,
- "handle" : HandleDeleteFromRootDir,
- ],
- "config_dir_table" : $[
- "widget" : `custom,
- "custom_widget" : `VBox (
- // label (above table)
- `Left (`Label (_("Directory with Scripts"))),
- `Table (`id("configtable"), `header (
- // table header
- _("Path to File"))
- )
- ),
- // help for table with users
- "help" : _("<p>Configure the <b>Directory with Scripts</b> (the <tt>config</tt> directory). It contains scripts that are run after the installation of all the image packages.</p>"),
- "init" : InitConfigDirTable,
- ],
- "config_dir_add" : $[
- "widget" : `push_button,
- "label" : Label::AddButton (),
- "no_help" : true,
- "handle" : HandleAddToConfigDir,
- ],
- "config_dir_delete" : $[
- "widget" : `push_button,
- "label" : Label::DeleteButton (),
- "no_help" : true,
- "handle" : HandleDeleteFromConfigDir,
- ],
- "config.sh" : $[
- "widget" : `multi_line_edit,
- // textentry label
- "label" : _("I&mage Configuration Script"),
- "help" : _("<p>Edit your <b>Image Configuration Script</b>, called <tt>config.sh</tt>. This script is run at the end of the installation but before the package scripts have run.</p>"),
- "init" : InitDescription,
- "store" : StoreDescription,
- "handle" : HandleDescription,
- ],
- "import_config.sh" : $[
- "widget" : `push_button,
- // textentry label
- "label" : _("&Import..."),
- "help" : "",
- "handle" : HandleImportConfigFile
- ],
- "config_dir" : $[
- "widget" : `textentry,
- // textentry label
- "label" : _("Pa&th to Directory with Scripts"),
- "help" : _("<p>The optional <b>Directory with Scripts</b> (<tt>config</tt> directory) contains scripts that are run after the installation of all the image packages.</p>"),
- "init" : InitDescription,
- "store" : StoreDescription,
- "handle" : HandleDescription,
- ],
- "browse_config_dir" : $[
- "widget" : `push_button,
- // push button label
- "label" : _("Br&owse..."),
- "help" : "",
- "handle" : HandleBrowseConfigDirectory
- ],
- "autoyast_path" : $[
- "widget" : `textentry,
- // textentry label
- "label" : _("Path to Auto&YaST Profile"),
- "help" : _("Choose the path to the AutoYaST profile (config.xml)."),
- ],
- "browse_autoyast" : $[
- "widget" : `push_button,
- // push button label
- "label" : _("Brow&se..."),
- "help" : "",
- "handle" : HandleBrowseAutoYaSTFile
- ],
- "images.sh" : $[
- "widget" : `multi_line_edit,
- // textentry label
- "label" : _("C&leanup Script"),
- "help" : _("<p>Edit your <b>Cleanup Script</b> (<tt>images.sh</tt>). This script is run at the beginning of the image creation process.</p>"),
- "init" : InitDescription,
- "store" : StoreDescription,
- "handle" : HandleDescription,
- ],
- "import_images.sh" : $[
- "widget" : `push_button,
- // textentry label
- "label" : _("Im&port..."),
- "help" : "",
- "handle" : HandleImportImagesFile
- ],
- // ---------------- widgtes for description tab
- "author" : $[
- "widget" : `textentry,
- // textentry label
- "label" : _("&Author"),
- // help text for Author, Contact and Specification widgets
- "help" : _("<p>Set the values for <b>Author</b> of the image, <b>Contact Information</b>, and the image <b>Specification</b>.</p>"),
- "init" : InitDescription,
- "store" : StoreDescription,
- "handle" : HandleDescription,
- ],
- "contact" : $[
- "widget" : `textentry,
- // textentry label
- "label" : _("C&ontact"),
- "init" : InitDescription,
- "store" : StoreDescription,
- "handle" : HandleDescription,
- "no_help" : true,
- ],
- "specification" : $[
- "widget" : `multi_line_edit,
- // textentry label
- "label" : _("&Specification"),
- "init" : InitDescription,
- "store" : StoreDescription,
- "handle" : HandleDescription,
- "no_help" : true,
- ],
- // ---------------- widgtes for users tab
- "general_users" : $[
- "widget" : `empty,
- // general help for users tab
- "help" : _("<p>Here, create users that should be available in the target system.</p>"),
- ],
- "group" : $[
- "widget" : `textentry,
- // textentry label
- "label" : _("&Group name"),
- "help" : _("<p>Select the <b>Group Name</b> to which the users belong.</p>"),
- "init" : InitDescription,
- "store" : StoreDescription,
- "handle" : HandleDescription,
- ],
- "userstable" : $[
- "widget" : `custom,
- "custom_widget" : `Table (`id("table"), `opt (`notify), `header(
- // table header
- _("Name"),
- // table header
- _("Home Directory"))),
- // help for table with users
- "help" : _("<p>For each user, specify <b>Name</b>, <b>Password</b>, and <b>Home Directory</b>.</p>"),
- "init" : InitUsersTable,
- "handle" : HandleAddEditUser,
- ],
- "adduser" : $[
- "widget" : `push_button,
- "label" : Label::AddButton (),
- "no_help" : true,
- "handle" : HandleAddEditUser,
- ],
- "edituser" : $[
- "widget" : `push_button,
- "label" : Label::EditButton (),
- "no_help" : true,
- "handle" : HandleAddEditUser,
- ],
- "deleteuser" : $[
- "widget" : `push_button,
- "label" : Label::DeleteButton (),
- "no_help" : true,
- "handle" : HandleDeleteUser,
- ],
- // ------------------
- ];
- }
-
- /**
- * Main dialog for Kiwi image configuration
- */
- define symbol KiwiDialog () {
- InitImageConfiguration ();
+any ret = CommandLine::Run(cmdline_description);
- map widget_descr = get_widget_description ();
- widget_descr["tab"] = CWMTab::CreateWidget($[
- "tab_order" : ["config.xml", "description", "users", "scripts", "directories"],
- "tabs" : tabs_descr (),
- "widget_descr" : widget_descr,
- "initial_tab" : "config.xml",
- ]);
- Wizard::SetContentsButtons("", `VBox (), "", Label::BackButton(), Label::NextButton());
+y2milestone("ProductCreator-kiwi module finished with %1", ret);
+y2milestone("----------------------------------------");
- term contents = `VBox (
- `Left (`Label (KiwiConfig["name"]:"")),
- "tab",
- `VSpacing (0.3),
- "global"
- );
+return ret;
- map caption = $[
- // dialog caption
- "iso" : _("Live CD Configuration"),
- // dialog caption
- "xen" : _("Xen Image Configuration"),
- // dialog caption
- "usb" : _("USB Stick Image Configuration"),
- // button label
- "vmx" : _("Virtual Disk Image"),
- ];
- map next_button = $[
- // button label
- "iso" : _("&Create ISO"),
- // button label
- "xen" : _("&Create Xen Image"),
- // button label
- "usb" : _("&Create USB Stick Image"),
- // button label
- "vmx" : _("&Create Virtual Disk Image"),
- ];
- symbol ret = CWM::ShowAndRun ($[
- "widget_names" : [ "global", "tab" ],
- "widget_descr" : widget_descr,
- "contents" : contents,
- "caption" : caption[kiwi_task]:"",
- "back_button" : Label::BackButton (),
- "next_button" : next_button[kiwi_task]:Label::NextButton (),
- ]);
- y2milestone("Returning %1", ret);
- return ret;
- }
}
Added: trunk/product-creator/src/kiwi_dialogs.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/product-creator/src/kiwi_dialogs.ycp?rev=39527&view=auto
==============================================================================
--- trunk/product-creator/src/kiwi_dialogs.ycp (added)
+++ trunk/product-creator/src/kiwi_dialogs.ycp Thu Jul 19 13:52:47 2007
@@ -0,0 +1,1659 @@
+/**
+ * File: include/product-creator/kiwi.ycp
+ * Package: Configuration of product-creator
+ * Summary: Dialogs for kiwi configuration
+ * Authors: Jiri Suchomel
+ *
+ * $Id$
+ */
+{
+ textdomain "product-creator";
+
+ import "CWM";
+ import "CWMTab";
+ import "ProductCreator";
+ import "FileUtils";
+ import "Label";
+ import "Kiwi";
+ import "Popup";
+ import "SourceDialogs";
+ import "Summary";
+ import "URL";
+ import "Wizard";
+
+ include "product-creator/dialogs.ycp";
+
+ // map of current Live ISO configuration
+ map KiwiConfig = $[];
+
+ // what are we configuring now ("iso"/"xen"/...)
+ string kiwi_task = "";
+
+ // directory with kiwi images
+ string images_dir = "";
+
+ // return the id of actual widget for boot image
+ string boot_image_widget () {
+ return kiwi_task + "boot";
+ }
+
+ // read available the images under /usr/share/kiwi/image/ directory
+ list<term> GetAvailableImages (string subdir) {
+
+ list<term> ret = [];
+ map out = (map) SCR::Execute (.target.bash_output, sformat ("ls %1/%2", images_dir, subdir));
+ if (out["exit"]:0 != 0)
+ return ret;
+ foreach (string file, splitstring (out["stdout"]:"", "\n"), {
+ if (file != "" && FileUtils::IsDirectory (sformat ("%1/%2/%3", images_dir, subdir, file)))
+ {
+ ret = add (ret, `item (`id(file), file, file == KiwiConfig[subdir]:""));
+ }
+ });
+ return ret;
+ }
+
+ /********************************************************************************************
+ * widget handlers
+ *******************************************************************************************/
+
+ /**
+ * Initialize the widget with ignored packages
+ */
+ define void InitSWIgnore (string id) {
+ string sw_selection = KiwiConfig["sw_selection"]:"image";
+ string ignore_key = sw_selection == "image" ? "ignore" : (sw_selection + "_ignore");
+ UI::ChangeWidget (`id (id), `Value, mergestring (KiwiConfig[ignore_key]:[], "\n"));
+ }
+
+ define void StoreSWIgnore (string key, map event) {
+ string sw_selection = KiwiConfig["sw_selection"]:"image";
+ string ignore_key = sw_selection == "image" ? "ignore" : (sw_selection + "_ignore");
+ KiwiConfig[ignore_key] = filter (string p,
+ splitstring ((string) UI::QueryWidget(`id(key), `Value), "\n"), ``(p != ""));
+ }
+
+ define symbol HandleSWIgnore (string key, map event) {
+ if (event["ID"]:nil == `next) StoreSWIgnore (key, event);
+ return nil;
+ }
+
+
+ /**
+ * Initialize the contents of richtext with selected software
+ */
+ define void InitSWRichText (string id) {
+
+ string sw_selection = KiwiConfig["sw_selection"]:"image";
+ string pattern_key = sw_selection == "image" ? "addons" : (sw_selection + "_patterns");
+ string rt = "";
+ if (KiwiConfig[pattern_key]:[] != [])
+ {
+ // richtext header
+ rt = Summary::AddHeader ("", _("Patterns"));
+ foreach (string pattern, (list<string>) KiwiConfig[pattern_key]:[], {
+ rt = Summary::AddListItem (rt, pattern);
+ });
+ }
+ string package_key = sw_selection == "image" ? "packages" : (sw_selection + "_packages");
+ if (KiwiConfig[package_key]:[] != [])
+ {
+ // richtext header
+ rt = Summary::AddHeader (rt, _("Packages"));
+ foreach (string package, (list<string>) KiwiConfig[package_key]:[], {
+ rt = Summary::AddListItem (rt, package);
+ });
+ }
+ UI::ChangeWidget (`id (id), `Value, rt);
+ }
+
+ /**
+ * Handler for software selection
+ */
+ define symbol HandleSWSelection (string key, map event) {
+ if (event["ID"]:nil == key)
+ {
+ string sw_selection = KiwiConfig["sw_selection"]:"image";
+ if (sw_selection == "image" && packageSelector () != `cancel)
+ {
+ KiwiConfig["addons"] = ProductCreator::Config["addons"]:[];
+ KiwiConfig["packages"] = ProductCreator::Config["packages"]:[];
+ InitSWRichText ("rt_sw");
+ if (ProductCreator::Config["taboo"]:[] != nil)
+ {
+ //FIXME do not replace current 'ignored' tags...
+ KiwiConfig["ignore"] = union (KiwiConfig["ignore"]:[],
+ ProductCreator::Config["taboo"]:[]);
+ InitSWIgnore ("ignore");
+ }
+ }
+ else if (sw_selection != "image")
+ {
+ map selected = runPackageSelector ("",
+ KiwiConfig[sw_selection + "_patterns"]:[],
+ KiwiConfig[sw_selection + "_packages"]:[],
+ KiwiConfig[sw_selection + "_ignore"]:[],
+ `packages
+ );
+ KiwiConfig[sw_selection + "_patterns"] = selected["addons"]:[];
+ KiwiConfig[sw_selection + "_packages"] = selected["packages"]:[];
+ InitSWRichText ("rt_sw");
+ if (ProductCreator::Config["taboo"]:[] != nil)
+ {
+ KiwiConfig["ignore"] = ProductCreator::Config["taboo"]:[];
+ InitSWIgnore ("ignore");
+ }
+ }
+ }
+ return nil;
+ }
+
+ /**
+ * initialize the combo box with package selection groups
+ */
+ define void InitSWSelectionCombo (string id) {
+ string sw_selection = KiwiConfig["sw_selection"]:"image";
+ list items = [
+ `item (`id ("image"), _("Image"), sw_selection == "image"),
+ ];
+ if (kiwi_task == "xen")
+ items = add (items, `item (`id ("xen"), _("Xen Specific"), sw_selection == "xen"));
+ UI::ChangeWidget (`id (id), `Items, items);
+ }
+
+ define void StoreSWSelectionCombo (string key, map event) {
+ KiwiConfig[key] = (string) UI::QueryWidget(`id(key), `Value);
+ }
+
+ /**
+ * handler for combo box with isoboot items
+ */
+ define symbol HandleSWSelectionCombo (string key, map event) {
+ any id = event["ID"]:nil;
+ // store the value on exiting
+ if (id == `next) StoreSWSelectionCombo (key, event);
+ else if (event["ID"]:nil == key)
+ {
+ string selected = (string) UI::QueryWidget(`id(key), `Value);
+ if (selected != KiwiConfig["sw_selection"]:"image")
+ {
+ StoreSWIgnore ("ignore", event);
+ StoreSWSelectionCombo (key, event);
+ InitSWRichText ("rt_sw");
+ InitSWIgnore ("ignore");
+ }
+ }
+ return nil;
+ }
+
+
+ /**
+ * initialize the value of combo box with isoboot items
+ */
+ define void InitBootCombo (string id) {
+ UI::ChangeWidget (`id (id), `Items, GetAvailableImages (id));
+ }
+
+ /**
+ * store the value of current isoboot image
+ */
+ define void StoreBootCombo (string key, map event) {
+ KiwiConfig[key] = (string) UI::QueryWidget(`id(key), `Value);
+ }
+ /**
+ * handler for combo box with isoboot items
+ */
+ define symbol HandleBootCombo (string key, map event) {
+ // store the value on exiting
+ if (event["ID"]:nil == `next) StoreBootCombo (key, event);
+ return nil;
+ }
+
+ /**
+ * initialize the value of compress checkbox
+ */
+ define void InitCompressCheckBox (string id) {
+ UI::ChangeWidget (`id (id), `Enabled, false);// FIXME squashfs not available?
+ UI::ChangeWidget (`id (id), `Value, KiwiConfig["compressed"]:false);
+ }
+
+ /**
+ * store the value of compress checkbox
+ */
+ define void StoreCompressCheckBox (string key, map event) {
+ KiwiConfig["compressed"] = (boolean) UI::QueryWidget(`id(key), `Value);
+ }
+ /**
+ * handler for compress checkbox
+ */
+ define symbol HandleCompressCheckBox (string key, map event) {
+ // store the value on exiting
+ if (event["ID"]:nil == `next) StoreCompressCheckBox (key, event);
+ return nil;
+ }
+
+ /**
+ * initialize the value of version
+ */
+ define void InitVersion (string id) {
+ UI::ChangeWidget (`id (id), `Value, sformat ("%1", KiwiConfig[id]:"1"));
+ }
+
+ /**
+ * store the value of current version
+ */
+ define void StoreVersion (string key, map event) {
+ KiwiConfig[key] = sformat ("%1", UI::QueryWidget(`id(key), `Value));
+ }
+
+ /**
+ * handler for version
+ */
+ define symbol HandleVersion (string key, map event) {
+ // store the value on exiting
+ if (event["ID"]:nil == `next) StoreVersion (key, event);
+ return nil;
+ }
+
+ /**
+ * initialize the value of combo box with isoboot items
+ */
+ define void InitSizeUnitCombo (string id) {
+ UI::ChangeWidget (`id (id), `Items, maplist (string u, [ "M", "G" ], ``(
+ `item (`id (u), u + "B", KiwiConfig[id]:"M" == u))
+ ));
+ }
+
+ /**
+ * initialize the value of version
+ */
+ define void InitSize (string id) {
+ UI::ChangeWidget (`id (id), `Value, KiwiConfig[id]:2700);
+ }
+
+ /**
+ * initialize the product label
+ */
+ define void InitLabel (string id) {
+ UI::ChangeWidget (`id ("name"), `Value, KiwiConfig["name"]:"");
+ }
+
+
+ /**
+ * universal widget: initialize the string value of widget @param
+ */
+ define void InitDescription (string id) {
+ UI::ChangeWidget (`id (id), `Value, KiwiConfig[id]:"");
+ }
+
+ /**
+ * store the string value of given widget
+ */
+ define void StoreDescription (string key, map event) {
+ KiwiConfig[key] = UI::QueryWidget (`id(key), `Value);
+ }
+
+ /**
+ * handler for general string-value widgets: store their value on exit/save
+ */
+ define symbol HandleDescription (string key, map event) {
+ // store the value on exiting
+ if (event["ID"]:nil == `next) StoreDescription (key, event);
+ return nil;
+ }
+
+ define void InitOutputDir (string id) {
+ UI::ChangeWidget (`id (id), `Value, KiwiConfig["iso-directory"]:"");
+ }
+
+ /**
+ * initialize the table with users
+ */
+ define void InitUsersTable (string id) {
+
+ list items = maplist (string user, map usermap, (map) KiwiConfig["users"]:$[],
+ ``(`item (`id (user), user, usermap["home"]:"")));
+ UI::ChangeWidget (`id ("table"), `Items, items);
+ UI::ChangeWidget (`id ("edituser"), `Enabled, size (items) > 0);
+ UI::ChangeWidget (`id ("deleteuser"), `Enabled, size (items) > 0);
+ }
+
+ /**
+ * Handle changes in users table
+ */
+ define symbol HandleAddEditUser (string key, map event) {
+ if (event["ID"]:nil != key && (key != "userstable" || event["ID"]:nil != "table")) return nil;
+
+ if (key == "userstable") key = "edituser";
+ string current_user = (string) UI::QueryWidget (`id ("table"), `CurrentItem);
+
+ UI::OpenDialog (`opt(`decorated), `HBox (`HSpacing (0.5), `VBox (
+ `VSpacing (0.5),
+ // popup label
+ `Label (`id (`label), _("Add new user")),
+ // text entry label
+ `TextEntry (`id (`username), _("&Name")),
+ `Password (`id (`pw1), Label::Password(), ""),
+ `Password (`id(`pw2), Label::ConfirmPassword(), ""),
+ `TextEntry (`id (`home), _("&Home Directory")),
+ `HBox (
+ `PushButton (`id(`ok),`opt(`key_F10), Label::OKButton()),
+ `PushButton (`id(`cancel),`opt(`key_F9), Label::CancelButton())
+ ),
+ `VSpacing (0.5)), `HSpacing (0.5))
+ );
+ if (key == "edituser")
+ {
+ UI::ChangeWidget (`id (`username), `Value, current_user);
+ UI::ChangeWidget (`id (`home), `Value, KiwiConfig["users", current_user, "home"]:"");
+ UI::ChangeWidget (`id (`pw1), `Value, "*****");
+ UI::ChangeWidget (`id (`pw2), `Value, "*****");
+ // popup label
+ UI::ChangeWidget (`id (`label), `Value, _("Edit User"));
+ }
+ any ret = nil;
+ repeat
+ {
+ ret = UI::UserInput ();
+ if (ret == `ok)
+ {
+ string username = (string) UI::QueryWidget (`id(`username), `Value);
+ string pwd = (string) UI::QueryWidget (`id(`pw1), `Value);
+ if (username == "")
+ {
+ // popup message
+ Report::Error (_("Enter the user name."));
+ ret = `notnext;
+ continue;
+ }
+ if (pwd != UI::QueryWidget (`id(`pw2), `Value))
+ {
+ // popup message
+ Report::Error (_("The passwords do not match.
+Try again."));
+ ret = `notnext;
+ continue;
+ }
+ if (pwd == "")
+ {
+ // popup message
+ Report::Error (_("Enter the user password."));
+ ret = `notnext;
+ continue;
+ }
+ if (! haskey (KiwiConfig, "users"))
+ KiwiConfig["users"] = $[];
+ else if (key == "edituser" && username != current_user)
+ KiwiConfig["users"] = remove (KiwiConfig["users"]:$[], current_user);
+ KiwiConfig["users", username] = $[
+ "pwd" : pwd,
+ "home" : UI::QueryWidget (`id(`home), `Value)
+ ];
+ }
+ } until (ret == `ok || ret == `cancel);
+
+ UI::CloseDialog ();
+ if (ret == `ok) InitUsersTable ("table");
+ return nil;
+ }
+
+ /**
+ * handle delete user button
+ */
+ define symbol HandleDeleteUser (string key, map event) {
+ if (event["ID"]:nil != key) return nil;
+
+ string current_user = (string) UI::QueryWidget (`id ("table"), `CurrentItem);
+ KiwiConfig["users"] = remove (KiwiConfig["users"]:$[], current_user);
+ InitUsersTable ("table");
+ return nil;
+ }
+
+ /**
+ * initialize the table with root dir contents
+ */
+ define void InitRootDirTable (string id) {
+
+ list items = maplist (string file, (list<string>) KiwiConfig["root_dir"]:[], {
+// return `item (`id (file), substring (file, findlastof (file, "/") + 1));
+ return `item (`id (file), file);
+ });
+ UI::ChangeWidget (`id ("roottable"), `Items, items);
+ UI::ChangeWidget (`id ("root_dir_delete"), `Enabled, size (items) > 0);
+ }
+
+ // add new subdir to the 'root' directory
+ define symbol HandleAddToRootDir (string key, map event) {
+
+ if (event["ID"]:nil != key) return nil;
+ // popup for file selection dialog
+ string dir = UI::AskForExistingDirectory ("", _("Directory to Import"));
+ if (dir!= nil)
+ {
+ KiwiConfig["root_dir"] = union (KiwiConfig["root_dir"]:[], [dir]);
+ InitRootDirTable ("roottable");
+ }
+ return nil;
+ }
+
+ // delete subdir from the 'root' directory
+ define symbol HandleDeleteFromRootDir (string key, map event) {
+ if (event["ID"]:nil != key) return nil;
+ string current = (string) UI::QueryWidget (`id ("roottable"), `Value);
+ KiwiConfig["root_dir"] = filter (string f, KiwiConfig["root_dir"]:[], ``(f != current));
+ InitRootDirTable ("roottable");
+ return nil;
+ }
+
+ /**
+ * initialize the table with config dir contents
+ */
+ define void InitConfigDirTable (string id) {
+
+ list items = maplist (string file, (list<string>) KiwiConfig["config_dir"]:[], {
+// return `item (`id (file), substring (file, findlastof (file, "/") + 1));
+ return `item (`id (file), file);
+ });
+ UI::ChangeWidget (`id ("configtable"), `Items, items);
+ UI::ChangeWidget (`id ("config_dir_delete"), `Enabled, size (items) > 0);
+ }
+
+ // add new subdir to the 'config' directory
+ define symbol HandleAddToConfigDir (string key, map event) {
+
+ if (event["ID"]:nil != key) return nil;
+ // popup for file selection dialog
+ string dir = UI::AskForExistingFile ("", "", _("Script to Import"));
+ if (dir!= nil)
+ {
+ KiwiConfig["config_dir"] = union (KiwiConfig["config_dir"]:[], [dir]);
+ InitConfigDirTable ("configtable");
+ }
+ return nil;
+ }
+
+ // delete subdir from the 'config' directory
+ define symbol HandleDeleteFromConfigDir (string key, map event) {
+ if (event["ID"]:nil != key) return nil;
+ string current = (string) UI::QueryWidget (`id ("configtable"), `Value);
+ KiwiConfig["config_dir"] = filter (string f, KiwiConfig["config_dir"]:[], ``(f != current));
+ InitConfigDirTable ("configtable");
+ return nil;
+ }
+
+ /**
+ * universal handler for directory browsing
+ */
+ string BrowseDirectoryHandler (string key, string label) {
+
+ string current = (string) UI::QueryWidget (`id (key), `Value);
+ if (current == nil) current = "";
+ string dir = UI::AskForExistingDirectory (current, label);
+ if (dir!= nil)
+ {
+ UI::ChangeWidget (`id (key), `Value, dir);
+ StoreDescription (key, $[]);
+ }
+ return dir;
+ }
+
+ /**
+ * handler for 'root' directory browse
+ */
+ symbol HandleBrowseRootDirectory (string key, map event) {
+ if (event["ID"]:nil != key) return nil;
+ // popup for file selection dialog ('root' is a name, do not translate)
+ BrowseDirectoryHandler ("root_dir", _("Path to root Directory"));
+ return nil;
+ }
+
+ /**
+ * handler for 'config' directory browse
+ */
+ symbol HandleBrowseConfigDirectory (string key, map event) {
+ if (event["ID"]:nil != key) return nil;
+ // popup for file selection dialog ('config' is a name, do not translate)
+ BrowseDirectoryHandler ("config_dir", _("Path to config Directory"));
+ return nil;
+ }
+
+ /**
+ * handler for output directory browse
+ */
+ symbol HandleBrowseOutputDirectory (string key, map event) {
+ if (event["ID"]:nil != key) return nil;
+ // popup for file selection dialog
+ BrowseDirectoryHandler ("output_dir", _("Path to the Output Directory"));
+ return nil;
+ }
+
+ /**
+ * universal handler for file browsing
+ */
+ string BrowseFileHandler (string key, string label) {
+
+ string current = (string) UI::QueryWidget (`id (key), `Value);
+ if (current == nil) current = "";
+ string file = UI::AskForExistingFile (current, "", label);
+ if (file != nil && key != "config.sh")
+ {
+ UI::ChangeWidget (`id (key), `Value, file);
+ StoreDescription (key, $[]);
+ }
+ return file;
+ }
+
+ /**
+ * Handler for browsing for images.sh file
+ */
+ symbol HandleBrowseImagesFile (string key, map event) {
+ if (event["ID"]:nil != key) return nil;
+ // popup for file selection dialog
+ BrowseFileHandler ("images_path", _("Path to images.sh File"));
+ return nil;
+ }
+
+ /**
+ * Handler for browsing for autoyast profile
+ */
+ symbol HandleBrowseAutoYaSTFile (string key, map event) {
+ if (event["ID"]:nil != key) return nil;
+ // popup for file selection dialog
+ BrowseFileHandler ("autoyast_path", _("Path to AutoYaST Profile"));
+ return nil;
+ }
+
+ /**
+ * Handler for importing config.sh file
+ */
+ symbol HandleImportConfigFile (string key, map event) {
+ if (event["ID"]:nil != key) return nil;
+ // popup for file selection dialog
+ string file = BrowseFileHandler ("config.sh", _("Path to config.sh File"));
+ if (file != nil)
+ {
+ if (FileUtils::Exists (file))
+ {
+ string configsh = (string) SCR::Read (.target.string, file);
+ if (configsh != nil)
+ {
+ UI::ChangeWidget (`id ("config.sh"), `Value, configsh);
+ StoreDescription ("config.sh", event);
+ }
+ }
+ }
+ return nil;
+ }
+
+ /**
+ * Handler for importing images.sh file
+ * TODO same function as HandleImportConfigFile
+ */
+ symbol HandleImportImagesFile (string key, map event) {
+ if (event["ID"]:nil != key) return nil;
+ // popup for file selection dialog
+ string file = BrowseFileHandler ("images.sh", _("Path to images.sh File"));
+ if (file != nil)
+ {
+ if (FileUtils::Exists (file))
+ {
+ string imagessh = (string) SCR::Read (.target.string, file);
+ if (imagessh != nil)
+ {
+ UI::ChangeWidget (`id ("images.sh"), `Value, imagessh);
+ StoreDescription ("images.sh", event);
+ }
+ }
+ }
+ return nil;
+ }
+
+ // generic popup
+ define symbol NotImplementedHandler (string key, map event) {
+ if (event["ID"]:nil == key)
+ {
+ Popup::Message (_("Feature not implemented yet."));
+ }
+ return nil;
+ }
+
+ /**
+ * handler for main action: create the iso image with kiwi
+ */
+ define boolean CreateImage (string key, map event) {
+ if (event["ID"]:nil != `next)
+ return true;
+ boolean ret = false;
+
+ map question = $[
+ // popup question
+ "iso" : _("Create ISO image now?"),
+ // popup question
+ "xen" : _("Create Xen image now?"),
+ // popup question
+ "usb" : _("Create USB stick image now?"),
+ // popup question
+ "vmx" : _("Create virtual disk image now?"),
+ ];
+
+ map success = $[
+ // popup message, %1 is a dir
+ "iso" : _("ISO image successfully created in
+%1
+directory."),
+ // popup message, %1 is a dir
+ "xen" : _("Xen image files successfully created in
+%1
+directory.
+"),
+ // popup message, %1 is a dir
+ "usb" : _("USB stick image successfully created in
+%1
+directory."),
+ // popup message, %1 is a dir
+ "vmx" : _("Virtual disk image successfully created in
+%1
+directory."),
+ ];
+
+ if (Popup::YesNo (question[kiwi_task]:""))
+ {
+ if (Kiwi::WriteConfigXML (KiwiConfig, kiwi_task))
+ {
+ /*
+ string out_dir = KiwiConfig["iso-directory"]:"";
+ if (FileUtils::CheckAndCreatePath (out_dir) && Kiwi::PrepareAndCreate (out_dir))
+ {
+ if (kiwi_task == "usb" && false)
+ {
+ // additional question (yes/no)
+ if (Popup::YesNo (sformat (success[kiwi_task]:"", out_dir) + _("
+Save the image to the stick now?")))
+ {
+ NotImplementedHandler ("", $[ "ID" : ""]);
+ }
+ }
+ else
+ {
+ Popup::Message (sformat (success[kiwi_task]:"", out_dir));
+ }
+ ret = true;
+ }
+ */
+ }
+ }
+ if (ret)
+ {
+ string dir = Kiwi::SaveConfiguration (KiwiConfig, kiwi_task);
+ if (dir != nil && dir != "")
+ {
+ ProductCreator::Config["kiwi_configuration_" + kiwi_task] = dir;
+ }
+ }
+ return ret;
+ }
+
+ /**
+ * Global init function for Kiwi image dialog
+ * - read saved settings and fill in defaults
+ */
+ define void InitImageConfiguration () {
+
+ kiwi_task = ProductCreator::kiwi_task;
+ images_dir = Kiwi::images_dir;
+
+ // read the information from the base product
+ integer src_id = ProductCreator::checkProductDependency ();
+ map content = ProductCreator::ReadContentFile(src_id);
+
+ KiwiConfig = ProductCreator::Config;
+ // busy popup
+ Popup::ShowFeedback (_("Reading current live image configuration..."), _("Please wait..."));
+
+ map default_dirmap = $[
+ "iso" : sformat ("%1/kwliveDVD-suse-10.3", images_dir),
+ "xen" : sformat ("%1/buildhost-suse-10.1", images_dir),
+ "usb" : sformat ("%1/kwliveDVD-suse-10.3", images_dir),
+ "vmx" : sformat ("%1/kwliveDVD-suse-10.3", images_dir),
+ ];
+
+ // path to current config directory
+ string default_dir = default_dirmap[kiwi_task]:"";
+ string kiwi_configuration = KiwiConfig["kiwi_configuration_" + kiwi_task]:default_dir;
+
+ if (!FileUtils::Exists (kiwi_configuration))
+ {
+ y2warning ("directory %1 is not available, using %2", kiwi_configuration, default_dir);
+ kiwi_configuration = default_dir;
+ }
+
+ if (FileUtils::Exists (kiwi_configuration + "/root"))
+ {
+ // read all entries from root_dir and save to list
+ map out = (map) SCR::Execute (.target.bash_output,
+ sformat ("ls -A1 -d %1/root/* 2>/dev/null", kiwi_configuration));
+ KiwiConfig["root_dir"] = filter (string f, splitstring(out["stdout"]:"", "\n"), ``(f!=""));
+ }
+ if (FileUtils::Exists (kiwi_configuration + "/config"))
+ {
+ map out = (map) SCR::Execute (.target.bash_output,
+ sformat ("ls -A1 -d %1/config/* 2>/dev/null", kiwi_configuration));
+ KiwiConfig["config_dir"] = filter (string f, splitstring(out["stdout"]:"", "\n"),``(f!=""));
+ }
+
+ foreach (string file, [ "images.sh", "config.sh" ], {
+ string file_path = kiwi_configuration + "/" + file;
+ if (FileUtils::Exists (file_path))
+ {
+ string contents = (string) SCR::Read (.target.string, file_path);
+ if (contents != nil)
+ KiwiConfig[file] = contents;
+ }
+ });
+ KiwiConfig = (map)union(KiwiConfig, Kiwi::ReadConfigXML (kiwi_configuration));
+
+ if (!KiwiConfig["_imported"]:false)
+ {
+ // for new configuration, do not read all from the template
+y2warning ("------------------------------ new configuration ---------------");
+ foreach (string key, ["addons", "packages", "sources"], {
+ KiwiConfig[key] = ProductCreator::Config[key]:[];
+ });
+ }
+
+ map label2boot = $[
+ "openSUSE 10.2" : "suse-10.2",
+ "openSUSE 10.3" : "suse-10.3",
+ "SUSE Linux 10.1" : "suse-10.1",
+ "SUSE Linux Enterprise Server 10" : "suse-SLES10",
+ "SUSE Linux Enterprise Desktop 10" : "suse-SLED10"
+ ];
+ map distproduct2boot = $[
+ "openSUSE-10.2-CD-download" : "suse-10.2",
+ "openSUSE-10.2-dvd5-download" : "suse-10.2",
+ "openSUSE-10.3-dvd5-download" : "suse-10.3",
+ "openSUSE-10.3-CD-download" : "suse-10.3",
+ "SUSE-Linux-10.1-CD-download-x86" : "suse-10.1",
+ "SUSE-Linux-Enterprise-Server-i386" : "suse-SLES10",
+ "SUSE-Linux-Enterprise-Desktop-i386" : "suse-SLED10",
+ "SUSE-Linux-Enterprise-Server-SP1" : "suse-SLES10-SP1",
+ "SUSE-Linux-Enterprise-Desktop-SP1" : "suse-SLED10-SP1"
+ ];
+ string boot_image = label2boot[content["LABEL"]:""]:"";
+ if (boot_image == "")
+ boot_image = distproduct2boot[content["DISTPRODUCT"]:""]:"";
+
+ // guess some default boot image value
+ if (kiwi_task == "iso" && !haskey (KiwiConfig, "isoboot") && boot_image != "")
+ {
+ KiwiConfig["isoboot"] = boot_image;
+ }
+ else if (kiwi_task == "usb")
+ {
+ if (!haskey (KiwiConfig, "usbboot") && boot_image != "")
+ KiwiConfig["usbboot"] = boot_image;
+ }
+ else if (kiwi_task == "vmx")
+ {
+ if (!haskey (KiwiConfig, "vmxboot") && boot_image != "")
+ KiwiConfig["vmxboot"] = boot_image;
+ }
+ else if (kiwi_task == "xen")
+ {
+ if (!haskey (KiwiConfig, "xenboot"))
+ KiwiConfig["xenboot"] = boot_image;
+ }
+ string name = KiwiConfig["name"]:"";
+ if (!haskey (KiwiConfig, "specification"))
+ KiwiConfig["specification"] = KiwiConfig["name"]:"";
+ Popup::ClearFeedback ();
+ }
+
+
+ /********************************************************************************************
+ * widget descriptions
+ *******************************************************************************************/
+
+ // return map with description of tabs
+ // it is a function, to be able to adapt to actual state (e.g. boot_image_widget ())
+ map tabs_descr () {
+
+ return $[
+ "config.xml" : $[
+ // tab header
+ "header" : _("Image Configuration"),
+ "contents" : `HBox (`HSpacing(1),
+ `VBox (
+ `VSpacing (0.2),
+ /*
+ `HBox (
+ `HWeight (1, `HBox (
+ boot_image_widget ()
+// `VBox (`Label (""), "configure_boot")
+ )),
+ `HWeight (1, `VBox (`Label (""), `Left ("compressed")))
+ ),
+ */
+ `VSpacing (0.2),
+ `HBox (
+ `HWeight (1, "version"),
+ `HWeight (1, `HBox ("size", "sizeunit"))
+ ),
+ "sw_selection",
+ `HBox (
+ `HWeight (1, `VBox (
+ `Left (`Label (_("Installed Software"))), "rt_sw", `Right ("configure_sw")
+ )),
+ `HWeight (1, "ignore")
+ ),
+ `VSpacing (0.2)
+ ), `HSpacing(1)),
+ "widget_names" : [
+ "version",
+ "size", "sizeunit",
+ "sw_selection",
+ "rt_sw", "configure_sw",
+ "ignore",
+ ],
+ ],
+ "description" : $[
+ // tab header
+ "header" : _("Description"),
+ "contents" : `HBox (`HSpacing(1),
+ `VBox (
+ `VSpacing (0.2),
+ "author",
+ `VSpacing (0.2),
+ "contact",
+ `VSpacing (0.2),
+ "specification",
+ `VStretch ()
+ ), `HSpacing (1)),
+ "widget_names" : [ "author", "contact", "specification" ],
+ ],
+ "users" : $[
+ // tab header
+ "header" : _("Users"),
+ "contents" : `HBox (`HSpacing(1),
+ `VBox (
+ "general_users",
+ `VSpacing (0.2),
+ "group",
+ `VSpacing (0.2),
+ "userstable",
+ `VSpacing (0.2),
+ `HBox ("adduser", "edituser", "deleteuser", `HStretch ()),
+ `VSpacing (0.2)
+ ), `HSpacing (1)),
+ "widget_names" : [
+ "general_users", "group", "userstable", "adduser", "edituser", "deleteuser"
+ ]
+ ],
+ "scripts" : $[
+ // tab header
+ "header" : _("Scripts"),
+ "contents" : `HBox (`HSpacing(1),
+ `VBox (
+ "general_scripts",
+ `VSpacing (0.2),
+ `HBox ("config.sh", `Bottom ("import_config.sh")),
+ `HBox ("images.sh", `Bottom ("import_images.sh")),
+ `VSpacing (0.2)
+ ), `HSpacing (1)),
+ "widget_names" : [
+ "general_scripts",
+ "config.sh", "import_config.sh",
+ "images.sh", "import_images.sh",
+ ],
+ ],
+ "directories" : $[
+ // tab header
+ "header" : _("Directories"),
+ "contents" : `HBox (`HSpacing(1),
+ `VBox (
+ "general_directories",
+ `VSpacing (0.2),
+ "root_dir_table",
+ `VSpacing (0.2),
+ `HBox ("root_dir_add", `Left ("root_dir_delete")),
+ `VSpacing (0.2),
+ "config_dir_table",
+ `VSpacing (0.2),
+ `HBox ("config_dir_add", `Left ("config_dir_delete")),
+ `VSpacing (0.2),
+ `VSpacing (0.2)
+ ), `HSpacing (1)),
+ "widget_names" : [
+ "general_directories",
+ "root_dir_table", "root_dir_add", "root_dir_delete",
+ "config_dir_table", "config_dir_add", "config_dir_delete",
+ ],
+ ],
+ ];
+ }
+
+ map get_widget_description () {
+ return $[
+ // global widgets
+ "global" :$[
+ "widget" : `empty,
+ "validate_type" : `function,
+ "validate_function" : CreateImage,
+ "no_help" : true,
+ ],
+ // widgets for config.xml tab
+ "isoboot" : $[
+ "widget" : `combobox,
+ "opt" : [ `hstretch, `notify ],
+ // combo box label
+ "label" : _("C&D Boot Image"),
+ // help text for "C&D Boot Image", %1/%2 is path (on extra line)
+ "help" : sformat (_("<p>Choose one <b>CD Boot Image</b> from the<br>
+<tt>%1/%2</tt><br>
+directory.</p>
+"),
+ Kiwi::images_dir, boot_image_widget ()),
+ "items" : [],
+ "init" : InitBootCombo,
+ "store" : StoreBootCombo,
+ "handle" : HandleBootCombo,
+ ],
+ "xenboot" : $[
+ "widget" : `combobox,
+ "opt" : [ `hstretch, `notify ],
+ // combo box label
+ "label" : _("&Xen Boot Image"),
+ // help text for "XEN Boot Image"
+ "help" : sformat (_("<p>Choose one <b>Xen Boot Image</b> from the<br>
+<tt>%1/%2</tt><br>
+directory.</p>
+"),
+ Kiwi::images_dir, boot_image_widget ()),
+ "items" : [],
+ "init" : InitBootCombo,
+ "store" : StoreBootCombo,
+ "handle" : HandleBootCombo,
+ ],
+ "usbboot" : $[
+ "widget" : `combobox,
+ "opt" : [ `hstretch, `notify ],
+ // combo box label
+ "label" : _("&USB Stick Boot Image"),
+ // help text for "XEN Boot Image"
+ "help" : sformat (_("<p>Choose one <b>USB stick Boot Image</b> from the<br>
+<tt>%1/%2</tt><br>
+directory.</p>
+"),
+ Kiwi::images_dir, boot_image_widget ()),
+ "items" : [],
+ "init" : InitBootCombo,
+ "store" : StoreBootCombo,
+ "handle" : HandleBootCombo,
+ ],
+ "vmxboot" : $[
+ "widget" : `combobox,
+ "opt" : [ `hstretch, `notify ],
+ // combo box label
+ "label" : _("&Virtual Disk Boot Image"),
+ // help text for "XEN Boot Image"
+ "help" : sformat (_("<p>Choose one <b>Virtual Disk Boot Image</b> from the<br>
+<tt>%1/%2</tt><br>
+directory.</p>
+"),
+ Kiwi::images_dir, boot_image_widget ()),
+ "items" : [],
+ "init" : InitBootCombo,
+ "store" : StoreBootCombo,
+ "handle" : HandleBootCombo,
+ ],
+ "configure_boot" : $[
+ "widget" : `push_button,
+ // pusbutton label
+ "label" : _("C&onfigure..."),
+ "help" : _("<p>Create a new boot image with <b>Configure</b>.</p>"),
+ "handle" : NotImplementedHandler
+ ],
+ "compressed" : $[
+ "widget" : `checkbox,
+ // textentry label
+ "label" : _("Co&mpress"),
+ "help" : _("<p>Check <b>Compress</b> if the final image should be based \non the squashfs compressed file system."),
+ "init" : InitCompressCheckBox,
+ "store" : StoreCompressCheckBox,
+ "handle" : HandleCompressCheckBox,
+ ],
+ "sw_selection" : kiwi_task == "xen" ? $[
+ "widget" : `combobox,
+ "opt" : [ `hstretch, `notify ],
+ // combo box label
+ "label" : _("So&ftware Selection"),
+ // help text for "So&ftware selection"
+ "help" : "",
+ "items" : [],
+ "init" : InitSWSelectionCombo,
+ "store" : StoreSWSelectionCombo,
+ "handle" : HandleSWSelectionCombo,
+ ] : $[
+ "widget" : `empty,
+ "no_help" : true,
+ ],
+ "rt_sw" : $[
+ "widget" : `richtext,
+ "init" : InitSWRichText,
+ "help" : "",
+ "label" : "&L",
+ ],
+ "configure_sw" : $[
+ "widget" : `push_button,
+ // pusbutton label
+ "label" : _("Ch&ange..."),
+ "help" : _("<p>Adapt the software selection with <b>Change</b>.</p>"),
+ "handle" : HandleSWSelection
+ ],
+ "ignore" : $[
+ "widget" : `multi_line_edit,
+ // label
+ "label" : _("&Ignored Software"),
+ "init" : InitSWIgnore,
+ "store" : StoreSWIgnore,
+ "handle" : HandleSWIgnore,
+ // help text for "&Ignored software"
+ "help" : _("<p>For <b>ignored software</b>, enter each entry (like 'smtp_daemon') on new line</p>"),
+ ],
+ "output_dir" : $[
+ "widget" : `textentry,
+ // textentry label
+ "label" : _("O&utput Directory"),
+ "help" : _("help for output dir"),
+ "init" : InitOutputDir,
+ ],
+ "browse_output_dir" : $[
+ "widget" : `push_button,
+ "label" : Label::BrowseButton (),
+ "help" : "",
+ "handle" : HandleBrowseOutputDirectory
+ ],
+ "version" : $[
+ "widget" : `textentry,
+ // textentry label
+ "label" : _("&Version"),
+ "help" : _("<p>Enter the <b>Version</b> of your image configuration.</p>"),
+ "valid_chars" : String::CDigit () + ".",
+ "init" : InitVersion,
+ "store" : StoreVersion,
+ "handle" : HandleVersion,
+ ],
+ "size" : $[
+ "widget" : `intfield,
+ "opt" : [ `hstretch ],
+ // textentry label
+ "label" : _("&Size"),
+ "help" : _("<p>Set the image <b>Size</b> in the specified <b>Unit</b>.</p>"),
+ "init" : InitSize,
+ "store" : StoreDescription,
+ "handle" : HandleDescription,
+ ],
+ "sizeunit" : $[
+ "widget" : `combobox,
+ // textentry label
+ "label" : _("&Unit"),
+ "no_help" : true,
+ "items" : [],
+ "init" : InitSizeUnitCombo,
+ "store" : StoreDescription,
+ "handle" : HandleDescription,
+ ],
+ // ---------------- widgtes for directory structure
+ "general_scripts" : $[
+ "widget" : `empty,
+ // general help for directory structure tab
+ "help" : _("<p>Here, edit the configuration scripts used to build your image.</p>"),
+ ],
+ "general_directories" : $[
+ "widget" : `empty,
+ // general help for directory structure tab
+ "help" : _("<p>Here, point to the configuration directories that should help to build your image.</p>"),
+ ],
+ "root_dir" : $[
+ "widget" : `textentry,
+ // textentry label
+ "label" : _("Directory with System Configur&ation"),
+ // help text
+ "help" : _("<p>Define the path to the <b>Directory with System Configuration</b> (the <tt>root</tt> directory). The entire directory is copied into the root of the image tree using <tt>cp -a</tt>.</p>"),
+ "init" : InitDescription,
+ "store" : StoreDescription,
+ "handle" : HandleDescription,
+ ],
+ "browse_root_dir" : $[
+ "widget" : `push_button,
+ "label" : Label::BrowseButton (),
+ "help" : "",
+ "handle" : HandleBrowseRootDirectory
+ ],
+ "root_dir_table" : $[
+ "widget" : `custom,
+ "custom_widget" : `VBox (
+ // label (above table)
+ `Left (`Label (_("Directory with System Configuration"))),
+ `Table (`id("roottable"), `header (
+ // table header
+ _("Path to Directory"))
+ )
+ ),
+ // help for table with users
+ "help" : _("<p>Configure the <b>Directory with System Configuration</b> (the <tt>root</tt> directory). The entire directory is copied into the root of the image tree using <tt>cp -a</tt>.</p>"),
+ "init" : InitRootDirTable,
+ ],
+ "root_dir_add" : $[
+ "widget" : `push_button,
+ "label" : Label::AddButton (),
+ "no_help" : true,
+ "handle" : HandleAddToRootDir,
+ ],
+ "root_dir_delete" : $[
+ "widget" : `push_button,
+ "label" : Label::DeleteButton (),
+ "no_help" : true,
+ "handle" : HandleDeleteFromRootDir,
+ ],
+ "config_dir_table" : $[
+ "widget" : `custom,
+ "custom_widget" : `VBox (
+ // label (above table)
+ `Left (`Label (_("Directory with Scripts"))),
+ `Table (`id("configtable"), `header (
+ // table header
+ _("Path to File"))
+ )
+ ),
+ // help for table with users
+ "help" : _("<p>Configure the <b>Directory with Scripts</b> (the <tt>config</tt> directory). It contains scripts that are run after the installation of all the image packages.</p>"),
+ "init" : InitConfigDirTable,
+ ],
+ "config_dir_add" : $[
+ "widget" : `push_button,
+ "label" : Label::AddButton (),
+ "no_help" : true,
+ "handle" : HandleAddToConfigDir,
+ ],
+ "config_dir_delete" : $[
+ "widget" : `push_button,
+ "label" : Label::DeleteButton (),
+ "no_help" : true,
+ "handle" : HandleDeleteFromConfigDir,
+ ],
+ "config.sh" : $[
+ "widget" : `multi_line_edit,
+ // textentry label
+ "label" : _("I&mage Configuration Script"),
+ "help" : _("<p>Edit your <b>Image Configuration Script</b>, called <tt>config.sh</tt>. This script is run at the end of the installation but before the package scripts have run.</p>"),
+ "init" : InitDescription,
+ "store" : StoreDescription,
+ "handle" : HandleDescription,
+ ],
+ "import_config.sh" : $[
+ "widget" : `push_button,
+ // textentry label
+ "label" : _("&Import..."),
+ "help" : "",
+ "handle" : HandleImportConfigFile
+ ],
+ "config_dir" : $[
+ "widget" : `textentry,
+ // textentry label
+ "label" : _("Pa&th to Directory with Scripts"),
+ "help" : _("<p>The optional <b>Directory with Scripts</b> (<tt>config</tt> directory) contains scripts that are run after the installation of all the image packages.</p>"),
+ "init" : InitDescription,
+ "store" : StoreDescription,
+ "handle" : HandleDescription,
+ ],
+ "browse_config_dir" : $[
+ "widget" : `push_button,
+ // push button label
+ "label" : _("Br&owse..."),
+ "help" : "",
+ "handle" : HandleBrowseConfigDirectory
+ ],
+ "autoyast_path" : $[
+ "widget" : `textentry,
+ // textentry label
+ "label" : _("Path to Auto&YaST Profile"),
+ "help" : _("Choose the path to the AutoYaST profile (config.xml)."),
+ ],
+ "browse_autoyast" : $[
+ "widget" : `push_button,
+ // push button label
+ "label" : _("Brow&se..."),
+ "help" : "",
+ "handle" : HandleBrowseAutoYaSTFile
+ ],
+ "images.sh" : $[
+ "widget" : `multi_line_edit,
+ // textentry label
+ "label" : _("C&leanup Script"),
+ "help" : _("<p>Edit your <b>Cleanup Script</b> (<tt>images.sh</tt>). This script is run at the beginning of the image creation process.</p>"),
+ "init" : InitDescription,
+ "store" : StoreDescription,
+ "handle" : HandleDescription,
+ ],
+ "import_images.sh" : $[
+ "widget" : `push_button,
+ // textentry label
+ "label" : _("Im&port..."),
+ "help" : "",
+ "handle" : HandleImportImagesFile
+ ],
+ // ---------------- widgtes for description tab
+ "author" : $[
+ "widget" : `textentry,
+ // textentry label
+ "label" : _("&Author"),
+ // help text for Author, Contact and Specification widgets
+ "help" : _("<p>Set the values for <b>Author</b> of the image, <b>Contact Information</b>, and the image <b>Specification</b>.</p>"),
+ "init" : InitDescription,
+ "store" : StoreDescription,
+ "handle" : HandleDescription,
+ ],
+ "contact" : $[
+ "widget" : `textentry,
+ // textentry label
+ "label" : _("C&ontact"),
+ "init" : InitDescription,
+ "store" : StoreDescription,
+ "handle" : HandleDescription,
+ "no_help" : true,
+ ],
+ "specification" : $[
+ "widget" : `multi_line_edit,
+ // textentry label
+ "label" : _("&Specification"),
+ "init" : InitDescription,
+ "store" : StoreDescription,
+ "handle" : HandleDescription,
+ "no_help" : true,
+ ],
+ // ---------------- widgtes for users tab
+ "general_users" : $[
+ "widget" : `empty,
+ // general help for users tab
+ "help" : _("<p>Here, create users that should be available in the target system.</p>"),
+ ],
+ "group" : $[
+ "widget" : `textentry,
+ // textentry label
+ "label" : _("&Group name"),
+ "help" : _("<p>Select the <b>Group Name</b> to which the users belong.</p>"),
+ "init" : InitDescription,
+ "store" : StoreDescription,
+ "handle" : HandleDescription,
+ ],
+ "userstable" : $[
+ "widget" : `custom,
+ "custom_widget" : `Table (`id("table"), `opt (`notify), `header(
+ // table header
+ _("Name"),
+ // table header
+ _("Home Directory"))),
+ // help for table with users
+ "help" : _("<p>For each user, specify <b>Name</b>, <b>Password</b>, and <b>Home Directory</b>.</p>"),
+ "init" : InitUsersTable,
+ "handle" : HandleAddEditUser,
+ ],
+ "adduser" : $[
+ "widget" : `push_button,
+ "label" : Label::AddButton (),
+ "no_help" : true,
+ "handle" : HandleAddEditUser,
+ ],
+ "edituser" : $[
+ "widget" : `push_button,
+ "label" : Label::EditButton (),
+ "no_help" : true,
+ "handle" : HandleAddEditUser,
+ ],
+ "deleteuser" : $[
+ "widget" : `push_button,
+ "label" : Label::DeleteButton (),
+ "no_help" : true,
+ "handle" : HandleDeleteUser,
+ ],
+ // ------------------
+ ];
+ }
+
+ /**
+ * Main dialog for Kiwi image configuration
+ */
+ define symbol KiwiDialog () {
+
+ InitImageConfiguration ();
+
+ map widget_descr = get_widget_description ();
+ widget_descr["tab"] = CWMTab::CreateWidget($[
+ "tab_order" : ["config.xml", "description", "users", "scripts", "directories"],
+ "tabs" : tabs_descr (),
+ "widget_descr" : widget_descr,
+ "initial_tab" : "config.xml",
+ ]);
+ Wizard::SetContentsButtons("", `VBox (), "", Label::BackButton(), Label::NextButton());
+
+ term contents = `VBox (
+ `Left (`Label (KiwiConfig["name"]:"")),
+ "tab",
+ `VSpacing (0.3),
+ "global"
+ );
+
+ map caption = $[
+ // dialog caption
+ "iso" : _("Live CD Configuration"),
+ // dialog caption
+ "xen" : _("Xen Image Configuration"),
+ // dialog caption
+ "usb" : _("USB Stick Image Configuration"),
+ // button label
+ "vmx" : _("Virtual Disk Image"),
+ ];
+ map next_button = $[
+ // button label
+ "iso" : _("&Create ISO"),
+ // button label
+ "xen" : _("&Create Xen Image"),
+ // button label
+ "usb" : _("&Create USB Stick Image"),
+ // button label
+ "vmx" : _("&Create Virtual Disk Image"),
+ ];
+ symbol ret = CWM::ShowAndRun ($[
+ "widget_names" : [ "global", "tab" ],
+ "widget_descr" : widget_descr,
+ "contents" : contents,
+ "caption" : caption[kiwi_task]:"",
+ "back_button" : Label::BackButton (),
+ "next_button" : next_button[kiwi_task]:Label::NextButton (),
+ ]);
+ y2milestone("Returning %1", ret);
+ return ret;
+ }
+
+ /**
+ * Prepare dialog: define kiwi data without cd-creator
+ */
+ define symbol PrepareDialog () {
+
+ if (kiwi_task == "")
+ kiwi_task = "iso";
+
+ map Config = KiwiConfig;
+ string kiwi_configuration = Config["kiwi_configuration_" + kiwi_task]:"";
+ string name = Config["name"]:"";
+ string out_dir = Config["iso-directory"]:"";
+ map repositories = $[];//Config["sources"]:[]; FIXME!
+
+ // on start, disable all sources (-> move to client?)
+ if (Config == $[])
+ {
+ Pkg::SourceRestore ();
+ Pkg::SourceLoad();
+ list<map> all_sources = Pkg::SourceEditGet();
+ all_sources = maplist (map source, all_sources, {
+ source["enabled"] = false;
+ return source;
+ });
+ Pkg::SourceEditSet ((list