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
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Łukasz Nowak
slapos.buildout
Commits
a434827f
Commit
a434827f
authored
May 04, 2017
by
Kazuhiko Shiozaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a wrapper shell script for very long shebang scripts for all installed files.
parent
13653bde
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
0 deletions
+38
-0
src/zc/buildout/buildout.py
src/zc/buildout/buildout.py
+38
-0
No files found.
src/zc/buildout/buildout.py
View file @
a434827f
...
...
@@ -44,6 +44,7 @@ import os
import
pkg_resources
import
re
import
shutil
import
stat
import
subprocess
import
sys
import
tempfile
...
...
@@ -213,6 +214,42 @@ def _format_picked_versions(picked_versions, required_by):
output
.
extend
(
required_output
)
return
output
def
_fix_shebang
(
installed_files
):
is_executable
=
stat
.
S_IXUSR
|
stat
.
S_IXGRP
|
stat
.
S_IXOTH
path_list
=
installed_files
.
splitlines
()
for
path
in
path_list
:
if
os
.
path
.
isdir
(
path
):
file_list
=
[]
for
(
dirpath
,
_
,
filename_list
)
in
os
.
walk
(
path
):
if
dirpath
.
endswith
(
'/EGG-INFO/scripts'
):
# shebang conversion of egg scripts will be done in
# zc.buildout.easy_install.script
continue
for
filename
in
filename_list
:
file_path
=
os
.
path
.
join
(
dirpath
,
filename
)
if
os
.
path
.
isfile
(
file_path
):
file_list
.
append
(
file_path
)
else
:
file_list
=
[
path
]
for
file_path
in
file_list
:
if
file_path
.
endswith
(
'.shebang'
)
or
os
.
path
.
islink
(
file_path
):
continue
st_mode
=
os
.
stat
(
file_path
).
st_mode
if
not
st_mode
&
is_executable
:
continue
header
=
file
(
file_path
).
readline
(
128
)
m
=
re
.
match
(
'^#! ?(/.*)'
,
header
)
if
not
m
or
len
(
header
)
<
128
:
continue
shebang_abspath
=
file_path
+
'.shebang'
os
.
rename
(
file_path
,
shebang_abspath
)
file
(
file_path
,
'w'
).
write
(
'''#!/bin/sh
exec %s "%s.shebang" "$@"
'''
%
(
m
.
groups
()[
0
],
file_path
))
os
.
chmod
(
file_path
,
stat
.
S_IMODE
(
st_mode
))
if
not
os
.
path
.
isdir
(
path
):
path_list
.
append
(
shebang_abspath
)
return
'
\
n
'
.
join
(
sorted
(
path_list
))
_buildout_default_options
=
_annotate_section
({
'allow-hosts'
:
'*'
,
...
...
@@ -812,6 +849,7 @@ class Buildout(DictMixin):
elif
not
isinstance
(
installed_files
,
str
):
installed_files
=
'
\
n
'
.
join
(
installed_files
)
installed_files
=
_fix_shebang
(
installed_files
)
saved_options
[
'__buildout_installed__'
]
=
installed_files
saved_options
[
'__buildout_signature__'
]
=
signature
installed_part_options
[
part
]
=
saved_options
...
...
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