aboutsummaryrefslogtreecommitdiff
path: root/kernel/kernel-ratten/kernel-ratten.SlackBuild
blob: a0743c552a59b7c363a3e27c90e100c67cf2d3e5 (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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
#!/bin/bash
#
# slackbuild for kernel-ratten
# by rhatto at riseup.net
#

if [ -s "slack-required" ]; then
  echo Recomended and required packages for building kernel-ratten are:
  cat slack-required | sed -e 's/^/\t/'
  if [ "$INTERACT" != "no" ]; then
    echo If you dont have those installed, press Ctrl-C. Otherwise, hit ENTER.
    read crap
#  else
#    echo Sleeping 3 seconds...
#    sleep 3
  fi
fi

if [ -f ~/.slackbuildrc ]; then
  source ~/.slackbuildrc
elif [ -f /etc/slackbuildrc ]; then
  source /etc/slackbuildrc
fi

CWD="`pwd`"

PACKAGE="kernel-ratten"
PATCHSET="bs-rt"
ARCH="x86_64"
SPLASH="/etc/bootsplash/themes/Slack-Black-Tux/config/bootsplash-1024x768.cfg"
BUILD=${BUILD:=1rha}
KERNEL_VERSION=${KERNEL_VERSION:=2.6.18}
EXTRAVERSION=${EXTRAVERSION:=1}
PATCH_VERSION=${PATCH_VERSION:=3.1.6-2.6.15}
REALTIME_PATCH=${REALTIME_PATCH:=rt-lsm-0.8.7-kernel.patch}
TMP=${TMP:=/tmp}
SRC_DIR=${SRC:=$CWD}
REPOS=${REPOS:=$TMP}

# -------  error codes for createpkg  --------------
ERROR_WGET=31;      ERROR_MAKE=32;      ERROR_INSTALL=33
ERROR_MD5=34;       ERROR_CONF=35;      ERROR_HELP=36
ERROR_TAR=37;       ERROR_MKPKG=38;     ERROR_GPG=39
ERROR_PATCH=40

if [ ! -f "$SPLASH" ]; then
  echo error: file not found: $SPLASH
  exit 1
fi

if [ ! -z "$EXTRAVERSION" ]; then
  KERNEL_VERSION="$KERNEL_VERSION.$EXTRAVERSION"
fi

RTOOL="wget"
KERNEL="linux-$KERNEL_VERSION.tar.bz2"
PATCH="bootsplash-$PATCH_VERSION.diff"
KERNEL_URL="http://www.kernel.org/pub/linux/kernel/v2.6/$KERNEL"
PATCH_URL="ftp://ftp.openbios.org/pub/bootsplash/kernel/$PATCH"

SRC_DIR="$SRC_DIR/kernel"
mkdir -p $SRC_DIR

if [ "$RTOOL" == "wget" ]; then

  if [ ! -f "$SRC_DIR/$KERNEL" ]; then
    rm -f $SRC_DIR/$KERNEL.sign
    wget "$KERNEL_URL" -O "$SRC_DIR/$KERNEL" || exit $ERROR_WGET
    wget "$KERNEL_URL.sign" -O "$SRC_DIR/$KERNEL.sign" || exit $ERROR_WGET
  fi

  if [ ! -f "$SRC_DIR/$PATCH" ]; then
    wget "$PATCH_URL" -O "$SRC_DIR/$PATCH" || exit $ERROR_WGET
  fi

fi

TMP="$TMP/$PACKAGE"
rm -rf $TMP
mkdir -p $TMP
cd $TMP

rm -rf linux-$KERNEL_VERSION*
tar jxvf $SRC_DIR/$KERNEL || exit $ERROR_TAR

if [ ! -z "$PATCHSET" ]; then
  mv linux-$KERNEL_VERSION linux-$KERNEL_VERSION-$PATCHSET
  KERNEL_VERSION="$KERNEL_VERSION-$PATCHSET"
fi

cp $CWD/config-$KERNEL_VERSION linux-$KERNEL_VERSION/.config
cd linux-$KERNEL_VERSION

if [ ! -z "$EXTRAVERSION" ] && [ ! -z "$PATCHSET" ]; then
  sed -e "s/^EXTRAVERSION =.*$/EXTRAVERSION = \.$EXTRAVERSION-$PATCHSET/" Makefile > Makefile.tmp
elif [ ! -z "$PATCHSET" ]; then
  sed -e "s/^EXTRAVERSION =*$/EXTRAVERSION = -$PATCHSET/" Makefile > Makefile.tmp
fi

mv Makefile.tmp Makefile
patch -p1 < $CWD/$REALTIME_PATCH || exit $ERROR_PATCH
patch -p1 < $SRC_DIR/$PATCH || exit $ERROR_TAR

make oldconfig || exit $ERROR_MAKE
time make || exit $ERROR_MAKE

if [ -d "/lib/modules/$KERNEL_VERSION" ]; then
  ( cd /lib/modules && mv $KERNEL_VERSION $KERNEL_VERSION.old )
fi

make modules_install || exit $ERROR_INSTALL

# make the package

CWD="`pwd`"

PKG="$TMP/package-$PACKAGE"

mkdir -p $PKG/{install,boot,lib/modules,usr/doc}

cp -Rp /lib/modules/$KERNEL_VERSION $PKG/lib/modules

if [ -d "/lib/modules/$KERNEL_VERSION.old" ]; then
  ( cd /lib/modules && mv $KERNEL_VERSION $KERNEL_VERSION.delete && mv $KERNEL_VERSION.old $KERNEL_VERSION && rm -rf $KERNEL_VERSION.delete  )
fi

cp System.map $PKG/boot/System.map-$KERNEL_VERSION
cp .config $PKG/boot/config-$KERNEL_VERSION
cp arch/$ARCH/boot/bzImage $PKG/boot/vmlinuz-$KERNEL_VERSION

cat << EOF > $PKG/install/slack-desc
kernel-ratten: kernel-ratten (linux kernel $KERNEL_VERSION for ratten AMD64 workstation)
kernel-ratten: 
kernel-ratten: This is the kernel for the RATTEN workstation.
kernel-ratten: 
kernel-ratten: 
kernel-ratten: 
kernel-ratten: 
kernel-ratten: 
kernel-ratten: 
kernel-ratten: 
kernel-ratten: 
EOF

VERSION="`echo $KERNEL_VERSION | sed -e 's/-/_/g'`"

# docs
mkdir -p $PKG/usr/doc/$PACKAGE-$VERSION
# cp -r Documentation $PKG/usr/doc/$PACKAGE-$VERSION/
for file in COPYING CREDITS MAINTAINERS README REPORTING-BUGS; do
  cp $CWD/$file* $PKG/usr/doc/$PACKAGE-$VERSION/
done

mkinitrd -c -k $KERNEL_VERSION -o $PKG/boot/initrd.gz
splash -s -f $SPLASH > $PKG/boot/initrd.gz 

cd $PKG

( cd boot && ln -s vmlinuz-$KERNEL_VERSION vmlinuz )
( cd boot && ln -s config-$KERNEL_VERSION config )
( cd boot && ln -s System.map-$KERNEL_VERSION System.map )

makepkg -c y -l y $REPOS/$PACKAGE-$VERSION-$ARCH-$BUILD.tgz || exit $ERROR_MKPKG

if [ "$CLEANUP" == "yes" ]; then
  rm -rf $TMP
fi