[jhbuild/jhdebuild: 533/536] [jhdebuild] Remove duplicated code



commit 703ad3039c322ca299491e9de2775cc8e929ced3
Author: John Carr <john carr unrouted co uk>
Date:   Sun May 17 18:50:42 2009 +0100

    [jhdebuild] Remove duplicated code
---
 jhbuild/modtypes/__init__.py  |   37 -------------------------------------
 jhbuild/modtypes/autotools.py |    8 --------
 jhbuild/modtypes/debian.py    |   34 +++++++++++++++++++++++++++++++++-
 jhbuild/modtypes/distutils.py |   33 ---------------------------------
 jhbuild/modtypes/perl.py      |   31 -------------------------------
 5 files changed, 33 insertions(+), 110 deletions(-)

diff --git a/jhbuild/modtypes/__init__.py b/jhbuild/modtypes/__init__.py
index 57fda86..f91d24b 100644
--- a/jhbuild/modtypes/__init__.py
+++ b/jhbuild/modtypes/__init__.py
@@ -133,8 +133,6 @@ def get_branch(node, repositories, default_repo, config):
 class Package:
     type = 'base'
     PHASE_START = 'start'
-    PHASE_APT_GET_UPDATE = 'deb_apt_get_update'
-    PHASE_BUILD_DEPS     = 'deb_build_deps'
     PHASE_DONE  = 'done'
     def __init__(self, name, dependencies = [], after = [], suggests = []):
         self.name = name
@@ -330,36 +328,6 @@ class Package:
                     raise SkipToEnd()
     do_deb_start.error_phases = []
 
