summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--source-builder/sb/build.py31
-rw-r--r--source-builder/sb/path.py33
-rw-r--r--source-builder/sb/setbuilder.py8
3 files changed, 41 insertions, 31 deletions
diff --git a/source-builder/sb/build.py b/source-builder/sb/build.py
index 4497478..d8cf915 100644
--- a/source-builder/sb/build.py
+++ b/source-builder/sb/build.py
@@ -44,14 +44,6 @@ import path
#
version = '0.1'
-def removeall(path):
-
- def _onerror(function, path, excinfo):
- print 'removeall error: (%r) %s' % (function, path)
-
- shutil.rmtree(path, onerror = _onerror)
- return
-
def _notice(opts, text):
if not opts.quiet() and not log.default.has_stdout():
print text
@@ -107,7 +99,7 @@ class build:
def __init__(self, name, create_tar_files, _defaults, opts):
self.opts = opts
self.create_tar_files = create_tar_files
- _notice(opts, 'building: ' + name)
+ _notice(opts, 'config: ' + name)
self.config = config.file(name, _defaults = _defaults, opts = opts)
self.script = script(quiet = opts.quiet(), trace = opts.trace())
@@ -119,27 +111,12 @@ class build:
self._output('removing: %s' % (path.host(rmpath)))
if not self.opts.dry_run():
if path.exists(rmpath):
- removeall(rmpath)
+ path.removeall(rmpath)
def mkdir(self, mkpath):
self._output('making dir: %s' % (path.host(mkpath)))
if not self.opts.dry_run():
- if os.name == 'nt':
- try:
- os.makedirs(path.host(mkpath))
- except IOError, err:
- _notice(self.opts, 'warning: cannot make directory: %s' % (mkpath))
- except OSError, err:
- _notice(self.opts, 'warning: cannot make directory: %s' % (mkpath))
- except WindowsError, err:
- _notice(self.opts, 'warning: cannot make directory: %s' % (mkpath))
- else:
- try:
- os.makedirs(path.host(mkpath))
- except IOError, err:
- _notice(self.opts, 'warning: cannot make directory: %s' % (mkpath))
- except OSError, err:
- _notice(self.opts, 'warning: cannot make directory: %s' % (mkpath))
+ path.mkdir(mkpath)
def get_file(self, url, local):
if local is None:
@@ -369,7 +346,7 @@ class build:
self._output('run: ' + cmd)
exit_code, proc, output = e.shell(cmd, cwd = path.host(cwd))
if exit_code != 0:
- raise error.general('shell cmd failed: %s' % (os.path.relpath(cmd)))
+ raise error.general('shell cmd failed: %s' % (cmd))
def builddir(self):
builddir = self.config.abspath('_builddir')
diff --git a/source-builder/sb/path.py b/source-builder/sb/path.py
index eda6d50..1050eee 100644
--- a/source-builder/sb/path.py
+++ b/source-builder/sb/path.py
@@ -24,8 +24,11 @@
#
import os
+import shutil
import string
+import error
+
windows = os.name == 'nt'
def host(path):
@@ -81,6 +84,36 @@ def isfile(path):
def isabspath(path):
return path[0] == '/'
+def mkdir(path):
+ if exists(path):
+ if not isdir(path):
+ raise error.general('path exists and is not a directory: %s' % (path))
+ else:
+ if windows:
+ try:
+ os.makedirs(host(path))
+ except IOError, err:
+ raise error.general('cannot make directory: %s' % (path))
+ except OSError, err:
+ raise error.general('cannot make directory: %s' % (path))
+ except WindowsError, err:
+ raise error.general('cannot make directory: %s' % (path))
+ else:
+ try:
+ os.makedirs(host(path))
+ except IOError, err:
+ raise error.general('cannot make directory: %s' % (path))
+ except OSError, err:
+ raise error.general('cannot make directory: %s' % (path))
+
+def removeall(path):
+
+ def _onerror(function, path, excinfo):
+ print 'removeall error: (%r) %s' % (function, path)
+
+ shutil.rmtree(path, onerror = _onerror)
+ return
+
if __name__ == '__main__':
print host('/a/b/c/d-e-f')
print host('//a/b//c/d-e-f')
diff --git a/source-builder/sb/setbuilder.py b/source-builder/sb/setbuilder.py
index 8890589..79fe58f 100644
--- a/source-builder/sb/setbuilder.py
+++ b/source-builder/sb/setbuilder.py
@@ -127,10 +127,10 @@ class buildset:
def last_package(self, _build, tmproot):
if self.opts.get_arg('--bset-tar-file'):
- tar = path.join(_build.config.expand('%{_tardir}'),
- _build.config.expand('%s.tar.bz2' % (self.bset_pkg)))
- _notice(self.opts, 'tarball: %s -> %s' %
- (os.path.relpath(path.host(tmproot)), os.path.relpath(path.host(tar))))
+ tardir = _build.config.expand('%{_tardir}')
+ path.mkdir(tardir)
+ tar = path.join(tardir, _build.config.expand('%s.tar.bz2' % (self.bset_pkg)))
+ _notice(self.opts, 'tarball: %s' % (os.path.relpath(path.host(tar))))
if not self.opts.dry_run():
cmd = _build.config.expand("'cd " + tmproot + \
" && %{__tar} -cf - . | %{__bzip2} > " + tar + "'")