1
0
mirror of https://git.FreeBSD.org/ports.git synced 2024-11-28 01:06:17 +00:00
freebsd-ports/sysutils/LPRng/files/pkg-install.in
Florent Thoumie b34a004c77 - Fix packing list issues. [1]
- Add new PORT_REPLACES_BASE_LPR knob. [2]
- Preserve original files when replacing base lpr. [1]
- Global cleanup. [1]

PR:		ports/76945 [1], ports/65824 [2]
Submitted by:	flz [1], Linh Pham <question+freebsdpr@closedsrc.org> [2]
Approved by:	maintainer timeout (1 month [1], 10 months [2])
2005-04-04 12:32:57 +00:00

120 lines
2.7 KiB
Bash

#! /bin/sh
prefix=%%PREFIX%%
sysconfdir=%%SYSCONFDIR%%
case "x$2" in
"xPRE-INSTALL")
# Preserve original files from being overwritten.
if [ "x$prefix" = "x/usr" ]; then
cd $prefix
for i in bin/lp bin/lpq bin/lpr bin/lprm sbin/lpc sbin/lpd \
share/man/man1/lp.1.gz share/man/man1/lpq.1.gz \
share/man/man1/lpr.1.gz share/man/man1/lprm.1.gz \
share/man/man5/printcap.5.gz share/man/man8/lpc.8.gz \
share/man/man8/lpd.8.gz ; do
cp -p $i $i.orig
done
fi
;;
"xPOST-INSTALL")
cd $sysconfdir
# Preserve original configuration files from being overwritten.
# Restore previously saved configuration if possible.
if [ "x$sysconfdir" = "x/etc" ]; then
for i in lpd.conf lpd.perms printcap; do
[ -f $i ] && mv $i $i.orig
[ -f $i.saved ] && mv $i.saved $i || cp $i.sample $i
done
else
for i in lpd.conf lpd.perms printcap; do
[ -f $i.saved ] && mv $i.saved $i || cp $i.sample $i
done
fi
# This is a trick to detect if the user installed a new world at deinstall stage.
if [ "x$prefix" = "x/usr" ]; then
cd $prefix
for i in bin/lp bin/lpq bin/lpr bin/lprm sbin/lpc sbin/lpd \
share/man/man1/lp.1.gz share/man/man1/lpq.1.gz \
share/man/man1/lpr.1.gz share/man/man1/lprm.1.gz \
share/man/man5/printcap.5.gz share/man/man8/lpc.8.gz \
share/man/man8/lpd.8.gz ; do
touch $i.orig
done
fi
;;
"xDEINSTALL")
cd $sysconfdir
# Remove unchanged files.
for i in lpd.conf lpd.perms printcap; do
cmp -s $i $i.sample && rm -f $i
done
# Remove backup files if installworld overwrited LPRng files.
if [ "x$prefix" = "x/usr" ]; then
cd $prefix
for i in bin/lp bin/lpq bin/lpr bin/lprm sbin/lpc sbin/lpd \
share/man/man1/lp.1.gz share/man/man1/lpq.1.gz \
share/man/man1/lpr.1.gz share/man/man1/lprm.1.gz \
share/man/man5/printcap.5.gz share/man/man8/lpc.8.gz \
share/man/man8/lpd.8.gz ; do
[ $i -nt $i.orig ] && rm $i.orig
done
fi
;;
"xPOST-DEINSTALL")
cd $sysconfdir
# Save remaining modified files so we can restore them at next install.
# Restore original files when LPRng files haven't changed.
for i in lpd.conf lpd.perms printcap; do
if [ "x$sysconfdir" = "x/etc" ]; then
if [ -f $i ]; then
mv $i $i.saved
else
[ -f $i.orig ] && mv $i.orig $i
fi
else
[ -f $i ] && mv $i $i.saved
fi
done
# Restore backup files.
if [ "x$prefix" = "x/usr" ]; then
cd $prefix
for i in bin/lp bin/lpq bin/lpr bin/lprm sbin/lpc sbin/lpd \
share/man/man1/lp.1.gz share/man/man1/lpq.1.gz \
share/man/man1/lpr.1.gz share/man/man1/lprm.1.gz \
share/man/man5/printcap.5.gz share/man/man8/lpc.8.gz \
share/man/man8/lpd.8.gz ; do
[ -f $i.orig ] && mv $i.orig $i
done
fi
;;
esac
exit 0