Skip to content

Commit 139d2a1

Browse files
committed
Tools Rework and version bump
Android Studio to v3.3.1. Reworked the tools to get rid of the need for the LessMSI download and now uses a special bootstrap exe to get 7zip
1 parent 2149d43 commit 139d2a1

5 files changed

+86
-120
lines changed

AndroidStudioPortable-Definitions.ps1

+40-38
Original file line numberDiff line numberDiff line change
@@ -14,32 +14,37 @@
1414
will be untouched.
1515
#>
1616

17+
#Settings folder for Android Studio
1718
$PortabelHomeDirectoryName =
1819
'portable-home'
1920
$PortableHomeDirectory =
2021
".\$PortabelHomeDirectoryName"
2122

23+
#Locations of Android SDK downloads
2224
$AndroidSDKDirectory =
2325
".\android-sdk-windows"
2426
$AndroidSDKBinariesDirectories = @(
2527
"$AndroidSDKDirectory\tools",
2628
"$AndroidSDKDirectory\platform-tools"
2729
)
2830

31+
## Android Studio
2932
$AndroidStudio =
30-
'android-studio-ide-181.5056338-windows'
33+
'android-studio-ide-182.5264788-windows'
3134
$AndroidStudioArchive =
3235
"$AndroidStudio.zip"
36+
#URL changes based on version above
3337
$AndroidStudioURL =
34-
"https://dl.google.com/dl/android/studio/ide-zips/3.2.1.0/$AndroidStudioArchive"
38+
"https://dl.google.com/dl/android/studio/ide-zips/3.3.1.0/$AndroidStudioArchive"
39+
## Autogenerated from above
3540
$AndroidStudioDirectory =
3641
".\$AndroidStudio\android-studio"
3742
$AndroidStudioBinariesDirectory =
3843
"$AndroidStudioDirectory\bin"
3944
$AndroidStudioUserHomeDirectory =
4045
"`${idea.home}/../../$PortabelHomeDirectoryName"
4146
$AndroidStudioHomeDirectory =
42-
"$AndroidStudioUserHomeDirectory/.AndroidStudio3.1"
47+
"$AndroidStudioUserHomeDirectory/.AndroidStudio"
4348
$AndroidStudioExecutable =
4449
'studio64.exe'
4550
$AndroidStudioConfigurationFile =
@@ -62,52 +67,49 @@ $AndroidStudioBatchFile =
6267
$GradleUserHomeDirectory =
6368
"$PortableHomeDirectory\.gradle"
6469

65-
$OracleJDK =
66-
'jdk-8u181-windows-x64'
67-
$OracleJDKInstaller =
68-
"$OracleJDK.exe"
69-
$OracleJDKURL =
70-
"http://download.oracle.com/otn-pub/java/jdk/8u181-b13/96a7b8442fe848ef90c96a2fad6ed6d1/$OracleJDKInstaller"
71-
$OracleJDKdlCookie =
72-
"Cookie: oraclelicense=accept-securebackup-cookie"
73-
$OracleJDKInternalCABPath =
74-
'.rsrc\1033\JAVA_CAB10'
75-
$OracleJDKInternalCAB =
76-
'111'
77-
$OracleJDKInternalArchive =
78-
'tools.zip'
79-
$OracleJDKDirectory =
80-
".\$OracleJDK"
81-
$OracleJDKBinariesDirectory =
82-
"$OracleJDKDirectory\bin"
70+
## OpenJDK Java binaries
71+
$OpenJDK =
72+
'OpenJDK8U-jdk_x64_windows_hotspot_8u202b08'
73+
$OpenJDKName =
74+
'jdk8u202-b08'
75+
#Should Autogenerate from above
76+
$OpenJDKArchive =
77+
"$OpenJDK.zip"
78+
$OpenJDKURL =
79+
"https://github.com/AdoptOpenJDK/openjdk8-binaries/releases/download/$OpenJDKName/$OpenJDKArchive"
80+
$OpenJDKDirectory =
81+
".\$OpenJDKName"
82+
$OpenJDKBinariesDirectory =
83+
"$OpenJDKDirectory\bin"
8384

84-
$LessMSI =
85-
'lessmsi-v1.6.1'
86-
$LessMSIArchive =
87-
"$LessMSI.zip"
88-
$LessMSIURL =
89-
'https://github.com/activescott/lessmsi/releases/download/v1.6.1/' +
90-
$LessMSIArchive
91-
$LessMSIDirectory =
92-
".\$LessMSI"
93-
$LessMSIExecutable =
94-
'lessmsi.exe'
85+
### Tools Section. Shouldnt need to change ##
9586

