setup: Allow cloning openwrt with --reference

This helps speed up a clone, especially on slow networks.

python3 setup.py --setup --reference ~/git/tip/wlan-ap-wallaby/openwrt/

Signed-off-by: Ben Greear <greearb@candelatech.com>
This commit is contained in:
Ben Greear
2020-08-25 08:44:23 -07:00
committed by John Crispin
parent 9e457cd352
commit 7766193c0b

View File

@@ -34,7 +34,10 @@ def clone_tree():
print("### Cloning tree") print("### Cloning tree")
Path(openwrt).mkdir(exist_ok=True, parents=True) Path(openwrt).mkdir(exist_ok=True, parents=True)
run(["git", "clone", config["repo"], openwrt], check=True) if git_ref != "":
run(["git", "clone", "--reference", git_ref, config["repo"], openwrt], check=True)
else:
run(["git", "clone", config["repo"], openwrt], check=True)
print("### Clone done") print("### Clone done")
except: except:
print("### Cloning the tree failed") print("### Cloning the tree failed")
@@ -113,9 +116,10 @@ genkey = True
rebase = False rebase = False
config = "config.yml" config = "config.yml"
openwrt = "openwrt" openwrt = "openwrt"
git_ref = ""
try: try:
opts, args = getopt.getopt(sys.argv[1:], "srdc:f:", ["setup", "rebase", "docker", "config=", "folder="]) opts, args = getopt.getopt(sys.argv[1:], "srdc:f:", ["setup", "rebase", "docker", "config=", "folder=", "reference="])
except getopt.GetoptError as err: except getopt.GetoptError as err:
print(err) print(err)
sys.exit(2) sys.exit(2)
@@ -128,6 +132,8 @@ for o, a in opts:
rebase = True rebase = True
elif o in ("-c", "--config"): elif o in ("-c", "--config"):
config = a config = a
elif o in ("--reference"):
git_ref = a
elif o in ("-d", "--docker"): elif o in ("-d", "--docker"):
git_am = "apply" git_am = "apply"
genkey = False genkey = False