update to newer version
[yum.git] / yum-3.2.27-chroot.patch
1 diff -ur yum-3.2.27.orig/cli.py yum-3.2.27/cli.py
2 --- yum-3.2.27.orig/cli.py      2010-03-03 20:09:36.000000000 -0500
3 +++ yum-3.2.27/cli.py   2010-03-23 16:24:21.313420546 -0400
4 @@ -1278,13 +1278,15 @@
5      def getRoot(self,opts):
6          # If the conf file is inside the  installroot - use that.
7          # otherwise look for it in the normal root
8 +        if opts.conffile is None:
9 +            opts.conffile = '/etc/yum/yum.conf'
10 +            if opts.installroot:
11 +                if os.access(opts.installroot+opts.conffile, os.R_OK):
12 +                    opts.conffile = opts.installroot+opts.conffile
13 +                elif os.access(opts.installroot+'/etc/yum.conf', os.R_OK):
14 +                    opts.conffile = opts.installroot+'/etc/yum.conf'
15 +
16          if opts.installroot:
17 -            if os.access(opts.installroot+'/'+opts.conffile, os.R_OK):
18 -                opts.conffile = opts.installroot+'/'+opts.conffile
19 -            elif opts.conffile == '/etc/yum/yum.conf':
20 -                # check if /installroot/etc/yum.conf exists.
21 -                if os.access(opts.installroot+'/etc/yum.conf', os.R_OK):
22 -                    opts.conffile = opts.installroot+'/etc/yum.conf'         
23              root=opts.installroot
24          else:
25              root = '/'
26 @@ -1325,7 +1327,7 @@
27                  action="store_true",
28                  help=_("run entirely from system cache, don't update cache"))
29          group.add_option("-c", "--config", dest="conffile",
30 -                default='/etc/yum/yum.conf',
31 +                default=None,
32                  help=_("config file location"), metavar='[config file]')
33          group.add_option("-R", "--randomwait", dest="sleeptime", type='int',
34                  default=None,
35 diff -ur yum-3.2.27.orig/yum/config.py yum-3.2.27/yum/config.py
36 --- yum-3.2.27.orig/yum/config.py       2010-03-23 16:13:48.022914313 -0400
37 +++ yum-3.2.27/yum/config.py    2010-03-23 16:26:57.116806313 -0400
38 @@ -603,7 +603,27 @@
39      syslog_ident = Option()
40      syslog_facility = Option('LOG_DAEMON')
41      persistdir = Option('/var/lib/yum')
42 -    
43 +
44 +    def getRootedPath(self, path, enforce_default=False, defaults_to_host=False):
45 +        instroot = self.installroot
46 +        if instroot is None:
47 +            return path
48 +
49 +        if   path.startswith('hostfs://'):   res = path[9:]
50 +        elif path.startswith('chrootfs://'): res = instroot + '/' + path[11:]
51 +        else:
52 +            tmp = instroot + '/' + path
53 +
54 +            if enforce_default:
55 +                if defaults_to_host:    res = path
56 +                else:                   res = tmp
57 +            else:
58 +                if os.path.exists(tmp): res = tmp
59 +                elif defaults_to_host:  res = path
60 +                else:                   res = tmp
61 +
62 +        return res
63
64  class YumConf(StartupConf):
65      '''
66      Configuration option definitions for yum.conf\'s [main] section.
67 @@ -617,6 +637,7 @@
68  
69      keepcache = BoolOption(True)
70      logfile = Option('/var/log/yum.log')
71 +    lockfile = Option('/var/run/yum.pid')
72      reposdir = ListOption(['/etc/yum/repos.d', '/etc/yum.repos.d'])
73  
74      commands = ListOption()
75 @@ -859,9 +880,9 @@
76      yumconf.populate(startupconf._parser, 'main')
77  
78      # Apply the installroot to directory options
79 -    for option in ('cachedir', 'logfile', 'persistdir'):
80 +    for option in ('cachedir', 'logfile', 'lockfile', 'persistdir'):
81          path = getattr(yumconf, option)
82 -        ir_path = yumconf.installroot + path
83 +        ir_path = yumconf.getRootedPath(path)
84          ir_path = ir_path.replace('//', '/') # os.path.normpath won't fix this and
85                                               # it annoys me
86          ir_path = varReplace(ir_path, yumvars)
87 diff -ur yum-3.2.27.orig/yum/__init__.py yum-3.2.27/yum/__init__.py
88 --- yum-3.2.27.orig/yum/__init__.py     2010-03-18 12:28:57.000000000 -0400
89 +++ yum-3.2.27/yum/__init__.py  2010-03-23 16:27:43.617623958 -0400
90 @@ -398,8 +398,7 @@
91              # this check makes sure that our dirs exist properly.
92              # if they aren't in the installroot then don't prepend the installroot path
93              # if we don't do this then anaconda likes to not  work.
94 -            if os.path.exists(self.conf.installroot+'/'+reposdir):
95 -                reposdir = self.conf.installroot + '/' + reposdir
96 +            reposdir = self.conf.getRootedPath(reposdir)            
97  
98              if os.path.isdir(reposdir):
99                  for repofn in sorted(glob.glob('%s/*.repo' % reposdir)):
100 @@ -1377,10 +1376,8 @@
101          if self.conf.uid != 0:
102              return
103              
104 -        root = self.conf.installroot
105 -        lockfile = root + '/' + lockfile # lock in the chroot
106 -        lockfile = os.path.normpath(lockfile) # get rid of silly preceding extra /
107 -        
108 +        lockfile = self.conf.lockfile
109
110          mypid=str(os.getpid())    
111          while not self._lock(lockfile, mypid, 0644):
112              fd = open(lockfile, 'r')