87+
##7z File Expander
9688
$7z =
97-
'7z1805-x64'
89+
'7z1900-extra'
90+
91+
#Autgenerated from above
9892
$7zInstaller =
99-
"$7z.msi"
93+
"$7z.7z"
10094
$7zURL =
10195
"http://d.7-zip.org/a/$7zInstaller"
102-
$7zDirectory =
103-
".\$7z\SourceDir\Files\7-Zip"
10496
$7zExecutable =
105-
'7z.exe'
106-
97+
'7za.exe'
98+
#$7zExtractFile =
99+
# "x64\$7zExecutable" #64 bit version if desired
100+
$7zExtractFile =
101+
"$7zExecutable"
102+
$7zBootStrapURL =
103+
'https://www.7-zip.org/a/7zr.exe'
104+
$7zBootStrapExec =
105+
'7zr.exe'
106+
107+
##Aria Downloader
107108
$aria2 =
108109
'aria2-1.34.0-win-64bit-build1'
109110
$aria2Archive =
110111
"$aria2.zip"
112+
##URL may need adjusted if newer version is used
111113
$aria2URL =
112114
"https://github.com/aria2/aria2/releases/download/release-1.34.0/$aria2Archive"
113115
$aria2Directory =

Readme.md

+9-8
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,12 @@ portable. To run the scripts you need PowerShell version 2.0 or higher.
77
* __Setup-AndroidStudioPortable.ps1__
88

99
+ Downloads aria2 and unpacks its archive.
10-
+ Downloads lessmsi and unpacks its archive.
11-
+ Downloads 7-Zip and unpacks its installer with lessmsi.
12-
+ Downloads the Android SDK and unpacks its archive with 7-Zip as .Net
13-
libraries can't handle long file names inside.
10+
+ Downloads 7zr to bootstrap extraction of 7-zip archives
11+
+ Downloads 7-Zip and unpacks its installer with 7zr.
1412
+ Downloads Android Studio and unpacks its archive.
1513
+ Downloads the Oracle JDK installer and unpacks it with 7-Zip.
1614
+ Unpacks `.pack` files in the JDK directory into `.jar` files with
1715
the unpack200 utility bundled with the JDK.
18-
+ Removes all aria2, lessmsi and 7-Zip files with the SDK, Studio, and JDK
19-
archives and installers.
2016
+ Generates a batch file to start an Android Studio instance without
2117
PowerShell.
2218

@@ -39,10 +35,15 @@ portable. To run the scripts you need PowerShell version 2.0 or higher.
3935
- Android Studio _bin_ directory
4036
- Android SDK _tools_ and _platform-tools_ directories
4137

38+
* __Remove-SetupTemporaryFiles.ps1__
39+
40+
+ Removes all aria2 and 7-Zip files then Studio and JDK
41+
archives.
42+
4243
* __Remove-AndroidStudioPortable.ps1__
4344

44-
+ Removes all aria2, lessmsi and 7-Zip files with the SDK, Studio, and JDK
45-
archives and installers.
45+
+ Removes all aria2 and 7-Zip files then Studio and JDK
46+
archives.
4647
+ Removes the unpacked SDK, Studio, and JDK directories but leaves the
4748
portable home directory along.
4849

Remove-AndroidStudioPortable.ps1

+3-27
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#Requires -Version 2.0
1+
#Requires -Version 2.0
22

33
<#
44
.SYNOPSIS
@@ -19,34 +19,10 @@
1919
. '.\AndroidStudioPortable-Helpers.ps1'
2020

2121
#
22-
# Remove temporary files.
22+
# Cleanup Tools
2323
#
24+
. '.\Remove-SetupTemporaryFiles.ps1'
2425

25-
$aria2RootDirectory =
26-
Get-RelativeRootDirectory -RelativePath $aria2Directory
27-
$LessMSIRootDirectory =
28-
Get-RelativeRootDirectory -RelativePath $LessMSIDirectory
29-
$7zRootDirectory =
30-
Get-RelativeRootDirectory -RelativePath $7zDirectory
31-
32-
$TemporaryFiles = @(
33-
$aria2Archive,
34-
$aria2RootDirectory,
35-
$LessMSIArchive,
36-
$LessMSIRootDirectory,
37-
$7zInstaller,
38-
$7zRootDirectory,
39-
$AndroidSDKArchive,
40-
$AndroidStudioArchive,
41-
$OracleJDKInstaller,
42-
$OracleJDKInternalArchive
43-
)
44-
45-
$RemoveItemParameters = @{
46-
Path = $TemporaryFiles;
47-
ErrorAction = 'SilentlyContinue';
48-
}
49-
Remove-Item @RemoveItemParameters -Recurse -Force
5026

5127
#
5228
# Remove installed packages.

Remove-SetupTemporaryFiles.ps1

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#
2+
# Remove temporary files.
3+
#
4+
$aria2RootDirectory =
5+
Get-RelativeRootDirectory -RelativePath $aria2Directory
6+
7+
$TemporaryFiles = @(
8+
$aria2Archive,
9+
$aria2RootDirectory,
10+
$7zBootStrapExec,
11+
$7zInstaller,
12+
$7zExecutable,
13+
$AndroidStudioArchive,
14+
$OracleJDKInstaller,
15+
$OracleJDKInternalArchive
16+
)
17+
18+
$RemoveItemParameters = @{
19+
Path = $TemporaryFiles;
20+
ErrorAction = 'SilentlyContinue';
21+
}
22+
Remove-Item @RemoveItemParameters -Recurse -Force

