- strip support!
Use NoStrip global variable in actions.py if you don't want/need to strip a path/file...
This commit is contained in:
+17
-2
@@ -162,6 +162,8 @@ class PisiBuild:
|
|||||||
self.run_build_action()
|
self.run_build_action()
|
||||||
self.run_install_action()
|
self.run_install_action()
|
||||||
|
|
||||||
|
self.strip_install_dir()
|
||||||
|
|
||||||
# after all, we are ready to build/prepare the packages
|
# after all, we are ready to build/prepare the packages
|
||||||
self.build_packages()
|
self.build_packages()
|
||||||
|
|
||||||
@@ -287,6 +289,16 @@ class PisiBuild:
|
|||||||
ctx.ui.action(_("* Applying patch: %s") % patch.filename)
|
ctx.ui.action(_("* Applying patch: %s") % patch.filename)
|
||||||
util.do_patch(self.srcDir, patchFile, level=patch.level, target=patch.target)
|
util.do_patch(self.srcDir, patchFile, level=patch.level, target=patch.target)
|
||||||
|
|
||||||
|
def strip_install_dir(self):
|
||||||
|
"""strip install directory"""
|
||||||
|
ctx.ui.action(_("Stripping files.."))
|
||||||
|
install_dir = self.bctx.pkg_install_dir()
|
||||||
|
try:
|
||||||
|
nostrip = self.actionGlobals['NoStrip']
|
||||||
|
util.strip_directory(install_dir, nostrip)
|
||||||
|
except KeyError:
|
||||||
|
util.strip_directory(install_dir)
|
||||||
|
|
||||||
def gen_metadata_xml(self, package):
|
def gen_metadata_xml(self, package):
|
||||||
"""Generate the metadata.xml file for build source.
|
"""Generate the metadata.xml file for build source.
|
||||||
|
|
||||||
@@ -314,7 +326,8 @@ class PisiBuild:
|
|||||||
else:
|
else:
|
||||||
metadata.package.build = self.calc_build_no(metadata.package.name)
|
metadata.package.build = self.calc_build_no(metadata.package.name)
|
||||||
|
|
||||||
metadata.write(os.path.join(self.bctx.pkg_dir(), ctx.const.metadata_xml))
|
metadata_xml_path = os.path.join(self.bctx.pkg_dir(), ctx.const.metadata_xml)
|
||||||
|
metadata.write(metadata_xml_path)
|
||||||
self.metadata = metadata
|
self.metadata = metadata
|
||||||
|
|
||||||
def gen_files_xml(self, package):
|
def gen_files_xml(self, package):
|
||||||
@@ -339,7 +352,9 @@ class PisiBuild:
|
|||||||
d[frpath] = FileInfo(frpath, ftype, fsize, fhash)
|
d[frpath] = FileInfo(frpath, ftype, fsize, fhash)
|
||||||
for (p, fileinfo) in d.iteritems():
|
for (p, fileinfo) in d.iteritems():
|
||||||
files.append(fileinfo)
|
files.append(fileinfo)
|
||||||
files.write(os.path.join(self.bctx.pkg_dir(), ctx.const.files_xml))
|
|
||||||
|
files_xml_path = os.path.join(self.bctx.pkg_dir(), ctx.const.files_xml)
|
||||||
|
files.write(files_xml_path)
|
||||||
self.files = files
|
self.files = files
|
||||||
|
|
||||||
def calc_build_no(self, package_name):
|
def calc_build_no(self, package_name):
|
||||||
|
|||||||
@@ -353,6 +353,48 @@ def do_patch(sourceDir, patchFile, level, target = ''):
|
|||||||
|
|
||||||
os.chdir(cwd)
|
os.chdir(cwd)
|
||||||
|
|
||||||
|
|
||||||
|
def strip_directory(top, excludelist=[]):
|
||||||
|
for root, dirs, files in os.walk(top):
|
||||||
|
for fn in files:
|
||||||
|
frpath = os.path.join(root, fn)
|
||||||
|
|
||||||
|
# real path in .pisi package
|
||||||
|
p = '/' + removepathprefix(top, frpath)
|
||||||
|
strip = True
|
||||||
|
for exclude in excludelist:
|
||||||
|
if p.startswith(exclude):
|
||||||
|
strip = False
|
||||||
|
|
||||||
|
if strip:
|
||||||
|
strip_file(frpath)
|
||||||
|
|
||||||
|
def strip_file(filepath):
|
||||||
|
"""strip a file"""
|
||||||
|
p = os.popen("file %s" % filepath)
|
||||||
|
o = p.read()
|
||||||
|
|
||||||
|
def run_strip(f, flags=""):
|
||||||
|
p = os.popen("strip %s %s" %(flags, f))
|
||||||
|
ret = p.close()
|
||||||
|
if ret:
|
||||||
|
raise UtilError, "strip command failed!"
|
||||||
|
|
||||||
|
if "current ar archive" in o:
|
||||||
|
run_strip(filepath, "-g")
|
||||||
|
return True
|
||||||
|
|
||||||
|
elif "SB executable" in o:
|
||||||
|
run_strip(filepath)
|
||||||
|
return True
|
||||||
|
|
||||||
|
elif "SB shared object" in o:
|
||||||
|
run_strip(filepath, "--strip-unneeded")
|
||||||
|
# FIXME: warn for TEXTREL
|
||||||
|
return True
|
||||||
|
|
||||||
|
return False
|
||||||
|
|
||||||
def partition_freespace(directory):
|
def partition_freespace(directory):
|
||||||
""" returns free space of given directory's partition """
|
""" returns free space of given directory's partition """
|
||||||
st = os.statvfs(directory)
|
st = os.statvfs(directory)
|
||||||
|
|||||||
Reference in New Issue
Block a user