Codebase list google-nexus-tools / 2613c37
Import upstream version 5.4+git20220915.1.8859200 Kali Janitor 1 year, 3 months ago
18 changed file(s) with 714 addition(s) and 280 deletion(s). Raw diff Collapse all Expand all
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 **[Donate with Cash App](https://cash.app/$corbdav)**
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 _Featured on [MakeUseOf](https://www.makeuseof.com/how-to-unlock-android-device-bootloader), [XDA](https://www.xda-developers.com/set-up-adb-and-fastboot-on-linux-mac-os-x-and-chrome-os-with-a-single-command/), [Android Police](https://www.androidpolice.com/install-and-use-adb-on-windows-mac-linux-android-chromebooks-browser/), [9to5Google](https://9to5google.com/2021/12/02/how-to-downgrade-from-android-12-to-android-11-on-google-pixel/#:~:text=Nexus%20Tools), [Wccftech](https://wccftech.com/set-android-adb-fastboot-mac-os/), [Redmond Pie](https://www.redmondpie.com/how-to-install-android-5.0-lollipop-on-nexus-5-using-mac-the-easy-way/), and others!_
9
10 ### How to use on Linux, macOS, and Chrome OS
11
12 Paste this command into the Terminal app:
13
414 ```
5 bash <(curl https://raw.githubusercontent.com/corbindavenport/nexus-tools/master/install.sh)
15 bash <(curl -s https://raw.githubusercontent.com/corbindavenport/nexus-tools/master/install.sh)
616 ```
7 and this command to un-install Nexus Tools:
17
18 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.
19
20 ### How to use on Windows
21
22 Open Windows PowerShell from the Start Menu and paste this command:
23
824 ```
9 bash <(curl https://raw.githubusercontent.com/corbindavenport/nexus-tools/master/uninstall.sh)
25 iex ((New-Object System.Net.WebClient).DownloadString('https://raw.githubusercontent.com/corbindavenport/nexus-tools/master/install.ps1'))
1026 ```
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).
1227
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.
28 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.
1429
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.
30 ### Compatibility
1631
17 ---------------------------------------
32 The Nexus Tools installer is compiled as an x86_64 (64-bit x86) application for macOS, x86_64 Linux, and Windows. It can run in the [Rosetta 2 compatibility layer](https://support.apple.com/en-us/HT211861) on Macs with Apple Silicon chips, like M1 and M2. It also works on ARM Windows 10 and 11 through the [WOW64 translation layer](https://docs.microsoft.com/en-us/windows/arm/apps-on-arm-x86-emulation).
1833
19 __XDA Thread:__ [http://forum.xda-developers.com/showthread.php?t=2564453](http://forum.xda-developers.com/showthread.php?t=2564453)
34 ADB, Fastboot, and other applications in the Platform Tools package are compiled for x86_64 on Windows and Linux. The Mac versions are Universal Binaries, so they run natively on both Intel and Apple Silicon Mac computers.
2035
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/)
36 ### Analytics
2237
23 ---------------------------------------
38 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:
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 ```
41 bash <(curl -s https://raw.githubusercontent.com/corbindavenport/nexus-tools/master/install.sh) --no-analytics
42 ```
2943
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.
44 It also works when running Nexus Tools locally:
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 ```
47 nexustools --no-analytics
48 ```
49
50 This analytics data is viewable publicly at [plausible.io/nexustools.corbin.io](https://plausible.io/nexustools.corbin.io).
51
52 ### Development info
53
54 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:
55
56 ```
57 dart ./bin/main.dart
58 ```
59
60 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.
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:uuid/uuid.dart';
4 import 'dart:convert';
5 import 'package:nexustools/sys.dart' as sys;
6
7 String macZip =
8 'https://dl.google.com/android/repository/platform-tools-latest-darwin.zip';
9 String linuxZip =
10 'https://dl.google.com/android/repository/platform-tools-latest-linux.zip';
11 String windowsZip =
12 'https://dl.google.com/android/repository/platform-tools-latest-windows.zip';
13 List supportedCPUs = ['amd64', 'x86_64', 'AMD64'];
14 Map envVars = io.Platform.environment;
15 double appVersion = 5.4;
16
17 // Function for checking for update
18 Future checkUpdate() async {
19 var net = Uri.parse(
20 'https://api.github.com/repos/corbindavenport/nexus-tools/releases/latest');
21 try {
22 var data = await http.read(net);
23 var parsedData = json.decode(data);
24 // Compare versions
25 if (double.parse(parsedData['tag_name']) > appVersion) {
26 print(
27 '[INFO] Nexus Tools update available! Download: https://git.io/JBuTh');
28 } else {
29 print('[INFO] You have the latest version of Nexus Tools.');
30 }
31 } catch (e) {
32 print('[EROR] Could not check for updates.');
33 }
34 }
35
36 // Function for obtaining Nexus Tools path
37 // Credit: https://stackoverflow.com/a/25498458
38 String nexusToolsDir() {
39 var home = '';
40 if (io.Platform.isMacOS) {
41 home = envVars['HOME'];
42 } else if (io.Platform.isLinux) {
43 home = envVars['HOME'];
44 } else if (io.Platform.isWindows) {
45 home = envVars['UserProfile'];
46 }
47 if (home.endsWith('/')) {
48 home = home.substring(0, home.length - 1);
49 }
50 if (io.Platform.isWindows) {
51 return '$home\\NexusTools';
52 } else {
53 return '$home/.nexustools';
54 }
55 }
56
57 // Function for installing Platform Tools package
58 Future installPlatformTools() async {
59 var dir = nexusToolsDir();
60 // Get the proper ZIP file
61 var zip = '';
62 if (io.Platform.isMacOS) {
63 zip = macZip;
64 } else if (io.Platform.isLinux) {
65 zip = linuxZip;
66 } else if (io.Platform.isWindows) {
67 zip = windowsZip;
68 }
69 // Download file
70 print('[....] Downloading Platform Tools package, please wait.');
71 var net = Uri.parse(zip);
72 try {
73 var data = await http.readBytes(net);
74 var archive = ZipDecoder().decodeBytes(data);
75 extractArchiveToDisk(archive, dir);
76 } catch (e) {
77 var error = e.toString();
78 print('[EROR] There was an error downloading Platform Tools: $error');
79 io.exit(1);
80 }
81 // Move files out of platform-tools subdirectory and delete the subdirectory
82 if (io.Platform.isWindows) {
83 await io.Process.run('move', ['$dir\\platform-tools\\*', '$dir'],
84 runInShell: true);
85 await io.Process.run('rmdir', ['/Q', '/S', '$dir\\platform-tools'],
86 runInShell: true);
87 } else {
88 await io.Process.run(
89 '/bin/sh', ['-c', 'mv -f -v $dir/platform-tools/* $dir/']);
90 await io.Process.run('/bin/sh', ['-c', 'rm -rf $dir/platform-tools']);
91 }
92 // Mark binaries in directory as executable
93 if (io.Platform.isLinux || io.Platform.isMacOS) {
94 await io.Process.run('/bin/sh', ['-c', 'chmod -f +x $dir/*']);
95 }
96 // Give a progress report
97 print('[ OK ] Platform Tools now installed in $dir.');
98 // Add binaries to path
99 await sys.addPath(dir);
100 // Create help link
101 if (io.Platform.isWindows) {
102 var file = io.File('$dir\\About Nexus Tools.url');
103 await file.writeAsString(
104 '[InternetShortcut]\nURL=https://github.com/corbindavenport/nexus-tools/blob/master/README.md',
105 mode: io.FileMode.writeOnly);
106 } else if (io.Platform.isMacOS) {
107 var file = io.File('$dir/About Nexus Tools.url');
108 await file.writeAsString(
109 '[InternetShortcut]\nURL=https://github.com/corbindavenport/nexus-tools/blob/master/README.md',
110 mode: io.FileMode.writeOnly);
111 } else if (io.Platform.isLinux) {
112 var file = io.File('$dir/About Nexus Tools.desktop');
113 await file.writeAsString(
114 '[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',
115 mode: io.FileMode.writeOnly);
116 }
117 // Install drivers on Windows
118 if (io.Platform.isWindows) {
119 // Check if Universal Adb Driver package is already installed
120 var info = await io.Process.run('wmic', ['product', 'get', 'Name']);
121 var parsedInfo = info.stdout.toString();
122 if (parsedInfo.contains('Universal Adb Driver')) {
123 print('[ OK ] Universal ADB Drivers already installed.');
124 } else {
125 // Prompt to install drivers
126 print(
127 '[WARN] Drivers may be required for ADB if they are not already installed.');
128 io.stdout
129 .write('[WARN] Install drivers from adb.clockworkmod.com? [Y/N] ');
130 var input = io.stdin.readLineSync();
131 if (input?.toLowerCase() == 'y') {
132 await installWindowsDrivers(dir);
133 }
134 }
135 }
136 }
137
138 // Function for removing Platform Tools package
139 Future removePlatformTools() async {
140 // Nexus Tools 3.2+ (August 2016-Present) installs binaries in ~/.nexustools
141 var dir = nexusToolsDir();
142 var installExists = false;
143 installExists = await io.Directory(dir).exists();
144 if (installExists) {
145 print(
146 '[WARN] Deleting $dir will delete Android System Tools (ADB, Fastboot, etc.).');
147 print('[WARN] This will also delete the Nexus Tools application.');
148 io.stdout.write('[WARN] Continue with removal? [Y/N] ');
149 var input = io.stdin.readLineSync();
150 if (input?.toLowerCase() != 'y') {
151 return;
152 }
153 // Proceed with deletion
154 await io.Directory(dir).delete(recursive: true);
155 print('[ OK ] Deleted directory at $dir.');
156 print('[INFO] Nexus Tools can be re-installed at https://git.io/JBuTh.');
157 } else {
158 print('[EROR] No installation found at $dir.');
159 }
160 }
161
162 // Function for installing Windows Universal ADB drivers
163 // Drivers provided by ClockWorkMod: https://adb.clockworkmod.com/
164 Future installWindowsDrivers(String dir) async {
165 print('[....] Downloading drivers, please wait.');
166 var net = Uri.parse(
167 'https://github.com/koush/adb.clockworkmod.com/releases/latest/download/UniversalAdbDriverSetup.msi');
168 try {
169 var data = await http.readBytes(net);
170 var file = io.File('$dir\\ADB Drivers.msi');
171 await file.writeAsBytes(data, mode: io.FileMode.writeOnly);
172 print('[....] Opening driver installer.');
173 await io.Process.run(
174 'start', ['/wait', 'msiexec.exe', '/i', '$dir\\ADB Drivers.msi'],
175 runInShell: true);
176 } catch (e) {
177 print(
178 '[EROR] There was an error downloading drivers, try downloading them from adb.clockworkmod.com.');
179 }
180 }
181
182 // Function for Plausible Analytics reporting
183 void connectAnalytics() async {
184 var uuid = Uuid();
185 var id = uuid.v4();
186 // Get exact operating system
187 var realOS = '';
188 var isWSL = await io.Directory('/mnt/c/Windows').exists();
189 var isChromeOS = await io.Directory('/usr/share/themes/CrosAdapta').exists();
190 if (isWSL) {
191 realOS = 'wsl';
192 } else if (isChromeOS) {
193 realOS = 'chromeos';
194 } else {
195 realOS = io.Platform.operatingSystem;
196 }
197 var cpu = await sys.getCPUArchitecture();
198 // Set data
199 var net = Uri.parse('https://plausible.io/api/event');
200 var netHeaders = {
201 'user-agent': 'Nexus Tools',
202 'X-Forwarded-For': '127.0.0.1',
203 'Content-Type': 'application/json',
204 'User-Agent':
205 'Mozilla/5.0 ($realOS) AppleWebKit/500 (KHTML, like Gecko) Chrome/$appVersion $id'
206 };
207 var netBody =
208 '{"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('[ OK ] Your hardware platform is supported, yay!');
249 } else {
250 print(
251 '[EROR] Your hardware platform is detected as $cpu. Google only provides Platform Tools for x86-based platforms.');
252 io.exit(1);
253 }
254 // Display environment-specific warnings
255 var isWSL = await io.Directory('/mnt/c/Windows').exists();
256 var isChromeOS = await io.Directory('/usr/share/themes/CrosAdapta').exists();
257 if (isWSL) {
258 print(
259 '[WARN] WSL does not support USB devices, you will only be able to use ADB over Wi-Fi.');
260 } else if (isChromeOS) {
261 print('[WARN] Chrome OS 75 or higher is required for USB support.');
262 }
263 }
264
265 void printHelp() {
266 var helpDoc = '''
267 Nexus Tools $appVersion
268 Downloader/management app for Android SDK Platform Tools
269
270 Usage: nexustools [OPTIONS]
271
272 Example: nexustools -i (this installs Platform Tools)
273
274 -i, --install Install/update Android Platform Tools
275 -r, --remove Remove Platform Tools
276 -n, --no-analytics Run Nexus Tools without Plausible Analytics
277 (analytics is only run on install)
278 -c, --check Check for Nexus Tools update
279 -h, --help Display this help message
280 ''';
281 print(helpDoc);
282 }
283
284 void main(List<String> arguments) async {
285 if (arguments.contains('-i') || arguments.contains('--install')) {
286 print('[INFO] Nexus Tools $appVersion');
287 // Check version unless Nexus Tools is running from web (curl) installer
288 // The web installer adds the -w parameter
289 if (!arguments.contains('-w')) {
290 await checkUpdate();
291 }
292 // Start analytics unless opted out
293 if (arguments.contains('--no-analytics')) {
294 print('[ OK ] Plausible Analytics are disabled.');
295 } else {
296 connectAnalytics();
297 }
298 // Start installation
299 await checkInstall();
300 await installPlatformTools();
301 // Post-install
302 var appName = '';
303 if (io.Platform.isWindows) {
304 appName = 'Command Line window (not a new tab!)';
305 } else {
306 appName = 'Terminal window';
307 }
308 print(
309 '[INFO] Installation complete! Open a new $appName to apply changes.');
310 print('[INFO] Run "nexustools --help" at any time for more options.');
311 print(
312 '[INFO] Join the Discord server: https://discord.com/invite/59wfy5cNHw');
313 print('[INFO] Donate to support development: https://git.io/J4jct');
314 } else if (arguments.contains('-r') || arguments.contains('--remove')) {
315 print('[INFO] Nexus Tools $appVersion');
316 // Start removal
317 await removePlatformTools();
318 } else if (arguments.contains('-h') || arguments.contains('--help')) {
319 printHelp();
320 } else if (arguments.contains('-c') || arguments.contains('--check')) {
321 await checkUpdate();
322 } else {
323 print('[EROR] Invalid arguments. Run nexustools -h for help!');
324 }
325 }
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.2.2"
10 async:
11 dependency: transitive
12 description:
13 name: async
14 url: "https://pub.dartlang.org"
15 source: hosted
16 version: "2.8.2"
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.4"
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.1"
80 source_span:
81 dependency: transitive
82 description:
83 name: source_span
84 url: "https://pub.dartlang.org"
85 source: hosted
86 version: "1.8.2"
87 string_scanner:
88 dependency: transitive
89 description:
90 name: string_scanner
91 url: "https://pub.dartlang.org"
92 source: hosted
93 version: "1.1.0"
94 term_glyph:
95 dependency: transitive
96 description:
97 name: term_glyph
98 url: "https://pub.dartlang.org"
99 source: hosted
100 version: "1.2.0"
101 typed_data:
102 dependency: transitive
103 description:
104 name: typed_data
105 url: "https://pub.dartlang.org"
106 source: hosted
107 version: "1.3.0"
108 uuid:
109 dependency: "direct dev"
110 description:
111 name: uuid
112 url: "https://pub.dartlang.org"
113 source: hosted
114 version: "3.0.5"
115 vector_math:
116 dependency: transitive
117 description:
118 name: vector_math
119 url: "https://pub.dartlang.org"
120 source: hosted
121 version: "2.1.2"
122 sdks:
123 dart: ">=2.14.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 http:
13 io:
14 uuid:
15 archive: ^3.2.2
16 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