I am trying to do the same for https://github.com/eneshecan/whatsapp-for-linux/releases as is described here: Download and install latest deb package from github via terminal but cant get it to work, it seems because the URL is not in the source but only seen in the browser? can anyone help? I just need the full URL as a string so I can download and install the deb file
Asked
Active
Viewed 158 times
2 Answers
1
You could do something like this (kudos to this for the trick that gets the latest version):
base_url="https://github.com/eneshecan/whatsapp-for-linux/releases/download"
version=$(curl --silent https://api.github.com/repos/eneshecan/whatsapp-for-linux/releases | grep -oP '"tag_name":\s*"v\K[^"]+' | sort -h | tail -n1)
wget "$base_url"/v"$version"/whatsapp-for-linux_"${version}"_amd64.deb
terdon
- 234,489
- 66
- 447
- 667
-
thanks, different solution :-) I wonder why its so complicated on some github repos I marked it as solution as it works for my use-case :-) – Questi Feb 24 '23 at 14:26
-
@Questi it's because there is no standard here, and every developer can arrange their repository as they want. – terdon Feb 24 '23 at 14:29
1
I use the following to choose (using bash's select built-in) one or more of the most recent "Glorious Eggroll" Proton releases to download and extract for Steam.
It would be easy enough to modify to download a .deb file from another repo. It does basically the same thing as @terdon's answer, but a bit fancier (the select stuff; and code to avoid downloading a file that has already been downloaded, checking both the current dir and a ./archives/ sub-directory - I like to move older .tar.gz files out of the main working dir to reduce clutter; and code to extract the download if it hasn't already been extracted into the target dir).
#!/bin/bash
GE_API_URL='https://api.github.com/repos/GloriousEggroll/proton-ge-custom/releases'
GE_json='GE-releases.json'
GE_list='GE-releases.list'
compatdir='/var/games/steam/compatibilitytools.d'
archives='./archives'
mkdir -p "$compatdir"
# Don't download the releases file more than once/day
if [ -e "$GE_json" ] ; then
GE_date="$(stat --printf "%y" "$GE_json" | cut -d' ' -f 1)"
fi
YMD="$(date +%Y-%m-%d)"
if [ "$GE_date" != "$YMD" ] ; then
wget "$GE_API_URL" -O "$GE_json"
jq -r .[].assets[].browser_download_url < "$GE_json" |
grep '\.tar.gz$' | sort -rV > "$GE_list"
fi
#mapfile -t releases < "$GE_list" # all
mapfile -t releases < <(head "$GE_list") # latest 10
echo "Currently installed Proton-GE versions:"
ls "$compatdir" | grep GE | sort -rV
echo
export COLUMNS=80
echo "Select a GE release to download and install or 0 to quit:"
select r in "${releases[@]}"; do
[ -z "$r" ] && break
tgz="$(basename "$r")"
[ -e "$archives/$tgz" ] && tgz="$archives/$tgz"
if [ ! -e "$tgz" ] ; then
echo "Downloading $r"
wget "$r"
fi
bn="$(basename "$tgz" ".tar.gz")"
if [ ! -e "$compatdir/$bn" ] ; then
echo "Extracting $bn into $compatdir/"
time tar xfz "$tgz" -C "$compatdir/"
fi
echo
echo -n "Select another version to install or 0 to quit: "
done
cas
- 1
- 7
- 119
- 185
-
not sure how to use this :P though it would be nice to check if there is already a downloaded file and if its the newest version to not attempt to download and install it :) – Questi Mar 18 '23 at 20:26