Use standard rpm macros

Signed-off-by: Tom Eastep <teastep@shorewall.net>
This commit is contained in:
Tom Eastep 2012-02-22 12:40:16 -08:00
parent 2624005fa8
commit ef850e4537
4 changed files with 131 additions and 134 deletions

View File

@ -117,34 +117,34 @@ esac
INSTALLD='-D'
if [ -z "$HOST" ]; then
if [ -z "$BUILD" ]; then
case $(uname) in
CYGWIN*)
HOST=CYGWIN
cygwin*)
BUILD=cygwin
;;
Darwin)
HOST=MAC
BUILD=apple
;;
*)
if [ -f /etc/debian_version ]; then
HOST=DEBIAN
BUILD=debian
elif [ -f /etc/redhat-release ]; then
HOST=REDHAT
BUILD=redhat
elif [ -f /etc/slackware-version ] ; then
HOST=SLACKWARE
BUILD=slackware
elif [ -f /etc/SuSE-release ]; then
HOST=SUSE
BUILD=suse
elif [ -f /etc/arch-release ] ; then
HOST=ARCHLINUX
BUILD=archlinux
else
HOST=LINUX
BUILD=linux
fi
;;
esac
fi
case $HOST in
CYGWIN*)
case $BUILD in
cygwin*)
if [ -z "$DESTDIR" ]; then
DEST=
INIT=
@ -153,7 +153,7 @@ case $HOST in
OWNER=$(id -un)
GROUP=$(id -gn)
;;
MAC)
apple)
if [ -z "$DESTDIR" ]; then
DEST=
INIT=
@ -212,25 +212,25 @@ PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin:/usr/local/sbin
# Determine where to install the firewall script
#
[ -n "$TARGET" ] || TARGET=$HOST
[ -n "$HOST" ] || HOST=$BUILD
case "$TARGET" in
CYGWIN)
case "$HOST" in
cygwin)
echo "Installing Cygwin-specific configuration..."
;;
MAC)
apple)
echo "Installing Mac-specific configuration...";
;;
DEBIAN|REDHAT|SLACKWARE|ARCHLINUX|LINUX|SUSE)
debian|redhat|slackware|archlinux|linux|suse)
;;
*)
echo "ERROR: Unknown TARGET \"$TARGET\"" >&2
echo "ERROR: Unknown HOST \"$HOST\"" >&2
exit 1;
;;
esac
if [ -n "$DESTDIR" ]; then
if [ $HOST != CYGWIN ]; then
if [ $BUILD != cygwin ]; then
if [ `id -u` != 0 ] ; then
echo "Not setting file owner/group permissions, not running as root."
OWNERSHIP=""
@ -271,7 +271,7 @@ for f in lib.* ; do
echo "Library ${f#*.} file installed as ${DESTDIR}/usr/share/shorewall/$f"
done
if [ $HOST = MAC ]; then
if [ $BUILD = apple ]; then
eval sed -i \'s\|g_libexec=.\*\|g_libexec=$LIBEXEC\|\' ${DESTDIR}/usr/share/shorewall/lib.cli
eval sed -i \'s\|g_perllib=.\*\|g_perllib=$PERLLIB\|\' ${DESTDIR}/usr/share/shorewall/lib.cli
else

View File

