我正在尝试做同样的事情https://github.com/eneshecan/whatsapp-for-linux/releases正如这里所描述的:通过终端从github下载并安装最新的deb包 但无法让它工作,似乎是因为 URL 不在源代码中而只能在浏览器中看到?有人可以帮忙吗?我只需要完整的 URL 作为字符串,这样我就可以下载并安装 deb 文件
答案1
你可以做这样的事情(荣誉这对于获取最新版本的技巧):
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
答案2
我使用以下命令来选择(使用 bash 的select
内置)一个或多个最新的“Glorious Eggroll”Proton 版本来下载并提取到 Steam。
修改以从另一个存储库下载 .deb 文件将很容易。它的作用与 @terdon 的答案基本相同,但有点更奇特(东西select
;以及避免下载已下载文件的代码,检查当前目录和子目录./archives/
- 我喜欢移动旧的 .tar .gz 文件离开主工作目录以减少混乱;以及提取下载内容的代码(如果尚未提取到目标目录)。
#!/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