Skip to content

Commit e3a89eb

Browse files
committed
add dev and nightly
1 parent 8e0ccf1 commit e3a89eb

File tree

2 files changed

+99
-57
lines changed

2 files changed

+99
-57
lines changed

FirefoxDownload/Firefox.ps1

Lines changed: 48 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,18 @@ if($PSVersionTable.PSVersion.Major -lt 3){
66
Write-Host "I need PowerShell major version >= 3, Current is $($PSVersionTable.PSVersion.Major)" -ForegroundColor Red
77
return
88
}
9+
910
$installLocation = $env:ffdir
10-
if ([string]::IsNullOrEmpty($installLocation)){
11-
$installLocation = (Resolve-Path .\).Path
12-
}
13-
Write-Host "Current install location is $installLocation"
14-
if((Test-Path $installLocation)){
15-
if(-Not ((Get-ChildItem $installLocation | Measure-Object).Count -eq 0)){
16-
Write-Host 'I need an empty folder!' -ForegroundColor Red
17-
return
18-
}
19-
}
20-
else{
21-
Write-Host "Create directory $installLocation" -ForegroundColor Yellow
22-
New-Item -ItemType Directory -Force -Path $installLocation | Out-Null
23-
}
2411
$local = $env:ffloc
12+
$arch = $env:ffarch
13+
$branch = $env:ffbranch
14+
$url = 'https://www.mozilla.org/en-US/firefox/channel/desktop/'
15+
16+
#$local check
2517
if ([string]::IsNullOrEmpty($local)){
2618
$local = (Get-UICulture).Name
2719
}
28-
$arch = $env:ffarch
20+
#$arch check
2921
if ([string]::IsNullOrEmpty($arch)){
3022
if($ENV:PROCESSOR_ARCHITECTURE -eq 'AMD64'){
3123
$arch = 'win64'
@@ -34,18 +26,39 @@ if ([string]::IsNullOrEmpty($arch)){
3426
$arch = 'win'
3527
}
3628
}
37-
$branch = $env:ffbranch
29+
#$branch check
3830
switch ($branch)
3931
{
32+
'nightly' {$branch = 'firefox-nightly-latest-l10n'}
33+
'dev' {$branch = 'firefox-devedition-latest'}
4034
'beta' {$branch = 'firefox-beta-latest'}
4135
'esr' {$branch = 'firefox-esr-latest'}
4236
default {$branch = 'firefox-latest'}
4337
}
4438
Write-Host "Current branch is $branch" -ForegroundColor Yellow
45-
$url = "https://download.mozilla.org/?product=$branch&os=$arch&lang=$local"
46-
$downloadFileName = Join-Path $installLocation 'installer.exe'
39+
$url = "https://download.mozilla.org/?product=$branch-ssl&os=$arch&lang=$local"
4740
if ($env:TEMP -eq $null) {
48-
$env:TEMP = Join-Path $installLocation 'temp'
41+
$env:TEMP = Join-Path $installLocation 'temp'
42+
}
43+
#$installLocation check
44+
if ([string]::IsNullOrEmpty($installLocation)){
45+
$installLocation = (Resolve-Path .\).Path
46+
}
47+
48+
function Check-InstallLocation {
49+
50+
Write-Host "Current install location is $installLocation"
51+
if((Test-Path $installLocation)){
52+
if(-Not ((Get-ChildItem $installLocation | Measure-Object).Count -eq 0)){
53+
Write-Host 'I need an empty folder!' -ForegroundColor Red
54+
return $false
55+
}
56+
}
57+
else{
58+
Write-Host "Create directory $installLocation" -ForegroundColor Yellow
59+
New-Item -ItemType Directory -Force -Path $installLocation | Out-Null
60+
}
61+
return $true
4962
}
5063

5164
function Get-Downloader {
@@ -161,14 +174,21 @@ param (
161174
}
162175
}
163176

164-
Download-File $url $downloadFileName
165-
if(-Not (Test-Path $installLocation)){
166-
return
177+
function Download-Firefox {
178+
$downloadFileName = Join-Path $installLocation 'installer.exe'
179+
Download-File $url $downloadFileName
180+
if(-Not (Test-Path $downloadFileName)){
181+
Write-Host 'Firefox Download Fail!' -ForegroundColor Red
182+
return
183+
}
184+
Extract-File $downloadFileName $installLocation
185+
Remove-IfExists "$installLocation\setup.exe"
186+
Move-Item "$installLocation\core\*" -Destination $installLocation
187+
Remove-IfExists "$installLocation\core"
188+
Remove-IfExists $downloadFileName
189+
Write-Host 'Firefox Download Finished' -ForegroundColor Green
167190
}
168-
Extract-File $downloadFileName $installLocation
169-
Remove-IfExists "$installLocation\setup.exe"
170-
Move-Item "$installLocation\core\*" -Destination $installLocation
171-
Remove-IfExists "$installLocation\core"
172-
Remove-IfExists $downloadFileName
173191

174-
Write-Host 'Firefox Download Finished' -ForegroundColor Green
192+
if(Check-InstallLocation) {
193+
Download-Firefox
194+
}

FirefoxDownload/FirefoxWithFiredoge.ps1

Lines changed: 51 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,18 @@ if($PSVersionTable.PSVersion.Major -lt 3){
66
Write-Host "I need PowerShell major version >= 3, Current is $($PSVersionTable.PSVersion.Major)" -ForegroundColor Red
77
return
88
}
9+
910
$installLocation = $env:ffdir
10-
if ([string]::IsNullOrEmpty($installLocation)){
11-
$installLocation = (Resolve-Path .\).Path
12-
}
13-
Write-Host "Current install location is $installLocation"
14-
if((Test-Path $installLocation)){
15-
if(-Not ((Get-ChildItem $installLocation | Measure-Object).Count -eq 0)){
16-
Write-Host 'I need an empty folder!' -ForegroundColor Red
17-
return
18-
}
19-
}
20-
else{
21-
Write-Host "Create directory $installLocation" -ForegroundColor Yellow
22-
New-Item -ItemType Directory -Force -Path $installLocation | Out-Null
23-
}
2411
$local = $env:ffloc
12+
$arch = $env:ffarch
13+
$branch = $env:ffbranch
14+
$url = 'https://www.mozilla.org/en-US/firefox/channel/desktop/'
15+
16+
#$local check
2517
if ([string]::IsNullOrEmpty($local)){
2618
$local = (Get-UICulture).Name
2719
}
28-
$arch = $env:ffarch
20+
#$arch check
2921
if ([string]::IsNullOrEmpty($arch)){
3022
if($ENV:PROCESSOR_ARCHITECTURE -eq 'AMD64'){
3123
$arch = 'win64'
@@ -34,18 +26,39 @@ if ([string]::IsNullOrEmpty($arch)){
3426
$arch = 'win'
3527
}
3628
}
37-
$branch = $env:ffbranch
29+
#$branch check
3830
switch ($branch)
3931
{
32+
'nightly' {$branch = 'firefox-nightly-latest-l10n'}
33+
'dev' {$branch = 'firefox-devedition-latest'}
4034
'beta' {$branch = 'firefox-beta-latest'}
4135
'esr' {$branch = 'firefox-esr-latest'}
4236
default {$branch = 'firefox-latest'}
4337
}
4438
Write-Host "Current branch is $branch" -ForegroundColor Yellow
45-
$url = "https://download.mozilla.org/?product=$branch&os=$arch&lang=$local"
46-
$downloadFileName = Join-Path $installLocation 'installer.exe'
39+
$url = "https://download.mozilla.org/?product=$branch-ssl&os=$arch&lang=$local"
4740
if ($env:TEMP -eq $null) {
48-
$env:TEMP = Join-Path $installLocation 'temp'
41+
$env:TEMP = Join-Path $installLocation 'temp'
42+
}
43+
#$installLocation check
44+
if ([string]::IsNullOrEmpty($installLocation)){
45+
$installLocation = (Resolve-Path .\).Path
46+
}
47+
48+
function Check-InstallLocation {
49+
50+
Write-Host "Current install location is $installLocation"
51+
if((Test-Path $installLocation)){
52+
if(-Not ((Get-ChildItem $installLocation | Measure-Object).Count -eq 0)){
53+
Write-Host 'I need an empty folder!' -ForegroundColor Red
54+
return $false
55+
}
56+
}
57+
else{
58+
Write-Host "Create directory $installLocation" -ForegroundColor Yellow
59+
New-Item -ItemType Directory -Force -Path $installLocation | Out-Null
60+
}
61+
return $true
4962
}
5063

5164
function Get-Downloader {
@@ -161,18 +174,27 @@ param (
161174
}
162175
}
163176

164-
Download-File $url $downloadFileName
165-
if(-Not (Test-Path $installLocation)){
166-
return
177+
function Download-Firefox {
178+
$downloadFileName = Join-Path $installLocation 'installer.exe'
179+
Download-File $url $downloadFileName
180+
if(-Not (Test-Path $downloadFileName)){
181+
Write-Host 'Firefox Download Fail!' -ForegroundColor Red
182+
return
183+
}
184+
Extract-File $downloadFileName $installLocation
185+
Remove-IfExists "$installLocation\setup.exe"
186+
Move-Item "$installLocation\core\*" -Destination $installLocation
187+
Remove-IfExists "$installLocation\core"
188+
Remove-IfExists $downloadFileName
189+
Write-Host 'Firefox Download Finished' -ForegroundColor Green
167190
}
168-
Extract-File $downloadFileName $installLocation
169-
Remove-IfExists "$installLocation\setup.exe"
170-
Move-Item "$installLocation\core\*" -Destination $installLocation
171-
Remove-IfExists "$installLocation\core"
172-
Remove-IfExists $downloadFileName
173-
174-
Write-Host 'Firefox Download Finished' -ForegroundColor Green
175191

192+
if(Check-InstallLocation) {
193+
Download-Firefox
194+
}
195+
else{
196+
Write-Host 'Firefox Download Skipped' -ForegroundColor Yellow
197+
}
176198

177199
$JSON = Download-String 'https://static.pzhacm.org/shuax/fd/fd.json' | ConvertFrom-Json
178200
if([string]::IsNullOrEmpty($JSON.description)){

0 commit comments

Comments
 (0)