Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.recipe.cmmi
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Jérome Perrin
slapos.recipe.cmmi
Commits
f26567c4
Commit
f26567c4
authored
Oct 21, 2014
by
Kazuhiko Shiozaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
strip installed binaries.
parent
651071c2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
74 additions
and
0 deletions
+74
-0
slapos/recipe/cmmi/__init__.py
slapos/recipe/cmmi/__init__.py
+74
-0
No files found.
slapos/recipe/cmmi/__init__.py
View file @
f26567c4
...
...
@@ -7,6 +7,7 @@ import os
import
pkg_resources
from
platform
import
machine
as
platform_machine
import
re
import
stat
import
shutil
import
subprocess
import
sys
...
...
@@ -50,6 +51,8 @@ class Recipe(object):
options
[
'url'
]
=
options
.
get
(
'url'
,
''
).
strip
()
options
[
'path'
]
=
options
.
get
(
'path'
,
''
).
strip
()
options
[
'promises'
]
=
options
.
get
(
'promises'
,
''
)
default_strip
=
buildout
[
'buildout'
].
query_bool
(
'strip'
,
'true'
)
options
[
'strip'
]
=
options
.
query_bool
(
'strip'
,
default_strip
and
'true'
or
'false'
)
# Check dependencies, all the dependent parts will be installed first. It
# seems once part is referenced, for example, self.buildout[part], it will
...
...
@@ -386,4 +389,75 @@ class Recipe(object):
if
self
.
options
[
'share'
]
==
''
:
parts
.
append
(
self
.
options
[
'default-location'
])
if
self
.
options
[
'strip'
]:
self
.
strip
(
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
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment