Commit a60c9f4e authored by Franco Fichtner's avatar Franco Fichtner

pkg: split @shadow and @sample syntax, slight differences

(cherry picked from commit 72e46245)
(cherry picked from commit 83b5aae6)
parent 547b5a50
# $FreeBSD$
#
# MAINTAINER: portmgr@FreeBSD.org
#
# @sample etc/somefile.conf.sample
# or
# @sample file1 file2
#
# Where file1 is considered as a sample file and file2 the target file
#
# This will install the somefile.conf.sample and automatically copy to
# somefile.conf if it doesn't exist. On deinstall it will remove the
# somefile.conf if it still matches the sample, otherwise it is
# kept.
#
# This replaces the old pattern:
# @unexec if cmp -s %D/etc/pkgtools.conf %D/etc/pkgtools.conf.sample; then rm -f %D/etc/pkgtools.conf; fi
# etc/pkgtools.conf.sample
# @exec [ -f %B/pkgtools.conf ] || cp %B/%f %B/pkgtools.conf
actions: [file(1)]
arguments: true
post-install: <<EOD
case "%1" in
/*) sample_file="%1" ;;
*) sample_file="%D/%1" ;;
esac
target_file="${sample_file%.sample}"
set -- %@
if [ $# -eq 2 ]; then
target_file=${2}
fi
case "${target_file}" in
/*) target_file="${target_file}" ;;
*) target_file="%D/${target_file}" ;;
esac
if ! [ -f "${target_file}" ]; then
/bin/cp -p "${sample_file}" "${target_file}"
fi
EOD
pre-deinstall: <<EOD
case "%1" in
/*) sample_file="%1" ;;
*) sample_file="%D/%1" ;;
esac
target_file="${sample_file%.sample}"
set -- %@
if [ $# -eq 2 ]; then
set -- %@
target_file=${2}
fi
case "${target_file}" in
/*) target_file="${target_file}" ;;
*) target_file="%D/${target_file}" ;;
esac
if cmp -s "${target_file}" "${sample_file}"; then
rm -f "${target_file}"
else
echo "You may need to manually remove ${target_file} if it is no longer needed."
fi
EOD
......@@ -9,7 +9,7 @@
# Where file1 is considered as a sample file and file2 the target file
#
# This will install the somefile.conf.sample and automatically copy to
# somefile.conf if it doesn't exist. On deinstall it will be kept.
# somefile.conf if it doesn't exist. On deinstall it will be removed.
#
# This replaces the old pattern:
# @unexec if cmp -s %D/etc/pkgtools.conf %D/etc/pkgtools.conf.sample; then rm -f %D/etc/pkgtools.conf; fi
......@@ -51,4 +51,5 @@ pre-deinstall: <<EOD
/*) target_file="${target_file}" ;;
*) target_file="%D/${target_file}" ;;
esac
rm -f "${target_file}"
EOD
# Copyright (c) 2015-2016 Franco Fichtner <franco@opnsense.org>
# Copyright (c) 2015-2017 Franco Fichtner <franco@opnsense.org>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
......@@ -69,6 +69,15 @@ install-${TARGET}: force
mv -v "${DESTDIR}${ROOT_${TARGET}}/${TREE}/$${FILE}" \
"${DESTDIR}${ROOT_${TARGET}}/${TREE}/$${FILE%%.sample}"; \
fi; \
if [ "$${FILE%%.shadow}" != "$${FILE}" ]; then \
if [ -n "${NO_SAMPLE}" ]; then \
mv -v "${DESTDIR}${ROOT_${TARGET}}/${TREE}/$${FILE}" \
"${DESTDIR}${ROOT_${TARGET}}/${TREE}/$${FILE%%.shadow}"; \
else \
mv "${DESTDIR}${ROOT_${TARGET}}/${TREE}/$${FILE}" \
"${DESTDIR}${ROOT_${TARGET}}/${TREE}/$${FILE%%.shadow}.sample"; \
fi; \
fi; \
done
.endfor
......@@ -77,10 +86,15 @@ plist-${TARGET}: force
@(cd ${TREE}; find * -type f ${_IGNORES}) | while read FILE; do \
FILE="$${FILE%%.in}"; PREFIX=""; \
if [ -z "${NO_SAMPLE}" -a "$${FILE%%.sample}" != "$${FILE}" ]; then \
PREFIX="@sample "; \
fi; \
if [ -z "${NO_SAMPLE}" -a "$${FILE%%.shadow}" != "$${FILE}" ]; then \
FILE="$${FILE%%.shadow}.sample"; \
PREFIX="@shadow "; \
fi; \
if [ -n "${NO_SAMPLE}" ]; then \
FILE="$${FILE%%.sample}"; \
FILE="$${FILE%%.shadow}"; \
fi; \
echo "$${PREFIX}${ROOT_${TARGET}}/${TREE}/$${FILE}"; \
done
......
......@@ -1133,8 +1133,8 @@
/usr/local/www/widgets/widgets/traffic_graphs.widget.php
/usr/local/www/wizard.php
/usr/local/www/xmlrpc.php
@shadow /usr/local/etc/bogons.sample
@shadow /usr/local/etc/bogonsv6.sample
@shadow /usr/local/etc/config.xml.sample
@sample /usr/local/etc/bogons.sample
@sample /usr/local/etc/bogonsv6.sample
@sample /usr/local/etc/config.xml.sample
@shadow /usr/local/etc/pkg/repos/FreeBSD.conf.sample
@shadow /usr/local/etc/pkg/repos/origin.conf.sample
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment