OSDN Git Service

[add] : Added packages
[alterlinux/hayao-aur-packages.git] / linux-zen-letsnote / PKGBUILD
1 # Maintainer: Jan Alexander Steffens (heftig) <heftig@archlinux.org>
2
3 pkgbase=linux-zen-letsnote
4 pkgver=5.9.11.zen2
5 pkgrel=1
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"
9 arch=(x86_64)
10 license=(GPL2)
11 makedepends=(
12   bc kmod libelf pahole
13   xmlto python-sphinx python-sphinx_rtd_theme graphviz imagemagick
14   git
15 )
16 options=('!strip')
17 _srcname=zen-kernel
18 source=(
19   "$_srcname::git+https://github.com/zen-kernel/zen-kernel#tag=$_srctag"
20   config         # the main kernel config file
21   sphinx-workaround.patch
22   lets-note.patch
23 )
24 sha256sums=('SKIP'
25             'SKIP'
26             'SKIP'
27             'SKIP')
28
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})"
32
33 prepare() {
34   cd $_srcname
35
36   echo "Setting version..."
37   scripts/setlocalversion --save-scmversion
38   echo "-$pkgrel" > localversion.10-pkgrel
39   echo "${pkgbase#linux}" > localversion.20-pkgname
40
41   local src
42   for src in "${source[@]}"; do
43     src="${src%%::*}"
44     src="${src##*/}"
45     [[ $src = *.patch ]] || continue
46     echo "Applying patch $src..."
47     patch -Np1 < "../$src"
48   done
49
50   echo "Setting config..."
51   cp ../config .config
52   make olddefconfig
53
54   make -s kernelrelease > version
55   echo "Prepared $pkgbase version $(<version)"
56 }
57
58 build() {
59   cd $_srcname
60   make all
61   make htmldocs
62 }
63
64 _package() {
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)
70   replaces=()
71
72   cd $_srcname
73   local kernver="$(<version)"
74   local modulesdir="$pkgdir/usr/lib/modules/$kernver"
75
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"
80
81   # Used by mkinitcpio to name the kernel
82   echo "$pkgbase" | install -Dm644 /dev/stdin "$modulesdir/pkgbase"
83
84   echo "Installing modules..."
85   make INSTALL_MOD_PATH="$pkgdir/usr" INSTALL_MOD_STRIP=1 modules_install
86
87   # remove build and source links
88   rm "$modulesdir"/{source,build}
89 }
90
91 _package-headers() {
92   pkgdesc="Headers and scripts for building modules for the $pkgdesc kernel"
93
94   cd $_srcname
95   local builddir="$pkgdir/usr/lib/modules/$(<version)/build"
96
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
103
104   # add objtool for external module building and enabled VALIDATION_STACK option
105   install -Dt "$builddir/tools/objtool" tools/objtool/objtool
106
107   # add xfs and shmem for aufs building
108   mkdir -p "$builddir"/{fs/xfs,mm}
109
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
114
115   install -Dt "$builddir/drivers/md" -m644 drivers/md/*.h
116   install -Dt "$builddir/net/mac80211" -m644 net/mac80211/*.h
117
118   # http://bugs.archlinux.org/task/13146
119   install -Dt "$builddir/drivers/media/i2c" -m644 drivers/media/i2c/msp3400-driver.h
120
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
125
126   echo "Installing KConfig files..."
127   find . -name 'Kconfig*' -exec install -Dm644 {} "$builddir/{}" \;
128
129   echo "Removing unneeded architectures..."
130   local arch
131   for arch in "$builddir"/arch/*/; do
132     [[ $arch = */x86/ ]] && continue
133     echo "Removing $(basename "$arch")"
134     rm -r "$arch"
135   done
136
137   echo "Removing documentation..."
138   rm -r "$builddir/Documentation"
139
140   echo "Removing broken symlinks..."
141   find -L "$builddir" -type l -printf 'Removing %P\n' -delete
142
143   echo "Removing loose objects..."
144   find "$builddir" -type f -name '*.o' -printf 'Removing %P\n' -delete
145
146   echo "Stripping build tools..."
147   local file
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" ;;
158     esac
159   done < <(find "$builddir" -type f -perm -u+x ! -name vmlinux -print0)
160
161   echo "Stripping vmlinux..."
162   strip -v $STRIP_STATIC "$builddir/vmlinux"
163
164   echo "Adding symlink..."
165   mkdir -p "$pkgdir/usr/src"
166   ln -sr "$builddir" "$pkgdir/usr/src/$pkgbase"
167 }
168
169 _package-docs() {
170   pkgdesc="Documentation for the $pkgdesc kernel"
171
172   cd $_srcname
173   local builddir="$pkgdir/usr/lib/modules/$(<version)/build"
174
175   echo "Installing documentation..."
176   local src dst
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)
182
183   echo "Adding symlink..."
184   mkdir -p "$pkgdir/usr/share/doc"
185   ln -sr "$builddir/Documentation" "$pkgdir/usr/share/doc/$pkgbase"
186 }
187
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}
193   }"
194 done
195
196 # vim:set ts=8 sts=2 sw=2 et: