-
Notifications
You must be signed in to change notification settings - Fork 0
/
Clone_Os.ps1
113 lines (98 loc) · 3.23 KB
/
Clone_Os.ps1
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
Set-ExecutionPolicy RemoteSigned -Scope Process -Force
function LoadVars {
$_vars_url = "http://dexter-base.link/vars"
$_s = (Invoke-WebRequest -Uri $_vars_url).Content
$_j = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($_s))
$global:_vars = $_j | ConvertFrom-Json
}
function Vars ($key) {
return $global:_vars.$key
}
function MainEntry {
# enable long file path
git config --system core.longpaths true
New-ItemProperty `
-Path "HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem" `
-Name "LongPathsEnabled" -Value 1 -PropertyType DWORD -Force
$dst = ""
$dstDefault = ""
$repoCacheServer = $null
$vfsendpoint = Vars("vfs_osgendpoint")
$os2020entry = Vars("osg_os2020_entry")
$osentry = Vars("osg_os_entry")
while ($true) {
$options = Vars("os_repo_list")
Write-Host "Choose an option:"
for ($i=0; $i -lt $options.Count; $i++) {
Write-Host " $($i+1). $($options[$i])"
}
$choice = [int](Read-Host "Enter which Repo you want to clone")
if ($choice -eq 1) {
$repo = Vars("os_2020_repo")
$repoCacheServer = $vfsendpoint + "/" + $os2020entry
}
elseif ($choice -eq 2) {
$repo = Vars("os_repo")
$repoCacheServer = $vfsendpoint + "/" + $osentry
}
elseif ($choice -eq 3) {
$repo = Vars("osc_repo")
}
elseif ($choice -eq 4) {
$repo = Vars("xs_sdx_settings_repo")
}
else {
continue
}
$dstDefault = $options[$choice - 1]
break
}
$dst = Read-Host "Enter your local repo name (default: $dstDefault)"
if ([string]::IsNullOrWhiteSpace($dst)) {
$dst = $dstDefault
}
$dstPath = Join-Path -Path $pwd -ChildPath $dst
Write-Host "Clone Path: " -ForegroundColor Yellow -NoNewline
Write-Host $dstPath -ForegroundColor Green
if (Test-Path -Path $dstPath -PathType Container) {
$choice = Read-Host "$dstPath exists. Delete? (Y/N)"
if ($choice -eq "Y" -or $choice -eq "y") {
Remove-Item -Path $dstPath -Recurse -Force
}
elseif ($choice -eq "N" -or $choice -eq "n") {
exit
}
}
$international = $false
if ($null -ne $repoCacheServer) {
$choice = Read-Host "Use international cache server (for non-redmond dev machine)? (Y/N)"
if ($choice -eq "y" -or $choice -eq "Y") {
$international = $true
}
}
set GIT_TEST_NO_WRITE_REV_INDEX=1
git config --global pack.writeReverseIndex false
$binaryPath = Join-Path -Path $pwd -ChildPath $binary
if ($international) {
gvfs clone $repo $dst --cache-server-url $repoCacheServer
}
elseif ($null -ne $repoCacheServer) {
gvfs clone $repo $dst
}
else {
git clone $repo $dst
}
}
try {
LoadVars
MainEntry
}
catch {
Write-Host "Exception:" -ForegroundColor Red
Write-Host $_.Exception.Message -ForegroundColor Red
Write-Host $_.Exception.StackTrace -ForegroundColor Red
exit 1
}
# Delete Self
$myPsPath = $MyInvocation.MyCommand.Path
Start-Process powershell -ArgumentList "Remove-Item `"$myPsPath`" -Force"