#!/bin/bash # very simple and rudamentary script to # check for gross errors in the layout of an # RPM package's contents # # Usage: # ./rpm-check package.rpm # PACKAGENAME=`rpm -qp --queryformat "%{NAME}" $1` FAILURE=FALSE echo Checking $PACKAGENAME ... # check for files outside /usr/local and /etc/init.d for i in `rpm -qp --queryformat "[%{FILELINKTOS}-%{FILEFLAGS}-%{FILENAMES}\n]" $1`; do # echo __ $i __ case $i in -*etc*.rpm) #old way of naming etc echo \| Do not name config file with .rpm anymore. echo \| Use %config\(noreplace\). Config file: FAILURE=TRUE ;; -*/usr/local/etc|-*/usr/local/bin|-*/usr/local/man|-*/etc/init.d) #catches directories echo \| Do not include directories in packages, only include echo \| the files in them. Offending directory: echo $i | cut -d"-" -f3 FAILURE=TRUE ;; -17-/usr/local*etc/*) # /usr/local etc files marked as config # echo config ok ;; -*/usr/local*etc/*) # /usr/local etc files NOT marked as config echo \| This file should be marked as config: echo $i | cut -d"-" -f3 FAILURE=TRUE ;; -*/usr/local/man*) # echo man check ok ;; -*/man/*) echo \| Man files should be placed under /usr/local/man/man* FAILURE=TRUE ;; -*/usr/local*) # catch non-/usr/local # echo /usr/local ok ;; -*/etc/init.d/$PACKAGENAME*) # echo /etc/init.d ok ;; -*/etc/init.d/*) echo \| Consider naming the startup script the same as the package: echo $i | cut -d"-" -f3 ;; -*) echo \| This file is outside /usr/local and it not an /etc/init.d echo \| script. This is generally a bad thing: echo $i | cut -d"-" -f3 FAILURE=TRUE ;; *) echo \| Make sure having this symlink is a good idea: echo $i | cut -d"-" -f3 FAILURE=TRUE esac done if [ $FAILURE = TRUE ]; then echo Warnings and/or errors issued for $PACKAGENAME exit 1 else echo ok! fi