Codebase list google-nexus-tools / c02eb9a
Import upstream version 5.4 Kali Janitor 1 year, 5 months ago
21 changed file(s) with 802 addition(s) and 280 deletion(s). Raw diff Collapse all Expand all
0 name: Compile Nexus Tools
1 on:
2 workflow_dispatch:
3
4 jobs:
5 compile_linux:
6 runs-on: ubuntu-latest
7 steps:
8 # Checks-out repository under $GITHUB_WORKSPACE
9 - uses: actions/checkout@v2
10 # Install dependencies
11 - name: Install Dart SDK
12 run: |
13 sudo apt-get update
14 sudo apt-get install apt-transport-https -y
15 sudo sh -c 'wget -qO- https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -'
16 sudo sh -c 'wget -qO- https://storage.googleapis.com/download.dartlang.org/linux/debian/dart_stable.list > /etc/apt/sources.list.d/dart_stable.list'
17 sudo apt-get update
18 sudo apt install dart -y
19 - name: Compile Dart executable
20 run: |
21 cd $GITHUB_WORKSPACE
22 dart pub get
23 dart compile exe "./bin/main.dart" -o "./nexustools"
24 # Upload binary
25 - name: Upload Dart executable
26 uses: actions/upload-artifact@v2
27 with:
28 name: nexustools-linux-x64
29 path: nexustools
30 compile_windows:
31 runs-on: windows-latest
32 steps:
33 - name: Install Dart SDK
34 run: |
35 choco install dart-sdk
36 - uses: actions/checkout@v2
37 - name: Compile Dart executable
38 run: |
39 C:\tools\dart-sdk\bin\dart pub get
40 C:\tools\dart-sdk\bin\dart compile exe "bin\main.dart" -o "nexustools.exe"
41 - name: Upload Dart executable
42 uses: actions/upload-artifact@v2
43 with:
44 name: nexustools-windows-x64
45 path: nexustools.exe
46 compile_macos:
47 runs-on: macos-latest
48 steps:
49 - name: Install Dart SDK
50 run: |
51 brew tap dart-lang/dart
52 brew install dart
53 - uses: actions/checkout@v2
54 - name: Compile Dart executable
55 run: |
56 dart pub get
57 dart compile exe "./bin/main.dart" -o "./nexustools"
58 - name: Upload Dart executable
59 uses: actions/upload-artifact@v2
60 with:
61 name: nexustools-macos-x64
62 path: nexustools
0 .packages
1 .dart_tool
2 dist/*
3 .DS_Store
0 # Donate
1
2 If you found Nexus Tools useful, please consider donating to support development! It takes a lot of work and testing to ensure Nexus Tools remains compatible with multiple operating systems and hardware platforms.
3
4 **[Donate with PayPal](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=4SZVSMJKDS35J&lc=US&item_name=Nexus%20Tools%20Donation&currency_code=USD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted)**
5
6 **[Join the Patreon](https://www.patreon.com/corbindavenport)**
0 ![alt text](http://i.imgur.com/shjM51Q.png "Nexus Tools")
1 ===========
0 # Nexus Tools
21
3 Nexus Tools is an installer for the Android debug/development command-line tools ADB (Android Device Bridge) and Fastboot for Mac OS X, Linux, and Google Chrome/Chromium OS. The script does not need to be downloaded, simply copy and paste this command into the terminal and run it to install Nexus Tools:
2 Nexus Tools is an installer for the [Android SDK Platform Tools](https://developer.android.com/studio/releases/platform-tools) package, which includes [ADB](https://developer.android.com/studio/command-line/adb.html), Fastboot, and other applications. Nexus Tools is writen in Dart, and can run on Linux, macOS, Windows, Windows Subsystem for Linux, and Chrome OS.
3
4 Nexus Tools downloads the latest Platform tools package directly from Google's servers (so you're always getting the latest version), saves them to `~/.nexustools` (`$Home\NexusTools` on Windows), and adds the directory to your system's path. On Windows, Nexus Tools can optionally install [Koush's Universal ADB Driver](https://github.com/koush/UniversalAdbDriver).
5
6 Once Nexus Tools is finished, you can run `adb`, `fastboot`, and other commands with no problems. **You need to open a new terminal/command line window after installation for changes to take effect.** The SDK Platform Tools can be updated by running `nexustools -i`, or you can uninstall everything by running `nexustools -r`.
7
8 ### How to use on Linux, macOS, and Chrome OS
9
10 Paste this command into the Terminal app:
11
412 ```
5 bash <(curl https://raw.githubusercontent.com/corbindavenport/nexus-tools/master/install.sh)
13 bash <(curl -s https://raw.githubusercontent.com/corbindavenport/nexus-tools/master/install.sh)
614 ```
7 and this command to un-install Nexus Tools:
15
16 You can also download the Mac and Linux versions from the [latest release page](https://github.com/corbindavenport/nexus-tools/releases/), un-zip the file, and run it from the Terminal.
17
18 ### How to use on Windows
19
20 Open Windows PowerShell from the Start Menu and paste this command:
21
822 ```
9 bash <(curl https://raw.githubusercontent.com/corbindavenport/nexus-tools/master/uninstall.sh)
23 iex ((New-Object System.Net.WebClient).DownloadString('https://raw.githubusercontent.com/corbindavenport/nexus-tools/master/install.ps1'))
1024 ```
11 These commands will download the selected script and run it. The script will download the files it needs during runtime, so it requires an internet connection. The script works on both Mac OS X and Linux (as long as the curl package is installed).
1225
13 Support for Google Chrome OS is experimental at this time, as I was only able to test it on a build of Chromium for x86 PCs. I don't have an actual Chromebook to test it on, but Nexus Tools should work correctly on both x86 and ARM Chromebooks.
26 You can also download the Windows version from the [latest release page](https://github.com/corbindavenport/nexus-tools/releases/), un-zip the file, and run it from Windows PowerShell or the Command Prompt.
1427
15 Nexus Tools requires sudo privileges to install/uninstall the adb and fastboot tools to /usr/bin, so they can be run without typing the full directory.
28 ### Compatibility
1629
17 ---------------------------------------
30 Nexus Tools is only available for x86_64 macOS, Linux, and Windows, because Google only provides native Platform Tools binaries for those platforms. On Macs with Apple Silicon, Nexus Tools runs in the [Rosetta 2 compatibility layer](https://support.apple.com/en-us/HT211861).
1831
19 __XDA Thread:__ [http://forum.xda-developers.com/showthread.php?t=2564453](http://forum.xda-developers.com/showthread.php?t=2564453)
32 ### Analytics
2033
21 __XDA Article:__ [http://www.xda-developers.com/android/set-up-adb-and...](http://www.xda-developers.com/android/set-up-adb-and-fastboot-on-linux-mac-os-x-and-chrome-os-with-a-single-command/)
34 Nexus Tools uses [Plausible Analytics](https://plausible.io) to transmit your operating system and CPU architecture during the installation process. This data is not sold or shared in any way, it's only for me to know which hardware platforms I should focus my attention on. You can disable analytics reporting by adding the `--no-analytics` parameter to the install command, like this:
2235
23 ---------------------------------------
36 ```
37 bash <(curl -s https://raw.githubusercontent.com/corbindavenport/nexus-tools/master/install.sh) --no-analytics
38 ```
2439
25 This program is free software: you can redistribute it and/or modify
26 it under the terms of the GNU General Public License as published by
27 the Free Software Foundation, either version 3 of the License, or
28 (at your option) any later version.
40 It also works when running Nexus Tools locally:
2941
30 This program is distributed in the hope that it will be useful,
31 but WITHOUT ANY WARRANTY; without even the implied warranty of
32 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
33 GNU General Public License for more details.
42 ```
43 nexustools --no-analytics
44 ```
3445
35 You should have received a copy of the GNU General Public License
36 along with this program. If not, see <http://www.gnu.org/licenses/>.
46 This analytics data is viewable publicly at [plausible.io/nexustools.corbin.io](https://plausible.io/nexustools.corbin.io).
47
48 ### Development info
49
50 Nexus Tools is written in Dart, so you need the [Dart SDK](https://dart.dev/get-dart) to work on it. You can run Nexus Tools from source like this:
51
52 ```
53 dart ./bin/main.dart
54 ```
55
56 The `compile.sh` (macOS and Linux) and `compile.ps1` scripts create executables and zip them. You can also use GitHub Actions to compile Nexus Tools, by navigating to Actions > Compile Nexus Tools > Run workflow.
0 # Defines a default set of lint rules enforced for projects at Google. For
1 # details and rationale, see
2 # https://github.com/dart-lang/pedantic#enabled-lints.
3
4 include: package:pedantic/analysis_options.yaml
5
6 # For lint rules and documentation, see http://dart-lang.github.io/linter/lints.
7
8 # Uncomment to specify additional rules.
9 # linter:
10 # rules:
11 # - camel_case_types
12
13 # analyzer:
14 # exclude:
15 # - path/to/excluded/files/**
bin/linux-arm-adb less more
Binary diff not shown
bin/linux-arm-fastboot less more
Binary diff not shown
bin/linux-i386-adb less more
Binary diff not shown
bin/linux-i386-fastboot less more
Binary diff not shown
bin/mac-adb less more
Binary diff not shown
bin/mac-fastboot less more
Binary diff not shown
0 import 'package:archive/archive_io.dart';
1 import 'package:http/http.dart' as http;
2 import 'dart:io' as io;
3 import 'package:archive/archive.dart';
4 import 'package:uuid/uuid.dart';
5 import 'dart:convert';
6 import 'package:nexustools/sys.dart' as sys;
7
8 String macZip =
9 'https://dl.google.com/android/repository/platform-tools-latest-darwin.zip';
10 String linuxZip =
11 'https://dl.google.com/android/repository/platform-tools-latest-linux.zip';
12 String windowsZip =
13 'https://dl.google.com/android/repository/platform-tools-latest-windows.zip';
14 List supportedCPUs = ['amd64', 'x86_64', 'AMD64'];
15 Map envVars = io.Platform.environment;
16 double appVersion = 5.4;
17
18 // Function for checking for update
19 Future checkUpdate() async {
20 var net = Uri.parse(
21 'https://api.github.com/repos/corbindavenport/nexus-tools/releases/latest');
22 try {
23 var data = await http.read(net);
24 var parsedData = json.decode(data);
25 // Compare versions
26 if (double.parse(parsedData['tag_name']) > appVersion) {
27 print(
28 '[INFO] Nexus Tools update available! Download: https://git.io/JBuTh');
29 } else {
30 print('[INFO] You have the latest version of Nexus Tools.');
31 }
32 } catch (e) {
33 print('[EROR] Could not check for updates.');
34 }
35 }
36
37 // Function for obtaining Nexus Tools path
38 // Credit: https://stackoverflow.com/a/25498458
39 String nexusToolsDir() {
40 var home = '';
41 if (io.Platform.isMacOS) {
42 home = envVars['HOME'];
43 } else if (io.Platform.isLinux) {
44 home = envVars['HOME'];
45 } else if (io.Platform.isWindows) {
46 home = envVars['UserProfile'];
47 }
48 if (home.endsWith('/')) {
49 home = home.substring(0, home.length - 1);
50 }
51 if (io.Platform.isWindows) {
52 return '$home\\NexusTools';
53 } else {
54 return '$home/.nexustools';
55 }
56 }
57
58 // Function for installing Platform Tools package
59 Future installPlatformTools() async {
60 var dir = nexusToolsDir();
61 // Get the proper ZIP file
62 var zip = '';
63 if (io.Platform.isMacOS) {
64 zip = macZip;
65 } else if (io.Platform.isLinux) {
66 zip = linuxZip;
67 } else if (io.Platform.isWindows) {
68 zip = windowsZip;
69 }
70 // Download file
71 print('[....] Downloading Platform Tools package, please wait.');
72 var net = Uri.parse(zip);
73 try {
74 var data = await http.readBytes(net);
75 //await zipFile.writeAsBytes(data);
76 var archive = ZipDecoder().decodeBytes(data);
77 extractArchiveToDisk(archive, dir);
78 } catch (e) {
79 var error = e.toString();
80 print('[EROR] There was an error downloading Platform Tools: $error');
81 io.exit(1);
82 }
83 // Move files out of platform-tools subdirectory and delete the subdirectory
84 if (io.Platform.isWindows) {
85 await io.Process.run('move', ['$dir\\platform-tools\\*', '$dir'],
86 runInShell: true);
87 await io.Process.run('rmdir', ['/Q', '/S', '$dir\\platform-tools'],
88 runInShell: true);
89 } else {
90 await io.Process.run(
91 '/bin/sh', ['-c', 'mv -f -v $dir/platform-tools/* $dir/']);
92 await io.Process.run('/bin/sh', ['-c', 'rm -rf $dir/platform-tools']);
93 }
94 // Mark binaries in directory as executable
95 if (io.Platform.isLinux || io.Platform.isMacOS) {
96 await io.Process.run('/bin/sh', ['-c', 'chmod -f +x $dir/*']);
97 }
98 // Give a progress report
99 print('[ OK ] Platform Tools now installed in $dir.');
100 // Add binaries to path
101 await sys.addPath(dir);
102 // Create help link
103 if (io.Platform.isWindows) {
104 var file = io.File('$dir\\About Nexus Tools.url');
105 await file.writeAsString(
106 '[InternetShortcut]\nURL=https://github.com/corbindavenport/nexus-tools/blob/master/README.md',
107 mode: io.FileMode.writeOnly);
108 } else if (io.Platform.isMacOS) {
109 var file = io.File('$dir/About Nexus Tools.url');
110 await file.writeAsString(
111 '[InternetShortcut]\nURL=https://github.com/corbindavenport/nexus-tools/blob/master/README.md',
112 mode: io.FileMode.writeOnly);
113 } else if (io.Platform.isLinux) {
114 var file = io.File('$dir/About Nexus Tools.desktop');
115 await file.writeAsString(
116 '[Desktop Entry]\nEncoding=UTF-8\nIcon=text-html\nType=Link\nName=About Nexus Tools\nURL=https://github.com/corbindavenport/nexus-tools/blob/master/README.md',
117 mode: io.FileMode.writeOnly);
118 }
119 // Install drivers on Windows
120 if (io.Platform.isWindows) {
121 // Check if Universal Adb Driver package is already installed
122 var info = await io.Process.run('wmic', ['product', 'get', 'Name']);
123 var parsedInfo = info.stdout.toString();
124 if (parsedInfo.contains('Universal Adb Driver')) {
125 print('[ OK ] Universal ADB Drivers already installed.');
126 } else {
127 // Prompt to install drivers
128 print(
129 '[WARN] Drivers may be required for ADB if they are not already installed.');
130 io.stdout
131 .write('[WARN] Install drivers from adb.clockworkmod.com? [Y/N] ');
132 var input = io.stdin.readLineSync();
133 if (input?.toLowerCase() == 'y') {
134 await installWindowsDrivers(dir);
135 }
136 }
137 }
138 }
139
140 // Function for removing Platform Tools package
141 Future removePlatformTools() async {
142 // Nexus Tools 3.2+ (August 2016-Present) installs binaries in ~/.nexustools
143 var dir = nexusToolsDir();
144 var installExists = false;
145 installExists = await io.Directory(dir).exists();
146 if (installExists) {
147 print(
148 '[WARN] Deleting $dir will delete Android System Tools (ADB, Fastboot, etc.).');
149 print('[WARN] This will also delete the Nexus Tools application.');
150 io.stdout.write('[WARN] Continue with removal? [Y/N] ');
151 var input = io.stdin.readLineSync();
152 if (input?.toLowerCase() != 'y') {
153 return;
154 }
155 // Proceed with deletion
156 await io.Directory(dir).delete(recursive: true);
157 print('[ OK ] Deleted directory at $dir.');
158 print('[INFO] Nexus Tools can be re-installed at https://git.io/JBuTh.');
159 } else {
160 print('[EROR] No installation found at $dir.');
161 }
162 }
163
164 // Function for installing Windows Universal ADB drivers
165 // Drivers provided by ClockWorkMod: https://adb.clockworkmod.com/
166 Future installWindowsDrivers(String dir) async {
167 print('[....] Downloading drivers, please wait.');
168 var net = Uri.parse(
169 'https://github.com/koush/adb.clockworkmod.com/releases/latest/download/UniversalAdbDriverSetup.msi');
170 try {
171 var data = await http.readBytes(net);
172 var file = io.File('$dir\\ADB Drivers.msi');
173 await file.writeAsBytes(data, mode: io.FileMode.writeOnly);
174 print('[....] Opening driver installer.');
175 await io.Process.run(
176 'start', ['/wait', 'msiexec.exe', '/i', '$dir\\ADB Drivers.msi'],
177 runInShell: true);
178 } catch (e) {
179 print(
180 '[EROR] There was an error downloading drivers, try downloading them from adb.clockworkmod.com.');
181 }
182 }
183
184 // Function for Plausible Analytics reporting
185 void connectAnalytics() async {
186 var uuid = Uuid();
187 var id = uuid.v4();
188 // Get exact operating system
189 var realOS = '';
190 var isWSL = await io.Directory('/mnt/c/Windows').exists();
191 var isChromeOS = await io.Directory('/usr/share/themes/CrosAdapta').exists();
192 if (isWSL) {
193 realOS = 'wsl';
194 } else if (isChromeOS) {
195 realOS = 'chromeos';
196 } else {
197 realOS = io.Platform.operatingSystem;
198 }
199 var cpu = await sys.getCPUArchitecture();
200 // Set data
201 var net = Uri.parse('https://plausible.io/api/event');
202 var netHeaders = {
203 'user-agent': 'Nexus Tools',
204 'X-Forwarded-For': '127.0.0.1',
205 'Content-Type': 'application/json',
206 'User-Agent': 'Mozilla/5.0 ($realOS) AppleWebKit/500 (KHTML, like Gecko) Chrome/$appVersion $id'
207 };
208 var netBody = '{"name":"pageview","url":"app://localhost/$realOS/$cpu","domain":"nexustools.corbin.io"}';
209 // Send request
210 try {
211 await http.post(net, headers: netHeaders, body: netBody);
212 } catch (_) {
213 // Do nothing
214 }
215 }
216
217 // Pre-installation steps
218 Future checkInstall() async {
219 // Check if directory already exists
220 var dir = nexusToolsDir();
221 var installExists = false;
222 if (io.Platform.isWindows) {
223 installExists = await io.File('$dir\\adb.exe').exists();
224 } else {
225 installExists = await io.File('$dir/adb').exists();
226 }
227 if (installExists) {
228 io.stdout.write(
229 '[WARN] Platform tools already installed in $dir. Continue? [Y/N] ');
230 var input = io.stdin.readLineSync();
231 if (input?.toLowerCase() != 'y') {
232 io.exit(0);
233 }
234 } else {
235 // Make the directory
236 await io.Directory(dir).create(recursive: true);
237 print('[ OK ] Created folder at $dir.');
238 }
239 // Check if ADB is already installed
240 sys.checkIfInstalled(dir, 'adb', 'ADB');
241 // Check if Fastboot is already installed
242 sys.checkIfInstalled(dir, 'fastboot', 'Fastboot');
243 // Check CPU architecture
244 var cpu = await sys.getCPUArchitecture();
245 if (supportedCPUs.contains(cpu)) {
246 print('[ OK ] Your hardware platform is supported, yay!');
247 } else if (io.Platform.isMacOS && (cpu == 'arm64')) {
248 print(
249 '[WARN] Google does not provide native Apple Silicon binaries yet, x86_64 binaries will be installed');
250 } else {
251 print(
252 '[EROR] Your hardware platform is detected as $cpu, but Google only provides Platform Tools for x86-based platforms.');
253 io.exit(1);
254 }
255 // Display environment-specific warnings
256 var isWSL = await io.Directory('/mnt/c/Windows').exists();
257 var isChromeOS = await io.Directory('/usr/share/themes/CrosAdapta').exists();
258 if (isWSL) {
259 print(
260 '[WARN] WSL does not support USB devices, you will only be able to use ADB over Wi-Fi.');
261 } else if (isChromeOS) {
262 print('[WARN] Chrome OS 75 or higher is required for USB support.');
263 }
264 }
265
266 void printHelp() {
267 var helpDoc = '''
268 Nexus Tools $appVersion
269 Downloader/management app for Android SDK Platform Tools
270
271 Usage: nexustools [OPTIONS]
272
273 Example: nexustools -i (this installs Platform Tools)
274
275 -i, --install Install/update Android Platform Tools
276 -r, --remove Remove Platform Tools
277 -n, --no-analytics Run Nexus Tools without Plausible Analytics
278 (analytics is only run on install)
279 -c, --check Check for Nexus Tools update
280 -h, --help Display this help message
281 ''';
282 print(helpDoc);
283 }
284
285 void main(List<String> arguments) async {
286 if (arguments.contains('-i') || arguments.contains('--install')) {
287 print('[INFO] Nexus Tools $appVersion');
288 // Check version unless Nexus Tools is running from web (curl) installer
289 // The web installer adds the -w parameter
290 if (!arguments.contains('-w')) {
291 await checkUpdate();
292 }
293 // Start analytics unless opted out
294 if (arguments.contains('--no-analytics')) {
295 print('[ OK ] Plausible Analytics are disabled.');
296 } else {
297 connectAnalytics();
298 }
299 // Start installation
300 await checkInstall();
301 await installPlatformTools();
302 // Post-install
303 var appName = '';
304 if (io.Platform.isWindows) {
305 appName = 'Command Line window (not a new tab!)';
306 } else {
307 appName = 'Terminal window';
308 }
309 print(
310 '[INFO] Installation complete! Open a new $appName to apply changes.');
311 print('[INFO] Run "nexustools --help" at any time for more options.');
312 print(
313 '[INFO] Join the Discord server: https://discord.com/invite/59wfy5cNHw');
314 print('[INFO] Donate to support development: https://git.io/J4jct');
315 } else if (arguments.contains('-r') || arguments.contains('--remove')) {
316 print('[INFO] Nexus Tools $appVersion');
317 // Start removal
318 await removePlatformTools();
319 } else if (arguments.contains('-h') || arguments.contains('--help')) {
320 printHelp();
321 } else if (arguments.contains('-c') || arguments.contains('--check')) {
322 await checkUpdate();
323 } else {
324 print('[EROR] Invalid arguments. Run nexustools -h for help!');
325 }
326 }
0 $FileName = "nexustools-windows-x64"
1
2 # Make the new directory
3 $dirCheck = Test-Path dist
4 if ($dirCheck) {
5 # Do nothing
6 } else {
7 New-Item -Name "dist" -ItemType Directory
8 }
9
10 dart compile exe "./bin/main.dart" -o "./dist/nexustools.exe"
11 Compress-Archive -Path "./dist/nexustools.exe" -DestinationPath "./dist/$FileName.zip" -Force
12 del "./dist/nexustools.exe"
0 # This script is for compiling the Dart executable
1 # The current path needs to be set to the root of the repository first
2 # You also need the Dart SDK and zip installed
3
4 OS=$(uname)
5 ARCH=$(uname -m)
6 FILENAME=""
7
8 if [ "$OS" = "Darwin" ]; then
9 # This will need to be updated when M1 support is added
10 FILENAME="nexustools-macos-x64"
11 elif [ "$OS" = "Linux" ] && [ "$ARCH" = "x86_64" ]; then
12 FILENAME="nexustools-linux-x64"
13 elif [ "$OS" = "Linux" ] && [ "$ARCH" = "amd64" ]; then
14 FILENAME="nexustools-linux-x64"
15 else
16 FILENAME="nexustools"
17 fi
18
19 mkdir -p ./dist
20 dart compile exe "./bin/main.dart" -o "./dist/nexustools"
21 cd ./dist
22 zip "$FILENAME.zip" "nexustools"
23 rm "nexustools"
24 cd ../
0 # This script is just a wrapper to start the Dart executable from the GitHub releases page.
1
2 $Dir = "$Home\NexusTools"
3 $Arch = $ENV:Processor_Architecture
4 $BaseUrl = "https://github.com/corbindavenport/nexus-tools"
5 $Download = "$BaseUrl/releases/latest/download/nexustools-windows-x64.zip"
6
7 # Make the new directory
8 $dirCheck = Test-Path "$Dir"
9 if ($dirCheck) {
10 # Do nothing
11 } else {
12 # Create folder and hide output
13 New-Item "$Dir" -ItemType Directory -ea 0 | Out-Null
14 }
15
16 # Start Dart executable
17 Invoke-WebRequest -Uri "$Download" -OutFile "$Dir\temp.zip"
18 Expand-Archive -LiteralPath "$Dir\temp.zip" -DestinationPath "$Dir" -Force
19 del "$Dir\temp.zip"
20 & "$Dir\nexustools.exe" -i -w
0 # This program is free software: you can redistribute it and/or modify
1 # it under the terms of the GNU General Public License as published by
2 # the Free Software Foundation, either version 3 of the License, or
3 # (at your option) any later version.
4 #
5 # This program is distributed in the hope that it will be useful,
6 # but WITHOUT ANY WARRANTY; without even the implied warranty of
7 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
8 # GNU General Public License for more details.
9 #
10 # You should have received a copy of the GNU General Public License
11 # along with this program. If not, see <http://www.gnu.org/licenses/>.
12
130 #!/bin/bash
141
15 ADB="/usr/bin/adb"
16 FASTBOOT="/usr/bin/fastboot"
17 UDEV="/etc/udev/rules.d/51-android.rules"
2 # This script is just a wrapper to start the Dart executable from the GitHub releases page.
3
4 DIR="$HOME/.nexustools"
185 OS=$(uname)
19 ARCH=$(arch)
6 ARCH=$(uname -m)
7 BASEURL="https://github.com/corbindavenport/nexus-tools"
8 DOWNLOAD=''
9 PARAMS="$@"
2010
21 # get sudo
11 _run_executable() {
12 cd $DIR
13 curl -Lfs --progress-bar -o ./temp.zip $DOWNLOAD|| { echo "[EROR] Download failed."; exit; }
14 unzip -q -o ./temp.zip
15 rm ./temp.zip
16 chmod +x ./nexustools*
17 # Run Nexus Tools and pass parameters to the executable
18 ./nexustools* -i -w "$PARAMS"
19 }
2220
23 echo "[INFO] Nexus Tools 2.3"
24 echo "[INFO] Please enter sudo password for install."
25 sudo echo "[ OK ] Sudo access granted."
26
27 # check if already installed
28
29 if [ -f $ADB ]; then
30 read -p "[WARN] ADB is already present, press ENTER to overwrite or exit to cancel."
31 sudo rm $ADB
21 # Check that required applications are installed
22 if ! [ -x "$(command -v curl)" ]; then
23 echo "[EROR] The 'curl' command is not installed. Please install it and run Nexus Tools again."
24 exit
3225 fi
33 if [ -f $FASTBOOT ]; then
34 read -p "[WARN] Fastboot is already present, press ENTER to overwrite or exit to cancel."
35 sudo rm $FASTBOOT
26 if ! [ -x "$(command -v unzip)" ]; then
27 echo "[EROR] The 'unzip' command is not installed. Please install it and run Nexus Tools again."
28 exit
3629 fi
3730
38 # detect operating system and install
31 # Make the new directory
32 mkdir -p $DIR
3933
40 if [ -x "/usr/bin/crossystem" ]; then # Chrome OS
41 sudo mount -o remount,rw / 2>/dev/null
42 if [ "$?" -ne "0" ]; then
43 if [ -x /usr/local/bin ]; then
44 ADB=/usr/local/bin/adb
45 FASTBOOT=/usr/local/bin/fastboot
46 UDEV=
47 fi
48 /usr/bin/crossystem 'mainfw_type?developer'
49 fi
50 if [ "$?" -ne "0" ]; then
51
52 echo "[INFO] It appears your Chromium/Chrome OS device is not in developer mode."
53 echo "[INFO] Developer mode is needed to install ADB and Fastboot."
54 echo "[INFO] Make sure your device is booted in developer mode."
55 echo "[INFO] To set up developer tools, use this command: sudo dev_install"
56 echo " "
57 exit 1
58 fi
59 case "$(arch)" in
60 i*86|amd64|x86_64)
61 echo "[INFO] Downloading ADB for Chrome OS [Intel CPU]..."
62 sudo curl -s -o $ADB "http://github.com/corbindavenport/nexus-tools/raw/master/bin/linux-i386-adb" -LOk
63 echo "[INFO] Downloading Fastboot for Chrome [Intel CPU]..."
64 sudo curl -s -o $FASTBOOT "http://github.com/corbindavenport/nexus-tools/raw/master/bin/linux-i386-fastboot" -LOk
65 ;;
66 arm|armv*)
67 echo "[WARN] The ADB binaries for ARM are out of date, and do not work on Android 4.2.2+"
68 echo "[INFO] Downloading ADB for Chrome OS [ARM CPU]..."
69 sudo curl -s -o $ADB "http://github.com/corbindavenport/nexus-tools/raw/master/bin/linux-arm-adb" -LOk
70 echo "[INFO] Downloading Fastboot for Chrome OS [ARM CPU]..."
71 sudo curl -s -o $FASTBOOT "http://github.com/corbindavenport/nexus-tools/raw/master/bin/linux-arm-fastboot" -LOk
72 ;;
73 *)
74 echo "[EROR] Your CPU platform could not be detected."
75 echo " "
76 exit 1
77 esac
78 echo "[INFO] Downloading udev list..."
79 if [ -n "$UDEV" ]; then
80 if [ ! -d /etc/udev/ ]; then
81 sudo mkdir /etc/udev/
82 fi
83 if [ ! -d /etc/udev/rules.d/ ]; then
84 sudo mkdir /etc/udev/rules.d/
85 fi
86 sudo curl -s -o $UDEV "http://github.com/corbindavenport/nexus-tools/raw/master/udev.txt" -LOk
87 sudo chmod 644 $UDEV
88 sudo chown root. $UDEV 2>/dev/null
89 sudo service udev restart 2>/dev/null
90 sudo killall adb 2>/dev/null
91 fi
92 echo "[INFO] Making ADB and Fastboot executable..."
93 sudo chmod +x $ADB
94 sudo chmod +x $FASTBOOT
95 echo "[ OK ] Done!"
96 echo "[INFO] Type adb or fastboot to run."
97 echo " "
98 exit 0
99 elif [ "$(uname)" == "Darwin" ]; then # Mac OS X
100 echo "[INFO] Downloading ADB for Mac OS X..."
101 sudo curl -s -o $ADB "http://github.com/corbindavenport/nexus-tools/raw/master/bin/mac-adb" -LOk
102 echo "[INFO] Downloading Fastboot for Mac OS X..."
103 sudo curl -s -o $FASTBOOT "http://github.com/corbindavenport/nexus-tools/raw/master/bin/mac-fastboot" -LOk
104 echo "[INFO] Making ADB and Fastboot executable..."
105 echo "[INFO] Downloading udev list..."
106 if [ -n "$UDEV" ]; then
107 if [ ! -d /etc/udev/ ]; then
108 sudo mkdir /etc/udev/
109 fi
110 if [ ! -d /etc/udev/rules.d/ ]; then
111 sudo mkdir /etc/udev/rules.d/
112 fi
113 sudo curl -s -o $UDEV "http://github.com/corbindavenport/nexus-tools/raw/master/udev.txt" -LOk
114 sudo chmod 644 $UDEV
115 sudo chown root. $UDEV 2>/dev/null
116 sudo service udev restart 2>/dev/null
117 sudo killall adb 2>/dev/null
118 fi
119 echo "[INFO] Making ADB and Fastboot executable..."
120 sudo chmod +x $ADB
121 sudo chmod +x $FASTBOOT
122 echo "[ OK ] Done!"
123 echo "[INFO] Type adb or fastboot to run."
124 echo " "
125 exit 0
126 elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then # Generic Linux
127 if [ "$(arch)" == "i386" ] || [ "$(arch)" == "i486" ] || [ "$(arch)" == "i586" ] || [ "$(arch)" == "amd64" ] || [ "$(arch)" == "x86_64" ] || [ "$(arch)" == "i686" ]; then # Linux on Intel x86/x86_64 CPU
128 echo "[INFO] Downloading ADB for Linux [Intel CPU]..."
129 sudo curl -s -o $ADB "http://github.com/corbindavenport/nexus-tools/raw/master/bin/linux-i386-adb" -LOk
130 echo "[INFO] Downloading Fastboot for Linux [Intel CPU]..."
131 sudo curl -s -o $FASTBOOT "http://github.com/corbindavenport/nexus-tools/raw/master/bin/linux-i386-fastboot" -LOk
132 elif [ "$(arch)" == "arm" ] || [ "$(arch)" == "armv6l" ]; then # Linux on ARM CPU
133 echo "[WARN] The ADB binaries for ARM are out of date, and do not work on Android 4.2.2+"
134 echo "[INFO] Downloading ADB for Linux [ARM CPU]..."
135 sudo curl -s -o $ADB "http://github.com/corbindavenport/nexus-tools/raw/master/bin/linux-arm-adb" -LOk
136 echo "[INFO] Downloading Fastboot for Linux [ARM CPU]..."
137 sudo curl -s -o $FASTBOOT "http://github.com/corbindavenport/nexus-tools/raw/master/bin/linux-arm-fastboot" -LOk
138 else
139 echo "[EROR] Your CPU platform could not be detected."
140 echo " "
141 exit 1
142 fi
143 echo "[INFO] Downloading udev list..."
144 if [ -n "$UDEV" ]; then
145 if [ ! -d /etc/udev/ ]; then
146 sudo mkdir /etc/udev/
147 fi
148 if [ ! -d /etc/udev/rules.d/ ]; then
149 sudo mkdir /etc/udev/rules.d/
150 fi
151 sudo curl -s -o $UDEV "http://github.com/corbindavenport/nexus-tools/raw/master/udev.txt" -LOk
152 sudo chmod 644 $UDEV
153 sudo chown root. $UDEV 2>/dev/null
154 sudo service udev restart 2>/dev/null
155 sudo killall adb 2>/dev/null
156 fi
157 echo "[INFO] Making ADB and Fastboot executable..."
158 sudo chmod +x $ADB
159 sudo chmod +x $FASTBOOT
160 echo "[ OK ] Done!"
161 echo "[INFO] Type adb or fastboot to run."
162 echo " "
163 exit 0
34 # Start Dart executable
35 if [ "$OS" = "Darwin" ]; then # macOS
36 # Install Rosetta x86 emulation layer if needed
37 if [ "$ARCH" = "arm64" ]; then
38 echo "[WARN] Apple Rosetta compatibility layer will be enabled, if it has not been already. Press ENTER to install or X to cancel."
39 read -sn1 input
40 [ "$input" = "" ] && /usr/sbin/softwareupdate --install-rosetta --agree-to-license || exit
41 fi
42 DOWNLOAD="$BASEURL/releases/latest/download/nexustools-macos-x64.zip"
43 _run_executable
44 elif [ "$OS" = "Linux" ] && [ "$ARCH" = "x86_64" ]; then # Generic Linux
45 DOWNLOAD="$BASEURL/releases/latest/download/nexustools-linux-x64.zip"
46 _run_executable
47 elif [ "$OS" = "Linux" ] && [ "$ARCH" = "amd64" ]; then # Generic Linux
48 DOWNLOAD="$BASEURL/releases/latest/download/nexustools-linux-x64.zip"
49 _run_executable
16450 else
165 echo "[EROR] Your operating system or architecture could not be detected."
166 echo "[EROR] Report bugs at: github.com/corbindavenport/nexus-tools/issues"
167 echo "[EROR] Report the following information in the bug report:"
168 echo "[EROR] OS: $OS"
169 echo "[EROR] ARCH: $ARCH"
170 echo " "
171 exit 1
51 echo "[EROR] Your OS or CPU architecture doesn't seem to be supported."
52 echo "[EROR] Detected OS: $OS"
53 echo "[EROR] Detected arch: $ARCH"
54 exit
17255 fi
0 import 'dart:io' as io;
1
2 Map envVars = io.Platform.environment;
3
4 // Function for checking if an executable is already installed
5 void checkIfInstalled(String dir, String command, String commandName) async {
6 var info = '';
7 if (io.Platform.isWindows) {
8 var cmd = await io.Process.run('where', [command]);
9 info = cmd.stdout.toString();
10 } else {
11 var cmd = await io.Process.run('which', [command]);
12 info = cmd.stdout.toString();
13 }
14 if (info.contains(dir)) {
15 // Executable is installed in the Nexus Tools directory
16 return;
17 } else if (info.isEmpty) {
18 // Executable isn't installed at all
19 } else {
20 // Executable is installed but not inside the Nexus Tools directory
21 var location = info.replaceAll('\n', '');
22 print('[EROR] $commandName is already installed at $location. Please uninstall $commandName and try again.');
23 io.exit(1);
24 }
25 }
26
27 // Function get current CPU architecture
28 Future<String> getCPUArchitecture() async {
29 if (io.Platform.isWindows) {
30 var cpu = envVars['PROCESSOR_ARCHITECTURE'];
31 return cpu;
32 } else if (io.Platform.isMacOS) {
33 // Get architecture reported by the system
34 var info = await io.Process.run('uname', ['-m']);
35 var cpu = info.stdout.toString().replaceAll('\n', '');
36 if (cpu == 'x86_64') {
37 // Check if running under Rosetta 2
38 var rosetta = await io.Process.run('sysctl', ['-in', 'sysctl.proc_translated']);
39 var rosettaStr = rosetta.stdout.toString().replaceAll('\n', '');
40 // This command will run '1' if we're running under Rosetta 2
41 if (rosettaStr == '1') {
42 cpu = 'arm64';
43 }
44 }
45 return cpu;
46 } else {
47 var info = await io.Process.run('uname', ['-m']);
48 var cpu = info.stdout.toString().replaceAll('\n', '');
49 return cpu;
50 }
51 }
52
53 // Function for adding a directory to the system/shell $PATH
54 Future addPath(String path) async {
55 if (envVars['PATH'].toString().contains(path)) {
56 // Directory is already in $PATH
57 print('[ OK ] $path is already in PATH.');
58 } else {
59 // Directory needs to be added to $PATH
60 if (io.Platform.isWindows) {
61 var newPath = envVars['PATH'].toString() + ';$path';
62 await io.Process.run('setx', ['path', '$newPath'], runInShell: true);
63 print('[ OK ] Added $path to user %PATH.');
64 } else if (envVars['SHELL'].toString().contains('zsh')) {
65 // Z Shell
66 var file = io.File(envVars['HOME'] + '/.zshrc');
67 await file.writeAsString('\nexport PATH=\$PATH:$path', mode: io.FileMode.append);
68 print('[ OK ] Z Shell detected, added $path to ' + file.path);
69 } else if (envVars['SHELL'].toString().contains('bash')) {
70 // Bash
71 var file = io.File(envVars['HOME'] + '/.bash_profile');
72 await file.writeAsString('\nexport PATH=\$PATH:$path', mode: io.FileMode.append);
73 print('[ OK ] Bash Shell detected, added $path to ' + file.path);
74 } else {
75 print('[WARN] Shell could not be detected, you will need to manually add $path to your PATH.');
76 }
77 }
78 }
0 # Generated by pub
1 # See https://dart.dev/tools/pub/glossary#lockfile
2 packages:
3 archive:
4 dependency: "direct dev"
5 description:
6 name: archive
7 url: "https://pub.dartlang.org"
8 source: hosted
9 version: "3.1.2"
10 async:
11 dependency: transitive
12 description:
13 name: async
14 url: "https://pub.dartlang.org"
15 source: hosted
16 version: "2.8.1"
17 charcode:
18 dependency: transitive
19 description:
20 name: charcode
21 url: "https://pub.dartlang.org"
22 source: hosted
23 version: "1.3.1"
24 collection:
25 dependency: transitive
26 description:
27 name: collection
28 url: "https://pub.dartlang.org"
29 source: hosted
30 version: "1.15.0"
31 console:
32 dependency: "direct dev"
33 description:
34 name: console
35 url: "https://pub.dartlang.org"
36 source: hosted
37 version: "4.1.0"
38 crypto:
39 dependency: transitive
40 description:
41 name: crypto
42 url: "https://pub.dartlang.org"
43 source: hosted
44 version: "3.0.1"
45 http:
46 dependency: "direct dev"
47 description:
48 name: http
49 url: "https://pub.dartlang.org"
50 source: hosted
51 version: "0.13.3"
52 http_parser:
53 dependency: transitive
54 description:
55 name: http_parser
56 url: "https://pub.dartlang.org"
57 source: hosted
58 version: "4.0.0"
59 io:
60 dependency: "direct dev"
61 description:
62 name: io
63 url: "https://pub.dartlang.org"
64 source: hosted
65 version: "1.0.3"
66 meta:
67 dependency: transitive
68 description:
69 name: meta
70 url: "https://pub.dartlang.org"
71 source: hosted
72 version: "1.7.0"
73 path:
74 dependency: transitive
75 description:
76 name: path
77 url: "https://pub.dartlang.org"
78 source: hosted
79 version: "1.8.0"
80 pedantic:
81 dependency: "direct dev"
82 description:
83 name: pedantic
84 url: "https://pub.dartlang.org"
85 source: hosted
86 version: "1.11.1"
87 source_span:
88 dependency: transitive
89 description:
90 name: source_span
91 url: "https://pub.dartlang.org"
92 source: hosted
93 version: "1.8.1"
94 string_scanner:
95 dependency: transitive
96 description:
97 name: string_scanner
98 url: "https://pub.dartlang.org"
99 source: hosted
100 version: "1.1.0"
101 term_glyph:
102 dependency: transitive
103 description:
104 name: term_glyph
105 url: "https://pub.dartlang.org"
106 source: hosted
107 version: "1.2.0"
108 typed_data:
109 dependency: transitive
110 description:
111 name: typed_data
112 url: "https://pub.dartlang.org"
113 source: hosted
114 version: "1.3.0"
115 uuid:
116 dependency: "direct dev"
117 description:
118 name: uuid
119 url: "https://pub.dartlang.org"
120 source: hosted
121 version: "3.0.4"
122 vector_math:
123 dependency: transitive
124 description:
125 name: vector_math
126 url: "https://pub.dartlang.org"
127 source: hosted
128 version: "2.1.0"
129 sdks:
130 dart: ">=2.12.0 <3.0.0"
0 name: nexustools
1 description: Installer for ADB, Fastboot, and other Android tools.
2 version: 5.0.0
3 homepage: https://github.com/corbindavenport/nexus-tools/
4
5 environment:
6 sdk: '>=2.12.0 <3.0.0'
7
8 # dependencies:
9 # path: ^1.8.0
10
11 dev_dependencies:
12 pedantic: ^1.10.0
13 http:
14 io:
15 uuid:
16 archive: ^3.1.2
17 console:
+0
-31
udev.txt less more
0 SUBSYSTEM=="usb", ATTRS{idVendor}=="0bb4", MODE="0666"
1 SUBSYSTEM=="usb", ATTRS{idVendor}=="0e79", MODE="0666"
2 SUBSYSTEM=="usb", ATTRS{idVendor}=="0502", MODE="0666"
3 SUBSYSTEM=="usb", ATTRS{idVendor}=="0b05", MODE="0666"
4 SUBSYSTEM=="usb", ATTRS{idVendor}=="413c", MODE="0666"
5 SUBSYSTEM=="usb", ATTRS{idVendor}=="0489", MODE="0666"
6 SUBSYSTEM=="usb", ATTRS{idVendor}=="091e", MODE="0666"
7 SUBSYSTEM=="usb", ATTRS{idVendor}=="18d1", MODE="0666"
8 SUBSYSTEM=="usb", ATTRS{idVendor}=="0bb4", MODE="0666"
9 SUBSYSTEM=="usb", ATTRS{idVendor}=="12d1", MODE="0666"
10 SUBSYSTEM=="usb", ATTRS{idVendor}=="24e3", MODE="0666"
11 SUBSYSTEM=="usb", ATTRS{idVendor}=="2116", MODE="0666"
12 SUBSYSTEM=="usb", ATTRS{idVendor}=="0482", MODE="0666"
13 SUBSYSTEM=="usb", ATTRS{idVendor}=="17ef", MODE="0666"
14 SUBSYSTEM=="usb", ATTRS{idVendor}=="1004", MODE="0666"
15 SUBSYSTEM=="usb", ATTRS{idVendor}=="22b8", MODE="0666"
16 SUBSYSTEM=="usb", ATTRS{idVendor}=="0409", MODE="0666"
17 SUBSYSTEM=="usb", ATTRS{idVendor}=="2080", MODE="0666"
18 SUBSYSTEM=="usb", ATTRS{idVendor}=="0955", MODE="0666"
19 SUBSYSTEM=="usb", ATTRS{idVendor}=="2257", MODE="0666"
20 SUBSYSTEM=="usb", ATTRS{idVendor}=="10a9", MODE="0666"
21 SUBSYSTEM=="usb", ATTRS{idVendor}=="1d4d", MODE="0666"
22 SUBSYSTEM=="usb", ATTRS{idVendor}=="0471", MODE="0666"
23 SUBSYSTEM=="usb", ATTRS{idVendor}=="04da", MODE="0666"
24 SUBSYSTEM=="usb", ATTRS{idVendor}=="05c6", MODE="0666"
25 SUBSYSTEM=="usb", ATTRS{idVendor}=="1f53", MODE="0666"
26 SUBSYSTEM=="usb", ATTRS{idVendor}=="04e8", MODE="0666"
27 SUBSYSTEM=="usb", ATTRS{idVendor}=="04dd", MODE="0666"
28 SUBSYSTEM=="usb", ATTRS{idVendor}=="0fce", MODE="0666"
29 SUBSYSTEM=="usb", ATTRS{idVendor}=="0930", MODE="0666"
30 SUBSYSTEM=="usb", ATTRS{idVendor}=="19d2", MODE="0666"
0 # This program is free software: you can redistribute it and/or modify
1 # it under the terms of the GNU General Public License as published by
2 # the Free Software Foundation, either version 3 of the License, or
3 # (at your option) any later version.
4 #
5 # This program is distributed in the hope that it will be useful,
6 # but WITHOUT ANY WARRANTY; without even the implied warranty of
7 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
8 # GNU General Public License for more details.
9 #
10 # You should have received a copy of the GNU General Public License
11 # along with this program. If not, see <http://www.gnu.org/licenses/>.
12
130 #!/bin/bash
141
15 ADB="/usr/bin/adb"
16 FASTBOOT="/usr/bin/fastboot"
17 UDEV="/etc/udev/rules.d/51-android.rules"
2 # This script only exists to maintain compatibility with guides and tutorials that mention Nexus Tools. Nexus Tools can be uninstalled by running nexustools -r in the Terminal, or by deleting ~/.nexustools manually.
183
19 # get sudo
4 OS=$(uname)
5 ARCH=$(uname -m)
206
21 echo "[INFO] Nexus Tools 2.3"
22 echo "[INFO] Please enter sudo password for uninstall."
23 sudo echo "[ OK ] Sudo access granted."
24
25 # check for chrome os
26
27 if [ -x "/usr/bin/crossystem" ]; then # Chrome OS
28 sudo mount -o remount,rw / 2>/dev/null
29 if [ "$?" -ne "0" ]; then
30 if [ -x /usr/local/bin ]; then
31 ADB=/usr/local/bin/adb
32 FASTBOOT=/usr/local/bin/fastboot
33 UDEV=
34 fi
35 /usr/bin/crossystem 'mainfw_type?developer'
36 fi
37 if [ "$?" -ne "0" ]; then
38 echo "[INFO] It appears your Chromium/Chrome OS device is not in developer mode."
39 echo "[INFO] Developer mode is needed to install ADB and Fastboot."
40 echo "[INFO] Make sure your device is booted in developer mode."
41 echo "[INFO] To set up developer tools, use this command: sudo dev_install"
42 echo " "
43 exit 1
44 fi
45 fi
46
47 # remove files
48
49 if [ -f $ADB ]; then
50 sudo rm $ADB
51 echo "[ OK ] ADB removed."
7 # Nexus Tools 3.2+ (August 2016-Now) installs binaries in ~/.nexustools
8 if [ -d $HOME/.nexustools ]; then
9 echo "[WARN] Nexus Tools folder found in $HOME/.nexustools. Press ENTER to delete or X to skip."
10 read -sn1 input
11 [ "$input" = "" ] && rm -rf $HOME/.nexustools
5212 else
53 echo "[EROR] ADB not found in /usr/bin, skipping uninstall."
54 fi
55 if [ -f $FASTBOOT ]; then
56 sudo rm $FASTBOOT
57 echo "[ OK ] Fastboot removed."
58 else
59 echo "[EROR] Fastboot not found in /usr/bin, skipping uninstall."
60 fi
61 if [ -f $UDEV ]; then
62 sudo rm $UDEV
63 echo "[ OK ] Udev list removed."
64 else
65 echo "[EROR] Udev list not found in /etc/udev/rules.d/, skipping uninstall."
66 fi
67 echo "[ OK ] Done uninstalling."
68 echo " "
13 echo "[ OK ] No installation found."
14 fi