2013-08-21 17:00:24 +00:00
|
|
|
#!/bin/ksh
|
|
|
|
#
|
2015-04-12 18:37:23 +00:00
|
|
|
# $OpenBSD: portcheck,v 1.96 2015/04/12 18:37:23 zhuk Exp $
|
2013-08-21 17:00:24 +00:00
|
|
|
# Copyright (c) 2013 Vadim Zhukov
|
|
|
|
#
|
|
|
|
# Permission to use, copy, modify, and distribute this software for any
|
|
|
|
# purpose with or without fee is hereby granted, provided that the above
|
|
|
|
# copyright notice and this permission notice appear in all copies.
|
|
|
|
#
|
|
|
|
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
|
|
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
|
|
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
|
|
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
|
|
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
|
|
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
|
|
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
|
|
|
|
set -e
|
|
|
|
set +X
|
2013-08-22 22:37:17 +00:00
|
|
|
set -u
|
2013-08-21 17:00:24 +00:00
|
|
|
|
|
|
|
usage() {
|
2014-02-04 21:18:14 +00:00
|
|
|
echo "usage: ${0##*/} [-dNP] [-p portsdir] [-x glob]" >&2
|
|
|
|
echo " ${0##*/} -A [-dP] [-p portsdir] [-x glob] [subdir ...]" >&2
|
2013-08-21 17:00:24 +00:00
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
############################################################
|
|
|
|
# Parsing command line options
|
|
|
|
#
|
|
|
|
|
2014-02-04 21:18:14 +00:00
|
|
|
existing_port=true
|
|
|
|
ignore_cvs=true
|
2013-08-21 17:00:24 +00:00
|
|
|
plist_checks=true
|
|
|
|
portsdir=
|
|
|
|
rootrun=false
|
|
|
|
debugging=false
|
|
|
|
|
2013-12-29 07:07:25 +00:00
|
|
|
ignore_list=; unset ignore_list[0]
|
2013-08-22 22:37:17 +00:00
|
|
|
|
2014-02-04 21:18:14 +00:00
|
|
|
while getopts "AdNPp:x:" OPT; do
|
2013-08-21 17:00:24 +00:00
|
|
|
case $OPT in
|
|
|
|
A)
|
2014-02-04 21:18:14 +00:00
|
|
|
$existing_port || usage
|
2013-08-22 22:37:17 +00:00
|
|
|
if ! $rootrun; then
|
|
|
|
ignore_list[${#ignore_list[@]}]=.cvsignore
|
|
|
|
ignore_list[${#ignore_list[@]}]=.fslckout
|
|
|
|
ignore_list[${#ignore_list[@]}]=.git
|
|
|
|
ignore_list[${#ignore_list[@]}]=.gitignore
|
|
|
|
ignore_list[${#ignore_list[@]}]=.hg
|
|
|
|
ignore_list[${#ignore_list[@]}]=.hgignore
|
|
|
|
ignore_list[${#ignore_list[@]}]=.svn
|
2014-02-09 15:19:32 +00:00
|
|
|
ignore_list[${#ignore_list[@]}]=FINISHED
|
|
|
|
ignore_list[${#ignore_list[@]}]=INDEX
|
|
|
|
ignore_list[${#ignore_list[@]}]=README
|
|
|
|
ignore_list[${#ignore_list[@]}]=README.md
|
|
|
|
ignore_list[${#ignore_list[@]}]=bulk
|
|
|
|
ignore_list[${#ignore_list[@]}]=distfiles
|
|
|
|
ignore_list[${#ignore_list[@]}]=infrastructure
|
|
|
|
ignore_list[${#ignore_list[@]}]=lost+found
|
|
|
|
ignore_list[${#ignore_list[@]}]=mystuff
|
|
|
|
ignore_list[${#ignore_list[@]}]=openbsd-wip
|
|
|
|
ignore_list[${#ignore_list[@]}]=packages
|
|
|
|
ignore_list[${#ignore_list[@]}]=plist
|
|
|
|
ignore_list[${#ignore_list[@]}]=pobj
|
|
|
|
ignore_list[${#ignore_list[@]}]=tests
|
|
|
|
ignore_list[${#ignore_list[@]}]=update
|
2013-08-22 22:37:17 +00:00
|
|
|
fi
|
2013-08-21 17:00:24 +00:00
|
|
|
rootrun=true
|
|
|
|
;;
|
|
|
|
|
|
|
|
d)
|
|
|
|
debugging=true
|
|
|
|
;;
|
|
|
|
|
2014-02-04 21:18:14 +00:00
|
|
|
N)
|
|
|
|
$rootrun && usage
|
|
|
|
existing_port=false
|
|
|
|
ignore_cvs=false
|
|
|
|
;;
|
|
|
|
|
2013-08-21 17:00:24 +00:00
|
|
|
P)
|
|
|
|
plist_checks=false
|
|
|
|
;;
|
|
|
|
|
|
|
|
p)
|
|
|
|
portsdir=$OPTARG
|
|
|
|
;;
|
|
|
|
|
|
|
|
x)
|
|
|
|
set -A ignore_list -- "${ignore_list[@]}" "$OPTARG"
|
|
|
|
;;
|
|
|
|
|
|
|
|
*)
|
|
|
|
usage
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
2013-08-22 17:44:22 +00:00
|
|
|
if ! $rootrun && [[ -n $portsdir && ${PWD##"$portsdir"} == "$PWD" ]]; then
|
|
|
|
cat >&2 <<EOE
|
|
|
|
${0##*/}: current directory does not seem to be under the
|
|
|
|
specified root directory: $portsdir.
|
|
|
|
EOE
|
|
|
|
exit 3
|
|
|
|
fi
|
|
|
|
|
2013-08-21 17:00:24 +00:00
|
|
|
shift $(($OPTIND - 1))
|
|
|
|
(($# > 0)) && ! $rootrun && usage
|
|
|
|
(($# == 0)) && set -- .
|
|
|
|
|
|
|
|
############################################################
|
2013-11-10 14:56:41 +00:00
|
|
|
# Detect path to root of directory tree of current port(s) and put it
|
2013-08-21 17:00:24 +00:00
|
|
|
# in $portsdir, unless it was set by user above. As a last resort, we
|
|
|
|
# use some heuristics based on the commonly used names.
|
|
|
|
#
|
|
|
|
# We also have a $pkgpath variable, that represents subdirectory under
|
2013-11-10 14:56:41 +00:00
|
|
|
# root ports directory where the port(s) will be imported. In case we
|
2013-08-21 17:00:24 +00:00
|
|
|
# use heuristics for determining $portsdir, we'll set up $pkgpath, too,
|
|
|
|
# since we would get this info anyway.
|
|
|
|
#
|
|
|
|
# In make_args we write PORTSDIR_PATH override, that allows us to run
|
|
|
|
# even in ports directory that is not on the PORTSDIR_PATH. This is
|
|
|
|
# useful, for example, when you check your port on cvs.openbsd.org,
|
|
|
|
# where you cannot just override mk.conf.
|
|
|
|
#
|
|
|
|
|
|
|
|
pkgpath=
|
|
|
|
|
2013-08-24 15:44:59 +00:00
|
|
|
if [[ -z $portsdir ]]; then
|
|
|
|
IFS=:
|
|
|
|
testp=/usr/ports/devel/quirks
|
|
|
|
set -A portsdir_path -- \
|
|
|
|
$( (cd $testp && make show=PORTSDIR_PATH 2>/dev/null) || true)
|
|
|
|
unset IFS
|
|
|
|
if ((${#portsdir_path[@]} > 0)); then
|
|
|
|
for p in "${portsdir_path[@]}"; do
|
|
|
|
if [[ -z $portsdir && ${PWD#"$p"} != "$PWD" ]]; then
|
|
|
|
portsdir=$p
|
|
|
|
elif [[ -n $portsdir && ${PWD#"$p"} != "$PWD" &&
|
|
|
|
$p > $portsdir ]]; then
|
|
|
|
portsdir=$p
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2013-08-21 17:00:24 +00:00
|
|
|
if [[ -z $portsdir ]]; then
|
|
|
|
# heuristics mode ON
|
|
|
|
pkgpath=${PWD##*/ports/*(mystuff/|openbsd-wip/)}
|
|
|
|
portsdir=${PWD%"/$pkgpath"}
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ -z $portsdir ]]; then
|
|
|
|
cat >&2 <<EOE
|
|
|
|
${0##*/}: could not detect root ports directory. Please provide
|
|
|
|
one with -p option.
|
|
|
|
EOE
|
|
|
|
exit 2
|
|
|
|
fi
|
|
|
|
|
2014-08-12 00:37:44 +00:00
|
|
|
# This way we can run all checks even on cvs.openbsd.org and/or
|
|
|
|
# when SKIPDIR framework is used
|
|
|
|
set -A make_args -- \
|
|
|
|
SKIPDIR= STARTAFTER= STARTDIR= \
|
|
|
|
MASTER_SITE_OPENBSD= \
|
2013-08-21 17:00:24 +00:00
|
|
|
PORTSDIR_PATH="$portsdir:$(cd /usr/ports && make -V PORTSDIR_PATH || true)"
|
|
|
|
|
2013-08-22 17:44:22 +00:00
|
|
|
if $rootrun; then
|
|
|
|
cd -- "$portsdir"
|
|
|
|
echo "scanning ports under the $portsdir" >&2
|
|
|
|
fi
|
2013-08-21 17:00:24 +00:00
|
|
|
|
2014-08-10 20:41:54 +00:00
|
|
|
############################################################
|
|
|
|
# Support for SKIPDIR, STARTDIR and STARTAFTER, see ports(7)
|
|
|
|
#
|
|
|
|
|
|
|
|
SKIPDIR=${SKIPDIR:-}
|
|
|
|
STARTDIR=${STARTDIR:-}
|
|
|
|
STARTAFTER=${STARTAFTER:-}
|
|
|
|
if [[ -n $STARTAFTER ]]; then
|
|
|
|
STARTDIR=$STARTAFTER
|
|
|
|
SKIPDIR="$SKIPDIR $STARTAFTER"
|
|
|
|
fi
|
|
|
|
|
|
|
|
path_parts_count() {
|
|
|
|
(IFS=/; set -- $1; echo $#)
|
|
|
|
}
|
|
|
|
|
|
|
|
# true if directory given should be skipped based on STARTDIR
|
|
|
|
# and/or SKIPDIR variable
|
|
|
|
skip_dir() {
|
|
|
|
$rootrun || return 1
|
|
|
|
local dir=$(readlink -f "$1")
|
|
|
|
dir=${dir##$portsdir*(/)}
|
|
|
|
local startpartscount=$(path_parts_count "$STARTDIR")
|
|
|
|
local dirpartscount=$(path_parts_count "$dir")
|
|
|
|
if ((dirpartscount >= startpartscount)); then
|
|
|
|
[[ -n $STARTDIR && $dir < $STARTDIR ]] && return 0
|
|
|
|
fi
|
|
|
|
local d
|
|
|
|
for d in $SKIPDIR; do
|
|
|
|
[[ $d == "$dir" ]] && return 0
|
|
|
|
done
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
2013-08-21 17:00:24 +00:00
|
|
|
############################################################
|
|
|
|
# Check and fail routines
|
|
|
|
#
|
|
|
|
|
|
|
|
error=false
|
|
|
|
|
|
|
|
err() {
|
|
|
|
local prefix=
|
|
|
|
while (($# > 0)); do
|
|
|
|
printf "$prefix%s" "$1" >&2
|
|
|
|
prefix=" "
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
echo >&2
|
|
|
|
error=true
|
|
|
|
}
|
|
|
|
|
|
|
|
err_duplicated() {
|
|
|
|
err "both $2 and some of its parents has $1"
|
|
|
|
}
|
|
|
|
|
|
|
|
err_coredump_found() {
|
|
|
|
err "core dump file found: $1"
|
|
|
|
}
|
|
|
|
|
2013-08-22 09:44:17 +00:00
|
|
|
has_subdirs_only() {
|
|
|
|
$debugging && echo "CALLED: has_subdirs_only($*)" >&2
|
|
|
|
|
|
|
|
local dir=$1; shift
|
|
|
|
ls -A "$dir" | {
|
|
|
|
local has_files=false has_dirs=false
|
|
|
|
while read F; do
|
|
|
|
$ignore_cvs && [[ $F == CVS ]] && continue
|
2013-08-22 17:44:22 +00:00
|
|
|
ignoring "$dir/$F" && continue
|
2013-08-22 09:44:17 +00:00
|
|
|
if [[ -d $dir/$F ]]; then
|
|
|
|
has_dirs=true
|
|
|
|
else
|
|
|
|
has_files=true
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
$has_dirs && ! $has_files
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-21 17:00:24 +00:00
|
|
|
ignoring() {
|
2013-12-29 07:07:25 +00:00
|
|
|
((${#ignore_list[*]} > 0)) || return 1
|
2013-08-21 17:00:24 +00:00
|
|
|
local iglob
|
|
|
|
for iglob in "${ignore_list[@]}"; do
|
2013-08-22 17:44:22 +00:00
|
|
|
[[ ${1#./} == $iglob ]] && return 0
|
2013-08-21 17:00:24 +00:00
|
|
|
done
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
2013-08-22 20:33:16 +00:00
|
|
|
is_vcs_item() {
|
|
|
|
[[ -d "$1" && ${1##*/} == @(CVS|.fslckout|.git|.hg|.svn) ]]
|
2013-08-21 17:00:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
handle_extra_file() {
|
2013-12-29 07:07:25 +00:00
|
|
|
ignoring "$1" && return 0
|
2013-08-21 17:00:24 +00:00
|
|
|
|
|
|
|
# avoid warning, e.g., about ".*"
|
|
|
|
test -e "$1" || return 0
|
|
|
|
|
|
|
|
if is_vcs_item "$1"; then
|
|
|
|
if ! $ignore_cvs || [[ ${1##*/} != CVS ]]; then
|
|
|
|
err "VCS item detected: $1"
|
|
|
|
fi
|
|
|
|
elif [[ -f $1 && $1 == *.core ]]; then
|
|
|
|
err_coredump_found "$1"
|
|
|
|
elif [[ -d $1 ]]; then
|
|
|
|
err "extra directory: $1"
|
|
|
|
else
|
|
|
|
err "extra file: $1"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2013-08-22 20:33:16 +00:00
|
|
|
# Make a path to .py[co] file looks like as if it's in the same dir
|
|
|
|
# as the corresponding .py file, and has same basename. E.g.:
|
|
|
|
# lib/python3.3/__pycache__/Foo/cpython-33.Bar.pyc
|
|
|
|
# became:
|
|
|
|
# lib/python2.7/Foo/Bar.pyc
|
|
|
|
# which corresponds to:
|
|
|
|
# lib/python2.7/Foo/Bar.py
|
2013-08-22 16:43:04 +00:00
|
|
|
normalize_pyco() {
|
|
|
|
local pyco=$1
|
|
|
|
[[ $pyco == *.cpython-+([0-9]).py[co] ]] &&
|
|
|
|
pyco=${pyco%.cpython-+([0-9]).py[co]}.${pyco##*.}
|
|
|
|
[[ $pyco == */__pycache__/* ]] &&
|
|
|
|
pyco=${pyco%/__pycache__/*}/${pyco##*/__pycache__/}
|
|
|
|
printf "%s" "$pyco"
|
|
|
|
}
|
|
|
|
|
2013-08-21 17:00:24 +00:00
|
|
|
# Print out a ref to the particular subport/subpackage, if needed.
|
|
|
|
# Port FLAVORs could also be handled, if provided.
|
|
|
|
# Usage: portref directory [subpackage [flavor all_flavors]]
|
|
|
|
portref() {
|
|
|
|
local dir=$1; shift
|
2013-08-22 22:37:17 +00:00
|
|
|
local subpkg= flavor all_flavors=
|
2013-08-21 17:00:24 +00:00
|
|
|
if (($# > 0)); then
|
|
|
|
subpkg=$1
|
|
|
|
shift
|
|
|
|
fi
|
|
|
|
if (($# > 0)); then
|
|
|
|
flavor=$1
|
|
|
|
all_flavors=$2
|
|
|
|
shift 2
|
|
|
|
fi
|
|
|
|
|
|
|
|
local ref=
|
|
|
|
if [[ $dir != . ]]; then
|
|
|
|
ref="${dir#./}"
|
|
|
|
[[ -n $subpkg && $subpkg != "-" ]] && ref="$ref,$subpkg"
|
|
|
|
else
|
|
|
|
[[ $subpkg != "-" ]] && ref="$subpkg"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ -n $all_flavors ]]; then
|
|
|
|
[[ -n $ref ]] && ref="$ref, "
|
|
|
|
if [[ -z $flavor ]]; then
|
|
|
|
ref="${ref}default FLAVOR"
|
|
|
|
else
|
|
|
|
ref="${ref}FLAVOR \"$flavor\""
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
[[ -n $ref ]] && echo "in $ref: "
|
|
|
|
}
|
|
|
|
|
2013-08-22 10:41:20 +00:00
|
|
|
# Contains last SUBST_CMD. Filled by check_port_dir(), used
|
|
|
|
# by check_port_hier() to lazily call the check_pkg_dir().
|
|
|
|
last_subst_cmd=
|
|
|
|
|
2013-08-21 17:00:24 +00:00
|
|
|
# Checks made:
|
|
|
|
# * Whitelist filter of what could be in this directory.
|
|
|
|
check_port_hier() {
|
|
|
|
$debugging && echo "CALLED: check_port_hier($*)" >&2
|
|
|
|
|
2013-08-22 12:53:49 +00:00
|
|
|
local distinfo_lives_upper pkg_lives_upper plist_lives_upper
|
2013-08-21 17:00:24 +00:00
|
|
|
local dir=$1; shift
|
|
|
|
for opt; do
|
|
|
|
# looks unsafe but we do not pass anything except
|
|
|
|
# "foo=true" and "foo=false" here
|
|
|
|
eval "$opt"
|
|
|
|
done
|
|
|
|
|
2013-08-22 12:53:49 +00:00
|
|
|
distinfo_lives_upper=${distinfo_lives_upper:-false}
|
|
|
|
pkg_lives_upper=${pkg_lives_upper:-false}
|
|
|
|
plist_lives_upper=${plist_lives_upper:-false}
|
2013-08-21 17:00:24 +00:00
|
|
|
|
|
|
|
local distinfo_exists=false
|
|
|
|
[[ -f $dir/distinfo ]] && distinfo_exists=true
|
|
|
|
$distinfo_exists && $distinfo_lives_upper &&
|
|
|
|
err_duplicated distinfo "$dir"
|
|
|
|
|
2013-08-22 10:41:20 +00:00
|
|
|
local pkg_exists=false tell_pkg_exists=$pkg_lives_upper
|
|
|
|
if [[ -d $dir/pkg ]]; then
|
|
|
|
pkg_exists=true
|
|
|
|
tell_pkg_exists=true
|
|
|
|
fi
|
2013-08-21 17:00:24 +00:00
|
|
|
|
|
|
|
local plist_exists=false
|
|
|
|
ls $dir/pkg/PLIST* >/dev/null 2>&1 && plist_exists=true
|
|
|
|
$plist_lives_upper && $plist_exists &&
|
2013-11-10 14:56:41 +00:00
|
|
|
err_duplicated "packing list(s)" "$dir"
|
2013-08-21 17:00:24 +00:00
|
|
|
|
|
|
|
$distinfo_lives_upper && distinfo_exists=true
|
|
|
|
$plist_lives_upper && plist_exists=true
|
|
|
|
|
|
|
|
local recursive_args
|
|
|
|
set -A recursive_args -- \
|
|
|
|
distinfo_lives_upper=$distinfo_exists \
|
2013-08-22 10:41:20 +00:00
|
|
|
pkg_lives_upper=$tell_pkg_exists \
|
2013-08-21 17:00:24 +00:00
|
|
|
plist_lives_upper=$plist_exists
|
|
|
|
|
|
|
|
local F
|
|
|
|
for F in "$dir"/* "$dir"/.*; do
|
|
|
|
F=${F#./}
|
|
|
|
ignoring "$F" && continue
|
|
|
|
|
|
|
|
if is_vcs_item "$F"; then
|
|
|
|
if ! $ignore_cvs || [[ ${F##*/} != CVS ]]; then
|
|
|
|
err "VCS item detected: $F"
|
|
|
|
fi
|
|
|
|
elif [[ -d $F ]]; then
|
|
|
|
case "${F##*/}" in
|
2013-08-22 10:41:20 +00:00
|
|
|
files|patches)
|
2013-08-21 17:00:24 +00:00
|
|
|
check_${F##*/}_dir "$F"
|
|
|
|
;;
|
|
|
|
|
2013-08-22 10:41:20 +00:00
|
|
|
pkg)
|
|
|
|
# Do nothing, pkg_exists is already set,
|
|
|
|
# and we need to read SUBST_CMD first.
|
|
|
|
;;
|
|
|
|
|
2013-08-21 17:00:24 +00:00
|
|
|
patches?(-*))
|
|
|
|
check_patches_dir "$F"
|
|
|
|
;;
|
|
|
|
|
|
|
|
*)
|
2013-08-22 23:30:23 +00:00
|
|
|
if ! ([[ -f $F/Makefile ]] ||
|
2013-08-23 00:43:20 +00:00
|
|
|
ls $F/*.port.mk >/dev/null 2>&1) &&
|
2013-08-22 23:30:23 +00:00
|
|
|
! has_subdirs_only "$F"; then
|
2013-08-21 17:00:24 +00:00
|
|
|
# Avoid extra spam
|
|
|
|
err "not a port directory: $F"
|
|
|
|
else
|
|
|
|
local pkgpath_set=false
|
|
|
|
[[ -n $pkgpath ]] && pkgpath_set=true
|
|
|
|
check_port_dir "$F" "${recursive_args[@]}"
|
|
|
|
$pkgpath_set || pkgpath=${pkgpath%/*}
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
else
|
|
|
|
case "${F##*/}" in
|
|
|
|
Makefile?(.inc)|*.port.mk)
|
|
|
|
check_makefile "$F"
|
|
|
|
;;
|
|
|
|
|
|
|
|
distinfo)
|
|
|
|
;;
|
|
|
|
|
|
|
|
*)
|
|
|
|
handle_extra_file "$F"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
fi
|
|
|
|
done
|
2013-08-22 10:41:20 +00:00
|
|
|
|
2013-08-22 13:29:07 +00:00
|
|
|
$pkg_exists && check_pkg_dir "$dir"/pkg "$last_subst_cmd"
|
2013-08-22 10:41:20 +00:00
|
|
|
|
2013-08-23 08:39:51 +00:00
|
|
|
$existing_port ||
|
|
|
|
egrep -q '^ *SUBDIR[[:space:]]*\+?=' "$dir"/Makefile ||
|
2013-08-21 17:00:24 +00:00
|
|
|
err missing subdir Makefile
|
|
|
|
}
|
|
|
|
|
|
|
|
# Checks made:
|
|
|
|
# * Whitelist filter of what could be in this directory.
|
|
|
|
check_port_dir() {
|
|
|
|
$debugging && echo "CALLED: check_port_dir($*)" >&2
|
|
|
|
|
|
|
|
local dir=$1; shift
|
2014-08-10 20:41:54 +00:00
|
|
|
skip_dir "$dir" && return
|
2013-08-22 12:53:49 +00:00
|
|
|
local distinfo_lives_upper pkg_lives_upper plist_lives_upper
|
2013-08-21 17:00:24 +00:00
|
|
|
for opt; do
|
|
|
|
# looks unsafe but we do not pass anything except
|
|
|
|
# "foo=true" and "foo=false" here
|
|
|
|
eval "$opt"
|
|
|
|
done
|
|
|
|
|
2013-08-22 12:53:49 +00:00
|
|
|
distinfo_lives_upper=${distinfo_lives_upper:-false}
|
|
|
|
pkg_lives_upper=${pkg_lives_upper:-false}
|
|
|
|
plist_lives_upper=${plist_lives_upper:-false}
|
2013-08-21 17:00:24 +00:00
|
|
|
|
|
|
|
check_perms_in_dir "$dir"
|
|
|
|
|
|
|
|
if [[ -f $dir/Makefile.inc ]] ||
|
2013-08-22 09:44:17 +00:00
|
|
|
egrep -sq '^ *SUBDIR[[:space:]]*\+?=' "$dir"/Makefile ||
|
|
|
|
has_subdirs_only "$dir"; then
|
2013-08-22 22:37:17 +00:00
|
|
|
check_port_hier "${dir#./}" "${@:-}"
|
2013-08-21 17:00:24 +00:00
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
|
|
|
local F
|
|
|
|
local distinfo_exists=false
|
|
|
|
local mk_exists=false
|
|
|
|
local pkg_exists=false
|
|
|
|
local plist_exists=false
|
|
|
|
local portmk_exists=true
|
|
|
|
local non_portmk=0
|
|
|
|
|
|
|
|
for F in "$dir"/* "$dir"/.*; do
|
|
|
|
F=${F#./}
|
|
|
|
ignoring "$F" && continue
|
|
|
|
case ${F##*/} in
|
|
|
|
Makefile)
|
|
|
|
test -f "$F" || err "$F is not a file"
|
|
|
|
check_makefile "$F"
|
|
|
|
mk_exists=true
|
2013-08-22 20:33:16 +00:00
|
|
|
((++non_portmk))
|
2013-08-21 17:00:24 +00:00
|
|
|
;;
|
|
|
|
|
|
|
|
distinfo)
|
|
|
|
$distinfo_lives_upper && err_duplicated distinfo "$dir"
|
|
|
|
distinfo_exists=true
|
|
|
|
test -f "$F" || err "$F is not a file"
|
2013-08-22 20:33:16 +00:00
|
|
|
((++non_portmk))
|
2013-08-21 17:00:24 +00:00
|
|
|
;;
|
|
|
|
|
|
|
|
*.port.mk)
|
|
|
|
test -f "$F" || err "$F is not a file"
|
|
|
|
check_makefile "$F"
|
|
|
|
portmk_exists=true
|
|
|
|
;;
|
|
|
|
|
|
|
|
systrace.filter)
|
|
|
|
test -f "$F" || err "$F is not a file"
|
2013-08-22 20:33:16 +00:00
|
|
|
((++non_portmk))
|
2013-08-21 17:00:24 +00:00
|
|
|
;;
|
|
|
|
|
|
|
|
files|patches)
|
|
|
|
if [[ -d $F ]]; then
|
|
|
|
check_${F##*/}_dir "$F"
|
|
|
|
else
|
|
|
|
err "$F" is not a directory
|
|
|
|
fi
|
2013-08-22 20:33:16 +00:00
|
|
|
((++non_portmk))
|
2013-08-21 17:00:24 +00:00
|
|
|
;;
|
|
|
|
|
|
|
|
pkg)
|
|
|
|
if [[ -d $F ]]; then
|
|
|
|
pkg_exists=true
|
2013-08-21 21:53:29 +00:00
|
|
|
# Actual check to be done later, we need to gather
|
|
|
|
# additional info through "make show=" call.
|
2013-08-21 17:00:24 +00:00
|
|
|
ls "$F"/PLIST* >/dev/null 2>&1 &&
|
|
|
|
plist_exists=true
|
|
|
|
$plist_lives_upper && $plist_exists &&
|
2013-11-10 14:56:41 +00:00
|
|
|
err_duplicated "packing list(s)" "$dir"
|
2013-08-21 17:00:24 +00:00
|
|
|
else
|
|
|
|
err "$F" is not a directory
|
|
|
|
fi
|
2013-08-22 20:33:16 +00:00
|
|
|
((++non_portmk))
|
2013-08-21 17:00:24 +00:00
|
|
|
;;
|
|
|
|
|
|
|
|
*)
|
|
|
|
handle_extra_file "$F"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
# examples: lang/clang, www/mozilla
|
|
|
|
$portmk_exists && ((non_portmk == 0)) && return
|
|
|
|
|
|
|
|
$mk_exists || err no Makefile in "$dir"
|
2013-08-21 21:53:29 +00:00
|
|
|
$pkg_exists || $pkg_lives_upper || err "no pkg/ in $dir"
|
2013-08-21 17:00:24 +00:00
|
|
|
$distinfo_lives_upper && distinfo_exists=true
|
|
|
|
$distinfo_exists || $existing_port || err "no distinfo in $dir"
|
|
|
|
|
|
|
|
# Now gather and check some info via "make show=...".
|
|
|
|
# We request all info at once for speed.
|
|
|
|
|
2015-04-12 18:37:23 +00:00
|
|
|
local dist_subdir distfiles flavor flavors gh_commit master_sites
|
2013-08-23 01:26:18 +00:00
|
|
|
local multi_packages pkgpath_this pseudo_flavor pseudo_flavors
|
|
|
|
local shared_libs subst_cmd
|
2014-04-27 17:57:14 +00:00
|
|
|
local perm_pkg_cdrom perm_pkg_ftp perm_dist_ftp
|
2015-04-12 18:37:23 +00:00
|
|
|
local show_items="DIST_SUBDIR DISTFILES FLAVOR FLAVORS GH_COMMIT"
|
2013-08-22 10:41:20 +00:00
|
|
|
local show_items="$show_items MASTER_SITES MULTI_PACKAGES PKGPATH"
|
2013-08-23 01:26:18 +00:00
|
|
|
local show_items="$show_items PSEUDO_FLAVOR PSEUDO_FLAVORS"
|
|
|
|
local show_items="$show_items SHARED_LIBS SUBST_CMD"
|
2014-04-27 17:57:14 +00:00
|
|
|
local show_items="$show_items PERMIT_PACKAGE_CDROM PERMIT_PACKAGE_FTP"
|
|
|
|
local show_items="$show_items PERMIT_DISTFILES_FTP"
|
2013-12-11 15:54:03 +00:00
|
|
|
local read_ok=false
|
2013-08-21 17:00:24 +00:00
|
|
|
|
2013-08-22 12:53:49 +00:00
|
|
|
local read_failed=false
|
2013-08-22 10:41:20 +00:00
|
|
|
(cd -- "$dir"; make "${make_args[@]}" show="$show_items" || true) </dev/null |&
|
2013-08-22 12:53:49 +00:00
|
|
|
read -pr dist_subdir &&
|
|
|
|
read -pr distfiles &&
|
|
|
|
read -pr flavor &&
|
|
|
|
read -pr flavors &&
|
2015-04-12 18:37:23 +00:00
|
|
|
read -pr gh_commit &&
|
2013-08-22 12:53:49 +00:00
|
|
|
read -pr master_sites &&
|
|
|
|
read -pr multi_packages &&
|
2013-08-22 20:56:14 +00:00
|
|
|
read -pr pkgpath_this &&
|
2013-08-23 01:26:18 +00:00
|
|
|
read -pr pseudo_flavor &&
|
2013-08-22 12:53:49 +00:00
|
|
|
read -pr pseudo_flavors &&
|
|
|
|
read -pr shared_libs &&
|
|
|
|
read -pr subst_cmd &&
|
2014-04-27 17:57:14 +00:00
|
|
|
read -pr perm_pkg_cdrom &&
|
|
|
|
read -pr perm_pkg_ftp &&
|
|
|
|
read -pr perm_dist_ftp &&
|
2013-08-22 12:53:49 +00:00
|
|
|
read_ok=true
|
|
|
|
if $read_ok; then
|
|
|
|
exec 3<&p
|
|
|
|
exec 3<&-
|
2013-12-11 15:54:03 +00:00
|
|
|
wait
|
2013-08-23 07:45:07 +00:00
|
|
|
else
|
|
|
|
error=true
|
|
|
|
return
|
2013-08-22 12:53:49 +00:00
|
|
|
fi
|
2013-08-22 10:41:20 +00:00
|
|
|
|
2013-08-23 01:26:18 +00:00
|
|
|
pseudo_flavor=$(echo "$pseudo_flavor" | sed -e 's/,/ /g')
|
|
|
|
pseudo_flavor=${pseudo_flavor##" "}
|
|
|
|
|
|
|
|
local f pf found
|
|
|
|
|
2013-08-22 22:37:17 +00:00
|
|
|
local check_flavors=
|
2013-08-23 01:26:18 +00:00
|
|
|
[[ $flavor != "$pseudo_flavor" ]] && unset check_flavors[0]
|
2013-08-22 10:41:20 +00:00
|
|
|
|
|
|
|
for f in $flavors; do
|
|
|
|
for pf in $pseudo_flavors; do
|
|
|
|
[[ $f == "$pf" ]] && continue 2
|
2013-08-21 17:00:24 +00:00
|
|
|
done
|
2013-08-22 10:41:20 +00:00
|
|
|
[[ $f == debug ]] && continue # XXX
|
2013-08-22 22:37:17 +00:00
|
|
|
check_flavors[${#check_flavors[@]}]=$f
|
2013-08-22 10:41:20 +00:00
|
|
|
done
|
2013-08-21 17:00:24 +00:00
|
|
|
|
2013-08-22 10:41:20 +00:00
|
|
|
check_distfiles "$dir" "$dist_subdir" $distfiles
|
|
|
|
check_master_sites "$dir" $master_sites
|
2014-04-27 17:57:14 +00:00
|
|
|
check_permit_dist "$dir" "$perm_pkg_cdrom" "$perm_pkg_ftp" \
|
|
|
|
"$perm_dist_ftp"
|
2013-08-22 10:41:20 +00:00
|
|
|
$pkg_exists && check_pkg_dir "$dir"/pkg "$subst_cmd"
|
2013-12-21 11:47:20 +00:00
|
|
|
$existing_port || check_shlibs_versions "$dir" $shared_libs
|
2013-08-21 17:00:24 +00:00
|
|
|
|
2015-04-12 18:37:23 +00:00
|
|
|
if [[ -n $gh_commit ]]; then
|
|
|
|
local ghclen=$(echo -n "$gh_commit" | wc -c)
|
|
|
|
if ((ghclen != 40)); then
|
|
|
|
err "GH_COMMIT should be in full form (40 characters)"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2013-08-22 10:41:20 +00:00
|
|
|
for _s in $multi_packages; do
|
2014-07-23 22:11:20 +00:00
|
|
|
sub_checks "$dir" "$_s" "${check_flavors[@]}"
|
2013-08-22 10:41:20 +00:00
|
|
|
done
|
2013-08-21 17:00:24 +00:00
|
|
|
|
2013-08-22 20:56:14 +00:00
|
|
|
pkgpath=${pkgpath:-"$pkgpath_this"}
|
2013-08-22 10:41:20 +00:00
|
|
|
last_subst_cmd="$subst_cmd"
|
2013-08-21 17:00:24 +00:00
|
|
|
}
|
|
|
|
|
2013-08-22 20:33:16 +00:00
|
|
|
# Checks made: obvious
|
|
|
|
check_trailing_whitespace() {
|
|
|
|
egrep -q '[[:space:]]+$' "$1" &&
|
|
|
|
err "trailing whitespace in $1"
|
|
|
|
}
|
|
|
|
|
2013-10-13 16:47:18 +00:00
|
|
|
# Checks made: obvious
|
|
|
|
check_newline_at_eof() {
|
|
|
|
(( $(tail -1 -- "$1" | wc -l) == 0)) &&
|
|
|
|
err "no newline at EOF in $1"
|
|
|
|
}
|
|
|
|
|
2013-08-21 17:00:24 +00:00
|
|
|
# Checks made:
|
|
|
|
# * Every library in SHARED_LIBS has 0.0 version.
|
2013-12-21 11:47:20 +00:00
|
|
|
check_shlibs_versions() {
|
|
|
|
$debugging && echo "CALLED: check_shlibs_versions($*)" >&2
|
2013-08-21 17:00:24 +00:00
|
|
|
|
|
|
|
local dir=$1; shift
|
|
|
|
local lib
|
|
|
|
local libver
|
|
|
|
local portref=$(portref "$dir")
|
|
|
|
|
|
|
|
while (($# > 1)); do
|
|
|
|
lib=$1
|
|
|
|
libver=$2
|
|
|
|
if [[ $libver != 0.0 ]]; then
|
|
|
|
err "${portref}the $lib shared library has" \
|
|
|
|
"version $libver instead of 0.0"
|
|
|
|
fi
|
|
|
|
shift 2
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
# Checks made:
|
|
|
|
# * Distfiles with useless names go into DIST_SUBDIR or have {url} suffix.
|
|
|
|
check_distfiles() {
|
|
|
|
$debugging && echo "CALLED: check_distfiles($*)" >&2
|
|
|
|
|
|
|
|
local dir=$1; shift
|
|
|
|
local dist_subdir=$1; shift
|
|
|
|
local portref=$(portref "$dir")
|
|
|
|
|
|
|
|
# do not care about absent distfiles, this is fine for meta ports
|
|
|
|
while (($# > 1)); do
|
|
|
|
# try to catch "version-only" names, but not anything more
|
|
|
|
if [[ $1 == ?(v)?(.)+([0-9])?(.+([0-9]))*(.+([a-z])) &&
|
|
|
|
-z $dist_subdir && $1 != *\{*\} ]]; then
|
|
|
|
err "${portref}badly named distfile $1 without" \
|
|
|
|
"DIST_SUBDIR or {url} postfix"
|
|
|
|
fi
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
# Checks made:
|
|
|
|
# * No unreliable (without fixed distfiles) hosting listed in MASTER_SITES.
|
|
|
|
check_master_sites() {
|
|
|
|
$debugging && echo "CALLED: check_master_sites($*)" >&2
|
|
|
|
|
|
|
|
local dir=$1; shift
|
|
|
|
local portref=$(portref "$dir")
|
|
|
|
local name
|
|
|
|
|
|
|
|
while (($# > 1)); do
|
|
|
|
case "$1" in
|
|
|
|
http?(s)://bitbucket.com/*) name=BitBucket;;
|
|
|
|
http?(s)://gitorious.com/*) name=Gitorious;;
|
|
|
|
*) name=;;
|
|
|
|
esac
|
|
|
|
[[ -n $name ]] && err "$portref$name does not hold real" \
|
|
|
|
"releases, please host the distfiles somewhere" \
|
2013-12-11 15:53:07 +00:00
|
|
|
"else or ask someone to do this for you"
|
2013-08-21 17:00:24 +00:00
|
|
|
shift
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
# Run checks that are FLAVOR/SUBPACKAGE-dependent.
|
|
|
|
sub_checks() {
|
|
|
|
$debugging && echo "CALLED: sub_checks($*)" >&2
|
|
|
|
|
|
|
|
local dir=$1; shift
|
|
|
|
local subpkg=$1; shift
|
2014-04-27 17:57:14 +00:00
|
|
|
local flavor
|
2013-08-21 17:00:24 +00:00
|
|
|
for flavor in "$@"; do
|
|
|
|
# avoid extra noise
|
|
|
|
[[ ${flavor#no_} != ${flavor} &&
|
|
|
|
${subpkg#-} == ${flavor#no_} ]] &&
|
|
|
|
continue
|
|
|
|
|
|
|
|
(
|
|
|
|
cd -- "$dir"
|
|
|
|
portref=$(portref "$dir" "$subpkg" "$flavor" "$*")
|
|
|
|
export SUBPACKAGE="$subpkg" FLAVOR="$flavor"
|
|
|
|
|
2014-04-27 17:57:14 +00:00
|
|
|
local wantlib_var=WANTLIB${subpkg%-}
|
2014-07-23 22:11:20 +00:00
|
|
|
local vars="COMMENT$subpkg FULLPKGNAME$subpkg"
|
|
|
|
vars="$vars MODULES"
|
2014-05-19 00:57:54 +00:00
|
|
|
vars="$vars PKG_ARCH$subpkg $wantlib_var"
|
2014-04-27 17:57:14 +00:00
|
|
|
vars="$vars PERMIT_PACKAGE_CDROM${subpkg%-}"
|
|
|
|
vars="$vars PERMIT_PACKAGE_FTP${subpkg%-}"
|
|
|
|
make "${make_args[@]}" show="$vars" | {
|
2014-07-23 22:11:20 +00:00
|
|
|
local comment fullpkgname modules pkg_arch
|
|
|
|
local wantlib perm_pkg_cdrom perm_pkg_ftp
|
2014-05-19 00:57:54 +00:00
|
|
|
read -r comment
|
2014-07-23 22:11:20 +00:00
|
|
|
read -r fullpkgname
|
2013-08-21 21:53:29 +00:00
|
|
|
read -r modules
|
2013-10-25 23:32:08 +00:00
|
|
|
read -r pkg_arch
|
2013-08-21 21:53:29 +00:00
|
|
|
read -r wantlib
|
2014-04-27 17:57:14 +00:00
|
|
|
read -r perm_pkg_cdrom
|
|
|
|
read -r perm_pkg_ftp
|
2014-05-19 00:57:54 +00:00
|
|
|
|
|
|
|
if [[ $comment == @(a|an|the)" "* ]]; then
|
|
|
|
err "${portref}no leading articles in" \
|
|
|
|
"COMMENT${subpkg%-}, please"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ $pkg_arch == "*" && -n $wantlib ]]; then
|
2014-04-27 17:57:14 +00:00
|
|
|
err "${portref}non-empty $wantlib_var for" \
|
2013-10-25 23:32:08 +00:00
|
|
|
"arch-independent package"
|
|
|
|
fi
|
2014-05-19 00:57:54 +00:00
|
|
|
|
2014-08-10 20:46:04 +00:00
|
|
|
check_wantlib "$portref" "$modules" $wantlib
|
2014-04-27 17:57:14 +00:00
|
|
|
check_permit_subpkg "$portref" "$subpkg" \
|
2014-08-10 20:46:04 +00:00
|
|
|
"$perm_pkg_cdrom" "$perm_pkg_ftp"
|
2014-05-08 17:07:46 +00:00
|
|
|
|
|
|
|
if $plist_checks; then
|
|
|
|
(make "${make_args[@]}" \
|
|
|
|
print-plist-with-depends || true) \
|
|
|
|
</dev/null |&
|
|
|
|
check_plist "$portref" "$fullpkgname" \
|
|
|
|
"$flavor" "${subpkg%-}" "$modules"
|
2014-08-10 20:39:03 +00:00
|
|
|
check_lib_depends "$portref" "$subpkg" \
|
|
|
|
"$modules" "$wantlib"
|
2014-05-08 17:07:46 +00:00
|
|
|
wait
|
|
|
|
fi
|
|
|
|
|
2014-04-27 17:57:14 +00:00
|
|
|
! $error
|
2013-08-21 17:00:24 +00:00
|
|
|
} || error=true
|
|
|
|
|
|
|
|
! $error
|
|
|
|
) || error=true
|
|
|
|
done
|
2013-12-11 15:54:03 +00:00
|
|
|
wait
|
2013-08-21 17:00:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# Checks made:
|
|
|
|
# * If package installs system-wide icons, it should have the
|
2015-03-27 08:09:54 +00:00
|
|
|
# x11/gtk+3,-guic dependency and @exec/@unexec-delete with
|
2013-08-21 17:00:24 +00:00
|
|
|
# %D/bin/gtk-update-icon-cache -q -t %D/share/icons/$theme
|
2013-10-19 20:06:14 +00:00
|
|
|
# for each icon theme used in package. If there is an
|
|
|
|
# index.theme provided, then, instead of gtk-update-icon-cache,
|
|
|
|
# @unexec-delete should contain the following command:
|
|
|
|
# rm -f %D/share/icons/$theme/icon-theme.cache
|
2013-08-21 17:00:24 +00:00
|
|
|
#
|
|
|
|
# * If package adds a MIME type handler, it should have the
|
|
|
|
# devel/desktop-file-utils dependency and @exec/@unexec-delete with
|
|
|
|
# %D/bin/update-desktop-database . Unfortunately, it's hard to tell
|
|
|
|
# if there is a MIME type handler in .desktop file, so we just
|
|
|
|
# trigger if any .desktop files are added to
|
|
|
|
# ${PREFIX}/share/applications/ .
|
|
|
|
#
|
|
|
|
# * If package adds a MIME types package, it should have the
|
|
|
|
# misc/shared-mime-info dependency and @exec/@unexec-delete with
|
|
|
|
# %D/bin/update-mime-database %D/share/mime
|
|
|
|
#
|
2014-05-07 22:27:06 +00:00
|
|
|
# * If package adds a GLib schema, it should have @exec/@unexec-delete
|
|
|
|
# with %D/bin/glib-compile-schemas %D/share/glib-2.0/schemas >/dev/null
|
2014-05-08 15:39:49 +00:00
|
|
|
# and "devel/dconf" in MODULES (or at least RDEP on devel/dconf).
|
2014-05-07 22:27:06 +00:00
|
|
|
#
|
2013-08-21 17:00:24 +00:00
|
|
|
# * If package installs .mo files under ${PREFIX}/share/locale/, then
|
|
|
|
# run-time dependency on devel/gettext should exists.
|
2013-08-22 16:43:04 +00:00
|
|
|
#
|
2015-04-04 17:23:52 +00:00
|
|
|
# * If package installs files under ${PREFIX}/share/dbus-1/system-services/,
|
|
|
|
# it must have a run-time dependency on x11/dbus,-suid.
|
|
|
|
#
|
2013-08-22 16:43:04 +00:00
|
|
|
# * Each .py should have corresponding .pyc files, to avoid
|
|
|
|
# generation of the latter at run-time.
|
2014-05-06 11:00:55 +00:00
|
|
|
#
|
|
|
|
# * Manual (man and info) pages should go under ${PREFIX}/{man,info},
|
|
|
|
# not under ${PREFIx}/share/{man,info}.
|
2013-08-21 17:00:24 +00:00
|
|
|
check_plist() {
|
|
|
|
$debugging && echo "CALLED: check_plist($*)" >&2
|
|
|
|
|
|
|
|
local portref=$1; shift
|
|
|
|
local fullpkgname=$1; shift
|
2013-08-22 11:31:43 +00:00
|
|
|
local flavor_list=$1; shift
|
2014-05-08 17:07:46 +00:00
|
|
|
local subpkg=$1; shift
|
|
|
|
local modules_list=$1; shift
|
2013-08-22 11:31:43 +00:00
|
|
|
|
|
|
|
local flavor is_static=false
|
|
|
|
for flavor in $flavor_list; do
|
|
|
|
[[ $flavor == static ]] && is_static=true
|
|
|
|
done
|
2013-08-21 17:00:24 +00:00
|
|
|
|
|
|
|
local guic_dep=false
|
|
|
|
local guic_dep_needed=false
|
|
|
|
local guic_exec_cnt=0
|
|
|
|
local guic_unexec_cnt=0
|
|
|
|
|
|
|
|
local mime_dep=false
|
|
|
|
local mime_dep_needed=false
|
|
|
|
local mime_exec_cnt=0
|
|
|
|
local mime_unexec_cnt=0
|
|
|
|
|
|
|
|
local mimepkg_dep=false
|
|
|
|
local mimepkg_dep_needed=false
|
|
|
|
local mimepkg_exec_cnt=0
|
|
|
|
local mimepkg_unexec_cnt=0
|
|
|
|
|
2014-05-08 17:07:46 +00:00
|
|
|
local dconf_module
|
|
|
|
if [[ $modules_list == ?(* )devel/dconf?( *) ]]; then
|
|
|
|
dconf_module=true
|
|
|
|
else
|
|
|
|
dconf_module=false
|
|
|
|
fi
|
2014-05-08 15:39:49 +00:00
|
|
|
local dconf_dep=false
|
|
|
|
local dconf_dep_needed=false
|
|
|
|
local dconf_exec_cnt=0
|
|
|
|
local dconf_unexec_cnt=0
|
2014-05-07 22:27:06 +00:00
|
|
|
|
2013-08-22 20:33:16 +00:00
|
|
|
# Lists of icon themes discovered through reading
|
|
|
|
# @file, @exec and @unexec lines, accordingly.
|
2013-08-22 22:37:17 +00:00
|
|
|
local icon_themes= exec_icon_themes= unexec_icon_themes=
|
2013-08-21 17:00:24 +00:00
|
|
|
|
2013-10-19 20:06:14 +00:00
|
|
|
# List of icon themes that remove cache file
|
|
|
|
local rm_cache_themes=
|
|
|
|
|
2013-08-21 17:00:24 +00:00
|
|
|
local gettext_dep=false
|
|
|
|
local translation_found=false
|
|
|
|
|
2015-04-04 17:23:52 +00:00
|
|
|
local dbus_suid_dep=false
|
|
|
|
local dbus_suid_dep_needed=false
|
|
|
|
|
2013-08-22 20:33:16 +00:00
|
|
|
# Lists of .py, .pyc and .pyo items found, accordingly
|
2013-08-22 22:37:17 +00:00
|
|
|
local py_files= pyc_files= pyo_files=
|
|
|
|
unset py_files[0] pyc_files[0] pyo_files[0]
|
2013-08-22 16:43:04 +00:00
|
|
|
|
2014-05-06 11:00:55 +00:00
|
|
|
local wrong_man=false wrong_info=false
|
|
|
|
|
2013-08-22 20:33:16 +00:00
|
|
|
# Temporary ones
|
2013-08-22 16:43:04 +00:00
|
|
|
local app l theme varname py
|
2013-08-21 17:00:24 +00:00
|
|
|
|
2013-08-22 10:41:20 +00:00
|
|
|
while read -pr l; do
|
2013-08-21 17:00:24 +00:00
|
|
|
case "$l" in
|
2013-08-22 16:43:04 +00:00
|
|
|
"@comment "*)
|
|
|
|
# ignore
|
|
|
|
;;
|
2014-08-12 01:44:08 +00:00
|
|
|
share/icons/*/*/*|share/icons/*/@(index.theme|iconrc?(-png)))
|
2013-08-22 00:56:00 +00:00
|
|
|
# Themes have at least two levels in depth.
|
|
|
|
#
|
2013-08-21 17:00:24 +00:00
|
|
|
# We match directories by purpose, this helps to catch
|
|
|
|
# update-plist fuckups, when directories go into one
|
|
|
|
# package and actual icons go in another.
|
|
|
|
guic_dep_needed=true
|
|
|
|
theme=${l#share/icons/}
|
|
|
|
theme=${theme%%/*}
|
|
|
|
# wrap with the '/' characters to avoid erroneous matching
|
|
|
|
echo "$icon_themes" | fgrep -q "/$theme/" ||
|
|
|
|
icon_themes="$icon_themes /$theme/"
|
2013-10-19 20:06:14 +00:00
|
|
|
if [[ "$l" = "share/icons/$theme/index.theme" ]]; then
|
|
|
|
echo "$rm_cache_themes" | fgrep -q "/$theme/" ||
|
2013-11-28 15:48:29 +00:00
|
|
|
err "${portref}missing @unexec-delete rm -f" \
|
2013-10-19 20:06:14 +00:00
|
|
|
"%D/share/icons/$theme/icon-theme.cache"
|
|
|
|
fi
|
2013-08-21 17:00:24 +00:00
|
|
|
;;
|
2013-08-22 00:56:00 +00:00
|
|
|
share/icons/*(*/))
|
|
|
|
# Do not match intermediate directories to avoid false
|
|
|
|
# positives.
|
|
|
|
;;
|
2014-07-08 09:48:07 +00:00
|
|
|
share/icons/*.xpm)
|
|
|
|
app=${l#share/icons/}
|
|
|
|
app=${app%%/*}
|
|
|
|
app=${app%%.*}
|
|
|
|
err "${portref}installs icon ${l##*/} in ${l%/*}, it" \
|
|
|
|
"should likely go in share/pixmaps/ instead"
|
|
|
|
;;
|
2014-08-12 01:44:08 +00:00
|
|
|
share/icons/default.*)
|
|
|
|
;;
|
2013-08-22 00:56:00 +00:00
|
|
|
share/icons/*)
|
2013-08-21 17:00:24 +00:00
|
|
|
app=${l#share/icons/}
|
|
|
|
app=${app%%/*}
|
2013-08-22 13:23:54 +00:00
|
|
|
app=${app%%.*}
|
2013-08-21 17:00:24 +00:00
|
|
|
err "${portref}installs icon ${l##*/} in ${l%/*}, it" \
|
|
|
|
"should go in share/$app/icons/ or like instead"
|
|
|
|
;;
|
2015-03-27 08:09:54 +00:00
|
|
|
"@depend x11/gtk+3,-guic"*)
|
2013-08-21 17:00:24 +00:00
|
|
|
guic_dep=true
|
|
|
|
;;
|
|
|
|
"@exec %D/bin/gtk-update-icon-cache -q -t %D/share/icons/"*)
|
|
|
|
theme=${l##*/}
|
|
|
|
varname=$(echo "$theme" | sed -e 's/[^a-zA-Z_]/_/g')
|
2013-08-22 20:33:16 +00:00
|
|
|
((++guic_exec_cnt))
|
|
|
|
eval "((++guic_exec_cnt_$varname))"
|
2013-10-19 20:06:14 +00:00
|
|
|
exec_icon_themes="$exec_icon_themes /$theme/"
|
2013-08-21 17:00:24 +00:00
|
|
|
;;
|
|
|
|
"@unexec-delete %D/bin/gtk-update-icon-cache -q -t %D/share/icons/"*)
|
|
|
|
theme=${l##*/}
|
|
|
|
varname=$(echo "$theme" | sed -e 's/[^a-zA-Z_]/_/g')
|
2013-08-22 20:33:16 +00:00
|
|
|
((++guic_unexec_cnt))
|
|
|
|
eval "((++guic_unexec_cnt_$varname))"
|
2013-10-19 20:06:14 +00:00
|
|
|
unexec_icon_themes="$unexec_icon_themes /$theme/"
|
2013-08-21 17:00:24 +00:00
|
|
|
;;
|
|
|
|
"@unexec-delete rm -f "%D/share/icons/*/icon-theme.cache)
|
|
|
|
# as an alternative, port could zap the theme entirely
|
|
|
|
theme=${l#*/icons/}
|
|
|
|
theme=${theme%/icon-theme.cache}
|
|
|
|
varname=$(echo "$theme" | sed -e 's/[^a-zA-Z_]/_/g')
|
2013-08-22 20:33:16 +00:00
|
|
|
((++guic_unexec_cnt))
|
|
|
|
eval "((++guic_unexec_cnt_$varname))"
|
2013-10-19 20:06:14 +00:00
|
|
|
unexec_icon_themes="$unexec_icon_themes /$theme/"
|
|
|
|
rm_cache_themes="$rm_cache_themes /$theme/"
|
|
|
|
if echo "$icon_themes" | fgrep -q "/$theme/"; then
|
2013-11-28 13:38:01 +00:00
|
|
|
err "${portref}the @unexec-delete line removing" \
|
2013-10-19 20:06:14 +00:00
|
|
|
"%D/share/icons/$theme/icon-theme.cache" \
|
|
|
|
"does not preceed all of the icon theme" \
|
|
|
|
"$theme files"
|
|
|
|
fi
|
2013-08-21 17:00:24 +00:00
|
|
|
;;
|
|
|
|
@?(un)exec?(-delete|-update)" %D/bin/gtk-update-icon-cache"*)
|
|
|
|
err "${portref}incorrect gtk-update-icon-cache" \
|
|
|
|
"invocation: ${l#@* }"
|
|
|
|
;;
|
|
|
|
|
|
|
|
share/applications/*(*/)*.desktop)
|
|
|
|
mime_dep_needed=true
|
|
|
|
;;
|
|
|
|
"@depend devel/desktop-file-utils"*)
|
|
|
|
mime_dep=true
|
|
|
|
;;
|
|
|
|
"@exec %D/bin/update-desktop-database")
|
2013-08-22 20:33:16 +00:00
|
|
|
((++mime_exec_cnt))
|
2013-08-21 17:00:24 +00:00
|
|
|
;;
|
|
|
|
"@unexec-delete %D/bin/update-desktop-database")
|
2013-08-22 20:33:16 +00:00
|
|
|
((++mime_unexec_cnt))
|
2013-08-21 17:00:24 +00:00
|
|
|
;;
|
|
|
|
@?(un)exec?(-delete|-update)" %D/bin/update-desktop-database"*)
|
|
|
|
err "${portref}incorrect update-desktop-database" \
|
|
|
|
"invocation: ${l#@* }"
|
|
|
|
;;
|
|
|
|
|
|
|
|
share/mime/packages/*.xml)
|
|
|
|
mimepkg_dep_needed=true
|
|
|
|
;;
|
|
|
|
"@depend misc/shared-mime-info"*)
|
|
|
|
mimepkg_dep=true
|
|
|
|
;;
|
|
|
|
"@exec %D/bin/update-mime-database %D/share/mime")
|
2013-08-22 20:33:16 +00:00
|
|
|
((++mimepkg_exec_cnt))
|
2013-08-21 17:00:24 +00:00
|
|
|
;;
|
|
|
|
"@unexec-delete %D/bin/update-mime-database %D/share/mime")
|
2013-08-22 20:33:16 +00:00
|
|
|
((++mimepkg_unexec_cnt))
|
2013-08-21 17:00:24 +00:00
|
|
|
;;
|
|
|
|
@?(un)exec?(-delete|-update)" %D/bin/update-mime-database"*)
|
|
|
|
err "${portref}incorrect update-mime-database" \
|
|
|
|
"invocation: ${l#@* }"
|
|
|
|
;;
|
|
|
|
|
2014-05-07 22:27:06 +00:00
|
|
|
share/glib-2.0/schemas/*.xml)
|
2014-05-08 15:39:49 +00:00
|
|
|
dconf_dep_needed=true
|
2014-05-07 22:27:06 +00:00
|
|
|
;;
|
2014-05-08 15:39:49 +00:00
|
|
|
"@depend devel/dconf"*)
|
|
|
|
dconf_dep=true
|
2014-05-07 22:27:06 +00:00
|
|
|
;;
|
|
|
|
"@exec %D/bin/glib-compile-schemas %D/share/glib-2.0/schemas >/dev/null")
|
2014-05-08 15:39:49 +00:00
|
|
|
((++dconf_exec_cnt))
|
2014-05-07 22:27:06 +00:00
|
|
|
;;
|
|
|
|
"@unexec-delete %D/bin/glib-compile-schemas %D/share/glib-2.0/schemas >/dev/null")
|
2014-05-08 15:39:49 +00:00
|
|
|
((++dconf_unexec_cnt))
|
2014-05-07 22:27:06 +00:00
|
|
|
;;
|
|
|
|
@?(un)exec?(-delete|-update)" %D/bin/glib-compile-schemas"*)
|
|
|
|
err "${portref}incorrect glib-compile-schemas" \
|
|
|
|
"invocation: ${l#@* }"
|
|
|
|
;;
|
|
|
|
|
2013-08-21 17:00:24 +00:00
|
|
|
"@depend devel/gettext"*)
|
|
|
|
gettext_dep=true
|
|
|
|
;;
|
|
|
|
share/locale/*/*/*.mo)
|
|
|
|
translation_found=true
|
|
|
|
;;
|
2013-08-22 16:43:04 +00:00
|
|
|
|
2015-04-04 17:23:52 +00:00
|
|
|
share/dbus-1/system-services/*)
|
|
|
|
dbus_suid_dep_needed=true
|
|
|
|
;;
|
|
|
|
"@depend x11/dbus,-suid"*)
|
|
|
|
dbus_suid_dep=true
|
|
|
|
;;
|
|
|
|
|
2013-08-22 16:43:04 +00:00
|
|
|
# XXX KSH arrays are limited to 10239 items
|
2013-08-24 16:15:56 +00:00
|
|
|
share/@(doc|*(*/)examples)+(/*).py|?(s)bin/*.py)
|
2013-08-22 16:43:04 +00:00
|
|
|
# ignore
|
|
|
|
;;
|
|
|
|
*.py)
|
|
|
|
py_files[${#py_files[@]}]=$l
|
|
|
|
;;
|
|
|
|
*.pyc)
|
|
|
|
pyc_files[${#pyc_files[@]}]=$(normalize_pyco "$l")
|
|
|
|
;;
|
|
|
|
*.pyo)
|
|
|
|
pyo_files[${#pyo_files[@]}]=$(normalize_pyco "$l")
|
|
|
|
;;
|
2014-05-06 11:00:55 +00:00
|
|
|
|
|
|
|
share/man/*)
|
|
|
|
wrong_man=true
|
|
|
|
;;
|
|
|
|
share/info/*)
|
|
|
|
wrong_info=true
|
|
|
|
;;
|
2013-08-21 17:00:24 +00:00
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
# gtk-update-icon-cache
|
|
|
|
$guic_dep_needed && ! $guic_dep &&
|
|
|
|
[[ $fullpkgname != gtk-update-icon-cache-* ]] &&
|
2015-03-27 08:09:54 +00:00
|
|
|
err "${portref}missing RDEP on x11/gtk+3,-guic"
|
2013-08-21 17:00:24 +00:00
|
|
|
local cnt
|
|
|
|
for theme in $icon_themes; do
|
|
|
|
theme=${theme#/}
|
|
|
|
theme=${theme%/}
|
|
|
|
|
|
|
|
varname=$(echo "$theme" | sed -e 's/[^a-zA-Z_]/_/g')
|
|
|
|
|
|
|
|
((guic_exec_cnt--)) || true
|
|
|
|
((guic_unexec_cnt--)) || true
|
|
|
|
eval "((guic_exec_cnt_$varname--)) || true"
|
|
|
|
eval "((guic_unexec_cnt_$varname--)) || true"
|
|
|
|
|
|
|
|
eval "cnt=\$guic_exec_cnt_$varname"
|
|
|
|
if (($cnt > 0)); then
|
|
|
|
err "${portref}extra @exec of gtk-update-icon-cache" \
|
|
|
|
"for icon theme $theme"
|
|
|
|
((guic_exec_cnt--)) || true
|
|
|
|
elif (($cnt < 0)); then
|
|
|
|
err "${portref}missing @exec of gtk-update-icon-cache" \
|
|
|
|
"for icon theme $theme"
|
|
|
|
fi
|
|
|
|
|
|
|
|
eval "cnt=\$guic_unexec_cnt_$varname"
|
|
|
|
if (($cnt > 0)); then
|
|
|
|
err "${portref}extra @unexec-delete of gtk-update-icon-cache" \
|
|
|
|
"for icon theme $theme"
|
|
|
|
((guic_unexec_cnt--)) || true
|
|
|
|
elif (($cnt < 0)); then
|
|
|
|
err "${portref}missing @unexec-delete of gtk-update-icon-cache" \
|
|
|
|
"for icon theme $theme"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
for theme in $exec_icon_themes; do
|
|
|
|
theme=${theme#/}
|
|
|
|
theme=${theme%/}
|
|
|
|
echo "$icon_themes" | fgrep -q "/$theme/" ||
|
2013-08-22 09:44:17 +00:00
|
|
|
err "${portref}doing @exec of gtk-update-icon-cache" \
|
2013-08-21 17:00:24 +00:00
|
|
|
"for absent icon theme $theme"
|
|
|
|
done
|
|
|
|
|
|
|
|
for theme in $unexec_icon_themes; do
|
|
|
|
theme=${theme#/}
|
|
|
|
theme=${theme%/}
|
|
|
|
echo "$icon_themes" | fgrep -q "/$theme/" ||
|
2013-08-22 09:44:17 +00:00
|
|
|
err "${portref}doing @unexec-delete of gtk-update-icon-cache" \
|
2013-08-21 17:00:24 +00:00
|
|
|
"for absent icon theme $theme"
|
|
|
|
done
|
|
|
|
|
|
|
|
((guic_exec_cnt > 0)) &&
|
|
|
|
err "${portref}extra @exec of gtk-update-icon-cache"
|
|
|
|
((guic_unexec_cnt > 0)) &&
|
|
|
|
err "${portref}extra @unexec-delete of gtk-update-icon-cache"
|
|
|
|
|
|
|
|
# desktop-file-utils (simplier than previous, isn't it?)
|
|
|
|
$mime_dep_needed && ! $mime_dep &&
|
|
|
|
[[ $fullpkgname != desktop-file-utils-* ]] &&
|
|
|
|
err "${portref}missing RDEP on devel/desktop-file-utils"
|
|
|
|
if $mime_dep_needed; then
|
|
|
|
((mime_exec_cnt--)) || true
|
|
|
|
((mime_unexec_cnt--)) || true
|
|
|
|
fi
|
|
|
|
if ((mime_exec_cnt > 0)) &&
|
|
|
|
[[ $fullpkgname != desktop-file-utils-* ]]; then
|
|
|
|
err "${portref}extra @exec of update-desktop-database"
|
|
|
|
elif ((mime_exec_cnt < 0)); then
|
|
|
|
err "${portref}missing @exec of update-desktop-database"
|
|
|
|
fi
|
|
|
|
if ((mime_unexec_cnt > 0)); then
|
|
|
|
err "${portref}extra @unexec-delete of update-desktop-database"
|
|
|
|
elif ((mime_unexec_cnt < 0)); then
|
|
|
|
err "${portref}missing @unexec-delete of update-desktop-database"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# update-mime-database (same as previous)
|
|
|
|
$mimepkg_dep_needed && ! $mimepkg_dep &&
|
|
|
|
[[ $fullpkgname != shared-mime-info-* ]] &&
|
|
|
|
err "${portref}missing RDEP on misc/shared-mime-info"
|
|
|
|
if $mimepkg_dep_needed; then
|
|
|
|
((mimepkg_exec_cnt--)) || true
|
|
|
|
((mimepkg_unexec_cnt--)) || true
|
|
|
|
fi
|
|
|
|
if ((mimepkg_exec_cnt > 0)) &&
|
|
|
|
[[ $fullpkgname != shared-mime-info-* ]]; then
|
|
|
|
err "${portref}extra @exec of update-mime-database"
|
|
|
|
elif ((mimepkg_exec_cnt < 0)); then
|
|
|
|
err "${portref}missing @exec of update-mime-database"
|
|
|
|
fi
|
|
|
|
if ((mimepkg_unexec_cnt > 0)); then
|
|
|
|
err "${portref}extra @unexec-delete of update-mime-database"
|
|
|
|
elif ((mimepkg_unexec_cnt < 0)); then
|
|
|
|
err "${portref}missing @unexec-delete of update-mime-database"
|
|
|
|
fi
|
|
|
|
|
2014-05-07 22:27:06 +00:00
|
|
|
# glib-compile-schemas (almost same as previous)
|
2014-05-08 15:39:49 +00:00
|
|
|
#
|
|
|
|
# TODO: detect situation of extra devel/dconf in MODULES
|
|
|
|
# (requires investigation of all subpackages).
|
2014-05-08 17:07:46 +00:00
|
|
|
if $dconf_dep_needed; then
|
|
|
|
if ! $dconf_module; then
|
|
|
|
err "${portref}GLib2 XML schemas found without" \
|
|
|
|
"devel/dconf in MODULES"
|
|
|
|
elif ! $dconf_dep; then
|
|
|
|
err "${portref}missing" \
|
|
|
|
"RUN_DEPENDS${subpkg}+=\${MODDCONF_RUN_DEPENDS}"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2014-05-08 15:39:49 +00:00
|
|
|
if $dconf_dep_needed; then
|
|
|
|
((dconf_exec_cnt--)) || true
|
|
|
|
((dconf_unexec_cnt--)) || true
|
2014-05-07 22:27:06 +00:00
|
|
|
fi
|
2014-05-08 15:39:49 +00:00
|
|
|
if ((dconf_exec_cnt > 0)) &&
|
2014-05-07 22:27:06 +00:00
|
|
|
[[ $fullpkgname != glib2-* ]]; then
|
|
|
|
err "${portref}extra @exec of glib-compile-schemas"
|
2014-05-08 15:39:49 +00:00
|
|
|
elif ((dconf_exec_cnt < 0)); then
|
2014-05-07 22:27:06 +00:00
|
|
|
err "${portref}missing @exec of glib-compile-schemas"
|
|
|
|
fi
|
2014-05-08 15:39:49 +00:00
|
|
|
if ((dconf_unexec_cnt > 0)); then
|
2014-05-07 22:27:06 +00:00
|
|
|
err "${portref}extra @unexec-delete of glib-compile-schemas"
|
2014-05-08 15:39:49 +00:00
|
|
|
elif ((dconf_unexec_cnt < 0)); then
|
2014-05-07 22:27:06 +00:00
|
|
|
err "${portref}missing @unexec-delete of glib-compile-schemas"
|
|
|
|
fi
|
|
|
|
|
2013-08-21 17:00:24 +00:00
|
|
|
# gettext
|
2013-08-22 11:31:43 +00:00
|
|
|
$translation_found && ! $gettext_dep && ! $is_static &&
|
2013-08-22 13:56:16 +00:00
|
|
|
[[ $fullpkgname != gettext-* ]] &&
|
2013-11-10 14:56:41 +00:00
|
|
|
err "${portref}translation file(s) found without" \
|
2014-05-08 15:41:55 +00:00
|
|
|
"devel/gettext dependency in MODULES or RUN_DEPENDS"
|
2013-08-21 17:00:24 +00:00
|
|
|
|
2015-04-04 17:23:52 +00:00
|
|
|
# dbus,-suid
|
|
|
|
if $dbus_suid_dep_needed; then
|
|
|
|
if ! $dbus_suid_dep; then
|
|
|
|
err "${portref}missing" \
|
|
|
|
"RUN_DEPENDS${subpkg}+=x11/dbus,-suid"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2013-08-22 16:43:04 +00:00
|
|
|
# Python modules
|
2013-08-22 22:37:17 +00:00
|
|
|
((${#py_files[@]} > 0)) && set -sA py_files -- "${py_files[@]}"
|
|
|
|
((${#pyc_files[@]} > 0)) && set -sA pyc_files -- "${pyc_files[@]}"
|
|
|
|
((${#pyo_files[@]} > 0)) && set -sA pyo_files -- "${pyo_files[@]}"
|
2013-08-22 16:43:04 +00:00
|
|
|
local ic=0 io=0
|
2013-08-22 22:37:17 +00:00
|
|
|
if ((${#py_files[@]} > 0)); then for py in "${py_files[@]}"; do
|
2013-08-22 16:43:04 +00:00
|
|
|
while [[ $ic -lt ${#pyc_files[@]} ]]; do
|
|
|
|
[[ ${pyc_files[$ic]} < "$py"c ]] || break
|
2013-10-13 16:54:24 +00:00
|
|
|
# allowed behaviour
|
|
|
|
#err "${portref}compiled Python module without" \
|
|
|
|
# "source, expected: ${pyc_files[$ic]%c}"
|
2013-08-22 16:43:04 +00:00
|
|
|
((++ic))
|
|
|
|
done
|
|
|
|
if [[ $ic -lt ${#pyc_files[@]} &&
|
|
|
|
${pyc_files[$ic]} == "$py"c ]]; then
|
|
|
|
((++ic))
|
|
|
|
else
|
|
|
|
err "${portref}Python module without" \
|
2013-10-13 16:54:24 +00:00
|
|
|
"compiled version, consider using" \
|
2014-05-09 20:34:36 +00:00
|
|
|
"\${MODPY_BIN} \${MODPY_LIBDIR}/compileall.py: $py"
|
2013-08-22 16:43:04 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
while [[ $io -lt ${#pyo_files[@]} ]]; do
|
|
|
|
[[ ${pyo_files[$io]} < "$py"o ]] || break
|
2013-10-13 16:54:24 +00:00
|
|
|
# allowed behaviour
|
|
|
|
#err "${portref}optimized Python module without" \
|
|
|
|
# "source, expected: ${pyo_files[$io]%o}"
|
2013-08-22 16:43:04 +00:00
|
|
|
((++io))
|
|
|
|
done
|
|
|
|
if [[ $io -lt ${#pyo_files[@]} &&
|
|
|
|
${pyo_files[$io]} == "$py"o ]]; then
|
|
|
|
((++io))
|
2013-10-13 16:54:24 +00:00
|
|
|
# too much noise, maybe enable in the future
|
2013-08-22 16:43:04 +00:00
|
|
|
#else
|
|
|
|
# err "${portref}Python module without" \
|
|
|
|
# "optimized version: $py"
|
|
|
|
fi
|
2013-08-22 22:37:17 +00:00
|
|
|
done; fi
|
2013-10-13 16:54:24 +00:00
|
|
|
|
|
|
|
# allowed behaviour
|
|
|
|
#while (($ic < ${#pyc_files[@]})); do
|
|
|
|
# err "${portref}compiled Python module without source," \
|
|
|
|
# "expected: ${pyc_files[$ic]%c}"
|
|
|
|
# ((++ic))
|
|
|
|
#done
|
|
|
|
|
|
|
|
# allowed behaviour
|
|
|
|
#while (($io < ${#pyo_files[@]})); do
|
|
|
|
# err "${portref}optimized Python module without source," \
|
|
|
|
# "expected: ${pyo_files[$io]%o}"
|
|
|
|
# ((++io))
|
|
|
|
#done
|
2014-05-06 11:00:55 +00:00
|
|
|
|
|
|
|
$wrong_man && err "${portref}manual pages should go under" \
|
|
|
|
"\${PREFIX}/man/ rather than under \${PREFIX}/share/man/"
|
|
|
|
$wrong_info && err "${portref}info pages should go under" \
|
|
|
|
"\${PREFIX}/info/ rather than under \${PREFIX}/share/info/"
|
2013-08-21 17:00:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# Checks made:
|
|
|
|
# * devel/gettext and converters/libiconv MODULES are not forgotten.
|
2014-11-13 15:35:50 +00:00
|
|
|
# * lib/kde/ and lib/kde4/ prefixes not missing where applicable.
|
2014-07-10 09:57:13 +00:00
|
|
|
# * stdc++ doesn't get into WANTLIB when gcc4.port.mk is used.
|
2013-08-21 17:00:24 +00:00
|
|
|
check_wantlib() {
|
|
|
|
local portref="$1"; shift
|
|
|
|
local modules="$1"; shift
|
|
|
|
|
|
|
|
local iconv_wantlib=false
|
|
|
|
local intl_wantlib=false
|
2013-12-10 19:08:49 +00:00
|
|
|
local phonon_s_wantlib=false
|
|
|
|
|
2013-08-21 17:00:24 +00:00
|
|
|
local gettext_module=false
|
|
|
|
local iconv_module=false
|
2013-08-21 19:49:32 +00:00
|
|
|
local kde3_module=false
|
|
|
|
local kde4_module=false
|
2013-12-10 19:08:49 +00:00
|
|
|
local phonon_module=false
|
2014-07-10 09:57:13 +00:00
|
|
|
local gcc4_module=false
|
2013-12-10 19:08:49 +00:00
|
|
|
|
2013-08-21 17:00:24 +00:00
|
|
|
local v
|
|
|
|
|
|
|
|
for v in $modules; do case $v in
|
|
|
|
converters/libiconv) iconv_module=true;;
|
2014-07-10 09:57:13 +00:00
|
|
|
devel/gettext) gettext_module=true;;
|
|
|
|
gcc4) gcc4_module=true;;
|
2013-12-10 19:08:49 +00:00
|
|
|
multimedia/phonon) phonon_module=true;;
|
2013-08-21 19:49:32 +00:00
|
|
|
x11/kde) kde3_module=true;;
|
|
|
|
x11/kde4) kde4_module=true;;
|
2013-08-21 17:00:24 +00:00
|
|
|
esac; done
|
|
|
|
|
|
|
|
for v; do case $v in
|
2013-08-21 19:49:32 +00:00
|
|
|
iconv?(?(">")=+([0-9])))
|
|
|
|
iconv_wantlib=true
|
|
|
|
;;
|
|
|
|
|
|
|
|
intl?(?(">")=+([0-9])))
|
|
|
|
intl_wantlib=true
|
|
|
|
;;
|
|
|
|
|
2013-12-10 19:08:49 +00:00
|
|
|
phonon_s?(?(">")=+([0-9])))
|
|
|
|
phonon_s_wantlib=true
|
|
|
|
;;
|
|
|
|
|
2013-12-29 16:59:06 +00:00
|
|
|
@(smbclient|wbclient)?(?('>')=+([0-9])))
|
|
|
|
err "$portref$v instead of lib/samba/$v" \
|
|
|
|
"in WANTLIB"
|
|
|
|
;;
|
|
|
|
|
2014-01-13 11:47:31 +00:00
|
|
|
@(DCOP|soundserver_idl|vcard)?(?('>')=+([0-9])))
|
2013-08-21 23:46:00 +00:00
|
|
|
err "$portref$v instead of \${KDE}/$v" \
|
|
|
|
"in WANTLIB (check other libs, too!)"
|
2013-08-21 19:49:32 +00:00
|
|
|
;;
|
|
|
|
|
2014-01-26 01:06:40 +00:00
|
|
|
@(kdecore|kdeui|kio)?(?('>')=+([0-9])))
|
2013-08-21 19:49:32 +00:00
|
|
|
if $kde4_module; then
|
|
|
|
err "$portref$v instead of \${KDE4LIB}/$v" \
|
2013-08-21 23:46:00 +00:00
|
|
|
"in WANTLIB (check other libs, too!)"
|
2013-08-21 19:49:32 +00:00
|
|
|
elif $kde3_module; then
|
|
|
|
err "$portref$v instead of \${KDE}/$v" \
|
2013-08-21 23:46:00 +00:00
|
|
|
"in WANTLIB (check other libs, too!)"
|
2013-08-21 19:49:32 +00:00
|
|
|
else
|
|
|
|
err "$portref$v WANTLIB without x11/kde*" \
|
2013-08-21 23:46:00 +00:00
|
|
|
"in MODULES (check other libs, too!)"
|
2013-08-21 19:49:32 +00:00
|
|
|
fi
|
|
|
|
;;
|
2014-07-10 09:57:13 +00:00
|
|
|
stdc++?(?('>')=+([0-9])))
|
|
|
|
if $gcc4_module; then
|
|
|
|
err "$portref$v in WANTLIB when gcc4 is" \
|
|
|
|
"in MODULES; run port-lib-depends-check" \
|
|
|
|
"and if stdc++ is still there, check" \
|
|
|
|
"actual build thoroughly, it's broken"
|
|
|
|
fi
|
2013-08-21 17:00:24 +00:00
|
|
|
esac; done
|
|
|
|
|
|
|
|
if $intl_wantlib && ! $gettext_module; then
|
|
|
|
err "${portref}missing devel/gettext in MODULES"
|
|
|
|
elif $iconv_wantlib && ! $gettext_module && ! $iconv_module; then
|
|
|
|
err "${portref}missing converters/libiconv in MODULES"
|
|
|
|
fi
|
|
|
|
|
2013-12-10 19:08:49 +00:00
|
|
|
if $phonon_s_wantlib && ! $phonon_module; then
|
|
|
|
err "${portref}missing multimedia/phonon in MODULES"
|
|
|
|
fi
|
|
|
|
|
2014-08-10 20:46:04 +00:00
|
|
|
true
|
2013-08-21 17:00:24 +00:00
|
|
|
}
|
|
|
|
|
2014-08-10 20:39:03 +00:00
|
|
|
# Checks made:
|
|
|
|
# * Each library mentioned in WANTLIB is accessible either:
|
|
|
|
# a) as a part of base system, in /usr/lib or /usr/X11R6/lib;
|
|
|
|
# b) via LIB_DEPENDS directly, or via deeper dependency of LIB_DEPENDS.
|
|
|
|
check_lib_depends() {
|
|
|
|
$debugging && echo "CALLED: check_lib_depends($*)" >&2
|
|
|
|
|
|
|
|
local portref="$1"; shift
|
|
|
|
local subpkg="$1"; shift
|
|
|
|
local modules="$1"; shift
|
|
|
|
local wantlib="$1"; shift
|
|
|
|
|
|
|
|
# The idea as follows: build full list of run-time dependencies, but
|
|
|
|
# without RUN_DEPENDS begin involved.
|
|
|
|
#
|
|
|
|
# Then we look at libs in each pkgpath we got, and strip those
|
|
|
|
# from WANTLIB. We also strip system libraries from /usr/lib
|
|
|
|
# and /usr/X11R6/lib. And all WANTLIBs coming from MODULES are stripped
|
|
|
|
# too, supposing that authors of those MODULES know what they're doing
|
|
|
|
# (without stripping 'em, we'll get many false positives).
|
|
|
|
#
|
|
|
|
# If there are any non-stripped items in WANTLIB, we found a problem.
|
|
|
|
#
|
|
|
|
# XXX those checks do not take actual versions into account!
|
|
|
|
|
|
|
|
# get list of all WANTLIBs coming from MODULES
|
|
|
|
local m modvars=
|
|
|
|
for m in $modules; do
|
|
|
|
m=${m##*/}
|
|
|
|
case $m in
|
|
|
|
python)
|
|
|
|
m=py
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
m=$(echo "MOD${m}_WANTLIB" | tr a-z A-Z)
|
|
|
|
modvars="$modvars $m"
|
|
|
|
done
|
|
|
|
local l modlibs=
|
|
|
|
make "${make_args[@]}" show="$modvars" </dev/null |&
|
|
|
|
while read -pr l; do
|
|
|
|
modlibs="$modlibs $l"
|
|
|
|
done
|
|
|
|
wait # make sure process exited before possible return below
|
|
|
|
|
|
|
|
# strip WANTLIBs coming from MODULES
|
|
|
|
local libsleft wl
|
|
|
|
for l in $modlibs; do
|
|
|
|
libsleft=
|
|
|
|
for wl in $wantlib; do
|
|
|
|
if [[ $l != "$wl" ]]; then
|
|
|
|
libsleft="$libsleft $wl"
|
|
|
|
elif $debugging; then
|
|
|
|
echo "WANTLIB ITEM $wl COMES FROM MODULES"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
[[ -n $libsleft ]] || return 0 # all libs found
|
|
|
|
wantlib=$libsleft
|
|
|
|
done
|
|
|
|
|
|
|
|
# prepare easy-to-use WANTLIB list in $checklibs
|
|
|
|
local wlprefix checklibs=
|
|
|
|
for wl in $wantlib; do
|
|
|
|
wl=${wl%%[><=]*}
|
|
|
|
wlprefix=${wl%/*}
|
|
|
|
[[ $wlprefix == "$wl" ]] && wlprefix=lib
|
|
|
|
wl=${wl##*/}
|
|
|
|
checklibs="$checklibs ${wlprefix}/lib$wl"
|
|
|
|
done
|
|
|
|
|
|
|
|
# strip system libraries
|
|
|
|
local d
|
|
|
|
for d in /usr /usr/X11R6; do
|
|
|
|
for l in $d/lib/lib*.@(so*(.+([0-9]))|a); do
|
|
|
|
libsleft=
|
|
|
|
for wl in $checklibs; do
|
|
|
|
if [[ $l != +(/*)/${wl}.@(so*(.+([0-9]))|a) ]]; then
|
|
|
|
libsleft="$libsleft $wl"
|
|
|
|
elif $debugging; then
|
|
|
|
echo "FOUND WANTLIB ITEM $wl: $l"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
[[ -n $libsleft ]] || return 0 # all libs found
|
|
|
|
checklibs=$libsleft
|
|
|
|
done
|
|
|
|
done
|
|
|
|
|
|
|
|
# get deep list of LDEPs
|
|
|
|
# XXX won't work on ${NO_SHARED_ARCHS}, anybody cares?
|
|
|
|
local lmake_args="${make_args[@]}"
|
|
|
|
lmake_args[${#lmake_args[@]}]="RUN_DEPENDS="
|
|
|
|
lmake_args[${#lmake_args[@]}]="RUN_DEPENDS$subpkg="
|
|
|
|
# Rely on the fact we're already in the port directory, see sub_checks().
|
|
|
|
# XXX ignoring make errors for now
|
|
|
|
local pure_lib_deps=$(make "${lmake_args[@]}" show-run-depends | sort)
|
|
|
|
[[ -n $pure_lib_deps ]] || return 0
|
|
|
|
# SUBDIR doesn't accept newline-separated values
|
|
|
|
set -A pure_lib_deps -- $pure_lib_deps
|
|
|
|
|
|
|
|
(
|
|
|
|
# strip libraries from ports
|
|
|
|
# TODO cache print-plist-libs output?
|
|
|
|
cd -- /usr/ports # XXX "$portsdir" fails for openbsd-wip and like
|
|
|
|
unset FLAVOR SUBPACKAGE
|
|
|
|
make "${make_args[@]}" SUBDIR="${pure_lib_deps[*]}" \
|
|
|
|
print-plist-libs </dev/null 2>/dev/null |&
|
|
|
|
while read -pr l; do
|
|
|
|
case $l in
|
|
|
|
"===> "*)
|
|
|
|
;;
|
|
|
|
|
|
|
|
*)
|
|
|
|
libsleft=
|
|
|
|
for wl in $checklibs; do
|
|
|
|
if [[ $l != +(/*)/${wl}.@(so*(.+([0-9]))|a) ]]; then
|
|
|
|
libsleft="$libsleft $wl"
|
|
|
|
elif $debugging; then
|
|
|
|
echo "FOUND WANTLIB ITEM $wl: $l"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
[[ -n $libsleft ]] || exit 0 # all libs found
|
|
|
|
checklibs=$libsleft
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
# prettify list of WANTLIBs left and print it
|
|
|
|
libsleft=
|
|
|
|
for wl in $checklibs; do
|
|
|
|
libsleft="$libsleft ${wl##*/lib}"
|
|
|
|
done
|
|
|
|
err "${portref}the following libraries in WANTLIB${subpkg%-}" \
|
|
|
|
"look like masked by RUN_DEPENDS${subpkg%-}:$libsleft"
|
|
|
|
wait
|
|
|
|
! $error
|
|
|
|
) || error=true
|
|
|
|
}
|
|
|
|
|
2014-04-27 17:57:14 +00:00
|
|
|
# Checks made:
|
|
|
|
# * No extra PERMIT_DISTFILES_FTP variables in Makefile.
|
|
|
|
# * PERMIT_DISTFILES_FTP should not contain just "No" but a reason.
|
|
|
|
#
|
|
|
|
# Runs in the port directory.
|
|
|
|
# XXX does not handle Makefile.inc and other .include cases correctly.
|
|
|
|
check_permit_dist() {
|
|
|
|
$debugging && echo "CALLED: check_permit_dist($*)" >&2
|
|
|
|
|
|
|
|
local portref=$(portref $1); shift
|
|
|
|
local perm_pkg_cdrom=$(echo "$1" | tr '[:upper:]' '[:lower:]')
|
|
|
|
local perm_pkg_ftp=$(echo "$2" | tr '[:upper:]' '[:lower:]')
|
|
|
|
local perm_dist_ftp=$(echo "$3" | tr '[:upper:]' '[:lower:]')
|
|
|
|
|
|
|
|
if [[ ($perm_pkg_cdrom == yes || $perm_pkg_ftp == yes) && \
|
|
|
|
$perm_dist_ftp == yes ]]; then
|
|
|
|
egrep -q "^ *PERMIT_DISTFILES_FTP[[:space:]]*=" Makefile &&
|
|
|
|
err "${portref}extra PERMIT_DISTFILES_FTP line(-s)"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ $perm_dist_ftp == no ]]; then
|
|
|
|
err "${portref}PERMIT_DISTFILES_FTP should be either" \
|
|
|
|
"\"Yes\" or a reason for being non-redistributable"
|
|
|
|
fi
|
|
|
|
|
|
|
|
true
|
|
|
|
}
|
|
|
|
|
|
|
|
# Checks made:
|
|
|
|
# * No extra PERMIT_PACKAGE_FTP variables in Makefile.
|
|
|
|
# * PERMIT_PACKAGE_* should not contain just "No" but a reason.
|
|
|
|
#
|
|
|
|
# Runs in the port directory.
|
|
|
|
# XXX does not handle Makefile.inc and other .include cases correctly.
|
|
|
|
check_permit_subpkg() {
|
|
|
|
$debugging && echo "CALLED: check_permit_subpkg($*)" >&2
|
|
|
|
|
|
|
|
local portref=$1; shift
|
|
|
|
local subpkg=${1%-}; shift
|
|
|
|
local perm_pkg_cdrom=$(echo "$1" | tr '[:upper:]' '[:lower:]')
|
|
|
|
local perm_pkg_ftp=$(echo "$2" | tr '[:upper:]' '[:lower:]')
|
|
|
|
|
|
|
|
if [[ $perm_pkg_cdrom == yes && $perm_pkg_ftp == yes ]]; then
|
|
|
|
egrep -q "^ *PERMIT_PACKAGE_FTP${subpkg}[[:space:]]*=" Makefile &&
|
|
|
|
err "${portref}extra PERMIT_PACKAGE_FTP lines"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ $perm_pkg_cdrom == no ]]; then
|
|
|
|
err "${portref} PERMIT_PACKAGE_CDROM should be either" \
|
|
|
|
"\"Yes\" or a reason for being non-redistributable"
|
|
|
|
fi
|
|
|
|
if [[ $perm_pkg_ftp == no ]]; then
|
|
|
|
err "${portref} PERMIT_PACKAGE_FTP should be either" \
|
|
|
|
"\"Yes\" or a reason for being non-redistributable"
|
|
|
|
fi
|
|
|
|
|
|
|
|
true
|
|
|
|
}
|
|
|
|
|
2013-08-21 17:00:24 +00:00
|
|
|
# Checks made:
|
|
|
|
# * Directory is not empty
|
|
|
|
# * No '*.core' files present
|
|
|
|
check_files_dir() {
|
|
|
|
$debugging && echo "CALLED: check_files_dir($*)" >&2
|
|
|
|
|
|
|
|
find -f "$1" -- -type f | {
|
|
|
|
local empty=true
|
2013-08-27 07:52:15 +00:00
|
|
|
local mode
|
2013-08-21 17:00:24 +00:00
|
|
|
while read F; do
|
|
|
|
ignoring "$F" && continue
|
2013-08-27 07:52:15 +00:00
|
|
|
mode=$(stat -f %p "$F" || true)
|
|
|
|
(( (0$mode & 0111) != 0 )) &&
|
|
|
|
err "executable file: $F"
|
2013-08-21 17:00:24 +00:00
|
|
|
empty=false
|
2013-08-22 20:43:10 +00:00
|
|
|
[[ $F == *.core ]] &&
|
|
|
|
err_coredump_found "$F"
|
2013-08-21 17:00:24 +00:00
|
|
|
done
|
2014-07-23 22:12:41 +00:00
|
|
|
$empty && err "there are no files, please remove the $1 directory"
|
2013-08-21 17:00:24 +00:00
|
|
|
! $error
|
|
|
|
} || error=true
|
|
|
|
}
|
|
|
|
|
|
|
|
# Checks made:
|
2013-08-21 21:02:16 +00:00
|
|
|
# * Each patch contains OpenBSD RCS tag.
|
2013-08-21 17:00:24 +00:00
|
|
|
# * Directory is not empty and consists only of plain files starting
|
|
|
|
# with 'patch-' and not ending with '.orig'.
|
|
|
|
check_patches_dir() {
|
|
|
|
$debugging && echo "CALLED: check_patches_dir($*)" >&2
|
|
|
|
|
|
|
|
local empty=true
|
|
|
|
local F
|
|
|
|
|
2013-08-27 07:52:15 +00:00
|
|
|
check_perms_in_dir "$1"
|
|
|
|
|
2013-08-21 17:00:24 +00:00
|
|
|
for F in "$1"/* "$1"/.*; do case "${F##*/}" in
|
|
|
|
patch-*.orig)
|
|
|
|
handle_extra_file "$F"
|
|
|
|
;;
|
|
|
|
|
|
|
|
patch-*)
|
|
|
|
empty=false
|
|
|
|
test -f "$F" ||
|
|
|
|
err "$F is not a file"
|
|
|
|
$rootrun || head -n 1 -- "$F" | egrep -q '^\$OpenBSD.*\$$' ||
|
|
|
|
err "$F does not have \$OpenBSD\$ RCS tag at the top"
|
|
|
|
;;
|
|
|
|
|
|
|
|
*)
|
|
|
|
handle_extra_file "$F"
|
|
|
|
;;
|
|
|
|
esac; done
|
|
|
|
|
|
|
|
$empty && err "there are no patches, please remove the $1 directory instead"
|
|
|
|
}
|
|
|
|
|
|
|
|
# Checks made:
|
|
|
|
# * Directory is not empty and consist only of plain files with fixed names.
|
2013-11-07 08:18:16 +00:00
|
|
|
# * PFRAG, PLIST, README and .rc files contain appropriate OpenBSD RCS
|
|
|
|
# tags; other files should NOT contain OpenBSD RCS tag.
|
2013-08-21 17:00:24 +00:00
|
|
|
# * PFRAG.shared should be merged in PLIST if it contains @lib items only.
|
2013-11-07 08:18:16 +00:00
|
|
|
# * No trailing whitespace for DESCR, MESSAGE, README, UNMESSAGE and
|
|
|
|
# .rc files (PLIST and PFRAG are better checked with "make package").
|
2013-08-21 21:02:16 +00:00
|
|
|
# * See also check_plist_file().
|
2013-08-21 17:00:24 +00:00
|
|
|
check_pkg_dir() {
|
|
|
|
$debugging && echo "CALLED: check_pkg_dir($*)" >&2
|
|
|
|
|
2013-08-21 21:53:29 +00:00
|
|
|
local dir=$1; shift
|
2013-08-22 09:44:17 +00:00
|
|
|
local subst_cmd
|
|
|
|
if (($# > 0)); then
|
|
|
|
# XXX should find the way to always obtain SUBST_CMD
|
|
|
|
subst_cmd=$1
|
|
|
|
shift
|
|
|
|
fi
|
2013-08-21 17:00:24 +00:00
|
|
|
local empty=true
|
|
|
|
local F
|
|
|
|
|
2013-08-27 07:52:15 +00:00
|
|
|
check_perms_in_dir "$dir"
|
|
|
|
|
2014-02-04 21:28:30 +00:00
|
|
|
dir="${dir#./}"
|
2013-08-21 21:53:29 +00:00
|
|
|
for F in "$dir"/* "$dir"/.*; do case "${F##*/}" in
|
2013-08-21 17:00:24 +00:00
|
|
|
DESCR?(-*))
|
|
|
|
empty=false
|
|
|
|
[[ -f $F ]] ||
|
|
|
|
err "$F is not a file"
|
|
|
|
check_trailing_whitespace "$F"
|
2013-10-13 16:47:18 +00:00
|
|
|
check_newline_at_eof "$F"
|
2014-02-03 22:13:55 +00:00
|
|
|
check_long_lines "$F"
|
2014-01-11 16:42:01 +00:00
|
|
|
check_hardcoded "$F"
|
2013-08-22 09:44:17 +00:00
|
|
|
[[ -n $subst_cmd ]] && check_subst_vars "$F" "$subst_cmd"
|
2013-08-21 21:02:16 +00:00
|
|
|
egrep -q '\$OpenBSD.*\$' "$F" &&
|
2013-08-21 17:00:24 +00:00
|
|
|
err "$F should not contain \$OpenBSD\$ tag"
|
|
|
|
;;
|
|
|
|
|
|
|
|
PFRAG.shared?(-*))
|
|
|
|
empty=false
|
2013-08-22 09:44:17 +00:00
|
|
|
[[ -n $subst_cmd ]] && check_subst_vars "$F" "$subst_cmd"
|
2013-08-21 21:02:16 +00:00
|
|
|
check_plist_file "$F"
|
2013-08-21 17:00:24 +00:00
|
|
|
awk <"$F" '/^(@comment )?@lib /' | {
|
|
|
|
local no_a_for_so=false plist=${F##*/} shlibs_found=false
|
|
|
|
plist=PLIST${plist##PFRAG.+([!-])}
|
|
|
|
while read l; do
|
|
|
|
shlibs_found=true
|
|
|
|
l=${l##"@comment "}
|
|
|
|
l=${l##"@lib "}
|
|
|
|
l=${l%%.so.*}.a
|
|
|
|
fgrep -q -- "$l" "${F%/*}/$plist" || no_a_for_so=true
|
|
|
|
done
|
|
|
|
$shlibs_found && ! $no_a_for_so &&
|
|
|
|
err "$F should be merged in $plist"
|
2013-08-22 10:41:20 +00:00
|
|
|
! $error
|
|
|
|
} || error=true
|
2013-08-21 17:00:24 +00:00
|
|
|
;;
|
|
|
|
|
|
|
|
PFRAG.*|PLIST?(-*))
|
|
|
|
empty=false
|
2013-08-22 09:44:17 +00:00
|
|
|
[[ -n $subst_cmd ]] && check_subst_vars "$F" "$subst_cmd"
|
2013-08-21 21:02:16 +00:00
|
|
|
check_plist_file "$F"
|
2013-08-21 17:00:24 +00:00
|
|
|
;;
|
|
|
|
|
2013-11-07 08:18:16 +00:00
|
|
|
README?(-*))
|
2013-08-21 17:00:24 +00:00
|
|
|
[[ -f $F ]] ||
|
|
|
|
err "$F is not a file"
|
2013-08-22 09:44:17 +00:00
|
|
|
[[ -n $subst_cmd ]] && check_subst_vars "$F" "$subst_cmd"
|
2013-08-21 17:00:24 +00:00
|
|
|
check_trailing_whitespace "$F"
|
2013-10-13 16:47:18 +00:00
|
|
|
check_newline_at_eof "$F"
|
2014-02-03 22:13:55 +00:00
|
|
|
check_long_lines "$F"
|
2014-01-11 16:42:01 +00:00
|
|
|
check_hardcoded "$F"
|
2013-08-21 17:00:24 +00:00
|
|
|
head -n 1 -- "$F" |
|
2013-08-21 21:02:16 +00:00
|
|
|
egrep -q '^(#[[:space:]]*)?\$OpenBSD(:.*)?\$$' ||
|
2013-08-21 17:00:24 +00:00
|
|
|
err "$F does not have \$OpenBSD\$ RCS tag at the top"
|
|
|
|
;;
|
|
|
|
|
|
|
|
*.rc)
|
|
|
|
[[ -f $F ]] ||
|
|
|
|
err "$F is not a file"
|
2014-01-25 10:08:00 +00:00
|
|
|
[[ ${F##*/} == [A-Za-z_]*([A-Za-z0-9_]).rc ]] ||
|
|
|
|
err "$F name will not work in rc.subr(8)"
|
2013-08-21 17:00:24 +00:00
|
|
|
check_trailing_whitespace "$F"
|
2014-02-03 22:13:55 +00:00
|
|
|
check_long_lines "$F"
|
2014-01-11 16:42:01 +00:00
|
|
|
check_hardcoded "$F"
|
2013-08-21 17:00:24 +00:00
|
|
|
head -n 5 -- "$F" |
|
2013-08-21 21:02:16 +00:00
|
|
|
egrep -q '^#[[:space:]]*\$OpenBSD(:.*)?\$$' ||
|
2013-08-21 17:00:24 +00:00
|
|
|
err "$F does not have \$OpenBSD\$ RCS tag at the top"
|
|
|
|
;;
|
|
|
|
|
|
|
|
MESSAGE?(-*)|UNMESSAGE?(-*))
|
|
|
|
[[ -f $F ]] ||
|
|
|
|
err "$F is not a file"
|
2013-08-22 09:44:17 +00:00
|
|
|
[[ -n $subst_cmd ]] && check_subst_vars "$F" "$subst_cmd"
|
2013-08-21 17:00:24 +00:00
|
|
|
check_trailing_whitespace "$F"
|
2013-10-13 16:47:18 +00:00
|
|
|
check_newline_at_eof "$F"
|
2014-02-03 22:13:55 +00:00
|
|
|
check_long_lines "$F"
|
2014-01-11 16:42:01 +00:00
|
|
|
check_hardcoded "$F"
|
2013-08-21 21:02:16 +00:00
|
|
|
egrep -q '\$OpenBSD.*\$' "$F" &&
|
2013-08-21 17:00:24 +00:00
|
|
|
err "$F should not contain \$OpenBSD\$ tag"
|
|
|
|
;;
|
|
|
|
|
|
|
|
*)
|
|
|
|
handle_extra_file "$F"
|
|
|
|
;;
|
|
|
|
esac; done
|
|
|
|
|
2013-08-22 10:43:15 +00:00
|
|
|
$empty && err "$dir directory does not contain either DESCR, PFRAG or PLIST files"
|
2013-08-21 17:00:24 +00:00
|
|
|
}
|
|
|
|
|
2014-01-11 16:42:01 +00:00
|
|
|
# Checks made:
|
2014-02-09 17:24:48 +00:00
|
|
|
# * There are no hardcoded /usr/local or /var paths in file.
|
2014-04-19 17:20:37 +00:00
|
|
|
# /var/log, /var/run and /var/tmp are perfectly fine, though.
|
2014-01-11 16:42:01 +00:00
|
|
|
check_hardcoded() {
|
|
|
|
$debugging && echo "CALLED: check_hardcoded($*)" >&2
|
|
|
|
|
2014-08-12 00:30:35 +00:00
|
|
|
perl -n -e 'BEGIN { $ec=0; }
|
|
|
|
if (m,/usr/local\b,o) { $ec=1; close ARGV; }
|
2014-04-19 17:20:37 +00:00
|
|
|
if (m,/var((?:/+[^/\s]+)*)(?:\s.*)?$,o) {
|
|
|
|
unless ($1 =~ m,^/+(?:log|run|tmp),o) {
|
2014-08-12 00:30:35 +00:00
|
|
|
$ec=1; close ARGV;
|
2014-04-19 17:20:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
END { $? = $ec; }' \
|
2014-08-12 00:30:35 +00:00
|
|
|
"$1" || err "hardcoded paths detected in $1, consider using" \
|
2014-04-19 17:20:37 +00:00
|
|
|
"SUBST_VARS and TRUEPREFIX/LOCALBASE/LOCALSTATEDIR/VARBASE"
|
2014-01-11 16:42:01 +00:00
|
|
|
}
|
|
|
|
|
2013-11-01 10:43:40 +00:00
|
|
|
# Checks made:
|
2014-02-03 22:13:55 +00:00
|
|
|
# * There are no lines longer than 80 characters that have at least
|
|
|
|
# one space (avoids warnings on long URLs etc.).
|
2013-11-01 10:43:40 +00:00
|
|
|
check_long_lines() {
|
|
|
|
$debugging && echo "CALLED: check_long_lines($*)" >&2
|
|
|
|
local file=$1; shift
|
|
|
|
|
2014-02-03 22:13:55 +00:00
|
|
|
local n=$(awk <"$file" \
|
|
|
|
'/[[:space:]]/ && length > 80 { n++ } END { print n+0 }')
|
2013-11-09 23:27:30 +00:00
|
|
|
(($n > 0 )) &&
|
2014-02-03 22:13:55 +00:00
|
|
|
err "$n line(s) longer than 80 chars in $file"
|
2013-11-01 10:43:40 +00:00
|
|
|
}
|
|
|
|
|
2013-08-21 17:00:24 +00:00
|
|
|
# Checks made:
|
2013-08-21 21:02:16 +00:00
|
|
|
# * There is an OpenBSD RCS tag at the top.
|
|
|
|
# * No items with ${FULLPKGNAME} are allowed, except readme.
|
2014-02-09 19:26:25 +00:00
|
|
|
# * No empty lines.
|
2013-08-21 21:02:16 +00:00
|
|
|
check_plist_file() {
|
2013-08-22 09:44:17 +00:00
|
|
|
$debugging && echo "CALLED: check_plist_file($*)" >&2
|
|
|
|
|
2013-08-21 21:02:16 +00:00
|
|
|
[[ -f $1 ]] ||
|
|
|
|
err "$1 is not a file"
|
|
|
|
head -n 1 -- "$1" |
|
|
|
|
egrep -q '^@comment \$OpenBSD.*\$$' ||
|
|
|
|
err "$1 does not have \$OpenBSD\$ RCS tag at the top"
|
2013-08-22 00:30:17 +00:00
|
|
|
|
|
|
|
# Do not match just '${FULLPKGNAME}' because many ports use the
|
|
|
|
# following trick:
|
|
|
|
# @cwd ${LOCALBASE}/share/doc/pkg-readmes
|
|
|
|
# ${FULLPKGNAME}
|
2013-08-22 09:44:17 +00:00
|
|
|
egrep -v '^(share/doc/pkg-readmes/\$\{FULLPKGNAME\}|@comment .*)$' "$1" |
|
2013-08-22 00:30:17 +00:00
|
|
|
egrep '.\$\{FULLPKGNAME\}|\$\{FULLPKGNAME\}.' >&2 &&
|
2013-11-10 14:56:41 +00:00
|
|
|
err "$1 contains item(s) with \${FULLPKGNAME} in it, see above"
|
2014-02-09 19:26:25 +00:00
|
|
|
|
|
|
|
egrep -q '^[[:space:]]*$' "$1" && err "$1 contains empty lines"
|
2013-08-21 21:02:16 +00:00
|
|
|
}
|
|
|
|
|
2013-08-21 21:53:29 +00:00
|
|
|
# Checks made:
|
|
|
|
# * Every variable referenced by ${[A-Z]+} should be in ${SUBST_VARS}.
|
|
|
|
check_subst_vars() {
|
2013-08-22 09:44:17 +00:00
|
|
|
$debugging && echo "CALLED: check_subst_vars($*)" >&2
|
|
|
|
|
2013-08-21 21:53:29 +00:00
|
|
|
local F=$1; shift
|
|
|
|
local subst_cmd=$1; shift
|
|
|
|
|
2013-08-22 14:08:12 +00:00
|
|
|
# Add variables sometimes referenced in port docs.
|
|
|
|
eval "$subst_cmd" -DPATH=test -DWRKSRC=test <"$F" |
|
|
|
|
egrep '\$\{[A-Z]+\}' >&2 &&
|
2013-08-21 21:53:29 +00:00
|
|
|
err "looks like misspelled variables in $F, see above"
|
|
|
|
}
|
|
|
|
|
2013-08-21 21:02:16 +00:00
|
|
|
# Checks made:
|
|
|
|
# * Contains OpenBSD RCS tag at the top line.
|
2013-08-21 17:00:24 +00:00
|
|
|
# * No REVISION marks present in given file (unless in update mode).
|
2013-12-21 08:59:30 +00:00
|
|
|
# * Each REVISION mark presents only once.
|
2014-04-27 17:57:14 +00:00
|
|
|
# * BUILD_DEPENDS, MODULES and PERMIT_DISTFILES_FTP are not defined in
|
|
|
|
# VAR-subpkg manner.
|
2013-08-21 17:00:24 +00:00
|
|
|
# * No trailing whitespace.
|
2013-12-21 11:47:20 +00:00
|
|
|
# * SHARED_LIBS are not defined inside ".if" statements.
|
2013-12-28 22:29:50 +00:00
|
|
|
# * Variables are not assigned via "=" twice outside of .if statemets.
|
2013-08-21 17:00:24 +00:00
|
|
|
check_makefile() {
|
|
|
|
$debugging && echo "CALLED: check_makefile($*)" >&2
|
|
|
|
|
2013-12-21 08:59:30 +00:00
|
|
|
local F="$1"
|
|
|
|
check_trailing_whitespace "$F"
|
2014-02-03 22:13:55 +00:00
|
|
|
check_long_lines "$F"
|
2014-05-08 07:02:33 +00:00
|
|
|
check_hardcoded "$F"
|
2013-12-21 08:59:30 +00:00
|
|
|
head -n 1 -- "$F" |
|
2013-08-21 21:02:16 +00:00
|
|
|
egrep -q '^#[[:space:]]*\$OpenBSD.*\$' ||
|
2013-08-21 17:00:24 +00:00
|
|
|
err "$F does not have \$OpenBSD\$ RCS tag at the top"
|
|
|
|
|
2014-02-09 15:44:20 +00:00
|
|
|
local iflevel=0 l lnum=0 revs= t r mkvars= var duprevfound
|
2013-12-28 22:29:50 +00:00
|
|
|
# do not unset mkvars, having empty element(-s) is fine
|
2013-12-21 08:59:30 +00:00
|
|
|
unset revs[0]
|
2013-12-21 11:47:20 +00:00
|
|
|
local tab="$(print '\t')"
|
2014-05-07 21:57:00 +00:00
|
|
|
while IFS= read -r l; do ((++lnum))
|
2013-12-21 08:59:30 +00:00
|
|
|
set -A t -- $l
|
2014-02-09 15:44:20 +00:00
|
|
|
duprevfound=false
|
2013-12-28 22:29:50 +00:00
|
|
|
|
|
|
|
case $l in
|
|
|
|
*(" ")REVISION*)
|
|
|
|
$existing_port ||
|
|
|
|
err "REVISION mark found at $F:$lnum"
|
|
|
|
var=${t[0]%=}
|
|
|
|
if ((${#revs[@]} > 0)); then
|
|
|
|
for r in "${revs[@]}"; do
|
|
|
|
if [[ $var == "$r" ]]; then
|
|
|
|
err "duplicated $r in $F"
|
|
|
|
# avoid dup error messages
|
2014-02-09 15:44:20 +00:00
|
|
|
duprevfound=true
|
2013-12-28 22:29:50 +00:00
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
revs[${#revs[@]}]=${t[0]}
|
|
|
|
;;
|
2014-04-27 17:57:14 +00:00
|
|
|
*(" ")@(BUILD_DEPENDS|MODULES|PERMIT_DISTFILES_FTP)-*)
|
2013-12-28 22:29:50 +00:00
|
|
|
err "${l%%-*} is not a subpackageble variable, see $F:$lnum"
|
|
|
|
;;
|
|
|
|
*(" ").*(" "|"$tab")if*)
|
|
|
|
((++iflevel))
|
|
|
|
;;
|
|
|
|
*(" ").*(" "|"$tab")endif*)
|
|
|
|
((iflevel--))
|
|
|
|
;;
|
|
|
|
*(" ")SHARED_LIBS*(" "|"$tab")*(+|:|!)=*)
|
|
|
|
if ((iflevel > 0)); then
|
|
|
|
err "should not be inside .if block ($F:$lnum): $l"
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2013-12-30 12:29:25 +00:00
|
|
|
if [[ $l == *(" ")+([A-Za-z0-9_-])*(" "|"$tab")?(\?)=* ]] &&
|
2014-02-09 15:44:20 +00:00
|
|
|
((iflevel == 0)) && ! $duprevfound; then
|
2014-02-09 16:09:55 +00:00
|
|
|
var=${t[0]%?(\?)=*}
|
2013-12-28 22:29:50 +00:00
|
|
|
for v in "${mkvars[@]}"; do
|
|
|
|
if [[ $v == "$var" ]]; then
|
|
|
|
err "duplicated assignment of $v" \
|
|
|
|
"at $F:$lnum"
|
2013-12-21 08:59:30 +00:00
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
2013-12-28 22:29:50 +00:00
|
|
|
mkvars[${#mkvars[@]}]=$var
|
2013-12-21 08:59:30 +00:00
|
|
|
fi
|
2013-12-28 22:29:50 +00:00
|
|
|
done <"$F"
|
2013-08-21 17:00:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# Checks made:
|
|
|
|
# * None of executable bits (111) are set on plain files.
|
|
|
|
check_perms_in_dir() {
|
|
|
|
$debugging && echo "CALLED: check_perms_in_dir($*)" >&2
|
|
|
|
|
2013-08-22 10:41:20 +00:00
|
|
|
(find -f "$1" -- -maxdepth 1 -type f \
|
|
|
|
\( -perm -100 -or -perm -010 -or -perm 001 \) \
|
|
|
|
</dev/null || true) |&
|
2013-08-22 21:16:04 +00:00
|
|
|
local F
|
2013-08-22 10:41:20 +00:00
|
|
|
while read -pr F; do
|
|
|
|
F=${F#./}
|
|
|
|
ignoring "$F" && continue
|
|
|
|
err "executable file: ${F#./}"
|
|
|
|
done
|
2013-08-21 17:00:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
############################################################
|
|
|
|
# Run checks. Also calculate and show pkgpath variable,
|
|
|
|
# unless we're checking the ports tree root dir.
|
|
|
|
#
|
|
|
|
|
|
|
|
for D; do
|
|
|
|
if [[ $D == /* ]]; then
|
|
|
|
err "absolute path $D ignored"
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
if [[ $D == *(*/)..*(/*) ]]; then
|
|
|
|
err "too many .. in $D, skipping"
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
check_port_dir "$D"
|
|
|
|
done
|
|
|
|
|
|
|
|
if ! $rootrun; then
|
|
|
|
[[ -z $pkgpath ]] && pkgpath=${PWD##"$portsdir/"}
|
|
|
|
|
|
|
|
if [[ $pkgpath == "$PWD" ]]; then
|
|
|
|
cat >&2 <<EOE
|
|
|
|
${0##*/}: could not determine PKGPATH. Please help me with the -p option.
|
|
|
|
EOE
|
|
|
|
exit 2
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "$pkgpath"
|
|
|
|
fi
|
|
|
|
|
|
|
|
! $error
|