Extend @sample to accept arguments
Maintainers can now use @sample sample_file target_file for all cases that does not fall into the usual @sample something.sample Reviewed by: antoine Differential Revision: https://reviews.freebsd.org/D3734
This commit is contained in:
parent
ce1853bf02
commit
5adc8a9faa
Notes:
svn2git
2021-03-31 03:12:20 +00:00
svn path=/head/; revision=397963
11
CHANGES
11
CHANGES
@ -10,7 +10,16 @@ in the release notes and/or placed into UPDATING.
|
||||
|
||||
All ports committers are allowed to commit to this file.
|
||||
|
||||
20150926
|
||||
20150926:
|
||||
AUTHOR: bapt@FreeBSD.org
|
||||
|
||||
@sample now accept arguments, so it can now be used the following way:
|
||||
|
||||
@sample afile.sample
|
||||
or
|
||||
@sample path/to/example etc/target
|
||||
|
||||
20150926:
|
||||
AUTHOR: bapt@FreeBSD.org
|
||||
|
||||
New keywords are supported in pkg since 1.5.x:
|
||||
|
@ -3,6 +3,10 @@
|
||||
# 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
|
||||
@ -14,24 +18,42 @@
|
||||
# etc/pkgtools.conf.sample
|
||||
# @exec [ -f %B/pkgtools.conf ] || cp %B/%f %B/pkgtools.conf
|
||||
|
||||
actions: [file]
|
||||
actions: [file(1)]
|
||||
arguments: true
|
||||
post-install: <<EOD
|
||||
case "%@" in
|
||||
/*) sample_file="%@" ;;
|
||||
*) sample_file="%D/%@" ;;
|
||||
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}" && \
|
||||
/bin/chmod u+w "${target_file}"
|
||||
fi
|
||||
EOD
|
||||
pre-deinstall: <<EOD
|
||||
case "%@" in
|
||||
/*) sample_file="%@" ;;
|
||||
*) sample_file="%D/%@" ;;
|
||||
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
|
||||
|
@ -82,17 +82,22 @@ parse_plist() {
|
||||
@sample\ *)
|
||||
set -- $line
|
||||
shift
|
||||
# Ignore the actual file if it is in stagedir
|
||||
case "$@" in
|
||||
/*)
|
||||
echo "@comment ${@%.sample}"
|
||||
echo "${comment}$@"
|
||||
;;
|
||||
*)
|
||||
echo "@comment ${cwd}/${@%.sample}"
|
||||
echo "${comment}${cwd}/$@"
|
||||
;;
|
||||
sample_file=$1
|
||||
target_file=${1%.sample}
|
||||
if [ $# -eq 2 ]; then
|
||||
target_file=$2
|
||||
fi
|
||||
case "${sample_file}" in
|
||||
/*) ;;
|
||||
*) sample_file=${cwd}/${sample_file} ;;
|
||||
esac
|
||||
case "${target_file}" in
|
||||
/*) ;;
|
||||
*) target_file=${cwd}/${target_file} ;;
|
||||
esac
|
||||
# Ignore the actual file if it is in stagedir
|
||||
echo "@comment ${target_file}"
|
||||
echo "${comment}${sample_file}"
|
||||
;;
|
||||
# Handle [dir] Keywords
|
||||
@fc\ *|@fcfontsdir\ *|@fontsdir\ *)
|
||||
|
Loading…
Reference in New Issue
Block a user