1 diff -Nurp yum-3.2.19.orig/cli.py yum-3.2.19/cli.py
2 --- yum-3.2.19.orig/cli.py 2008-08-19 21:31:11.000000000 +0200
3 +++ yum-3.2.19/cli.py 2008-09-29 02:50:02.000000000 +0200
4 @@ -1099,13 +1099,14 @@ class YumOptionParser(OptionParser):
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==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'
16 - if os.access(opts.installroot+'/'+opts.conffile, os.R_OK):
17 - opts.conffile = opts.installroot+'/'+opts.conffile
18 - elif opts.conffile == '/etc/yum/yum.conf':
19 - # check if /installroot/etc/yum.conf exists.
20 - if os.access(opts.installroot+'/etc/yum.conf', os.R_OK):
21 - opts.conffile = opts.installroot+'/etc/yum.conf'
25 @@ -1139,7 +1140,7 @@ class YumOptionParser(OptionParser):
26 help=_("be tolerant of errors"))
27 self.add_option("-C", dest="cacheonly", action="store_true",
28 help=_("run entirely from cache, don't update cache"))
29 - self.add_option("-c", dest="conffile", default='/etc/yum/yum.conf',
30 + self.add_option("-c", dest="conffile", default=None,
31 help=_("config file location"), metavar=' [config file]')
32 self.add_option("-R", dest="sleeptime", type='int', default=None,
33 help=_("maximum command wait time"), metavar=' [minutes]')
34 diff -Nurp yum-3.2.19.orig/docs/yum.conf.5 yum-3.2.19/docs/yum.conf.5
35 --- yum-3.2.19.orig/docs/yum.conf.5 2008-08-06 19:39:50.000000000 +0200
36 +++ yum-3.2.19/docs/yum.conf.5 2008-09-29 02:50:02.000000000 +0200
37 @@ -23,8 +23,10 @@ The [main] section must exist for yum to
41 -Directory where yum should store its cache and db files. The default is
43 +Directory where yum should store its cache and db files. The default
44 +is `/var/cache/yum'. Unless the prefixes `hostfs://' or `chrootfs://'
45 +are used, some magic will be applied to determine the real path in
46 +combination with `--installroot'.
49 Directory where yum should store information that should persist over multiple
50 @@ -44,6 +46,10 @@ documented in \fB[repository] options\fR
51 repositories defined in /etc/yum/yum.conf to form the complete set of
52 repositories that yum will use.
54 +Unless the prefixes `hostfs://' or `chrootfs://' are used, some magic
55 +will be applied to determine the real path in combination with
59 Debug message output level. Practical range is 0\-10. Default is `2'.
61 @@ -51,7 +57,10 @@ Debug message output level. Practical ra
62 Error message output level. Practical range is 0\-10. Default is `2'.
65 -Full directory and file name for where yum should write its log file.
66 +Full directory and file name for where yum should write its log
67 +file. Unless the prefixes `hostfs://' or `chrootfs://' are used,
68 +some magic will be applied to determine the real path in combination
69 +with `--installroot'.
72 Either `1' or `0'. This tells yum whether or not it should perform a GPG
73 diff -Nurp yum-3.2.19.orig/yum/config.py yum-3.2.19/yum/config.py
74 --- yum-3.2.19.orig/yum/config.py 2008-08-19 21:31:11.000000000 +0200
75 +++ yum-3.2.19/yum/config.py 2008-09-29 02:50:49.000000000 +0200
76 @@ -588,6 +588,27 @@ class StartupConf(BaseConfig):
77 syslog_ident = Option()
78 syslog_facility = Option('LOG_DAEMON')
80 + def getRootedPath(self, option, enforce_default=False, defaults_to_host=False):
81 + path = getattr(self, option)
82 + instroot = getattr(self, 'installroot', None)
86 + if path.startswith('hostfs://'): res = path[9:]
87 + elif path.startswith('chrootfs://'): res = instroot + '/' + path[11:]
89 + tmp = instroot + '/' + path
92 + if defaults_to_host: res = path
95 + if os.path.exists(tmp): res = tmp
96 + elif defaults_to_host: res = path
101 class YumConf(StartupConf):
103 Configuration option definitions for yum.conf\'s [main] section.
104 @@ -601,6 +622,7 @@ class YumConf(StartupConf):
105 persistdir = Option('/var/lib/yum')
106 keepcache = BoolOption(True)
107 logfile = Option('/var/log/yum.log')
108 + lockfile = Option('/var/run/yum.pid')
109 reposdir = ListOption(['/etc/yum/repos.d', '/etc/yum.repos.d'])
111 commands = ListOption()
112 @@ -757,9 +779,8 @@ def readMainConfig(startupconf):
113 yumconf.populate(startupconf._parser, 'main')
115 # Apply the installroot to directory options
116 - for option in ('cachedir', 'logfile', 'persistdir'):
117 - path = getattr(yumconf, option)
118 - setattr(yumconf, option, yumconf.installroot + path)
119 + for option in ('cachedir', 'logfile', 'lockfile'):
120 + setattr(yumconf, option, yumconf.getRootedPath(option))
122 # Add in some extra attributes which aren't actually configuration values
123 yumconf.yumvar = yumvars
124 diff -Nurp yum-3.2.19.orig/yum/__init__.py yum-3.2.19/yum/__init__.py
125 --- yum-3.2.19.orig/yum/__init__.py 2008-08-26 21:37:17.000000000 +0200
126 +++ yum-3.2.19/yum/__init__.py 2008-09-29 02:50:02.000000000 +0200
127 @@ -288,8 +288,7 @@ class YumBase(depsolve.Depsolve):
128 self.getReposFromConfigFile(self.conf.config_file_path, repo_config_age)
130 for reposdir in self.conf.reposdir:
131 - if os.path.exists(self.conf.installroot+'/'+reposdir):
132 - reposdir = self.conf.installroot + '/' + reposdir
133 + reposdir = self.conf.getRootedPath(reposdir)
135 if os.path.isdir(reposdir):
136 for repofn in glob.glob('%s/*.repo' % reposdir):
137 @@ -933,11 +932,9 @@ class YumBase(depsolve.Depsolve):
138 # if we're not root then we don't lock - just return nicely
139 if self.conf.uid != 0:
142 - root = self.conf.installroot
143 - lockfile = root + '/' + lockfile # lock in the chroot
144 - lockfile = os.path.normpath(lockfile) # get rid of silly preceding extra /
147 + lockfile = self.conf.lockfile
149 mypid=str(os.getpid())
150 while not self._lock(lockfile, mypid, 0644):
151 fd = open(lockfile, 'r')
152 diff -Nurp yum-3.2.19.orig/yum/rpmtrans.py yum-3.2.19/yum/rpmtrans.py
153 --- yum-3.2.19.orig/yum/rpmtrans.py 2008-08-26 21:40:17.000000000 +0200
154 +++ yum-3.2.19/yum/rpmtrans.py 2008-09-29 02:50:21.000000000 +0200
155 @@ -227,7 +227,7 @@ class RPMTransaction:
157 if not hasattr(self, '_ts_done'):
158 # need config variable to put this in a better path/name
159 - te_fn = '%s/transaction-done.%s' % (self.base.conf.persistdir, self._ts_time)
160 + te_fn = '%s/transaction-done.%s' % (self.base.conf.getRootedPath('persistdir'), self._ts_time)
161 self.ts_done_fn = te_fn
163 self._ts_done = open(te_fn, 'w')