-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a script to automatically write the formula
- Loading branch information
Showing
4 changed files
with
60 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Ignore assets downloaded by update script. | ||
*_asset |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
class Pls < Formula | ||
desc "Prettier and powerful ls for the pros" | ||
homepage "https://pls.cli.rs/" | ||
license "GPL-3.0-or-later" | ||
|
||
if OS.mac? | ||
url "{{ MAC_URL }}" | ||
sha256 "{{ MAC_SHA }}" | ||
elsif OS.linux? | ||
url "{{ LINUX_URL }}" | ||
sha256 "{{ LINUX_SHA }}" | ||
end | ||
|
||
depends_on "libgit2" | ||
|
||
def install | ||
bin.install "pls" | ||
end | ||
|
||
test do | ||
linkage_with_libgit2 = (bin/"pls").dynamically_linked_libraries.any? do |dll| | ||
next false unless dll.start_with?(HOMEBREW_PREFIX.to_s) | ||
|
||
File.realpath(dll) == (Formula["libgit2"].opt_lib/shared_library("libgit2")).realpath.to_s | ||
end | ||
|
||
assert linkage_with_libgit2, "No linkage with libgit2! Cargo is likely using a vendored version." | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/usr/bin/env bash | ||
|
||
REPO="pls-rs/pls" | ||
RELEASE=$(curl -s "https://api.github.com/repos/${REPO}/releases" | jq -r '.[0]') | ||
|
||
NAME=$(echo ${RELEASE} | jq -r '.name') | ||
echo "Latest release is ${NAME}." | ||
|
||
MAC_URL=$(echo ${RELEASE} | jq -r '.assets[] | select(.name | contains("apple-darwin")).browser_download_url') | ||
echo "Downloading macOS asset from ${MAC_URL}." | ||
|
||
curl -sL ${MAC_URL} -o mac_asset | ||
MAC_SHA=$(shasum -a 256 mac_asset | awk '{ print $1 }') | ||
echo "SHA256 for macOS asset is ${MAC_SHA}." | ||
|
||
LINUX_URL=$(echo ${RELEASE} | jq -r '.assets[] | select(.name | contains("unknown-linux-musl")).browser_download_url') | ||
echo "Downloading Linux asset from ${LINUX_URL}." | ||
|
||
curl -sL ${LINUX_URL} -o linux_asset | ||
LINUX_SHA=$(shasum -a 256 linux_asset | awk '{ print $1 }') | ||
echo "SHA256 for Linux asset is ${LINUX_SHA}." | ||
|
||
sed -e "s|{{ MAC_URL }}|$MAC_URL|g" \ | ||
-e "s|{{ MAC_SHA }}|$MAC_SHA|g" \ | ||
-e "s|{{ LINUX_URL }}|$LINUX_URL|g" \ | ||
-e "s|{{ LINUX_SHA }}|$LINUX_SHA|g" "Template/pls.rb.jinja" > "Formula/pls.rb" | ||
|
||
echo "Formula written!" |