Setup-AndroidStudioPortable.ps1

+12-47
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@
2929
#
3030

3131
#
32-
# Download and unpack lessmsi to be able to unpack
33-
# a 7-Zip installer later.
32+
# 0. Check to see if we need to download anything
3433
#
3534

3635
$ToolsAreRequired =
@@ -48,32 +47,22 @@ if ($ToolsAreRequired -And !(Test-Path -Path $aria2Directory))
4847
Write-Output "Expand Aria2"
4948
Expand-Archive -Path $aria2Archive
5049
}
51-
52-
if ($ToolsAreRequired -And !(Test-Path -Path $LessMSIDirectory))
53-
{
54-
if (!(Test-Path -Path $LessMSIArchive))
55-
{
56-
Write-Output "Get LessMSI"
57-
& ".\$aria2Directory\$aria2Executable" -o $LessMSIArchive $LessMSIURL
58-
}
59-
Write-Output "Expand LessMSI"
60-
Expand-Archive -Path $LessMSIArchive
61-
}
6250

6351
#
64-
# Download and unpack the 7-Zip installer.
52+
# Download and unpack the 7-Zip archive and bootstrap extractor.
6553
#
6654

67-
if ($ToolsAreRequired -And !(Test-Path -Path $7zDirectory))
55+
if ($ToolsAreRequired -And !(Test-Path -Path $7zExecutable))
6856
{
6957
if (!(Test-Path -Path $7zInstaller))
7058
{
7159
Write-Output "Get 7-Zip"
72-
& ".\$aria2Directory\$aria2Executable" -o $7zInstaller $7zURL
60+
& ".\$aria2Directory\$aria2Executable" --file-allocation=none -o $7zBootStrapExec $7zBootStrapURL
61+
& ".\$aria2Directory\$aria2Executable" --file-allocation=none -o $7zInstaller $7zURL
7362
}
7463

75-
Write-Output "Use LessMSI to unpack 7zip"
76-
& ".\$LessMSIDirectory\$LessMSIExecutable" 'x' $7zInstaller
64+
Write-Output "Use 7zr to unpack 7zip"
65+
& ".\$7zBootStrapExec" 'e' $7zInstaller '-bso0' '-bsp1' '-y' $7zExtractFile
7766
}
7867

7968
#
@@ -82,14 +71,14 @@ if ($ToolsAreRequired -And !(Test-Path -Path $7zDirectory))
8271

8372
if (!(Test-Path -Path $AndroidStudioDirectory))
8473
{
85-
if (!(Test-Path -Path $AndroidStudioArchive))
74+
if (!(Test-Path -Path $AndroidStudioArchive) -or (Test-Path -Path "$AndroidStudioArchive.aria2"))
8675
{
8776
Write-Output "Download Android Studio $AndroidStudio"
88-
& ".\$aria2Directory\$aria2Executable" -c -o $AndroidStudioArchive $AndroidStudioURL
77+
& ".\$aria2Directory\$aria2Executable" --file-allocation=none -c -o $AndroidStudioArchive $AndroidStudioURL
8978
}
9079

9180
Write-Output "Unpacking Android Studio"
92-
& ".\$7zDirectory\$7zExecutable" 'x' $AndroidStudioArchive '-o*' '-y'
81+
& ".\$7zExecutable" 'x' $AndroidStudioArchive '-o*' '-bso0' '-bsp1' '-y'
9382
}
9483

9584
#
@@ -220,33 +209,9 @@ foreach ($VMConfigurationFile in $AndroidStudioVMConfigurationFiles)
220209
}
221210

222211
#
223-
# Remove temporary files.
212+
# Cleanup Tools
224213
#
225-
$aria2RootDirectory =
226-
Get-RelativeRootDirectory -RelativePath $aria2Directory
227-
$LessMSIRootDirectory =
228-
Get-RelativeRootDirectory -RelativePath $LessMSIDirectory
229-
$7zRootDirectory =
230-
Get-RelativeRootDirectory -RelativePath $7zDirectory
231-
232-
$TemporaryFiles = @(
233-
$aria2Archive,
234-
$aria2RootDirectory,
235-
$LessMSIArchive,
236-
$LessMSIRootDirectory,
237-
$7zInstaller,
238-
$7zRootDirectory,
239-
$AndroidStudioArchive,
240-
$OracleJDKInstaller,
241-
$OracleJDKInternalCAB,
242-
$OracleJDKInternalArchive
243-
)
244-
245-
$RemoveItemParameters = @{
246-
Path = $TemporaryFiles;
247-
ErrorAction = 'SilentlyContinue';
248-
}
249-
Remove-Item @RemoveItemParameters -Recurse -Force
214+
. '.\Remove-SetupTemporaryFiles.ps1'
250215

251216
#
252217
# Generate a batch file to start Android Studio.

0 commit comments

Comments
 (0)