1 --- yum-2.3.2/docs/yum.conf.5.chroot 2005-03-25 11:12:20.000000000 +0100
2 +++ yum-2.3.2/docs/yum.conf.5 2005-04-08 18:27:12.000000000 +0200
7 -Directory where yum should store its cache and db files. The default is
9 +Directory where yum should store its cache and db files. The default
10 +is `/var/cache/yum'. Unless the prefixes `hostfs://' or `chrootfs://'
11 +are used, some magic will be applied to determine the real path in
12 +combination with `--installroot'.
15 A list of directories where yum should look for .repo files which define
17 repositories defined in /etc/yum.conf to form the complete set of repositories
20 +Unless the prefixes `hostfs://' or `chrootfs://' are used, some magic
21 +will be applied to determine the real path in combination with
25 Debug message output level. Practical range is 0\-10. Default is `2'.
28 Error message output level. Practical range is 0\-10. Default is `2'.
31 -Full directory and file name for where yum should write its log file.
32 +Full directory and file name for where yum should write its log
33 +file. Unless the prefixes `hostfs://' or `chrootfs://' are used,
34 +some magic will be applied to determine the real path in combination
35 +with `--installroot'.
38 Either `1' or `0'. This tells yum whether or not it should perform a GPG
39 --- yum-2.3.2/yum/__init__.py.chroot 2005-04-04 20:14:18.000000000 +0200
40 +++ yum-2.3.2/yum/__init__.py 2005-04-08 20:11:06.000000000 +0200
42 # read each of them in using confpp, then parse them same as any other repo
44 for reposdir in self.conf.reposdir:
45 - if os.path.exists(self.conf.installroot + '/' + reposdir):
46 - reposdir = self.conf.installroot + '/' + reposdir
48 + reposdir = self.conf.getRootedPath(reposdir)
50 if os.path.isdir(reposdir):
51 repofn = glob.glob(reposdir+'/*.repo')
54 self.pkgSack.excludeArchs(archlist)
55 self.log(3, 'Finished')
57 + def __getLockfileName(self):
58 + lockfile = self.conf.configdata['lockfile']
59 + return self.conf.getRootedPath(lockfile,
60 + enforce_default = True,
61 + defaults_to_host = False)
64 - def doLock(self, lockfile):
66 """perform the yum locking, raise yum-based exceptions, not OSErrors"""
68 # if we're not root then we don't lock - just return nicely
69 if self.conf.getConfigOption('uid') != 0:
72 - root = self.conf.installroot
73 - lockfile = root + '/' + lockfile # lock in the chroot
75 + lockfile=self.__getLockfileName()
77 mypid=str(os.getpid())
78 while not self._lock(lockfile, mypid, 0644):
80 msg = 'Existing lock %s: another copy is running. Aborting.' % lockfile
81 raise Errors.LockError(0, msg)
83 - def doUnlock(self, lockfile):
85 """do the unlock for yum"""
87 # if we're not root then we don't lock - just return nicely
88 if self.conf.getConfigOption('uid') != 0:
91 - root = self.conf.installroot
92 - lockfile = root + '/' + lockfile # lock in the chroot
93 + lockfile=self.__getLockfileName()
95 self._unlock(lockfile)
97 --- yum-2.3.2/yum/config.py.chroot 2005-03-28 00:01:22.000000000 +0200
98 +++ yum-2.3.2/yum/config.py 2005-04-08 20:09:25.000000000 +0200
101 #defaults -either get them or set them
102 optionstrings = [('cachedir', '/var/cache/yum'),
103 - ('logfile', '/var/log/yum.log'),
104 + ('logfile', '/var/log/yum.log'),
105 + ('lockfile', '/var/run/yum.pid'),
106 ('reposdir', ['/etc/yum/repos.d', '/etc/yum.repos.d']),
107 ('syslog_ident', None),
108 ('syslog_facility', 'LOG_USER'),
111 # do the dirs - set the root if there is one (grumble)
112 for option in ['cachedir', 'logfile']:
113 - path = self.configdata[option]
114 - root = self.configdata['installroot']
115 - rootedpath = root + path
116 + rootedpath = self.getRootedPath(self.configdata[option])
117 self.configdata[option] = rootedpath
118 setattr(self, option, rootedpath)
121 "All plugin search paths must be absolute")
124 + def getRootedPath(self, path, enforce_default=False, defaults_to_host=False):
125 + instroot = self.configdata['installroot']
126 + if path.startswith('hostfs://'): res = path[9:]
127 + elif path.startswith('chrootfs://'): res = instroot + '/' + path[11:]
129 + tmp = instroot + '/' +path
131 + if enforce_default:
132 + if defaults_to_host: res = path
135 + if os.path.exists(tmp): res = tmp
136 + elif defaults_to_host: res = path
141 def listConfigOptions(self):
142 """return list of options available for global config"""
143 return self.configdata.keys()
145 # read each of them in using confpp, then parse them same as any other repo
146 # section - as above.
148 - reposdir = conf.reposdir
149 - if os.path.exists(conf.installroot + '/' + reposdir):
150 - reposdir = conf.installroot + '/' + reposdir
151 + reposdir = conf.getRootedPath(conf.reposdir)
153 reposglob = reposdir + '/*.repo'
154 if os.path.exists(reposdir) and os.path.isdir(reposdir):
155 --- yum-2.3.2/cli.py.chroot 2005-03-28 05:18:03.000000000 +0200
156 +++ yum-2.3.2/cli.py 2005-04-08 18:27:12.000000000 +0200
161 - conffile = '/etc/yum.conf'
166 @@ -129,12 +129,14 @@
168 # if the conf file is inside the installroot - use that.
169 # otherwise look for it in the normal root
171 + conffile = '/etc/yum.conf'
172 + if installroot and os.access(installroot + '/' + conffile, os.R_OK):
173 + conffile = installroot + '/' + conffile
176 - if os.access(installroot + '/' + conffile, os.R_OK):
177 - conffile = installroot + '/' + conffile
184 self.doConfigSetup(fn = conffile, root = root)
185 except yum.Errors.ConfigError, e:
186 --- yum-2.3.2/yummain.py.chroot 2005-03-27 07:39:17.000000000 +0200
187 +++ yum-2.3.2/yummain.py 2005-04-08 18:27:12.000000000 +0200
192 - base.doUnlock('/var/run/yum.pid')
194 except Errors.LockError, e:
201 - base.doLock('/var/run/yum.pid')
203 except Errors.LockError, e:
204 base.errorlog(0,'%s' % e.msg)