]> git.siccegge.de Git - forks/vmdebootstrap.git/commitdiff
Allow option to chown the image when complete.
authorNeil Williams <codehelp@debian.org>
Sun, 10 Aug 2014 13:32:55 +0000 (14:32 +0100)
committerNeil Williams <codehelp@debian.org>
Thu, 28 Aug 2014 05:46:44 +0000 (22:46 -0700)
(Closes: #748477)
Patch from Nick Daly <nick.m.daly@gmail.com>

vmdebootstrap

index a9f9e9bf4c2b87e6886f7c170dfca3dc3ed93b1d..64614ad8c5f91442a5e71b7579b38ee8e97d3a9b 100755 (executable)
@@ -26,7 +26,7 @@ import tempfile
 import time
 
 
-__version__ = '0.2'
+__version__ = '0.3'
 
 
 class VmDebootstrap(cliapp.Application):
@@ -100,6 +100,9 @@ class VmDebootstrap(cliapp.Application):
         self.settings.boolean(['sudo'], 
                               'install sudo, and if user is created, add them '
                                 'to sudo group')
+        self.settings.string(['owner'],
+                             'the user who will own the image when the build '
+                               'is complete.')
 
     def process_args(self, args):
         if not self.settings['image'] and not self.settings['tarball']:
@@ -156,8 +159,12 @@ class VmDebootstrap(cliapp.Application):
 
             if self.settings['tarball']:
                 self.create_tarball(rootdir)
+
+            if self.settings['owner']:
+                self.chown(rootdir)
         except BaseException, e:
             self.message('EEEK! Something bad happened...')
+            self.message(e)
             self.cleanup_system()
             raise
         else:
@@ -501,6 +508,13 @@ append initrd=%(initrd)s root=UUID=%(uuid)s ro %(kserial)s
         self.message('Creating tarball of disk contents')
         self.runcmd(['tar', '-cf', self.settings['tarball'], '-C', rootdir, '.'])
 
+    def chown(self, rootdir):
+        # Change image owner after completed build
+        self.message("Changing owner to %s" % self.settings["owner"])
+        subprocess.call(["chown",
+                         self.settings["owner"],
+                         self.settings["image"]])
+
 
 if __name__ == '__main__':
     VmDebootstrap(version=__version__).run()