forked from fmarier/user-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
git-apply-grsec
executable file
·29 lines (26 loc) · 902 Bytes
/
git-apply-grsec
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
#!/bin/sh
#
# Apply a grsecurity patch over a kernel stored in git
if [ "z$1" = "z" ] ; then
echo "Usage: $0 <grsecurity-version>.patch"
exit 1;
elif [ ! -r "$1" ] ; then
echo "Cannot open file $1"
exit 2;
elif [ ! -r ".config" ] ; then
echo "You must run this script inside the source tree of a configured kernel."
exit 3;
fi
# Remove the last patch if necessary
NEEDS_RESET="$(git log --oneline | head -1 | grep 'Applied grsecurity' >/dev/null && echo yes)"
if [ "z$NEEDS_RESET" = "zyes" ] ; then
git reset --hard HEAD^
git clean -f
git clean -d -f
fi
fakeroot make-kpkg clean
(patch -p1 < "$1") || (echo "Failed to apply patch" && exit 1)
git add grsecurity/ include/linux/gr* localversion-grsec tools/
git add include/linux/netfilter net/netfilter scripts/gcc-plugin.sh
git add include/trace/events arch/x86/kernel
git commit -a -m "Applied $(basename "$1")"