Prune www/mod_extract_forwarded
[dports.git] / Keywords / pkg_install.awk
1 # $FreeBSD$
2 #
3 # MAINTAINER: portmgr@FreeBSD.org
4 #
5 # This file handles converting keywords to pkg_install compatible format.
6 # It will be removed once pkg_install is EOL.
7 #
8
9 #  @sample somefile.conf.sample
10 # ->
11 #  @comment begin @sample somefile.conf.sample
12 #  @unexec if cmp -s %D/etc/somefile.conf %D/etc/somefile.conf.sample; then rm -f %D/etc/somefile.conf; fi
13 #  etc/somefile.conf.sample
14 #  @exec if ! [ -f %D/etc/somefile.conf ]; then cp %D/etc/somefile.conf.sample %D/etc/somefile.conf; fi
15 #  @comment end @sample somefile.conf.sample
16
17 ##
18 #  @shell bin/shell
19 # ->
20 #  @comment begin @shell bin/shell
21 #  @exec cp /etc/shells /etc/shells.bak; (grep -v %D/%F /etc/shells.bak; echo %D/%F) >/etc/shells; rm -f /etc/shells.bak
22 #  @unexec cp /etc/shells /etc/shells.bak; (grep -v %D/%F /etc/shells.bak) >/etc/shells; rm -f /etc/shells.bak
23 #  @comment end @shell bin/shell
24
25 $1 == "@sample" {
26         sample_file=$2
27         # Take out .sample
28         target_file=substr(sample_file, 0, length(sample_file) - 7)
29         print "@comment begin " $0
30         print "@unexec if cmp -s '%D/" target_file "' '%D/" sample_file "'; then rm -f '%D/" target_file "'; fi"
31         print sample_file
32         print "@exec if ! [ -f '%D/" target_file "' ]; then /bin/cp -p '%D/" sample_file "' '%D/" target_file "'; fi"
33         print "@comment end " $0
34         next
35 }
36
37 $1 == "@shell" {
38         shell_file=$2
39         print "@comment begin " $0
40         print shell_file
41         print "@exec cp /etc/shells /etc/shells.bak; (grep -v %D/%F /etc/shells.bak; echo %D/%F) >/etc/shells; rm -f /etc/shells.bak"
42         print "@unexec cp /etc/shells /etc/shells.bak; (grep -v %D/%F /etc/shells.bak) >/etc/shells; rm -f /etc/shells.bak"
43         print "@comment end " $0
44         next
45 }
46
47 $1 == "@fc" {
48         font_dir=$2
49         print "@comment begin " $0
50         print "@exec fc-cache -s %D/" font_dir " 2>/dev/null || true"
51         print "@unexec fc-cache -s %D/" font_dir " 2>/dev/null || true"
52         print "@unexec rmdir %D/"font_dir" 2>/dev/null || true"
53         print "@comment end " $0
54         next
55 }
56
57 $1 == "@fcfontsdir" {
58         font_dir=$2
59         print "@comment begin " $0
60         print "@exec fc-cache -s %D/" font_dir " 2>/dev/null || true"
61         print "@exec mkfontscale %D/" font_dir " 2>/dev/null || true"
62         print "@exec mkfontdir %D/" font_dir " 2>/dev/null || true"
63         print "@unexec fc-cache -s %D/" font_dir " 2>/dev/null || true"
64         print "@unexec mkfontscale %D/" font_dir " 2>/dev/null || true"
65         print "@unexec if [ -e %D/%@/fonts.scale -a \"`stat -f '%%z' %D/" font_dir "/fonts.scale 2>/dev/null`\" = '2' ]; then rm %D/" font_dir "/fonts.scale ; fi"
66         print "@unexec mkfontdir %D/" font_dir " 2>/dev/null || true"
67         print "@unexec if [ -e %D/" font_dir "/fonts.dir -a \"`stat -f '%%z' %D/" font_dir "/fonts.dir 2>/dev/null`\" = '2' ]; then rm %D/" font_dir "/fonts.dir ; fi"
68         print "@unexec rmdir %D/"font_dir" 2>/dev/null || true"
69         print "@comment end " $0
70         next
71 }
72
73 $1 == "@fontsdir" {
74         font_dir=$2
75         print "@comment begin " $0
76         print "@exec mkfontscale %D/" font_dir " 2>/dev/null || true"
77         print "@exec mkfontdir %D/" font_dir " 2>/dev/null || true"
78         print "@unexec mkfontscale %D/" font_dir " 2>/dev/null || true"
79         print "@unexec if [ -e %D/%@/fonts.scale -a \"`stat -f '%%z' %D/" font_dir "/fonts.scale 2>/dev/null`\" = '2' ]; then rm %D/" font_dir "/fonts.scale ; fi"
80         print "@unexec mkfontdir %D/" font_dir " 2>/dev/null || true"
81         print "@unexec if [ -e %D/" font_dir "/fonts.dir -a \"`stat -f '%%z' %D/" font_dir "/fonts.dir 2>/dev/null`\" = '2' ]; then rm %D/" font_dir "/fonts.dir ; fi"
82         print "@unexec rmdir %D/"font_dir" 2>/dev/null || true"
83         print "@comment end " $0
84         next
85 }
86
87 $1 == "@dirrmtry" {
88         directory=substr($0, 11, length($0) - 10)
89         print "@comment begin " $0
90         if ($2 ~ /^\//) {
91                 print "@unexec rmdir \"" directory "\" 2>/dev/null || true"
92         } else {
93                 print "@unexec rmdir \"%D/" directory "\" 2>/dev/null || true"
94         }
95         print "@comment end " $0
96         next
97 }
98
99 # Print everything else as-is
100 {
101   print $0
102 }