Skip to content

Commit

Permalink
Fix Kernel Upgrades
Browse files Browse the repository at this point in the history
  • Loading branch information
Fishwaldo committed May 16, 2023
1 parent 4b83657 commit 5ccb1b0
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 12 deletions.
2 changes: 1 addition & 1 deletion conf/distro/pinix.conf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ require conf/distro/poky.conf

DISTRO = "pinix"
DISTRO_NAME = "PinIx"
DISTRO_VERSION = "1.1"
DISTRO_VERSION = "1.2"
DISTRO_CODENAME = "pinix"
SDK_VENDOR = "-pine64"
TARGET_VENDOR = "-pine64"
Expand Down
2 changes: 2 additions & 0 deletions recipes-core/packagegroups/packagegroup-star64-minimal.bb
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,6 @@ RDEPENDS:packagegroup-star64-minimal = " \
linux-firmware-rtl8852 \
libgpiod-tools \
bluez5 \
u-boot-tools \
kernel-image-fitimage-initramfs \
"
66 changes: 66 additions & 0 deletions recipes-kernel/linux/kernel-image-fitimage-initramfs.bb
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
SUMMARY = "Install a InitRamFS enabled FitImage"
LICENSE = "MIT"
SRC_URI = " \
file://checkfitimage.sh \
"
LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"

inherit kernel-artifact-names module-base

KERNEL_PRIORITY ?= "${@int(d.getVar('KERNEL_VERSION',1).split('-')[0].split('+')[0].split('.')[0]) * 10000 + \
int(d.getVar('KERNEL_VERSION',1).split('-')[0].split('+')[0].split('.')[1]) * 100 + \
int(d.getVar('KERNEL_VERSION',1).split('-')[0].split('+')[0].split('.')[-1])}"



PV="${KERNEL_VERSION}"


python do_package:prepend() {
import oe.packagedata
pkgv = oe.packagedata.read_subpkgdata('kernel-image-fitimage', d)['PKGV']
d.setVar('PKGV', pkgv)
pkgr = oe.packagedata.read_subpkgdata('kernel-image-fitimage', d)['PKGR']
#d.setVar('PKGR', pkgr)
bb.note("PKGV: %s" % d.getVar('PKGV'))
bb.note("PKGR: %s" % d.getVar('PKGR'))
}

pkg_preinst:${PN} () {
bootpart=`lsblk -o NAME,LABEL -r | grep "mmcblk[0-9]p[0-9] boot" | awk -F' ' '{print $1}'`
mount /dev/$bootpart /boot || true
dpkg-divert --package ${PN} --divert /usr/share/kernel/${KERNEL_IMAGETYPE}-initramfs-${KERNEL_VERSION} /boot/${KERNEL_IMAGETYPE}-initramfs-${KERNEL_VERSION}
}

pkg_postinst_ontarget:${PN} () {
${libexecdir}/checkfitimage.sh || true
}

pkg_prerm:${PN} () {
dpkg-divert --remove /boot/${KERNEL_IMAGETYPE}-initramfs-${KERNEL_VERSION}
${libexecdir}/checkfitimage.sh || true
}

do_install() {
install -d -m 0755 ${D}/boot/
ls ${DEPLOY_DIR_IMAGE}/fitImage-*${KERNEL_FIT_BIN_EXT}
install -m 0644 ${DEPLOY_DIR_IMAGE}/fitImage-${INITRAMFS_IMAGE}-${MACHINE}--${KERNEL_VERSION}*${KERNEL_FIT_BIN_EXT} ${D}/boot/${KERNEL_IMAGETYPE}-initramfs-${KERNEL_VERSION}
install -d -m 0755 ${D}/${libexecdir}
install -m 0755 ${WORKDIR}/checkfitimage.sh ${D}/${libexecdir}/
}

FILES:${PN} += " \
/boot/${KERNEL_IMAGETYPE}-initramfs-${KERNEL_VERSION} \
${libexecdir}/checkfitimage.sh \
"

do_install[depends] = "virtual/kernel:do_deploy"

RDEPENDS:${PN} += " \
u-boot-tools \
kernel-modules-${PV} (>= ${PV}) \
"

RREPLACES:${PN} = " \
kernel-image-fitimage \
"
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh
cd /boot/
CURVER=`dumpimage -l fitImage | grep "FIT description" | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+'`
LATEST=`ls fitImage-initramfs-* | awk -F"-" '{ print $3 }' | sort -t '.' -k 1,1 -k 2,2 -k 3,3 -g | tail -n 1`
echo "Current Version is '$CURVER'"
echo "Latest Version is '$LATEST'"
cp fitImage-initramfs-$LATEST fitImage
11 changes: 0 additions & 11 deletions recipes-kernel/linux/linux-starfive-dev.bbappend
Original file line number Diff line number Diff line change
@@ -1,13 +1,2 @@
KERNEL_SPLIT_MODULES = "0"

KERNEL_PRIORITY ?= "${@int(d.getVar('PV',1).split('-')[0].split('+')[0].split('.')[0]) * 10000 + \
int(d.getVar('PV',1).split('-')[0].split('+')[0].split('.')[1]) * 100 + \
int(d.getVar('PV',1).split('-')[0].split('+')[0].split('.')[-1])}"

pkg_postinst_ontarget:kernel-image-fitimage () {
update-alternatives --install /${KERNEL_IMAGEDEST}/${KERNEL_IMAGETYPE} ${KERNEL_IMAGETYPE} ${KERNEL_IMAGETYPE}-${KERNEL_VERSION} ${KERNEL_PRIORITY} || true
}

pkg_postrm_kernel:kernel-image-fitimage () {
update-alternatives --remove ${KERNEL_IMAGETYPE} ${KERNEL_IMAGETYPE}-${KERNEL_VERSION} || true
}

0 comments on commit 5ccb1b0

Please sign in to comment.