summaryrefslogtreecommitdiff
path: root/morphlib/stagingarea.py
diff options
context:
space:
mode:
authorRichard Maw <richard.maw@codethink.co.uk>2012-07-31 12:52:12 +0000
committerRichard Maw <richard.maw@codethink.co.uk>2012-08-01 13:12:03 +0000
commit0032ccbd60f202ec76d9b738cddc8bdbf9f54133 (patch)
treecd398ab063be0bdab20b91cbd2420ad4981de813 /morphlib/stagingarea.py
parent93a3d28ee51cc301cd79ff8bfabb2010defda09b (diff)
downloadmorph-0032ccbd60f202ec76d9b738cddc8bdbf9f54133.tar.gz
python scripts: pep8ize codebase
This was done with the aid of the pep8 script, available by running `easy_install pep8`. It may be worth making this part of ./check, but that will require putting pep8 into the development tools stratum. This should be easy, given pep8 has no external dependencies.
Diffstat (limited to 'morphlib/stagingarea.py')
-rw-r--r--morphlib/stagingarea.py47
1 files changed, 23 insertions, 24 deletions
diff --git a/morphlib/stagingarea.py b/morphlib/stagingarea.py
index f3be5209..a87b45c3 100644
--- a/morphlib/stagingarea.py
+++ b/morphlib/stagingarea.py
@@ -1,14 +1,14 @@
# Copyright (C) 2012 Codethink Limited
-#
+#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
-#
+#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
-#
+#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
@@ -24,48 +24,48 @@ import morphlib
class StagingArea(object):
'''Represent the staging area for building software.
-
+
The build dependencies of what will be built will be installed in the
staging area. The staging area may be a dedicated part of the
filesystem, used with chroot, or it can be the actual root of the
filesystem, which is needed when bootstrap building Baserock. The
caller chooses this by providing the root directory of the staging
area when the object is created. The directory must already exist.
-
+
The staging area can also install build artifacts.
-
+
'''
-
+
def __init__(self, app, dirname, tempdir):
self._app = app
self.dirname = dirname
self.tempdir = tempdir
# Wrapper to be overridden by unit tests.
- def _mkdir(self, dirname): # pragma: no cover
+ def _mkdir(self, dirname): # pragma: no cover
os.mkdir(dirname)
def _dir_for_source(self, source, suffix):
- dirname = os.path.join(self.tempdir,
+ dirname = os.path.join(self.tempdir,
'%s.%s' % (source.morphology['name'], suffix))
self._mkdir(dirname)
return dirname
def builddir(self, source):
'''Create a build directory for a given source project.
-
+
Return path to directory.
-
+
'''
return self._dir_for_source(source, 'build')
-
+
def destdir(self, source):
'''Create an installation target directory for a given source project.
-
+
This is meant to be used as $DESTDIR when installing chunks.
Return path to directory.
-
+
'''
return self._dir_for_source(source, 'inst')
@@ -78,32 +78,32 @@ class StagingArea(object):
dirname += '/'
assert filename.startswith(dirname)
- return filename[len(dirname)-1:] # include leading slash
+ return filename[len(dirname) - 1:] # include leading slash
def install_artifact(self, handle):
'''Install a build artifact into the staging area.
-
+
We access the artifact via an open file handle. For now, we assume
the artifact is a tarball.
-
+
'''
- logging.debug('Installing artifact %s' %
- getattr(handle, 'name', 'unknown name'))
+ logging.debug('Installing artifact %s' %
+ getattr(handle, 'name', 'unknown name'))
morphlib.bins.unpack_binary_from_file(handle, self.dirname)
def remove(self):
'''Remove the entire staging area.
-
+
Do not expect anything with the staging area to work after this
method is called. Be careful about calling this method if
the filesystem root directory was given as the dirname.
-
+
'''
-
+
shutil.rmtree(self.dirname)
- def runcmd(self, argv, **kwargs): # pragma: no cover
+ def runcmd(self, argv, **kwargs): # pragma: no cover
'''Run a command in a chroot in the staging area.'''
cwd = kwargs.get('cwd') or '/'
if 'cwd' in kwargs:
@@ -114,4 +114,3 @@ class StagingArea(object):
real_argv = ['chroot', self.dirname, 'sh', '-c',
'cd "$1" && shift && exec "$@"', '--', cwd] + argv
return self._app.runcmd(real_argv, **kwargs)
-