@ -119,78 +119,76 @@ esac
INITFILE="shorewall-init"
if [ -z "$HOST" ]; then
if [ -z "$BUILD" ]; then
case $(uname) in
CYGWIN*)
HOST=CYGWIN
cygwin*)
BUILD=cygwin
;;
Darwin)
HOST=MAC
BUILD=apple
;;
*)
if [ -f /etc/debian_version ]; then
HOST=DEBIAN
BUILD=debian
elif [ -f /etc/redhat-release ]; then
HOST=REDHAT
BUILD=redhat
elif [ -f /etc/SuSE-release ]; then
HOST=SUSE
BUILD=suse
elif [ -f /etc/slackware-version ] ; then
HOST=SLACKWARE
BUILD=slackware
elif [ -f /etc/arch-release ] ; then
HOST=ARCHLINUX
BUILD=archlinux
else
HOST=
BUILD=linux
fi
;;
esac
fi
case $HOST in
CYGWIN*)
OWNER=$(id -un)
GROUP=$(id -gn)
;;
MAC)
[ -z "$OWNER" ] && OWNER=root
[ -z "$GROUP" ] && GROUP=wheel
INSTALLD=
[ -n "$OWNER" ] || OWNER=$(id -un)
[ -n "$GROUP" ] || GROUP=$(id -gn)
case $BUILD in
apple)
T=
;;
debian|redhat|suse|slackware|archlinux)
;;
*)
[ -z "$OWNER" ] && OWNER=root
[ -z "$GROUP" ] && GROUP=root
[ -n "$BUILD" ] && echo "ERROR: Unknown BUILD environment ($BUILD)" >&2 || echo "ERROR: Unknown BUILD environment"
exit 1
;;
esac
OWNERSHIP="-o $OWNER -g $GROUP"
[ -n "$TARGET" ] || TARGET=$HOST
[ -n "$HOST" ] || HOST=$BUILD
case "$TARGET" in
DEBIAN)
case "$HOST" in
debian)
echo "Installing Debian-specific configuration..."
SPARSE=yes
;;
REDHAT)
redhat|redhat)
echo "Installing Redhat/Fedora-specific configuration..."
INITDIR=/etc/rc.d/init.d
[ -n "$INITDIR" ] || INITDIR=/etc/rc.d/init.d
;;
SLACKWARE)
slackware)
echo "Shorewall-init is currently not supported on Slackware" >&2
exit 1
;;
ARCHLINUX)
archlinux)
echo "Shorewall-init is currently not supported on Arch Linux" >&2
exit 1
;;
SUSE)
suse|suse)
echo "Installing SuSE-specific configuration..."
;;
LINUX)
linux)
echo "ERROR: Shorewall-init is not supported on this system" >&2
;;
*)
echo "ERROR: Unsupported TARGET distribution: \"$TARGET\"" >&2
echo "ERROR: Unsupported HOST distribution: \"$HOST\"" >&2
exit 1;
;;
esac
@ -268,7 +266,7 @@ if [ -z "$DESTDIR" ]; then
ln -s ${INITDIR}/${INITFILE} /usr/share/shorewall-init/init
fi
if [ $TARGET = DEBIAN ]; then
if [ $HOST = debian ]; then
if [ -n "${DESTDIR}" ]; then
mkdir -p ${DESTDIR}/etc/network/if-up.d/
mkdir -p ${DESTDIR}/etc/network/if-post-down.d/
@ -286,7 +284,7 @@ else
mkdir -p ${DESTDIR}/etc/sysconfig
if [ -z "$RPM" ]; then
if [ $TARGET = SUSE ]; then
if [ $HOST = suse ]; then
mkdir -p ${DESTDIR}/etc/sysconfig/network/if-up.d
mkdir -p ${DESTDIR}/etc/sysconfig/network/if-down.d
else
@ -312,18 +310,18 @@ if [ -d ${DESTDIR}/etc/NetworkManager ]; then
install_file ifupdown.sh ${DESTDIR}/etc/NetworkManager/dispatcher.d/01-shorewall 0544
fi
case $TARGET in
DEBIAN)
case $HOST in
debian)
install_file ifupdown.sh ${DESTDIR}/etc/network/if-up.d/shorewall 0544
install_file ifupdown.sh ${DESTDIR}/etc/network/if-post-down.d/shorewall 0544
;;
SUSE)
suse)
if [ -z "$RPM" ]; then
install_file ifupdown.sh ${DESTDIR}/etc/sysconfig/network/if-up.d/shorewall 0544
install_file ifupdown.sh ${DESTDIR}/etc/sysconfig/network/if-down.d/shorewall 0544
fi
;;
REDHAT)
redhat)
if [ -f ${DESTDIR}/sbin/ifup-local -o -f ${DESTDIR}/sbin/ifdown-local ]; then
echo "WARNING: /sbin/ifup-local and/or /sbin/ifdown-local already exist; up/down events will not be handled"
else
@ -335,7 +333,7 @@ esac
if [ -z "$DESTDIR" ]; then
if [ -n "$first_install" ]; then
if [ $TARGET = DEBIAN ]; then
if [ $HOST = debian ]; then
update-rc.d shorewall-init defaults
@ -372,7 +370,7 @@ if [ -z "$DESTDIR" ]; then
fi
else
if [ -n "$first_install" ]; then
if [ $TARGET = DEBIAN ]; then
if [ $HOST = debian ]; then
if [ -n "${DESTDIR}" ]; then
mkdir -p ${DESTDIR}/etc/rcS.d
fi
@ -384,14 +382,14 @@ else
fi
if [ -f ${DESTDIR}/etc/ppp ]; then
case $TARGET in
DEBIAN|SUSE)
case $HOST in
debian|suse)
for directory in ip-up.d ip-down.d ipv6-up.d ipv6-down.d; do
mkdir -p ${DESTDIR}/etc/ppp/$directory #SuSE doesn't create the IPv6 directories
cp -fp ${DESTDIR}${LIBEXEC}/shorewall-init/ifupdown ${DESTDIR}/etc/ppp/$directory/shorewall
done
;;
REDHAT)
redhat)
#
# Must use the dreaded ip_xxx.local file
#

