diff --git a/checks/architecture_check.sh b/checks/architecture_check.sh index 77d2c7f..ea8727e 100644 --- a/checks/architecture_check.sh +++ b/checks/architecture_check.sh @@ -22,27 +22,61 @@ # Verify that the package content is correct in relation to its architecture. check() { - if [ "$PKG_ARCH" = "x86_64" ]; then - if [ -d "$WORKING_DIR/usr/lib" ]; then - while read file && ! [ -z "$file" ]; do - type=$(file "$file" | grep "ELF 64-bit") - if ! [ -z "$type" ]; then - log_error "binary-in-wrong-architecture-specific-path" "$file" - fi - done <<< "$(find "$WORKING_DIR/usr/lib" ! -type d)" - fi - fi - if [ "$PKG_ARCH" = "i486" -o "$PKG_ARCH" = "i686" ]; then - if [ -d "$WORKING_DIR/usr/lib64" ]; then - while read file && ! [ -z "$file" ]; do - type=$(file "$file" | grep "ELF 32-bit") - if ! [ -z "$type" ]; then - log_error "binary-in-wrong-architecture-specific-path" "$file" - fi - done <<< "$(find "$WORKING_DIR/usr/lib64" ! -type d)" - fi - fi + case "$PKG_ARCH" in + + x86_64 ) + if [ -d "$WORKING_DIR/usr/lib" ]; then + while read file && ! [ -z "$file" ]; do + type=$(file "$file" | grep "ELF 64-bit") + if ! [ -z "$type" ]; then + log_error "binary-in-wrong-architecture-specific-path" "$file" + fi + done <<< "$(find "$WORKING_DIR/usr/lib" ! -type d)" + fi + ;; + + i[3456]86 ) + if [ -d "$WORKING_DIR/usr/lib64" ]; then + while read file && ! [ -z "$file" ]; do + type=$(file "$file" | grep "ELF 32-bit") + if ! [ -z "$type" ]; then + log_error "binary-in-wrong-architecture-specific-path" "$file" + fi + done <<< "$(find "$WORKING_DIR/usr/lib64" ! -type d)" + fi + ;; + + arm64* ) + # arm64 doesn't exist yet, this is a placeholder to document that + # the entry for arm* below is 32-bit only. + : ;; + + arm* ) + if [ -d "$WORKING_DIR/usr/lib64" ]; then + while read file && ! [ -z "$file" ]; do + type=$(file "$file" | grep "ELF 32-bit") + if ! [ -z "$type" ]; then + log_error "binary-in-wrong-architecture-specific-path" "$file" + fi + done <<< "$(find "$WORKING_DIR/usr/lib64" ! -type d)" + fi + ;; + + noarch | fw ) + # todo: check there's nothing arch-specific + : ;; + + '' ) + # null string returned by package_element => can't check + : ;; + + * ) + log_error "package-has-unrecognised-arch" "$PKG_ARCH" + ;; + + esac + } info() { @@ -51,5 +85,8 @@ info() { echo -n "should not contain 64-bit binaries, /usr/lib64 should not contain " echo "32-bit binaries." echo + elif [ "$1" = "package-has-unrecognised-arch" ]; then + echo "The ARCH field of the package name is not a recognised arch." + echo fi } diff --git a/checks/info_check.sh b/checks/info_check.sh index c396c5f..94d0776 100644 --- a/checks/info_check.sh +++ b/checks/info_check.sh @@ -31,11 +31,23 @@ check() { fi done - while read i && ! [ -z "$i" ]; do - while read infopage && ! [ -z "$infopage" ]; do - log_warning "uncompressed-info-page" "$infopage" - done <<< "$(find "$i" -type f ! -name "*.gz" ! -name "*.png")" - done <<< "$(find "$WORKING_DIR" -type d -name "info")" + while read infopage && ! [ -z "$infopage" ]; do + log_warning "uncompressed-info-page" "$infopage" + done <<< "$(echo $PACKAGE_LISTING | grep -E '/info/.*\.info(-[0-9]+)?$')" + + if [ -f $WORKING_DIR/usr/info/dir ]; then + log_error "found-info-dir-file" "/usr/info/dir" + fi + + if [ -d $WORKING_DIR/usr/info ]; then + if [ -e $WORKING_DIR/install/doinst.sh ]; then + if ! [ $(grep install-info $WORKING_DIR/install/doinst.sh | wc -l) -ge "2" ]; then + log_error "missing-install-info" + fi + else + log_error "missing-install-info" + fi + fi } info() { @@ -45,5 +57,12 @@ info() { elif [ "$1" = "uncompressed-info-page" ]; then echo "Info-pages should be gzip-compressed" echo + elif [ "$1" = "found-info-dir-file" ]; then + echo "The Info pages' \"dir\" file should not be included in the package." + echo + elif [ "$1" = "missing-install-info" ]; then + echo -n "Whenever installing new Info pages in /usr/info, install-info" + echo "should be run in doinst.sh." + echo fi } diff --git a/checks/man_check.sh b/checks/man_check.sh index 97a3859..38bcdf3 100644 --- a/checks/man_check.sh +++ b/checks/man_check.sh @@ -34,8 +34,8 @@ check() { while read i && ! [ -z "$i" ]; do while read manpage && ! [ -z "$manpage" ]; do log_warning "uncompressed-man-page" "$manpage" - done <<< "$(find "$i" -type f ! -name "*.gz")" - done <<< "$(find "$WORKING_DIR" -type d -name "man")" + done <<< "$(find "$i" -type f ! -name "*.*.gz")" + done <<< "$(find "$WORKING_DIR" -type d \( -path "*/man/man?*" -o -path "*/man/*/man?*" \))" } info() { diff --git a/checks/ownership_check.sh b/checks/ownership_check.sh index 4b31749..ee54bd2 100644 --- a/checks/ownership_check.sh +++ b/checks/ownership_check.sh @@ -28,7 +28,7 @@ check() { while read tperms owngrp size date time objname && ! [ -z "$tperms" ]; do OWNER=$(echo "$owngrp" | cut -d "/" -f 1) DIRECTORY=$(dirname "$objname") - if [ "$DIRECTORT" = "/usr/bin" -o "$DIRECTORY" = "/usr/sbin" ]; then + if [ "$DIRECTORY" = "/usr/bin" -o "$DIRECTORY" = "/usr/sbin" ]; then INCORRECT="yes" for user in $USER_WHITELIST; do if [ "$user" = "$OWNER" ]; then diff --git a/checks/permissions_check.sh b/checks/permissions_check.sh index c0cae24..db85b44 100644 --- a/checks/permissions_check.sh +++ b/checks/permissions_check.sh @@ -37,16 +37,21 @@ check() { # Check permissions under /etc if [ -d "$WORKING_DIR/etc" ]; then - permission=$(stat -c "%a" "$WORKING_DIR/etc") - if ! [ "$permission" = "755" ]; then - log_warning "strange-permission" "$file" "$permission" - fi + while read file && ! [ -z "$file" ]; do + if [ -d "$file" ]; then + permission=$(stat -c "%a" "$file") + + if ! [ "$permission" = "755" ]; then + log_warning "strange-permission" "$file" "$permission" + fi + fi + done <<< "$(find "$WORKING_DIR/etc")" fi } info() { if [ "$1" = "strange-permission" ]; then - echo -n "A file that you listed to include in your package has strange " + echo -n "An object that you listed to include in your package has strange " echo -n "permissions. Usually, a file should have 0644 permissions and " echo "directories should have 0755 permissions." echo diff --git a/checks/slack-desc_check.sh b/checks/slack-desc_check.sh index ee8de33..6635694 100644 --- a/checks/slack-desc_check.sh +++ b/checks/slack-desc_check.sh @@ -49,16 +49,6 @@ check() { log_error "slack-desc-description-lines-too-long" fi - # Check the handy ruler. If not present, that's ok. - hr='|-----handy-ruler------------------------------------------------------|' - if [ $(grep "^ *${hr}\$" "$slackdescpath" | sed "s/|.*|//" | wc -c) -eq $(( ${#descprefix} + 1 )) ]; then - : # it's perfect! - elif grep -q "^ *${hr}\$" "$slackdescpath" ; then - log_warning "slack-desc-handy-ruler-misaligned" - elif grep -q "|-.*-|" "$slackdescpath" ; then - log_warning "slack-desc-handy-ruler-broken" - fi - # check there's no other junk if grep -q -v -e '^ *#' -e "^${descprefix}:" -e '^ *$' -e '|-.*-|' "$slackdescpath" ; then log_error "slack-desc-unrecognised-text" diff --git a/lintpkg b/lintpkg index 531b2a3..bb130c0 100755 --- a/lintpkg +++ b/lintpkg @@ -94,7 +94,7 @@ package_element() { } clean_filename() { - if [ -e "$1" ]; then + if [ -e "$1" -o -L "$1" ]; then EXTRAINFO=$(echo $1 | sed "s|^$WORKING_DIR||") EXTRAINFO=$(echo $EXTRAINFO | sed "s|\/\/|\/|g") else @@ -106,7 +106,7 @@ clean_filename() { log_error() { for i in $IGNORE; do - if [ -n "$1" -a "$i" = "$1" ]; then + if [ -n "$1" -a "$i" = "$1" ] || [ "$i" = "$PKG_NAME" ] || [ "$i" = "${PKG_NAME}:$1" ]; then return fi done @@ -128,7 +128,7 @@ log_error() { log_warning() { for i in $IGNORE; do - if [ -n "$1" -a "$i" = "$1" ]; then + if [ -n "$1" -a "$i" = "$1" ] || [ "$i" = "$PKG_NAME" ] || [ "$i" = "${PKG_NAME}:$1" ]; then return fi done @@ -150,7 +150,7 @@ log_warning() { log_notice() { for i in $IGNORE; do - if [ -n "$1" -a "$i" = "$1" ]; then + if [ -n "$1" -a "$i" = "$1" ] || [ "$i" = "$PKG_NAME" ] || [ "$i" = "${PKG_NAME}:$1" ]; then return fi done @@ -174,6 +174,15 @@ local_info() { if [ "$1" = "external-compression-utility-missing" ]; then echo "The necessary compression utility for uncompressing the package is missing." echo + elif [ "$1" = "package-has-wrong-compression-type" ]; then + echo "The package is compressed with the wrong compression utility." + echo + elif [ "$1" = "package-is-uncompressed-tar" ]; then + echo "The package is really an uncompressed tar archive." + echo + elif [ "$1" = "file-is-not-tar" ]; then + echo "The file is not a valid compressed tar archive." + echo fi } @@ -208,10 +217,12 @@ options: -i --info (Display explanations for reported messages.) -h --help (Display summary of command line options and exit.) -E --extractdir (Base directory for extracted temporary files.) -V --version (Display version information and exit.) - -x --exclude (Don't show/count errors for the specified - message identifiers. Multiple identifiers - can be specified by separating them with - commas.) + -x --exclude [:] (Don't show/count errors for the + specified package names and message identifiers. + Multiple identifiers can be specified by + separating them with commas.) + -X --exclude-from (Don't show/count errors for the package names + and message identifiers specified in .) EOF } @@ -369,6 +380,14 @@ while [ 0 ]; do IGNORE=$(echo $2 | tr , '\n') shift 2 + elif [ "$1" = "-X" -o "$1" = "--exclude-from" ]; then + if [ -z "$2" -o "$(echo $2 | head -c 1)" = "-" ]; then + usage + exit + fi + + IGNORE=$(sed -e 's/#.*//' -e 's/^ *//' -e 's/ *$//' $2 | tr , '\n') + shift 2 else break fi @@ -413,18 +432,38 @@ for PACKAGE in $*; do PACKAGES=$(expr $PACKAGES + 1) # Determine compressor utility: - case $PKG_EXTENSION in - 'tgz' ) + filetype=$(file -b "$PACKAGE") + case $filetype in + 'gzip compressed data'* ) packagecompression=gzip + if [ "$PKG_EXTENSION" != 'tgz' ]; then + log_error "package-has-wrong-compression-type" "$filetype" + fi ;; - 'tbz' ) + 'bzip2 compressed data'* ) packagecompression=bzip2 + if [ "$PKG_EXTENSION" != 'tbz' ]; then + log_error "package-has-wrong-compression-type" "$filetype" + fi ;; - 'tlz' ) + 'LZMA compressed data'* ) packagecompression=lzma + if [ "$PKG_EXTENSION" != 'tlz' ]; then + log_error "package-has-wrong-compression-type" "$filetype" + fi ;; - 'txz' ) + 'XZ compressed data'* ) packagecompression=xz + if [ "$PKG_EXTENSION" != 'txz' ]; then + log_error "package-has-wrong-compression-type" "$filetype" + fi + ;; + 'POSIX tar archive'* ) + log_error "package-is-uncompressed-tar" + ;; + *) + log_error "file-is-not-tar" "$filetype" + continue ;; esac diff --git a/slackware-whitelist b/slackware-whitelist new file mode 100644 index 0000000..d8188a2 --- /dev/null +++ b/slackware-whitelist @@ -0,0 +1,64 @@ +# a series +aaa_base:dir-or-file-in-mnt +aaa_base:dir-or-file-in-usr-local +aaa_base:dir-or-file-in-var-lock +aaa_base:incorrect-info-dir +aaa_base:incorrect-man-dir +cups:strange-permission +dbus:strange-owner-or-group +etc:dir-or-file-in-tmp +floppy:strange-owner-or-group +glibc-solibs:unstripped-binary +grub:unstripped-binary +kernel-modules:unstripped-binary +kernel-modules-smp:unstripped-binary +slocate:strange-owner-or-group +utempter:strange-owner-or-group +util-linux:strange-owner-or-group +# ap series +at:strange-owner-or-group +mariadb:dir-or-file-in-var-run +sudo:strange-permission +# d series +clisp:unstripped-binary +gcc:unstripped-binary +gcc-go:unstripped-binary +perl:dir-or-file-in-usr-local +python:unstripped-binary +# e series +emacs:strange-owner-or-group +# f series (none) +# k series +kernel-source:unstripped-binary +# kde series +kde-runtime:strange-owner-or-group +# kdei series (none) +# l series +ConsoleKit:dir-or-file-in-var-run +glibc:unstripped-binary +gnu-efi:unstripped-binary +polkit:strange-permission +vte:strange-owner-or-group +# n series +iptraf-ng:dir-or-file-in-var-run +nn:strange-owner-or-group +openvpn:strange-permission +procmail:strange-owner-or-group +proftpd:dir-or-file-in-home +samba:dir-or-file-in-var-run +samba:strange-permission +sendmail:strange-owner-or-group +slrn:strange-owner-or-group +stunnel:dir-or-file-in-var-run +uucp:strange-owner-or-group +vsftpd:dir-or-file-in-home +# t series (none) +# tcl series (none) +# x series +xf86-video-rendition:unstripped-binary +# xap series +sane:dir-or-file-in-var-lock +xlockmore:strange-owner-or-group +xscreensaver:strange-owner-or-group +# xfce series (none) +# y series (none)