-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
98 lines (79 loc) · 3.39 KB
/
Makefile
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
.PHONY: all clean-package clean clean-all build help
VERSION=4.5.7
GRSEC_RELEASE=3.1-${VERSION}-201606202152
PATCHES=
N_CORES=`cat /proc/cpuinfo | grep 'core id' | sort | uniq | wc -l`
PKGNAME=linux-grsecurity
PKGREV=1
PKGSTAGING=${PKGNAME}_${VERSION}-${PKGREV}
all: ${PKGSTAGING}.deb
${PKGSTAGING}.deb: | ${PKGSTAGING}
dpkg-deb --build ${PKGSTAGING}
lintian $@
${PKGSTAGING}: linux-${VERSION}/arch/x86_64/boot/bzImage
rm -rf $@
mkdir $@
mkdir $@/boot $@/usr
cp -R DEBIAN $@/
for f in control preinst postinst prerm postrm; do \
sed "s/{{VERSION}}/${VERSION}/" -i "$@/DEBIAN/$$f"; done
for f in control preinst postinst prerm postrm; do \
sed "s/{{PKGREV}}/${PKGREV}/" -i "$@/DEBIAN/$$f"; done
install -m644 linux-${VERSION}/arch/x86_64/boot/bzImage $@/boot/vmlinuz-${VERSION}-grsec
cd linux-${VERSION} && make modules_install INSTALL_MOD_PATH=../$@
cd linux-${VERSION} && make headers_install INSTALL_HDR_PATH=../$@/usr
depmod -b $@ ${VERSION}-grsec
rm $@/lib/modules/${VERSION}-grsec/build
install -m644 config $@/boot/config-${VERSION}-${PKGREV}
install -Dm644 copyright $@/usr/share/doc/${PKGNAME}/copyright
gzip -n9 changelog -c > $@/usr/share/doc/${PKGNAME}/changelog.Debian.gz
# This is best obtained from the ordinary firmware packages
rm -rf $@/lib/firmware
# Fix permissions
find ./$@/lib -type f -exec chmod 644 {} \;
find ./$@/usr -type f -exec chmod 644 {} \;
find ./$@ -type d -exec chmod 755 {} \;
find ./$@/DEBIAN -type f -executable -exec chmod 755 {} \;
find ./$@/DEBIAN -type f -perm 664 -exec chmod 644 {} \;
chmod 600 ./$@/boot/vmlinuz-${VERSION}-grsec
linux-${VERSION}/arch/x86_64/boot/bzImage: | linux-${VERSION}
cd linux-${VERSION} && make -j${N_CORES}
touch $@
linux-${VERSION}: linux-${VERSION}.tar grsecurity-${GRSEC_RELEASE}.patch
rm -rf $@
tar -xf linux-${VERSION}.tar
cd $@ && patch -p1 -i ../grsecurity-${GRSEC_RELEASE}.patch && for patch in ${PATCHES}; do patch -p1 -i ../patches/$$patch; done
cp config $@/.config
linux-${VERSION}.tar: linux-${VERSION}.tar.xz linux-${VERSION}.tar.sign
xz -kdf linux-${VERSION}.tar.xz
touch $@
gpg --verify linux-${VERSION}.tar.sign linux-${VERSION}.tar || rm -f $@
linux-${VERSION}.tar.sign:
curl -OL https://cdn.kernel.org/pub/linux/kernel/v4.x/$@
linux-${VERSION}.tar.xz:
curl -OL https://cdn.kernel.org/pub/linux/kernel/v4.x/$@
grsecurity-${GRSEC_RELEASE}.patch: grsecurity-${GRSEC_RELEASE}.patch.sig
curl -OL http://grsecurity.net/test/$@
gpg --verify [email protected] $@ || rm -f $@
grsecurity-${GRSEC_RELEASE}.patch.sig:
curl -OL http://grsecurity.net/test/$@
clean-package:
rm -rf ${PKGSTAGING} ${PKGSTAGING}.deb
clean: clean-package
rm -rf linux-${VERSION}
clean-all: clean
rm -rf linux-${VERSION}.tar \
linux-${VERSION}.tar.sign \
linux-${VERSION}.tar.xz \
grsecurity-${GRSEC_RELEASE}.patch \
grsecurity-${GRSEC_RELEASE}.patch.sig
help:
@echo "Build Targets"
@echo " all - Build the package ${PKGSTAGING}.deb"
@echo " ${PKGSTAGING} - Extract, patch, compile, and create install directory"
@echo " linux-${VERSION} - Just extract the source archive and apply patches"
@echo
@echo "Clean Targets"
@echo " clean-package - Remove only the package and install directory"
@echo " clean - Remove the above, as well as the source directory"
@echo " clean-all - Purge all artifacts"