Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F146592652
D23617.id68108.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D23617.id68108.diff
View Options
Index: Keywords/sample.ucl
===================================================================
--- Keywords/sample.ucl
+++ Keywords/sample.ucl
@@ -20,42 +20,56 @@
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
- if cmp -s "${target_file}" "${sample_file}"; then
- rm -f "${target_file}"
+post-install-lua: <<EOS
+ sample_file = pkg.prefixed_path("%1", "%D")
+ _,n = string.gsub("%@", "%S+","")
+ if n == 2 then
+ target_file = pkg.prefixed_path("%1", "%D")
else
- echo "You may need to manually remove ${target_file} if it is no longer needed."
- fi
-EOD
+ target_file = string.gsub(sample_file,'%.sample$', "")
+ end
+ outh = io.open(target_file, "r")
+ if outh ~= nil then
+ io.close(outh)
+ return
+ end
+ outh = io.open(target_file, "w+")
+ for line in io.lines(sample_file) do
+ outh:write(line, "\n")
+ end
+ io.close(outh)
+EOS
+
+pre-deinstall-lua: <<EOS
+ sample_file = pkg.prefixed_path("%1")
+ _,n = string.gsub("%@", "%S+","")
+ if n == 2 then
+ target_file = pkg.prefixed_path("%1")
+ else
+ target_file = string.gsub(sample_file, '%.sample$', "")
+ end
+
+ outh = io.open(target_file, "r")
+ inh = io.open(sample_file, "r")
+ sizeout = outh:seek("end")
+ sizein = inh:seek("end")
+ if sizeout ~= sizein then
+ pkg.print_msg("You may need to manually remove " .. target_file .. " if it is no longer needed.")
+ return
+ end
+ inh:seek("set", 0)
+ outh:seek("set", 0)
+ linein = inh:read("l")
+ lineout = outh:read("l")
+ while (linein == lineout and linein ~= nil and lineout ~= nil) do
+ linein = inh:read("l")
+ lineout = outh:read("l")
+ end
+ io.close(inh)
+ io.close(outh)
+ if linein == lineout 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
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Mar 4, 10:35 PM (18 h, 44 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
29258819
Default Alt Text
D23617.id68108.diff (2 KB)
Attached To
Mode
D23617: Lua version of the @sample
Attached
Detach File
Event Timeline
Log In to Comment