Skip to content

Commit

Permalink
Build and install fwup
Browse files Browse the repository at this point in the history
  • Loading branch information
bjyoungblood committed Oct 18, 2024
1 parent b68cc17 commit 747f4a1
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 31 deletions.
2 changes: 2 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ updates:
directory: "/"
schedule:
interval: "weekly"
commit-message:
prefix: "ci:"
6 changes: 5 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
29 changes: 12 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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:
Expand All @@ -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/)
1 change: 0 additions & 1 deletion bin/download
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ Testing Locally:
```shell
asdf plugin test <plugin-name> <plugin-url> [--asdf-tool-version <version>] [--asdf-plugin-gitref <git-ref>] [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.
37 changes: 27 additions & 10 deletions lib/utils.bash
Original file line number Diff line number Diff line change
Expand Up @@ -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: $*"
Expand All @@ -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
Expand All @@ -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
}

Expand All @@ -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"
Expand All @@ -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."
Expand Down

0 comments on commit 747f4a1

Please sign in to comment.