Commit 95b28bb7 authored by Franco Fichtner's avatar Franco Fichtner

pkg: shadow the sample files, delete on uninstall is undesired

While there also get rid of the need for a /usr/ports dir (this will
make tools.git crash and burn for sure.)

shadow.ucl adapted from https://github.com/freebsd/freebsd-ports/blob/master/Keywords/sample.ucl

(cherry picked from commit 82bece2a)
(cherry picked from commit 73e58543)
parent 75a2b9f8
# $FreeBSD$
#
# MAINTAINER: franco@opnsense.org
#
# @shadow etc/somefile.conf.sample
# or
# @shadow 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 be 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
EOD
......@@ -235,29 +235,17 @@ metadata: force
@${MAKE} DESTDIR=${DESTDIR} manifest > ${DESTDIR}/+MANIFEST
@${MAKE} DESTDIR=${DESTDIR} plist > ${DESTDIR}/plist
package-keywords: force
@if [ ! -f /usr/ports/Keywords/sample.ucl ]; then \
mkdir -p /usr/ports/Keywords; \
cd /usr/ports/Keywords; \
fetch https://raw.githubusercontent.com/opnsense/ports/master/Keywords/sample.ucl; \
fi
@echo ">>> Installed /usr/ports/Keywords/sample.ucl"
package-check: force
@if [ -f ${WRKDIR}/.mount_done ]; then \
echo ">>> Cannot continue with live mount. Please run 'make umount'." >&2; \
exit 1; \
fi
@if [ ! -f /usr/ports/Keywords/sample.ucl ]; then \
echo ">>> Missing required file(s). Please run 'make package-keywords'" >&2; \
exit 1; \
fi
package: package-check
@rm -rf ${WRKSRC}
@${MAKE} DESTDIR=${WRKSRC} FLAVOUR=${FLAVOUR} metadata
@${MAKE} DESTDIR=${WRKSRC} FLAVOUR=${FLAVOUR} install
@${PKG} create -v -m ${WRKSRC} -r ${WRKSRC} \
@PORTSDIR=${.CURDIR} ${PKG} create -v -m ${WRKSRC} -r ${WRKSRC} \
-p ${WRKSRC}/plist -o ${PKGDIR}
upgrade-check: force
......
......@@ -34,7 +34,7 @@ plist${TARGET}: force
@(cd ${TREE}; find * -type f ! -name "*.pyc") | while read FILE; do \
FILE="$${FILE%%.in}"; PREFIX=""; \
if [ -z "${NO_SAMPLE}" -a "$${FILE%%.sample}" != "$${FILE}" ]; then \
PREFIX="@sample "; \
PREFIX="@shadow "; \
fi; \
if [ -n "${NO_SAMPLE}" ]; then \
FILE="$${FILE%%.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