Skip to content

Instantly share code, notes, and snippets.

@lemon32767
Created May 24, 2020 20:14
Show Gist options
  • Save lemon32767/5246652a49a2776eb4035d1810139034 to your computer and use it in GitHub Desktop.
Save lemon32767/5246652a49a2776eb4035d1810139034 to your computer and use it in GitHub Desktop.
#!/bin/env python
import subprocess, json, re, shutil, os
srcurl = "https://ziglang.org/download/index.json"
tmppath = "/tmp/zig-master.tar.xz"
print(" > downloading index...")
src = subprocess.check_output(["curl", "-L", srcurl])
dat = json.loads(src)
masterurl = dat["master"]["x86_64-linux"]["tarball"]
dire = "/tmp/" + re.findall("zig-linux-x86_64-[0-9.]+\+[0-9a-f]+", masterurl)[0]
print(" > master date: " + dat["master"]["date"])
print(" > downloading master tarball...")
subprocess.check_call(["curl", "-L", "--output", tmppath, masterurl])
print(" > extracting...")
os.chdir("/tmp")
subprocess.check_call(["tar", "xf", tmppath])
os.unlink(tmppath)
destdir=".local/share/zig-master"
out = os.getenv("HOME")+"/" + destdir
shutil.rmtree(out)
shutil.move(dire, out)
print(" > done!")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment