Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F148879789
D3734.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
D3734.diff
View Options
Index: head/CHANGES
===================================================================
--- head/CHANGES
+++ head/CHANGES
@@ -10,7 +10,16 @@
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:
Index: head/Keywords/sample.ucl
===================================================================
--- head/Keywords/sample.ucl
+++ head/Keywords/sample.ucl
@@ -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
Index: head/Mk/Scripts/functions.sh
===================================================================
--- head/Mk/Scripts/functions.sh
+++ head/Mk/Scripts/functions.sh
@@ -82,17 +82,22 @@
@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\ *)
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Mar 21, 6:00 PM (20 h, 22 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
30084419
Default Alt Text
D3734.diff (3 KB)
Attached To
Mode
D3734: Allow @sample to take arguments
Attached
Detach File
Event Timeline
Log In to Comment