Skip to content

Commit

Permalink
friendly to jetson-io.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Rubberazer committed Oct 30, 2024
1 parent c0ef41e commit 2233486
Showing 1 changed file with 17 additions and 18 deletions.
35 changes: 17 additions & 18 deletions Jetclocks/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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;\
Expand All @@ -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

Expand All @@ -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

0 comments on commit 2233486

Please sign in to comment.