Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-ports
Path: blob/main/Mk/Scripts/qa.sh
24925 views
1
#!/bin/sh
2
# MAINTAINER: [email protected]
3
4
set -o pipefail
5
6
if [ -z "${STAGEDIR}" -o -z "${PREFIX}" -o -z "${LOCALBASE}" ]; then
7
echo "STAGEDIR, PREFIX, LOCALBASE required in environment." >&2
8
exit 1
9
fi
10
11
[ -n "${DEBUG_MK_SCRIPTS}" -o -n "${DEBUG_MK_SCRIPTS_QA}" ] && set -x
12
13
LF=$(printf '\nX')
14
LF=${LF%X}
15
16
notice() {
17
echo "Notice: $*" >&2
18
}
19
20
warn() {
21
echo "Warning: $*" >&2
22
}
23
24
err() {
25
echo "Error: $*" >&2
26
}
27
28
list_stagedir_elfs() {
29
cd ${STAGEDIR} && find -s . -type f \( -perm +111 -o -name '*.so*' \) "$@"
30
}
31
32
shebangonefile() {
33
local f interp interparg badinterp rc
34
35
f="$*"
36
rc=0
37
38
# whitelist some files
39
case "${f}" in
40
*.pm|*.pod|*.txt|${STAGEDIR}${LINUXBASE}/*)
41
return 0
42
;;
43
esac
44
45
interp=$(sed -n -e '1s/^#![[:space:]]*\([^[:space:]]*\).*/\1/p;2q' "${f}")
46
badinterp=""
47
case "${interp}" in
48
"") ;;
49
/bin/rc)
50
# whitelist some interpreters
51
;;
52
${LOCALBASE}/bin/python|${PREFIX}/bin/python|${LOCALBASE}/bin/python2|${PREFIX}/bin/python2|${LOCALBASE}/bin/python3|${PREFIX}/bin/python3)
53
badinterp="${interp}"
54
;;
55
${LINUXBASE}/*) ;;
56
${LOCALBASE}/bin/perl5.* | ${PREFIX}/bin/perl5.*)
57
# lang/perl5* are allowed to have these shebangs.
58
if ! expr ${PKGORIGIN} : '^lang/perl5.*' > /dev/null; then
59
err "'${interp}' is an invalid shebang for '${f#${STAGEDIR}${PREFIX}/}' you must use ${LOCALBASE}/bin/perl."
60
err "Either pass \${PERL} to the build or use USES=shebangfix"
61
rc=1
62
fi
63
;;
64
${LOCALBASE}/*) ;;
65
${PREFIX}/*) ;;
66
/bin/csh) ;;
67
/bin/sh) ;;
68
/bin/tcsh) ;;
69
/usr/bin/awk) ;;
70
/usr/bin/env)
71
interparg=$(sed -n -e '1s/^#![[:space:]]*[^[:space:]]*[[:space:]]*\([^[:space:]]*\).*/\1/p;2q' "${f}")
72
case "${interparg}" in
73
python|python2|python3)
74
badinterp="${interp} ${interparg}"
75
;;
76
esac
77
;;
78
/usr/bin/nawk) ;;
79
/usr/bin/sed) ;;
80
/usr/sbin/dtrace) ;;
81
/usr/bin/make) ;;
82
/usr/libexec/atf-sh) ;;
83
/usr/libexec/flua) ;;
84
*)
85
badinterp="${interp}"
86
;;
87
esac
88
89
if [ -n "${badinterp}" ]; then
90
err "'${badinterp}' is an invalid shebang you need USES=shebangfix for '${f#${STAGEDIR}${PREFIX}/}'"
91
rc=1
92
fi
93
94
return ${rc}
95
}
96
97
shebang() {
98
local f l link rc
99
100
rc=0
101
102
while read -r f; do
103
# No results presents a blank line from heredoc.
104
[ -z "${f}" ] && continue
105
shebangonefile "${f}" || rc=1
106
# Use heredoc to avoid losing rc from find|while subshell
107
done <<-EOF
108
$(find ${STAGEDIR}${PREFIX} \
109
-type f -perm +111 2>/dev/null)
110
EOF
111
112
return ${rc}
113
}
114
115
baselibs() {
116
local rc
117
local found_openssl
118
local file
119
[ "${PKGBASE}" = "pkg" -o "${PKGBASE}" = "pkg-devel" ] && return
120
121
while read -r f; do
122
case ${f} in
123
File:\ .*)
124
file=${f#File: .}
125
;;
126
*NEEDED*\[libarchive.so.[56]])
127
err "Bad linking on ${f##* } for ${file} please add USES=libarchive"
128
rc=1
129
;;
130
*NEEDED*\[libedit.so.7])
131
err "Bad linking on ${f##* } for ${file} please add USES=libedit"
132
rc=1
133
;;
134
*NEEDED*\[libcrypto.so.*]|*NEEDED*\[libssl.so.*])
135
found_openssl=1
136
;;
137
esac
138
done <<-EOF
139
$(list_stagedir_elfs -exec readelf -d {} + 2>/dev/null)
140
EOF
141
142
if ! list_stagedir_elfs | egrep -q 'lib(crypto|ssl).so*'; then
143
if [ -z "${USESSSL}" -a -n "${found_openssl}" ]; then
144
warn "you need USES=ssl"
145
elif [ -n "${USESSSL}" -a -z "${found_openssl}" ]; then
146
warn "you may not need USES=ssl"
147
fi
148
fi
149
return ${rc}
150
}
151
152
symlinks() {
153
local rc
154
155
rc=0
156
157
# Split stat(1) result into 2 lines and read each line separately to
158
# retain spaces in filenames.
159
while read -r l; do
160
# No results presents a blank line from heredoc.
161
[ -z "${l}" ] && continue
162
read -r link
163
case "${link}" in
164
${STAGEDIR}*)
165
err "Bad symlink '${l#${STAGEDIR}${PREFIX}/}' pointing inside the stage directory"
166
rc=1
167
;;
168
/*)
169
# Only warn for symlinks within the package.
170
if [ -e "${STAGEDIR}${link}" ]; then
171
warn "Bad symlink '${l#${STAGEDIR}}' pointing to an absolute pathname '${link}'"
172
fi
173
# Also warn if the symlink exists nowhere.
174
if [ ! -e "${STAGEDIR}${link}" -a ! -e "${link}" ]; then
175
warn "Symlink '${l#${STAGEDIR}}' pointing to '${link}' which does not exist in the stage directory or in localbase"
176
fi
177
;;
178
esac
179
# Use heredoc to avoid losing rc from find|while subshell.
180
done <<-EOF
181
$(find ${STAGEDIR} -type l -exec stat -f "%N${LF}%Y" {} +)
182
EOF
183
184
return ${rc}
185
}
186
187
paths() {
188
local rc
189
190
rc=0
191
192
while read -r f; do
193
# No results presents a blank line from heredoc.
194
[ -z "${f}" ] && continue
195
# Ignore false-positive/harmless files
196
case "${f}" in
197
*/lib/ruby/gems/*) continue ;;
198
*/share/texmf-var/web2c/*/*.fmt) continue ;;
199
*/share/texmf-var/web2c/*/*.log) continue ;;
200
esac
201
err "'${f#${STAGEDIR}${PREFIX}/}' is referring to ${STAGEDIR}"
202
rc=1
203
# Use heredoc to avoid losing rc from find|while subshell
204
done <<-EOF
205
$(find ${TMPPLIST} ${STAGEDIR} -type f -exec grep -l "${STAGEDIR}" {} +)
206
EOF
207
208
return ${rc}
209
}
210
211
# For now do not raise an error, just warnings
212
stripped() {
213
[ -x /usr/bin/file ] || return # this is fatal
214
[ -n "${STRIP}" ] || return 0
215
# Split file and result into 2 lines and read separately to ensure
216
# files with spaces are kept intact.
217
# Using readelf -h ... /ELF Header:/ will match on all ELF files.
218
find ${STAGEDIR} -type f ! -name '*.a' ! -name '*.o' \
219
-exec sh -c 'readelf -S -- /dev/null "$0" "$@" || :' -- {} + 2>/dev/null | awk '
220
/File:/ {sub(/File: /, "", $0); file=$0}
221
/[[:space:]]\.debug_info[[:space:]]*PROGBITS/ {print file}' |
222
while read -r f; do
223
warn "'${f#${STAGEDIR}${PREFIX}/}' is not stripped consider trying INSTALL_TARGET=install-strip or using \${STRIP_CMD}"
224
done
225
}
226
227
desktopfileutils() {
228
if [ -z "${USESDESKTOPFILEUTILS}" ]; then
229
grep -q MimeType= ${STAGEDIR}${PREFIX}/share/applications/*.desktop 2>/dev/null &&
230
warn "you need USES=desktop-file-utils"
231
else
232
grep -q MimeType= ${STAGEDIR}${PREFIX}/share/applications/*.desktop 2>/dev/null ||
233
warn "you may not need USES=desktop-file-utils"
234
fi
235
return 0
236
}
237
238
sharedmimeinfo() {
239
local f found
240
241
found=0
242
for f in ${STAGEDIR}${PREFIX}/share/mime/packages/*.xml; do
243
[ "${f}" = "${STAGEDIR}${PREFIX}/share/mime/packages/*.xml" ] && break #no matches
244
[ "${f}" = "${STAGEDIR}${PREFIX}/share/mime/packages/freedesktop.org.xml" ] && continue
245
found=1
246
break
247
done
248
if [ -z "${USESSHAREDMIMEINFO}" -a ${found} -eq 1 ]; then
249
warn "you need USES=shared-mime-info"
250
elif [ -n "${USESSHAREDMIMEINFO}" -a ${found} -eq 0 ]; then
251
warn "you may not need USES=shared-mime-info"
252
fi
253
return 0
254
}
255
256
suidfiles() {
257
local filelist
258
259
filelist=$(find ${STAGEDIR} -type f \
260
\( -perm -u+x -or -perm -g+x -or -perm -o+x \) \
261
\( -perm -u+s -or -perm -g+s \))
262
if [ -n "${filelist}" ]; then
263
warn "setuid files in the stage directory (are these necessary?):"
264
ls -liTd ${filelist}
265
fi
266
return 0
267
}
268
269
libtool() {
270
if [ -z "${USESLIBTOOL}" ]; then
271
find ${STAGEDIR} -name '*.la' | while read -r f; do
272
if grep -q 'libtool library' "${f}"; then
273
err ".la libraries found, port needs USES=libtool"
274
return 1
275
fi
276
done
277
# The return above continues here.
278
fi
279
}
280
281
libperl() {
282
local has_some_libperl_so files found
283
if [ -n "${SITE_ARCH_REL}" -a -d "${STAGEDIR}${PREFIX}/${SITE_ARCH_REL}" ]; then
284
has_some_libperl_so=0
285
files=0
286
while read -r f; do
287
# No results presents a blank line from heredoc.
288
[ -z "${f}" ] && continue
289
files=$((files+1))
290
found=$(readelf -d ${f} | awk "BEGIN {libperl=1}
291
/NEEDED.*${LIBPERL}/ { libperl = 0 }
292
END {print libperl}
293
")
294
case "${found}" in
295
1)
296
warn "${f} is not linked with ${LIBPERL}, not respecting lddlflags?"
297
;;
298
0)
299
has_some_libperl_so=1
300
;;
301
esac
302
# Use heredoc to avoid losing rc from find|while subshell
303
done <<-EOT
304
$(find ${STAGEDIR}${PREFIX}/${SITE_ARCH_REL} -name '*.so')
305
EOT
306
307
if [ ${files} -gt 0 -a ${has_some_libperl_so} -eq 0 ]; then
308
err "None of the ${files} .so in ${STAGEDIR}${PREFIX}/${SITE_ARCH_REL} are linked with ${LIBPERL}, see above for the full list."
309
return 1
310
else
311
return 0
312
fi
313
fi
314
}
315
316
prefixvar() {
317
if [ ${PREFIX} != ${LINUXBASE} -a -d ${STAGEDIR}${PREFIX}/var ]; then
318
warn "port uses ${PREFIX}/var instead of /var"
319
fi
320
}
321
322
terminfo() {
323
local f found
324
325
for f in ${STAGEDIR}${PREFIX}/share/misc/*.terminfo; do
326
[ "${f}" = "${STAGEDIR}${PREFIX}/share/misc/*.terminfo" ] && break #no matches
327
found=1
328
break
329
done
330
for f in ${STAGEDIR}${PREFIX}/share/misc/terminfo.db*; do
331
[ "${f}" = "${STAGEDIR}${PREFIX}/share/misc/terminfo.db*" ] && break #no matches
332
found=1
333
break
334
done
335
if [ -z "${USESTERMINFO}" -a -n "${found}" ]; then
336
warn "you need USES=terminfo"
337
elif [ -n "${USESTERMINFO}" -a -z "${found}" ]; then
338
warn "you may not need USES=terminfo"
339
fi
340
return 0
341
}
342
343
listcontains() {
344
local str lst elt
345
str=$1
346
lst=$2
347
348
for elt in ${lst} ; do
349
if [ ${elt} = ${str} ]; then
350
return 0
351
fi
352
done
353
return 1
354
}
355
356
proxydeps_suggest_uses() {
357
local pkg=$1
358
local lib_file=$2
359
360
# miscellaneous USE clauses
361
if [ ${pkg} = 'devel/gettext-runtime' ]; then
362
warn "you need USES+=gettext-runtime"
363
elif [ ${pkg} = 'databases/sqlite3' ]; then
364
warn "you need USES+=sqlite"
365
elif [ ${pkg} = 'databases/sqlite2' ]; then
366
warn "you need USES+=sqlite:2"
367
# Gnome -> same as port
368
# grep LIB_DEPENDS= Mk/Uses/gnome.mk |sed -e 's|\(.*\)_LIB_DEPENDS.*:\(.*\)\/\(.*\)|[ "\1" = "\3" ] \&\& echo "\\${pkg} = \\\"\2/\3\\\" -o \\\\"|'|sort|sh
369
elif [ ${pkg} = "accessibility/atk" -o \
370
${pkg} = "accessibility/atkmm" -o \
371
${pkg} = "graphics/cairo" -o \
372
${pkg} = "graphics/cairomm" -o \
373
${pkg} = "devel/dconf" -o \
374
${pkg} = "devel/gconf2" -o \
375
${pkg} = "devel/glib20" -o \
376
${pkg} = "devel/glibmm" -o \
377
${pkg} = "audio/gsound" -o \
378
${pkg} = "x11-toolkits/gtk20" -o \
379
${pkg} = "x11-toolkits/gtk30" -o \
380
${pkg} = "www/gtkhtml4" -o \
381
${pkg} = "x11-toolkits/gtkmm20" -o \
382
${pkg} = "x11-toolkits/gtkmm24" -o \
383
${pkg} = "x11-toolkits/gtkmm30" -o \
384
${pkg} = "x11-toolkits/gtksourceview2" -o \
385
${pkg} = "x11-toolkits/gtksourceview3" -o \
386
${pkg} = "x11-toolkits/gtksourceviewmm3" -o \
387
${pkg} = "databases/libgda5" -o \
388
${pkg} = "databases/libgda5-ui" -o \
389
${pkg} = "devel/libglade2" -o \
390
${pkg} = "graphics/libgnomecanvas" -o \
391
${pkg} = "x11/libgnomekbd" -o \
392
${pkg} = "devel/libgsf" -o \
393
${pkg} = "graphics/librsvg2" -o \
394
${pkg} = "devel/libsigc++12" -o \
395
${pkg} = "devel/libsigc++20" -o \
396
${pkg} = "x11-toolkits/libwnck" -o \
397
${pkg} = "x11-toolkits/libwnck3" -o \
398
${pkg} = "textproc/libxml++26" -o \
399
${pkg} = "textproc/libxml2" -o \
400
${pkg} = "textproc/libxslt" -o \
401
${pkg} = "x11-toolkits/pango" -o \
402
${pkg} = "x11-toolkits/pangomm" -o \
403
${pkg} = "x11-toolkits/pangox-compat" -o \
404
${pkg} = "x11-toolkits/vte" -o \
405
${pkg} = "x11-toolkits/vte3" ]; then
406
warn "you need USE_GNOME+=${pkg#*/}"
407
# Gnome different as port
408
# grep LIB_DEPENDS= Mk/Uses/gnome.mk |sed -e 's|\(.*\)_LIB_DEPENDS.*:\(.*\)\/\(.*\)|[ "\1" = "\3" ] \|\| echo "elif [ \\${pkg} = \\\"\2/\3\\\" ]; then; warn \\\"you need USE_GNOME+=\1\\\""|'|sort|sh
409
elif [ ${pkg} = "databases/evolution-data-server" ]; then warn "you need USE_GNOME+=evolutiondataserver3"
410
elif [ ${pkg} = "graphics/gdk-pixbuf" ]; then warn "you need USE_GNOME+=gdkpixbuf"
411
elif [ ${pkg} = "graphics/gdk-pixbuf2" ]; then warn "you need USE_GNOME+=gdkpixbuf"
412
elif [ ${pkg} = "x11/gnome-desktop" ]; then warn "you need USE_GNOME+=gnomedesktop3"
413
elif [ ${pkg} = "devel/gobject-introspection" ]; then warn "you need USE_GNOME+=introspection"
414
elif [ ${pkg} = "graphics/libart_lgpl" ]; then warn "you need USE_GNOME+=libartlgpl2"
415
elif [ ${pkg} = "devel/libIDL" ]; then warn "you need USE_GNOME+=libidl"
416
elif [ ${pkg} = "x11-fm/nautilus" ]; then warn "you need USE_GNOME+=nautilus4"
417
elif [ ${pkg} = "graphics/librsvg2-rust" ]; then warn "you need USE_GNOME+=librsvg2"
418
# mate
419
# grep LIB_DEPENDS= Mk/Uses/mate.mk |sed -e 's|\(.*\)_LIB_DEPENDS.*:\(.*\)\/\(.*\)|elif [ ${pkg} = "\2/\3" ]; then warn "you need USE_MATE+=\1"|'
420
elif [ ${pkg} = "x11-fm/caja" ]; then warn "you need USE_MATE+=caja"
421
elif [ ${pkg} = "sysutils/mate-control-center" ]; then warn "you need USE_MATE+=controlcenter"
422
elif [ ${pkg} = "x11/mate-desktop" ]; then warn "you need USE_MATE+=desktop"
423
elif [ ${pkg} = "x11/libmatekbd" ]; then warn "you need USE_MATE+=libmatekbd"
424
elif [ ${pkg} = "net/libmateweather" ]; then warn "you need USE_MATE+=libmateweather"
425
elif [ ${pkg} = "x11-wm/marco" ]; then warn "you need USE_MATE+=marco"
426
elif [ ${pkg} = "x11/mate-menus" ]; then warn "you need USE_MATE+=menus"
427
elif [ ${pkg} = "x11/mate-panel" ]; then warn "you need USE_MATE+=panel"
428
elif [ ${pkg} = "sysutils/mate-polkit" ]; then warn "you need USE_MATE+=polkit"
429
# KDE
430
# grep -B1 _LIB= Mk/Uses/kde.mk | grep _PORT=|sed -e 's/^kde-\(.*\)_PORT=[[:space:]]*\([^[:space:]]*\).*/elif [ ${pkg} = "\2" ]; then warn "you need to use USE_KDE+=\1"/'
431
# KDE Applications
432
elif [ ${pkg} = "net/akonadi-contacts" ]; then warn "you need to use USE_KDE+=akonadicontacts"
433
elif [ ${pkg} = "deskutils/akonadi-import-wizard" ]; then warn "you need to use USE_KDE+=akonadiimportwizard"
434
elif [ ${pkg} = "net/akonadi-mime" ]; then warn "you need to use USE_KDE+=akonadimime"
435
elif [ ${pkg} = "net/akonadi-notes" ]; then warn "you need to use USE_KDE+=akonadinotes"
436
elif [ ${pkg} = "net/akonadi-calendar" ]; then warn "you need to use USE_KDE+=akonadicalendar"
437
elif [ ${pkg} = "net/akonadi-search" ]; then warn "you need to use USE_KDE+=akonadisearch"
438
elif [ ${pkg} = "net/calendarsupport" ]; then warn "you need to use USE_KDE+=calendarsupport"
439
elif [ ${pkg} = "net/kcalcore" ]; then warn "you need to use USE_KDE+=calendarcore"
440
elif [ ${pkg} = "net/kcalutils" ]; then warn "you need to use USE_KDE+=calendarutils"
441
elif [ ${pkg} = "net/kcontacts" ]; then warn "you need to use USE_KDE+=contacts"
442
elif [ ${pkg} = "net/eventviews" ]; then warn "you need to use USE_KDE+=eventviews"
443
elif [ ${pkg} = "net/libkgapi" ]; then warn "you need to use USE_KDE+=gapi"
444
elif [ ${pkg} = "deskutils/grantleetheme" ]; then warn "you need to use USE_KDE+=grantleetheme"
445
elif [ ${pkg} = "net/libgravatar" ]; then warn "you need to use USE_KDE+=gravatar"
446
elif [ ${pkg} = "net/kidentitymanagement" ]; then warn "you need to use USE_KDE+=identitymanagement"
447
elif [ ${pkg} = "net/kimap" ]; then warn "you need to use USE_KDE+=imap"
448
elif [ ${pkg} = "net/incidenceeditor" ]; then warn "you need to use USE_KDE+=incidenceeditor"
449
elif [ ${pkg} = "deskutils/kdepim-apps-libs" ]; then warn "you need to use USE_KDE+=kdepim-apps-libs"
450
elif [ ${pkg} = "net/kitinerary" ]; then warn "you need to use USE_KDE+=kitinerary"
451
elif [ ${pkg} = "net/kontactinterface" ]; then warn "you need to use USE_KDE+=kontactinterface"
452
elif [ ${pkg} = "net/kf5-kdav" ]; then warn "you need to use USE_KDE+=kdav"
453
elif [ ${pkg} = "security/kpkpass" ]; then warn "you need to use USE_KDE+=kpkpass"
454
elif [ ${pkg} = "net/ksmtp" ]; then warn "you need to use USE_KDE+=ksmtp"
455
elif [ ${pkg} = "net/kldap" ]; then warn "you need to use USE_KDE+=ldap"
456
elif [ ${pkg} = "deskutils/libkdepim" ]; then warn "you need to use USE_KDE+=libkdepim"
457
elif [ ${pkg} = "security/libkleo" ]; then warn "you need to use USE_KDE+=libkleo"
458
elif [ ${pkg} = "net/libksieve" ]; then warn "you need to use USE_KDE+=libksieve"
459
elif [ ${pkg} = "net/mailcommon" ]; then warn "you need to use USE_KDE+=mailcommon"
460
elif [ ${pkg} = "net/mailimporter" ]; then warn "you need to use USE_KDE+=mailimporter"
461
elif [ ${pkg} = "net/kmailtransport" ]; then warn "you need to use USE_KDE+=mailtransport"
462
elif [ ${pkg} = "net/kmbox" ]; then warn "you need to use USE_KDE+=mbox"
463
elif [ ${pkg} = "net/messagelib" ]; then warn "you need to use USE_KDE+=messagelib"
464
elif [ ${pkg} = "net/kmime" ]; then warn "you need to use USE_KDE+=mime"
465
elif [ ${pkg} = "net/pimcommon" ]; then warn "you need to use USE_KDE+=pimcommon"
466
elif [ ${pkg} = "net/kpimtextedit" ]; then warn "you need to use USE_KDE+=pimtextedit"
467
elif [ ${pkg} = "net/ktnef" ]; then warn "you need to use USE_KDE+=tnef"
468
elif [ ${pkg} = "databases/akonadi" ]; then warn "you need to use USE_KDE+=akonadi"
469
elif [ ${pkg} = "sysutils/baloo-widgets" ]; then warn "you need to use USE_KDE+=baloo-widgets"
470
elif [ ${pkg} = "audio/libkcddb" ]; then warn "you need to use USE_KDE+=libkcddb"
471
elif [ ${pkg} = "audio/libkcompactdisc" ]; then warn "you need to use USE_KDE+=libkcompactdisc"
472
elif [ ${pkg} = "graphics/libkdcraw" ]; then warn "you need to use USE_KDE+=libkdcraw"
473
elif [ ${pkg} = "games/libkdegames" ]; then warn "you need to use USE_KDE+=libkdegames"
474
elif [ ${pkg} = "misc/libkeduvocdocument" ]; then warn "you need to use USE_KDE+=libkeduvocdocument"
475
elif [ ${pkg} = "graphics/libkexiv2" ]; then warn "you need to use USE_KDE+=libkexiv2"
476
elif [ ${pkg} = "graphics/libksane" ]; then warn "you need to use USE_KDE+=libksane"
477
elif [ ${pkg} = "astro/marble" ]; then warn "you need to use USE_KDE+=marble"
478
elif [ ${pkg} = "graphics/okular" ]; then warn "you need to use USE_KDE+=okular"
479
# KDE Plasma
480
elif [ ${pkg} = "x11/plasma5-kactivitymanagerd" ]; then warn "you need to use USE_KDE+=activitymanagerd"
481
elif [ ${pkg} = "x11-wm/plasma5-kdecoration" ]; then warn "you need to use USE_KDE+=decoration"
482
elif [ ${pkg} = "devel/plasma5-khotkeys" ]; then warn "you need to use USE_KDE+=hotkeys"
483
elif [ ${pkg} = "sysutils/plasma5-kmenuedit" ]; then warn "you need to use USE_KDE+=kmenuedit"
484
elif [ ${pkg} = "security/plasma5-kscreenlocker" ]; then warn "you need to use USE_KDE+=kscreenlocker"
485
elif [ ${pkg} = "x11/plasma5-libkscreen" ]; then warn "you need to use USE_KDE+=libkscreen"
486
elif [ ${pkg} = "sysutils/plasma5-libksysguard" ]; then warn "you need to use USE_KDE+=libksysguard"
487
elif [ ${pkg} = "deskutils/plasma5-milou" ]; then warn "you need to use USE_KDE+=milou"
488
elif [ ${pkg} = "x11-themes/plasma5-oxygen" ]; then warn "you need to use USE_KDE+=oxygen"
489
elif [ ${pkg} = "x11/plasma5-plasma-workspace" ]; then warn "you need to use USE_KDE+=plasma-workspace"
490
elif [ ${pkg} = "sysutils/plasma5-powerdevil" ]; then warn "you need to use USE_KDE+=powerdevil"
491
# KDE Frameworks
492
elif [ ${pkg} = "x11-toolkits/kf5-attica" ]; then warn "you need to use USE_KDE+=attica"
493
elif [ ${pkg} = "sysutils/kf5-baloo" ]; then warn "you need to use USE_KDE+=baloo"
494
elif [ ${pkg} = "x11/kf5-frameworkintegration" ]; then warn "you need to use USE_KDE+=frameworkintegration"
495
elif [ ${pkg} = "devel/kf5-kcmutils" ]; then warn "you need to use USE_KDE+=kcmutils"
496
elif [ ${pkg} = "devel/kf5-kdeclarative" ]; then warn "you need to use USE_KDE+=kdeclarative"
497
elif [ ${pkg} = "x11/kf5-kded" ]; then warn "you need to use USE_KDE+=kded"
498
elif [ ${pkg} = "x11/kf5-kdelibs4support" ]; then warn "you need to use USE_KDE+=kdelibs4support"
499
elif [ ${pkg} = "security/kf5-kdesu" ]; then warn "you need to use USE_KDE+=kdesu"
500
elif [ ${pkg} = "www/kf5-khtml" ]; then warn "you need to use USE_KDE+=khtml"
501
elif [ ${pkg} = "devel/kf5-kio" ]; then warn "you need to use USE_KDE+=kio"
502
elif [ ${pkg} = "lang/kf5-kross" ]; then warn "you need to use USE_KDE+=kross"
503
elif [ ${pkg} = "x11/kf5-plasma-framework" ]; then warn "you need to use USE_KDE+=plasma-framework"
504
elif [ ${pkg} = "graphics/kf5-prison" ]; then warn "you need to use USE_KDE+=prison"
505
elif [ ${pkg} = "misc/kf5-purpose" ]; then warn "you need to use USE_KDE+=purpose"
506
elif [ ${pkg} = "devel/kf5-solid" ]; then warn "you need to use USE_KDE+=solid"
507
elif [ ${pkg} = "textproc/kf5-sonnet" ]; then warn "you need to use USE_KDE+=sonnet"
508
elif [ ${pkg} = "net/kf5-syndication" ]; then warn "you need to use USE_KDE+=syndication"
509
elif [ ${pkg} = "textproc/kf5-syntax-highlighting" ]; then warn "you need to use USE_KDE+=syntaxhighlighting"
510
elif [ ${pkg} = "devel/kf5-threadweaver" ]; then warn "you need to use USE_KDE+=threadweaver"
511
elif expr ${pkg} : '.*/kf5-.*' > /dev/null; then
512
warn "you need USE_KDE+=$(echo ${pkg} | sed -E 's|.*/kf5-k||')"
513
# GStreamer 0.10
514
elif [ ${pkg} = "multimedia/gstreamer" ]; then warn "you need to use USE_GSTREAMER+=yes"
515
elif [ ${pkg} = "multimedia/gstreamer-plugins" ]; then warn "you need to use USE_GSTREAMER+=yes"
516
elif [ ${pkg} = "multimedia/gstreamer-plugins-bad" ]; then warn "you need to use USE_GSTREAMER+=bad"
517
# GStreamer 1
518
elif [ ${pkg} = "multimedia/gstreamer1" ]; then warn "you need to use USE_GSTREAMER1+=yes"
519
elif [ ${pkg} = "multimedia/gstreamer1-plugins" ]; then warn "you need to use USE_GSTREAMER1+=yes"
520
elif [ ${pkg} = "multimedia/gstreamer1-plugins-bad" ]; then warn "you need to use USE_GSTREAMER1+=bad"
521
# boost related
522
elif [ ${pkg} = "devel/boost-python-libs" ]; then warn "you need to add LIB_DEPENDS+=\${PY_BOOST} and maybe USES+=python"
523
# sdl-related
524
elif [ ${pkg} = 'devel/sdl12' ]; then
525
warn "you need USE_SDL+=sdl"
526
elif echo ${pkg} | grep -E '/sdl_(console|gfx|image|mixer|mm|net|pango|sound|ttf)$' > /dev/null; then
527
warn "you need USE_SDL+=$(echo ${pkg} | sed -E 's|.*/sdl_||')"
528
elif [ ${pkg} = 'devel/sdl20' ]; then
529
warn "you need USE_SDL+=sdl2"
530
elif echo ${pkg} | grep -E '/sdl2_(gfx|image|mixer|net|ttf)$' > /dev/null; then
531
warn "you need USE_SDL+=$(echo ${pkg} | sed -E 's|.*/sdl2_||')2"
532
# gl-related
533
elif expr ${lib_file} : "${LOCALBASE}/lib/libGL.so.*$" > /dev/null; then
534
warn "you need USE_GL+=gl"
535
elif expr ${lib_file} : "${LOCALBASE}/lib/libGLX.so.*$" > /dev/null; then
536
warn "you need USE_GL+=gl"
537
elif expr ${lib_file} : "${LOCALBASE}/lib/libgbm.so.*$" > /dev/null; then
538
warn "you need USE_GL+=gbm"
539
elif expr ${lib_file} : "${LOCALBASE}/lib/libGLESv2.so.*$" > /dev/null; then
540
warn "you need USE_GL+=glesv2"
541
elif expr ${lib_file} : "${LOCALBASE}/lib/libEGL.so.*$" > /dev/null; then
542
warn "you need USE_GL+=egl"
543
elif expr ${lib_file} : "${LOCALBASE}/lib/libOpenGL.so.*$" > /dev/null; then
544
warn "you need USE_GL+=opengl"
545
elif [ ${pkg} = 'graphics/glew' ]; then
546
warn "you need USE_GL+=glew"
547
elif [ ${pkg} = 'graphics/libGLU' ]; then
548
warn "you need USE_GL+=glu"
549
elif [ ${pkg} = 'graphics/libGLw' ]; then
550
warn "you need USE_GL+=glw"
551
elif [ ${pkg} = 'graphics/freeglut' ]; then
552
warn "you need USE_GL+=glut"
553
# Xorg-libraries: this should be by XORG_MODULES @ bsd.xorg.mk
554
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
555
warn "you need USE_XORG+=$(echo ${pkg} | sed -E 's|.*/lib||' | tr '[:upper:]' '[:lower:]')"
556
elif [ ${pkg} = 'x11/pixman' ]; then
557
warn "you need USE_XORG+=pixman"
558
# Qt5
559
elif expr ${pkg} : '.*/qt5-.*' > /dev/null; then
560
warn "you need USES=qt:5 and USE_QT+=$(echo ${pkg} | sed -E 's|.*/qt5-||')"
561
# Qt6
562
elif expr ${pkg} : '.*/qt6-.*' > /dev/null; then
563
warn "you need USES=qt:6 and USE_QT+=$(echo ${pkg} | sed -E 's|.*/qt6-||')"
564
# MySQL
565
elif expr ${lib_file} : "${LOCALBASE}/lib/mysql/[^/]*$" > /dev/null; then
566
warn "you need USES+=mysql"
567
# postgresql
568
elif expr ${pkg} : "^databases/postgresql.*-client" > /dev/null; then
569
warn "you need USES+=pgsql"
570
# bdb
571
elif expr ${pkg} : "^databases/db[456]" > /dev/null; then
572
warn "you need USES+=bdb"
573
# firebird
574
elif [ ${pkg} = "databases/firebird25-client" ]; then
575
warn "you need USES+=firebird"
576
# fuse
577
elif [ ${pkg} = "filesystems/fusefs-libs" ]; then
578
warn "you need USES+=fuse"
579
# gnustep
580
elif [ ${pkg} = "lang/gnustep-base" ]; then
581
warn "you need USES+=gnustep and USE_GNUSTEP+=base"
582
elif [ ${pkg} = "x11-toolkits/gnustep-gui" ]; then
583
warn "you need USES+=gnustep and USE_GNUSTEP+=gui"
584
# iconv
585
elif [ ${pkg} = "converters/libiconv" ]; then
586
warn "you need USES+=iconv, USES+=iconv:wchar_t, or USES+=iconv:translit depending on needs"
587
# jpeg
588
elif [ ${pkg} = "graphics/jpeg-turbo" ]; then
589
warn "you need USES+=jpeg"
590
# libarchive
591
elif [ ${pkg} = "archivers/libarchive" ]; then
592
warn "you need USES+=libarchive"
593
elif [ ${pkg} = "devel/libedit" ]; then
594
warn "you need USES+=libedit"
595
# lua
596
elif expr ${pkg} : "^lang/lua" > /dev/null; then
597
warn "you need USES+=lua"
598
# magick
599
elif [ ${pkg} = "graphics/ImageMagick6" ] ; then
600
warn "you need USES=magick:6"
601
elif [ ${pkg} = "graphics/ImageMagick6-nox11" ] ; then
602
warn "you need USES=magick:6,nox11"
603
elif [ ${pkg} = "graphics/ImageMagick7" ] ; then
604
warn "you need USES=magick:7"
605
elif [ ${pkg} = "graphics/ImageMagick7-nox11" ] ; then
606
warn "you need USES=magick:7,nox11"
607
# motif
608
elif [ ${pkg} = "x11-toolkits/lesstif" -o ${pkg} = "x11-toolkits/open-motif" ]; then
609
warn "you need USES+=motif"
610
# ncurses
611
elif [ ${pkg} = "devel/ncurses" ]; then
612
warn "you need USES+=ncurses"
613
# objc
614
elif [ ${pkg} = "lang/libobjc2" ]; then
615
warn "you need USES+=objc"
616
# openal
617
elif [ ${pkg} = "audio/openal" -o ${pkg} = "audio/openal-soft" -o ${pkg} = "audio/freealut" ]; then
618
warn "you need USES+=openal"
619
# readline
620
elif [ ${pkg} = "devel/readline" ]; then
621
warn "you need USES+=readline"
622
# ssl
623
# When updating this, please also update the versions list in
624
# bsd.default-versions.mk and ssl.mk!
625
elif [ ${pkg} = "security/openssl" -o ${pkg} = "security/openssl111" \
626
-o ${pkg} = "security/openssl31" -o ${pkg} = "security/openssl32" \
627
-o ${pkg} = "security/openssl33" \
628
-o ${pkg} = "security/libressl" -o ${pkg} = "security/libressl-devel" \
629
]; then
630
warn "you need USES=ssl"
631
# Tcl
632
elif expr ${pkg} : "^lang/tcl" > /dev/null; then
633
warn "you need USES+=tcl"
634
# Tk
635
elif expr ${pkg} : "^x11-toolkits/tk" > /dev/null; then
636
warn "you need USES+=tk"
637
# Xfce
638
# grep LIB_DEPENDS= Mk/Uses/xfce.mk |sed -e 's|\(.*\)_LIB_DEPENDS.*:\(.*\)\/\(.*\)|elif [ ${pkg} = "\2/\3" ]; then warn "you need USE_XFCE+=\1"|'
639
elif [ ${pkg} = "sysutils/garcon" ]; then warn "you need USE_XFCE+=garcon"
640
elif [ ${pkg} = "x11/libexo" ]; then warn "you need USE_XFCE+=libexo"
641
elif [ ${pkg} = "x11-toolkits/libxfce4gui" ]; then warn "you need USE_XFCE+=libgui"
642
elif [ ${pkg} = "x11/libxfce4menu" ]; then warn "you need USE_XFCE+=libmenu"
643
elif [ ${pkg} = "x11/libxfce4util" ]; then warn "you need USE_XFCE+=libutil"
644
elif [ ${pkg} = "x11-wm/xfce4-panel" ]; then warn "you need USE_XFCE+=panel"
645
elif [ ${pkg} = "x11-fm/thunar" ]; then warn "you need USE_XFCE+=thunar"
646
elif [ ${pkg} = "x11/xfce4-conf" ]; then warn "you need USE_XFCE+=xfconf"
647
# default
648
elif expr ${lib_file} : "${LOCALBASE}/lib/[^/]*$" > /dev/null; then
649
lib_file=${lib_file#${LOCALBASE}/lib/}
650
lib_file=${lib_file%.so*}.so
651
warn "you need LIB_DEPENDS+=${lib_file}:${pkg}"
652
fi
653
}
654
655
proxydeps() {
656
local file dep_file dep_file_pkg already rc dep_lib_file dep_lib_files
657
658
rc=0
659
660
# Check all dynamically linked ELF files
661
# Some .so are not executable, but we want to check them too.
662
while read -r file; do
663
# No results presents a blank line from heredoc.
664
[ -z "${file}" ] && continue
665
while read -r dep_file; do
666
# No results presents a blank line from heredoc.
667
[ -z "${dep_file}" ] && continue
668
# Skip files we already checked.
669
if listcontains ${dep_file} "${already}"; then
670
continue
671
fi
672
if pkg which -q ${dep_file} > /dev/null 2>&1; then
673
dep_file_pkg=$(pkg which -qo ${dep_file})
674
675
# Check that the .so we need has a SONAME
676
if [ "${dep_file_pkg}" != "${PKGORIGIN}" ]; then
677
# When grep -q finds a match it will close the pipe immediately.
678
# This may cause the test to fail when pipefail is turned on.
679
set +o pipefail
680
if ! readelf -d "${dep_file}" | grep SONAME > /dev/null; then
681
err "${file} is linked to ${dep_file} which does not have a SONAME. ${dep_file_pkg} needs to be fixed."
682
fi
683
set -o pipefail
684
fi
685
686
# If we don't already depend on it, and we don't provide it
687
if ! listcontains ${dep_file_pkg} "${LIB_RUN_DEPENDS} ${PKGORIGIN}"; then
688
# If the package has a flavor, check that the dependency is not on that particular flavor.
689
flavor=$(pkg annotate -q -S "$(pkg which -q "${dep_file}")" flavor)
690
if [ -n "${flavor}" ]; then
691
if listcontains ${dep_file_pkg}@${flavor} "${LIB_RUN_DEPENDS} ${PKGORIGIN}"; then
692
continue
693
fi
694
fi
695
err "${file} is linked to ${dep_file} from ${dep_file_pkg} but it is not declared as a dependency"
696
proxydeps_suggest_uses ${dep_file_pkg} ${dep_file}
697
rc=1
698
fi
699
else
700
err "${file} is linked to ${dep_file} that does not belong to any package"
701
rc=1
702
fi
703
already="${already} ${dep_file}"
704
dep_lib_file=$(basename ${dep_file})
705
dep_lib_files="${dep_lib_files} ${dep_lib_file%%.so*}.so"
706
done <<-EOT
707
$(env LD_LIBMAP_DISABLE=1 ldd -a "${STAGEDIR}${file}" | \
708
awk '
709
BEGIN {section=0}
710
/^\// {section++}
711
!/^\// && section<=1 && ($3 ~ "^'${PREFIX}'" || $3 ~ "^'${LOCALBASE}'") {print $3}')
712
EOT
713
done <<-EOT
714
$(list_stagedir_elfs | \
715
file -F $'\1' -f - | \
716
grep -a 'ELF.*FreeBSD.*dynamically linked' | \
717
cut -f 1 -d $'\1'| \
718
sed -e 's/^\.//')
719
EOT
720
721
# Check whether all files in LIB_DEPENDS are actually linked against
722
for _library in ${WANTED_LIBRARIES} ; do
723
if ! listcontains ${_library%%.so*}.so "${dep_lib_files}" ; then
724
warn "you might not need LIB_DEPENDS on ${_library}"
725
fi
726
done
727
728
[ -z "${PROXYDEPS_FATAL}" ] && return 0
729
730
return ${rc}
731
}
732
733
sonames() {
734
[ ! -d ${STAGEDIR}${PREFIX}/lib -o -n "${BUNDLE_LIBS}" ] && return 0
735
while read -r f; do
736
# No results presents a blank line from heredoc.
737
[ -z "${f}" ] && continue
738
# Ignore symlinks
739
[ -f "${f}" -a ! -L "${f}" ] || continue
740
# Ignore .debug files
741
[ "${f}" == "${f%.debug}" ] || continue
742
if ! readelf -d ${f} | grep SONAME > /dev/null; then
743
warn "${f} doesn't have a SONAME."
744
warn "pkg(8) will not register it as being provided by the port."
745
warn "If another port depend on it, pkg will not be able to know where it comes from."
746
case "${f}" in
747
${STAGEDIR}${PREFIX}/lib/*/*)
748
warn "It is in a subdirectory, it may not be used in another port."
749
;;
750
*)
751
warn "It is directly in ${PREFIX}/lib, it is probably used by other ports."
752
;;
753
esac
754
fi
755
# Use heredoc to avoid losing rc from find|while subshell
756
done <<-EOT
757
$(find ${STAGEDIR}${PREFIX}/lib -name '*.so.*')
758
EOT
759
}
760
761
perlcore_port_module_mapping() {
762
case "$1" in
763
Net)
764
echo "Net::Config"
765
;;
766
libwww)
767
echo "LWP"
768
;;
769
*)
770
echo "$1" | sed -e 's/-/::/g'
771
;;
772
esac
773
}
774
775
perlcore() {
776
local portname version module gotsome
777
[ -x "${LOCALBASE}/bin/corelist" ] || return 0
778
for dep in ${UNIFIED_DEPENDS}; do
779
portname=$(expr "${dep}" : ".*/p5-\(.*\)")
780
if [ -n "${portname}" ]; then
781
gotsome=1
782
module=$(perlcore_port_module_mapping "${portname}")
783
version=$(expr "${dep}" : ".*>=*\([^:<]*\)")
784
785
while read -r l; do
786
case "${l}" in
787
*was\ not\ in\ CORE*)
788
# This never was with Perl
789
# CORE, so nothing to do here
790
;;
791
*and\ removed*)
792
# This was in Perl CORE but has
793
# been removed since.
794
warn "${dep##*:} was in Perl CORE. Check with \`corelist ${module} ${version}\` and \`corelist -a ${module}\` if it should be conditionally added depending on PERL_LEVEL"
795
;;
796
*deprecated*in*)
797
# This is in Perl CORE but is
798
# deprecated.
799
warn "${dep##*:} is in Perl CORE but deprecated. Check with \`corelist ${module} ${version}\` and \`corelist -a ${module}\` if the dependency is really needed or if it should be conditionally added depending on PERL_LEVEL"
800
;;
801
*was\ first\ released*)
802
# This is in Perl CORE and is
803
# maybe not needed.
804
warn "${dep##*:} is present in Perl CORE. Check with \`corelist ${module} ${version}\` and \`corelist -a ${module}\` if the dependency is really needed or if it should be conditionally added depending on PERL_LEVEL"
805
;;
806
*)
807
err "This line is not handled: \"${l}\""
808
esac
809
done <<-EOT
810
$(${LOCALBASE}/bin/corelist "${module}"|tail -1)
811
EOT
812
fi
813
done
814
if [ -n "${gotsome}" ] && ! pkg info -e devel/p5-Module-CoreList; then
815
notice "You have some Perl modules as dependencies but you do not have devel/p5-Module-CoreList installed, the perlcore QA check gets better results when using it, especially with older Perl versions."
816
fi
817
}
818
819
no_arch() {
820
[ -z "$NO_ARCH" ] && return
821
rc=0
822
while read -r f; do
823
[ -z "$f" ] && continue
824
if [ -n "$NO_ARCH_IGNORE" ]; then
825
skip=
826
for blacklist in $NO_ARCH_IGNORE; do
827
case $f in
828
*$blacklist) skip=1; break;;
829
esac
830
done
831
[ "$skip" ] && continue
832
fi
833
err "'${f#.}' is a architecture specific binary file and you have set NO_ARCH. Either remove NO_ARCH or add '$(basename $f)' to NO_ARCH_IGNORE."
834
rc=1
835
done <<-EOF
836
$(list_stagedir_elfs \
837
| file -F $'\1' -f - -N \
838
| grep -aE 'ELF .* [LM]SB .*, .*, version [0-9]+ \(FreeBSD\)' \
839
| cut -f 1 -d $'\1')
840
EOF
841
return $rc
842
}
843
844
gemdeps()
845
{
846
rc=0
847
if [ "${PKGBASE%%-*}" = "rubygem" ]; then
848
# shellcheck disable=SC2153
849
# In the heredoc, ${PORTNAME} comes from the environment, not
850
# to be confused with ${portname}
851
while read -r l; do
852
if [ -n "${l}" ]; then
853
name=${l%% *}
854
vers=${l#* }
855
while read -r v; do
856
if ! while read -r p; do
857
${LOCALBASE}/bin/ruby -e "puts 'OK' if Gem::Dependency.new('${name}','${v}').match?('${name}','${p}')"
858
done | grep -qFx OK; then
859
err RubyGem dependency ${name} ${v} is not satisfied.
860
rc=1
861
fi <<-EOF
862
$(${LOCALBASE}/bin/gem list -e "${name}" \
863
| sed "s|.*(\(.*\))|\1|" \
864
| tr -d ' ' \
865
| tr , '\n')
866
EOF
867
done <<-EOF
868
$(while echo "${vers}" | grep -q '"'; do
869
echo "${vers}" | cut -d '"' -f2
870
vers=$(echo "${vers}"|cut -d '"' -f3-)
871
done)
872
EOF
873
fi
874
done <<-EOF
875
$(grep -a 's.add_runtime_dependency' ${STAGEDIR}${PREFIX}/lib/ruby/gems/*/specifications/${PORTNAME}-*.gemspec \
876
| sed 's|.*<\(.*\)>.*\[\(.*\)\])|\1 \2|' \
877
| sort -u)
878
EOF
879
fi
880
return $rc
881
}
882
883
# If an non rubygem-port has a 'Gemfile' file
884
# it is checked with bundle to be sure
885
# all dependencies are satisfied.
886
# Without the check missing/wrong dependencies
887
# are just found when executing the application
888
gemfiledeps()
889
{
890
# skip check if port does not use ruby at all
891
if [ -z "$USE_RUBY" ]; then
892
return 0
893
fi
894
895
# skip check if port is a rubygem-* one; they have no Gemfiles
896
if [ "${PKGBASE%%-*}" = "rubygem" ]; then
897
return 0
898
fi
899
900
# advise install of bundler if its not present for check
901
if ! type bundle > /dev/null 2>&1; then
902
notice "Please install sysutils/rubygem-bundler for additional Gemfile-checks"
903
return 0
904
fi
905
906
# locate the Gemfile(s)
907
while read -r f; do
908
909
# no results presents a blank line from heredoc
910
[ -z "$f" ] && continue
911
912
# if there is no Gemfile everything is fine - stop here
913
[ ! -f "$f" ] && return 0;
914
915
# use bundle to check if Gemfile is satisfied
916
# if bundle returns 1 the Gemfile is not satisfied
917
# and so stage-qa isn't also
918
if ! bundle check --dry-run --gemfile $f > /dev/null 2>&1; then
919
warn "Dependencies defined in ${f} are not satisfied"
920
fi
921
922
done <<-EOF
923
$(find ${STAGEDIR} -name Gemfile)
924
EOF
925
return 0
926
}
927
928
flavors()
929
{
930
local rc pkgnames uniques
931
rc=0
932
if [ -n "${FLAVOR}" ]; then
933
pkgnames=$(make -C "${CURDIR}" flavors-package-names|sort)
934
uniques=$(echo "${pkgnames}"|uniq)
935
if [ "$pkgnames" != "${uniques}" ]; then
936
err "Package names are not unique with flavors:"
937
make -C "${CURDIR}" pretty-flavors-package-names >&2
938
err "maybe use <flavor>_PKGNAMEPREFIX/SUFFIX".
939
rc=1
940
fi
941
fi
942
return ${rc}
943
}
944
945
license()
946
{
947
local lic autoaccept pkgmirror #distsell distmirror pkgsell
948
949
if [ -n "$DISABLE_LICENSES" ]; then
950
warn "You have disabled the licenses framework with DISABLE_LICENSES, unable to run checks"
951
elif [ -n "$LICENSE" ]; then
952
for lic in $LICENSE_PERMS; do
953
case "$lic" in
954
auto-accept) autoaccept=1 ;;
955
#dist-mirror) distmirror=1 ;;
956
#dist-sell) distsell=1 ;;
957
pkg-mirror) pkgmirror=1 ;;
958
#pkg-sell) pkgsell=1 ;;
959
esac
960
done
961
962
if [ -z "$autoaccept" ]; then
963
warn "License is not auto-accepted, packages will not be built, ports depending on this one will be ignored."
964
fi
965
if [ -z "$pkgmirror" ]; then
966
warn "License does not allow package to be distributed, ports depending on this one will be ignored"
967
fi
968
fi
969
970
return 0
971
}
972
973
# This is to prevent adding dependencies to meta ports that are only there to
974
# improve the end user experience.
975
depends_blacklist()
976
{
977
local dep rc instead
978
979
rc=0
980
981
for dep in ${UNIFIED_DEPENDS}; do
982
origin=$(expr "${dep}" : ".*:\([^@]*\)")
983
instead=""
984
985
case "$origin" in
986
lang/python|lang/python2|lang/python3)
987
# lang/python depends on lang/pythonX, but it's
988
# ok, it is also in the blacklist.
989
if [ ${PKGORIGIN} != lang/python ]; then
990
instead="USES=python:xy with a specific version"
991
fi
992
;;
993
lang/gcc)
994
instead="USE_GCC"
995
;;
996
lang/go)
997
instead="USES=go"
998
;;
999
lang/mono)
1000
instead="USES=mono"
1001
;;
1002
devel/llvm)
1003
instead="USES=llvm"
1004
;;
1005
esac
1006
1007
if [ -n "${instead}" ]; then
1008
err "$origin should not be depended upon. Instead, use $instead."
1009
rc=1
1010
fi
1011
done
1012
1013
return $rc
1014
}
1015
1016
pkgmessage()
1017
{
1018
for message in ${PKGMESSAGES}; do
1019
if [ -f "${message}" ]; then
1020
if ! head -1 "${message}" | grep -q '^\['; then
1021
warn "${message} not in UCL format, will be shown on initial install only."
1022
warn "See https://docs.freebsd.org/en/books/porters-handbook/pkg-files/#porting-message"
1023
fi
1024
fi
1025
done
1026
1027
return 0
1028
}
1029
1030
reinplace()
1031
{
1032
if [ -f ${REWARNFILE} ]; then
1033
warn "Possible REINPLACE_CMD issues:"
1034
cat ${REWARNFILE}
1035
fi
1036
}
1037
1038
prefixman() {
1039
if [ -d "${STAGEDIR}${PREFIX}/man" ]; then
1040
warn "Installing man files in ${PREFIX}/man is no longer supported. Consider installing these files in ${PREFIX}/share/man instead."
1041
ls -liTd ${STAGEDIR}${PREFIX}/man
1042
fi
1043
return 0
1044
}
1045
1046
pythonpackagedir() {
1047
# Detects Python packages installing top-level directories like docs/, tests/,
1048
# etc. into site-packages, which can cause conflicts between packages.
1049
1050
# Only check Python ports
1051
[ -z "${USESPYTHON}" ] && return 0
1052
1053
# Only check if site-packages exists
1054
[ -z "${PYTHONPREFIX_SITELIBDIR}" ] && return 0
1055
[ ! -d "${STAGEDIR}${PYTHONPREFIX_SITELIBDIR}" ] && return 0
1056
1057
# List of directories that should not be installed in site-packages.
1058
# This is a subset of setuptools.discovery.FlatLayoutPackageFinder.DEFAULT_EXCLUDE,
1059
# focusing on directories commonly shipped by mistake that cause file conflicts.
1060
local problematic_dirs="docs doc tests test examples benchmarks scripts tools util utils htmlcov tasks ci"
1061
local rc=0
1062
1063
for dir in ${problematic_dirs}; do
1064
if [ -d "${STAGEDIR}${PYTHONPREFIX_SITELIBDIR}/${dir}" ]; then
1065
# Check if it's actually a top-level directory and not part of a package
1066
# (e.g., mypackage/tests is OK, but tests/ at top level is not)
1067
err "Python package installs top-level '${dir}/' directory in site-packages"
1068
err " Location: ${PYTHONPREFIX_SITELIBDIR#${PREFIX}/}/${dir}"
1069
err "This causes file conflicts with other packages. Exclude it via pyproject.toml:"
1070
err " [tool.setuptools.packages.find]"
1071
err " exclude = [\"${dir}\", \"${dir}.*\"]"
1072
err "See: https://setuptools.pypa.io/en/latest/userguide/package_discovery.html"
1073
rc=1
1074
fi
1075
done
1076
1077
return ${rc}
1078
}
1079
1080
checks="shebang symlinks paths stripped desktopfileutils sharedmimeinfo"
1081
checks="$checks suidfiles libtool libperl prefixvar baselibs terminfo"
1082
checks="$checks proxydeps sonames perlcore no_arch gemdeps gemfiledeps flavors"
1083
checks="$checks license depends_blacklist pkgmessage reinplace prefixman pythonpackagedir"
1084
1085
ret=0
1086
cd ${STAGEDIR} || exit 1
1087
for check in ${checks}; do
1088
eval check_test="\$IGNORE_QA_$check"
1089
if [ -z "${check_test}" ]; then
1090
${check} || ret=1
1091
else
1092
warn "Ignoring $check QA test"
1093
fi
1094
done
1095
1096
exit ${ret}
1097
1098