[yum-commits] Branch 'yum-3_2_X' - 4 commits - docs/yum.conf.5 yum/config.py yum/__init__.py yum/misc.py
skvidal at osuosl.org
skvidal at osuosl.org
Thu Feb 4 21:51:31 UTC 2010
docs/yum.conf.5 | 6 ++++++
yum/__init__.py | 8 ++++++--
yum/config.py | 11 ++++++++---
yum/misc.py | 24 ++++++++++++++++++++++++
4 files changed, 44 insertions(+), 5 deletions(-)
New commits:
commit f62af5f55fade08bbb9e56023f3a27d41a7adb78
Merge: 7d22147... 3dffdd1...
Author: Seth Vidal <skvidal at fedoraproject.org>
Date: Thu Feb 4 16:51:46 2010 -0500
Merge branch 'yum-3_2_X' of ssh://yum.baseurl.org/srv/projects/yum/git/yum into yum-3_2_X
* 'yum-3_2_X' of ssh://yum.baseurl.org/srv/projects/yum/git/yum:
Another fix for verify, shell=True doesn't work with array args.
commit 7d22147b73d5465176e9728b5ea182480df7ff4d
Author: Seth Vidal <skvidal at fedoraproject.org>
Date: Thu Feb 4 16:22:06 2010 -0500
make persistdir a startupconf option
so we don't have to hardcode the path to it in yumvar options.
diff --git a/yum/config.py b/yum/config.py
index aa1583d..ad8db7e 100644
--- a/yum/config.py
+++ b/yum/config.py
@@ -602,7 +602,8 @@ class StartupConf(BaseConfig):
gaftonmode = BoolOption(False)
syslog_ident = Option()
syslog_facility = Option('LOG_DAEMON')
-
+ persistdir = Option('/var/lib/yum')
+
class YumConf(StartupConf):
'''
Configuration option definitions for yum.conf\'s [main] section.
@@ -613,7 +614,7 @@ class YumConf(StartupConf):
recent = IntOption(7, range_min=0)
cachedir = Option('/var/cache/yum')
- persistdir = Option('/var/lib/yum')
+
keepcache = BoolOption(True)
logfile = Option('/var/log/yum.log')
reposdir = ListOption(['/etc/yum/repos.d', '/etc/yum.repos.d'])
@@ -833,7 +834,8 @@ def readStartupConfig(configfile, root):
startupconf._parser = parser
# setup the release ver here
startupconf.releasever = _getsysver(startupconf.installroot, startupconf.distroverpkg)
- startupconf.uuid = get_uuid(startupconf.installroot + '/var/lib/yum/uuid')
+ uuidfile = '%s/%s/uuid' % (startupconf.installroot, startupconf.persistdir)
+ startupconf.uuid = get_uuid(uuidfile)
return startupconf
commit 66afb391409fc721412d8e474372861e8563fec0
Merge: 573f11e... 32b079e...
Author: Seth Vidal <skvidal at fedoraproject.org>
Date: Thu Feb 4 15:32:00 2010 -0500
Merge branch 'yum-3_2_X' of ssh://yum.baseurl.org/srv/projects/yum/git/yum into yum-3_2_X
* 'yum-3_2_X' of ssh://yum.baseurl.org/srv/projects/yum/git/yum:
Fix a couple of typos for pkg.verify(), sizes are weird in edge cases:
catch YumBaseErrors in utils (rhbz #523145)
Remove the extra seconds in the .sqlite loading (sucks to be apt ;)
Only show dates for commits, in --version
Hack the changelog timestamps, so that ordering by timestamps alone
commit 573f11e7ea790c61c690eb7039301ce0a3e4c8e1
Author: Seth Vidal <skvidal at fedoraproject.org>
Date: Thu Feb 4 15:30:55 2010 -0500
add uuid functionality so we can have additional info to work from
trivially.
diff --git a/docs/yum.conf.5 b/docs/yum.conf.5
index 494296e..cca3db7 100644
--- a/docs/yum.conf.5
+++ b/docs/yum.conf.5
@@ -744,6 +744,12 @@ This will be replaced with your base architecture in yum. For example, if
your $arch is i686 your $basearch will be i386.
.IP
+\fB$uuid\fR
+This will be replaced with a unique but persistent uuid for this machine.
+The value that is first generated will be stored in /var/lib/yum/uuid and
+reused until this file is deleted.
+
+.IP
\fB$YUM0-$YUM9\fR
These will be replaced with the value of the shell environment variable of
the same name. If the shell environment variable does not exist then the
diff --git a/yum/__init__.py b/yum/__init__.py
index 1fe8889..968362c 100644
--- a/yum/__init__.py
+++ b/yum/__init__.py
@@ -104,6 +104,7 @@ class _YumPreBaseConf:
self.syslog_device = '/dev/log'
self.arch = None
self.releasever = None
+ self.uuid = None
class _YumCostExclude:
""" This excludes packages that are in repos. of lower cost than the passed
@@ -236,7 +237,8 @@ class YumBase(depsolve.Depsolve):
syslog_device = self.preconf.syslog_device
releasever = self.preconf.releasever
arch = self.preconf.arch
-
+ uuid = self.preconf.uuid
+
if arch: # if preconf is setting an arch we need to pass that up
self.arch.setup_arch(arch)
else:
@@ -251,7 +253,9 @@ class YumBase(depsolve.Depsolve):
startupconf = config.readStartupConfig(fn, root)
startupconf.arch = arch
startupconf.basearch = self.arch.basearch
-
+ if uuid:
+ startupconf.uuid = uuid
+
if startupconf.gaftonmode:
global _
_ = yum.i18n.dummy_wrapper
diff --git a/yum/config.py b/yum/config.py
index b43ce7c..aa1583d 100644
--- a/yum/config.py
+++ b/yum/config.py
@@ -40,6 +40,7 @@ if not _use_iniparse:
import rpmUtils.transaction
import Errors
import types
+from misc import get_uuid
# Alter/patch these to change the default checking...
__pkgs_gpgcheck_default__ = False
@@ -832,6 +833,7 @@ def readStartupConfig(configfile, root):
startupconf._parser = parser
# setup the release ver here
startupconf.releasever = _getsysver(startupconf.installroot, startupconf.distroverpkg)
+ startupconf.uuid = get_uuid(startupconf.installroot + '/var/lib/yum/uuid')
return startupconf
@@ -850,7 +852,8 @@ def readMainConfig(startupconf):
yumvars['basearch'] = startupconf.basearch
yumvars['arch'] = startupconf.arch
yumvars['releasever'] = startupconf.releasever
-
+ yumvars['uuid'] = startupconf.uuid
+
# Read [main] section
yumconf = YumConf()
yumconf.populate(startupconf._parser, 'main')
diff --git a/yum/misc.py b/yum/misc.py
index 3917a4f..4b0226b 100644
--- a/yum/misc.py
+++ b/yum/misc.py
@@ -921,3 +921,27 @@ def get_open_files(pid):
files.append(i)
return files
+
+def get_uuid(savepath):
+ """create, store and return a uuid. If a stored one exists, report that
+ if it cannot be stored, return a random one"""
+ if os.path.exists(savepath):
+ return open(savepath, 'r').read()
+ else:
+ try:
+ from uuid import uuid4
+ except ImportError:
+ myid = open('/proc/sys/kernel/random/uuid', 'r').read()
+ else:
+ myid = str(uuid4())
+
+ try:
+ sf = open(savepath, 'w')
+ sf.write(myid)
+ sf.flush()
+ sf.close()
+ except (IOError, OSError), e:
+ pass
+
+ return myid
+
More information about the Yum-commits
mailing list