Mailinglist Archive: yast-commit (953 mails)

< Previous Next >
[yast-commit] r49755 - in /branches/tmp/lslezak/product-creator-cross-arch/src: ProductCreator.ycp complex.ycp dialogs.ycp wizards.ycp
  • From: lslezak@xxxxxxxxxxxxxxxx
  • Date: Wed, 06 Aug 2008 10:50:41 -0000
  • Message-id: <20080806105041.E832D2738C@xxxxxxxxxxxxxxxx>
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<string,string> read_content =
ProductCreator::ReadContentFile(SrcID);
+ y2milestone("content file: %1", read_content);
+
+ foreach(string key, string value, read_content,
+ {
+ if (key == "ARCH." + arch)
+ {
+ found_architecture = true;
+ break;
+ }
+ else
+ {
+ string found_arch = regexpsub(key, "ARCH\\.(.*)", "\\1");
+
+ if (found_arch != nil)
+ {
+ found_archs = add(found_archs, found_arch);
+ }
+ }
+ }
+ );
+ }
+ else
+ {
+ y2milestone("Not a YaST source, cannot verify the architecture");
+ found_architecture = true;
+ }
+
+ y2milestone("Architecture %1 is supported: %2", arch, found_architecture);
+
+ if (found_architecture)
+ {
+ return true;
+ }
+ else
+ {
+ y2milestone("Supported architectures: %1", found_archs);
+
+ if (size(found_archs) == 0)
+ {
+ y2milestone("The repository does not provide architecture data,
assuming it is compatible");
+ return true;
+ }
+
+ // the architecture is different, ask to switch
+ string new_arch = AskArch(found_archs);
+
+ // nil == switch has been canceled
+ if (new_arch != nil)
+ {
+ // change the architecture
+ ProductCreator::SetArch(new_arch);
+ Pkg::SourceForceRefreshNow(SrcID);
+ return true;
+ }
+ }
+
+ return false;
+}
+
+
/**
* Dialog for selecting the sources
* @return symbol
@@ -489,43 +621,17 @@
else if (ret == `select)
{
integer SrcID = (integer)UI::QueryWidget(`id(`table),
`CurrentItem);
- map general_info = Pkg::SourceGeneralData(SrcID);
- boolean found_architecture = false;

- string arch = Arch::architecture ();
- if (arch == "s390_64") arch = "s390x";
+ boolean repo_ok = CheckArchitecture(SrcID);

- // architecture check is possible only for YaST sources
- if (general_info["type"]:"" == "YaST")
- {
- // Check architecture
- map<string,string> read_content =
ProductCreator::ReadContentFile(SrcID);
- y2milestone("content file: %1", read_content);
-
- foreach(string key, string value, read_content,
- {
- if (key == "ARCH." + arch)
- {
- found_architecture = true;
- break;
- }
- }
- );
- }
- else
- {
- y2milestone("Not a YaST source, cannot verify the
architecture");
- found_architecture = true;
- }
-
- y2milestone("Architecture %1 is supported: %2", arch,
found_architecture);
-
- if (found_architecture)
+ if (repo_ok)
{
if (!contains(selected_items, SrcID))
{
selected_items = add (selected_items, SrcID );

+ map general_info = Pkg::SourceGeneralData(SrcID);
+
// enable the source
if (general_info["enabled"]:false)
{
@@ -535,12 +641,6 @@

UI::ChangeWidget(`id(`table), `Item(SrcID, 0) , _("X"));
}
- else
- {
- Report::Error(sformat(_("The source does not support the
architecture of this machine (%1).
-Select another source.
-"), arch));
- }
}
else if (ret == `remove)
{
@@ -597,6 +697,18 @@
continue;
}

+ if (ProductCreator::GetArch() != Arch::architecture())
+ {
+ y2milestone("Target architecture has been changed");
+ ProductCreator::Config["arch"] = ProductCreator::GetArch();
+
+ // TODO: check archs onece again (needed after switching
architecture multiple times)
+ // reload repositories
+ Pkg::SourceFinishAll();
+// Pkg::TargetInit("/");
+ Pkg::SourceStartManager(false);
+ }
+
going_back = false;

break;
@@ -851,8 +963,8 @@
// while the package manager is initialized
UI::ReplaceWidget(`rep,
mode == nil ?
- `PackageSelector(`id(`packages )) :
- `PackageSelector(`id(`packages ), `opt(mode))
+ `PackageSelector(`id(`packages)) :
+ `PackageSelector(`id(`packages), `opt(mode))
);

symbol result = (symbol) UI::RunPkgSelection(`id(`packages ) );
@@ -1417,6 +1529,16 @@
summary = Summary::AddLine(summary, sformat(_("Selected %1 packages"),
size(Pkg::GetPackages(`selected, true))));

+ string arch = ProductCreator::Config["arch"]:"";
+ // display the architecture in the summary if it has been changed
+ if (arch != nil && arch != "" && arch != Arch::architecture())
+ {
+ summary = Summary::AddHeader(summary, _("Architecture") );
+
+ // summary line, %1 is e.g. i386, x86_64, ppc...
+ summary = Summary::AddLine(summary, sformat(_("Target
architectrure: %1"), arch));
+ }
+
// summary caption
summary = Summary::AddHeader(summary,_("Output Directory"));


Modified: branches/tmp/lslezak/product-creator-cross-arch/src/wizards.ycp
URL:
http://svn.opensuse.org/viewcvs/yast/branches/tmp/lslezak/product-creator-cross-arch/src/wizards.ycp?rev=49755&r1=49754&r2=49755&view=diff
==============================================================================
--- branches/tmp/lslezak/product-creator-cross-arch/src/wizards.ycp (original)
+++ branches/tmp/lslezak/product-creator-cross-arch/src/wizards.ycp Wed Aug 6
12:50:41 2008
@@ -303,7 +303,7 @@
list<string> required_packages = ["inst-source-utils", "mkisofs",
"createrepo"];

// add PPC specific packages
- if (Arch::architecture() == "ppc" || Arch::architecture() == "ppc64")
+ if (ProductCreator::GetArch() == "ppc" || ProductCreator::GetArch() ==
"ppc64")
{
// /bin/objcopy - binutils
// /bin/mkzimage - lilo

--
To unsubscribe, e-mail: yast-commit+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: yast-commit+help@xxxxxxxxxxxx

< Previous Next >
This Thread
  • No further messages