summaryrefslogtreecommitdiffstats
path: root/t/recipes/checks/maintainer-scripts/empty/legacy-maintainer-scripts/build-spec/debian/postinst
blob: e56ed3bfea3737a30c8749c2dd82f457128da4f4 (plain)
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
#! /bin/sh -e

if [ "$1" = "configure" ]; then
        if [ -d /usr/doc -a ! -e /usr/doc/maintainer-scripts -a -d /usr/share/doc/maintainer-scripts ]; then
                ln -sf ../share/doc/maintainer-scripts /usr/doc/maintainer-scripts
        fi
fi

# valid
. /usr/share/lintian/shell || exit 0
. /usr/share/lintian/shell >/dev/null
. /usr/share/lintian/shell 2>/dev/null
. /usr/share/lintian/shell </dev/null
. "$(dirname $0)/shell" ; bar
# invalid
. /usr/share/lintian/shell foo
. "$(dirname $0)/shell" bar

print "Hit enter to continue"
read

H[0]='this is a string'
echo ${H[0]}
echo "Index 0's length is ${#H[0]}"
echo "All of the array is: ${H[@]}"

install-info /usr/share/info/foo \
	--quiet \ # make it so
	--section foo

echo Please use update-rc.d or invoke-rc.d to set up blah blah.

chown root.root /usr/share/doc/maintainer-scripts/changelog
chown root:root /usr/share/doc/maintainer-scripts/changelog

$FOO=bar
update-rc.d foo defaults >/dev/null
update-rc.d $FOO defaults
update-rc.d foo remove

# valid
FOO=/tmp
FOO=/var/tmp
: ${FOO:=/tmp}
FOO=`mktemp /tmp/scripts.XXXXXX`
rm "$FOO"
FOO=`tempfile -n/tmp/scripts.tmp`
mkdir /var/tmp/scripts
FOO="/tmp/false.positive.XXXXXX"
# invalid
echo foo >>/tmp/scripts.tmp
rm /tmp/scripts.tmp
rmdir /var/tmp/scripts

# invalid, maintainer-script-hides-init-failure
invoke-rc.d foo start || exit 0

# The right way to invoke an rc script
if which invoke-rc.d >/dev/null 2>&1; then
    invoke-rc.d package start
else
    /etc/init.d/package start
fi

# Example ucf invocation.
ucf /usr/share/foo/configuration /etc/foo.conf

# Calling gconftool directly.
gconftool-2 --makefile-install-rule foo.schema

# Calling gconf-schemas with no dependency.
gconf-schemas --register foo.schema

# Calling update-xmlcatalog with no dependency.
update-xmlcatalog --add --type system --id "/usr/share/sgml/dtd/foo" \
    --package maintainer-scripts --root

# Maintainer scripts shouldn't touch /var/lib/dpkg/status.  This is the old
# recipe from the dpkg wiki that should be replaced with dpkg-query.
sed -n -e \"/^Conffiles:/,/^[^ ]/{\\\\' /etc/conffile'{s/.* //;p}}\" \
    /var/lib/dpkg/status

# Don't modify these files.
echo 'broken    6714/tcp' >> /etc/services
cp /nonexistent /etc/protocols
mv /usr/share/doc/rpc /etc/rpc

# But this is okay.
cp /etc/protocols /etc/protocols.new

# This is also wrong.
echo 'broken' > /etc/inetd.conf
cp /etc/inetd.conf.new /etc/inetd.conf

# But this is fine.
cp /etc/inetd.conf /srv/chroot/etc/inetd.conf

# Deprecated
install-sgmlcatalog --install package
install-sgmlcatalog --remove package

# This too is a heredoc.
some-program > /etc/config-file <<'EOF'
echo "All of the array is: ${H[@]}"
EOF

# But this isn't.
cat '<<EOF'
echo "All of the array is: ${H[@]}"
EOF

# This is a heredoc
cat <<-EOF
echo "All of the array is ${H[@]}"
EOF

# As is this
cat <<';'
echo "All of the array is ${H[@]}"
;

# and this
cat <<foo
echo "All of the array is ${H[@]}"
foobar
echo $HOSTNAME
foo

# and again
cat <<\bar
echo "All of the array is ${H[@]}"
bar

# yet another
cat <<"x++"
echo "All of the array is ${H[@]}"
x++

# Recognize single quotes even if they start at the beginning of a line.
echo not a bashism \
'/{ptex,tex}/{amstex,plain,generic,}'

# More bashisms.
echo -e 'foo\n'
echo "${!foo}"
cat $(\< file)
select foo in a b ; do echo $foo ; done
cnt=$((cnt + 1))
if false ; then
    exec -l /bin/sh
    exec -c /bin/sh
    exec -a foo /bin/sh
fi
let cnt++
if test -a /etc/default ; then
    echo "$RANDOM|stuff"
fi

# Calling start-stop-daemon directly in an init script.
start-stop-daemon --start --quiet --name foo --startas /usr/bin/foo

# But stopping it is fine -- we may be working around something else.
start-stop-daemon --stop --quiet --name foo --startas /usr/bin/foo

# Deprecated chown use with flags.
chown -R root.root /usr/share/doc/maintainer-scripts

case $mainscript in
	/usr/bin/foo) foobarbaz;;
esac

/usr/bin/baz; echo bar

# Some comment checking
# This should flag $RANDOM
test $# -gt 2 && echo $RANDOM
# But these shouldn't
test 1=1 # echo $RANDOM
(test 1=1)# echo $RANDOM
test 1=1;# echo $RANDOM
backgroundtask &#echo $RA