First working prototype of auto-debuild integration
authorRalf Jung <post@ralfj.de>
Fri, 27 Jul 2012 12:08:44 +0000 (14:08 +0200)
committerRalf Jung <ralfjung-e@gmx.de>
Fri, 27 Jul 2012 12:08:44 +0000 (14:08 +0200)
build_system.py
kdebuildpy.py
vcs.py

index 073d432663ee5143f3c49831e18f0bca3747690c..5634f9dd1be6e10ce87ae56274f40686d2c234f7 100644 (file)
@@ -37,16 +37,32 @@ class CMake:
 try:
        import auto_debuild
        class AutoDebuild:
-               def __init__(self, sourceFolder, module):
-                       self.autoDebuildConfig = {}
+               def __init__(self, sourceFolder, module, vcs, config):
+                       self.sourceFolder = os.path.abspath(sourceFolder)
+                       self.autoDebuildConfig = {
+                               'sourceName': module['name'],
+                               'debDir': os.path.abspath(config['debDir']),
+                               'buildSystem': module.get('build-system', 'cmake'),
+                       }
+                       self.vcs = vcs
+                       self.configured = False # make sure configure is called before build/install
 
                def configure(self, force=False): # force is ignored
+                       self.autoDebuildConfig['version'] = self.vcs.version() # by now, data has been fetched, so this is possible
+                       os.chdir(self.sourceFolder)
+                       print self.sourceFolder,self.autoDebuildConfig
                        self.files = auto_debuild.createDebianFiles(self.autoDebuildConfig)
+                       self.configured = True
 
                def build(self):
+                       if not self.configured: self.configure()
+                       os.chdir(self.sourceFolder)
                        auto_debuild.buildDebianPackage(self.autoDebuildConfig)
 
                def install(self):
+                       if not self.configured: self.configure()
+                       os.chdir(self.sourceFolder)
                        subprocess.check_call(['sudo', 'dpkg', '--install'] + self.files)
 except ImportError:
+       print "auto_debuild not found, disabling auto-debuild system"
        pass
index bf2f2a3b8c365b125452257c3b81402daa7a7665..4363bd44c60e308c90dd5de4bb01d9439c2d28ba 100755 (executable)
@@ -42,7 +42,7 @@ class Project:
                        raise Exception("Unknown VCS type "+vcsName)
                # build system
                if config.get('buildDeb', False):
-                       self.buildSystem = build_system.AutoDebuild(self.sourceFolder(), module)
+                       self.buildSystem = build_system.AutoDebuild(self.sourceFolder(), module, self.vcs, config)
                else:
                        buildSystemName = module.get('build-system', 'cmake')
                        if buildSystemName == 'cmake':
diff --git a/vcs.py b/vcs.py
index a810d35291907ab5464ef1e603640cb2778acf38..893a75f159832a4e84dd49ee394a0acdbab7ebd1 100644 (file)
--- a/vcs.py
+++ b/vcs.py
@@ -8,11 +8,11 @@ class Git:
                self.folder = os.path.abspath(folder)
                self.url = url
                self.commit = commit
-       
+
        class _ProgressPrinter(git.remote.RemoteProgress):
                def update(self, op_code, cur_count, max_count=None, message=''):
                        print self._cur_line+(" "*30)+"\r",
-       
+
        def update(self):
                isBranch = (self.commit.startswith('origin/'))
                if isBranch:
@@ -46,6 +46,12 @@ class Git:
                        print "(keeping local patches around)",
                print
 
+       def version(self):
+               repo = git.Repo(self.folder)
+               v = repo.git.describe()
+               if v.startswith('v'): v = v[1:]
+               return v
+
 class KDEGit(Git):
        def __init__(self, folder, name, commit):
                Git.__init__(self, folder, 'kde:'+name, commit)