From 22334863b5691a168a65894db4360eccfb6d9aec Mon Sep 17 00:00:00 2001 From: Rubberazer <47650457+Rubberazer@users.noreply.github.com> Date: Wed, 30 Oct 2024 01:09:52 +0100 Subject: [PATCH] friendly to jetson-io.py --- Jetclocks/Makefile | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/Jetclocks/Makefile b/Jetclocks/Makefile index 5ff6ece..d416f34 100644 --- a/Jetclocks/Makefile +++ b/Jetclocks/Makefile @@ -11,7 +11,8 @@ clean: install: $(eval EXTFILE := $(shell find /boot/extlinux -name "extlinux.conf" -exec basename {} \;)) - $(eval CHECKER := $(shell grep /boot/extlinux/$(EXTFILE) -e "DEFAULT jetclocks")) + $(eval CHECKER := $(shell grep /boot/extlinux/$(EXTFILE) -e "DEFAULT jetclocks")) + $(eval LABEL := $(shell grep -i "DEFAULT" /boot/extlinux/$(EXTFILE) | sed 's/DEFAULT //g')) $(eval DTBFILE := $(shell find /boot/dtb -name "*kernel*.dtb" -exec basename {} \; | head -n 1)) @if [ "$(CHECKER)" = "" ] && [ "$(DTBFILE)" != "" ]; then\ make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules_install;\ @@ -21,21 +22,22 @@ install: depmod -a;\ echo "jetclocks.conf created into /etc/modules-load.d/";\ echo "Finding device tree blob";\ - echo "Creating backup of: /boot/dtb/$(DTBFILE) -> /boot/dtb/$(DTBFILE).jetclocks.backup";\ - cp /boot/dtb/$(DTBFILE) /boot/dtb/$(DTBFILE).jetclocks.backup;\ - echo "Applying overlay blob to: /boot/dtb/$(DTBFILE) -> /boot/dtb/jetclocks.dtb";\ - fdtoverlay -i /boot/dtb/$(DTBFILE) -o /boot/dtb/jetclocks.dtb $(PWD)/overlay_blob/jetclocks.dtbo;\ + echo "Creating backup of: /boot/dtb/$(DTBFILE) -> /boot/$(DTBFILE).jetclocks.backup";\ + cp /boot/dtb/$(DTBFILE) /boot/$(DTBFILE).jetclocks.backup;\ + echo "Applying overlay blob to: /boot/dtb/$(DTBFILE)";\ + fdtoverlay -i /boot/dtb/$(DTBFILE) -o /boot/dtb/temp.dtb $(PWD)/overlay_blob/jetclocks.dtbo;\ + mv /boot/dtb/temp.dtb /boot/dtb/$(DTBFILE);\ echo "Creating backup of: /boot/extlinux/$(EXTFILE) -> /boot/extlinux/$(EXTFILE).jetclocks.backup";\ cp /boot/extlinux/$(EXTFILE) /boot/extlinux/$(EXTFILE).jetclocks.backup;\ echo "Modifying: /boot/extlinux/$(EXTFILE)";\ - echo "`awk '/LABEL primary/{f=1} /APPEND/{f=0;print} f' /boot/extlinux/extlinux.conf | sed '/#/d'`" > $(PWD)/extlinux.conf.temp;\ - sed -i 's/LABEL\sprimary/LABEL jetclocks/g' $(PWD)/extlinux.conf.temp;\ - sed -i 's/MENU\sLABEL\sjetclocks/MENU LABEL primary/g' $(PWD)/extlinux.conf.temp;\ + echo -e "\n" > $(PWD)/extlinux.conf.temp;\ + echo "`awk '/LABEL $(LABEL)/{flag=1} flag; /APPEND;next/{flag=0}' /boot/extlinux/$(EXTFILE) | sed '/^#/d'`" > $(PWD)/extlinux.conf.temp;\ + sed -i '0,/LABEL $(LABEL)/s//LABEL jetclocks/' $(PWD)/extlinux.conf.temp;\ + sed -i 's/MENU\sLABEL\s/MENU LABEL $(LABEL)/g' $(PWD)/extlinux.conf.temp;\ sed -i '/FDT/d' $(PWD)/extlinux.conf.temp;\ - sed -i '/LINUX/a\ FDT /boot/dtb/jetclocks.dtb' $(PWD)/extlinux.conf.temp;\ + sed -i '/LINUX/a\ FDT /boot/dtb/$(DTBFILE)' $(PWD)/extlinux.conf.temp;\ echo "`cat $(PWD)/extlinux.conf.temp`" >> /boot/extlinux/$(EXTFILE);\ - sed -i 's/DEFAULT\sprimary/DEFAULT jetclocks/g' /boot/extlinux/$(EXTFILE);\ - rm -f $(PWD)/extlinux.conf.temp;\ + sed -i '/DEFAULT/c\DEFAULT jetclocks' /boot/extlinux/$(EXTFILE);\ echo "All done, you should reboot your machine now";\ fi @@ -48,13 +50,10 @@ uninstall: @echo "/etc/modules-load.d/jetclocks.conf removed" @echo "/usr/include/jetclocks.h removed" depmod -a + $(eval CHECKER := $(shell grep /boot/extlinux/extlinux.conf -e "DEFAULT jetclocks")) $(eval EXTFILE := $(shell find /boot/extlinux -name "*jetclocks.backup" -exec basename {} \;)) - @if [ "$(EXTFILE)" != "" ]; then\ + @if [ "$(CHECKER)" != "" ]; then\ cp /boot/extlinux/$(EXTFILE) /boot/extlinux/extlinux.conf;\ - echo "/boot/extlinux/$(EXTLIFE) restored to /boot/extlinux/extlinux.conf";\ - fi - $(eval DTBFILE := $(shell find /boot/dtb -name "jetclocks.dtb" -exec basename {} \;)) - @if [ "$(EXTFILE)" != "" ]; then\ - rm -f /boot/dtb/$(DTBFILE);\ - echo "/boot/dtb/$(DTBFILE) removed";\ + echo "/boot/extlinux/$(EXTFILE) restored to /boot/extlinux/extlinux.conf";\ + rm -f /boot/extlinux/$(EXTFILE);\ fi