Make auto-debuild configuration idempotent
authorRalf Jung <post@ralfj.de>
Sun, 29 Jul 2012 21:07:41 +0000 (23:07 +0200)
committerRalf Jung <post@ralfj.de>
Sun, 29 Jul 2012 21:07:41 +0000 (23:07 +0200)
build_system.py

index 6e72e71e9b8eed6713bc5a3a789133f5a9deee6a..979a47ac35e078c8200f7e60b3888d14e97d983d 100644 (file)
@@ -68,6 +68,7 @@ try:
                                self.autoDebuildConfig[dstName] = src[name]
 
                def configure(self, force=False): # force is ignored
                                self.autoDebuildConfig[dstName] = src[name]
 
                def configure(self, force=False): # force is ignored
+                       if self.configured: return # do not configure twice
                        self.autoDebuildConfig['version'] = self.vcs.version() # by now, data has been fetched, so this is possible
                        if self.autoDebuildConfig['version'] is None:
                                raise Exception("VCS did not provide us with a proper version, please fix this")
                        self.autoDebuildConfig['version'] = self.vcs.version() # by now, data has been fetched, so this is possible
                        if self.autoDebuildConfig['version'] is None:
                                raise Exception("VCS did not provide us with a proper version, please fix this")
@@ -77,12 +78,12 @@ try:
                        self.configured = True
 
                def build(self):
                        self.configured = True
 
                def build(self):
-                       if not self.configured: self.configure()
+                       self.configure() # make sure we are configured (this call is idempotent)
                        os.chdir(self.sourceFolder)
                        auto_debuild.buildDebianPackage(self.autoDebuildConfig)
 
                def install(self):
                        os.chdir(self.sourceFolder)
                        auto_debuild.buildDebianPackage(self.autoDebuildConfig)
 
                def install(self):
-                       if not self.configured: self.configure()
+                       self.configure() # make sure we are configured (this call is idempotent)
                        os.chdir(self.sourceFolder)
                        subprocess.check_call(['sudo', 'dpkg', '--install'] + self.files)
 except ImportError:
                        os.chdir(self.sourceFolder)
                        subprocess.check_call(['sudo', 'dpkg', '--install'] + self.files)
 except ImportError: