Skip to content

Commit

Permalink
updpatch: linux-sophgo
Browse files Browse the repository at this point in the history
- Enable -multi variant
- Add support for setting values in patch-linux-config.sh
  • Loading branch information
felixonmars committed Nov 16, 2023
1 parent 466bb91 commit 03de160
Show file tree
Hide file tree
Showing 5 changed files with 526 additions and 18 deletions.
73 changes: 70 additions & 3 deletions linux-sophgo/PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,20 @@ source=(
git+https://github.com/sophgo/linux-riscv.git#commit=$_commit
config # the main kernel config file
riscv64.config-patch
riscv64-multi.config-patch
)
sha256sums=('SKIP'
'20e2f62eb004af3f47609b4ab3380d8e870d51eba0df5f318a565910eada3503'
'f7c634cb4ae105f20e86eb6a087b84efd9ca5e5b9a4a8cda7d311aed19404d3c')
'2fa6d3552c0c00b720ea6e7168e565a95a28bb2707dec7068a27c1ca522b995c'
'c9f6809336e557f8d5302aa179d6fee09e848eca7a4c3e7574ba518f956e4893'
'479062d0178a6aed45288c6c4907dcaf448c0bb12785d3a42a17641e301c370d')

export KBUILD_BUILD_HOST=archlinux
export KBUILD_BUILD_USER=$pkgbase
export KBUILD_BUILD_TIMESTAMP="$(date -Ru${SOURCE_DATE_EPOCH:+d @$SOURCE_DATE_EPOCH})"