-    def skip_deb_apt_get_update(self, buildscript, last_state):
-        return False
-
-    def do_deb_apt_get_update(self, buildscript):
-        if not buildscript.config.nonetwork:
-            buildscript.set_action('Updating packages database for', self)
-            try:
-                buildscript.execute(['sudo', 'apt-get', 'update'])
-            except CommandError:
-                pass
-    do_deb_apt_get_update.error_phases = []
-
-    def skip_deb_build_deps(self, buildscript, last_state):
-        return False
-
-    def do_deb_build_deps(self, buildscript):
-        buildscript.set_action('Installing build deps for', self)
-        debian_name = self.get_debian_name(buildscript)
-        v = None
-        try:
-            v = self.get_available_debian_version(buildscript)
-        except KeyError:
-            pass
-        if v:
-            try:
-                buildscript.execute(['sudo', 'apt-get', '--yes', 'build-dep', debian_name])
-            except CommandError:
-                raise BuildStateError('Failed to install build deps')
-    do_deb_build_deps.error_phases = []
-
     def xml_tag_and_attrs(self):
         """Return a (tag, attrs) pair, describing how to serialize this
         module.
@@ -414,11 +382,6 @@ class MetaModule(Package):
                 + [[sxml.dep(package=d)] for d in self.dependencies]]
 
 
-    def do_deb_start(self, buildscript):
-        pass
-    do_deb_start.error_phases = []
-
-
 def parse_metamodule(node, config, url, repos, default_repo):
     id = node.getAttribute('id')
     dependencies, after, suggests = get_dependencies(node)
diff --git a/jhbuild/modtypes/autotools.py b/jhbuild/modtypes/autotools.py
index ccf45ad..dd7e4b7 100644
--- a/jhbuild/modtypes/autotools.py
+++ b/jhbuild/modtypes/autotools.py
@@ -252,10 +252,6 @@ class AutogenModule(Package, DebianBasePackage):
     do_dist.depends = [PHASE_CONFIGURE]
     do_dist.error_phases = [PHASE_FORCE_CHECKOUT, PHASE_CONFIGURE]
 
-    def do_deb_build_deps(self, buildscript):
-        return DebianBasePackage.do_deb_build_deps(self, buildscript)
-    do_deb_build_deps.error_phases = []
-
     def skip_install(self, buildscript, last_state):
         return buildscript.config.nobuild
 
@@ -287,10 +283,6 @@ class AutogenModule(Package, DebianBasePackage):
                 write_cached_value('version-%s-%s' % (self.name, self.branch.revision_id), version)
         return version
 
-    def do_deb_apt_get_update(self, buildscript):
-        Package.do_deb_apt_get_update(self, buildscript)
-    do_deb_apt_get_update.error_phases = []
-
     def get_tarball_dir(self, buildscript):
         return os.path.join(buildscript.config.tarballs_dir, self.name, self.branch.revision_id)
 
diff --git a/jhbuild/modtypes/debian.py b/jhbuild/modtypes/debian.py
index 8926ecb..90b8c03 100644
--- a/jhbuild/modtypes/debian.py
+++ b/jhbuild/modtypes/debian.py
@@ -9,7 +9,8 @@ from jhbuild.modtypes import Package
 from jhbuild.utils import debian
 
 class DebianBasePackage:
-
+    PHASE_APT_GET_UPDATE = 'deb_apt_get_update'
+    PHASE_BUILD_DEPS     = 'deb_build_deps'
     PHASE_DEB_DIST       = 'deb_dist'
     PHASE_TAR_X          = 'deb_tar_x'
     PHASE_DEBIAN_DIR     = 'deb_debian_dir'
@@ -17,6 +18,37 @@ class DebianBasePackage:
     PHASE_DINSTALL       = 'deb_dinstall'
     PHASE_UPGRADE        = 'deb_upgrade'
 
+    def skip_deb_apt_get_update(self, buildscript, last_state):
+        return False
+
+    def do_deb_apt_get_update(self, buildscript):
+        if not buildscript.config.nonetwork:
+            buildscript.set_action('Updating packages database for', self)
+            try:
+                buildscript.execute(['sudo', 'apt-get', 'update'])
+            except CommandError:
+                pass
+    do_deb_apt_get_update.error_phases = []
+
+    def skip_deb_build_deps(self, buildscript, last_state):
+        return False
+
+    def do_deb_build_deps(self, buildscript):
+        buildscript.set_action('Installing build deps for', self)
+        debian_name = self.get_debian_name(buildscript)
+        v = None
+        try:
+            v = self.get_available_debian_version(buildscript)
+        except KeyError:
+            pass
+        if v:
+            try:
+                buildscript.execute(['sudo', 'apt-get', '--yes', 'build-dep', debian_name])
+            except CommandError:
+                raise BuildStateError('Failed to install build deps')
+    do_deb_build_deps.error_phases = []
+    do_deb_build_deps.depends = [PHASE_APT_GET_UPDATE]
+
     def skip_deb_tar_x(self, buildscript, last_state):
         if os.path.exists(self.get_tarball_dir(buildscript)):
             buildscript.message('%s already has a tarball' % self.name)
diff --git a/jhbuild/modtypes/distutils.py b/jhbuild/modtypes/distutils.py
index 76f14e8..9d1593e 100644
--- a/jhbuild/modtypes/distutils.py
+++ b/jhbuild/modtypes/distutils.py
@@ -97,39 +97,6 @@ class DistutilsModule(Package):
                              ('supports-non-srcdir-builds',
                               'supports_non_srcdir_builds', True)]
 
-    def do_deb_start(self, buildscript):
-        buildscript.set_action('Starting building', self)
-        buildscript.execute(['sudo', 'apt-get', 'update'])
-        ext_dep = buildscript.config.external_dependencies.get(self.name)
-        if not ext_dep:
-            raise BuildStateError('No external dep for %s' % self.name)
-
-        #print buildscript.config.external_dependencies
-
-        available = self.get_available_debian_version(buildscript).split('-')[0]
-        if ':' in available: # remove epoch
-            available = available.split(':')[-1]
-
-        def lax_int(s):
-            try:
-                return int(s)
-            except ValueError:
-                return -1
-
-        deb_available = [lax_int(x) for x in available.split('.')]
-        ext_minimum = [lax_int(x) for x in ext_dep.get('minimum').split('.')]
-        ext_recommended = [lax_int(x) for x in ext_dep.get('recommended').split('.')]
-
-        if deb_available >= ext_recommended:
-            return (self.PHASE_DONE, None, None)
-
-        if deb_available >= ext_minimum:
-            # XXX: warn it would be better to have a newer version
-            return (self.PHASE_DONE, None, None)
-
-        return (self.PHASE_DOWNLOAD, None, None)
-
-    
     def do_deb_build(self, buildscript):
         # gets a debian/ directory
         builddir = self.get_builddir(buildscript)
diff --git a/jhbuild/modtypes/perl.py b/jhbuild/modtypes/perl.py
index 9d29913..98e491a 100644
--- a/jhbuild/modtypes/perl.py
+++ b/jhbuild/modtypes/perl.py
@@ -58,37 +58,6 @@ class PerlModule(Package):
         pass
     do_start.error_phases = []
 
-    def do_deb_start(self, buildscript):
-        buildscript.set_action('Starting building', self)
-        buildscript.execute(['sudo', 'apt-get', 'update'])
-        ext_dep = buildscript.config.external_dependencies.get(self.name)
-        if not ext_dep:
-            raise BuildStateError('No external dep for %s' % self.name)
-
-        #print buildscript.config.external_dependencies
-
-        available = self.get_available_debian_version(buildscript).split('-')[0]
-        if ':' in available: # remove epoch
-            available = available.split(':')[-1]
-
-        def lax_int(s):
-            try:
-                return int(s)
-            except ValueError:
-                return -1
-
-        deb_available = [lax_int(x) for x in available.split('.')]
-        ext_minimum = [lax_int(x) for x in ext_dep.get('minimum').split('.')]
-        ext_recommended = [lax_int(x) for x in ext_dep.get('recommended').split('.')]
-
-        if deb_available >= ext_recommended:
-            raise SkipToEnd()
-
-        if deb_available >= ext_minimum:
-            # XXX: warn it would be better to have a newer version
-            raise SkipToEnd()
-    do_deb_start.error_phases = []
-
     def do_checkout(self, buildscript):
         self.checkout(buildscript)
     do_checkout.error_phases = [PHASE_FORCE_CHECKOUT]



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]