Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
ShellB3
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Ray Garcia
ShellB3
Commits
0d350dad
Commit
0d350dad
authored
4 years ago
by
Joe Garcia
Browse files
Options
Downloads
Patches
Plain Diff
fallbacks for missing environment (if used outside SB3)
parent
09625ca7
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
ShellB3/sb3bin/thosewhohuntelfs.py
+45
-15
45 additions, 15 deletions
ShellB3/sb3bin/thosewhohuntelfs.py
with
45 additions
and
15 deletions
ShellB3/sb3bin/thosewhohuntelfs.py
+
45
−
15
View file @
0d350dad
...
...
@@ -78,6 +78,29 @@ def acceptableMachoHeaders(path=None,machoobj=None,includeall=False):
continue
yield
header
def
macToDarwinVer
(
v
):
vparts
=
v
.
replace
(
'
*
'
,
''
).
split
(
'
.
'
)
vv
=
int
(
vparts
[
0
])
if
vv
>
10
:
return
20
-
11
+
vv
return
4
+
int
(
vparts
[
1
])
def
darwinToMacVer
(
v
):
if
v
>=
20
:
return
"
{}
"
.
format
(
v
+
11
-
20
)
return
"
10.{}
"
.
format
(
v
-
4
)
def
macVer
(
v
):
dar
=
macToDarwinVer
(
v
)
nam
=
None
if
dar
<=
11
:
nam
=
"
Mac OS X
"
elif
dar
<=
15
:
nam
=
"
OS X
"
else
:
nam
=
"
macOS
"
return
"
{} {}
"
.
format
(
nam
,
darwinToMacVer
(
dar
))
def
ismacho
(
path
,
linkok
=
False
):
try
:
#print path
...
...
@@ -443,11 +466,26 @@ def probe(base,forbiddenlibs=''):
printerr
(
'
Forbidden libs are {}
'
.
format
(
'
,
'
.
join
(
forbiddenlibs
)))
fullbase
=
os
.
path
.
realpath
(
base
)
usesysroot
=
sysroot
#os.getenv('SYSROOT','')
darwinNumber
=
os
.
getenv
(
"
SDKDARWINVERNUMBER
"
,
None
)
macname
=
None
if
elvish
:
pass
elif
darwinNumber
is
not
None
:
darwinNumber
=
int
(
darwinNumber
)
elif
os
.
getenv
(
'
MACOSX_DEPLOYMENT_TARGET
'
,
None
)
is
not
None
:
darwinNumber
=
macToDarwinVer
(
os
.
getenv
(
'
MACOSX_DEPLOYMENT_TARGET
'
))
else
:
darwinNumber
=
int
(
platform
.
release
().
split
(
'
.
'
)[
0
])
macname
=
macVer
(
darwinToMacVer
(
darwinNumber
))
if
darwinNumber
>=
20
and
len
(
usesysroot
)
<=
1
:
usesysroot
=
"
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk
"
for
path
in
hunt_elfs
(
base
,
elvish
=
elvish
):
if
elvish
:
print
(
path
+
"
=> {}
"
.
format
(
printable_rpath
(
path
))),
rc
=
ldd
(
path
,
forbiddenlibs
=
forbiddenlibs
)
else
:
if
macname
is
None
:
macname
=
macVer
(
os
.
getenv
(
'
MACOSX_DEPLOYMENT_TARGET
'
))
rpaths
,
libs
=
macho_get_rpath
(
path
)
print
(
"
{} => rpaths {}
"
.
format
(
path
.
replace
(
fullbase
,
'
[ShellB3]:
'
),
'
,
'
.
join
(
rpaths
)))
rc
=
0
...
...
@@ -467,7 +505,7 @@ def probe(base,forbiddenlibs=''):
if
len
(
usesysroot
)
>
1
:
li
=
usesysroot
+
li
dli
=
li
if
int
(
os
.
getenv
(
"
SDKDARWINVERNUMBER
"
))
>=
15
:
#these SDKs don't store dylibs but "tdb" files
if
darwinNumber
>=
15
:
#these SDKs don't store dylibs but "tdb" files
if
li
.
endswith
(
'
.dylib
'
):
li
=
li
.
replace
(
'
.dylib
'
,
''
)
li
=
li
+
'
.tbd
'
...
...
@@ -477,18 +515,7 @@ def probe(base,forbiddenlibs=''):
if
dli
.
startswith
(
fullbase
):
dli
=
dli
.
replace
(
fullbase
,
'
[ShellB3]:
'
)
if
len
(
usesysroot
)
>
1
and
dli
.
startswith
(
usesysroot
):
def
macVer
(
v
):
vparts
=
v
.
replace
(
'
*
'
,
''
).
split
(
'
.
'
)
vv
=
int
(
vparts
[
0
])
if
vv
>
10
:
return
"
macOS {}
"
.
format
(
vv
)
iv
=
int
(
vparts
[
1
])
if
iv
<=
7
:
return
'
Mac OS X
'
+
v
if
iv
<=
11
:
return
"
OS X
"
+
v
return
"
macOS
"
+
v
dli
=
dli
.
replace
(
usesysroot
,
'
[
'
+
macVer
(
os
.
getenv
(
'
MACOSX_DEPLOYMENT_TARGET
'
))
+
'
]:
'
)
dli
=
dli
.
replace
(
usesysroot
,
'
[
'
+
macname
+
'
]:
'
)
if
os
.
access
(
li
,
os
.
R_OK
):
print
(
'
{} => {}
'
.
format
(
lib
,
dli
))
for
l
in
forbiddenlibs
:
...
...
@@ -496,7 +523,10 @@ def probe(base,forbiddenlibs=''):
print
(
'
@
'
*
32
+
'
Library named
'
+
os
.
path
.
basename
(
li
)
+
'
matches forbidden library
'
+
l
)
rc
=
1
else
:
print
(
'
{} => not found at {}
'
.
format
(
lib
,
li
))
pli
=
li
if
len
(
usesysroot
)
>
1
and
pli
.
startswith
(
usesysroot
):
pli
=
pli
.
replace
(
usesysroot
,
"
[Portable System SDK]
"
)
print
(
'
{} => not found at {}
'
.
format
(
lib
,
pli
))
printerr
(
'
{} cant find {} (Really its {})
'
.
format
(
path
,
lib
,
li
))
rc
=
1
if
rc
!=
0
:
...
...
@@ -544,7 +574,7 @@ def thosewhohuntelfs(base, *rpaths,**kwargs):
mybase
=
base
add_rpaths
=
[
join
(
'
@loader_path
'
,
os
.
path
.
relpath
(
base
,
dirp
))]
if
'
64
'
in
os
.
getenv
(
'
CPUTYPE
'
,
platform
.
machine
()):
#32bit mac can't do multiple paths safely
for
an_rpath
in
(
'
Library/Frameworks/Python.framework
'
,
'
Library/Frameworks/Python.framework/Versions/
'
+
os
.
getenv
(
'
PYFSVER
'
)):
#,'Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents'):
for
an_rpath
in
(
'
Library/Frameworks/Python.framework
'
,
'
Library/Frameworks/Python.framework/Versions/
'
+
os
.
getenv
(
'
PYFSVER
'
,
"
Current
"
)):
#,'Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents'):
if
an_rpath
in
path
:
mybase
=
os
.
path
.
join
(
base
,
an_rpath
)
add_rpaths
.
insert
(
0
,
join
(
'
@loader_path
'
,
os
.
path
.
relpath
(
mybase
,
dirp
)))
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment