Created
May 24, 2020 20:14
-
-
Save lemon32767/5246652a49a2776eb4035d1810139034 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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