Author: lslezak
Date: Wed Mar 12 14:51:56 2008
New Revision: 45376
URL: http://svn.opensuse.org/viewcvs/yast?rev=45376&view=rev
Log:
- do not use StorageDevices:: module, not needed anymore
- fixed the architecture check
- better check product dependency, added a new dialog for selecting
the base product (#368580)
Modified:
trunk/product-creator/package/yast2-product-creator.changes
trunk/product-creator/src/ProductCreator.ycp
trunk/product-creator/src/dialogs.ycp
trunk/product-creator/src/helps.ycp
trunk/product-creator/src/wizards.ycp
Modified: trunk/product-creator/package/yast2-product-creator.changes
URL: http://svn.opensuse.org/viewcvs/yast/trunk/product-creator/package/yast2-product-creator.changes?rev=45376&r1=45375&r2=45376&view=diff
==============================================================================
--- trunk/product-creator/package/yast2-product-creator.changes (original)
+++ trunk/product-creator/package/yast2-product-creator.changes Wed Mar 12 14:51:56 2008
@@ -1,4 +1,12 @@
-------------------------------------------------------------------
+Wed Mar 12 14:42:28 CET 2008 - lslezak@suse.cz
+
+- do not use StorageDevices:: module, not needed anymore
+- fixed the architecture check
+- better check product dependency, added a new dialog for selecting
+ the base product (#368580)
+
+-------------------------------------------------------------------
Tue Mar 11 13:37:26 CET 2008 - lslezak@suse.cz
- adapted to the new ProgressDownload callback signature (#168935)
Modified: trunk/product-creator/src/ProductCreator.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/product-creator/src/ProductCreator.ycp?rev=45376&r1=45375&r2=45376&view=diff
==============================================================================
--- trunk/product-creator/src/ProductCreator.ycp (original)
+++ trunk/product-creator/src/ProductCreator.ycp Wed Mar 12 14:51:56 2008
@@ -738,16 +738,6 @@
return ret;
}
-global boolean UpdateMD5File(string directory)
-{
- string command = sformat("/usr/bin/create_md5sums '%1'", String::Quote(directory));
- boolean ret = SCR::Execute(.target.bash, command) == 0;
-
- y2milestone("MD5SUMS updated: %1", ret);
-
- return ret;
-}
-
// execute a command
boolean Exec(string command)
{
@@ -766,6 +756,16 @@
return ret == 0;
}
+global boolean UpdateMD5File(string directory)
+{
+ string command = sformat("/bin/sh /usr/bin/create_md5sums '%1'", String::Quote(directory));
+ boolean ret = Exec(command);
+
+ y2milestone("MD5SUMS updated: %1", ret);
+
+ return ret;
+}
+
boolean CopyFile(integer srcid, integer mid, string src, string target)
{
string local_file = Pkg::SourceProvideFile(srcid, mid, src);
@@ -1085,60 +1085,97 @@
list<integer> sources = UrlToId(Config["sources"]:[]);
- // we have to sort the products according to requires to get the base product
- string tsort_input = "";
+ if (size(sources) == 1)
+ {
+ y2milestone("Only one source selected");
+ return sources[0]:-1;
+ }
- map provide_map = $[];
+ // the products must be in the pool
+ Pkg::SourceLoad();
- string base_product_name = "";
+ list<map> product_deps = Pkg::ResolvableDependencies("", `product, "");
+ y2milestone("found products: %1", product_deps);
- foreach(integer id , sources, ``{
+ // filter out unused products
+ product_deps = filter(map prod, product_deps, {return contains(sources, prod["source"]:-1);});
- map general_info = Pkg::SourceGeneralData(id);
+ y2milestone("used products: %1", product_deps);
+
+ // we have to sort the products according to requires to get the base product
+ string tsort_input = "";
- // a YUM source cannot contain base product
- // only YaST source is supported
- if (general_info["type"]:"" == "YaST")
+ foreach(map prod, product_deps,
{
- map content_file = ReadContentFile(id);
+ list<string> provides = [];
+ list<string> requires = [];
- string requires = content_file["REQUIRES"]:"";
- string provides = content_file["PROVIDES"]:"";
+ // collect provides and requires dependencies
+ foreach(map dep, (list<map>)prod["dependencies"]:[],
+ {
+ string kind = dep["dep_kind"]:"";
+ // replace ' ' -> '_' (tsort uses space as a separator)
+ string name = String::Replace(dep["name"]:"", " ", "_");
- if (provides == "")
- {
- //provides = sformat("%1-%2", productData["productname"]:"", productData["productversion"]:"" );
- provides = sformat("%1-%2", content_file["PRODUCT"]:"", content_file["VERSION"]:"" );
- }
+ if (name != "")
+ {
+ if (kind == "provides")
+ {
+ provides = add(provides, name);
+ }
+ else if (kind == "requires")
+ {
+ requires = add(requires, name);
+ }
+ }
+ }
+ );
+
+ integer src = prod["source"]:-1;
- string provides_tsort = String::Replace(provides, " ", "_");
+ y2milestone("Source %1: provides: %2, requires: %3", src, provides, requires);
- base_product_name = provides;
+ string src_str = sformat("@repository_id:%1@", src);
- tsort_input = tsort_input + provides_tsort + " " + String::Replace(requires, " ", "_") + "\n";
- provide_map[provides_tsort] = id;
+ // add requires dependencies to the tsort input
+ foreach(string r, requires,
+ {
+ tsort_input = tsort_input + sformat("%1 %2\n", src_str, r);
+ }
+ );
+
+ // add provides dependencies to the tsort input
+ foreach(string p, provides,
+ {
+ tsort_input = tsort_input + sformat("%1 %2\n", p, src_str);
+ }
+ );
}
- });
+ );
- integer base = sources[0]:0;
+ y2milestone("tsort input: %1", tsort_input);
- if (size(sources) > 1)
- {
- y2debug("tsort_input: %1", tsort_input);
- // run tsort
- map sorted = (map)SCR::Execute(.target.bash_output, sformat("echo '%1' | tsort | tac", String::Quote(tsort_input)));
- list<string> sorted_prods = splitstring(sorted["stdout"]:"", "\n");
+ // run tsort
+ map sorted = (map)SCR::Execute(.target.bash_output, sformat("echo '%1' | tsort | tac", String::Quote(tsort_input)));
+ list<string> sorted_prods = splitstring(sorted["stdout"]:"", "\n");
+ y2milestone("Sorted products: %1", sorted_prods);
- // remove requires
- sorted_prods = filter(string p, sorted_prods, {return haskey(provide_map, p);});
- y2milestone("Sorted products: %1", sorted_prods);
+ integer base_source = sources[0]:-1;
- base = provide_map[sorted_prods[0]:""]:0;
- }
+ foreach(string line, sorted_prods,
+ {
+ string src_id = regexpsub(line, "@repository_id:([0-9]*)@", "\\1");
- y2milestone("Found base source: id: %1, %2", base, Pkg::SourceGeneralData(base));
+ if (src_id != nil)
+ {
+ base_source = tointeger(src_id);
+ y2milestone("Found base source: %1", base_source);
+ break;
+ }
+ }
+ );
- return base;
+ return base_source;
}
global string CreateAddonFile(map products)
@@ -1201,8 +1238,11 @@
skel_root = sformat("%1/%2", Config["iso-directory"]:"", Config["name"]:"");
SCR::Execute(.target.mkdir, skel_root);
+ string base_url = Config["base_repo"]:"";
+ y2milestone("Configured base repository: %1", base_url);
+
// detect the base source
- integer base_source = checkProductDependency();
+ integer base_source = (base_url != "") ? (UrlToId([base_url])[0]:-1) : checkProductDependency();
boolean bootable_product = isBootSource(base_source);
// ppc64 has /boot/ppc
@@ -1718,14 +1758,15 @@
{
// remove the pattern
string cmd = sformat("/bin/rm -- '%1/%2/%3'", String::Quote(skel_root), String::Quote(descrDir), String::Quote(f));
- y2milestone("removing pattern %1", f);
success = success && Exec(cmd);
- y2debug("success: %1", success);
+ y2milestone("removing pattern %1: %2", f, success);
refresh_diryast = true;
}
}
);
+ y2milestone("removed patterns: %1", success);
+
if (refresh_diryast)
{
// regenerate directory.yast and patterns file
@@ -1754,7 +1795,7 @@
success = success && SCR::Write(.target.string, target_addon_file, addon_file);
}
- y2debug("success: %1", success);
+ y2milestone("Created skeleton: %1", success);
return success;
}
Modified: trunk/product-creator/src/dialogs.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/product-creator/src/dialogs.ycp?rev=45376&r1=45375&r2=45376&view=diff
==============================================================================
--- trunk/product-creator/src/dialogs.ycp (original)
+++ trunk/product-creator/src/dialogs.ycp Wed Mar 12 14:51:56 2008
@@ -16,7 +16,6 @@
import "SourceManager";
import "Report";
import "URL";
- import "StorageDevices";
import "Arch";
import "Label";
import "Popup";
@@ -254,6 +253,9 @@
return (symbol)ret;
}
+ // remember the direction to correctly skip baseProductSelectionDialog()
+ boolean going_back = false;
+
/**
* Configure2 dialog
* @return dialog result
@@ -381,6 +383,7 @@
}
else if (ret == `back)
{
+ going_back = true;
break;
}
else if(ret == `next)
@@ -535,11 +538,17 @@
y2milestone("Architecture %1 is supported: %2", arch, found_architecture);
- if (true)
+ if (found_architecture)
{
if (!contains(selected_items, SrcID))
{
selected_items = add (selected_items, SrcID );
+
+ // enable the source
+ if (general_info["enabled"]:false)
+ {
+ Pkg::SourceSetEnabled(SrcID, true);
+ }
}
UI::ChangeWidget(`id(`table), `Item(SrcID, 0) , _("X"));
@@ -554,6 +563,14 @@
else if (ret == `remove)
{
integer SrcID = (integer)UI::QueryWidget(`id(`table), `CurrentItem);
+ map general_info = Pkg::SourceGeneralData(SrcID);
+
+ // disable the source
+ if (general_info["enabled"]:false)
+ {
+ Pkg::SourceSetEnabled(SrcID, false);
+ }
+
selected_items = filter(integer i, selected_items, ``(SrcID!=i ));
UI::ChangeWidget(`id(`table), `Item(SrcID, 0) , "");
}
@@ -597,17 +614,9 @@
Report::Error(_("Select at least one source."));
continue;
}
- integer base_source = ProductCreator::checkProductDependency();
- // is the base source bootable?
- if (!ProductCreator::isBootSource(base_source))
- {
- if (Popup::ContinueCancel("The selected repository doesn't contain /boot directory.
-The created medium will not be bootable.\n"))
- {
- break;
- }
- }
+ going_back = false;
+
break;
}
else if( ret == `back) {
@@ -622,6 +631,81 @@
return (symbol)ret;
}
+ define symbol baseProductSelectionDialog()
+ {
+ if (size(ProductCreator::Config["sources"]:[]) == 1)
+ {
+ // there is just one repository, we can skip this dialog
+ y2milestone("Only one repository selected, skipping base repository selection");
+
+ // remove the option if it exists
+ ProductCreator::Config = remove(ProductCreator::Config, "base_repo");
+ return going_back ? `back : `next;
+ }
+
+ /* dialog caption */
+ string caption = _("Base Source Selection");
+
+ integer default_base = ProductCreator::Config["base_repo"]:-1;
+
+ if (default_base < 0)
+ {
+ y2milestone("The base repository is unknown, proposing...");
+ default_base = ProductCreator::checkProductDependency();
+ }
+
+ string default_url = Pkg::SourceGeneralData(default_base)["url"]:"";
+
+ list<term> items = [];
+
+ foreach(string srcurl, ProductCreator::Config["sources"]:[],
+ {
+ items = add(items, `item(srcurl, srcurl == default_url));
+ }
+ );
+
+ term contents = `SelectionBox(`id(`base_selection), _("Selected Base Source"), items);
+
+ Wizard::SetContentsButtons(caption, contents, HELPS["baseSelection"]:"",
+ Label::BackButton(), Label::NextButton());
+
+ symbol ret = `again;
+ string base = "";
+
+ while(!contains([`next, `back, `abort], ret))
+ {
+ ret = (symbol)UI::UserInput();
+
+ if (ret == `next)
+ {
+ // get the selected source
+ base = (string)UI::QueryWidget(`id(`base_selection), `CurrentItem);
+ y2internal("Selected base product: %1", base);
+
+ integer base_src_id = ProductCreator::UrlToId([base])[0]:-1;
+
+ // is the base source bootable?
+ if (!ProductCreator::isBootSource(base_src_id))
+ {
+ y2warning("Selected base product is not bootable");
+
+ if (!Popup::ContinueCancel("The selected base repository doesn't contain /boot directory.
+The created medium will not be bootable.\n"))
+ {
+ ret = `again;
+ }
+ }
+ }
+ }
+
+ if (ret == `next)
+ {
+ ProductCreator::Config["base_repo"] = base;
+ }
+
+ return ret;
+ }
+
/**
* Configure3 dialog
* @return dialog result
@@ -784,8 +868,8 @@
// while the package manager is initialized
UI::ReplaceWidget(`rep,
mode == nil ?
- `PackageSelector(`id(`packages ), StorageDevices::FloppyDevice ()) :
- `PackageSelector(`id(`packages ), `opt(mode), StorageDevices::FloppyDevice ())
+ `PackageSelector(`id(`packages )) :
+ `PackageSelector(`id(`packages ), `opt(mode))
);
symbol result = (symbol) UI::RunPkgSelection(`id(`packages ) );
Modified: trunk/product-creator/src/helps.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/product-creator/src/helps.ycp?rev=45376&r1=45375&r2=45376&view=diff
==============================================================================
--- trunk/product-creator/src/helps.ycp (original)
+++ trunk/product-creator/src/helps.ycp Wed Mar 12 14:51:56 2008
@@ -116,6 +116,23 @@
</p>
"),
+ /* help text - the base selection dialog 1/4 */
+"baseSelection" : _("<p><b>The Base Product</b></p>") +
+
+ /* help text - the base selection dialog 2/4 */
+_("<p>One of the used repositories must be marked as the base product. The base
+product repository should be bootable to ensure the new created product is also
+bootable.</p>") +
+
+ /* help text - the base selection dialog 3/4 */
+_("<p>The other repositories will be used as add-ons for the base repository.</p>")
+
+ /* help text - the base selection dialog 4/4 */
++ _("<p>The product creator solves dependencies of the selected products and proposes
+the base product. If the proposed value is wrong then select the right base
+repository from the list.</p>"),
+
+
];
/* EOF */
Modified: trunk/product-creator/src/wizards.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/product-creator/src/wizards.ycp?rev=45376&r1=45375&r2=45376&view=diff
==============================================================================
--- trunk/product-creator/src/wizards.ycp (original)
+++ trunk/product-creator/src/wizards.ycp Wed Mar 12 14:51:56 2008
@@ -32,6 +32,7 @@
map aliases = $[
"source" : ``( sourceDialog() ),
+ "base" : ``( baseProductSelectionDialog() ),
"config1" : ``( Configure1Dialog() ),
"config2" : ``( Configure2Dialog() ),
"isolinuxcheck" : [ ``( CheckBootableSrc() ), true],
@@ -47,6 +48,10 @@
"ws_start" : "config1",
"source" : $[
`abort : `abort,
+ `next : "base"
+ ],
+ "base" : $[
+ `abort : `abort,
`next : "config2"
],
"config1" : $[
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org