OSDN Git Service

upg
[joborun/jobcore.git] / linux-lts / PKGBUILD-arch-51090
1 # Maintainer: Andreas Radke <andyrtr@archlinux.org>
2
3 pkgbase=linux-lts
4 pkgver=5.10.90
5 pkgrel=1
6 pkgdesc='LTS Linux'
7 url="https://www.kernel.org/"
8 arch=(x86_64)
9 license=(GPL2)
10 makedepends=(
11   bc kmod libelf pahole cpio perl tar xz
12   xmlto python-sphinx python-sphinx_rtd_theme python-six graphviz imagemagick
13 )
14 options=('!strip')
15 _srcname=linux-$pkgver
16 source=(
17   https://cdn.kernel.org/pub/linux/kernel/v${pkgver%%.*}.x/${_srcname}.tar.{xz,sign}
18   config         # the main kernel config file
19   0001-ZEN-Add-sysctl-and-CONFIG-to-disallow-unprivileged-C.patch
20 )
21 validpgpkeys=(
22   'ABAF11C65A2970B130ABE3C479BE3E4300411886'  # Linus Torvalds
23   '647F28654894E3BD457199BE38DBBDC86092693E'  # Greg Kroah-Hartman
24 )
25 # https://www.kernel.org/pub/linux/kernel/v5.x/sha256sums.asc
26 sha256sums=('945e4264c014a3d9dfc0a4639309dd1ec2fb545416556421f931b95da78c2725'
27             'SKIP'
28             '80de9382be09f765b5cb1c11e21a09c99f75a0000bcc10def0542228644ea828'
29             '96a72e1652314215da7140956c3abcf495cafd00811eda3cf4ce03ec5f791f1e')
30
31 export KBUILD_BUILD_HOST=archlinux
32 export KBUILD_BUILD_USER=$pkgbase
33 export KBUILD_BUILD_TIMESTAMP="$(date -Ru${SOURCE_DATE_EPOCH:+d @$SOURCE_DATE_EPOCH})"
34
35 prepare() {
36   cd $_srcname
37
38   echo "Setting version..."
39   scripts/setlocalversion --save-scmversion
40   echo "-$pkgrel" > localversion.10-pkgrel
41   echo "${pkgbase#linux}" > localversion.20-pkgname
42
43   local src
44   for src in "${source[@]}"; do
45     src="${src%%::*}"
46     src="${src##*/}"
47     [[ $src = *.patch ]] || continue
48     echo "Applying patch $src..."
49     patch -Np1 < "../$src"
50   done
51
52   echo "Setting config..."
53   cp ../config .config
54   make olddefconfig
55 #return 1
56   make -s kernelrelease > version
57   echo "Prepared $pkgbase version $(<version)"
58 }
59
60 build() {
61   cd $_srcname
62   make all
63   make htmldocs
64 }
65
66 _package() {
67   pkgdesc="The $pkgdesc kernel and modules"
68   depends=(coreutils kmod initramfs)
69   optdepends=('crda: to set the correct wireless channels of your country'
70               'linux-firmware: firmware images needed for some devices')
71   provides=(VIRTUALBOX-GUEST-MODULES WIREGUARD-MODULE)
72   replaces=(wireguard-lts)
73
74   cd $_srcname
75   local kernver="$(<version)"
76   local modulesdir="$pkgdir/usr/lib/modules/$kernver"
77
78   echo "Installing boot image..."
79   # systemd expects to find the kernel here to allow hibernation
80   # https://github.com/systemd/systemd/commit/edda44605f06a41fb86b7ab8128dcf99161d2344
81   install -Dm644 "$(make -s image_name)" "$modulesdir/vmlinuz"
82
83   # Used by mkinitcpio to name the kernel
84   echo "$pkgbase" | install -Dm644 /dev/stdin "$modulesdir/pkgbase"
85
86   echo "Installing modules..."
87   make INSTALL_MOD_PATH="$pkgdir/usr" INSTALL_MOD_STRIP=1 modules_install
88
89   # remove build and source links
90   rm "$modulesdir"/{source,build}
91 }
92
93 _package-headers() {
94   pkgdesc="Headers and scripts for building modules for the $pkgdesc kernel"
95
96   cd $_srcname
97   local builddir="$pkgdir/usr/lib/modules/$(<version)/build"
98
99   echo "Installing build files..."
100   install -Dt "$builddir" -m644 .config Makefile Module.symvers System.map \
101     localversion.* version vmlinux
102   install -Dt "$builddir/kernel" -m644 kernel/Makefile
103   install -Dt "$builddir/arch/x86" -m644 arch/x86/Makefile
104   cp -t "$builddir" -a scripts
105
106   # add objtool for external module building and enabled VALIDATION_STACK option
107   install -Dt "$builddir/tools/objtool" tools/objtool/objtool
108
109   # add xfs and shmem for aufs building
110   mkdir -p "$builddir"/{fs/xfs,mm}
111
112   echo "Installing headers..."
113   cp -t "$builddir" -a include
114   cp -t "$builddir/arch/x86" -a arch/x86/include
115   install -Dt "$builddir/arch/x86/kernel" -m644 arch/x86/kernel/asm-offsets.s
116
117   install -Dt "$builddir/drivers/md" -m644 drivers/md/*.h
118   install -Dt "$builddir/net/mac80211" -m644 net/mac80211/*.h
119
120   # http://bugs.archlinux.org/task/13146
121   install -Dt "$builddir/drivers/media/i2c" -m644 drivers/media/i2c/msp3400-driver.h
122
123   # http://bugs.archlinux.org/task/20402
124   install -Dt "$builddir/drivers/media/usb/dvb-usb" -m644 drivers/media/usb/dvb-usb/*.h
125   install -Dt "$builddir/drivers/media/dvb-frontends" -m644 drivers/media/dvb-frontends/*.h
126   install -Dt "$builddir/drivers/media/tuners" -m644 drivers/media/tuners/*.h
127
128   echo "Installing KConfig files..."
129   find . -name 'Kconfig*' -exec install -Dm644 {} "$builddir/{}" \;
130
131   echo "Removing unneeded architectures..."
132   local arch
133   for arch in "$builddir"/arch/*/; do
134     [[ $arch = */x86/ ]] && continue
135     echo "Removing $(basename "$arch")"
136     rm -r "$arch"
137   done
138
139   echo "Removing documentation..."
140   rm -r "$builddir/Documentation"
141
142   echo "Removing broken symlinks..."
143   find -L "$builddir" -type l -printf 'Removing %P\n' -delete
144
145   echo "Removing loose objects..."
146   find "$builddir" -type f -name '*.o' -printf 'Removing %P\n' -delete
147
148   echo "Stripping build tools..."
149   local file
150   while read -rd '' file; do
151     case "$(file -bi "$file")" in
152       application/x-sharedlib\;*)      # Libraries (.so)
153         strip -v $STRIP_SHARED "$file" ;;
154       application/x-archive\;*)        # Libraries (.a)
155         strip -v $STRIP_STATIC "$file" ;;
156       application/x-executable\;*)     # Binaries
157         strip -v $STRIP_BINARIES "$file" ;;
158       application/x-pie-executable\;*) # Relocatable binaries
159         strip -v $STRIP_SHARED "$file" ;;
160     esac
161   done < <(find "$builddir" -type f -perm -u+x ! -name vmlinux -print0)
162
163   echo "Stripping vmlinux..."
164   strip -v $STRIP_STATIC "$builddir/vmlinux"
165
166   echo "Adding symlink..."
167   mkdir -p "$pkgdir/usr/src"
168   ln -sr "$builddir" "$pkgdir/usr/src/$pkgbase"
169 }
170
171 _package-docs() {
172   pkgdesc="Documentation for the $pkgdesc kernel"
173
174   cd $_srcname
175   local builddir="$pkgdir/usr/lib/modules/$(<version)/build"
176
177   echo "Installing documentation..."
178   local src dst
179   while read -rd '' src; do
180     dst="${src#Documentation/}"
181     dst="$builddir/Documentation/${dst#output/}"
182     install -Dm644 "$src" "$dst"
183   done < <(find Documentation -name '.*' -prune -o ! -type d -print0)
184
185   echo "Adding symlink..."
186   mkdir -p "$pkgdir/usr/share/doc"
187   ln -sr "$builddir/Documentation" "$pkgdir/usr/share/doc/$pkgbase"
188 }
189
190 pkgname=("$pkgbase" "$pkgbase-headers" "$pkgbase-docs")
191 for _p in "${pkgname[@]}"; do
192   eval "package_$_p() {
193     $(declare -f "_package${_p#$pkgbase}")
194     _package${_p#$pkgbase}
195   }"
196 done
197
198 # vim:set ts=8 sts=2 sw=2 et: