Skip to content

Commit

Permalink
add blobby, hybrid linux kernel packages
Browse files Browse the repository at this point in the history
  • Loading branch information
SolidHal committed Nov 17, 2024
1 parent 4d35a74 commit e4eecc7
Show file tree
Hide file tree
Showing 39 changed files with 646 additions and 79 deletions.
117 changes: 85 additions & 32 deletions kernel/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ include $(PRAWNOS_ROOT)/scripts/BuildScripts/BuildCommon.mk
include $(PRAWNOS_ROOT)/initramfs/makefile

### TARGETED VARS ###
KERNEL_PATCHED := $(PRAWNOS_KERNEL_BUILD)/.kernel_patched
KERNEL_EXTRACTED := $(PRAWNOS_KERNEL_BUILD)/.kernel_extracted
KERNEL_PATCHED := $(PRAWNOS_KERNEL_BUILD)/.kernel_$(KERNEL_TYPE)_patched
KERNEL_EXTRACTED := $(PRAWNOS_KERNEL_BUILD)/.kernel_$(KERNEL_TYPE)_extracted
KERNEL_CONFIG_GENERATED := $(PRAWNOS_KERNEL_BUILD)/.kernel_$(KERNEL_TYPE)_config_generated

KERNEL_SHARED_RESOURCES := $(PRAWNOS_KERNEL)/resources/shared
KERNEL_RESOURCES := $(PRAWNOS_KERNEL)/resources/$(TARGET)
Expand All @@ -26,19 +27,27 @@ KERNEL_LIBRE_TAR_SIGNATURE_BASENAME := $(KERNEL_LIBRE_BASENAME).sign
KERNEL_LIBRE_TAR_SIGNATURE := $(PRAWNOS_BUILD_SOURCES)/$(KERNEL_LIBRE_TAR_SIGNATURE_BASENAME)
KERNEL_LIBRE_TAR_SIGNATURE_TARGET_BASENAME := $(KERNEL_LIBRE_BASENAME)
KERNEL_LIBRE_TAR_SIGNATURE_TARGET := $(PRAWNOS_BUILD_SOURCES)/$(KERNEL_LIBRE_TAR_SIGNATURE_TARGET_BASENAME)
KERNEL_LIBRE_SOURCE_NAME := linux-$(KVER)-libre-$(TARGET)
KERNEL_LIBRE_PUBKEY := $(KERNEL_SHARED_RESOURCES)/linux-libre-signing-key.gpg

# hybrid kernel: Blobby wifi and bluetooth in an otherwise libre kernel
# As ATH9k devices and 2.4GHZ wifi become less commonly available, and no new wifi adapters with fully open
# source firmware and drivers have become available, its hard to stick to using blob-free wifi
# Let users compromise by re-adding blobby wifi to their otherwise blob-free kernel
KERNEL_HYBRID_CONFIG := $(PRAWNOS_BUILD)/hybrid-kernel-config
KERNEL_HYBRID_CONFIG_FRAGMENT := $(KERNEL_RESOURCES)/hybrid-config.fragment
KERNEL_HYBRID_SOURCE_NAME := linux-$(KVER)-hybrid-$(TARGET)

# Default to a libre kernel. blobby_kernel target will override if needed:
BLOBBY_BUILD := 0
# Blobby kernel vars
KERNEL_BLOBBY_CONFIG := $(KERNEL_RESOURCES)/blobby-config
KERNEL_BLOBBY_URL := https://cdn.kernel.org/pub/linux/kernel/v5.x/
KERNEL_BLOBBY_BASENAME := linux-$(KVER).tar.lz
KERNEL_BLOBBY_URL := https://cdn.kernel.org/pub/linux/kernel/v6.x/
KERNEL_BLOBBY_BASENAME := linux-$(KVER).tar.xz
KERNEL_BLOBBY_TAR := $(PRAWNOS_BUILD_SOURCES)/$(KERNEL_BLOBBY_BASENAME)
KERNEL_BLOBBY_TAR_SIGNATURE_TARGET_BASENAME := linux-$(KVER).tar
KERNEL_BLOBBY_TAR_SIGNATURE_BASENAME := $(KERNEL_BLOBBY_TAR_SIGNATURE_TARGET_BASENAME).sign
KERNEL_BLOBBY_TAR_SIGNATURE := $(PRAWNOS_BUILD_SOURCES)/$(KERNEL_BLOBBY_TAR_SIGNATURE_BASENAME)
KERNEL_BLOBBY_TAR_SIGNATURE_TARGET := $(PRAWNOS_BUILD_SOURCES)/$(KERNEL_BLOBBY_TAR_SIGNATURE_TARGET_BASENAME)
KERNEL_BLOBBY_SOURCE_NAME := linux-$(KVER)-blobby-$(TARGET)
KERNEL_BLOBBY_PUBKEY := $(KERNEL_SHARED_RESOURCES)/blobby-linux-signing-key.gpg

