-
Notifications
You must be signed in to change notification settings - Fork 3
/
install
98 lines (88 loc) · 2.63 KB
/
install
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
#!/bin/ksh
#
# Copyright (c) 2020 - 2024 Matthias Pressfreund
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#
srcroot='/usr/src'
srcdir=${srcroot}/usr.sbin/httpd
chksum='0a978cba1df7dacc0ed36eed89fea475088b28b7de845b487efc50d2b607aad6'
restore()
{
echo -n 'Restoring original sources ... '
cd ${srcdir}/..
rm -rf ${srcdir} && mv $1 ${srcdir}
(($? == 0)) && echo 'Done.' || echo 'Failed.'
}
if (($(id -u) != 0)); then
echo 'Need root privileges.'
exit 1
fi
if [[ ! -d ${srcdir} ]]; then
echo 'Missing source tree.'
exit 1
fi
chksum0=$(find ${srcdir} \( -name '*.[chy578]' -o -name '*.in' \
-o -name '*.sed' -o -name 'Makefile' \) -type f -maxdepth 1 -exec sha256 \
-q {} \; | sort | sha256)
if [[ ${chksum0} != ${chksum} ]]; then
echo 'Sources and patches do not match. Make sure ...'
echo ' ... the -current branch is in use.'
echo ' ... both are up-to-date.'
while :
do
echo -n 'Continue anyway (Not recommended!)? [y/N] '
read yn
case ${yn} in
y) break;;
*) echo 'Exiting.'; exit 1;;
esac
done
fi
echo -n 'Backing up original sources ... '
while :
do
bakdir=${srcdir}~$RANDOM
[[ -d ${bakdir} ]] || break
done
cp -a ${srcdir} ${bakdir}
if (($? == 0)); then
echo 'Done.'
else
echo 'Failed.'
exit 1
fi
echo 'Applying patch files ...'
for f in $(find $(pwd)/$(dirname $0) -type f -name '*.patch' | sort); do
addon=$(basename ${f} .patch)
len=$((${#addon}+10))
printf "%${len}s\n" | tr ' ' '='
printf '=== %s ===\n' "${addon}"
printf "%${len}s\n" | tr ' ' '='
patch -d ${srcroot} -f -i ${f} -p0 --posix
if (($? != 0)); then
restore ${bakdir}
exit 1
fi
done
cd ${srcdir}
echo 'Building and installing httpd-plus binary and manpage ...'
make clean && make obj && make && make install
ret=$?
restore ${bakdir}
if ((ret != 0)); then
echo "\nInstalling httpd-plus failed (exitcode: ${ret})."
exit 1
fi
echo '\nInstalling httpd-plus binary and manpage completed successfully.'
echo "Please consult 'man httpd.conf' for further information on new features."