-
Notifications
You must be signed in to change notification settings - Fork 0
/
PKGBUILD
181 lines (142 loc) · 5.82 KB
/
PKGBUILD
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
# Maintainer: Carl Perry <[email protected]>
pkgbase=linux-edolnx-sifive-p550-dgpu
_variant=edolnx-dgpu
pkgver=6.6.21
epoch=01 #Based on edolnx image version
pkgrel=1
_tag=53bc59aaa58961ab8c22b175449948fc2d7df599
_desc='Linux 6.6.x (-edolnx) for SiFive HiFive P550 Premier Board'
_srcname=riscv-linux-$_tag
url="https://github.com/sifive/riscv-linux"
arch=(riscv64)
license=('GPL2')
makedepends=(bc libelf pahole cpio perl tar xz gcc)
options=('!strip')
source=("https://github.com/sifive/riscv-linux/archive/$_tag.tar.gz"
'linux-riscv-dts-hifive-premier-p550-Enable-I2C1.patch'
'config')
sha256sums=('1b11c63074959accf51047843e81af529dd0f1c31d392e812ac2178bb2bd514c'
'59e0bc42c658c403970b3d7344f53709519c33a39c0e097d9d8b302f990919d8'
'192a8fa3f953d500a180125a89c75a687317bf2142940ca5ec035a81cfc73137')
prepare() {
cd $_srcname
local src
for src in $(ls ../linux-*.patch); do
echo "Applying patch $src..."
patch -Np1 <"../$src"
done
echo "Setting version..."
echo "-${_variant}" >localversion.10-variant
echo "-${pkgver}" >localversion.20-pkgver
echo "-$pkgrel" >localversion.30-pkgrel
echo "Setting config..."
cp ../config .config
make -j $(nproc) ARCH=riscv CC="${CROSS_COMPILE:-}gcc" olddefconfig
cp .config ../../config.new
make -j $(nproc) ARCH=riscv CC="${CROSS_COMPILE:-}gcc" -s kernelrelease >version
echo "Prepared $pkgbase version $(<version)"
}
build() {
cd $_srcname
make -j $(nproc) ARCH=riscv CC="${CROSS_COMPILE:-}gcc" all
}
_package() {
pkgdesc="The $_desc kernel and modules"
depends=(coreutils kmod mkinitcpio)
optdepends=('wireless-regdb: to set the correct wireless channels of your country'
'linux-firmware: firmware images needed for some devices')
provides=("linux=${pkgver}" "WIREGUARD-MODULE")
conflicts=('linux')
cd $_srcname
local kernver="$(<version)"
local modulesdir="$pkgdir/usr/lib/modules/$kernver"
echo "Installing boot image..."
install -Dm644 "arch/riscv/boot/Image" "$modulesdir/Image"
install -Dm644 "arch/riscv/boot/Image" "$pkgdir/boot/arch/Image"
echo "Installing modules..."
make -j $(nproc) ARCH=riscv INSTALL_MOD_PATH="$pkgdir/usr" INSTALL_MOD_STRIP=1 modules_install
echo "Installing dtbs..."
make -j $(nproc) ARCH=riscv INSTALL_DTBS_PATH="$pkgdir/usr/share/dtbs/$kernver" dtbs_install
make -j $(nproc) ARCH=riscv INSTALL_DTBS_PATH="$pkgdir/boot/dtbs/" dtbs_install
# remove build links
rm "$modulesdir"/build
}
_package-headers() {
pkgdesc="Headers and scripts for building modules for the $_desc kernel"
depends=(pahole)
provides=("linux-headers=${pkgver}")
conflicts=('linux-headers')
cd $_srcname
local builddir="$pkgdir/usr/lib/modules/$(<version)/build"
echo "Installing build files..."
install -Dt "$builddir" -m644 .config Makefile Module.symvers System.map version
install -Dt "$builddir/kernel" -m644 kernel/Makefile
install -Dt "$builddir/arch/riscv" -m644 arch/riscv/Makefile
cp -t "$builddir" -a scripts
# required when DEBUG_INFO_BTF_MODULES is enabled
cp --parents -r -t "$builddir/" tools/bpf/resolve_btfids
echo "Installing VDSO files..."
cp -a --parents -r -t "$builddir" arch/riscv/kernel/vdso/*
cp -a --parents -r -t "$builddir" lib/vdso/*
chmod -R g+w "$builddir/arch/riscv/kernel/vdso"
echo "Installing certificate files..."
#install -Dt "$builddir/certs" -m640 certs/*.pem
install -Dt "$builddir/certs" -m640 certs/*.x509
echo "Installing headers..."
cp -t "$builddir" -a include
chmod -R g+w "$builddir/include/generated"
cp -t "$builddir/arch/riscv" -a arch/riscv/include
install -Dt "$builddir/arch/riscv/kernel" -m644 arch/riscv/kernel/asm-offsets.s
install -Dt "$builddir/drivers/md" -m644 drivers/md/*.h
install -Dt "$builddir/net/mac80211" -m644 net/mac80211/*.h
# https://bugs.archlinux.org/task/13146
install -Dt "$builddir/drivers/media/i2c" -m644 drivers/media/i2c/msp3400-driver.h
# https://bugs.archlinux.org/task/20402
install -Dt "$builddir/drivers/media/usb/dvb-usb" -m644 drivers/media/usb/dvb-usb/*.h
install -Dt "$builddir/drivers/media/dvb-frontends" -m644 drivers/media/dvb-frontends/*.h
install -Dt "$builddir/drivers/media/tuners" -m644 drivers/media/tuners/*.h
# https://bugs.archlinux.org/task/71392
install -Dt "$builddir/drivers/iio/common/hid-sensors" -m644 drivers/iio/common/hid-sensors/*.h
echo "Installing KConfig files..."
find . -name 'Kconfig*' -exec install -Dm644 {} "$builddir/{}" \;
echo "Removing unneeded architectures..."
local arch
for arch in "$builddir"/arch/*/; do
[[ $arch = */riscv/ ]] && continue
echo "Removing $(basename "$arch")"
rm -r "$arch"
done
echo "Installing RAS from x86..."
install -Dt "$builddir/arch/x86/ras" -m644 arch/x86/ras/Kconfig
echo "Removing documentation..."
rm -r "$builddir/Documentation"
echo "Removing broken symlinks..."
find -L "$builddir" -type l -printf 'Removing %P\n' -delete
echo "Removing loose objects..."
find "$builddir" -type f -name '*.o' -printf 'Removing %P\n' -delete
echo "Stripping build tools..."
local file
while read -rd '' file; do
case "$(file -bi "$file")" in
application/x-sharedlib\;*) # Libraries (.so)
strip -v $STRIP_SHARED "$file" ;;
application/x-archive\;*) # Libraries (.a)
strip -v $STRIP_STATIC "$file" ;;
application/x-executable\;*) # Binaries
strip -v $STRIP_BINARIES "$file" ;;
application/x-pie-executable\;*) # Relocatable binaries
strip -v $STRIP_SHARED "$file" ;;
esac
done < <(find "$builddir" -type f -perm -u+x ! -name vmlinux -print0)
echo "Adding symlink..."
mkdir -p "$pkgdir/usr/src"
ln -sr "$builddir" "$pkgdir/usr/src/$pkgbase"
}
pkgname=("$pkgbase" "$pkgbase-headers")
for _p in "${pkgname[@]}"; do
eval "package_$_p() {
$(declare -f "_package${_p#$pkgbase}")
_package${_p#$pkgbase}
}"
done
# vim:set ts=8 sts=2 sw=2 et: