aboutsummaryrefslogtreecommitdiff
path: root/Keywords/sample.ucl
blob: a1d7085dc24e1948c79f9508695483dd29ad4b97 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# $FreeBSD$
#
# MAINTAINER: portmgr@FreeBSD.org
#
# @sample etc/somefile.conf.sample
#
# 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]
post-install: <<EOD
  case "%@" in
  /*) sample_file="%@" ;;
  *) sample_file="%D/%@" ;;
  esac
  target_file="${sample_file%.sample}"
  if ! [ -f "${target_file}" ]; then
    /bin/cp -p "${sample_file}" "${target_file}"
  fi
EOD
pre-deinstall: <<EOD
  case "%@" in
  /*) sample_file="%@" ;;
  *) sample_file="%D/%@" ;;
  esac
  target_file="${sample_file%.sample}"
  if cmp -s "${target_file}" "${sample_file}"; then
    rm -f "${target_file}"
  fi
EOD