1 # Maintainer: Jan Alexander Steffens (heftig) <heftig@archlinux.org>
3 pkgbase=linux-zen-letsnote
6 pkgdesc="Linux ZEN patched for Let's note"
7 _srctag=v${pkgver%.*}-${pkgver##*.}
8 url="https://github.com/zen-kernel/zen-kernel/commits/$_srctag"
13 xmlto python-sphinx python-sphinx_rtd_theme graphviz imagemagick
19 "$_srcname::git+https://github.com/zen-kernel/zen-kernel#tag=$_srctag"
20 config # the main kernel config file
21 sphinx-workaround.patch
29 export KBUILD_BUILD_HOST=archlinux
30 export KBUILD_BUILD_USER=$pkgbase
31 export KBUILD_BUILD_TIMESTAMP="$(date -Ru${SOURCE_DATE_EPOCH:+d @$SOURCE_DATE_EPOCH})"
36 echo "Setting version..."
37 scripts/setlocalversion --save-scmversion
38 echo "-$pkgrel" > localversion.10-pkgrel
39 echo "${pkgbase#linux}" > localversion.20-pkgname
42 for src in "${source[@]}"; do
45 [[ $src = *.patch ]] || continue
46 echo "Applying patch $src..."
47 patch -Np1 < "../$src"
50 echo "Setting config..."
54 make -s kernelrelease > version
55 echo "Prepared $pkgbase version $(<version)"
65 pkgdesc="The $pkgdesc kernel and modules"
66 depends=(coreutils kmod initramfs)
67 optdepends=('crda: to set the correct wireless channels of your country'
68 'linux-firmware: firmware images needed for some devices')
69 provides=(VIRTUALBOX-GUEST-MODULES WIREGUARD-MODULE)
73 local kernver="$(<version)"
74 local modulesdir="$pkgdir/usr/lib/modules/$kernver"
76 echo "Installing boot image..."
77 # systemd expects to find the kernel here to allow hibernation
78 # https://github.com/systemd/systemd/commit/edda44605f06a41fb86b7ab8128dcf99161d2344
79 install -Dm644 "$(make -s image_name)" "$modulesdir/vmlinuz"
81 # Used by mkinitcpio to name the kernel
82 echo "$pkgbase" | install -Dm644 /dev/stdin "$modulesdir/pkgbase"
84 echo "Installing modules..."
85 make INSTALL_MOD_PATH="$pkgdir/usr" INSTALL_MOD_STRIP=1 modules_install
87 # remove build and source links
88 rm "$modulesdir"/{source,build}
92 pkgdesc="Headers and scripts for building modules for the $pkgdesc kernel"
95 local builddir="$pkgdir/usr/lib/modules/$(<version)/build"
97 echo "Installing build files..."
98 install -Dt "$builddir" -m644 .config Makefile Module.symvers System.map \
99 localversion.* version vmlinux
100 install -Dt "$builddir/kernel" -m644 kernel/Makefile
101 install -Dt "$builddir/arch/x86" -m644 arch/x86/Makefile
102 cp -t "$builddir" -a scripts
104 # add objtool for external module building and enabled VALIDATION_STACK option
105 install -Dt "$builddir/tools/objtool" tools/objtool/objtool
107 # add xfs and shmem for aufs building
108 mkdir -p "$builddir"/{fs/xfs,mm}
110 echo "Installing headers..."
111 cp -t "$builddir" -a include
112 cp -t "$builddir/arch/x86" -a arch/x86/include
113 install -Dt "$builddir/arch/x86/kernel" -m644 arch/x86/kernel/asm-offsets.s
115 install -Dt "$builddir/drivers/md" -m644 drivers/md/*.h
116 install -Dt "$builddir/net/mac80211" -m644 net/mac80211/*.h
118 # http://bugs.archlinux.org/task/13146
119 install -Dt "$builddir/drivers/media/i2c" -m644 drivers/media/i2c/msp3400-driver.h
121 # http://bugs.archlinux.org/task/20402
122 install -Dt "$builddir/drivers/media/usb/dvb-usb" -m644 drivers/media/usb/dvb-usb/*.h
123 install -Dt "$builddir/drivers/media/dvb-frontends" -m644 drivers/media/dvb-frontends/*.h
124 install -Dt "$builddir/drivers/media/tuners" -m644 drivers/media/tuners/*.h
126 echo "Installing KConfig files..."
127 find . -name 'Kconfig*' -exec install -Dm644 {} "$builddir/{}" \;
129 echo "Removing unneeded architectures..."
131 for arch in "$builddir"/arch/*/; do
132 [[ $arch = */x86/ ]] && continue
133 echo "Removing $(basename "$arch")"
137 echo "Removing documentation..."
138 rm -r "$builddir/Documentation"
140 echo "Removing broken symlinks..."
141 find -L "$builddir" -type l -printf 'Removing %P\n' -delete
143 echo "Removing loose objects..."
144 find "$builddir" -type f -name '*.o' -printf 'Removing %P\n' -delete
146 echo "Stripping build tools..."
148 while read -rd '' file; do
149 case "$(file -bi "$file")" in
150 application/x-sharedlib\;*) # Libraries (.so)
151 strip -v $STRIP_SHARED "$file" ;;
152 application/x-archive\;*) # Libraries (.a)
153 strip -v $STRIP_STATIC "$file" ;;
154 application/x-executable\;*) # Binaries
155 strip -v $STRIP_BINARIES "$file" ;;
156 application/x-pie-executable\;*) # Relocatable binaries
157 strip -v $STRIP_SHARED "$file" ;;
159 done < <(find "$builddir" -type f -perm -u+x ! -name vmlinux -print0)
161 echo "Stripping vmlinux..."
162 strip -v $STRIP_STATIC "$builddir/vmlinux"
164 echo "Adding symlink..."
165 mkdir -p "$pkgdir/usr/src"
166 ln -sr "$builddir" "$pkgdir/usr/src/$pkgbase"
170 pkgdesc="Documentation for the $pkgdesc kernel"
173 local builddir="$pkgdir/usr/lib/modules/$(<version)/build"
175 echo "Installing documentation..."
177 while read -rd '' src; do
178 dst="${src#Documentation/}"
179 dst="$builddir/Documentation/${dst#output/}"
180 install -Dm644 "$src" "$dst"
181 done < <(find Documentation -name '.*' -prune -o ! -type d -print0)
183 echo "Adding symlink..."
184 mkdir -p "$pkgdir/usr/share/doc"
185 ln -sr "$builddir/Documentation" "$pkgdir/usr/share/doc/$pkgbase"
188 pkgname=("$pkgbase" "$pkgbase-headers" "$pkgbase-docs")
189 for _p in "${pkgname[@]}"; do
190 eval "package_$_p() {
191 $(declare -f "_package${_p#$pkgbase}")
192 _package${_p#$pkgbase}
196 # vim:set ts=8 sts=2 sw=2 et: