prtcheck: initial commit
This commit is contained in:
parent
06789efe1b
commit
156a9452db
42
man1/prtcheck.1
Normal file
42
man1/prtcheck.1
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
.\"
|
||||||
|
.\" prtcheck manual page.
|
||||||
|
.\" (C) 2003 by Martin Opel <mo@obbl-net.de>
|
||||||
|
.\"
|
||||||
|
.TH prtcheck 1
|
||||||
|
.SH NAME
|
||||||
|
prtcheck \- check the port in the current directory
|
||||||
|
.SH SYNOPSIS
|
||||||
|
.PP
|
||||||
|
.B prtcheck
|
||||||
|
[ \-\-root ]
|
||||||
|
.SH DESCRIPTION
|
||||||
|
|
||||||
|
The \fIprtcheck\fP script checks the following things: existence of
|
||||||
|
Pkgfile, \.footprint, and \.signature. It warns, if any files with non-root
|
||||||
|
user/group appear in the \.footprint, or if any of the fields Description, URL,
|
||||||
|
Packager, "Depends on" were omitted from the Pkgfile, or if any source
|
||||||
|
needed for compiling and verifying the package is unsigned.
|
||||||
|
|
||||||
|
\fIprtcheck\fP returns with an exit status of -1 if it encounters serious
|
||||||
|
violations of port correctness, >0 if it only finds easily-fixed violations,
|
||||||
|
and 0 if all checks were passed.
|
||||||
|
|
||||||
|
.SH OPTIONS
|
||||||
|
The following option is supported:
|
||||||
|
.TP
|
||||||
|
.I "\--root"
|
||||||
|
This option is helpful if you create ports as a normal user. Even after
|
||||||
|
debugging those Makefiles or source code packages that try to install directly
|
||||||
|
in /usr/local or ignore DESTDIR variables, the .footprint might contain
|
||||||
|
uid/gid entries matching the uid/gid of the user who called \fIpkgmk\fP (since
|
||||||
|
\fIfakeroot\fP is no requirement in a basic CRUX installation).
|
||||||
|
\fIprtcheck\fP normally just issues a warning if it finds such uid/gid entries,
|
||||||
|
but passing the --root option lets you create a new footprint, replacing the invalid
|
||||||
|
uid/gid entries with root/root. Follow up with \fIprtverify(1)\fP to additionally
|
||||||
|
check that your port's footprint respects CRUX filesystem conventions.
|
||||||
|
|
||||||
|
.PP
|
||||||
|
.SH AUTHORS
|
||||||
|
|
||||||
|
\fIprtcheck\fP was written by Martin Opel <mo@obbl-net.de> for CRUX Linux,
|
||||||
|
revised by John McQuah <jmcquah@disroot.org> to address FS#1763.
|
121
scripts/prtcheck
Executable file
121
scripts/prtcheck
Executable file
@ -0,0 +1,121 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# $Id: prtcheck,v 1.1.1.1 2003/08/27 11:43:05 opel Exp $
|
||||||
|
# (c) 2003, Martin Opel <mo@obbl-net.de>
|
||||||
|
# revised 2022 by John McQuah <jmcquah@disroot.org> to address FS#1763
|
||||||
|
#
|
||||||
|
# Utility to check a port for existence of .signature, .footprint and
|
||||||
|
# the mandatory fields in Pkgfile. See "man 1 prtcheck" for details
|
||||||
|
#
|
||||||
|
# May be redistributed and modified under the terms of the GPL
|
||||||
|
# only usable with CRUX Linux, version 1.0 or higher
|
||||||
|
#
|
||||||
|
# USE AT YOUR OWN RISK
|
||||||
|
#
|
||||||
|
|
||||||
|
|
||||||
|
msg() {
|
||||||
|
echo -n -e "====> $1"
|
||||||
|
}
|
||||||
|
|
||||||
|
warn() {
|
||||||
|
msg "WARNING: $1\n"
|
||||||
|
excode=$(( excode+1 ))
|
||||||
|
}
|
||||||
|
|
||||||
|
error() {
|
||||||
|
msg "ERROR: $1\n"
|
||||||
|
exit -1
|
||||||
|
}
|
||||||
|
|
||||||
|
ok() {
|
||||||
|
msg "$(basename "$PWD") ok"
|
||||||
|
}
|
||||||
|
|
||||||
|
get_filename() {
|
||||||
|
if [[ "$1" =~ ^(http|https|ftp|file)://.*/(.+) ]]; then
|
||||||
|
echo "${BASH_REMATCH[2]}"
|
||||||
|
else
|
||||||
|
echo "$1"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
#
|
||||||
|
# read options
|
||||||
|
#
|
||||||
|
while [ $# -gt 0 ]; do
|
||||||
|
if [ "$1" = "--root" ]; then
|
||||||
|
convertfootprint="true"
|
||||||
|
else
|
||||||
|
error "unsupported option \"$1\""
|
||||||
|
fi
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
|
||||||
|
((excode=0))
|
||||||
|
|
||||||
|
#
|
||||||
|
# Checking footprint
|
||||||
|
#
|
||||||
|
if [ ! -s .footprint ]; then
|
||||||
|
error "no footprint found or empty footprint!"
|
||||||
|
fi
|
||||||
|
if [ "$convertfootprint" = "true" ]; then
|
||||||
|
uid="$(id -nu)"
|
||||||
|
gid="$(id -ng)"
|
||||||
|
file=".footprint"
|
||||||
|
<$file sed -e "s,$uid/$gid,root/root," > $file.tmp
|
||||||
|
mv $file.tmp $file
|
||||||
|
fi
|
||||||
|
if [ "$( <.footprint cut -f 2 | grep -c -v "root/root" )" -gt 0 ]; then
|
||||||
|
warn "non-root users found!\nrun \"prtcheck --root\" to convert footprint"
|
||||||
|
fi
|
||||||
|
|
||||||
|
#
|
||||||
|
# Checking Pkgfile
|
||||||
|
#
|
||||||
|
if [ ! -s Pkgfile ]; then
|
||||||
|
error "no Pkgfile found or Pkgfile empty!"
|
||||||
|
fi
|
||||||
|
desc="$(<Pkgfile awk '/^# Description:/ {print gensub(/# Description:[[:blank:]]*(.*)/,"\\1","g",$0)}')"
|
||||||
|
if [ "$desc" = "" ]; then
|
||||||
|
error "no Description in Pkgfile!"
|
||||||
|
fi
|
||||||
|
url="$(<Pkgfile awk '/^# URL:/ {print gensub(/# URL:[[:blank:]]*(.*)/,"\\1","g",$0)}')"
|
||||||
|
if [ "$url" = "" ]; then
|
||||||
|
error "no URL in Pkgfile!"
|
||||||
|
fi
|
||||||
|
maintainer="$(<Pkgfile awk '/^# Maintainer:/ {print gensub(/# Maintainer:[[:blank:]]*(.*)/,"\\1","g",$0)}')"
|
||||||
|
if [ "$maintainer" = "" ]; then
|
||||||
|
error "no Maintainer in Pkgfile!"
|
||||||
|
fi
|
||||||
|
depends="$(<Pkgfile awk '/^# Depends on:/ {print gensub(/# Depends on:[[:blank:]]*(.*)/,"\\1","g",$0)}')"
|
||||||
|
if [ "$depends" = "" ]; then
|
||||||
|
warn "no dependencies, please check!"
|
||||||
|
fi
|
||||||
|
|
||||||
|
#
|
||||||
|
# Checking .signature
|
||||||
|
#
|
||||||
|
. Pkgfile
|
||||||
|
(( unsigned=0 ))
|
||||||
|
|
||||||
|
for f in Pkgfile .footprint; do
|
||||||
|
if ! grep -q "($f)" .signature; then
|
||||||
|
warn "$f not signed"
|
||||||
|
unsigned=$(( unsigned+1 ))
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
for (( p=0; p<${#source[@]}; p++ )); do
|
||||||
|
if [ -z "${renames[$p]}" ] || [ "${renames[$p]}" = "SKIP" ]; then
|
||||||
|
renames[$p]=$( get_filename "${source[$p]}" )
|
||||||
|
fi
|
||||||
|
if ! grep -q "(${renames[$p]})" .signature; then
|
||||||
|
warn "${renames[$p]} not signed"
|
||||||
|
unsigned=$(( unsigned+1 ))
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
[ "$unsigned" = 0 ] || error "incomplete signature file"
|
||||||
|
[ "$excode" = 0 ] && ok || exit $excode
|
Loading…
Reference in New Issue
Block a user