From 63a7ece4356912788f3d0d826df6887816044065 Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Sun, 19 Nov 2023 14:01:16 +0100 Subject: [PATCH] workflow: add `/etc/board-package` --- .gitignore | 1 + Makefile | 6 ++- root/usr/local/sbin/install_board_package.sh | 38 +++++++++++++++++++ root/usr/local/sbin/install_bootloader.sh | 36 ++++++++++++++++++ .../sbin/{install_deb => install_deb.sh} | 0 .../{install_gadget => install_gadget.sh} | 0 .../{install_kernel => install_kernel.sh} | 15 +++++--- 7 files changed, 89 insertions(+), 7 deletions(-) create mode 100755 root/usr/local/sbin/install_board_package.sh create mode 100755 root/usr/local/sbin/install_bootloader.sh rename root/usr/local/sbin/{install_deb => install_deb.sh} (100%) rename root/usr/local/sbin/{install_gadget => install_gadget.sh} (100%) rename root/usr/local/sbin/{install_kernel => install_kernel.sh} (74%) diff --git a/.gitignore b/.gitignore index 9df1e67..bfc3927 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ /*.deb +board-package diff --git a/Makefile b/Makefile index 660b80d..9022cca 100644 --- a/Makefile +++ b/Makefile @@ -22,7 +22,11 @@ all-boards: $(patsubst root-%,%-board,$(wildcard root-*)) else -board-package-$(BOARD_TARGET)-$(RELEASE_NAME)_all.deb: root-$(BOARD_TARGET) +root-$(BOARD_TARGET)/etc/board-package: + mkdir -p root-$(BOARD_TARGET)/etc + echo "BOARD=$(BOARD_TARGET)" > root-$(BOARD_TARGET)/etc/board-package + +board-package-$(BOARD_TARGET)-$(RELEASE_NAME)_all.deb: root-$(BOARD_TARGET)/etc/board-package fpm -s dir -t deb -n board-package-$(BOARD_TARGET)-$(RELEASE_NAME) -v $(RELEASE_NAME) \ -p $@ \ --deb-priority optional --category admin \ diff --git a/root/usr/local/sbin/install_board_package.sh b/root/usr/local/sbin/install_board_package.sh new file mode 100755 index 0000000..f8fe368 --- /dev/null +++ b/root/usr/local/sbin/install_board_package.sh @@ -0,0 +1,38 @@ +#!/bin/bash + +set -eo pipefail + +if [[ -e /etc/board-package ]]; then + source /etc/board-package +fi +if [[ -z "$BOARD" ]]; then + echo "The BOARD= is not defined in /etc/board-package" +fi + +if [[ "$#" -ne 1 ]]; then + echo "Usage: $0 [latest] [package-version]" + exit 1 +fi + +find() { + if [[ "$2" != "latest" ]]; then + set -- "$1" "tags/$2" + fi + curl --silent --fail "https://api.github.com/repos/ayufan-rock64/$1/releases/$2" \ + | jq -r '.assets | .[] | .browser_download_url' \ + | grep -E "board-package-$BOARD-" +} + +if FILES=$(find linux-package "$1"); then + echo "Installing $1..." + echo "$FILES" + install_deb.sh $FILES +else + echo "Did not find kernel '$1' in:" + echo "- https://github.com/ayufan-rock64/linux-kernel/releases" + echo "- https://github.com/ayufan-rock64/linux-mainline-kernel/releases" + exit 1 +fi + +echo 'Now run `change-default-kernel.sh` to switch the used kernel.' +exit 0 diff --git a/root/usr/local/sbin/install_bootloader.sh b/root/usr/local/sbin/install_bootloader.sh new file mode 100755 index 0000000..cdd2cfd --- /dev/null +++ b/root/usr/local/sbin/install_bootloader.sh @@ -0,0 +1,36 @@ +#!/bin/bash + +set -eo pipefail + +if [[ -e /etc/board-package ]]; then + source /etc/board-package +fi +if [[ -z "$BOARD" ]]; then + echo "The BOARD= is not defined in /etc/board-package" +fi + +if [[ "$#" -ne 1 ]]; then + echo "Usage: $0 [latest] [u-boot-version]" + exit 1 +fi + +find() { + if [[ "$2" != "latest" ]]; then + set -- "$1" "tags/$2" + fi + curl --silent --fail "https://api.github.com/repos/ayufan-rock64/$1/releases/$2" \ + | jq -r '.assets | .[] | .browser_download_url' \ + | grep -E "u-boot-$BOARD-" +} + +if FILES=$(find linux-mainline-u-boot "$1"); then + echo "Installing $1..." + echo "$FILES" + install_deb.sh $FILES +else + echo "Did not find u-boot '$1' in:" + echo "- https://github.com/ayufan-rock64/linux-mainline-u-boot/releases" + exit 1 +fi + +exit 0 diff --git a/root/usr/local/sbin/install_deb b/root/usr/local/sbin/install_deb.sh similarity index 100% rename from root/usr/local/sbin/install_deb rename to root/usr/local/sbin/install_deb.sh diff --git a/root/usr/local/sbin/install_gadget b/root/usr/local/sbin/install_gadget.sh similarity index 100% rename from root/usr/local/sbin/install_gadget rename to root/usr/local/sbin/install_gadget.sh diff --git a/root/usr/local/sbin/install_kernel b/root/usr/local/sbin/install_kernel.sh similarity index 74% rename from root/usr/local/sbin/install_kernel rename to root/usr/local/sbin/install_kernel.sh index 6841f8b..7c791e0 100755 --- a/root/usr/local/sbin/install_kernel +++ b/root/usr/local/sbin/install_kernel.sh @@ -3,25 +3,28 @@ set -eo pipefail if [[ "$#" -ne 1 ]]; then - echo "Usage: $0 " + echo "Usage: $0 [latest] [kernel-version]" exit 1 fi find() { - curl --silent --fail "https://api.github.com/repos/ayufan-rock64/$1/releases/tags/$2" \ + if [[ "$2" != "latest" ]]; then + set -- "$1" "tags/$2" + fi + curl --silent --fail "https://api.github.com/repos/ayufan-rock64/$1/releases/$2" \ | jq -r '.assets | .[] | .browser_download_url' \ | grep -E 'linux-image|linux-headers' \ | grep -v '\-dbg' } if FILES=$(find linux-mainline-kernel "$1"); then - echo "Installing..." + echo "Installing $1..." echo "$FILES" - install_deb $FILES + install_deb.sh $FILES elif FILES=$(find linux-kernel "$1"); then - echo "Installing..." + echo "Installing $1..." echo "$FILES" - install_deb $FILES + install_deb.sh $FILES else echo "Did not find kernel '$1' in:" echo "- https://github.com/ayufan-rock64/linux-kernel/releases"