From 83b5aae6c3728eea344e06488d60374b674e9b40 Mon Sep 17 00:00:00 2001 From: Franco Fichtner Date: Thu, 2 Mar 2017 07:02:25 +0100 Subject: [PATCH] pkg: second half of previous --- Keywords/sample.ucl | 61 +++++++++++++++++++++++++++++++++++++++++++++ Mk/tree.mk | 13 +++++++--- 2 files changed, 70 insertions(+), 4 deletions(-) create mode 100644 Keywords/sample.ucl diff --git a/Keywords/sample.ucl b/Keywords/sample.ucl new file mode 100644 index 000000000..9d3fc498f --- /dev/null +++ b/Keywords/sample.ucl @@ -0,0 +1,61 @@ +# $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: < +# Copyright (c) 2015-2017 Franco Fichtner # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions @@ -69,9 +69,14 @@ install-${TARGET}: force mv -v "${DESTDIR}${ROOT_${TARGET}}/${TREE}/$${FILE}" \ "${DESTDIR}${ROOT_${TARGET}}/${TREE}/$${FILE%%.sample}"; \ fi; \ - if [ -n "${NO_SAMPLE}" -a "$${FILE%%.shadow}" != "$${FILE}" ]; then \ - mv -v "${DESTDIR}${ROOT_${TARGET}}/${TREE}/$${FILE}" \ - "${DESTDIR}${ROOT_${TARGET}}/${TREE}/$${FILE%%.shadow}"; \ + 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