aboutsummaryrefslogtreecommitdiff
path: root/Keywords
diff options
context:
space:
mode:
authorEmmanuel Vadot <manu@FreeBSD.org>2020-10-02 08:58:44 +0000
committerEmmanuel Vadot <manu@FreeBSD.org>2020-10-02 08:58:44 +0000
commitf1d81cf365f774fe9cbd9aeb59a542aebdbe6edf (patch)
treeb6e1928829f35a32da7844b63ecb3a85e76e7f34 /Keywords
parentf2b4188cb704927fea2b7a69dd190d52e98bff05 (diff)
downloadports-f1d81cf365f774fe9cbd9aeb59a542aebdbe6edf.tar.gz
ports-f1d81cf365f774fe9cbd9aeb59a542aebdbe6edf.zip
Keywords: sample: Really fix the lua version
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@)
Notes
Notes: svn path=/head/; revision=551166
Diffstat (limited to 'Keywords')
-rw-r--r--Keywords/sample.ucl24
1 files changed, 16 insertions, 8 deletions
diff --git a/Keywords/sample.ucl b/Keywords/sample.ucl
index 818e833a2b5d..5022254bcfd2 100644
--- a/Keywords/sample.ucl
+++ b/Keywords/sample.ucl
@@ -21,11 +21,15 @@
actions: [file(1)]
arguments: true
post-install-lua: <<EOS
- sample_file = pkg.prefixed_path("%1")
- if "%#" == 2 then
- target_file = pkg.prefixed_path("%2")
- else
+ 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)
@@ -33,11 +37,15 @@ post-install-lua: <<EOS
EOS
pre-deinstall-lua: <<EOS
- sample_file = pkg.prefixed_path("%1")
- if "%#" == 2 then
- target_file = pkg.prefixed_path("%2")
- else
+ 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)