OSDN Git Service

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