"Fossies" - the Fresh Open Source Software Archive

Member "flutter-1.22.4/packages/flutter_tools/lib/src/fuchsia/amber_ctl.dart" (13 Nov 2020, 4749 Bytes) of package /linux/misc/flutter-1.22.4.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Dart source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 // Copyright 2014 The Flutter Authors. All rights reserved.
    2 // Use of this source code is governed by a BSD-style license that can be
    3 // found in the LICENSE file.
    4 
    5 import '../base/process.dart';
    6 
    7 import 'fuchsia_device.dart';
    8 import 'fuchsia_pm.dart';
    9 
   10 // usage: amber_ctl <command> [opts]
   11 // Commands
   12 //     get_up        - get an update for a package
   13 //       Options
   14 //         -n:      name of the package
   15 //         -v:      version of the package to retrieve, if none is supplied any
   16 //                  package instance could match
   17 //         -m:      merkle root of the package to retrieve, if none is supplied
   18 //                  any package instance could match
   19 //
   20 //     get_blob      - get the specified content blob
   21 //         -i: content ID of the blob
   22 //
   23 //     add_src       - add a source to the list we can use
   24 //         -n: name of the update source (optional, with URL)
   25 //         -f: file path or url to a source config file
   26 //         -h: SHA256 hash of source config file (optional, with URL)
   27 //         -x: do not disable other active sources (if the provided source is
   28 //             enabled)
   29 //
   30 //     add_repo_cfg  - add a repository config to the set of known repositories,
   31 //                     using a source config
   32 //         -n: name of the update source (optional, with URL)
   33 //         -f: file path or url to a source config file
   34 //         -h: SHA256 hash of source config file (optional, with URL)
   35 //
   36 //     rm_src        - remove a source, if it exists
   37 //         -n: name of the update source
   38 //
   39 //     list_srcs     - list the set of sources we can use
   40 //
   41 //     enable_src
   42 //         -n: name of the update source
   43 //         -x: do not disable other active sources
   44 //
   45 //     disable_src
   46 //         -n: name of the update source
   47 //
   48 //     system_update - check for, download, and apply any available system
   49 //                     update
   50 //
   51 //     gc - trigger a garbage collection
   52 //
   53 //     print_state - print go routine state of amber process
   54 
   55 /// Simple wrapper for interacting with the 'amber_ctl' tool running on the
   56 /// Fuchsia device.
   57 class FuchsiaAmberCtl {
   58   /// Teaches the amber instance running on [device] about the Fuchsia package
   59   /// server accessible via [configUrl].
   60   Future<bool> addSrc(FuchsiaDevice device, FuchsiaPackageServer server) async {
   61     final String localIp = await device.hostAddress;
   62     final String configUrl = 'http://[$localIp]:${server.port}/config.json';
   63     final RunResult result = await device.shell(
   64       'amber_ctl add_src -x -f $configUrl',
   65     );
   66     return result.exitCode == 0;
   67   }
   68 
   69   /// Instructs the amber instance running on [device] to forget about the
   70   /// Fuchsia package server that it was accessing via [serverUrl].
   71   Future<bool> rmSrc(FuchsiaDevice device, FuchsiaPackageServer server) async {
   72     final String localIp = await device.hostAddress;
   73     final RunResult result = await device.shell(
   74       'amber_ctl rm_src -n http://[$localIp]:${server.port}/',
   75     );
   76     return result.exitCode == 0;
   77   }
   78 
   79   /// Instructs the amber instance running on [device] to prefetch the package
   80   /// [packageName].
   81   Future<bool> getUp(FuchsiaDevice device, String packageName) async {
   82     final RunResult result = await device.shell(
   83       'amber_ctl get_up -n $packageName',
   84     );
   85     return result.exitCode == 0;
   86   }
   87 
   88   /// Converts the amber source config created when [server] was set up to a
   89   /// pkg_resolver repo config, and teaches the pkg_resolver instance running
   90   /// on [device] about the [FuchsiaPackageServer].
   91   Future<bool> addRepoCfg(FuchsiaDevice device, FuchsiaPackageServer server) async {
   92     final String localIp = await device.hostAddress;
   93     final String configUrl = 'http://[$localIp]:${server.port}/config.json';
   94     final RunResult result = await device.shell(
   95       'amber_ctl add_repo_cfg -n ${server.name} -f $configUrl',
   96     );
   97     return result.exitCode == 0;
   98   }
   99 
  100   /// Instructs the pkg_resolver instance running on [device] to prefetch the
  101   /// package [packageName].
  102   Future<bool> pkgCtlResolve(
  103     FuchsiaDevice device,
  104     FuchsiaPackageServer server,
  105     String packageName,
  106   ) async {
  107     final String packageUrl = 'fuchsia-pkg://${server.name}/$packageName';
  108     final RunResult result = await device.shell('pkgctl resolve $packageUrl');
  109     return result.exitCode == 0;
  110   }
  111 
  112   /// Instructs the pkg_resolver instance running on [device] to forget about
  113   /// the Fuchsia package server that it was accessing via [serverUrl].
  114   Future<bool> pkgCtlRepoRemove(
  115     FuchsiaDevice device,
  116     FuchsiaPackageServer server,
  117   ) async {
  118     final String repoUrl = 'fuchsia-pkg://${server.name}';
  119     final RunResult result = await device.shell('pkgctl repo rm $repoUrl');
  120     return result.exitCode == 0;
  121   }
  122 }