Factor dependency writing into its own function and add support for Recommends
authorRalf Jung <post@ralfj.de>
Fri, 27 Jul 2012 11:25:31 +0000 (13:25 +0200)
committerRalf Jung <post@ralfj.de>
Fri, 27 Jul 2012 11:25:31 +0000 (13:25 +0200)
auto_debuild.py

index 36cef6db343c3806c39cea22e459621f1b570e45..9d7c0421d850ac8537dfd082f004c5d96a4ae2e8 100755 (executable)
@@ -59,8 +59,9 @@ def getArchitecture(config):
        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
 
        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
 
-def writeDebList(list):
-       return ', '.join(list)
+def writeDependency(f, name, list):
+       if len(list):
+               print >>f, name+": "+', '.join(list)
 
 # actual work functions
 def createDebianFiles(config):
 
 # actual work functions
 def createDebianFiles(config):
@@ -99,15 +100,15 @@ def createDebianFiles(config):
                print >>f, "Section:",config.get('section', 'misc')
                print >>f, "Priority: extra"
                print >>f, "Maintainer: %s <%s>" % (name, email)
                print >>f, "Section:",config.get('section', 'misc')
                print >>f, "Priority: extra"
                print >>f, "Maintainer: %s <%s>" % (name, email)
-               print >>f, "Build-Depends:",writeDebList(["debhelper (>= 9)"] + config.get('buildDepends', []))
+               writeDependency(f, 'Build-Depends', ["debhelper (>= 9)"] + config.get('buildDepends', []))
                print >>f, "Standards-Version: 3.9.3"
                print >>f, ""
                print >>f, "Package:",binaryName
                print >>f, "Architecture:",packageArchitecture
                print >>f, "Standards-Version: 3.9.3"
                print >>f, ""
                print >>f, "Package:",binaryName
                print >>f, "Architecture:",packageArchitecture
-               if 'binaryPreDepends' in config:
-                       print >>f, "Pre-Depends:",writeDebList(config['binaryPreDepends'])
-               print >>f, "Depends:",writeDebList(["${shlibs:Depends}", "${misc:Depends}"] + config.get('binaryDepends', []))
-               print >>f, "Provides:",writeDebList(config.get('binaryProvides', [sourceName]))
+               writeDependency(f, "Pre-Depends", ["${misc:Pre-Depends}"] + config.get('binaryPreDepends', []))
+               writeDependency(f, "Depends", ["${shlibs:Depends}", "${misc:Depends}"] + config.get('binaryDepends', []))
+               writeDependency(f, "Recommends", config.get('binaryRecommends', []))
+               writeDependency(f, "Provides", config.get('binaryProvides', [sourceName]))
                print >>f, "Description:",sourceName,"(auto-debuild)"
                print >>f, " Package auto-generated by auto-debuild."
                files.append(os.path.join(debDir, "%s_%s_%s.deb" % (binaryName, version, arch)))
                print >>f, "Description:",sourceName,"(auto-debuild)"
                print >>f, " Package auto-generated by auto-debuild."
                files.append(os.path.join(debDir, "%s_%s_%s.deb" % (binaryName, version, arch)))
@@ -115,7 +116,7 @@ def createDebianFiles(config):
                        print >>f, ""
                        print >>f, "Package:",binaryName+"-dbg"
                        print >>f, "Architecture:",packageArchitecture
                        print >>f, ""
                        print >>f, "Package:",binaryName+"-dbg"
                        print >>f, "Architecture:",packageArchitecture
-                       print >>f, "Depends:",writeDebList(["${misc:Depends}", binaryName+" (= ${binary:Version})"])
+                       writeDependency(f, "Depends", ["${misc:Depends}", binaryName+" (= ${binary:Version})"])
                        print >>f, "Description:",sourceName,"debug smbols (auto-debuild)"
                        print >>f, " Package containing debug symbols for "+sourceName+", auto-generated by auto-debuild."
                        files.append(os.path.join(debDir, "%s-dbg_%s_%s.deb" % (binaryName, version, arch)))
                        print >>f, "Description:",sourceName,"debug smbols (auto-debuild)"
                        print >>f, " Package containing debug symbols for "+sourceName+", auto-generated by auto-debuild."
                        files.append(os.path.join(debDir, "%s-dbg_%s_%s.deb" % (binaryName, version, arch)))
@@ -164,6 +165,7 @@ def createAndInstall(config, overwriteCheck = False):
        # run compilation
        buildDebianPackage(config)
        # install files
        # run compilation
        buildDebianPackage(config)
        # install files
+       print "Installing created deb files..."
        subprocess.check_call(['sudo', 'dpkg', '--install'] + files)
 
 # if we are called directly as script
        subprocess.check_call(['sudo', 'dpkg', '--install'] + files)
 
 # if we are called directly as script