prepare() {
cp -r $_srcname $_srcname-multi

cd $_srcname

echo "Setting version..."
Expand Down Expand Up @@ -57,11 +61,44 @@ prepare() {

make -s kernelrelease > version
echo "Prepared $pkgbase version $(<version)"

cd ../$_srcname-multi

echo "Setting version..."
scripts/setlocalversion --save-scmversion
echo "-$pkgrel" > localversion.10-pkgrel
echo "${pkgbase#linux}-multi" > localversion.20-pkgname

local src
for src in "${source[@]}"; do
src="${src%%::*}"
src="${src##*/}"
[[ $src = *.patch ]] || continue
echo "Applying patch $src..."
patch -Np1 < "../$src"
done

echo "Setting config..."
cp ../config .config
make olddefconfig
diff -u ../config .config || :

patch -Np0 < ../riscv64-multi.config-patch
mv .config .config.1
make mrproper
mv .config.1 .config
make olddefconfig

make -s kernelrelease > version
echo "Prepared $pkgbase version $(<version)"
}

build() {
cd $_srcname
make htmldocs all

cd ../$_srcname-multi
make all
}

_package() {
Expand Down Expand Up @@ -94,6 +131,36 @@ _package() {
rm "$modulesdir"/{source,build}
}

_package-multi() {
pkgdesc="The $pkgdesc-multi kernel and modules"
depends=(coreutils kmod initramfs)
optdepends=('wireless-regdb: to set the correct wireless channels of your country'
'linux-firmware: firmware images needed for some devices')
provides=(VIRTUALBOX-GUEST-MODULES WIREGUARD-MODULE KSMBD-MODULE)

cd $_srcname-multi
local kernver="$(<version)"
local modulesdir="$pkgdir/usr/lib/modules/$kernver"

echo "Installing boot image..."
# systemd expects to find the kernel here to allow hibernation
# https://github.com/systemd/systemd/commit/edda44605f06a41fb86b7ab8128dcf99161d2344
install -Dm644 "$(make -s image_name)" "$modulesdir/vmlinuz"

# Used by mkinitcpio to name the kernel
echo "$pkgbase" | install -Dm644 /dev/stdin "$modulesdir/pkgbase"

echo "Installing modules..."
ZSTD_CLEVEL=19 make INSTALL_MOD_PATH="$pkgdir/usr" INSTALL_MOD_STRIP=1 \
DEPMOD=/doesnt/exist modules_install # Suppress depmod

echo "Installing dtbs..."
make INSTALL_DTBS_PATH="$pkgdir/usr/share/dtbs/$kernver" dtbs_install

# remove build and source links
rm "$modulesdir"/{source,build}
}

_package-headers() {
pkgdesc="Headers and scripts for building modules for the $pkgdesc kernel"
depends=(pahole)
Expand Down Expand Up @@ -192,7 +259,7 @@ _package-docs() {
ln -sr "$builddir/Documentation" "$pkgdir/usr/share/doc/$pkgbase"
}

pkgname=("$pkgbase" "$pkgbase-headers" "$pkgbase-docs")
pkgname=("$pkgbase" "$pkgbase-multi" "$pkgbase-headers" "$pkgbase-docs")
for _p in "${pkgname[@]}"; do
eval "package_$_p() {
$(declare -f "_package${_p#$pkgbase}")
Expand Down
22 changes: 9 additions & 13 deletions linux-sophgo/config
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#
# Automatically generated file; DO NOT EDIT.
# Linux/x86 6.1.39 Kernel Configuration
# Linux/x86 6.1.62 Kernel Configuration
#
CONFIG_CC_VERSION_TEXT="gcc (GCC) 13.1.1 20230714"
CONFIG_CC_VERSION_TEXT="gcc (GCC) 13.2.1 20230801"
CONFIG_CC_IS_GCC=y
CONFIG_GCC_VERSION=130101
CONFIG_GCC_VERSION=130201
CONFIG_CLANG_VERSION=0
CONFIG_AS_IS_GNU=y
CONFIG_AS_VERSION=24000
CONFIG_AS_VERSION=24100
CONFIG_LD_IS_BFD=y
CONFIG_LD_VERSION=24000
CONFIG_LD_VERSION=24100
CONFIG_LLD_VERSION=0
CONFIG_CC_CAN_LINK=y
CONFIG_CC_CAN_LINK_STATIC=y
Expand Down Expand Up @@ -528,7 +528,9 @@ CONFIG_RETHUNK=y
CONFIG_CPU_UNRET_ENTRY=y
CONFIG_CPU_IBPB_ENTRY=y
CONFIG_CPU_IBRS_ENTRY=y
CONFIG_CPU_SRSO=y
CONFIG_SLS=y
# CONFIG_GDS_FORCE_MITIGATION is not set
CONFIG_ARCH_HAS_ADD_PAGES=y
CONFIG_ARCH_MHP_MEMMAP_ON_MEMORY_ENABLE=y

Expand Down Expand Up @@ -774,6 +776,7 @@ CONFIG_GENERIC_SMP_IDLE_THREAD=y
CONFIG_ARCH_HAS_FORTIFY_SOURCE=y
CONFIG_ARCH_HAS_SET_MEMORY=y
CONFIG_ARCH_HAS_SET_DIRECT_MAP=y
CONFIG_ARCH_HAS_CPU_FINALIZE_INIT=y
CONFIG_HAVE_ARCH_THREAD_STRUCT_WHITELIST=y
CONFIG_ARCH_WANTS_DYNAMIC_TASK_STRUCT=y
CONFIG_ARCH_WANTS_NO_INSTR=y
Expand Down Expand Up @@ -1787,8 +1790,6 @@ CONFIG_NET_CLS_FW=m
CONFIG_NET_CLS_U32=m
CONFIG_CLS_U32_PERF=y
CONFIG_CLS_U32_MARK=y
CONFIG_NET_CLS_RSVP=m
CONFIG_NET_CLS_RSVP6=m
CONFIG_NET_CLS_FLOW=m
CONFIG_NET_CLS_CGROUP=m
CONFIG_NET_CLS_BPF=m
Expand Down Expand Up @@ -6175,10 +6176,7 @@ CONFIG_MEDIA_ATTACH=y
# IR I2C driver auto-selected by 'Autoselect ancillary drivers'
#
CONFIG_VIDEO_IR_I2C=m

#
# Camera sensor devices
#
CONFIG_VIDEO_CAMERA_SENSOR=y
CONFIG_VIDEO_APTINA_PLL=m
CONFIG_VIDEO_CCS_PLL=m
CONFIG_VIDEO_AR0521=m
Expand Down Expand Up @@ -6244,7 +6242,6 @@ CONFIG_VIDEO_VS6624=m
CONFIG_VIDEO_CCS=m
CONFIG_VIDEO_ET8EK8=m
CONFIG_VIDEO_M5MOLS=m
# end of Camera sensor devices

#
# Lens drivers
Expand Down Expand Up @@ -10384,7 +10381,6 @@ CONFIG_INTEGRITY_MACHINE_KEYRING=y
CONFIG_LOAD_UEFI_KEYS=y
CONFIG_INTEGRITY_AUDIT=y
# CONFIG_IMA is not set
# CONFIG_IMA_KEYRINGS_PERMIT_SIGNED_BY_BUILTIN_OR_SECONDARY is not set
# CONFIG_IMA_SECURE_AND_OR_TRUSTED_BOOT is not set
# CONFIG_EVM is not set
# CONFIG_DEFAULT_SECURITY_SELINUX is not set
Expand Down
Loading

0 comments on commit 03de160

Please sign in to comment.