3

I would like to download and install the latest .deb-package from github (https://github.com/elbersb/otr-verwaltung/downloads to be exact).

How can I download the latest package (e.g. *otrverwaltung_0.9.1_all.deb*) automatically with a script from github?

What I have tried so far:

wget -O- -q --no-check-certificate https://github.com/elbersb/otr-verwaltung/downloads | grep -o -l -e 'otrverwaltung_[0-9.]*_all.deb'
#The filename should be saved in a variable OTRPACKAGE
sudo dpkg -i OTRPACKAGE
imz -- Ivan Zakharyaschev
  • 15,113
  • 15
  • 61
  • 123
Martin Thoma
  • 2,802
  • 5
  • 34
  • 45

2 Answers2

2
# Find the URL of the .deb file
url=$(wget -O- -q --no-check-certificate https://github.com/elbersb/otr-verwaltung/downloads |
       sed -ne 's/^.*"\([^"]*otrverwaltung_[^"]*_all\.deb\)".*/\1/p')
case $url in
  http://*|https://*) :;;
  /*) url=https://github.com$url;;
  *) url=https://github.com/elbersb/otr-verwaltung/$url;;
esac
# Create a temporary directory
dir=$(mktemp -dt)
cd "$dir"
# Download the .deb file
wget "$url"
# Install the package
sudo dpkg -i "${url##*/}"
# Clean up
rm "${url##*/}"
cd /
rmdir "$dir"
manatwork
  • 30,549
  • 7
  • 101
  • 91
Gilles 'SO- stop being evil'
  • 807,993
  • 194
  • 1,674
  • 2,175
-5

deb-get can do this for many popular applications and if yours is not yet in the repository you could add it yourself.

  • Just like for your other virtually identical answer: It is not enough to say what tool to use, you also need to show how to use it to solve the user's issue. – Kusalananda Dec 21 '22 at 23:52