ATH9K_EXTRACTED := $(PRAWNOS_ATH9K_BUILD)/.ath9k_extracted
Expand Down Expand Up @@ -79,7 +88,7 @@ kernel_image_package_install: kernel_image_package


.PHONY: kernel_config
kernel_config: $(KERNEL_PATCHED)
kernel_config: $(KERNEL_PATCHED) $(KERNEL_CONFIG_GENERATED)
$(PRAWNOS_KERNEL_SCRIPTS_MENUCONFIG) $(KERNEL_RESOURCES) $(PRAWNOS_KERNEL_BUILD) $(TARGET) $(KERNEL_CONFIG)

### CLEAN RULES
Expand Down Expand Up @@ -107,19 +116,14 @@ update_ath9k_tar:
cd tmp && tar czvf $(ATH9K_SOURCE) $(ATH9K)
rm -rf tmp/

.PHONY: blobby_kernel
blobby_kernel:
$(MAKE) BLOBBY_BUILD=1 kernel


#TODO: package perf/linux-tools
.PHONY: perf
perf: $(PRAWNOS_KERNEL_BUILT)
$(PRAWNOS_KERNEL_SCRIPTS_PERF) $(KVER) $(KERNEL_RESOURCES) $(PRAWNOS_KERNEL_BUILD) $(PRAWNOS_INITRAMFS_IMAGE) $(TARGET)

### REAL RULES

ifeq ($(BLOBBY_BUILD),0)
ifeq ($(KERNEL_TYPE),$(PRAWNOS_LIBRE_KERNEL))
KERNEL_CONFIG := $(KERNEL_LIBRE_CONFIG)
KERNEL_URL := $(KERNEL_LIBRE_URL)
KERNEL_BASENAME := $(KERNEL_LIBRE_BASENAME)
Expand All @@ -129,7 +133,19 @@ KERNEL_TAR_SIGNATURE_BASENAME := $(KERNEL_LIBRE_TAR_SIGNATURE_BASENAME)
KERNEL_TAR_SIGNATURE_TARGET := $(KERNEL_LIBRE_TAR_SIGNATURE_TARGET)
KERNEL_TAR_SIGNATURE_TARGET_BASENAME := $(KERNEL_LIBRE_TAR_SIGNATURE_TARGET_BASENAME)
KERNEL_PUBKEY := $(KERNEL_LIBRE_PUBKEY)
else

else ifeq ($(KERNEL_TYPE),$(PRAWNOS_HYBRID_KERNEL))
KERNEL_CONFIG := $(KERNEL_HYBRID_CONFIG)
KERNEL_URL := $(KERNEL_LIBRE_URL)
KERNEL_BASENAME := $(KERNEL_LIBRE_BASENAME)
KERNEL_TAR := $(KERNEL_LIBRE_TAR)
KERNEL_TAR_SIGNATURE := $(KERNEL_LIBRE_TAR_SIGNATURE)
KERNEL_TAR_SIGNATURE_BASENAME := $(KERNEL_LIBRE_TAR_SIGNATURE_BASENAME)
KERNEL_TAR_SIGNATURE_TARGET := $(KERNEL_LIBRE_TAR_SIGNATURE_TARGET)
KERNEL_TAR_SIGNATURE_TARGET_BASENAME := $(KERNEL_LIBRE_TAR_SIGNATURE_TARGET_BASENAME)
KERNEL_PUBKEY := $(KERNEL_LIBRE_PUBKEY)

