Update editors/libreoffice-sq to version 5.2.5
[dports.git] / Keywords / sample.ucl
1 # $FreeBSD: head/Keywords/sample.ucl 417335 2016-06-22 21:44:25Z bapt $
2 #
3 # MAINTAINER: portmgr@FreeBSD.org
4 #
5 # @sample etc/somefile.conf.sample
6 # or
7 # @sample file1 file2
8 #
9 # Where file1 is considered as a sample file and file2 the target file
10 #
11 # This will install the somefile.conf.sample and automatically copy to
12 # somefile.conf if it doesn't exist. On deinstall it will remove the
13 # somefile.conf if it still matches the sample, otherwise it is
14 # kept.
15 #
16 # This replaces the old pattern:
17 #  @unexec if cmp -s %D/etc/pkgtools.conf %D/etc/pkgtools.conf.sample; then rm -f %D/etc/pkgtools.conf; fi
18 #  etc/pkgtools.conf.sample
19 #  @exec [ -f %B/pkgtools.conf ] || cp %B/%f %B/pkgtools.conf
20
21 actions: [file(1)]
22 arguments: true
23 post-install: <<EOD
24   case "%1" in
25   /*) sample_file="%1" ;;
26   *) sample_file="%D/%1" ;;
27   esac
28   target_file="${sample_file%.sample}"
29   set -- %@
30   if [ $# -eq 2 ]; then
31       target_file=${2}
32   fi
33   case "${target_file}" in
34   /*) target_file="${target_file}" ;;
35   *) target_file="%D/${target_file}" ;;
36   esac
37   if ! [ -f "${target_file}" ]; then
38     /bin/cp -p "${sample_file}" "${target_file}"
39   fi
40 EOD
41 pre-deinstall: <<EOD
42   case "%1" in
43   /*) sample_file="%1" ;;
44   *) sample_file="%D/%1" ;;
45   esac
46   target_file="${sample_file%.sample}"
47   set -- %@
48   if [ $# -eq 2 ]; then
49       set -- %@
50       target_file=${2}
51   fi
52   case "${target_file}" in
53   /*) target_file="${target_file}" ;;
54   *) target_file="%D/${target_file}" ;;
55   esac
56   if cmp -s "${target_file}" "${sample_file}"; then
57     rm -f "${target_file}"
58   else
59     echo "You may need to manually remove ${target_file} if it is no longer needed."
60   fi
61 EOD