Line 0
Link Here
|
|
|
1 |
#!/bin/sh |
2 |
# MAINTAINER: portmgr@FreeBSD.org |
3 |
# $FreeBSD$ |
4 |
|
5 |
# |
6 |
# This module finds shared objects that the port immediately depends on that |
7 |
# are not declared as immediate dependencies. |
8 |
# |
9 |
|
10 |
listcontains() { |
11 |
local str lst elt |
12 |
str=$1 |
13 |
lst=$2 |
14 |
|
15 |
for elt in ${lst} ; do |
16 |
if [ ${elt} = ${str} ] ; then |
17 |
return 0 |
18 |
fi |
19 |
done |
20 |
return 1 |
21 |
} |
22 |
|
23 |
list_staged_execs() { |
24 |
# finds all dynamic executables which have dependencies that aren't within the |
25 |
# declared set of dependencies in this port |
26 |
find ${STAGEDIR} -type f \ |
27 |
\( -perm -u+x -or -perm -g+x -or -perm -o+x \) \ |
28 |
-and -exec /bin/sh -c "ldd {} > /dev/null 2>&1" \; \ |
29 |
-and -exec echo {} \; |
30 |
} |
31 |
|
32 |
list_immediate_deps() { |
33 |
LD_LIBRARY_PATH=${LOCALBASE}/lib ldd -a "$1" | \ |
34 |
awk 'BEGIN {section=0}; /^\// {section++} /^[^\/]/ {if(section<=1) print}' | \ |
35 |
sed -e 's/.*=> //' -e 's/ .*//' |
36 |
} |
37 |
|
38 |
pkg_to_origin() { |
39 |
echo $(pkg info -o $1 | sed -E 's/^[^[:space:]]+[[:space:]]+//g') |
40 |
} |
41 |
|
42 |
proxydeps_suggest_uses() { |
43 |
local pkg=$1 |
44 |
local lib_file=$2 |
45 |
|
46 |
# miscellaneous USE clauses |
47 |
if expr ${pkg} : '^gettext-runtime' > /dev/null ; then |
48 |
warn "you need USES+=gettext" |
49 |
elif expr ${pkg} : '^glib-2' > /dev/null ; then |
50 |
warn "you need USE_GNOME+=glib20" |
51 |
elif expr ${pkg} : '^gdk-pixbuf2-' > /dev/null ; then |
52 |
warn "you need USE_GNOME+=gdkpixbuf2" |
53 |
elif expr ${pkg} : '^gtk2' > /dev/null ; then |
54 |
warn "you need USE_GNOME+=gtk20" |
55 |
elif expr ${pkg} : '^gtk3' > /dev/null ; then |
56 |
warn "you need USE_GNOME+=gtk30" |
57 |
elif expr ${pkg} : '^cairo-[0-9]' > /dev/null ; then |
58 |
warn "you need USE_GNOME+=cairo" |
59 |
elif expr ${pkg} : '^sqlite3' > /dev/null ; then |
60 |
warn "you need USES+=sqlite" |
61 |
# sdl-related |
62 |
elif expr ${pkg} : '^sdl-1' > /dev/null ; then |
63 |
warn "you need USE_SDL+=sdl" |
64 |
elif echo ${pkg} | grep -E '^sdl_(console|gfx|image|mixer|mm|net|pango|sound|ttf)-' > /dev/null ; then |
65 |
warn "you need USE_SDL+=$(echo ${pkg} | sed -E 's/^sdl_(.+)\-.*/\1/')" |
66 |
elif expr ${pkg} : '^sdl2-2' > /dev/null ; then |
67 |
warn "you need USE_SDL+=sdl2" |
68 |
elif echo ${pkg} | grep -E '^sdl2_(gfx|image|mixer|net|ttf)-' > /dev/null ; then |
69 |
warn "you need USE_SDL+=$(echo ${pkg} | sed -E 's/^sdl2_(.+)\-.*/\1/')2" |
70 |
# gl-related |
71 |
elif expr ${pkg} : 'libGL-[0-9]' > /dev/null ; then |
72 |
warn "you need USE_GL+=gl" |
73 |
elif expr ${pkg} : 'gbm-[0-9]' > /dev/null ; then |
74 |
warn "you need USE_GL+=gbm" |
75 |
elif expr ${pkg} : 'libglesv2-[0-9]' > /dev/null ; then |
76 |
warn "you need USE_GL+=glesv2" |
77 |
elif expr ${pkg} : '^libEGL-[0-9]' > /dev/null ; then |
78 |
warn "you need USE_GL+=egl" |
79 |
elif expr ${pkg} : '^glew-[0-9]' > /dev/null ; then |
80 |
warn "you need USE_GL+=glew" |
81 |
elif expr ${pkg} : '^libGLU-[0-9]' > /dev/null ; then |
82 |
warn "you need USE_GL+=glu" |
83 |
elif expr ${pkg} : '^libGLw-[0-9]' > /dev/null ; then |
84 |
warn "you need USE_GL+=glw" |
85 |
elif expr ${pkg} : '^freeglut-[0-9]' > /dev/null ; then |
86 |
warn "you need USE_GL+=glut" |
87 |
# Xorg-libraries: this should be by XORG_MODULES @ bsd.xorg.mk |
88 |
elif echo ${pkg} | grep -E '^lib(X11|Xau|Xdmcp|Xext|SM|ICE|Xfixes|Xft|Xdamage|Xcomposite|Xcursor|Xinerama|Xmu|Xmuu|Xpm|Xt|Xtst|Xi|Xrandr|Xrender|Xres|XScrnSaver|Xv|Xxf86vm|Xxf86dga|Xxf86misc|xcb)-' > /dev/null ; then |
89 |
warn "you need USE_XORG+=$(echo ${pkg} | sed -E 's/^lib(.+)\-.*/\1/' | tr '[:upper:]' '[:lower:]')" |
90 |
elif expr ${pkg} : '^pixman-[0-9]' > /dev/null ; then |
91 |
warn "you need USE_XORG+=pixman" |
92 |
# Qt4 |
93 |
elif echo ${pkg} | grep -E '^qt4-([a-z0-9]+)-[0-9]' > /dev/null ; then |
94 |
warn "you need USE_QT4+=$(echo ${pkg} | sed -E 's/^qt4-([a-z0-9]+)-[0-9].*/\1/')" |
95 |
# Qt5 |
96 |
elif echo ${pkg} | grep -E '^qt5-([a-z]+)-[0-9]' > /dev/null ; then |
97 |
warn "you need USE_QT5+=$(echo ${pkg} | sed -E 's/^qt5-([a-z]+)-[0-9].*/\1/')" |
98 |
# MySQL |
99 |
elif expr ${lib_file} : "${LOCALBASE}/lib/mysql/[^/]*$" > /dev/null ; then |
100 |
warn "you need USES+=mysql" |
101 |
# default |
102 |
elif expr ${lib_file} : "${LOCALBASE}/lib/[^/]*$" > /dev/null ; then |
103 |
lib_file=${lib_file#${LOCALBASE}/lib/} |
104 |
lib_file=${lib_file%.so*}.so |
105 |
warn "you need LIB_DEPENDS+=${lib_file}:$(pkg_to_origin ${pkg})" |
106 |
fi |
107 |
} |
108 |
|
109 |
subst_dep_file() { |
110 |
local dep_file=$1 |
111 |
if expr ${dep_file} : "${LOCALBASE}/lib/libGL.so.[0-9]$" > /dev/null ; then |
112 |
if [ -f ${LOCALBASE}/lib/.mesa/libGL.so ] ; then |
113 |
echo ${LOCALBASE}/lib/.mesa/libGL.so |
114 |
return |
115 |
fi |
116 |
elif expr ${dep_file} : "${LOCALBASE}/lib/libEGL.so.[0-9]$" > /dev/null ; then |
117 |
if [ -f ${LOCALBASE}/lib/.mesa/libEGL.so ] ; then |
118 |
echo ${LOCALBASE}/lib/.mesa/libEGL.so |
119 |
return |
120 |
fi |
121 |
fi |
122 |
echo ${dep_file} |
123 |
} |
124 |
|
125 |
proxydeps() { |
126 |
local pkg="${PKG_NAME}" |
127 |
local filelist="$(list_staged_execs)" |
128 |
local deplist="${PKG_DEPS}" |
129 |
|
130 |
local file dep_file dep_file_pkg already pkg_dep_files |
131 |
|
132 |
# check for every dynamic executable |
133 |
for file in ${filelist}; do |
134 |
pkg_dep_files=$(list_immediate_deps "${file}") |
135 |
for dep_file in $pkg_dep_files; do |
136 |
dep_file=$(subst_dep_file ${dep_file}) |
137 |
if listcontains ${dep_file} "${already}" ; then |
138 |
continue |
139 |
fi |
140 |
if ! (expr "$dep_file" : '^/lib/' \| "$dep_file" : '^/usr/lib/' > /dev/null) ; then |
141 |
if $(pkg which ${dep_file} > /dev/null 2>&1) ; then |
142 |
dep_file_pkg=$(pkg which ${dep_file} | sed -e 's/.* installed by package //g') |
143 |
if ! listcontains ${dep_file_pkg} "${deplist} ${pkg}" && [ $(pkg_to_origin ${dep_file_pkg}) != ${PKG_ORIGIN} ] ; then |
144 |
warn "dependency file '${dep_file}' belongs to the package ${dep_file_pkg} which isn't declared as a dependency" |
145 |
proxydeps_suggest_uses ${dep_file_pkg} ${dep_file} |
146 |
fi |
147 |
else |
148 |
warn "dependency file '${dep_file}' doesn't belong to any package" |
149 |
fi |
150 |
fi |
151 |
already="${already} ${dep_file}" |
152 |
done |
153 |
done |
154 |
} |