else ifeq ($(KERNEL_TYPE),$(PRAWNOS_BLOBBY_KERNEL))
KERNEL_CONFIG := $(KERNEL_BLOBBY_CONFIG)
KERNEL_URL := $(KERNEL_BLOBBY_URL)
KERNEL_BASENAME := $(KERNEL_BLOBBY_BASENAME)
Expand All @@ -145,6 +161,9 @@ $(KERNEL_ATH9K_FIRMWARES):
mkdir -p $(KERNEL_ATH9K_FIRMWARES)

$(KERNEL_TAR_SIGNATURE): | $(PRAWNOS_BUILD_SOURCES)
ifeq ($(KERNEL_TYPE),$(PRAWNOS_HYBRID_KERNEL))
wget $(WGET_OPTS) $(KERNEL_BLOBBY_URL)/$(KERNEL_BLOBBY_TAR_SIGNATURE_BASENAME) -O $(KERNEL_BLOBBY_TAR_SIGNATURE)
endif
wget $(WGET_OPTS) $(KERNEL_URL)/$(KERNEL_TAR_SIGNATURE_BASENAME) -O $(KERNEL_TAR_SIGNATURE)

$(KERNEL_EXTRACTED): $(KERNEL_TAR) $(KERNEL_TAR_SIGNATURE)
Expand All @@ -156,34 +175,68 @@ $(KERNEL_EXTRACTED): $(KERNEL_TAR) $(KERNEL_TAR_SIGNATURE)
git clone https://github.com/SolidHal/rk3588-kernel-libre $(PRAWNOS_BUILD)/linux-$(KVER)
touch $(KERNEL_EXTRACTED)
else
## we use standard linux or linux-libre sources
ifeq ($(KERNEL_TYPE),$(PRAWNOS_LIBRE_KERNEL))
gpg --import $(KERNEL_PUBKEY)
case $(BLOBBY_BUILD) in \
0) \
gpg --verify $(KERNEL_TAR_SIGNATURE) $(KERNEL_TAR_SIGNATURE_TARGET) && \
tar --lzip -xf $(KERNEL_TAR) -C $(PRAWNOS_BUILD) && \
touch $(KERNEL_EXTRACTED) \
;; \
1) \
if [ ! -f $(KERNEL_TAR_SIGNATURE_TARGET) ]; then xz --decompress --keep $(KERNEL_TAR) ; fi ; \
gpg --verify $(KERNEL_TAR_SIGNATURE) $(KERNEL_TAR_SIGNATURE_TARGET) && \
tar -xf $(KERNEL_TAR_SIGNATURE_TARGET) -C $(PRAWNOS_BUILD) && \
touch $(KERNEL_EXTRACTED) \
;; \
*) \
@echo "Unknown kernel type"; \
exit 1 \
;; \
esac
gpg --verify $(KERNEL_TAR_SIGNATURE) $(KERNEL_TAR_SIGNATURE_TARGET) && \
tar --lzip -xf $(KERNEL_TAR) -C $(PRAWNOS_BUILD) && \
mv $(PRAWNOS_BUILD)/linux-$(KVER) $(PRAWNOS_KERNEL_BUILD) && \
touch $(KERNEL_EXTRACTED)

