Fix compatibility with make 4
[auto-debuild.git] / auto_debuild.py
index 410d8489cd3118b5d5fd2e4cd0f79db5c06e43a9..0d2f65ebc6b1530bd9c03a7b7cf5b2cb6f32a400 100755 (executable)
@@ -105,7 +105,7 @@ class RulesFile:
                print(file=f)
                print(".PHONY: build", file=f) # there may be a directory called "build"
                print(file=f)
-               print("build %:", file=f) # need to mention "build" here again explicitly so PHONY takes effect
+               print("%:", file=f)
                # write proper dh call
                dh = self.dh
                if self.dhWith:
@@ -177,25 +177,23 @@ def commandInBuildEnv(config, command):
 
 def getArchitecture(config):
        cmd = commandInBuildEnv(config, ['dpkg-architecture', '-qDEB_HOST_ARCH'])
-       with subprocess.Popen(cmd, stdout=subprocess.PIPE) as p:
-               res = p.communicate()[0] # get only stdout
-               if p.returncode != 0: raise Exception("Querying dpkg for the architecture failed")
-       return res[0:len(res)-1] # chop of the \n at the end
+       output = subprocess.check_output(cmd)
+       return output.decode('utf-8').strip('\n') # chop off the \n at the end
 
 def writeDependency(f, name, list):
        if len(list):
                print(name+": "+', '.join(list), file=f)
 
+# actual work functions
 def deleteDebianFolder():
        if os.path.islink('debian'):
                target = os.readlink('debian')
                if os.path.exists(target):
                        shutil.rmtree(target)
                os.remove('debian')
-       else:
+       elif os.path.exists('debian'):
                shutil.rmtree('debian')
 
-# actual work functions
 def createDebianFiles(config):
        if not isinstance(config, ConfigDict):
                config = ConfigDict(config)