1 --- yum-2.2.1/docs/yum.conf.5.chroot 2005-02-19 23:30:54.000000000 +0100
2 +++ yum-2.2.1/docs/yum.conf.5 2005-04-08 19:53:02.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 Directory where yum should look for .repo files for its configuration
17 repository options below. These will be merged with the repositories defined
18 in /etc/yum.conf to form the complete set of repositories that yum will use.
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.2.1/yum/__init__.py.chroot 2005-03-15 08:34:03.000000000 +0100
40 +++ yum-2.2.1/yum/__init__.py 2005-04-08 20:10:36.000000000 +0200
42 self.log(3, 'Arch Excluding %s' % po)
43 self.pkgSack.delPackage(po)
44 self.log(2, 'Finished')
46 + def __getLockfileName(self):
47 + lockfile = self.conf.configdata['lockfile']
48 + return self.conf.getRootedPath(lockfile,
49 + enforce_default = True,
50 + defaults_to_host = False)
54 - def doLock(self, lockfile):
56 """perform the yum locking, raise yum-based exceptions, not OSErrors"""
58 # if we're not root then we don't lock - just return nicely
59 if self.conf.getConfigOption('uid') != 0:
62 - root = self.conf.installroot
63 - lockfile = root + '/' + lockfile # lock in the chroot
65 + lockfile=self.__getLockfileName()
67 mypid=str(os.getpid())
68 while not self._lock(lockfile, mypid, 0644):
69 fd = open(lockfile, 'r')
71 msg = 'Existing lock %s: another copy is running. Aborting.' % lockfile
72 raise Errors.LockError(0, msg)
74 - def doUnlock(self, lockfile):
76 """do the unlock for yum"""
78 # if we're not root then we don't lock - just return nicely
79 if self.conf.getConfigOption('uid') != 0:
82 - root = self.conf.installroot
83 - lockfile = root + '/' + lockfile # lock in the chroot
84 + lockfile=self.__getLockfileName()
86 self._unlock(lockfile)
88 --- yum-2.2.1/yum/config.py.chroot 2005-03-15 07:09:18.000000000 +0100
89 +++ yum-2.2.1/yum/config.py 2005-04-08 19:53:02.000000000 +0200
92 #defaults -either get them or set them
93 optionstrings = [('cachedir', '/var/cache/yum'),
94 - ('logfile', '/var/log/yum.log'),
95 + ('logfile', '/var/log/yum.log'),
96 + ('lockfile', '/var/run/yum.pid'),
97 ('reposdir', '/etc/yum.repos.d'),
98 ('rss-filename', 'yum-rss.xml'),
99 ('pkgpolicy', 'newest'),
102 # do the dirs - set the root if there is one (grumble)
103 for option in ['cachedir', 'logfile']:
104 - path = self.configdata[option]
105 - root = self.configdata['installroot']
106 - rootedpath = root + path
107 + rootedpath = self.getRootedPath(self.configdata[option])
108 self.configdata[option] = rootedpath
109 setattr(self, option, rootedpath)
112 # read each of them in using confpp, then parse them same as any other repo
113 # section - as above.
114 reposdir = self.getConfigOption('reposdir')
115 - if os.path.exists(self.getConfigOption('installroot') + '/' + reposdir):
116 - reposdir = self.getConfigOption('installroot') + '/' + reposdir
117 + reposdir = self.getRootedPath(reposdir)
119 reposglob = reposdir + '/*.repo'
120 if os.path.exists(reposdir) and os.path.isdir(reposdir):
125 + def getRootedPath(self, path, enforce_default=False, defaults_to_host=False):
126 + instroot = self.configdata['installroot']
127 + if path.startswith('hostfs://'): res = path[9:]
128 + elif path.startswith('chrootfs://'): res = instroot + '/' + path[11:]
130 + tmp = instroot + '/' +path
132 + if enforce_default:
133 + if defaults_to_host: res = path
136 + if os.path.exists(tmp): res = tmp
137 + elif defaults_to_host: res = path
142 def listConfigOptions(self):
143 """return list of options available for global config"""
144 return self.configdata.keys()
145 --- yum-2.2.1/cli.py.chroot 2005-03-15 08:19:11.000000000 +0100
146 +++ yum-2.2.1/cli.py 2005-04-08 19:53:02.000000000 +0200
151 - conffile = '/etc/yum.conf'
156 @@ -140,12 +140,14 @@
158 # if the conf file is inside the installroot - use that.
159 # otherwise look for it in the normal root
161 - if os.access(installroot + '/' + conffile, os.R_OK):
163 + conffile = '/etc/yum.conf'
164 + if installroot and os.access(installroot + '/' + conffile, os.R_OK):
165 conffile = installroot + '/' + conffile
173 self.conf = yumconf(configfile = conffile, root = root)
174 except yum.Errors.ConfigError, e:
175 --- yum-2.2.1/yummain.py.chroot 2005-01-07 14:45:50.000000000 +0100
176 +++ yum-2.2.1/yummain.py 2005-04-08 19:53:02.000000000 +0200
181 - base.doUnlock('/var/run/yum.pid')
183 except Errors.LockError, e:
190 - base.doLock('/var/run/yum.pid')
192 except Errors.LockError, e:
193 base.errorlog(0,'%s' % e.msg)