else ifeq ($(KERNEL_TYPE),$(PRAWNOS_HYBRID_KERNEL))
gpg --import $(KERNEL_LIBRE_PUBKEY)
gpg --import $(KERNEL_BLOBBY_PUBKEY)
rm -rf $(PRAWNOS_BUILD)/$(KERNEL_LIBRE_SOURCE_NAME)
rm -rf $(PRAWNOS_BUILD)/$(KERNEL_BLOBBY_SOURCE_NAME)
rm -rf $(PRAWNOS_BUILD)/$(KERNEL_HYBRID_SOURCE_NAME)
gpg --verify $(KERNEL_LIBRE_TAR_SIGNATURE) $(KERNEL_LIBRE_TAR_SIGNATURE_TARGET) && \
tar --lzip -xf $(KERNEL_LIBRE_TAR) -C $(PRAWNOS_BUILD) && \
mv $(PRAWNOS_BUILD)/linux-$(KVER) $(PRAWNOS_BUILD)/$(KERNEL_LIBRE_SOURCE_NAME) && \
if [ ! -f $(KERNEL_BLOBBY_TAR_SIGNATURE_TARGET) ]; then xz --decompress --keep $(KERNEL_BLOBBY_TAR) ; fi ; \
gpg --verify $(KERNEL_BLOBBY_TAR_SIGNATURE) $(KERNEL_BLOBBY_TAR_SIGNATURE_TARGET) && \
tar -xf $(KERNEL_BLOBBY_TAR_SIGNATURE_TARGET) -C $(PRAWNOS_BUILD) && \
mv $(PRAWNOS_BUILD)/linux-$(KVER) $(PRAWNOS_BUILD)/$(KERNEL_BLOBBY_SOURCE_NAME) && \
cp -a $(PRAWNOS_BUILD)/$(KERNEL_LIBRE_SOURCE_NAME) $(PRAWNOS_KERNEL_BUILD) && \
rm -rf $(PRAWNOS_KERNEL_BUILD)/drivers/net/wireless/marvell && \
cp -a $(PRAWNOS_BUILD)/$(KERNEL_BLOBBY_SOURCE_NAME)/drivers/net/wireless/marvell $(PRAWNOS_KERNEL_BUILD)/drivers/net/wireless/ && \
touch $(KERNEL_EXTRACTED)

else ifeq ($(KERNEL_TYPE),$(PRAWNOS_BLOBBY_KERNEL))
gpg --import $(KERNEL_BLOBBY_PUBKEY)
if [ ! -f $(KERNEL_TAR_SIGNATURE_TARGET) ]; then xz --decompress --keep $(KERNEL_TAR) ; fi ; \
gpg --verify $(KERNEL_TAR_SIGNATURE) $(KERNEL_TAR_SIGNATURE_TARGET) && \
tar -xf $(KERNEL_TAR_SIGNATURE_TARGET) -C $(PRAWNOS_BUILD) && \
mv $(PRAWNOS_BUILD)/linux-$(KVER) $(PRAWNOS_KERNEL_BUILD) && \
touch $(KERNEL_EXTRACTED)
else
@echo "Unknown kernel type:" $(KERNEL_TYPE)
exit 1
endif
endif

$(KERNEL_TAR): | $(PRAWNOS_BUILD_LOGS) $(PRAWNOS_BUILD_SOURCES)
ifeq ($(KERNEL_TYPE),$(PRAWNOS_HYBRID_KERNEL))
wget $(WGET_OPTS) $(KERNEL_BLOBBY_URL)/$(KERNEL_BLOBBY_BASENAME) -O $(KERNEL_BLOBBY_TAR)
endif
wget $(WGET_OPTS) $(KERNEL_URL)/$(KERNEL_BASENAME) -O $(KERNEL_TAR)


$(KERNEL_PATCHED): $(KERNEL_EXTRACTED)
@echo $(PRAWNOS_KERNEL_BUILD)
$(PRAWNOS_KERNEL_SCRIPTS_PATCH) $(KVER) $(KERNEL_PATCHES) $(PRAWNOS_KERNEL_BUILD) $(TARGET)
touch $(KERNEL_PATCHED)

$(KERNEL_CONFIG_GENERATED): $(KERNEL_EXTRACTED)
ifeq ($(KERNEL_TYPE),$(PRAWNOS_HYBRID_KERNEL))
@echo Generating hybrid kernel config from libre kernel config $(KERNEL_LIBRE_CONFIG)
rm -f $(KERNEL_HYBRID_CONFIG)
cp $(KERNEL_LIBRE_CONFIG) $(KERNEL_HYBRID_CONFIG)
$(PRAWNOS_KERNEL_SCRIPTS_GENERATE_CONFIG) $(KERNEL_RESOURCES) $(PRAWNOS_KERNEL_BUILD) $(TARGET) $(KERNEL_HYBRID_CONFIG) $(KERNEL_HYBRID_CONFIG_FRAGMENT)
else
@echo nothing to do for config for $(KERNEL_TYPE)
endif
touch $(KERNEL_CONFIG_GENERATED)

