| 1 |
kumaneko |
155 |
#! /bin/sh |
| 2 |
|
|
# |
| 3 |
|
|
# This is kernel build script for ubuntu 12.04's 3.2 kernel. |
| 4 |
|
|
# |
| 5 |
|
|
|
| 6 |
|
|
update_maintainer () { |
| 7 |
|
|
for i in debian*/control debian*/control.stub* |
| 8 |
|
|
do |
| 9 |
|
|
cp -p $i $i.orig |
| 10 |
|
|
sed -i -e 's/Maintainer: .*/Maintainer: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>/' -- $i |
| 11 |
|
|
touch -r $i.orig $i |
| 12 |
|
|
rm $i.orig |
| 13 |
|
|
done |
| 14 |
|
|
} |
| 15 |
|
|
|
| 16 |
|
|
die () { |
| 17 |
|
|
echo $1 |
| 18 |
|
|
exit 1 |
| 19 |
|
|
} |
| 20 |
|
|
|
| 21 |
|
|
ORIGINAL_FLAVOUR=`uname -r | cut -d - -f 3-` # e.g. generic generic-pae server |
| 22 |
|
|
NEW_FLAVOUR=${ORIGINAL_FLAVOUR}-cs |
| 23 |
|
|
echo "Building "${NEW_FLAVOUR}" from "${ORIGINAL_FLAVOUR}"." |
| 24 |
|
|
|
| 25 |
|
|
export CONCURRENCY_LEVEL=`grep -c '^processor' /proc/cpuinfo` || die "Can't export." |
| 26 |
|
|
|
| 27 |
|
|
apt-get -y install wget |
| 28 |
|
|
|
| 29 |
|
|
# Download CaitSith patches. |
| 30 |
kumaneko |
203 |
mkdir -p ~/rpmbuild/SOURCES/ |
| 31 |
|
|
cd ~/rpmbuild/SOURCES/ || die "Can't chdir to ~/rpmbuild/SOURCES/ ." |
| 32 |
kumaneko |
387 |
if [ ! -r caitsith-patch-0.2-20231225.tar.gz ] |
| 33 |
kumaneko |
155 |
then |
| 34 |
kumaneko |
389 |
wget https://sourceforge.net/projects/tomoyo/files/caitsith-patch/0.2/caitsith-patch-0.2-20231225.tar.gz || die "Can't download patch." |
| 35 |
kumaneko |
155 |
fi |
| 36 |
|
|
|
| 37 |
|
|
# Install kernel source packages. |
| 38 |
|
|
cd /usr/src/ || die "Can't chdir to /usr/src/ ." |
| 39 |
|
|
apt-get -y install fakeroot build-essential || die "Can't install packages." |
| 40 |
|
|
apt-get build-dep linux || die "Can't install packages." |
| 41 |
|
|
apt-get source linux-source-3.2.0 || die "Can't install kernel source." |
| 42 |
|
|
for i in `awk ' { if ( $1 != "Build-Depends:") next; $1 = ""; n = split($0, a, ","); for (i = 1; i <= n; i++) { split(a[i], b, " "); print b[1]; } } ' linux-3.2.0/debian/control`; do apt-get -y install $i; done |
| 43 |
|
|
|
| 44 |
|
|
# Apply patches and create kernel config. |
| 45 |
|
|
cd linux-3.2.0/ || die "Can't chdir to linux-3.2.0/ ." |
| 46 |
|
|
update_maintainer |
| 47 |
kumaneko |
387 |
tar -zxf ~/rpmbuild/SOURCES/caitsith-patch-0.2-20231225.tar.gz || die "Can't extract patch." |
| 48 |
kumaneko |
166 |
sed -i -e 's/CCSECURITY/CAITSITH/g' -e 's/ccsecurity/caitsith/g' -e 's/ccs_domain_info/cs_domain_info/g' -e 's/ccs_flags/cs_flags/g' patches/ccs-patch-*.diff |
| 49 |
kumaneko |
155 |
patch -p1 < patches/ccs-patch-3.2-ubuntu-12.04.diff || die "Can't apply patch." |
| 50 |
|
|
rm -fR patches/ specs/ || die "Can't delete patch." |
| 51 |
|
|
for i in `find debian.master/ -type f -name '*'${ORIGINAL_FLAVOUR}'*'`; do cp -p $i `echo $i | sed -e 's/'${ORIGINAL_FLAVOUR}'/'${NEW_FLAVOUR}'/g'`; done |
| 52 |
|
|
for i in debian.master/config/*/config.common.*; do cat config.caitsith >> $i; done |
| 53 |
|
|
rm debian.master/control.stub || die "Can't delete control.stub." |
| 54 |
|
|
make -f debian/rules debian.master/control.stub || die "Can't update control.stub." |
| 55 |
|
|
rm debian/control || die "Can't delete control." |
| 56 |
|
|
debian/rules debian/control || die "Can't update control." |
| 57 |
|
|
|
| 58 |
|
|
# Make modified header files go into local header package. |
| 59 |
|
|
patch -p0 << "EOF" || die "Can't patch link-headers." |
| 60 |
|
|
--- debian/scripts/link-headers |
| 61 |
|
|
+++ debian/scripts/link-headers |
| 62 |
|
|
@@ -39,4 +39,19 @@ |
| 63 |
|
|
done |
| 64 |
|
|
) |
| 65 |
|
|
|
| 66 |
|
|
+if [ $flavour == "NEW_FLAVOUR" ] |
| 67 |
|
|
+then |
| 68 |
|
|
+ cd $hdrdir/../../../../$symdir/usr/src/$symdir/include/linux/ |
| 69 |
|
|
+ for i in sched.h init_task.h security.h caitsith.h lsm2caitsith.h |
| 70 |
|
|
+ do |
| 71 |
|
|
+ rm -f $hdrdir/include/linux/$i |
| 72 |
|
|
+ cp -p $i $hdrdir/include/linux/$i |
| 73 |
|
|
+ done |
| 74 |
|
|
+ rm -f $hdrdir/include/net $hdrdir/security |
| 75 |
|
|
+ cd ../ |
| 76 |
|
|
+ tar -cf - net | tar -xf - -C $hdrdir/include/ |
| 77 |
|
|
+ cd ../ |
| 78 |
|
|
+ tar -cf - security | tar -xf - -C $hdrdir |
| 79 |
|
|
+fi |
| 80 |
|
|
+ |
| 81 |
|
|
exit |
| 82 |
|
|
EOF |
| 83 |
|
|
sed -i -e 's/NEW_FLAVOUR/'${NEW_FLAVOUR}'/' debian/scripts/link-headers || die "Can't patch link-headers." |
| 84 |
|
|
|
| 85 |
|
|
# Start compilation. |
| 86 |
|
|
debian/rules binary-headers || die "Failed to build kernel package." |
| 87 |
|
|
debian/rules binary-debs flavours=${NEW_FLAVOUR} || die "Failed to build kernel package." |
| 88 |
|
|
|
| 89 |
|
|
# Generate meta packages. |
| 90 |
|
|
cd /usr/src/ |
| 91 |
|
|
rm -fR linux-meta-*/ |
| 92 |
|
|
apt-get source linux-meta |
| 93 |
|
|
cd linux-meta-*/ |
| 94 |
|
|
update_maintainer |
| 95 |
|
|
sed -e 's/'${ORIGINAL_FLAVOUR}'/'${NEW_FLAVOUR}'/g' -- debian/control.d/${ORIGINAL_FLAVOUR} > debian/${NEW_FLAVOUR} |
| 96 |
|
|
rm -f debian/control.d/* |
| 97 |
|
|
mv debian/${NEW_FLAVOUR} debian/control.d/${NEW_FLAVOUR} |
| 98 |
|
|
debian/rules binary-arch |
| 99 |
|
|
cd ../ |
| 100 |
|
|
rm -fR linux-meta-*/ |
| 101 |
|
|
|
| 102 |
|
|
exit 0 |