Commit 24977bca authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

Revert "strip installed binaries."

Use slapos.extension.strip instead.

This reverts commit f26567c4.
parent 98d93463
...@@ -7,7 +7,6 @@ import os ...@@ -7,7 +7,6 @@ import os
import pkg_resources import pkg_resources
from platform import machine as platform_machine from platform import machine as platform_machine
import re import re
import stat
import shutil import shutil
import subprocess import subprocess
import sys import sys
...@@ -59,8 +58,6 @@ class Recipe(object): ...@@ -59,8 +58,6 @@ class Recipe(object):
options['url'] = options.get('url', '').strip() options['url'] = options.get('url', '').strip()
options['path'] = options.get('path', '').strip() options['path'] = options.get('path', '').strip()
options['promises'] = options.get('promises', '') options['promises'] = options.get('promises', '')
default_strip = bool_option(buildout['buildout'], 'strip', 'true')
options['strip'] = bool_option(options, 'strip', default_strip and 'true' or 'false')
# Check dependencies, all the dependent parts will be installed first. It # Check dependencies, all the dependent parts will be installed first. It
# seems once part is referenced, for example, self.buildout[part], it will # seems once part is referenced, for example, self.buildout[part], it will
...@@ -397,75 +394,4 @@ class Recipe(object): ...@@ -397,75 +394,4 @@ class Recipe(object):
if self.options['share'] == '': if self.options['share'] == '':
parts.append(self.options['default-location']) parts.append(self.options['default-location'])
if self.options['strip']:
self.strip(parts)
return parts return parts
def strip(self, path_list):
# Same logic as Debian's dh_strip script.
log = logging.getLogger(self.name)
args = ['find',] + list(path_list) + ['-type', 'f']
try:
p = subprocess.Popen(args, stdout=subprocess.PIPE)
file_list, _ = p.communicate()
retcode = p.returncode
if retcode < 0:
log.error('Command received signal %s: %s' % (-retcode, args))
raise zc.buildout.UserError('System error')
elif retcode > 0:
log.error('Command failed with exit code %s: %s' % (retcode, args))
raise zc.buildout.UserError('System error')
shared_lib_list = []
executable_list = []
static_lib_list = []
for path in file_list.splitlines():
file_name = os.path.basename(path)
if re.match('.*\.(so(\..*)?|cmxs)?$', file_name):
shared_lib_list.append(path)
elif os.stat(path).st_mode & stat.S_IEXEC:
try:
args = ['file', path]
p = subprocess.Popen(args, stdout=subprocess.PIPE)
result, _ = p.communicate()
if re.match('.*ELF.*(executable|shared).*', result):
executable_list.append(path)
except OSError, e:
log.warning('Command failed: %s: %s' % (e, args))
elif re.match('lib.*\.a$', file_name) and not re.match('.*_g\.a$', file_name):
static_lib_list.append(path)
for path in shared_lib_list:
strip_args = [
'--remove-section=.comment',
'--remove-section=.note',
'--strip-unneeded',
]
self.run_strip(path, strip_args)
for path in executable_list:
strip_args = [
'--remove-section=.comment',
'--remove-section=.note',
]
self.run_strip(path, strip_args)
for path in shared_lib_list:
strip_args = [
'--strip-debug',
]
self.run_strip(path, strip_args)
except OSError, e:
log.warning('Command failed: %s: %s' % (e, args))
def run_strip(self, path, strip_args):
log = logging.getLogger(self.name)
mode = os.stat(path).st_mode
writable_mode = mode | stat.S_IWUSR
if mode != writable_mode:
os.chmod(path, writable_mode)
try:
args = ['strip',] + strip_args + [path,]
p = subprocess.Popen(args, stdout=subprocess.PIPE)
result, _ = p.communicate()
except OSError, e:
log.warning('Command failed: %s: %s' % (e, args))
if mode != writable_mode:
os.chmod(path, mode)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment