summaryrefslogtreecommitdiff
path: root/classes
diff options
context:
space:
mode:
authorChris Larson <clarson@kergoth.com>2004-11-25 05:14:07 +0000
committerChris Larson <clarson@kergoth.com>2004-11-25 05:14:07 +0000
commit268cef014eec4c69a79d93c8341df7d6f2c5ff53 (patch)
tree6f1885e1f06ce8452d124f929d67ab49569d96d4 /classes
parenta146eeed0bab622d83c2e77efb3746ec5996f2e4 (diff)
Split out a 'oe_unpack_file()' python function from the base_do_unpack task.
BKrev: 41a56a1fNGTfCNspf3e1tgnkpRYRNg
Diffstat (limited to 'classes')
-rw-r--r--classes/base.oeclass163
1 files changed, 84 insertions, 79 deletions
diff --git a/classes/base.oeclass b/classes/base.oeclass
index 04f1bd3d0f..35c7fbecd1 100644
--- a/classes/base.oeclass
+++ b/classes/base.oeclass
@@ -295,46 +295,6 @@ python base_do_mrproper() {
oe.build.exec_task('do_clean', d)
}
-addtask patch after do_unpack
-do_patch[dirs] = "${WORKDIR}"
-python base_do_patch() {
- import re
-
- src_uri = oe.data.getVar('SRC_URI', d)
- if not src_uri:
- return
- src_uri = oe.data.expand(src_uri, d)
- for url in src_uri.split():
-# oe.note('url is %s' % url)
- (type, host, path, user, pswd, parm) = oe.decodeurl(url)
- if not "patch" in parm:
- continue
- from oe.fetch import init, localpath
- init([url])
- url = oe.encodeurl((type, host, path, user, pswd, []))
- local = '/' + localpath(url, d)
- # patch!
- dots = local.split(".")
- if dots[-1] in ['gz', 'bz2', 'Z']:
- efile = os.path.join(oe.data.getVar('WORKDIR', d),os.path.basename('.'.join(dots[0:-1])))
- else:
- efile = local
- efile = oe.data.expand(efile, d)
- patches_dir = oe.data.expand(oe.data.getVar('PATCHES_DIR', d), d)
- oe.mkdirhier(patches_dir + "/.patches")
- os.chdir(patches_dir)
- cmd = "PATH=\"%s\" patcher" % oe.data.getVar("PATH", d, 1)
- if "pnum" in parm:
- cmd += " -p %s" % parm["pnum"]
- # Getting rid of // at the front helps the Cygwin-Users of OE
- if efile.startswith('//'):
- efile = efile[1:]
- cmd += " -R -n \"%s\" -i %s" % (os.path.basename(efile), efile)
- ret = os.system(cmd)
- if ret != 0:
- raise oe.build.FuncFailed("'patcher' execution failed")
-}
-
addtask fetch
do_fetch[dirs] = "${DL_DIR}"
do_fetch[nostamp] = "1"
@@ -364,6 +324,52 @@ python base_do_fetch() {
raise oe.build.FuncFailed("Fetch failed: %s" % value)
}
+def oe_unpack_file(file, data, url = None):
+ import oe, os
+ if not url:
+ url = "file://%s" % file
+ dots = file.split(".")
+ if dots[-1] in ['gz', 'bz2', 'Z']:
+ efile = os.path.join(oe.data.getVar('WORKDIR', data, 1),os.path.basename('.'.join(dots[0:-1])))
+ else:
+ efile = file
+ cmd = None
+ if file.endswith('.tar'):
+ cmd = 'tar x --no-same-owner -f %s' % file
+ elif file.endswith('.tgz') or file.endswith('.tar.gz'):
+ cmd = 'tar xz --no-same-owner -f %s' % file
+ elif file.endswith('.tbz') or file.endswith('.tar.bz2'):
+ cmd = 'bzip2 -dc %s | tar x --no-same-owner -f -' % file
+ elif file.endswith('.gz') or file.endswith('.Z') or file.endswith('.z'):
+ cmd = 'gzip -dc %s > %s' % (file, efile)
+ elif file.endswith('.bz2'):
+ cmd = 'bzip2 -dc %s > %s' % (file, efile)
+ elif file.endswith('.zip'):
+ cmd = 'unzip -q %s' % file
+ elif os.path.isdir(file):
+ filesdir = os.path.realpath(oe.data.getVar("FILESDIR", data, 1))
+ destdir = "."
+ if file[0:len(filesdir)] == filesdir:
+ destdir = file[len(filesdir):file.rfind('/')]
+ destdir = destdir.strip('/')
+ if len(destdir) < 1:
+ destdir = "."
+ elif not os.access("%s/%s" % (os.getcwd(), destdir), os.F_OK):
+ os.makedirs("%s/%s" % (os.getcwd(), destdir))
+ cmd = 'cp -a %s %s/%s/' % (file, os.getcwd(), destdir)
+ else:
+ (type, host, path, user, pswd, parm) = oe.decodeurl(url)
+ if not 'patch' in parm:
+ destdir = oe.decodeurl(url)[1] or "."
+ oe.mkdirhier("%s/%s" % (os.getcwd(), destdir))
+ cmd = 'cp %s %s/%s/' % (file, os.getcwd(), destdir)
+ if not cmd:
+ return True
+ cmd = "PATH=\"%s\" %s" % (oe.data.getVar('PATH', data, 1), cmd)
+ oe.note("Unpacking %s to %s/" % (file, os.getcwd()))
+ ret = os.system(cmd)
+ return ret == 0
+
addtask unpack after do_fetch
do_unpack[dirs] = "${WORKDIR}"
python base_do_unpack() {
@@ -384,53 +390,52 @@ python base_do_unpack() {
# dont need any parameters for extraction, strip them off
local = re.sub(';.*$', '', local)
local = os.path.realpath(local)
+ ret = oe_unpack_file(local, localdata, url)
+ if not ret:
+ raise oe.build.FuncFailed()
+}
+
+addtask patch after do_unpack
+do_patch[dirs] = "${WORKDIR}"
+python base_do_patch() {
+ import re
+
+ src_uri = oe.data.getVar('SRC_URI', d)
+ if not src_uri:
+ return
+ src_uri = oe.data.expand(src_uri, d)
+ for url in src_uri.split():
+# oe.note('url is %s' % url)
+ (type, host, path, user, pswd, parm) = oe.decodeurl(url)
+ if not "patch" in parm:
+ continue
+ from oe.fetch import init, localpath
+ init([url])
+ url = oe.encodeurl((type, host, path, user, pswd, []))
+ local = '/' + localpath(url, d)
+ # patch!
dots = local.split(".")
if dots[-1] in ['gz', 'bz2', 'Z']:
- efile = os.path.join(oe.data.getVar('WORKDIR', localdata, 1),os.path.basename('.'.join(dots[0:-1])))
+ efile = os.path.join(oe.data.getVar('WORKDIR', d),os.path.basename('.'.join(dots[0:-1])))
else:
efile = local
- cmd = None
- if local.endswith('.tar'):
- cmd = 'tar x --no-same-owner -f %s' % local
- elif local.endswith('.tgz') or local.endswith('.tar.gz'):
- cmd = 'tar xz --no-same-owner -f %s' % local
- elif local.endswith('.tbz') or local.endswith('.tar.bz2'):
- cmd = 'bzip2 -dc %s | tar x --no-same-owner -f -' % local
- elif local.endswith('.gz') or local.endswith('.Z') or local.endswith('.z'):
- loc = local.rfind('.')
- cmd = 'gzip -dc %s > %s' % (local, efile)
- elif local.endswith('.bz2'):
- loc = local.rfind('.')
- cmd = 'bzip2 -dc %s > %s' % (local, efile)
- elif local.endswith('.zip'):
- loc = local.rfind('.')
- cmd = 'unzip -q %s' % local
- elif os.path.isdir(local):
- filesdir = os.path.realpath(oe.data.getVar("FILESDIR", localdata, 1))
- destdir = "."
- if local[0:len(filesdir)] == filesdir:
- destdir = local[len(filesdir):local.rfind('/')]
- destdir = destdir.strip('/')
- if len(destdir) < 1:
- destdir = "."
- elif not os.access("%s/%s" % (os.getcwd(), destdir), os.F_OK):
- os.makedirs("%s/%s" % (os.getcwd(), destdir))
- cmd = 'cp -a %s %s/%s/' % (local, os.getcwd(), destdir)
- else:
- (type, host, path, user, pswd, parm) = oe.decodeurl(url)
- if not 'patch' in parm:
- destdir = oe.decodeurl(url)[1] or "."
- oe.mkdirhier("%s/%s" % (os.getcwd(), destdir))
- cmd = 'cp %s %s/%s/' % (local, os.getcwd(), destdir)
- if not cmd:
- continue
- cmd = "PATH=\"%s\" %s" % (oe.data.getVar('PATH', d, 1), cmd)
- oe.note("Unpacking %s to %s/" % (local, os.getcwd()))
+ efile = oe.data.expand(efile, d)
+ patches_dir = oe.data.expand(oe.data.getVar('PATCHES_DIR', d), d)
+ oe.mkdirhier(patches_dir + "/.patches")
+ os.chdir(patches_dir)
+ cmd = "PATH=\"%s\" patcher" % oe.data.getVar("PATH", d, 1)
+ if "pnum" in parm:
+ cmd += " -p %s" % parm["pnum"]
+ # Getting rid of // at the front helps the Cygwin-Users of OE
+ if efile.startswith('//'):
+ efile = efile[1:]
+ cmd += " -R -n \"%s\" -i %s" % (os.path.basename(efile), efile)
ret = os.system(cmd)
if ret != 0:
- raise oe.build.FuncFailed("%s execution failed" % cmd)
+ raise oe.build.FuncFailed("'patcher' execution failed")
}
+
addhandler base_eventhandler
python base_eventhandler() {
from oe import note, error, data