Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.buildout
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
6
Merge Requests
6
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
slapos.buildout
Commits
4d6a8c28
Commit
4d6a8c28
authored
Oct 22, 2014
by
Kazuhiko Shiozaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add slapos.extension.strip.
parent
85830c30
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
182 additions
and
0 deletions
+182
-0
slapos.extension.strip_/CHANGES.txt
slapos.extension.strip_/CHANGES.txt
+8
-0
slapos.extension.strip_/MANIFEST.in
slapos.extension.strip_/MANIFEST.in
+1
-0
slapos.extension.strip_/README.rst
slapos.extension.strip_/README.rst
+48
-0
slapos.extension.strip_/setup.py
slapos.extension.strip_/setup.py
+45
-0
slapos.extension.strip_/slapos/__init__.py
slapos.extension.strip_/slapos/__init__.py
+6
-0
slapos.extension.strip_/slapos/extension/__init__.py
slapos.extension.strip_/slapos/extension/__init__.py
+6
-0
slapos.extension.strip_/slapos/extension/strip/__init__.py
slapos.extension.strip_/slapos/extension/strip/__init__.py
+68
-0
No files found.
slapos.extension.strip_/CHANGES.txt
0 → 100644
View file @
4d6a8c28
Changes
=======
0.1 (2014-10-22)
------------------
* Initial release.
slapos.extension.strip_/MANIFEST.in
0 → 100644
View file @
4d6a8c28
include *.txt
slapos.extension.strip_/README.rst
0 → 100644
View file @
4d6a8c28
Buildout Extension to strip binaries
====================================
slapos.extension.strip is a buildout extension that finds shared
libraries, binary executables and static libraries, and calls strip(1)
against them to reduce the size. It is triggered at the end of the
buildout process.
Usage
-----
Add ``slapos.extension.strip`` in ``[buildout]`` section's ``extensions`` option like :
::
[buildout]
extensions = slapos.extension.strip
Requirements
------------
The following programs are required. If any of them is missing, this
extension does nothing.
- ``file``
- ``find``
- ``strip``
Supported Options
-----------------
``file-binary``
Path to ``file`` program. Defaults to 'file' which should work on
any system that has the make program available in the system
``PATH``.
``find-binary``
Path to ``find`` program. Defaults to 'find' which should work on
any system that has the make program available in the system
``PATH``.
``strip-binary``
Path to ``strip`` program. Defaults to 'strip' which should work on
any system that has the make program available in the system
``PATH``.
slapos.extension.strip_/setup.py
0 → 100644
View file @
4d6a8c28
from
setuptools
import
setup
,
find_packages
import
os
version
=
'0.1'
name
=
'slapos.extension.strip'
def
read
(
*
rnames
):
return
open
(
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
*
rnames
)).
read
()
setup
(
name
=
name
,
version
=
version
,
description
=
"zc.buildout extension to strip binaries."
,
long_description
=
(
read
(
'README.rst'
)
+
'
\
n
'
+
read
(
'CHANGES.txt'
)
+
'
\
n
'
+
'Download
\
n
'
'***********************
\
n
'
),
classifiers
=
[
'Framework :: Buildout :: Extension'
,
'License :: OSI Approved :: BSD License'
,
'Programming Language :: Python'
,
'Topic :: Software Development :: Build Tools'
,
],
keywords
=
'buildout extension strip'
,
author
=
'Kazuhiko Shiozaki'
,
author_email
=
'kazuhiko@nexedi.com'
,
url
=
'http://git.erp5.org/gitweb/slapos.extension.strip'
,
license
=
'BSD'
,
packages
=
find_packages
(
exclude
=
[
'ez_setup'
]),
namespace_packages
=
[
'slapos'
,
'slapos.extension'
],
include_package_data
=
True
,
zip_safe
=
False
,
install_requires
=
[
'zc.buildout'
,
],
entry_points
=
{
'zc.buildout.unloadextension'
:
[
'default = slapos.extension.strip:finish'
,
],
},
)
slapos.extension.strip_/slapos/__init__.py
0 → 100644
View file @
4d6a8c28
# See http://peak.telecommunity.com/DevCenter/setuptools#namespace-packages
try
:
__import__
(
'pkg_resources'
).
declare_namespace
(
__name__
)
except
ImportError
:
from
pkgutil
import
extend_path
__path__
=
extend_path
(
__path__
,
__name__
)
slapos.extension.strip_/slapos/extension/__init__.py
0 → 100644
View file @
4d6a8c28
# See http://peak.telecommunity.com/DevCenter/setuptools#namespace-packages
try
:
__import__
(
'pkg_resources'
).
declare_namespace
(
__name__
)
except
ImportError
:
from
pkgutil
import
extend_path
__path__
=
extend_path
(
__path__
,
__name__
)
slapos.extension.strip_/slapos/extension/strip/__init__.py
0 → 100644
View file @
4d6a8c28
import
os
import
re
import
stat
import
subprocess
def
finish
(
buildout
):
print
'Stripping binaries ...'
buildout_directory
=
buildout
[
'buildout'
][
'directory'
]
file_binary
=
buildout
[
'buildout'
].
get
(
'file-binary'
,
'file'
)
find_binary
=
buildout
[
'buildout'
].
get
(
'find-binary'
,
'find'
)
strip_binary
=
buildout
[
'buildout'
].
get
(
'strip-binary'
,
'strip'
)
def
run_strip
(
path
,
strip_args
):
mode
=
os
.
stat
(
path
).
st_mode
writable_mode
=
mode
|
stat
.
S_IWUSR
if
mode
!=
writable_mode
:
os
.
chmod
(
path
,
writable_mode
)
args
=
[
strip_binary
,]
+
strip_args
+
[
path
,]
p
=
subprocess
.
Popen
(
args
,
stdout
=
subprocess
.
PIPE
)
result
,
_
=
p
.
communicate
()
if
mode
!=
writable_mode
:
os
.
chmod
(
path
,
mode
)
# Same logic as Debian's dh_strip script.
args
=
[
find_binary
,
buildout_directory
,
'-type'
,
'f'
]
try
:
p
=
subprocess
.
Popen
(
args
,
stdout
=
subprocess
.
PIPE
)
file_list
,
_
=
p
.
communicate
()
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
):
args
=
[
file_binary
,
path
]
p
=
subprocess
.
Popen
(
args
,
stdout
=
subprocess
.
PIPE
)
result
,
_
=
p
.
communicate
()
if
re
.
match
(
'.*ELF.*shared.*not stripped'
,
result
):
shared_lib_list
.
append
(
path
)
elif
os
.
stat
(
path
).
st_mode
&
stat
.
S_IEXEC
:
args
=
[
file_binary
,
path
]
p
=
subprocess
.
Popen
(
args
,
stdout
=
subprocess
.
PIPE
)
result
,
_
=
p
.
communicate
()
if
re
.
match
(
'.*ELF.*(executable|shared).* not stripped'
,
result
):
executable_list
.
append
(
path
)
elif
re
.
match
(
'lib.*
\
.
a
$'
,
file_name
):
static_lib_list
.
append
(
path
)
for
path
in
shared_lib_list
:
strip_args
=
[
'--remove-section=.comment'
,
'--remove-section=.note'
,
'--strip-unneeded'
,
]
run_strip
(
path
,
strip_args
)
for
path
in
executable_list
:
strip_args
=
[
'--remove-section=.comment'
,
'--remove-section=.note'
,
]
run_strip
(
path
,
strip_args
)
for
path
in
shared_lib_list
:
strip_args
=
[
'--strip-debug'
,
]
run_strip
(
path
,
strip_args
)
print
'Done.'
except
OSError
,
e
:
print
'Command failed: %s: %s'
%
(
e
,
args
)
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