Skip to content

Commit

Permalink
01-main...jc: clean, fast URL/version extraction
Browse files Browse the repository at this point in the history
How the code works: from JSON take (via `grep -m1 -o`) the line
  "browser_download_url": "https://github.com/kellyjonbrazil/jc/releases/download/v1.23.6/jc_1.23.6-1_amd64.deb"

1. extract the matching key/value pair, excluding the final dquote.
2. remove everything upto and including the first dquote -> URL
3. from the URL, remove everything upto & including /download/v
4. then remove everything from '/' onwards -> version
  • Loading branch information
mralusw authored and flexiondotorg committed Nov 10, 2023
1 parent 648e87c commit 7ae1797
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions 01-main/packages/jc
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ DEFVER=1
ARCHS_SUPPORTED='amd64'
get_github_releases 'kellyjonbrazil/jc' 'latest'
if [ "${ACTION}" != prettylist ]; then
URL=$(grep -m1 "browser_download_url.*${HOST_ARCH}.*\.deb\"" "${CACHE_FILE}" | cut -d'"' -f4)
VERSION_PUBLISHED=$(sed -n -e 's@.*/download/v\([^/]*\)/.*@\1@p' <<<"$URL")
printf %s\\n "$VERSION_PUBLISHED" >/tmp/dg.log
URL=$(grep -m1 -o "\"browser_download_url\":[[:space:]]*\"[^\"]*${HOST_ARCH}[^\"]*\.deb" "${CACHE_FILE}")
URL=${URL##*\"}
VERSION_PUBLISHED=${URL##*/download/v}
VERSION_PUBLISHED=${VERSION_PUBLISHED%%/*}
fi
EULA=''
PRETTY_NAME='jc'
Expand Down

0 comments on commit 7ae1797

Please sign in to comment.