mirror of
https://git.FreeBSD.org/ports.git
synced 2024-11-23 00:43:28 +00:00
2d3c3b823e
Give the alpine/pkg-install script triple protection against being run inappropriately.
40 lines
1005 B
Bash
40 lines
1005 B
Bash
#!/bin/sh
|
|
|
|
[ "$2" = 'POST-INSTALL' ] || exit 0
|
|
|
|
case "$1" in
|
|
alpine*) ;;
|
|
*) exit 0 ;;
|
|
esac
|
|
|
|
[ -x "${PKG_PREFIX}/bin/alpine" ] || exit 1
|
|
|
|
PATH=/bin:/usr/bin
|
|
export PATH
|
|
|
|
TDIR=`mktemp -d ${TMPDIR:-/tmp}/alpine-conf.XXXXXXXX`
|
|
|
|
if [ -s "${PKG_PREFIX}/etc/alpine.conf" ]; then
|
|
mv ${PKG_PREFIX}/etc/alpine.conf ${TDIR}/alpine.conf.installed
|
|
fi
|
|
|
|
${PKG_PREFIX}/bin/alpine -conf > ${TDIR}/alpine.conf.sample
|
|
install -o root -g wheel -m 444 ${TDIR}/alpine.conf.sample ${PKG_PREFIX}/etc/alpine.conf.sample
|
|
|
|
[ -s "${TDIR}/alpine.conf.installed" ] && mv ${TDIR}/alpine.conf.installed ${PKG_PREFIX}/etc/alpine.conf
|
|
|
|
${PKG_PREFIX}/bin/alpine -conf > ${TDIR}/alpine.conf
|
|
|
|
if [ -s "${PKG_PREFIX}/etc/alpine.conf" ]; then
|
|
if ! cmp -s ${TDIR}/alpine.conf ${PKG_PREFIX}/etc/alpine.conf; then
|
|
unlink ${PKG_PREFIX}/etc/alpine.conf
|
|
install -o root -g wheel -m 444 ${TDIR}/alpine.conf ${PKG_PREFIX}/etc/alpine.conf
|
|
fi
|
|
else
|
|
cp -p ${PKG_PREFIX}/etc/alpine.conf.sample ${PKG_PREFIX}/etc/alpine.conf
|
|
fi
|
|
|
|
rm -rf $TDIR
|
|
|
|
exit 0
|