[jhbuild/wip/packaging: 1/6] Add a "workdir" (defaults to $prefix/jhbuild), change PackageDB to use it



commit 98443a5b51ec08c11bc6d6ff480483ba2f8fd508
Author: Colin Walters <walters verbum org>
Date:   Mon Apr 25 19:02:42 2011 -0400

    Add a "workdir" (defaults to $prefix/jhbuild), change PackageDB to use it
    
    For a future change to use "make install DESTDIR=$workdir", which in turn
    will enable things like "jhbuild uninstall".
    
    This patch adds an explicit concept in jhbuild of a directory for
    build state called "workdir", distinct from the installation tree.
    
    We previously had something like this in the $prefix/share/jhbuild
    directory, which is where it put the packagedb.xml file.
    
    Add a workdir variable, and move packagedb.xml in there.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=647231

 jhbuild/config.py                |    3 ++-
 jhbuild/defaults.jhbuildrc       |    1 +
 jhbuild/frontends/buildscript.py |   18 ++++++++++--------
 3 files changed, 13 insertions(+), 9 deletions(-)
---
diff --git a/jhbuild/config.py b/jhbuild/config.py
index f13e303..f4734d4 100644
--- a/jhbuild/config.py
+++ b/jhbuild/config.py
@@ -40,7 +40,8 @@ _defaults_file = os.path.join(os.path.dirname(__file__), 'defaults.jhbuildrc')
 _default_jhbuildrc = os.path.join(os.environ['HOME'], '.jhbuildrc')
 
 _known_keys = [ 'moduleset', 'modules', 'skip', 'tags', 'prefix',
-                'checkoutroot', 'buildroot', 'autogenargs', 'makeargs',
+                'checkoutroot', 'buildroot', 'workdir',
+                'autogenargs', 'makeargs',
                 'installprog', 'repos', 'branches', 'noxvfb', 'xvfbargs',
                 'builddir_pattern', 'module_autogenargs', 'module_makeargs',
                 'interact', 'buildscript', 'nonetwork',
diff --git a/jhbuild/defaults.jhbuildrc b/jhbuild/defaults.jhbuildrc
index 7abe832..94784f3 100644
--- a/jhbuild/defaults.jhbuildrc
+++ b/jhbuild/defaults.jhbuildrc
@@ -33,6 +33,7 @@ tags = []
 
 # directories
 prefix = '/opt/gnome'
+workdir = 'jhbuild'  # If a relative path, prefix will be prepended
 checkoutroot = os.path.expanduser('~/checkout/gnome')
 tarballdir = None    # will default to checkoutroot
 buildroot = None     # if set, packages will be built with srcdir!=builddir
diff --git a/jhbuild/frontends/buildscript.py b/jhbuild/frontends/buildscript.py
index a97b28c..e4aef0a 100644
--- a/jhbuild/frontends/buildscript.py
+++ b/jhbuild/frontends/buildscript.py
@@ -37,6 +37,15 @@ class BuildScript:
         if not os.access(self.config.prefix, os.R_OK|os.W_OK|os.X_OK):
             raise FatalError(_('install prefix (%s) must be writable') % self.config.prefix)
 
+        if not os.path.isabs(self.config.workdir):
+            self.config.workdir = os.path.join(self.config.prefix, self.config.workdir)
+        if not os.path.exists(self.config.workdir):
+            try:
+                os.makedirs(self.config.workdir)
+            except OSError:
+                raise FatalError(
+                        _('working directory (%s) can not be created') % self.config.workdir)
+
         if not os.path.exists(self.config.checkoutroot):
             try:
                 os.makedirs(self.config.checkoutroot)
@@ -55,14 +64,7 @@ class BuildScript:
             if not os.access(self.config.copy_dir, os.R_OK|os.W_OK|os.X_OK):
                 raise FatalError(_('checkout copy dir (%s) must be writable') % self.config.copy_dir)
 
-        packagedbdir = os.path.join(self.config.prefix, 'share', 'jhbuild')
-        try:
-            if not os.path.isdir(packagedbdir):
-                os.makedirs(packagedbdir)
-        except OSError:
-            raise FatalError(_('could not create directory %s') % packagedbdir)
-        self.packagedb = packagedb.PackageDB(os.path.join(packagedbdir,
-                                                          'packagedb.xml'))
+        self.packagedb = packagedb.PackageDB(os.path.join(self.config.workdir, 'packagedb.xml'))
 
     def execute(self, command, hint=None, cwd=None, extra_env=None):
         '''Executes the given command.



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