--- /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)
