Skip to content

Instantly share code, notes, and snippets.

@jo-makar
Created July 4, 2021 19:43
Show Gist options
  • Save jo-makar/3e88101b7062a10fa5ba849aee96c18d to your computer and use it in GitHub Desktop.
Save jo-makar/3e88101b7062a10fa5ba849aee96c18d to your computer and use it in GitHub Desktop.
Apt and zoom (or any custom deb)

Apt and zoom (or any custom deb)

Setup

mkdir -p /srv/apt
# copy to update-zoom.py to /srv/apt

echo 'APT::Update::Pre-Invoke {"cd /srv/apt && ./update-zoom.py && apt-ftparchive packages . >Packages && apt-ftparchive release . >Release";};' >/etc/apt/apt.conf.d/100custom
echo 'deb [trusted=yes] file:/srv/apt ./' >/etc/apt/sources.list.d/custom.list

Usage

apt update
apt install zoom
#!/usr/bin/env python3
import requests
import datetime
import os
DEB_URL = 'https://zoom.us/client/latest/zoom_amd64.deb'
DEB_PATH = os.path.join(os.path.dirname(__file__), DEB_URL.split('/')[-1])
requests_kwargs = {'allow_redirects': True}
def update_required() -> bool:
try:
local_time = datetime.datetime.fromtimestamp(os.stat(DEB_PATH).st_mtime,
tz=datetime.timezone.utc)
except:
return True
resp = requests.head(DEB_URL, **requests_kwargs)
resp.raise_for_status()
lastmod = resp.headers['Last-Modified']
remote_time = datetime.datetime.strptime(lastmod, '%a, %d %b %Y %H:%M:%S GMT')
remote_time = remote_time.astimezone(datetime.timezone.utc)
return remote_time > local_time
# Alternatively can compare latest vs currently installed version:
# - Scrape latest version from https://zoom.us/download?os=linux
# - Get current version from "dpkg-query -W -f '${Version}\\n' zoom"
if update_required():
print('update required, downloading latest')
with requests.get(DEB_URL, stream=True, **requests_kwargs) as resp:
resp.raise_for_status()
with open(DEB_PATH, 'wb') as debfile:
for chunk in resp.iter_content(chunk_size=None):
debfile.write(chunk)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment