blob: 741abe88f42418009b5da5907f48b9a8fb77805c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
# Maintainer: VHSgunzo <vhsgunzo.github.io>
# Contributor: Torge Matthies <openglfreak at googlemail dot com>
# Contributor: Jan Alexander Steffens (heftig) <jan.steffens@gmail.com>
pkgname="linux-xanmod-bin"
pkgver='6.11.11' # example for rt branch: pkgver='6.1.73.rt22'
branch='main'
pkgrel="1"
check_psabi() {
awk 'BEGIN {
while (!/flags/) if (getline < "/proc/cpuinfo" != 1) exit 1
if (/lm/&&/cmov/&&/cx8/&&/fpu/&&/fxsr/&&/mmx/&&/syscall/&&/sse2/) level = 1
if (level == 1 && /cx16/&&/lahf/&&/popcnt/&&/sse4_1/&&/sse4_2/&&/ssse3/) level = 2
if (level == 2 && /avx/&&/avx2/&&/bmi1/&&/bmi2/&&/f16c/&&/fma/&&/abm/&&/movbe/&&/xsave/) level = 3
if (level == 3 && /avx512f/&&/avx512bw/&&/avx512cd/&&/avx512dq/&&/avx512vl/) level = 4
if (level > 0) { print "x64v" level }
}' 2>/dev/null||echo "x64v1"
}
is_exe_exist() { command -v "$@" &>/dev/null ; }
check_url_stat_code() {
set -o pipefail
if is_exe_exist curl
then curl -sL -o /dev/null -I -w "%{http_code}" "$@" 2>/dev/null
elif is_exe_exist wget
then wget --no-check-certificate --server-response \
--spider "$@"|& awk '/^ HTTP/{print$2}'|tail -1
else return 1
fi
}
is_url() {
[ ! -n "$1" ] && \
return 1
if [ -n "$2" ]
then [ "$(check_url_stat_code "$1")" == "$2" ]
else [ "$(check_url_stat_code "$1")" == "200" ]
fi
}
psabi="$(check_psabi)"
[ "$branch" != 'main' ] && \
pkgname="${pkgname/bin/${branch}-bin}"
[ "$branch" == 'rt' ] && \
pkgverdl="${pkgver/.rt/-rt}"||\
pkgverdl="${pkgver}"
pkgdesc='The Linux kernel, modules and headers with Xanmod patches - Prebuilt version'
url="http://www.xanmod.org/"
arch=('x86_64')
license=('GPL2')
options=('!strip')
depends=('coreutils' 'kmod' 'initramfs' 'pahole')
conflicts=("linux-xanmod-headers" 'linux-xanmod')
optdepends=('crda: to set the correct wireless channels of your country'
'linux-firmware: firmware images needed for some devices')
makedepends=('curl' 'gawk' 'grep' 'libarchive' 'xz' 'jq')
provides=('VIRTUALBOX-GUEST-MODULES'
'WIREGUARD-MODULE'
'KSMBD-MODULE'
'NTFS3-MODULE')
for v in ${psabi/x64v/} 3 2 1
do
[[ "$v" -le "${psabi/x64v/}" && "$_psabi" != "x64v$v" ]]||continue
_psabi="x64v$v"
_url="https://sourceforge.net/projects/xanmod/files/releases/$branch/${pkgverdl}-xanmod1/${pkgverdl}-${_psabi}-xanmod1"
if is_url "$_url"
then psabi="$_psabi" && break
fi
done
_url_info="$(curl -sL "$_url"|grep "net.sf.files"|sed 's|net.sf.files = ||g;s|;$||'|jq -r '.[].download_url'|grep -v '\-dbg_')"
_url_image="$(echo "$_url_info"|grep -o "https:.*/linux-image.*deb"|head -1)"
_url_headers="$(echo "$_url_info"|grep -o "https:.*/linux-headers.*deb"|head -1)"
source=("${_url_image}" "${_url_headers}")
noextract=("${_url_image}" "${_url_headers}")
sha256sums=('SKIP' 'SKIP')
_file_image="${_url_image##*/}"
_file_headers="${_url_headers##*/}"
prepare() {
bsdtar -xf ${_file_image} data.tar.xz
bsdtar -xf data.tar.xz
rm -f data.tar.xz
bsdtar -xf ${_file_headers} data.tar.xz
bsdtar -xf data.tar.xz
rm -f data.tar.xz
}
package() {
local kernver="${pkgverdl}-$psabi-xanmod1"
local modulesdir="$pkgdir/usr/lib/modules/${kernver}"
mkdir -p "${modulesdir}"
msg2 "Installing modules..."
cp -arTf --no-preserve=ownership "lib/modules/${kernver}" "${modulesdir}"
cp -arTf --no-preserve=ownership usr "${pkgdir}/usr"
msg2 "Installing boot image..."
# systemd expects to find the kernel here to allow hibernation
# https://github.com/systemd/systemd/commit/edda44605f06a41fb86b7ab8128dcf99161d2344
install -Dm644 "boot/vmlinuz-${kernver}" "$modulesdir/vmlinuz"
# Used by mkinitcpio to name the kernel
echo "${pkgname%-bin}" | install -Dm644 /dev/stdin "$modulesdir/pkgbase"
}
|