summaryrefslogtreecommitdiffstats
path: root/py
diff options
context:
space:
mode:
authorMichael E Brown <michael_e_brown@dell.com>2007-12-21 13:41:03 -0600
committerMichael E Brown <michael_e_brown@dell.com>2007-12-21 13:41:03 -0600
commitaefe3d7b6e7c289c84bea6865e7020b4c4637ea4 (patch)
treef0229059717ddce5dc8756872b5616b5711e5502 /py
parent3ae0cfcbab2ace30d69484ef2ab267cf84176a0c (diff)
parent99e36b173e3fa707796a8a13e9b356e651544044 (diff)
downloadmock-aefe3d7b6e7c289c84bea6865e7020b4c4637ea4.tar.gz
mock-aefe3d7b6e7c289c84bea6865e7020b4c4637ea4.tar.xz
mock-aefe3d7b6e7c289c84bea6865e7020b4c4637ea4.zip
Merge branch 'master' of /var/ftp/pub/Applications/git/mock
* 'master' of /var/ftp/pub/Applications/git/mock: /usr/sbin/mock no longer needs to be owned by group mock. remove unused debugging code. version bump and changelog fix privs for yum resolvdep, needs to be root to download addl filelists. fixup release instructions so that tags properly pushed. update changelog prior to release. bump version. add comment about making sure to fix both version defs. cleanup from unit tests if they are interrupted or end prematurely. fix resultdir for --uniqueext builds without resultdir specified. try to standardize on single-quotes for indexing hashes. we are now noarch, fix unit tests. add tmpfs plugin to installation list. requires usermode due to new userhelper stuff. fix use of tabs in spec file to make rpmlint happy. Run rpmbuild in a login shell in the chroot.
Diffstat (limited to 'py')
-rwxr-xr-xpy/mock.py8
-rw-r--r--py/mock/backend.py57
2 files changed, 28 insertions, 37 deletions
diff --git a/py/mock.py b/py/mock.py
index 61f5903..d4b0885 100755
--- a/py/mock.py
+++ b/py/mock.py
@@ -374,12 +374,6 @@ def main(ret):
unprivUid = os.getuid()
unprivGid = os.getgid()
- #DEBUG
- #import mock.uid
- #print("UID: %s %s" % (repr(mock.uid.getresuid()), repr(mock.uid.getresgid())))
- #for k, v in os.environ.items():
- # print " %s: %s" % (k, v)
-
# sudo
if os.environ.get("SUDO_UID") is not None:
unprivUid = int(os.environ['SUDO_UID'])
@@ -387,7 +381,6 @@ def main(ret):
groups = [ g[2] for g in grp.getgrall() if username in g[3]]
os.setgroups(groups)
unprivGid = int(os.environ['SUDO_GID'])
- #print "SUDO_UID activated: %s %s" % (unprivUid, unprivGid)
# consolehelper
if os.environ.get("USERHELPER_UID") is not None:
@@ -396,7 +389,6 @@ def main(ret):
groups = [ g[2] for g in grp.getgrall() if username in g[3]]
os.setgroups(groups)
unprivGid = pwd.getpwuid(unprivUid)[3]
- #print "USERHELPER_UID activated: %s %s" % (unprivUid, unprivGid)
uidManager = mock.uid.uidManager(unprivUid, unprivGid)
uidManager._becomeUser(unprivUid, unprivGid)
diff --git a/py/mock/backend.py b/py/mock/backend.py
index 66a3951..38a2abd 100644
--- a/py/mock/backend.py
+++ b/py/mock/backend.py
@@ -33,11 +33,10 @@ class Root(object):
self.buildrootLock = None
self.sharedRootName = config['root']
- root = self.sharedRootName
if config.has_key('unique-ext'):
- root = "%s-%s" % (root, config['unique-ext'])
+ config['root'] = "%s-%s" % (config['root'], config['unique-ext'])
- self.basedir = os.path.join(config['basedir'], root)
+ self.basedir = os.path.join(config['basedir'], config['root'])
self.target_arch = config['target_arch']
self._rootdir = os.path.join(self.basedir, 'root')
self.homedir = config['chroothome']
@@ -76,11 +75,11 @@ class Root(object):
self.pluginConf = config['plugin_conf']
self.pluginDir = config['plugin_dir']
for key in self.pluginConf.keys():
- if not key.endswith("_opts"): continue
- self.pluginConf[key]["basedir"] = self.basedir
- self.pluginConf[key]["cache_topdir"] = self.cache_topdir
- self.pluginConf[key]["cachedir"] = self.cachedir
- self.pluginConf[key]["root"] = self.sharedRootName
+ if not key.endswith('_opts'): continue
+ self.pluginConf[key]['basedir'] = self.basedir
+ self.pluginConf[key]['cache_topdir'] = self.cache_topdir
+ self.pluginConf[key]['cachedir'] = self.cachedir
+ self.pluginConf[key]['root'] = self.sharedRootName
# mount/umount
self.umountCmds = ['umount -n %s' % self.makeChrootPath('proc'),
@@ -326,27 +325,27 @@ class Root(object):
decorate(traceLog())
def installSrpmDeps(self, *srpms):
"""figure out deps from srpm. call yum to install them"""
- arg_string = self.preExistingDeps
- for hdr in mock.util.yieldSrpmHeaders(srpms, plainRpmOk=1):
- # get text buildreqs
- a = mock.util.requiresTextFromHdr(hdr)
- b = mock.util.getAddtlReqs(hdr, self.more_buildreqs)
- for item in mock.util.uniqReqs(a, b):
- arg_string = arg_string + " '%s'" % item
-
- # everything exists, okay, install them all.
- # pass build reqs (as strings) to installer
- if arg_string != "":
- output = self._yum('resolvedep %s' % arg_string, returnOutput=1)
- for line in output.split('\n'):
- if line.lower().find('No Package found for'.lower()) != -1:
- raise mock.exception.BuildError, "Bad build req: %s. Exiting." % line
- # nothing made us exit, so we continue
+ try:
self.uidManager.becomeUser(0, 0)
- try:
+ arg_string = self.preExistingDeps
+ for hdr in mock.util.yieldSrpmHeaders(srpms, plainRpmOk=1):
+ # get text buildreqs
+ a = mock.util.requiresTextFromHdr(hdr)
+ b = mock.util.getAddtlReqs(hdr, self.more_buildreqs)
+ for item in mock.util.uniqReqs(a, b):
+ arg_string = arg_string + " '%s'" % item
+
+ # everything exists, okay, install them all.
+ # pass build reqs (as strings) to installer
+ if arg_string != "":
+ output = self._yum('resolvedep %s' % arg_string, returnOutput=1)
+ for line in output.split('\n'):
+ if line.lower().find('No Package found for'.lower()) != -1:
+ raise mock.exception.BuildError, "Bad build req: %s. Exiting." % line
+ # nothing made us exit, so we continue
self._yum('install %s' % arg_string, returnOutput=1)
- finally:
- self.uidManager.restorePrivs()
+ finally:
+ self.uidManager.restorePrivs()
#
@@ -388,7 +387,7 @@ class Root(object):
chrootspec = spec.replace(self.makeChrootPath(), '') # get rid of rootdir prefix
# Completely/Permanently drop privs while running the following:
self.doChroot(
- "rpmbuild -bs --target %s --nodeps %s" % (self.target_arch, chrootspec),
+ "bash -l -c 'rpmbuild -bs --target %s --nodeps %s'" % (self.target_arch, chrootspec),
logger=self.build_log, timeout=timeout,
uidManager=self.uidManager,
uid=self.chrootuid,
@@ -409,7 +408,7 @@ class Root(object):
self._callHooks('prebuild')
self.doChroot(
- "rpmbuild -bb --target %s --nodeps %s" % (self.target_arch, chrootspec),
+ "bash -l -c 'rpmbuild -bb --target %s --nodeps %s'" % (self.target_arch, chrootspec),
logger=self.build_log, timeout=timeout,
uidManager=self.uidManager,
uid=self.chrootuid,