$(ATH9K_EXTRACTED): | $(PRAWNOS_BUILD_LOGS) $(PRAWNOS_BUILD_SOURCES) $(PRAWNOS_BUILD_SHARED)
tar -xvf $(ATH9K_TAR) -C $(PRAWNOS_BUILD_SHARED)
touch $(ATH9K_EXTRACTED)
Expand All @@ -196,7 +249,7 @@ $(KERNEL_ATH9K_INSTALLED): $(KERNEL_PATCHED) $(ATH9K_BUILT) | $(KERNEL_ATH9K_FIR
cp $(ATH9K_9271_FW) $(KERNEL_ATH9K_FIRMWARES)/
cp $(ATH9K_7010_FW) $(KERNEL_ATH9K_FIRMWARES)/

$(PRAWNOS_KERNEL_BUILT): $(KERNEL_ATH9K_INSTALLED) $(PRAWNOS_INITRAMFS_IMAGE)
$(PRAWNOS_KERNEL_BUILT): $(KERNEL_ATH9K_INSTALLED) $(PRAWNOS_INITRAMFS_IMAGE) $(KERNEL_CONFIG_GENERATED)
# rebuilding the kernel means we also need to rebuild the kernel package
$(MAKE) -C $(PRAWNOS_KERNEL_PACKAGE_IMAGE) clean
rm -rf $(KERNEL_BUILD_LOG)
Expand Down
35 changes: 0 additions & 35 deletions kernel/packages/prawnos-linux-image-arm64/src/debian/changelog

This file was deleted.

27 changes: 27 additions & 0 deletions kernel/packages/prawnos-linux-image-blobby-arm64/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#only include specific /debian files
src/debian/*
!src/debian/compat
!src/debian/changelog
!src/debian/control
!src/debian/copyright
!src/debian/rules
!src/debian/install
!src/debian/postinst
!src/debian/source

#generic packaging artifacts
debhelper-build-stamp
.debhelper
*.deb
*.dsc
*.build
*.buildinfo
*.changes
*.log
*.substvars
*.diff.gz
*.upload
*.orig.tar.gz

#kernel image specific ignores
prawnos-linux-image-blobby-arm64_*.debian.tar.xz
75 changes: 75 additions & 0 deletions kernel/packages/prawnos-linux-image-blobby-arm64/makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
.DEFAULT_GOAL := default
#import all shared make vars
PRAWNOS_ROOT := $(shell git rev-parse --show-toplevel)
include $(PRAWNOS_ROOT)/scripts/BuildScripts/BuildCommon.mk

ifneq ($(TARGET),$(PRAWNOS_ARM64))
$(error Cant build arm64 kernel package with non arm64 target)
endif

ifneq ($(KERNEL_TYPE),$(PRAWNOS_HYBRID_KERNEL))
$(error Cant build arm64 hybrid kernel package with KERNEL_TYPE not set to hybrid-kernel)
endif

#package specific vars
DEB_VERSION := $(PRAWNOS_KERNEL_IMAGE_CAT_DEB_VER)
PRAWNOS_VERSION := $(PRAWNOS_KERNEL_IMAGE_CAT_PRAWNOS_VER)
PACKAGE := prawnos-linux-image-blobby-arm64
PACKAGE_ARCH := arm64

#uses the full debian version for the package name
PACKAGE_NAME := $(PACKAGE)_$(DEB_VERSION)_$(PACKAGE_ARCH)
PACKAGE_NAME_DEB := $(PACKAGE_NAME).deb
#uses only the upstream kernel version for the orig tar
PACKAGE_NAME_ORIG := $(PACKAGE)_$(PRAWNOS_VERSION)
PACKAGE_NAME_ORIG_TAR = $(PACKAGE_NAME_ORIG).orig.tar.gz
PACKAGE_NAME_ORIG_DIR = $(PACKAGE)_$(KVER)-$(PRAWNOS_KERNEL_VER)-orig

ORIG := $(PRAWNOS_BUILD)/$(PACKAGE_NAME_ORIG_DIR)

default: $(PACKAGE_NAME_DEB)


$(PACKAGE_NAME_DEB): $(PACKAGE_NAME_ORIG_TAR)
@echo Building $@
$(PRAWNOS_PACKAGE_SCRIPTS_UPDATE_DEB_FILES) $(PRAWNOS_KERNEL_PACKAGE_IMAGE)/src $(DEB_VERSION) $(PRAWNOS_VERSION) $(PRAWNOS_KERNEL_PACKAGE_IMAGE)
$(PRAWNOS_PACKAGE_SCRIPTS_PBUILD) $(PACKAGE_NAME_DEB) \
$(PBUILDER_VARS) \
$(PRAWNOS_LOCAL_APT_VARS) \
$(PACKAGE_LOCAL_BUILD_DEPS)

$(PACKAGE_NAME_ORIG_TAR):
make -f $(PRAWNOS_KERNEL)/makefile kernel
rm -rf $(ORIG)
rm -f $(PACKAGE)_*-*.orig.tar.gz
mkdir $(ORIG)
cp $(PRAWNOS_KERNEL_BUILT) $(ORIG)/$(PACKAGE_NAME_ORIG)
cp $(PRAWNOS_KERNEL_RESOURCES_SHARED)/FlashKernelPartition.sh $(ORIG)/
tar -czf $(PACKAGE_NAME_ORIG_TAR) -C $(ORIG)/ .


.PHONY: clean
clean:
rm -rf *.upload
rm -rf *.deb
rm -rf *.changes
rm -rf *.dsc
rm -rf *.build
rm -rf *.diff.gz
rm -rf *.debian.tar.xz
rm -rf *.buildinfo
rm -f src/debian/debhelper-build-stamp
rm -rf src/debian/$(PACKAGE)*
rm -f src/debian/files
rm -rf src/debian/.debhelper
rm -f $(PACKAGE)_*-*.orig.tar.gz
rm -rf $(ORIG)

.PHONY: install
install:
$(PRAWNOS_PACKAGE_SCRIPTS_INSTALL) $(PACKAGE_NAME_DEB) $(INSTALL_TARGET)
$(PRAWNOS_IMAGE_SCRIPTS_INSTALL_KERNEL) $(KVER) $(PRAWNOS_IMAGE) $(TARGET) $(PRAWNOS_KERNEL_BUILD) $(PRAWNOS_BUILD) $(PACKAGE) $(PACKAGE_NAME_DEB)

.PHONY: upload
upload:
$(PRAWNOS_PACKAGE_SCRIPTS_UPLOAD) $(PACKAGE_NAME).changes
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
prawnos-linux-image-blobby-arm64 (6.6.60-1-1) testing; urgency=medium

* release 6.6.60-1-1

-- Eva Emmerich <eva@evaemmerich.com> Mon, 11 Nov 2024 12:39:22 -0800
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Source: prawnos-linux-image-blobby-arm64
Section: kernel
Priority: optional
Maintainer: Eva Emmerich <eva@evaemmerich.com>
Build-Depends: debhelper (>= 10)
Standards-Version: 4.5.0


Package: prawnos-linux-image-blobby-arm64
Architecture: arm64
Depends: ${misc:Depends} coreutils
Conflicts: prawnos-linux-image-libre-arm64, prawnos-linux-image-blobby-arm64
Description: the PrawnOS linux kernel distribution. Made up of normal aka blobby linux, PrawnOS initramfs, and varying numbers of patches
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
prawnos-linux-image-blobby-arm64* boot
FlashKernelPartition.sh etc/prawnos/kernel
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash


# the kernel file version doesn't include the debian package version, so we have to do some sed magic to drop it
DEBVERSION=$(dpkg-query --show --showformat='${Version}' prawnos-linux-image-arm64)
VERSION=$(sed 's/\(.*\)-.*/\1/' <<< ${DEBVERSION})

KERNEL_IMAGE="/boot/prawnos-linux-image-blobby-arm64_${VERSION}"

set -e

case "$1" in
configure)
/etc/prawnos/kernel/FlashKernelPartition.sh $KERNEL_IMAGE
;;
abort-upgrade|abort-remove|abort-deconfigure)
# Do nothing
;;
*)
echo "Unrecognized postinst argument '$1'"
;;
esac
Loading

0 comments on commit e4eecc7

Please sign in to comment.