Skip to content

Commit

Permalink
Make kernel image packaing work properly
Browse files Browse the repository at this point in the history
track the orig so /debian file changes can be made if necessary before a kver bump
  • Loading branch information
SolidHal committed Dec 5, 2020
1 parent 1dbd4c5 commit 57021d4
Show file tree
Hide file tree
Showing 11 changed files with 67 additions and 47 deletions.
4 changes: 4 additions & 0 deletions kernel/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,12 @@ extract_ath9k: $(ATH9K_EXTRACTED)
.PHONY: kernel_image_package
kernel_image_package: $(PRAWNOS_KERNEL_BUILT)
$(MAKE) -C $(PRAWNOS_KERNEL_PACKAGE_IMAGE)

.PHONY: kernel_image_package_install
kernel_image_package_install: kernel_image_package
$(MAKE) -C $(PRAWNOS_KERNEL_PACKAGE_IMAGE) install INSTALL_TARGET=$(PRAWNOS_BUILD)


.PHONY: kernel_config
kernel_config: $(KERNEL_PATCHED)
$(PRAWNOS_KERNEL_SCRIPTS_MENUCONFIG) $(KERNEL_RESOURCES) $(PRAWNOS_KERNEL_BUILD) $(TARGET)
Expand Down
4 changes: 1 addition & 3 deletions kernel/packages/prawnos-linux-image-arm64/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,4 @@ debhelper-build-stamp
*.upload

#kernel image specific ignores
prawnos-linux-image-arm64_*.orig.tar.gz
prawnos-linux-image-arm64_*.debian.tar.xz
orig/prawnos-linux-image-arm64_*
prawnos-linux-image-arm64_*.debian.tar.xz
23 changes: 13 additions & 10 deletions kernel/packages/prawnos-linux-image-arm64/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,18 @@ $(error Cant build armhf kernel package with arm64 target)
endif

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

#uses the full debian version for the package name
PACKAGE_NAME := $(PACKAGE)_$(VERSION)_$(PACKAGE_ARCH)
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)_$(KVER)-$(PRAWNOS_KERNEL_VER)
PACKAGE_NAME_ORIG_TAR := $(PACKAGE_NAME_ORIG).orig.tar.gz
PACKAGE_NAME_ORIG_DIR := $(PACKAGE)_$(KVER)-$(PRAWNOS_KERNEL_VER)-orig
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)

Expand All @@ -27,21 +28,23 @@ default: $(PACKAGE_NAME_DEB)

$(PACKAGE_NAME_DEB): $(PACKAGE_NAME_ORIG_TAR)
@echo Building $@
# keep the /debian files up to date with the current kernel version
$(PRAWNOS_KERNEL_SCRIPTS_UPDATE_DEB_FILES) $(PRAWNOS_KERNEL_PACKAGE_IMAGE)/src $(VERSION)

$(MAKE) clean
$(PRAWNOS_KERNEL_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_all
clean_all: clean clean_orig

Expand All @@ -59,8 +62,7 @@ clean:
rm -rf src/debian/$(PACKAGE)*
rm -f src/debian/files
rm -rf src/debian/.debhelper
# kernel package specific
rm -f orig/$(PACKAGE)_*-*
rm -rf $(ORIG)

#when just changing the debian package version, if we remake the orig as well then reprepro will complain on upload. So we might not always want to remove the orig.
.PHONY: clean_orig
Expand All @@ -70,6 +72,7 @@ clean_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:
Expand Down
Binary file not shown.
4 changes: 1 addition & 3 deletions kernel/packages/prawnos-linux-image-armhf/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,4 @@ debhelper-build-stamp
*.upload

#kernel image specific ignores
prawnos-linux-image-armhf_*.orig.tar.gz
prawnos-linux-image-armhf_*.debian.tar.xz
orig/prawnos-linux-image-armhf_*
prawnos-linux-image-armhf_*.debian.tar.xz
23 changes: 13 additions & 10 deletions kernel/packages/prawnos-linux-image-armhf/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,18 @@ $(error Cant build armhf kernel package with arm64 target)
endif

#package specific vars
VERSION := $(PRAWNOS_KERNEL_IMAGE_CAT_VER)
DEB_VERSION := $(PRAWNOS_KERNEL_IMAGE_CAT_VER)
PRAWNOS_VERSION := $(PRAWNOS_KERNEL_IMAGE_CAT_PRAWNOS_VER)
PACKAGE := prawnos-linux-image-armhf
PACKAGE_ARCH := armhf

#uses the full debian version for the package name
PACKAGE_NAME := $(PACKAGE)_$(VERSION)_$(PACKAGE_ARCH)
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)_$(KVER)-$(PRAWNOS_KERNEL_VER)
PACKAGE_NAME_ORIG_TAR := $(PACKAGE_NAME_ORIG).orig.tar.gz
PACKAGE_NAME_ORIG_DIR := $(PACKAGE)_$(KVER)-$(PRAWNOS_KERNEL_VER)-orig
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)

