[Yum] more about: passing two or more variables from a python routine.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 28 Sep 2004, Rick Graves wrote:

> Robert,
> 
> The subroutine can pass back expressions -- they do
> not have to be reduced to variables.
> 
> So the last line of the subroutine could be:
> 
>    return expr1, expr2, ...
> 
> Rick

Thanks!  In which case the patch looks like the following (at the end).

Seems to (still) work, sets distribution to "redhat-release" on my RH9
system.

It has occurred to me that a useful yum option would be:

  yum showvar [distribution,releasever,basearch]

to produce the respective output:

  distribution
  releasever
  basearch

The reason that would be useful is it would show how yum will expand the
variables in a yum.conf (good for admins) and it would allow relocatable
Makefiles to be built that do things like:

DISTRO=`yum showvar distribution`
DISTVER=`yum showvar releasever`
BASEARCH=`yum showvar basearch`
REPO_PATH = /home/rgb/public_html/my_yum/$(DISTRO)/$(DISTVER)/$(BASEARCH)

(good for developers).  For example, one could fairly easily build an
rpm and drop it into just the right place (and even rerun yum-arch on
that place) with a single make target.

However, I won't push my luck with Seth... he hasn't yet said excited
things about the patch and may even be thinking Bad Thoughts about it
even without cracking it way up.  ;-)

If I really want it I can easily write a python or perl script that does
only this and call it inside my makefiles.  If Seth accepts this one
measly little patch, I can get on with posting just ONE yum.conf to
accompany my rgb-ware distribution scheme...:-)

   rgb

-- 
Robert G. Brown	                       http://www.phy.duke.edu/~rgb/
Duke University Dept. of Physics, Box 90305
Durham, N.C. 27708-0305
Phone: 1-919-660-2567  Fax: 919-660-2525     email:rgb@xxxxxxxxxxxx

%< snip snip snip =====================================================
--- config.py	2004-05-07 00:58:34.000000000 -0400
+++ config.py.new	2004-09-28 16:25:41.000000000 -0400
@@ -152,7 +152,7 @@
             
             
         # figure out what the releasever really is from the distroverpkg
-        self.yumvar['releasever'] = self._getsysver()
+        self.yumvar['distribution'],self.yumvar['releasever'] = self._getsysver()
         
         if self._getoption('main','commands') != None:
             self.commands = self._getoption('main', 'commands')
@@ -284,16 +284,22 @@
         ts.setVSFlags(~(rpm._RPMVSF_NOSIGNATURES|rpm._RPMVSF_NODIGESTS))
         idx = ts.dbMatch('provides', self.distroverpkg)
         # we're going to take the first one - if there is more than one of these
-        # then the user needs a beating
+        # then the user needs a beating.  This sets the value of the
+        # distribution variable to the name of the distro-release rpm.
+        # In most cases this will be e.g. redhat-release, fedora-release,
+        # centos-release.  Or create your own "distro-release-version.rpm"
+        # that provides distroverpkg.
         if idx.count() == 0:
+            distribution = 'unknown'
             releasever = 'Null'
         else:
             hdr = idx.next()
+            distribution = hdr['name']
             releasever = hdr['version']
             del hdr
         del idx
         del ts
-        return releasever
+        return distribution,releasever
     
     def _getEnvVar(self):
         yumvar = {}
@@ -318,6 +324,7 @@
         basearch_reg = re.compile('\$basearch')
         arch_reg = re.compile('\$arch')
         releasever_reg = re.compile('\$releasever')
+        distribution_reg = re.compile('\$distribution')
         yum0_reg = re.compile('\$YUM0')
         yum1_reg = re.compile('\$YUM1')
         yum2_reg = re.compile('\$YUM2')
@@ -332,6 +339,7 @@
         (string, count) = basearch_reg.subn(self.yumvar['basearch'], string)
         (string, count) = arch_reg.subn(self.yumvar['arch'], string)
         (string, count) = releasever_reg.subn(self.yumvar['releasever'], string)
+        (string, count) = distribution_reg.subn(self.yumvar['distribution'], string)
         (string, count) = yum0_reg.subn(self.yumvar[0], string)
         (string, count) = yum1_reg.subn(self.yumvar[1], string)
         (string, count) = yum2_reg.subn(self.yumvar[2], string)


[Index of Archives]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]

  Powered by Linux