[Yum-devel] [REPOST PATCH] yum 2.4.3: install cross root fs

Ken MacLeod ken at bitsko.slc.ut.us
Tue Jun 12 14:01:51 UTC 2007


This is an update to a patch I sent back in
  https://lists.dulug.duke.edu/pipermail/yum-devel/2006-August/002355.html

This patch allows a yum.conf for a given installroot to specify the
architecture of that installroot.  For example, building an embedded
PPC fs on an x86 host.

This wasn't accepted earlier because it assumes that scripts aren't
executed in the target root fs.  This is normal practice for
cross-development but might be a surprise the first time someone tries
to create, say, a Fedora PPC NFS root on an x86 server.  I had
proposed a plug-in solution to make it more explicit but I didn't get
a chance to implement it.

I switched down to the CentOS yum 2.4.3 to run on our RHEL4 build
servers.  I'm posting mock patches to fedora-buildsys that work with
this patch, but those aren't in production use yet.

  -- Ken


diff -uNr yum-2.4.3-orig/ChangeLog yum-2.4.3-arch/ChangeLog
--- yum-2.4.3-orig/ChangeLog	2006-05-12 13:23:01.000000000 -0500
+++ yum-2.4.3-arch/ChangeLog	2007-03-11 17:04:56.000000000 -0500
@@ -1,3 +1,23 @@
+2007-03-11  Ken MacLeod  <ken.macleod at radisys.com>
+
+	* cli.py (YumBaseCli.installPkgs): pass configured arch to
+	returnBestPackages
+
+2006-07-31  Ken MacLeod  <ken at bitsko.slc.ut.us>
+
+	* yum/config.py (YumConf.arch): added, defaults to getCanonArch
+	(readMainConfig): use [main] arch config for substitution vars
+
+	* yum/__init__.py (YumBase.doSackSetup, YumBase.doUpdateSetup,
+	YumBase.bestPackagesFromList): use configured arch
+
+	* rpmUtils/updates.py (Updates.__init__): accept 'arch' argument
+
+	* rpmUtils/arch.py (getMultiArchInfo, getBestArch): accept an
+	'arch' argument, but not initialized at module load time
+	(canonArch): removed (not initialized at module load time)
+	(score): removed
+
 2006-05-12 14:13  skvidal
 
 	* yum-daily.spec, yum.spec, yum/__init__.py: 
diff -uNr yum-2.4.3-orig/cli.py yum-2.4.3-arch/cli.py
--- yum-2.4.3-orig/cli.py	2006-01-13 00:11:13.000000000 -0600
+++ yum-2.4.3-arch/cli.py	2007-03-11 17:03:35.000000000 -0500
@@ -915,7 +915,7 @@
         
         # this is where I could catch the installs of compat and multilib 
         # arches on a single yum install command. 
-        pkglist = returnBestPackages(toBeInstalled)
+        pkglist = returnBestPackages(toBeInstalled, self.conf.arch)
         
         # This is where we need to do a lookup to find out if this install
         # is also an obsolete. if so then we need to mark it as such in the
