From b670b7f656b874e5bb97db6d74a42b0be94833a5 Mon Sep 17 00:00:00 2001 From: "Manuel Amador (Rudd-O)" Date: Wed, 1 Sep 2010 15:39:01 -0500 Subject: [PATCH] Patch generation (tar waf tool) fixed to work properly on windows and linux. --- patches/wscript_build | 2 +- tools/waf/tar.py | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/patches/wscript_build b/patches/wscript_build index 4351d4e605d..0cdfb7302a3 100644 --- a/patches/wscript_build +++ b/patches/wscript_build @@ -10,7 +10,7 @@ for virttech in Utils.to_list(bld.path.ant_glob("*",dir=True)): source = patchfiles, target = '%s-patch.tgz'%virttech, name = '%s-patch_tgz'%virttech, - root = "patches/%s"%virttech, + root = os.path.join("patches",virttech), rename = lambda x: re.sub(".subst$","",x), after = 'patchsubst', ) diff --git a/tools/waf/tar.py b/tools/waf/tar.py index 45c4c05746f..a6948d3a18c 100644 --- a/tools/waf/tar.py +++ b/tools/waf/tar.py @@ -2,7 +2,7 @@ import Utils import tarfile from TaskGen import feature, before import Task -import os +import os, sys # this is a clever little thing # given a list of nodes, build or source @@ -14,9 +14,9 @@ import os def tar_up(task): tgt = task.outputs[0].bldpath(task.env) if os.path.exists(tgt): os.unlink(tgt) - if tgt.lower().endswith(".bz2"): z = tarfile.open(tgt,"w:bz2") - elif tgt.lower().endswith(".gz"): z = tarfile.open(tgt,"w:gz") - elif tgt.lower().endswith(".tgz"): z = tarfile.open(tgt,"w:gz") + if tgt.lower().endswith(".bz2"): z = tarfile.open(tgt,"w:bz2") + elif tgt.lower().endswith(".gz"): z = tarfile.open(tgt,"w:gz") + elif tgt.lower().endswith(".tgz"): z = tarfile.open(tgt,"w:gz") else: z = tarfile.open(tgt,"w") fileset = {} for inp in task.inputs: @@ -25,16 +25,16 @@ def tar_up(task): srcname = Utils.relpath(src,os.path.join("..",".")) # file in source dir else: srcname = Utils.relpath(src,os.path.join(task.env.variant(),".")) # file in artifacts dir + srcname = srcname.split(os.path.sep,len(task.generator.root.split(os.path.sep)))[-1] if task.generator.rename: srcname = task.generator.rename(srcname) - for dummy in task.generator.root.split("/"): - splittedname = srcname.split("/") - srcname = "/".join(splittedname[1:]) fileset[srcname] = src for srcname,src in fileset.items(): ti = tarfile.TarInfo(srcname) ti.mode = 0755 ti.size = os.path.getsize(src) - f = file(src) + openmode = 'r' + if sys.platform == 'win32': openmode = openmode + 'b' + f = file(src,openmode) z.addfile(ti,fileobj=f) f.close() z.close()