blob: c20a441b65da31e61de43160c87ce4c95fadcd78 (
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
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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
|
#!/bin/sh
# $FreeBSD$
this=`echo -n $0 | /usr/bin/sed -e 's!^.*/!!'`
PERL_VERSION="%%PERL_VERSION%%"
MAKE_CONF=%%MAKE_CONF%%
banner=`date +"%F %T"`
banner="# added by use.perl $banner"
if [ -z "${OSVERSION}" ]; then
if [ -f /sbin/sysctl -a -x /sbin/sysctl ] ; then
osreldate=`/sbin/sysctl -n kern.osreldate`
else
osreldate=`/usr/sbin/sysctl -n kern.osreldate`
fi
else
osreldate=${OSVERSION}
fi
if [ "x$this" = "xuse.perl" ]; then
PKG_PREFIX="%%PREFIX%%"
if [ "$1" = "port" ] ; then
need_remove_links=yes
need_create_links=yes
need_cleanup_make_conf=yes
need_cleanup_manpath=yes
need_spam_make_conf=yes
need_spam_manpath=yes
elif [ "$1" = "system" ] ; then
need_remove_links=yes
if [ $osreldate -lt 500036 ] ; then
need_base_system_perl=yes
fi
need_cleanup_make_conf=yes
need_cleanup_manpath=yes
else
echo 'Usage:
$0 port -> /usr/bin/perl is the perl5 port
$0 system -> /usr/bin/perl is the system perl'
exit 2;
fi
else
if [ "$2" = "POST-INSTALL" ] ; then
need_remove_links=yes
if [ $osreldate -ge 502100 ] ; then
need_create_links=yes
need_cleanup_make_conf=yes
need_cleanup_manpath=yes
need_spam_make_conf=yes
need_spam_manpath=yes
fi
need_post_install=yes
elif [ "$2" = "POST-DEINSTALL" ] ; then
need_remove_links=yes
if [ $osreldate -lt 500036 ] ; then
need_base_system_perl=yes
fi
need_cleanup_make_conf=yes
need_cleanup_manpath=yes
else
exit 0;
fi
fi
link_list="
a2p
c2ph
find2perl
h2ph
h2xs
perlbug
perlcc
perldoc
pl2pm
pod2html
pod2latex
pod2man
pod2text
s2p
splain"
if [ $osreldate -ge 500036 ] ; then
link_list=""
fi
special_link_list="
perl
perl5
suidperl"
do_remove_links()
{
echo "Removing stale symlinks from /usr/bin..."
for binary in $link_list $special_link_list
do
if [ -L "/usr/bin/$binary" ] ; then
echo " Removing /usr/bin/$binary"
/bin/rm -f "/usr/bin/$binary"
else
echo " Skipping /usr/bin/$binary"
fi
done
bins=`/bin/ls /usr/bin/*perl*5.* ${PKG_PREFIX}/bin/*perl*5.* 2>/dev/null`
for binary in $bins
do
if [ -L "$binary" ] ; then
echo " Removing $binary installed by an older perl port"
/bin/rm -f "$binary"
fi
done
echo "Done."
}
do_create_links()
{
echo "Creating various symlinks in /usr/bin..."
for binary in $link_list
do
if [ -f "/usr/bin/$binary" ] ; then
echo " Backing up /usr/bin/$binary as /usr/bin/$binary.freebsd"
/bin/mv -f "/usr/bin/$binary" "/usr/bin/$binary.freebsd"
fi
if [ -e "/usr/bin/$binary" ] ; then
echo " *** /usr/bin/$binary is still there, which should not happen"
elif [ -e "$PKG_PREFIX/bin/$binary" ] ; then
echo " Symlinking $PKG_PREFIX/bin/$binary to /usr/bin/$binary"
/bin/ln -sf "$PKG_PREFIX/bin/$binary" "/usr/bin/$binary"
else
echo " *** $PKG_PREFIX/bin/$binary is not there, a symlink won't do any good"
fi
done
for binary in $special_link_list
do
if [ -f "/usr/bin/$binary" ] ; then
echo " Removing /usr/bin/$binary"
fi
bin=`echo $binary | /usr/bin/sed -e 's!perl5!perl!'`
bin=`echo $bin | /usr/bin/sed -e 's!suidperl!sperl!'`
if [ -e "/usr/bin/$binary.XXX" ] ; then
echo " *** /usr/bin/$binary is still there, which should not happen"
elif [ -e "$PKG_PREFIX/bin/${bin}%%PERL_VERSION%%" ] ; then
echo " Symlinking $PKG_PREFIX/bin/${bin}%%PERL_VERSION%% to /usr/bin/$binary"
/bin/ln -sf "$PKG_PREFIX/bin/${bin}%%PERL_VERSION%%" "/usr/bin/$binary"
else
echo " *** $PKG_PREFIX/bin/${bin}%%PERL_VERSION%% is not there, a symlink won't do any good"
fi
done
echo "Done."
}
do_base_system_perl()
{
echo "Restoring base system perl binaries..."
for binary in $link_list
do
if [ -e "/usr/bin/$binary" ] ; then
echo " *** /usr/bin/$binary is there, which should not happen"
else
if [ -f "/usr/bin/$binary.freebsd" ] ; then
echo " Moving /usr/bin/$binary.freebsd to /usr/bin/$binary"
/bin/mv -f "/usr/bin/$binary.freebsd" "/usr/bin/$binary"
else
echo " *** /usr/bin/$binary.freebsd is NOT there, nothing to restore"
fi
fi
done
for binary in $special_link_list
do
if [ -e "/usr/bin/$binary" ] ; then
echo " *** /usr/bin/$binary is there, which should not happen"
else
bin=`echo $binary | /usr/bin/sed -e 's!perl5!perl!'`
bin=`echo $bin | /usr/bin/sed -e 's!suidperl!sperl!'`
bins=`/bin/ls /usr/bin/${bin}5.* 2>/dev/null | /usr/bin/sort`
bin=""
for b in $bins
do
if [ -f $b -a ! -L $b ] ; then
bin=$b
fi
done
if [ -z $bin ] ; then
echo " *** cannot find what /usr/bin/$binary shall be restored FROM"
elif [ -f $bin ] ; then
echo " Hardlinking $bin to /usr/bin/$binary"
ln -f "$bin" "/usr/bin/$binary"
else
echo " *** $bin is NOT there, nothing to restore"
fi
fi
done
echo "Done."
}
do_post_install()
{
INCLUDEDIR=/usr/include
install -d ${PKG_PREFIX}/lib/perl5/site_perl/%%PERL_VERSION%%/%%PERL_ARCH%%/auto
install -d ${PKG_PREFIX}/lib/perl5/site_perl/%%PERL_VERSION%%/auto
install -d ${PKG_PREFIX}/lib/perl5/%%PERL_VERSION%%/man/man3
cd ${INCLUDEDIR} && ${PKG_PREFIX}/bin/h2ph *.h machine/*.h sys/*.h >/dev/null
}
do_cleanup_make_conf()
{
echo -n "Cleaning up ${MAKE_CONF}..."
if [ -f ${MAKE_CONF} ] ; then
/usr/bin/awk 's=0;
/^#.*use.perl/ { s=1; mode=1 }
/^#/ { s=1; if (mode != 1) { mode=0 } }
/.*PERL.*=/ { s=1; if (mode == 1) { mode=2 } }
/^$/ { s=1; if (mode != 2) { mode = 0 } }
{ if (s != 1) { mode = 0 } if (mode == 0) print }' ${MAKE_CONF} >${MAKE_CONF}.new
/bin/mv ${MAKE_CONF} ${MAKE_CONF}.bak
/bin/mv ${MAKE_CONF}.new ${MAKE_CONF}
fi
echo " Done."
}
do_cleanup_manpath()
{
echo -n "Cleaning up /etc/manpath.config..."
if [ -f /etc/manpath.config ] ; then
/usr/bin/awk 's=0;
/^#.*use.perl/ { s=1; mode=1 }
/^#/ { s=1; if (mode != 1) { mode=0 } }
/^OPTIONAL_MANPATH.*perl5/ { s=1; if (mode == 1) { mode=2 } }
/^$/ { s=1; if (mode != 2) { mode = 0 } }
{ if (s != 1) { mode = 0 } if (mode == 0) print }' /etc/manpath.config >/etc/manpath.config.new
/bin/mv /etc/manpath.config /etc/manpath.config.bak
/bin/mv /etc/manpath.config.new /etc/manpath.config
fi
echo " Done."
}
do_spam_make_conf()
{
echo -n "Spamming ${MAKE_CONF}..."
echo "$banner" >>${MAKE_CONF}
echo "PERL_VER=%%PERL_VER%%" >>${MAKE_CONF}
echo "PERL_VERSION=%%PERL_VERSION%%" >>${MAKE_CONF}
if [ $osreldate -lt 500036 ] ; then
echo "NOPERL=yes" >>${MAKE_CONF}
fi
echo " Done."
}
do_spam_manpath()
{
echo -n "Spamming /etc/manpath.config..."
echo "$banner" >>/etc/manpath.config
echo "OPTIONAL_MANPATH ${PKG_PREFIX}/lib/perl5/%%PERL_VERSION%%/man" >>/etc/manpath.config
echo "OPTIONAL_MANPATH ${PKG_PREFIX}/lib/perl5/%%PERL_VERSION%%/perl/man" >>/etc/manpath.config
echo " Done."
}
[ $need_remove_links ] && do_remove_links
[ $need_create_links ] && do_create_links
[ $need_base_system_perl ] && do_base_system_perl
[ $need_post_install ] && do_post_install
[ $need_cleanup_make_conf ] && do_cleanup_make_conf
[ $need_spam_make_conf ] && do_spam_make_conf
[ $need_cleanup_manpath ] && do_cleanup_manpath
[ $need_spam_manpath ] && do_spam_manpath
exit 0
|