mirror of
https://git.FreeBSD.org/ports.git
synced 2024-12-30 05:40:06 +00:00
f1d81cf365
pkg doesn't accept expanding %X when the argument doesn't exists. Some how neither my testing or the exp-run (PR 249035) catched that. Approved by: portmgr (bapt@)
56 lines
1.5 KiB
Plaintext
56 lines
1.5 KiB
Plaintext
# $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-lua: <<EOS
|
|
args = {}
|
|
for arg in string.gmatch("%@", "%S+") do
|
|
table.insert(args, arg)
|
|
end
|
|
sample_file = pkg.prefixed_path(args[1])
|
|
if args[2] == nil then
|
|
target_file = string.gsub(sample_file,'%.sample$', "")
|
|
else
|
|
target_file = pkg.prefixed_path(args[2])
|
|
end
|
|
if not pkg.stat(target_file) then
|
|
pkg.copy(sample_file, target_file)
|
|
end
|
|
EOS
|
|
|
|
pre-deinstall-lua: <<EOS
|
|
args = {}
|
|
for arg in string.gmatch("%@", "%S+") do
|
|
table.insert(args, arg)
|
|
end
|
|
sample_file = pkg.prefixed_path(args[1])
|
|
if args[2] == nil then
|
|
target_file = string.gsub(sample_file,'%.sample$', "")
|
|
else
|
|
target_file = pkg.prefixed_path(args[2])
|
|
end
|
|
if pkg.filecmp(sample_file, target_file) == 0 then
|
|
os.remove(target_file)
|
|
else
|
|
pkg.print_msg("You may need to manually remove " .. target_file .. " if it is no longer needed.")
|
|
end
|
|
EOS
|