Newer
Older
# Maintainer: Sébastien Luttringer <seblu@aur.archlinux.org>
# Customized version of linux for seblu computers
license=('GPL2')
url='http://www.kernel.org'
options=('!strip')
makedepends=('git' 'bc')
depends=('coreutils' 'linux-firmware' 'kmod' 'mkinitcpio')
optdepends=('kernel-install-compat: Install kernel in /boot'
'kernel-install-grub: Regen grub config')
install=linux-seblu.install
source=("git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git#tag=v${pkgver/_/-}"
# apply patches
for _f in "${source[@]}"; do
if [[ "$_f" =~ \.patch$ ]]; then
msg2 "Patching $_f"
patch -p1 -d docker < "$_f"
fi
done
# loading default config
# use make localmodconfig to check .config is correct
msg2 'Copying config'
# force suffixe in config (must be the right!)
sed -i "s|CONFIG_LOCALVERSION=.*|CONFIG_LOCALVERSION=\"${pkgname#linux*}\"|g" .config
# remove git informations
# these info will be used by make kernelrelease and produce wrong information
# because ownership has fakely be changed by fakeroot during packaging.
rm -rf .git
# define current build version
yes '' | make config &>/dev/null
make prepare &>/dev/null
# get real compiled kernel version
kernrel=$(make kernelrelease)
pkgdesc="The Linux Kernel, version $kernrel"
pkgname="linux-$kernrel"
msg2 "Packing kernel release: $kernrel"
msg2 "Packing kernel version: $pkgver"
# install kernel
install -D -m644 arch/x86/boot/bzImage "$pkgdir/usr/lib/kernel/vmlinuz-$kernrel"
# and it's done by kernel-install in .install
make INSTALL_MOD_PATH="$pkgdir/usr" DEPMOD=/bin/true modules_install
install_sources() {
# remove previous build and source links
rm -f "$pkgdir/usr/lib/modules/$kernrel"/{source,build}
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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
# create build symlink into /usr/lib/modules
ln -sf ../../../src/linux-$kernrel "$pkgdir/usr/lib/modules/$kernrel/build"
# Copy kernel config files
cd "$srcdir"/linux
install -D -m644 Makefile "$pkgdir/usr/src/linux-$kernrel/Makefile"
install -D -m644 kernel/Makefile "$pkgdir/usr/src/linux-$kernrel/kernel/Makefile"
install -D -m644 .config "$pkgdir/usr/src/linux-$kernrel/.config"
for i in localversion*; do
install -m644 "$i" "$pkgdir/usr/src/linux-$kernrel/$i"
done
# create include directory
install -d "$pkgdir/usr/src/linux-$kernrel/include"
for i in acpi asm-generic config crypto drm generated linux math-emu \
media net pcmcia scsi sound trace uapi video xen; do
cp -a include/$i "$pkgdir/usr/src/linux-$kernrel/include/"
done
# remove unneeded architectures
for i in "$pkgdir/usr/src/linux-$kernrel"/arch/*; do
[[ "$i" == x86 ]] && continue
rm -rf "$i"
done
# copy arch includes for external modules
install -d "$pkgdir/usr/src/linux-$kernrel/arch/x86"
cp -a arch/x86/include "$pkgdir/usr/src/linux-$kernrel/arch/x86/"
# copy files necessary for later builds, like nvidia and vmware
cp Module.symvers "$pkgdir/usr/src/linux-$kernrel"
cp -a scripts "$pkgdir/usr/src/linux-$kernrel"
# fix permissions on scripts dir
chmod og-w -R "$pkgdir/usr/src/linux-$kernrel/scripts"
install -d "$pkgdir/usr/src/linux-$kernrel/.tmp_versions"
install -d "$pkgdir/usr/src/linux-$kernrel/arch/x86/kernel"
cp arch/x86/Makefile "$pkgdir/usr/src/linux-$kernrel/arch/x86/"
cp arch/x86/kernel/asm-offsets.s "$pkgdir/usr/src/linux-$kernrel/arch/x86/kernel/"
# add docbook makefile
install -D -m644 Documentation/DocBook/Makefile "$pkgdir/usr/src/linux-$kernrel/Documentation/DocBook/Makefile"
# add dm headers
install -d "$pkgdir/usr/src/linux-$kernrel/drivers/md"
cp drivers/md/*.h "$pkgdir/usr/src/linux-$kernrel/drivers/md"
# add inotify.h
install -d "$pkgdir/usr/src/linux-$kernrel/include/linux"
cp include/linux/inotify.h "$pkgdir/usr/src/linux-$kernrel/include/linux/"
# add wireless headers
install -d "$pkgdir/usr/src/linux-$kernrel/net/mac80211/"
cp net/mac80211/*.h "$pkgdir/usr/src/linux-$kernrel/net/mac80211/"
# add dvb headers for external modules
# in reference to:
# http://bugs.archlinux.org/task/9912
install -d "$pkgdir/usr/src/linux-$kernrel/drivers/media/dvb-core"
cp drivers/media/dvb-core/*.h "$pkgdir/usr/src/linux-$kernrel/drivers/media/dvb-core/"
# add dvb headers for external modules
# in reference to:
# http://bugs.archlinux.org/task/11194
install -d "$pkgdir/usr/src/linux-$kernrel/include/config/dvb/"
cp include/config/dvb/*.h "$pkgdir/usr/src/linux-$kernrel/include/config/dvb/"
# add dvb headers for http://mcentral.de/hg/~mrec/em28xx-new
# in reference to:
# http://bugs.archlinux.org/task/13146
install -Dm644 drivers/media/dvb-frontends/lgdt330x.h \
"$pkgdir/usr/src/linux-$kernrel/drivers/media/dvb-frontends/dvb-frontends/lgdt330x.h"
install -Dm644 drivers/media/i2c/msp3400-driver.h \
"$pkgdir/usr/src/linux-$kernrel/drivers/media/i2c/msp3400-driver.h"
# add dvb headers
# in reference to:
# http://bugs.archlinux.org/task/20402
install -d "$pkgdir/usr/src/linux-$kernrel/drivers/media/usb/dvb-usb"
cp drivers/media/usb/dvb-usb/*.h "$pkgdir/usr/src/linux-$kernrel/drivers/media/usb/dvb-usb/"
install -d "$pkgdir/usr/src/linux-$kernrel/drivers/media/dvb-frontends"
cp drivers/media/dvb-frontends/*.h "$pkgdir/usr/src/linux-$kernrel/drivers/media/dvb-frontends/"
install -d "$pkgdir/usr/src/linux-$kernrel/drivers/media/tuners"
cp drivers/media/tuners/*.h "$pkgdir/usr/src/linux-$kernrel/drivers/media/tuners/"
# copy in Kconfig files
for i in $(find . -name "Kconfig*"); do
install -d "$pkgdir/usr/src/linux-$kernrel"/$(echo $i | sed 's|/Kconfig.*||')
cp "$i" "$pkgdir/usr/src/linux-$kernrel/$i"
done
# strip scripts directory
find "$pkgdir/usr/src/linux-$kernrel/scripts" -type f -perm -u+w 2>/dev/null | while read binary ; do
case "$(file -bi "$binary")" in
*application/x-sharedlib*) # Libraries (.so)
$_nice strip $STRIP_SHARED "$binary";;
*application/x-archive*) # Libraries (.a)
$_nice strip $STRIP_STATIC "$binary";;
*application/x-executable*) # Binaries
$_nice strip $STRIP_BINARIES "$binary";;
esac
done
# check rights
chown -R root.root "$pkgdir/usr/src/linux-$kernrel"
chmod -R u=rwX,go=rX "$pkgdir/usr/src/linux-$kernrel"