this repo has no description
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Fix #690

+65
+65
src/xcselect/clt_install.py
··· 1 + #!/usr/bin/python2.7 2 + # This file is part of Darling. 3 + # 4 + # Copyright (C) 2020 Lubos Dolezel 5 + # 6 + # Darling is free software: you can redistribute it and/or modify 7 + # it under the terms of the GNU General Public License as published by 8 + # the Free Software Foundation, either version 3 of the License, or 9 + # (at your option) any later version. 10 + # 11 + # Darling is distributed in the hope that it will be useful, 12 + # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 + # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 + # GNU General Public License for more details. 15 + # 16 + # You should have received a copy of the GNU General Public License 17 + # along with Darling. If not, see <http://www.gnu.org/licenses/>. 18 + 19 + import urllib2 20 + import json 21 + import tempfile 22 + import os 23 + import subprocess 24 + 25 + print("You are about to download and install Apple Command Line Tools covered by the following license:") 26 + print("https://www.apple.com/legal/sla/docs/xcode.pdf\n") 27 + 28 + while True: 29 + resp = raw_input("Do you agree with the terms of the license? (y/n) ") 30 + 31 + if resp == "y": 32 + break 33 + elif resp == "n": 34 + exit(1) 35 + 36 + packagesResp = urllib2.urlopen("https://swdistcache.darlinghq.org/api/v1/products/by-tag?tag=DTCommandLineTools") 37 + packages = json.loads(packagesResp.read()) 38 + 39 + tempdir = tempfile.mkdtemp() 40 + 41 + print("Downloading packages...") 42 + 43 + for package in packages[0]['packages']: 44 + fname = os.path.basename(package['url']) 45 + print("Downloading " + fname + "...") 46 + 47 + f = urllib2.urlopen(package['url']) 48 + 49 + fullpath = tempdir + "/" + fname 50 + with open(fullpath, "wb") as localfile: 51 + for chunk in iter(lambda: f.read(16*1024), ''): 52 + localfile.write(chunk) 53 + 54 + print("Installing...") 55 + exitCode = subprocess.call(["sudo", "installer", "-pkg", fullpath, "-target", "/"]) 56 + 57 + if exitCode != 0: 58 + print("Installation failed with exit code " + str(exitCode)) 59 + exit(1) 60 + 61 + os.remove(fullpath) 62 + 63 + os.rmdir(tempdir) 64 + 65 + print("Installation complete!")