aboutsummaryrefslogtreecommitdiffstats
path: root/Keywords/pkg_install.awk
blob: 7128dfb06f46d2cb85ec0f8ffdc92f5d913f2101 (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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# $FreeBSD$
#
# MAINTAINER: portmgr@FreeBSD.org
#
# This file handles converting keywords to pkg_install compatible format.
# It will be removed once pkg_install is EOL.
#

#  @sample somefile.conf.sample
# ->
#  @comment begin @sample somefile.conf.sample
#  @unexec if cmp -s %D/etc/somefile.conf %D/etc/somefile.conf.sample; then rm -f %D/etc/somefile.conf; fi
#  etc/somefile.conf.sample
#  @exec if ! [ -f %D/etc/somefile.conf ]; then cp %D/etc/somefile.conf.sample %D/etc/somefile.conf; fi
#  @comment end @sample somefile.conf.sample
# 
##
#  @shell bin/shell
# ->
#  @comment begin @shell bin/shell
#  @exec cp /etc/shells /etc/shells.bak; (grep -v %D/%F /etc/shells.bak; echo %D/%F) >/etc/shells; rm -f /etc/shells.bak
#  @unexec cp /etc/shells /etc/shells.bak; (grep -v %D/%F /etc/shells.bak) >/etc/shells; rm -f /etc/shells.bak
#  @comment end @shell bin/shell

$1 == "@sample" {
    sample_file=$2
    # Take out .sample
    target_file=substr(sample_file, 0, length(sample_file) - 7)
    print "@comment begin " $0
    print "@unexec if cmp -s '%D/" target_file "' '%D/" sample_file "'; then rm -f '%D/" target_file "'; fi"
    print sample_file
    print "@exec if ! [ -f '%D/" target_file "' ]; then /bin/cp -p '%D/" sample_file "' '%D/" target_file "'; fi"
    print "@comment end " $0
    next
}

$1 == "@shell" {
    shell_file=$2
    print "@comment begin " $0
    print shell_file
    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"
    print "@unexec cp /etc/shells /etc/shells.bak; (grep -v %D/%F /etc/shells.bak) >/etc/shells; rm -f /etc/shells.bak"
    print "@comment end " $0
    next
}

$1 == "@fc" {
    font_dir=$2
    print "@comment begin " $0
    print "@exec fc-cache -s %D/" font_dir " 2>/dev/null || true"
    print "@unexec fc-cache -s %D/" font_dir " 2>/dev/null || true"
    print "@unexec rmdir %D/"font_dir" 2>/dev/null || true"
    print "@comment end " $0
    next
}

$1 == "@fcfontsdir" {
    font_dir=$2
    print "@comment begin " $0
    print "@exec fc-cache -s %D/" font_dir " 2>/dev/null || true"
    print "@exec mkfontscale %D/" font_dir " 2>/dev/null || true"
    print "@exec mkfontdir %D/" font_dir " 2>/dev/null || true"
    print "@unexec fc-cache -s %D/" font_dir " 2>/dev/null || true"
    print "@unexec mkfontscale %D/" font_dir " 2>/dev/null || true"
    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"
    print "@unexec mkfontdir %D/" font_dir " 2>/dev/null || true"
    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"
    print "@unexec rmdir %D/"font_dir" 2>/dev/null || true"
    print "@comment end " $0
    next
}

$1 == "@fontsdir" {
    font_dir=$2
    print "@comment begin " $0
    print "@exec mkfontscale %D/" font_dir " 2>/dev/null || true"
    print "@exec mkfontdir %D/" font_dir " 2>/dev/null || true"
    print "@unexec mkfontscale %D/" font_dir " 2>/dev/null || true"
    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"
    print "@unexec mkfontdir %D/" font_dir " 2>/dev/null || true"
    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"
    print "@unexec rmdir %D/"font_dir" 2>/dev/null || true"
    print "@comment end " $0
    next
}

$1 == "@dirrmtry" {
    directory=substr($0, 11, length($0) - 10)
    print "@comment begin " $0
    if ($2 ~ /^\//) {
        print "@unexec rmdir \"" directory "\" 2>/dev/null || true"
    } else {
        print "@unexec rmdir \"%D/" directory "\" 2>/dev/null || true"
    }
    print "@comment end " $0
    next
}

# Print everything else as-is
{
  print $0
}