From 2832ad072c3880f0499907988bc13cec6d3236f0 Mon Sep 17 00:00:00 2001 From: Ben Youngblood Date: Fri, 18 Oct 2024 13:05:50 -0700 Subject: [PATCH] Build and install fwup --- .github/workflows/build.yml | 6 +++++- README.md | 29 ++++++++++++----------------- bin/download | 1 - contributing.md | 3 +-- lib/utils.bash | 37 +++++++++++++++++++++++++++---------- 5 files changed, 45 insertions(+), 31 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 83106a3..f67344f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -16,7 +16,11 @@ jobs: - macos-latest runs-on: ${{ matrix.os }} steps: + - run: sudo apt-get install curl build-essential autoconf pkg-config libtool mtools unzip zip help2man libconfuse-dev libarchive-dev xdelta3 dosfstools + if: matrix.os == 'ubuntu-latest' + - run: brew install confuse libarchive pkg-config automake + if: matrix.os == 'macos-latest' - name: asdf_plugin_test uses: asdf-vm/actions/plugin-test@v2 with: - command: fwup --help + command: fwup --version diff --git a/README.md b/README.md index 0e0c32d..e75ee4d 100644 --- a/README.md +++ b/README.md @@ -10,15 +10,20 @@ - [Dependencies](#dependencies) - [Install](#install) -- [Contributing](#contributing) -- [License](#license) # Dependencies -**TODO: adapt this section** +## Linux -- `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html). -- `SOME_ENV_VAR`: set this environment variable in your shell config to load the correct version of tool x. +```bash +sudo apt-get install curl build-essential autoconf pkg-config libtool mtools unzip zip help2man libconfuse-dev libarchive-dev xdelta3 dosfstools +``` + +## MacOS + +```bash +brew install confuse libarchive pkg-config automake +``` # Install @@ -27,7 +32,7 @@ Plugin: ```shell asdf plugin add fwup # or -asdf plugin add fwup https://github.com/bjyoungblood/asdf-fwup.git +asdf plugin add fwup https://github.com/fwup-home/asdf-fwup.git ``` fwup: @@ -43,18 +48,8 @@ asdf install fwup latest asdf global fwup latest # Now fwup commands are available -fwup --help +fwup --version ``` Check [asdf](https://github.com/asdf-vm/asdf) readme for more instructions on how to install & manage versions. - -# Contributing - -Contributions of any kind welcome! See the [contributing guide](contributing.md). - -[Thanks goes to these contributors](https://github.com/bjyoungblood/asdf-fwup/graphs/contributors)! - -# License - -See [LICENSE](LICENSE) © [Ben Youngblood](https://github.com/bjyoungblood/) diff --git a/bin/download b/bin/download index c11ee53..38c6411 100755 --- a/bin/download +++ b/bin/download @@ -10,7 +10,6 @@ source "${plugin_dir}/lib/utils.bash" mkdir -p "$ASDF_DOWNLOAD_PATH" -# TODO: Adapt this to proper extension and adapt extracting strategy. release_file="$ASDF_DOWNLOAD_PATH/$TOOL_NAME-$ASDF_INSTALL_VERSION.tar.gz" # Download tar.gz file to the download directory diff --git a/contributing.md b/contributing.md index 081e0c6..6850dbb 100644 --- a/contributing.md +++ b/contributing.md @@ -5,8 +5,7 @@ Testing Locally: ```shell asdf plugin test [--asdf-tool-version ] [--asdf-plugin-gitref ] [test-command*] -# TODO: adapt this -asdf plugin test fwup https://github.com/bjyoungblood/asdf-fwup.git "fwup --help" +asdf plugin test fwup https://github.com/bjyoungblood/asdf-fwup.git "fwup --version" ``` Tests are automatically run in GitHub Actions on push and PR. diff --git a/lib/utils.bash b/lib/utils.bash index 74e00b8..ab831d6 100644 --- a/lib/utils.bash +++ b/lib/utils.bash @@ -2,10 +2,10 @@ set -euo pipefail -# TODO: Ensure this is the correct GitHub homepage where releases can be downloaded for fwup. GH_REPO="https://github.com/fwup-home/fwup" TOOL_NAME="fwup" -TOOL_TEST="fwup --help" +TOOL_TEST="fwup --version" +OS=$(uname -s) fail() { echo -e "asdf-$TOOL_NAME: $*" @@ -14,7 +14,6 @@ fail() { curl_opts=(-fsSL) -# NOTE: You might want to remove this if fwup is not hosted on GitHub releases. if [ -n "${GITHUB_API_TOKEN:-}" ]; then curl_opts=("${curl_opts[@]}" -H "Authorization: token $GITHUB_API_TOKEN") fi @@ -27,12 +26,10 @@ sort_versions() { list_github_tags() { git ls-remote --tags --refs "$GH_REPO" | grep -o 'refs/tags/.*' | cut -d/ -f3- | - sed 's/^v//' # NOTE: You might want to adapt this sed to remove non-version strings from tags + sed 's/^v//' } list_all_versions() { - # TODO: Adapt this. By default we simply list the tag names from GitHub releases. - # Change this function if fwup has other means of determining installable versions. list_github_tags } @@ -41,8 +38,7 @@ download_release() { version="$1" filename="$2" - # TODO: Adapt the release URL convention for fwup - url="$GH_REPO/archive/v${version}.tar.gz" + url="$GH_REPO/releases/download/v${version}/fwup-${version}.tar.gz" echo "* Downloading $TOOL_NAME release $version..." curl "${curl_opts[@]}" -o "$filename" -C - "$url" || fail "Could not download $url" @@ -58,10 +54,31 @@ install_version() { fi ( + cd "$ASDF_DOWNLOAD_PATH" + + case "$OS" in + Darwin) + set +u + PKG_CONFIG_PATH="$(brew --prefix libarchive)/lib/pkgconfig:$(brew --prefix)/lib/pkgconfig:$PKG_CONFIG_PATH" ./configure --prefix= + set -u + ;; + Linux) + ./configure --prefix= + ;; + *) + fail "Unsupported OS: $OS" + ;; + esac + + make -j4 + + if ! ./src/fwup --version; then + fail "Could not execute fwup after building" + fi + mkdir -p "$install_path" - cp -r "$ASDF_DOWNLOAD_PATH"/* "$install_path" + make DESTDIR="$ASDF_INSTALL_PATH" install - # TODO: Assert fwup executable exists. local tool_cmd tool_cmd="$(echo "$TOOL_TEST" | cut -d' ' -f1)" test -x "$install_path/$tool_cmd" || fail "Expected $install_path/$tool_cmd to be executable."