SLES9 and SLES10 enablement patches committed

Matt Domsch Matt_Domsch at dell.com
Mon May 8 16:45:13 UTC 2006


I've committed the two patches below to mock in CVS, which enables
mock to be used to create build environments for Novell/SuSE SLES 9
and SLES10.  In their environments, some files already exist so mock
shouldn't create them; useradd needs the -m flag to create the users's
home dir; we moved several iterations of chmod/chroot invocations out of the loop, and
instead do a 'chown -R' once (saves calling chroot as often); and
finally make sure files in /etc/ that should be writeable are.

Patches are by Michael E. Brown <Michael_E_Brown at dell.com> and myself.

Thanks,
Matt

-- 
Matt Domsch
Software Architect
Dell Linux Solutions linux.dell.com & www.dell.com/linux
Linux on Dell mailing lists @ http://lists.us.dell.com

--- /usr/bin/mock	2006-04-19 14:31:47.000000000 -0500
+++ ./mock	2006-04-19 14:32:16.000000000 -0500
@@ -566,8 +566,9 @@
         for item in [os.path.join(self.rootdir, 'etc', 'mtab'),
                      os.path.join(self.rootdir, 'etc', 'fstab'),
                      os.path.join(self.rootdir, 'var', 'log', 'yum.log')]:
-            fo = open(item, 'w')
-            fo.close()
+            if not os.path.exists(item):
+                fo = open(item, 'w')
+                fo.close()
         
         # write in yum.conf into chroot
         yumconf = os.path.join(self.rootdir, 'etc', 'yum.conf')
@@ -589,7 +590,7 @@
         if not os.path.exists(self.rootdir + self.homedir):
             if not os.path.exists(os.path.join(self.rootdir, 'usr/sbin/useradd')):
                 raise RootError, "Could not find useradd in chroot, maybe the install failed?"
-            cmd = '/usr/sbin/useradd -u %s -d %s %s' % (self.config['chrootuid'], 
+            cmd = '/usr/sbin/useradd -m -u %s -d %s %s' % (self.config['chrootuid'], 
                     self.homedir, self.config['chrootuser'])
             self.do_chroot(cmd, fatal = True)
 
@@ -604,9 +605,11 @@
         for subdir in ('RPMS', 'SRPMS', 'SOURCES', 'SPECS', 'BUILD', 'originals'):
             cmd = "mkdir -p %s/%s" % (self.builddir, subdir)
             self.do_chroot(cmd, fatal = True)
-            cmd = "chown %s.%s %s/%s" % (self.config['chrootuser'], 
-               self.config['chrootgroup'], self.builddir, subdir)
-            self.do_chroot(cmd, fatal = True)
+
+	# change ownership so we can write to build home dir
+        cmd = "chown -R %s.%s %s" % (self.config['chrootuser'], 
+           self.config['chrootgroup'], self.homedir)
+        self.do_chroot(cmd, fatal = True)
         
         # rpmmacros default
         macrofile_out = '%s%s/.rpmmacros' % (self.rootdir, self.homedir)

--- mock	2006-04-24 10:04:14.000000000 -0500
+++ mock.new	2006-05-05 16:16:09.000000000 -0500
@@ -579,6 +579,13 @@
         # files in /etc that need doing
         filedict = self.config['files']
         for key in filedict:
+            # ensure permisssions
+            if os.path.exists( "%s%s" % (self.rootdir, key) ):
+                cmd = "chown %s.%s %s" % (self.config['chrootuser'],
+                    self.config['chrootgroup'], "%s" % key)
+                self.do_chroot(cmd, fatal = True)
+
+            # write file
             fn = '%s%s' % (self.rootdir, key)
             fo = open(fn, 'w')
             fo.write(filedict[key])




More information about the Fedora-buildsys-list mailing list