View File

@ -135,43 +135,43 @@ esac
#
# Determine where to install the firewall script
#
CYGWIN=
cygwin=
INSTALLD='-D'
INITFILE=$PRODUCT
T='-T'
if [ -z "$HOST" ]; then
if [ -z "$BUILD" ]; then
case $(uname) in
CYGWIN*)
HOST=CYGWIN
cygwin*)
BUILD=cygwin
;;
Darwin)
HOST=MAC
BUILD=apple
;;
*)
if [ -f /etc/debian_version ]; then
HOST=DEBIAN
BUILD=debian
elif [ -f /etc/redhat-release ]; then
HOST=REDHAT
BUILD=redhat
elif [ -f /etc/SuSE-release ]; then
HOST=SUSE
BUILD=suse
elif [ -f /etc/slackware-version ] ; then
HOST=SLACKWARE
BUILD=slackware
elif [ -f /etc/arch-release ] ; then
HOST=ARCHLINUX
BUILD=archlinux
else
HOST=LINUX
BUILD=linux
fi
;;
esac
fi
case $HOST in
CYGWIN*)
case $BUILD in
cygwin*)
OWNER=$(id -un)
GROUP=$(id -gn)
;;
MAC)
apple)
[ -z "$OWNER" ] && OWNER=root
[ -z "$GROUP" ] && GROUP=wheel
INSTALLD=
@ -185,40 +185,39 @@ esac
OWNERSHIP="-o $OWNER -g $GROUP"
[ -n "$TARGET" ] || TARGET=$HOST
[ -n "$HOST" ] || HOST=$BUILD
case "$TARGET" in
CYGWIN)
case "$HOST" in
cygwin)
echo "$PRODUCT is not supported on Cygwin" >&2
exit 1
;;
MAC)
apple)
echo "$PRODUCT is not supported on OS X" >&2
exit 1
;;
DEBIAN)
debian)
echo "Installing Debian-specific configuration..."
SPARSE=yes
;;
REDHAT)
redhat)
echo "Installing Redhat/Fedora-specific configuration..."
INITDIR=/etc/rc.d/init.d
[ -n "$INITDIR" ] || INITDIR=/etc/rc.d/init.d
;;
SLACKWARE)
slackware)
echo "Installing Slackware-specific configuration..."
INITDIR="/etc/rc.d"
INITFILE="rc.firewall"
MANDIR="/usr/man"
[ -n "$INITDIR" ] || INITDIR="/etc/rc.d"
[ -n "$INITFILE" ] || INITFILE="rc.firewall"
[ -n "$MANDIR=" ] || MANDIR=/usr/man
;;
ARCHLINUX)
archlinux)
echo "Installing ArchLinux-specific configuration..."
INITDIR="/etc/rc.d"
INITFILE="$PRODUCT"
[ -n "$INITDIR" ] || INITDIR="/etc/rc.d"
;;
LINUX|SUSE)
linux|suse)
;;
*)
echo "ERROR: Unknown TARGET \"$TARGET\"" >&2
echo "ERROR: Unknown HOST \"$HOST\"" >&2
exit 1;
;;
esac
@ -323,7 +322,7 @@ if [ ! -f ${DESTDIR}/etc/$PRODUCT/$PRODUCT.conf ]; then
echo "Config file installed as ${DESTDIR}/etc/$PRODUCT/$PRODUCT.conf"
fi
if [ $TARGET = ARCHLINUX ] ; then
if [ $HOST = archlinux ] ; then
sed -e 's!LOGFILE=/var/log/messages!LOGFILE=/var/log/messages.log!' -i ${DESTDIR}/etc/$PRODUCT/$PRODUCT.conf
fi
@ -434,7 +433,7 @@ if [ -z "$DESTDIR" ]; then
touch /var/log/$PRODUCT-init.log
if [ -n "$first_install" ]; then
if [ $TARGET = DEBIAN ]; then
if [ $HOST = debian ]; then
run_install $OWNERSHIP -m 0644 default.debian /etc/default/$PRODUCT
update-rc.d $PRODUCT defaults