Expand All @@ -27,21 +28,23 @@ default: $(PACKAGE_NAME_DEB)

$(PACKAGE_NAME_DEB): $(PACKAGE_NAME_ORIG_TAR)
@echo Building $@
# keep the /debian files up to date with the current kernel version
$(PRAWNOS_KERNEL_SCRIPTS_UPDATE_DEB_FILES) $(PRAWNOS_KERNEL_PACKAGE_IMAGE)/src $(VERSION)

$(MAKE) clean
$(PRAWNOS_KERNEL_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_all
clean_all: clean clean_orig

Expand All @@ -59,8 +62,7 @@ clean:
rm -rf src/debian/$(PACKAGE)*
rm -f src/debian/files
rm -rf src/debian/.debhelper
# kernel package specific
rm -f $(ORIG)
rm -rf $(ORIG)

#when just changing the debian package version, if we remake the orig as well then reprepro will complain on upload. So we might not always want to remove the orig.
.PHONY: clean_orig
Expand All @@ -70,6 +72,7 @@ clean_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:
Expand Down
3 changes: 2 additions & 1 deletion kernel/resources/shared/FlashKernelPartition.sh
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ kimg=$1

rootfs=$(get_root_partition)
devname=$(lsblk -no pkname $rootfs | head -n 1)
model=$(get_device)
devtype=
kpart=

Expand Down Expand Up @@ -163,7 +164,7 @@ echo "
----------------------------
This will flash a new kernel image onto the running device's kernel partition: $kpart
The detected running boot device is: $devtype.
The device you are running is: $devname.
The model you are running is: $model.
DO NOT shutdown or reboot before completing the process!
"

Expand Down
13 changes: 5 additions & 8 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -80,28 +80,25 @@ clean_all: clean_most clean_ath9k clean_pbuilder
#:::::::::::::::::::::::::::::: image management ::::::::::::::::::::::::::

.PHONY: kernel_install
kernel_install: #Targets an already built .img and swaps the old kernel with the newly compiled kernel
#TODO: uncomment when we have an arm64 bit kernel image
# $(MAKE) kernel_image_package
$(PRAWNOS_IMAGE_SCRIPTS_INSTALL_KERNEL) $(KVER) $(PRAWNOS_IMAGE) $(TARGET) $(PRAWNOS_BUILD) prawnos-linux-image-$(TARGET)*.deb
kernel_install: #Targets the PrawnOS image and installs a kernel
$(MAKE) kernel_image_package_install

.PHONY: kernel_update
kernel_update:
$(MAKE) clean_image
$(MAKE) clean_kernel
$(MAKE) initramfs
$(MAKE) kernel
cp $(PRAWNOS_IMAGE_BASE) $(PRAWNOS_IMAGE)
$(MAKE) kernel_install
$(MAKE) kernel_image_package_install

.PHONY: image
image:
$(MAKE) clean_image
$(MAKE) filesystem
$(MAKE) initramfs
$(MAKE) kernel
cp $(PRAWNOS_IMAGE_BASE) $(PRAWNOS_IMAGE)
$(MAKE) kernel_install
$(MAKE) kernel_image_package_install


# $PDEV should be passed like PDEV=/dev/sdb
.PHONY: write_image
Expand Down
6 changes: 4 additions & 2 deletions scripts/BuildScripts/BuildCommon.mk
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,10 @@ PRAWNOS_KERNEL_IMAGE_DEBVER := 1
PRAWNOS_KERNEL_HEADERS_DEBVER := 1
endif

PRAWNOS_KERNEL_IMAGE_CAT_VER=$(KVER)-$(PRAWNOS_KERNEL_VER)-$(PRAWNOS_KERNEL_IMAGE_DEBVER)
PRAWNOS_KERNEL_HEADERS_CAT_VER=$(KVER)-$(PRAWNOS_KERNEL_VER)-$(PRAWNOS_KERNEL_HEADERS_DEBVER)
PRAWNOS_KERNEL_IMAGE_CAT_PRAWNOS_VER=$(KVER)-$(PRAWNOS_KERNEL_VER)
PRAWNOS_KERNEL_IMAGE_CAT_DEB_VER=$(KVER)-$(PRAWNOS_KERNEL_VER)-$(PRAWNOS_KERNEL_IMAGE_DEBVER)
PRAWNOS_KERNEL_HEADERS_CAT_PRAWNOS_VER=$(KVER)-$(PRAWNOS_KERNEL_VER)
PRAWNOS_KERNEL_HEADERS_CAT_DEB_VER=$(KVER)-$(PRAWNOS_KERNEL_VER)-$(PRAWNOS_KERNEL_HEADERS_DEBVER)

# Otherwise errors are ignored when output is piped to tee:
SHELL := /bin/bash -o pipefail
Expand Down
20 changes: 11 additions & 9 deletions scripts/BuildScripts/ImageScripts/installKernelToFs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@ fi
KVER=$1
OUTNAME=$2
TARGET=$3
KERNEL_PACKAGE_PATH=$4
KERNEL_PACKAGE=$5
KERNEL_BUILD=$4
KERNEL_PACKAGE_PATH=$5
KERNEL_PACKAGE_NAME=$6
KERNEL_PACKAGE_DEB=$7



Expand Down Expand Up @@ -85,21 +87,21 @@ kernel_size=65536
#this is very very important, not doing this or using the incorrect kernel size can lead to very strange and difficult to debug issues
dd if=/dev/zero of=${outdev}p1 conv=notrunc bs=512 count=$kernel_size
#now write the new kernel
dd if=build/$TARGET/linux-$KVER/vmlinux.kpart of=${outdev}p1
dd if=$KERNEL_BUILD/vmlinux.kpart of=${outdev}p1

#install the kernel image package to the chroot so it can be updated by apt later
#need to do funky things to avoid running the postinst script that dds the kernel to the kernel partition
#maybe it would make more sense to run this on install, but then a usb booting device couldn't upgrade its kernel
#TODO uncomment and test once arm64 is done
# cp $KERNEL_PACKAGE_PATH $outmnt/
# chroot $outmnt dpkg --unpack $KERNEL_PACKAGE
# chroot $outmnt rm /var/lib/dpkg/info/$KERNEL_PACKAGE.postinst -f
# chroot $outmnt dpkg --configure $KERNEL_PACKAGE
cp $KERNEL_PACKAGE_PATH/$KERNEL_PACKAGE_DEB $outmnt/
chroot $outmnt dpkg --unpack /$KERNEL_PACKAGE_DEB
chroot $outmnt rm /var/lib/dpkg/info/$KERNEL_PACKAGE_NAME.postinst
chroot $outmnt dpkg --configure $KERNEL_PACKAGE_NAME
chroot $outmnt rm /$KERNEL_PACKAGE_DEB

#install the kernel modules and headers
#we dont make any modules yet
# make -C build/$TARGET/linux-$KVER ARCH=$KERNEL_ARCH INSTALL_MOD_PATH=$outmnt modules_install
make -C build/$TARGET/linux-$KVER ARCH=$KERNEL_ARCH INSTALL_HDR_PATH=$outmnt/usr/src/linux-$KVER-gnu headers_install
make -C $KERNEL_BUILD ARCH=$KERNEL_ARCH INSTALL_HDR_PATH=$outmnt/usr/src/linux-$KVER-gnu headers_install
# the ath9k firmware is built into the kernel image, so nothing else must be done

umount -l $outmnt > /dev/null 2>&1
Expand Down
14 changes: 13 additions & 1 deletion scripts/BuildScripts/KernelScripts/updateKernelDebfiles.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,25 @@ then
fi
if [ -z "$2" ]
then
echo "No kernel version supplied"
echo "No deb kernel version supplied"
exit 1
fi
if [ -z "$3" ]
then
echo "No prawnos kernel version supplied"
exit 1
fi
if [ -z "$4" ]
then
echo "No prawnos kernel image package path supplied"
exit 1
fi


DEBSRC=$1
DEBKVER=$2
PRAWNOSKVER=$3
PACKAGEPATH=$4

cd $DEBSRC
# check the supplied kver against the current kver
Expand Down

0 comments on commit 57021d4

Please sign in to comment.