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
cceefef5
Commit
cceefef5
authored
Apr 06, 2017
by
Kazuhiko Shiozaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Create a wrapper shell script for very long shebang scripts.
parent
2304e1f2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
0 deletions
+26
-0
slapos/recipe/cmmi/__init__.py
slapos/recipe/cmmi/__init__.py
+26
-0
No files found.
slapos/recipe/cmmi/__init__.py
View file @
cceefef5
...
...
@@ -8,6 +8,7 @@ import pkg_resources
from
platform
import
machine
as
platform_machine
import
re
import
shutil
import
stat
import
subprocess
import
sys
import
zc.buildout
...
...
@@ -395,4 +396,29 @@ class Recipe(object):
if
self
.
options
[
'share'
]
==
''
:
parts
.
append
(
self
.
options
[
'default-location'
])
self
.
fix_shebang
(
self
.
options
[
'default-location'
])
return
parts
def
fix_shebang
(
self
,
location
):
# Workaround for shebang line limit by renaming the script and
# putting a wrapper shell script.
for
dir
in
(
'bin'
,
'sbin'
):
dir_abspath
=
os
.
path
.
join
(
location
,
dir
)
if
not
os
.
path
.
isdir
(
dir_abspath
):
continue
for
f
in
os
.
listdir
(
dir_abspath
):
f_abspath
=
os
.
path
.
join
(
dir_abspath
,
f
)
if
not
os
.
path
.
isfile
(
f_abspath
):
continue
header
=
file
(
f_abspath
).
readline
(
128
)
m
=
re
.
match
(
'^#! ?(/.*)'
,
header
)
if
not
m
or
len
(
header
)
<
128
:
continue
shebang_abspath
=
f_abspath
+
'.shebang'
os
.
rename
(
f_abspath
,
shebang_abspath
)
file
(
f_abspath
,
'w'
).
write
(
'''#!/bin/sh
shebang=$(head -1 "$0.shebang")
exec ${shebang#
\
#!}
"
$0.shebang" "$@"
'''
)
os
.
chmod
(
f_abspath
,
stat
.
S_IMODE
(
os
.
stat
(
shebang_abspath
).
st_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