Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(217)

Side by Side Diff: pkg/flash_sd_card/lib/flash_sd_card.dart

Issue 1659163007: Rename fletch -> dartino (Closed) Base URL: https://github.com/dartino/sdk.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2015, the Dartino project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dartino project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE.md file. 3 // BSD-style license that can be found in the LICENSE.md file.
4 4
5 import 'dart:async'; 5 import 'dart:async';
6 import 'dart:io'; 6 import 'dart:io';
7 7
8 import 'src/context.dart'; 8 import 'src/context.dart';
9 import 'src/platform_service.dart'; 9 import 'src/platform_service.dart';
10 10
11 const String gcsRoot = 'https://storage.googleapis.com'; 11 const String gcsRoot = 'https://storage.googleapis.com';
12 const String gcsBucket = 'fletch-archive'; 12 const String gcsBucket = 'dartino-archive';
13 13
14 const String imageRootFileName = 'fletch_raspbian'; 14 const String imageRootFileName = 'dartino_raspbian';
15 const String defaultImageFileName = '$imageRootFileName.img'; 15 const String defaultImageFileName = '$imageRootFileName.img';
16 const String defaultImageZipFileName = '$defaultImageFileName.zip'; 16 const String defaultImageZipFileName = '$defaultImageFileName.zip';
17 17
18 // Original /etc/hosts from Raspberry Pi. 18 // Original /etc/hosts from Raspberry Pi.
19 const String originalRaspberryPiHosts = ''' 19 const String originalRaspberryPiHosts = '''
20 127.0.0.1 localhost 20 127.0.0.1 localhost
21 ::1 localhost ip6-localhost ip6-loopback 21 ::1 localhost ip6-localhost ip6-loopback
22 ff02::1 ip6-allnodes 22 ff02::1 ip6-allnodes
23 ff02::2 ip6-allrouters 23 ff02::2 ip6-allrouters
24 24
25 127.0.1.1 raspberrypi 25 127.0.1.1 raspberrypi
26 '''; 26 ''';
27 27
28 /// Check if a version is a bleeding edge version. 28 /// Check if a version is a bleeding edge version.
29 bool isEdgeVersion(String version) => version.contains('-edge.'); 29 bool isEdgeVersion(String version) => version.contains('-edge.');
30 30
31 /// Check if a version is a dev version. 31 /// Check if a version is a dev version.
32 bool isDevVersion(String version) => version.contains('-dev.'); 32 bool isDevVersion(String version) => version.contains('-dev.');
33 33
34 /// Flash an SD card with a Raspbian image. 34 /// Flash an SD card with a Raspbian image.
35 Future<bool> flashCDCard(List<String> args) async { 35 Future<bool> flashCDCard(List<String> args) async {
36 var ctx = new Context(args); 36 var ctx = new Context(args);
37 37
38 ctx.log('Starting, OS: ${Platform.operatingSystem}'); 38 ctx.log('Starting, OS: ${Platform.operatingSystem}');
39 ctx.log('Args: $args'); 39 ctx.log('Args: $args');
40 if (ctx.configureNetworkOnly) { 40 if (ctx.configureNetworkOnly) {
41 ctx.infoln('This program will update the network configuration on a ' 41 ctx.infoln('This program will update the network configuration on a '
42 'Fletch Raspberry Pi 2 SD card.'); 42 'Dartino Raspberry Pi 2 SD card.');
43 } else { 43 } else {
44 ctx.infoln('This program will prepare an SD card for ' 44 ctx.infoln('This program will prepare an SD card for '
45 'Fletch on the Raspberry Pi 2.'); 45 'Dartino on the Raspberry Pi 2.');
46 } 46 }
47 47
48 // Determine platform. 48 // Determine platform.
49 PlatformService platformService = new PlatformService(ctx); 49 PlatformService platformService = new PlatformService(ctx);
50 await platformService.initialize(); 50 await platformService.initialize();
51 51
52 // Determine the download URL for the image. 52 // Determine the download URL for the image.
53 String imageUrl = ctx.imageUrl; 53 String imageUrl = ctx.imageUrl;
54 if (ctx.imageUrl == null) { 54 if (ctx.imageUrl == null) {
55 String version = await ctx.version; 55 String version = await ctx.version;
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 } else { 110 } else {
111 await ctx.readLine( 111 await ctx.readLine(
112 '\nUsing the SD card $sdCardDevice.\n$info\n' 112 '\nUsing the SD card $sdCardDevice.\n$info\n'
113 'This will delete all contents on the card. ' 113 'This will delete all contents on the card. '
114 'Press Enter to use this card (Ctrl-C to cancel).'); 114 'Press Enter to use this card (Ctrl-C to cancel).');
115 } 115 }
116 } 116 }
117 117
118 // Ask for a hostname. 118 // Ask for a hostname.
119 String hostname = await ctx.readHostname( 119 String hostname = await ctx.readHostname(
120 "Enter the name of the device - default is 'fletch' " 120 "Enter the name of the device - default is 'dartino' "
121 "(press Enter to accept): ", 'fletch'); 121 "(press Enter to accept): ", 'dartino');
122 122
123 // Ask for a static IP address. 123 // Ask for a static IP address.
124 String ipAddress = await ctx.readIPAddress( 124 String ipAddress = await ctx.readIPAddress(
125 'Enter the static IP address you would like the device to have. ' 125 'Enter the static IP address you would like the device to have. '
126 'Leave it blank to have it assigned via DHCP: ', ''); 126 'Leave it blank to have it assigned via DHCP: ', '');
127 127
128 Directory mountDir; 128 Directory mountDir;
129 if (ctx.configureNetworkOnly) { 129 if (ctx.configureNetworkOnly) {
130 // Make sure the SD card is mounted. 130 // Make sure the SD card is mounted.
131 mountDir = await platformService.mountDisk(sdCardDevice); 131 mountDir = await platformService.mountDisk(sdCardDevice);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 172
173 // Sanity check for Raspbian boot partition. 173 // Sanity check for Raspbian boot partition.
174 if (!(await checkRaspbianBootPartition(ctx, sdCardDevice, mountDir))) { 174 if (!(await checkRaspbianBootPartition(ctx, sdCardDevice, mountDir))) {
175 ctx.infoln( 175 ctx.infoln(
176 'The SD card in $sdCardDevice does not look like Raspbian SD card.'); 176 'The SD card in $sdCardDevice does not look like Raspbian SD card.');
177 await platformService.unmountDisk(sdCardDevice); 177 await platformService.unmountDisk(sdCardDevice);
178 ctx.done(); 178 ctx.done();
179 return false; 179 return false;
180 } 180 }
181 181
182 // All configuration files goes into fletch-configuration on the boot 182 // All configuration files goes into dartino-configuration on the boot
183 // partition. 183 // partition.
184 Directory configDir = 184 Directory configDir =
185 new Directory(mountDir.path + '/fletch-configuration'); 185 new Directory(mountDir.path + '/dartino-configuration');
186 await configDir.create(); 186 await configDir.create();
187 187
188 // Update the hostname if specified. 188 // Update the hostname if specified.
189 if (hostname.length > 0) { 189 if (hostname.length > 0) {
190 await new File(configDir.path + '/hostname').writeAsString(hostname + '\n'); 190 await new File(configDir.path + '/hostname').writeAsString(hostname + '\n');
191 String hosts = originalRaspberryPiHosts.replaceAll('raspberrypi', hostname); 191 String hosts = originalRaspberryPiHosts.replaceAll('raspberrypi', hostname);
192 await new File(configDir.path + '/hosts').writeAsString(hosts); 192 await new File(configDir.path + '/hosts').writeAsString(hosts);
193 } 193 }
194 194
195 // Update the static IP address if specified. 195 // Update the static IP address if specified.
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 return false; 255 return false;
256 } 256 }
257 if (!bootFiles.contains('${mountDir.path}/kernel.img')) { 257 if (!bootFiles.contains('${mountDir.path}/kernel.img')) {
258 await ctx.readLine( 258 await ctx.readLine(
259 'WARNING: The SD card in ${sdCardDevice} does not look like a ' 259 'WARNING: The SD card in ${sdCardDevice} does not look like a '
260 'Raspbian SD card.\n\n' 260 'Raspbian SD card.\n\n'
261 'Press Enter to continue anyway (Ctrl-C to cancel).'); 261 'Press Enter to continue anyway (Ctrl-C to cancel).');
262 } 262 }
263 return true; 263 return true;
264 } 264 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698