View File

@ -135,38 +135,38 @@ case "$PERLLIB" in
;;
esac
if [ -z "$HOST" ]; then
if [ -z "$BUILD" ]; then
case $(uname) in
CYGWIN*)
HOST=CYGWIN
cygwin*)
BUILD=cygwin
;;
Darwin)
HOST=MAC
BUILD=apple
;;
*)
if [ -f /etc/debian_version ]; then
HOST=DEBIAN
BUILD=debian
elif [ -f /etc/redhat-release ]; then
HOST=REDHAT
BUILD=redhat
elif [ -f /etc/slackware-version ] ; then
HOST=SLACKWARE
BUILD=slackware
elif [ -f /etc/SuSE-release ]; then
HOST=SUSE
BUILD=suse
elif [ -f /etc/arch-release ] ; then
HOST=ARCHLINUX
BUILD=archlinux
else
HOST=LINUX
BUILD=linux
fi
;;
esac
fi
case $HOST in
CYGWIN*)
case $BUILD in
cygwin*)
OWNER=$(id -un)
GROUP=$(id -gn)
;;
MAC)
apple)
[ -z "$OWNER" ] && OWNER=root
[ -z "$GROUP" ] && GROUP=wheel
INSTALLD=
@ -242,43 +242,43 @@ if [ $PRODUCT = shorewall ]; then
fi
fi
[ -n "$TARGET" ] || TARGET=$HOST
[ -n "$HOST" ] || HOST=$BUILD
case "$TARGET" in
CYGWIN)
case "$HOST" in
cygwin)
echo "Installing Cygwin-specific configuration..."
INITFILE=
;;
MAC)
apple)
echo "Installing Mac-specific configuration...";
INITFILE=
;;
DEBIAN)
debian)
echo "Installing Debian-specific configuration..."
SPARSE=yes
;;
REDHAT)
redhat)
echo "Installing Redhat/Fedora-specific configuration..."
INITDIR="/etc/rc.d/init.d"
[ -n "$INITDIR" ] || INITDIR="/etc/rc.d/init.d"
;;
SUSE)
suse)
echo "Installing SuSE-specific configuration...";
;;
SLACKWARE)
slackware)
echo "Installing Slackware-specific configuration..."
INITDIR="/etc/rc.d"
MANDIR="/usr/man"
INITFILE="rc.firewall"
[ -n "$INITDIR" ] || INITDIR="/etc/rc.d"
[ -n "$MANDIR" ] || MANDIR="/usr/man"
[ -n "$INITFILE" ] || INITFILE="rc.firewall"
;;
ARCHLINUX)
archlinux)
echo "Installing ArchLinux-specific configuration..."
INITDIR="/etc/rc.d"
INITFILE="$PRODUCT"
[ -n "$INITDIR" ] || INITDIR="/etc/rc.d"
[ -n "$INITFILE" ] || INITFILE="$PRODUCT"
;;
LINUX)
linux)
;;
*)
echo "ERROR: Unknown TARGET \"$TARGET\"" >&2
echo "ERROR: Unknown HOST \"$HOST\"" >&2
exit 1;
;;
esac
@ -288,7 +288,7 @@ if [ -z "$INITDIR" -a -n "$INITFILE" ] ; then
fi
if [ -n "$DESTDIR" ]; then
if [ $HOST != CYGWIN ]; then
if [ $BUILD != cygwin ]; then
if [ `id -u` != 0 ] ; then
echo "Not setting file owner/group permissions, not running as root."
OWNERSHIP=""
@ -326,7 +326,7 @@ if [ -z "${DESTDIR}" -a $PRODUCT = shorewall -a ! -f /usr/share/$PRODUCT/corever
exit 1
fi
if [ $TARGET != CYGWIN ]; then
if [ $HOST != cygwin ]; then
install_file $PRODUCT ${DESTDIR}/sbin/$PRODUCT 0755
echo "$PRODUCT control program installed in ${DESTDIR}/sbin/$PRODUCT"
else
@ -337,8 +337,8 @@ fi
#
# Install the Firewall Script
#
case $TARGET in
SLACKWARE)
case $HOST in
slackware)
if [ $PRODUCT = shorewall ]; then
install_file init.slackware.firewall.sh ${DESTDIR}${DEST}/rc.firewall 0644
install_file init.slackware.$PRODUCT.sh ${DESTDIR}${DEST}/rc.$PRODUCT 0644
@ -446,7 +446,7 @@ run_install $OWNERSHIP -m 0644 $PRODUCT.conf.annotated ${DESTDIR}/usr/share/$PRO
if [ ! -f ${DESTDIR}/etc/$PRODUCT/$PRODUCT.conf ]; then
run_install $OWNERSHIP -m 0644 $PRODUCT.conf${suffix} ${DESTDIR}/etc/$PRODUCT/$PRODUCT.conf
if [ $TARGET = DEBIAN ] && mywhich perl; then
if [ $HOST = debian ] && mywhich perl; then
#
# Make a Debian-like $PRODUCT.conf
#
@ -457,7 +457,7 @@ if [ ! -f ${DESTDIR}/etc/$PRODUCT/$PRODUCT.conf ]; then
fi
if [ $TARGET = ARCHLINUX ] ; then
if [ $HOST = archlinux ] ; then
sed -e 's!LOGFILE=/var/log/messages!LOGFILE=/var/log/messages.log!' -i ${DESTDIR}/etc/$PRODUCT/$PRODUCT.conf
fi
@ -601,7 +601,7 @@ run_install $OWNERSHIP -m 0644 maclist.annotated ${DESTDIR}/usr/share/$PRODUCT/c
if [ -z "$SPARSE" -a ! -f ${DESTDIR}/etc/$PRODUCT/maclist ]; then
run_install $OWNERSHIP -m 0600 maclist${suffix} ${DESTDIR}/etc/$PRODUCT/maclist
echo "MAC list file installed as ${DESTDIR}/etc/$PRODUCT/maclist"
echo "mac list file installed as ${DESTDIR}/etc/$PRODUCT/maclist"
fi
if [ -f masq ]; then
@ -1099,8 +1099,8 @@ if [ -d ${DESTDIR}/etc/logrotate.d ]; then
echo "Logrotate file installed as ${DESTDIR}/etc/logrotate.d/$PRODUCT"
fi
if [ -z "$DESTDIR" -a -n "$first_install" -a -z "${CYGWIN}${MAC}" ]; then
if [ $TARGET = DEBIAN ]; then
if [ -z "$DESTDIR" -a -n "$first_install" -a -z "${cygwin}${mac}" ]; then
if [ $HOST = debian ]; then
run_install $OWNERSHIP -m 0644 default.debian /etc/default/$PRODUCT
update-rc.d $PRODUCT defaults