blob: 951209e8640e2ae5b889bdba7b22ac13aed5be34 (
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
|
#!/bin/sh -euf
script=update-kernel
set -euf
# -----------------------------------------------------
# BASIC STUFF
is_yes()
{
case ${1-} in
[Yy][Ee][Ss]|[Yy]|[Tt][Rr][Uu][Ee])
return 0
;;
*)
return 1
;;
esac
}
empty()
{
case ${@:+1} in
'')
return 0
;;
*)
return 1
;;
esac
}
warn()
{
echo "$script: $@" >&2
}
fail()
{
echo "$script: $@" >&2
exit 1
}
# ------------------------------------------------------------
# Main action
usage()
{
echo "usage: $script [-vn] [-s server] [-B branch]" >&2
exit 2
}
supfile=/usr/src/cvsupfile-sys
server="cvsup2.FreeBSD.org"
version=`uname -r | sed -En 's/^([.0-9]+).*/\1/p'`
branch="RELENG_`echo $version | tr '.' '_'`"
csup="csup -L2"
patch="patch"
printf="printf"
patches="YES"
while getopts "B:ns:qv" arg; do
case $arg in
B)
branch="$OPTARG"
;;
n)
patches="NO"
;;
s)
server="$OPTARG"
;;
q)
csup="csup -L0"
printf="true"
;;
v)
;;
*)
usage
;;
esac
done
shift `expr $OPTIND - 1`
if [ $# -ne 0 ]; then
usage
fi
if empty $version; then
fail "couldn't determine OS version"
fi
if empty $branch; then
fail "couldn't determine cvsup branch"
fi
base=`dirname $0`
base=`realpath $base`
patchdir=$base/kernel-$version
if [ ! -d $patchdir ]; then
fail "patches directory does not exist: $patchdir"
fi
cat > $supfile << EOF
*default host=$server
*default base=/usr
*default prefix=/usr
*default release=cvs
*default tag=$branch
*default delete use-rel-suffix
src-sys
EOF
# Only allow up to 10 files to be deleted
$csup -d 10 $supfile
if is_yes $patches; then
# Allow globbing from here on out
set +f
cd $patchdir
for file in *; do
if [ -f "$file" ]; then
printf "Applying $file\n"
$patch -d /usr/src -p0 \
--forward --quiet --batch --fuzz=0 < $file
fi
done
fi
$printf "Done\n"
|