[Yum] Partial updates/installs/etc

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

 



> >   Another feature that would be useful...
> >                     ...... is the ability to install
> > (or update or whatever) packages from just one of the
> > repositories listed in the yum.conf file.

>   if you want to just use one repo I'd recommend a separate conf file
> with just that repo then yum -c foo.conf mycommands here

Hmmm.... that feels a bit cumbersome.
It loses the ability to operate on all repositories at once,
and means I'd have to maintain separate config files for each
individual repository  (and keep the 'main' sections consistent)


I offer the following patch to support operation on an individual
repository:

*** yummain.py.cln	2003-08-15 05:35:20.000000000 +0100
--- yummain.py	2003-08-19 13:43:49.000000000 +0100
***************
*** 41,52 ****
      errorlog=Logger(threshold=2, file_object=sys.stderr)
  
      # our default config file location
      yumconffile=None
      if os.access("/etc/yum.conf", os.R_OK):
          yumconffile="/etc/yum.conf"
          
      try:
!         gopts, cmds = getopt.getopt(args, 'tCc:hR:e:d:y', ['help', 'version', 'installroot='])
      except getopt.error, e:
          errorlog(0, _('Options Error: %s') % e)
          usage()
--- 41,53 ----
      errorlog=Logger(threshold=2, file_object=sys.stderr)
  
      # our default config file location
+     yumserver=None
      yumconffile=None
      if os.access("/etc/yum.conf", os.R_OK):
          yumconffile="/etc/yum.conf"
          
      try:
!         gopts, cmds = getopt.getopt(args, 'tCc:hs:R:e:d:y', ['help', 'version', 'installroot='])
      except getopt.error, e:
          errorlog(0, _('Options Error: %s') % e)
          usage()
***************
*** 65,73 ****
                  time.sleep(sleeptime)
              if o == '-c':
                  yumconffile=a
  
          if yumconffile:
!             conf=yumconf(configfile=yumconffile)
          else:
              errorlog(0, _('Cannot find any conf file.'))
              sys.exit(1)
--- 66,79 ----
                  time.sleep(sleeptime)
              if o == '-c':
                  yumconffile=a
+             if o == '-s':
+                 yumserver=a
  
          if yumconffile:
!             if yumserver:
!                 conf=yumconf(configfile=yumconffile, server=yumserver)
!             else:
!                 conf=yumconf(configfile=yumconffile)
          else:
              errorlog(0, _('Cannot find any conf file.'))
              sys.exit(1)
***************
*** 340,345 ****
--- 346,352 ----
            -d [debug level] - set the debugging level
            -y answer yes to all questions
            -t be tolerant about errors in package commands
+           -s [serverid] - process the specified server section only
            -R [time in minutes] - set the max amount of time to randonly run in.
            -C run from cache only - do not update the cache
            --installroot=[path] - set the install root (default '/')
*** config.py.cln	2003-08-19 13:19:24.000000000 +0100
--- config.py	2003-08-19 13:44:10.000000000 +0100
***************
*** 32,38 ****
  
  class yumconf:
  
!     def __init__(self, configfile = '/etc/yum.conf'):
          self.cfg = ConfigParser.ConfigParser()
          (s,b,p,q,f,o) = urlparse.urlparse(configfile)
          if s in ('http', 'ftp','file'):
--- 32,38 ----
  
  class yumconf:
  
!     def __init__(self, configfile = '/etc/yum.conf', server=None ):
          self.cfg = ConfigParser.ConfigParser()
          (s,b,p,q,f,o) = urlparse.urlparse(configfile)
          if s in ('http', 'ftp','file'):
***************
*** 127,133 ****
  
          if len(self.cfg.sections()) > 1:
              for section in self.cfg.sections(): # loop through the list of sections
!                 if section != 'main': # must be a serverid
                      if self._getoption(section, 'baseurl') != None:
                          name = self._getoption(section, 'name')
                          urls = self._getoption(section, 'baseurl')
--- 127,133 ----
  
          if len(self.cfg.sections()) > 1:
              for section in self.cfg.sections(): # loop through the list of sections
!                 if section != 'main' and (not server or section == server): # must be a serverid
                      if self._getoption(section, 'baseurl') != None:
                          name = self._getoption(section, 'name')
                          urls = self._getoption(section, 'baseurl')




I'm not an experience python programmer, so there may well be a better
way to do this.  But it seems to operate as required.
   Obviously, it's totally up to you whether you want to include this
in the official distribution.  But it's definitely something we'll be
adopting here.

Dave


[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