diff -uNr yum-2.4.3-orig/rpmUtils/arch.py yum-2.4.3-arch/rpmUtils/arch.py
--- yum-2.4.3-orig/rpmUtils/arch.py	2005-05-23 14:22:38.000000000 -0500
+++ yum-2.4.3-arch/rpmUtils/arch.py	2007-03-11 15:50:55.000000000 -0500
@@ -14,6 +14,7 @@
 arches = {
     # ia32
     "athlon": "i686",
+    "i686p4": "i686",
     "i686": "i586",
     "i586": "i486",
     "i486": "i386",
@@ -61,9 +62,6 @@
         return 0
     return 0
 
-def score(arch):
-    return archDifference(canonArch, arch)
-
 def isMultiLibArch(arch=None):
     """returns true if arch is a multilib arch, false if not"""
     if arch is None:
@@ -83,7 +81,7 @@
 def getBestArchFromList(archlist, myarch=None):
     """ 
         return the best arch from the list for myarch if - myarch is not given,
-        then return the best arch from the list for the canonArch.
+        then return the best arch from the list for getCanonArch().
     """
     
     if myarch is None:
@@ -215,7 +213,9 @@
     return arch
 
 # this gets you the "compat" arch of a biarch pair
-def getMultiArchInfo(arch = getCanonArch()):
+def getMultiArchInfo(arch=None):
+    if arch is None:
+        arch = getCanonArch()
     if multilibArches.has_key(arch):
         return multilibArches[arch]
     if arches.has_key(arch) and arches[arch] != "noarch":
@@ -225,8 +225,9 @@
 # get the best usual userspace arch for the arch we're on.  this is
 # our arch unless we're on an arch that uses the secondary as its
 # userspace (eg ppc64, sparc64)
-def getBestArch():
-    arch = canonArch
+def getBestArch(arch=None):
+    if not arch:
+        arch = getCanonArch()
 
     if arch == "sparc64":
         arch = "sparc"
@@ -237,7 +238,7 @@
     return arch
 
 def getBaseArch(myarch=None):
-    """returns 'base' arch for myarch, if specified, or canonArch if not.
+    """returns 'base' arch for myarch, if specified, or getCanonArch() if not.
        base arch is the arch before noarch in the arches dict if myarch is not
        a key in the multilibArches."""
 
@@ -266,5 +267,3 @@
             value = arches[basearch]
     
         return basearch
-        
-canonArch = getCanonArch()
diff -uNr yum-2.4.3-orig/rpmUtils/updates.py yum-2.4.3-arch/rpmUtils/updates.py
--- yum-2.4.3-orig/rpmUtils/updates.py	2005-03-26 11:40:30.000000000 -0600
+++ yum-2.4.3-arch/rpmUtils/updates.py	2007-03-11 15:50:55.000000000 -0500
@@ -25,7 +25,7 @@
        of obsoleting packages with obsoletes and what they obsolete ie:
         foo, i386, 0, 1.1, 1: bar >= 1.1."""
 
-    def __init__(self, instlist, availlist):
+    def __init__(self, instlist, availlist, arch=None):
         self.changeTup = [] # storage list tuple of updates or obsoletes
                             # (oldpkg, newpkg, ['update'|'obsolete'])
 
@@ -36,10 +36,9 @@
         self.exactarchlist = ['kernel', 'kernel-smp', 'glibc', 'kernel-hugemem',
                               'kernel-enterprise', 'kernel-bigmem', 'kernel-BOOT']
                               
-        self.myarch = rpmUtils.arch.getCanonArch() # this is for debugging only 
-                                                   # set this if you want to 
-                                                   # test on some other arch
-                                                   # otherwise leave it alone
+        if arch is None:
+            arch = rpmUtils.arch.getCanonArch()
+        self.myarch = arch
         
         # make some dicts from installed and available
         self.installdict = self.makeNADict(self.installed, 1)
diff -uNr yum-2.4.3-orig/yum/archwork.py yum-2.4.3-arch/yum/archwork.py
--- yum-2.4.3-orig/yum/archwork.py	2004-01-28 01:31:04.000000000 -0600
+++ yum-2.4.3-arch/yum/archwork.py	2007-03-11 15:50:55.000000000 -0500
@@ -67,7 +67,7 @@
 
 def compatArchList():
     archdict = {}
-    archdict['i386']=['i386','i486','i586','i686','athlon','noarch']
+    archdict['i386']=['i386','i486','i586','i686', 'i686p4','athlon','noarch']
     archdict['alpha']=['alpha','alphaev6','noarch']
     archdict['sparc']=['sparc','sparc64','noarch','sun4c','sun4u','sun4d','sun4m','sparcv9']
     archdict['ppc']=['ppc','noarch','ppc64','powerpc','powerppc','osfmach3_ppc','ppciseries','ppcpseries','rs6000']
diff -uNr yum-2.4.3-orig/yum/config.py yum-2.4.3-arch/yum/config.py
--- yum-2.4.3-orig/yum/config.py	2006-05-12 13:06:55.000000000 -0500
+++ yum-2.4.3-arch/yum/config.py	2007-03-11 15:50:55.000000000 -0500
@@ -207,6 +207,7 @@
         #defaults -either get them or set them
         optionstrings = [('cachedir', '/var/cache/yum'), 
                          ('logfile', '/var/log/yum.log'), 
+                         ('arch', rpmUtils.arch.getCanonArch()),
                          ('reposdir', ['/etc/yum/repos.d', '/etc/yum.repos.d']),
                          ('syslog_ident', None),
                          ('syslog_facility', 'LOG_DAEMON'),
@@ -267,9 +268,12 @@
 
         # get our variables parsed
         self.yumvar = self._getEnvVar()
-        self.yumvar['basearch'] = rpmUtils.arch.getBaseArch() # FIXME make this configurable??
-        self.yumvar['arch'] = rpmUtils.arch.getCanonArch() # FIXME make this configurable??
-        # figure out what the releasever really is from the distroverpkg
+        self.yumvar['arch'] = self.cfg._getoption('main', 'arch',
+                                                  rpmUtils.arch.getCanonArch())
+        self.yumvar['basearch'] \
+          = rpmUtils.arch.getBaseArch(self.cfg._getoption('main',
+                                                          'arch',
+                                                          rpmUtils.arch.getCanonArch()))
         self.yumvar['releasever'] = self._getsysver()
 
         # do the ints
diff -uNr yum-2.4.3-orig/yum/__init__.py yum-2.4.3-arch/yum/__init__.py
--- yum-2.4.3-orig/yum/__init__.py	2006-05-12 13:07:50.000000000 -0500
+++ yum-2.4.3-arch/yum/__init__.py	2007-03-11 15:50:55.000000000 -0500
@@ -250,7 +250,7 @@
             
         self.log(3, 'Setting up Package Sacks')
         if not archlist:
-            archlist = rpmUtils.arch.getArchList()
+            archlist = rpmUtils.arch.getArchList(self.conf.arch)
 
         archdict = {}
         for arch in archlist:
@@ -282,7 +282,8 @@
             self.doSackSetup()
 
         self.up = rpmUtils.updates.Updates(self.rpmdb.getPkgList(),
-                                           self.pkgSack.simplePkgList())
+                                           self.pkgSack.simplePkgList(),
+                                           arch=self.conf.arch)
         if self.conf.getConfigOption('debuglevel') >= 6:
             self.up.debug = 1
             




More information about the Yum-devel mailing list