Author: lslezak Date: Thu Aug 7 15:42:40 2008 New Revision: 49824 URL: http://svn.opensuse.org/viewcvs/yast?rev=49824&view=rev Log: - distinguish between package arch (like i686) and system arch (i386) 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 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=49824&r1=49823&r2=49824&view=diff ============================================================================== --- branches/tmp/lslezak/product-creator-cross-arch/src/ProductCreator.ycp (original) +++ branches/tmp/lslezak/product-creator-cross-arch/src/ProductCreator.ycp Thu Aug 7 15:42:40 2008 @@ -97,24 +97,50 @@ /* Target architecture + Initialized to the current architecture */ -string _arch = Arch::architecture(); +// forward declaration +string ToPackageArch(string arch); + +// default is the system architecture +string _arch = nil; + +string ToPackageArch(string arch) +{ + if (arch == "s390_64") + { + arch = "s390x"; + } + if (arch == "s390_32") + { + arch = "s390"; + } + + if (!contains(["i386", "i486", "i586", "i686", "sparc", "sparc64", "mips", "mips64", "ppc", "ppc64", "alpha", "s390", "s390x", "ia64", "x86_64"], arch)) + { + y2error("Unknown architecture '%1'!", arch); + return nil; + } + + return arch; +} /** - Set the target archiotecture - @param new_arch new architecture (i386, sparc, sparc64, mips, mips64, ppc, ppc64, alpha, s390_32, s390_64, ia64, x86_64) + Set the target package architecture + @param new_arch new architecture (i386, i486, i586, i686, sparc, sparc64, mips, mips64, ppc, ppc64, alpha, s390, s390x, ia64, x86_64) @return true on success */ -global boolean SetArch(string new_arch) +global boolean SetPackageArch(string new_arch) { - if (!contains(["i386", "sparc", "sparc64", "mips", "mips64", "ppc", "ppc64", "alpha", "s390_32", "s390_64", "ia64", "x86_64"], new_arch)) + string pkgarch = ToPackageArch(new_arch); + + if (pkgarch == nil) { - y2error("Unknown architecture '%1'!", new_arch); return false; } - _arch = new_arch; + _arch = pkgarch; y2milestone("Target architecture set to '%1'", new_arch); // set the architecture in the package manager @@ -123,18 +149,47 @@ return true; } +// convert package (like i686) arch to system arch (i386) global string GetArch() { + string ret = _arch; + + // not set, use the current arch + if (ret == nil) + { + ret = Arch::architecture(); + } + + // convert x86 package archs to i386 system arch + if (contains(["i486", "i586", "i686"], ret)) + { + ret = "i386"; + } + else if (ret == "s390_64") + { + ret = "s390x"; + } + else if (ret == "s390_32") + { + ret = "s390"; + } + + return ret; +} + +// nil means not set +global string GetPackageArch() +{ return _arch; } global void ResetArch() { - _arch = Arch::architecture(); - y2milestone("Resetting the target architecture to '%1'", _arch); + _arch = nil; - // set the architecture in the package manager - Pkg::SetArchitecture(_arch); + // set the system architecture in the package manager + y2milestone("Resetting the target architecture to '%1'", Pkg::SystemArchitecture()); + Pkg::SetArchitecture(Pkg::SystemArchitecture()); } 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=49824&r1=49823&r2=49824&view=diff ============================================================================== --- branches/tmp/lslezak/product-creator-cross-arch/src/complex.ycp (original) +++ branches/tmp/lslezak/product-creator-cross-arch/src/complex.ycp Thu Aug 7 15:42:40 2008 @@ -121,6 +121,8 @@ any ret = nil; while(true) { + // reset the current architecture (needed when going back) + ProductCreator::ResetArch(); ret = UI::UserInput(); @@ -483,7 +485,7 @@ string arch = ProductCreator::Config["arch"]:""; if (arch != nil && arch != "") { - ProductCreator::SetArch(arch); + ProductCreator::SetPackageArch(arch); } 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=49824&r1=49823&r2=49824&view=diff ============================================================================== --- branches/tmp/lslezak/product-creator-cross-arch/src/dialogs.ycp (original) +++ branches/tmp/lslezak/product-creator-cross-arch/src/dialogs.ycp Thu Aug 7 15:42:40 2008 @@ -202,7 +202,7 @@ string arch = ProductCreator::Config["arch"]:""; if (arch != nil && arch != "") { - ProductCreator::SetArch(arch); + ProductCreator::SetPackageArch(arch); } string name = (string)UI::QueryWidget(`id(`name), `Value); @@ -441,7 +441,7 @@ } integer archsz = size(archs); - integer col1num = (archsz > max_lines) ? archsz / 2 : archsz; + integer col1num = (archsz > max_lines) ? (archsz + 1) / 2 : archsz; y2milestone("Number of archs in the first column: %1", col1num); // preselect the first item @@ -467,9 +467,9 @@ `Frame(_("Target Architecture"), `RadioButtonGroup(`id(`rb), `HBox( - widget1, + `Top(widget1), `HStretch(), - widget2, + `Top(widget2), `HStretch() ) ) @@ -477,7 +477,7 @@ `VSpacing(1), `HBox( `HSpacing(`opt(`hstretch), 2), - `HWeight(1, `PushButton(`id(`change), Label::OKButton())), + `HWeight(1, `PushButton(`id(`ok), Label::OKButton())), `HSpacing(2), `HWeight(1, `PushButton(`id(`cancel), Label::CancelButton())), `HSpacing(`opt(`hstretch), 2) @@ -492,16 +492,21 @@ UI::CloseDialog(); - if (ui == `cancel) + if (ui == `cancel || ui == `close) { // canceled return nil; } - else + else if (ui == `ok) { y2milestone("Selected architecture: %1", ret); return ret; } + else + { + y2error("Unhandled user input %1", ui); + return nil; + } } @@ -573,7 +578,7 @@ if (new_arch != nil) { // change the architecture - ProductCreator::SetArch(new_arch); + ProductCreator::SetPackageArch(new_arch); // initialize the target, read trusted GPG keys (needed for refresh) Pkg::TargetInit("/", true); @@ -668,7 +673,6 @@ else if (ret == `select) { integer SrcID = (integer)UI::QueryWidget(`id(`table), `CurrentItem); - string target_arch = ProductCreator::GetArch(); boolean repo_ok = CheckArchitecture(SrcID); @@ -690,10 +694,10 @@ UI::ChangeWidget(`id(`table), `Item(SrcID, 0) , _("X")); // refresh the target architecture if it has been changed - if (target_arch != ProductCreator::GetArch()) + if (ProductCreator::GetPackageArch() != nil) { UI::ReplaceWidget(`rp, - `Label(sformat(_("Target Architecture: %1"), ProductCreator::GetArch())) + `Label(sformat(_("Target Architecture: %1"), ProductCreator::GetPackageArch())) ); } } @@ -753,10 +757,12 @@ continue; } - if (ProductCreator::GetArch() != Arch::architecture()) + string arch = ProductCreator::GetPackageArch() ; + + if (arch != nil && arch != Arch::architecture()) { y2milestone("Target architecture has been changed"); - ProductCreator::Config["arch"] = ProductCreator::GetArch(); + ProductCreator::Config["arch"] = arch; // TODO: check archs onece again (needed after switching architecture multiple times) // reload repositories @@ -774,21 +780,28 @@ else if (ret == `arch) { // ask for the target architecture + string pkg_arch = ProductCreator::GetPackageArch(); + + if (pkg_arch == nil) + { + pkg_arch = Pkg::SystemArchitecture(); + } + string new_arch = AskArch( _("Select the new target architecture."), - // sort the lilst according to the current locale - lsort(["i386", "sparc", "sparc64", "mips", "mips64", "ppc", "ppc64", "alpha", - "s390_32", "s390_64", "ia64", "x86_64"]), - ProductCreator::GetArch()); + // sort the list according to the current locale + lsort(["i386", "i486", "i586", "i686", "sparc", "sparc64", "mips", "mips64", "ppc", "ppc64", "alpha", + "s390", "s390x", "ia64", "x86_64"]), + pkg_arch); // nil == switch has been canceled - if (new_arch != nil && new_arch != "" && new_arch != ProductCreator::GetArch()) + if (new_arch != nil && new_arch != "" && new_arch != pkg_arch) { // change the architecture - ProductCreator::SetArch(new_arch); + ProductCreator::SetPackageArch(new_arch); UI::ReplaceWidget(`rp, - `Label(sformat(_("Target Architecture: %1"), ProductCreator::GetArch())) + `Label(sformat(_("Target Architecture: %1"), ProductCreator::GetPackageArch())) ); } } -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org