Author: lslezak
Date: Wed Aug 6 12:50:41 2008
New Revision: 49755
URL: http://svn.opensuse.org/viewcvs/yast?rev=49755&view=rev
Log:
- ask user to switch to another architecture if the selected repository
is not compatible with the current machine
- save arch flag to the config
Modified:
branches/tmp/lslezak/product-creator-cross-arch/src/ProductCreator.ycp
branches/tmp/lslezak/product-creator-cross-arch/src/complex.ycp
branches/tmp/lslezak/product-creator-cross-arch/src/dialogs.ycp
branches/tmp/lslezak/product-creator-cross-arch/src/wizards.ycp
Modified: branches/tmp/lslezak/product-creator-cross-arch/src/ProductCreator.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/lslezak/product-creator-cross-arch/src/ProductCreator.ycp?rev=49755&r1=49754&r2=49755&view=diff
==============================================================================
--- branches/tmp/lslezak/product-creator-cross-arch/src/ProductCreator.ycp (original)
+++ branches/tmp/lslezak/product-creator-cross-arch/src/ProductCreator.ycp Wed Aug 6 12:50:41 2008
@@ -26,6 +26,7 @@
import "Directory";
import "Profile";
import "AutoinstSoftware";
+// NOTE: do not use Arch:: directly in this module, use GetArch() function instead!
import "Arch";
import "Package";
import "PackageAI";
@@ -93,6 +94,51 @@
*/
global block<boolean> AbortFunction = nil;
+
+/*
+ Target architecture
+*/
+
+string _arch = Arch::architecture();
+
+/**
+ Set the target archiotecture
+ @param new_arch new architecture (i386, sparc, sparc64, mips, mips64, ppc, ppc64, alpha, s390_32, s390_64, ia64, x86_64)
+ @return true on success
+*/
+global boolean SetArch(string new_arch)
+{
+ if (!contains(["i386", "sparc", "sparc64", "mips", "mips64", "ppc", "ppc64", "alpha", "s390_32", "s390_64", "ia64", "x86_64"], new_arch))
+ {
+ y2error("Unknown architecture '%1'!", new_arch);
+ return false;
+ }
+
+ _arch = new_arch;
+ y2milestone("Target architecture set to '%1'", new_arch);
+
+ // set the architecture in the package manager
+ Pkg::SetArchitecture(_arch);
+
+ return true;
+}
+
+global string GetArch()
+{
+ return _arch;
+}
+
+global void ResetArch()
+{
+ _arch = Arch::architecture();
+ y2milestone("Resetting the target architecture to '%1'", _arch);
+
+ // set the architecture in the package manager
+ Pkg::SetArchitecture(_arch);
+}
+
+
+
/**
* Data was modified?
*/
@@ -178,7 +224,7 @@
global boolean isCode10Source()
{
boolean code10 = false;
- string arch = Arch::architecture ();
+ string arch = GetArch();
if (arch == "s390_64") arch = "s390x";
foreach (string url , ProductCreator::Config["sources"]:[],
{
@@ -619,7 +665,7 @@
}
else
{
- string arch = Arch::architecture();
+ string arch = GetArch();
if (arch == "s390_64") arch = "s390x";
bootconfig_path = sformat("boot/%1/loader/isolinux.cfg", arch);
@@ -1356,7 +1402,7 @@
string sles_path = "";
integer sles_src = 0;
string descr_dir = "";
- string arch = Arch::architecture();
+ string arch = GetArch();
if (arch == "s390_64") arch = "s390x";
y2milestone("Config: %1", Config);
@@ -1390,7 +1436,7 @@
if (bootable_product)
{
- if (Arch::i386() || Arch::x86_64())
+ if (_arch == "i386" || _arch == "x86_64")
{
if (Config["code10"]:false)
{
@@ -1401,7 +1447,7 @@
Exec(sformat("/bin/mkdir -p '%1/boot/loader'", String::Quote(skel_root)));
}
}
- else if (Arch::ppc() || Arch::ppc64())
+ else if (_arch == "ppc" || _arch == "ppc64")
{
Exec(sformat("/bin/mkdir -p '%1/PS3'", String::Quote(skel_root)));
Exec(sformat("/bin/mkdir -p '%1/ppc'", String::Quote(skel_root)));
@@ -1473,7 +1519,7 @@
CopyFile(id, 1, "boot/rescue", sformat("%1/boot", skel_root));
}
// Loader, x86 specific
- if (Arch::i386() || Arch::x86_64())
+ if (_arch == "i386" || _arch == "x86_64")
{
if (Config["code10"]:false)
{
@@ -1489,7 +1535,7 @@
CopyDirectoryRec(id, 1, "boot/loader", sformat("%1/boot", skel_root));
}
}
- else if (Arch::ppc() || Arch::ppc64())
+ else if (_arch == "ppc" || _arch == "ppc64")
{
// recursive copy of /boot
CopyDirectoryRec(id, 1, "boot", skel_root);
@@ -1503,7 +1549,7 @@
{
CopyDirectoryRec(id, 1, "boot", skel_root);
- if (Arch::ppc() || Arch::ppc64())
+ if (_arch == "ppc" || _arch == "ppc64")
{
CopyPPCBoot(id, skel_root);
}
@@ -1643,7 +1689,7 @@
}
// Loader, x86 specific
- if (Arch::i386() || Arch::x86_64())
+ if (_arch == "i386" || _arch == "x86_64")
{
if (Config["code10"]:false)
{
@@ -1659,7 +1705,7 @@
CopyDirectoryRec(base_source, 1, "boot/loader", sformat("%1/boot", skel_root));
}
}
- else if (Arch::ppc() || Arch::ppc64())
+ else if (_arch == "ppc" || _arch == "ppc64")
{
CopyPPCBoot(base_source, skel_root);
@@ -1676,7 +1722,7 @@
{
CopyDirectoryRec(base_source, 1, "boot", skel_root);
- if (Arch::ppc() || Arch::ppc64())
+ if (_arch == "ppc" || _arch == "ppc64")
{
CopyPPCBoot(base_source, skel_root);
}
@@ -2268,7 +2314,7 @@
global define boolean CopyMiscFiles() ``{
string cpCmd = "";
- string arch = Arch::architecture();
+ string arch = GetArch();
if (arch == "s390_64") arch = "s390x";
y2debug("isolinux.cfg: %1", Config["bootconfig"]:"" );
if (Config["bootconfig"]:"" != "")
Modified: branches/tmp/lslezak/product-creator-cross-arch/src/complex.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/lslezak/product-creator-cross-arch/src/complex.ycp?rev=49755&r1=49754&r2=49755&view=diff
==============================================================================
--- branches/tmp/lslezak/product-creator-cross-arch/src/complex.ycp (original)
+++ branches/tmp/lslezak/product-creator-cross-arch/src/complex.ycp Wed Aug 6 12:50:41 2008
@@ -11,7 +11,6 @@
textdomain "product-creator";
- import "Arch";
import "CommandLine";
import "Directory";
import "FileUtils";
@@ -303,7 +302,7 @@
y2debug("bootconfig available");
string fname = (ProductCreator::Config["code10"]:false)
- ? sformat("%1/boot/%2/loader/isolinux.cfg", ProductCreator::skel_root, Arch::architecture())
+ ? sformat("%1/boot/%2/loader/isolinux.cfg", ProductCreator::skel_root, ProductCreator::GetArch())
: sformat("%1/boot/loader/isolinux.cfg", ProductCreator::skel_root);
SCR::Write(.target.string, fname, ProductCreator::Config["bootconfig"]:"" );
@@ -369,7 +368,7 @@
{
Popup::ShowFeedback(_("Creating CD Image..."), _("This may take a while"));
}
- string arch = Arch::architecture ();
+ string arch = ProductCreator::GetArch();
if (arch == "s390_64") arch = "s390x";
string command = sformat("/usr/lib/YaST2/bin/y2mkiso '%1' '%2' '%3'", String::Quote(isodir), String::Quote(isofile), String::Quote((ProductCreator::Config["code10"]:false) ? arch : ""));
@@ -552,7 +551,7 @@
// skip isolinux configuration if the architecture
// is not i386 or x86_64 - there is no isolinux
- if (Arch::architecture() != "i386" && Arch::architecture() != "x86_64")
+ if (ProductCreator::GetArch() != "i386" && ProductCreator::GetArch() != "x86_64")
{
return `skip_isolinux;
}
Modified: branches/tmp/lslezak/product-creator-cross-arch/src/dialogs.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/lslezak/product-creator-cross-arch/src/dialogs.ycp?rev=49755&r1=49754&r2=49755&view=diff
==============================================================================
--- branches/tmp/lslezak/product-creator-cross-arch/src/dialogs.ycp (original)
+++ branches/tmp/lslezak/product-creator-cross-arch/src/dialogs.ycp Wed Aug 6 12:50:41 2008
@@ -16,7 +16,6 @@
import "SourceManager";
import "Report";
import "URL";
- import "Arch";
import "Label";
import "Popup";
import "URL";
@@ -25,6 +24,7 @@
import "CWM";
import "String";
import "Package";
+ import "Arch";
include "product-creator/routines.ycp";
include "product-creator/helps.ycp";
@@ -198,6 +198,13 @@
}
else if(ret == `next ) {
+ // set architecture if configured
+ string arch = ProductCreator::Config["arch"]:"";
+ if (arch != nil && arch != "")
+ {
+ ProductCreator::SetArch(arch);
+ }
+
string name = (string)UI::QueryWidget(`id(`name), `Value);
if (name == "")
@@ -419,6 +426,131 @@
return (symbol)ret;
}
+string AskArch(list<string> archs)
+{
+ term widget = `VBox();
+
+ // TODO: preselect the first item?
+ foreach(string a, archs,
+ {
+ widget = add(widget, `MinWidth(25, `Left(`RadioButton(`id(a), a))));
+ }
+ );
+
+ term content = `MarginBox(1, 0.5,
+ `VBox(
+ `Label(sformat(_("The source does not support the architecture of this machine (%1).
+Change the target architecture?
+"), Arch::architecture())),
+ `VSpacing(1),
+ `Frame(_("Target Architecture"),
+ `RadioButtonGroup(`id(`rb),
+ widget
+ )
+ ),
+ `VSpacing(1),
+ `HBox(
+ `PushButton(`id(`change), _("Change Architecture")),
+ `HSpacing(1),
+ `PushButton(`id(`cancel), Label::CancelButton())
+ )
+ )
+ );
+
+ UI::OpenDialog(content);
+
+ any ui = UI::UserInput();
+ string ret = (string)UI::QueryWidget(`id(`rb), `CurrentButton);
+
+ UI::CloseDialog();
+
+ if (ui == `cancel)
+ {
+ // canceled
+ return nil;
+ }
+ else
+ {
+ y2milestone("Selected architecture: %1", ret);
+ return ret;
+ }
+}
+
+
+boolean CheckArchitecture(integer SrcID)
+{
+ map general_info = Pkg::SourceGeneralData(SrcID);
+ boolean found_architecture = false;
+ list<string> found_archs = [];
+
+ string arch = ProductCreator::GetArch();
+ if (arch == "s390_64") arch = "s390x";
+
+ // architecture check is possible only for YaST sources
+ if (general_info["type"]:"" == "YaST")
+ {
+ // Check architecture
+ map