This repository has been archived by the owner on Sep 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
aa228download.jl
69 lines (57 loc) · 2.11 KB
/
aa228download.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# Download/update AA228Student and RedPen repositories
# Robert Moss | [email protected] | Sep. 2019
if VERSION < v"1.2"
error("Julia v1.2 is required. Your current version is v", VERSION)
end
if Int <: Int32
error("64-bit version of Julia is required, please redownload the 64-bit version.")
end
if Sys.iswindows()
try
# Check if in elevated mode (required to build ZMQ)
run(pipeline(Cmd(["net", "session"]), stdout=Pipe(), stderr=Pipe()))
catch err
@warn("A package dependency on Windows requires Administrator privileges, please restart your terminal and 'Run as administrator'.\nYou only need to do this to run aa228download.jl")
exit(-1)
end
end
using Pkg
using LibGit2
@info "Updating RedPen and AA228Student (requires git)..."
# Download Obfuscatee as a package
Pkg.add(PackageSpec(url="https://github.com/sisl/Obfuscatee.jl.git"))
# Download RedPen as a package
Pkg.add(PackageSpec(url="https://github.com/sisl/RedPen.jl.git"))
function gitpull(repo::GitRepo)
LibGit2.fetch(repo)
LibGit2.merge!(repo)
end
# Resolve FETCH_HEAD issues by clearing it out
clearhead(path::String) = rm(joinpath(path, ".git", "FETCH_HEAD"), force=true)
function update(path::String)
clearhead(aa228path)
repo = GitRepo(aa228path)
gitpull(repo)
end
# Download/update AA228Student repository
if basename(pwd()) == "AA228Student"
aa228path = pwd()
update(aa228path)
elseif isdir("AA228Student")
# Update repo if it exists
aa228path = joinpath(pwd(), "AA228Student")
update(aa228path)
else
# Download AA228Student as a local repo, then add it as a package
# Clone repo if it doesn't exist
LibGit2.clone("https://github.com/sisl/AA228Student.jl.git", "AA228Student")
aa228path = joinpath(pwd(), "AA228Student")
end
# Add AA228Student as a local package
@info string("Using AA228Student repository from: ", aa228path)
Pkg.add(PackageSpec(path=aa228path))
@info "Precompiling AA228Student..."
Pkg.update()
Pkg.build()
using AA228Student # Precompiles packages
@info string("Please submit projects from the following directory:\n", joinpath(aa228path, "workspace"))