From 53b27a6664a457d4f8a52e901e2eca110ed72d33 Mon Sep 17 00:00:00 2001 From: Taiki Endo Date: Sun, 15 Dec 2024 22:13:27 +0900 Subject: [PATCH] OpenWrt changed package manager --- .github/workflows/ci.yml | 2 +- action.yml | 61 +++++++++++++++++++++++++--------------- main.sh | 8 +++++- 3 files changed, 46 insertions(+), 25 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 552cc56..4dad60c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -116,7 +116,7 @@ jobs: - opensuse/tumbleweed:latest # glibc 2.39 (as of 2024-07-19) - archlinux:latest # glibc 2.39 (as of 2024-07-19) - alpine:latest # musl 1.2.5 (as of alpine 3.20) - - openwrt/rootfs:x86-64-openwrt-23.05 # musl 1.2.4 + - openwrt/rootfs:x86-64-openwrt-24.10 # musl 1.2.5 runs-on: ubuntu-latest timeout-minutes: 60 container: ${{ matrix.container }} diff --git a/action.yml b/action.yml index 6560c86..f09abab 100644 --- a/action.yml +++ b/action.yml @@ -10,34 +10,49 @@ runs: - run: | set -eu if ! command -v bash >/dev/null; then + install='' if grep -Eq '^ID=alpine' /etc/os-release; then - printf '::group::Install packages required for checkout-action (bash)\n' - # NB: sync with apk_install in main.sh - if command -v sudo >/dev/null; then - sudo apk --no-cache add bash - elif command -v doas >/dev/null; then - doas apk --no-cache add bash - else - apk --no-cache add bash - fi - printf '::endgroup::\n' + install='apk' elif grep -Eq '^ID_LIKE=.*openwrt' /etc/os-release; then - printf '::group::Install packages required for checkout-action (bash)\n' - # NB: sync with opkg_install in main.sh - if command -v sudo >/dev/null; then - sudo mkdir -p /var/lock - sudo opkg update - sudo opkg install bash + # https://github.com/openwrt/openwrt/issues/16935 + if command -v apk >/dev/null; then + install='apk' else - mkdir -p /var/lock - opkg update - opkg install bash + install='opkg' fi - printf '::endgroup::\n' - else - printf '::error::checkout-action requires bash\n' - exit 1 fi + case "${install}" in + apk) + printf '::group::Install packages required for checkout-action (bash)\n' + # NB: sync with apk_install in main.sh + if command -v sudo >/dev/null; then + sudo apk --no-cache add bash + elif command -v doas >/dev/null; then + doas apk --no-cache add bash + else + apk --no-cache add bash + fi + printf '::endgroup::\n' + ;; + opkg) + printf '::group::Install packages required for checkout-action (bash)\n' + # NB: sync with opkg_install in main.sh + if command -v sudo >/dev/null; then + sudo mkdir -p /var/lock + sudo opkg update + sudo opkg install bash + else + mkdir -p /var/lock + opkg update + opkg install bash + fi + printf '::endgroup::\n' + ;; + *) + printf '::error::checkout-action requires bash\n' + exit 1 + ;; + esac fi bash --noprofile --norc "${GITHUB_ACTION_PATH:?}/main.sh" shell: sh diff --git a/main.sh b/main.sh index 3122846..c02641b 100755 --- a/main.sh +++ b/main.sh @@ -83,7 +83,13 @@ sys_install() { suse) zypper_install "$@" ;; arch) pacman_install "$@" ;; alpine) apk_install "$@" ;; - openwrt) opkg_install "$@" ;; + openwrt) + if type -P apk >/dev/null; then + apk_install "$@" + else + opkg_install "$@" + fi + ;; esac }