OSDN Git Service

upg
[joborun/jobcore.git] / linux-lts / reference-material / PKGBUILD-88
1 #!/usr/bin/bash
2 # JOBoRun               : Jwm OpenBox Obarun RUNit
3 # Maintainer            : Joe Bo Run <joborun@disroot.org>
4 # PkgSource             : url="https://gittea.disroot.org/joborun/jobcore/$pkgname"
5 #-----------------------------------------| DESCRIPTION |---------------------------------------
6
7 pkgbase=linux-lts
8 pkgver=5.10.88
9 pkgrel=02
10 pkgdesc='LTS Linux'
11 _url="https://www.kernel.org/"
12 arch=(x86_64)
13 makedepends=(
14   bc kmod libelf pahole cpio perl tar xz
15   xmlto python-sphinx python-sphinx_rtd_theme graphviz imagemagick
16 )
17 options=('!strip')
18 _srcname=linux-$pkgver
19 url="https://cdn.kernel.org/pub/linux/kernel"
20 source=(
21   $url/v$pkgver%%.*.x/$_srcname.tar.{xz,sign}
22   config         # the main kernel config file
23   sha256sums
24   0001-ZEN-Add-sysctl-and-CONFIG-to-disallow-unprivileged-C.patch
25 #  0002-gcc-plugins-modern-gcc-plugin-infrastructure-requres.patch
26 #  fix-gpu-hang.diff
27   0002-HID-holtek-fix-mouse-probing.patch
28 )
29
30 export KBUILD_BUILD_HOST=joborun
31 export KBUILD_BUILD_USER=$pkgbase
32 export KBUILD_BUILD_TIMESTAMP="$(date -Ru${SOURCE_DATE_EPOCH:+d @$SOURCE_DATE_EPOCH})"
33
34 prepare() {
35   cd $_srcname
36   echo "Setting version... $pkgver"
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 joborun config..."
51   cp ../config .config
52   make olddefconfig
53 #return 1
54   make -s kernelrelease > version
55   echo "Prepared $pkgbase version $(<version)"
56 }
57
58 build() {
59   cd $_srcname
60   make all
61 }
62 ##  make htmldocs
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=(wireguard-lts)
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 #---- license gpg-key sha256sums ----
197
198 license=(GPL2)
199
200 validpgpkeys=(
201   'ABAF11C65A2970B130ABE3C479BE3E4300411886'  # Linus Torvalds
202   '647F28654894E3BD457199BE38DBBDC86092693E'  # Greg Kroah-Hartman
203 )
204
205 # https://www.kernel.org/pub/linux/kernel/v5.x/sha256sums.asc
206
207 sha256sums=(6f8631b6c382a2b0cfeff1e5f8805c8e1cfbe8d714b6e65f5bb79733c99068eb # linux-5.10.88.tar.xz
208         79115c89c930cde3d0de5305ccc0a073cf4de935d28409da2a5f95cf33f1ed7b # linux-5.10.88.tar.sign
209         6c9ac44e8cf06e37ab981524769c6b982c43cdc26e818740702182361fd55589 # config
210         f02d58b25a7656d6b3efdaa1c63772a1f2251f0a28e107bc90ccb3bf8350bfcd # sha256sums
211         96a72e1652314215da7140956c3abcf495cafd00811eda3cf4ce03ec5f791f1e # 0001-ZEN-Add-sysctl-and-CONFIG-to-disallow-unprivileged-C.patch
212         4753850a30c6a64e2bb27b1c07ea72f3c40b8c7ee73e890bbc4745860ce1798d) # 0002-HID-holtek-fix-mouse-probing.patch