Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
dfecafa4
Unverified
Commit
dfecafa4
authored
Jun 14, 2019
by
Zachary Anderson
Committed by
GitHub
Jun 14, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[flutter_tool,fuchsia] Update the install flow for packaging migration. (#34447)
parent
81bbd3e1
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
83 additions
and
10 deletions
+83
-10
amber_ctl.dart
packages/flutter_tools/lib/src/fuchsia/amber_ctl.dart
+33
-0
fuchsia_device.dart
packages/flutter_tools/lib/src/fuchsia/fuchsia_device.dart
+13
-9
fuchsia_pm.dart
packages/flutter_tools/lib/src/fuchsia/fuchsia_pm.dart
+5
-1
fuchsia_device_test.dart
packages/flutter_tools/test/fuchsia/fuchsia_device_test.dart
+32
-0
No files found.
packages/flutter_tools/lib/src/fuchsia/amber_ctl.dart
View file @
dfecafa4
...
@@ -27,6 +27,12 @@ import 'fuchsia_pm.dart';
...
@@ -27,6 +27,12 @@ import 'fuchsia_pm.dart';
// -x: do not disable other active sources (if the provided source is
// -x: do not disable other active sources (if the provided source is
// enabled)
// enabled)
//
//
// add_repo_cfg - add a repository config to the set of known repositories,
// using a source config
// -n: name of the update source (optional, with URL)
// -f: file path or url to a source config file
// -h: SHA256 hash of source config file (optional, with URL)
//
// rm_src - remove a source, if it exists
// rm_src - remove a source, if it exists
// -n: name of the update source
// -n: name of the update source
//
//
...
@@ -73,4 +79,31 @@ class FuchsiaAmberCtl {
...
@@ -73,4 +79,31 @@ class FuchsiaAmberCtl {
await
device
.
shell
(
'amber_ctl get_up -n
$packageName
'
);
await
device
.
shell
(
'amber_ctl get_up -n
$packageName
'
);
return
result
.
exitCode
==
0
;
return
result
.
exitCode
==
0
;
}
}
/// Converts the amber source config created when [server] was set up to a
/// pkg_resolver repo config, and teaches the pkg_resolver instance running
/// on [device] about the [FuchsiaPackageServer].
Future
<
bool
>
addRepoCfg
(
FuchsiaDevice
device
,
FuchsiaPackageServer
server
)
async
{
final
String
configUrl
=
'
${server.url}
/config.json'
;
final
RunResult
result
=
await
device
.
shell
(
'amber_ctl add_repo_cfg -n
${server.name}
-f
$configUrl
'
);
return
result
.
exitCode
==
0
;
}
/// Instructs the pkg_resolver instance running on [device] to prefetch the
/// package [packageName].
Future
<
bool
>
pkgCtlResolve
(
FuchsiaDevice
device
,
FuchsiaPackageServer
server
,
String
packageName
)
async
{
final
String
packageUrl
=
'fuchsia-pkg://
${server.name}
/
$packageName
'
;
final
RunResult
result
=
await
device
.
shell
(
'pkgctl resolve
$packageUrl
'
);
return
result
.
exitCode
==
0
;
}
/// Instructs the pkg_resolver instance running on [device] to forget about
/// the Fuchsia package server that it was accessing via [serverUrl].
Future
<
bool
>
pkgCtlRepoRemove
(
FuchsiaDevice
device
,
FuchsiaPackageServer
server
)
async
{
final
String
repoUrl
=
'fuchsia-pkg://
${server.name}
'
;
final
RunResult
result
=
await
device
.
shell
(
'pkgctl repo remove --repo-url
$repoUrl
'
);
return
result
.
exitCode
==
0
;
}
}
}
packages/flutter_tools/lib/src/fuchsia/fuchsia_device.dart
View file @
dfecafa4
...
@@ -265,7 +265,9 @@ class FuchsiaDevice extends Device {
...
@@ -265,7 +265,9 @@ class FuchsiaDevice extends Device {
}
}
// Start up a package server.
// Start up a package server.
fuchsiaPackageServer
=
FuchsiaPackageServer
(
packageRepo
.
path
,
host
,
port
);
const
String
packageServerName
=
'flutter_tool'
;
fuchsiaPackageServer
=
FuchsiaPackageServer
(
packageRepo
.
path
,
packageServerName
,
host
,
port
);
if
(!
await
fuchsiaPackageServer
.
start
())
{
if
(!
await
fuchsiaPackageServer
.
start
())
{
printError
(
'Failed to start the Fuchsia package server'
);
printError
(
'Failed to start the Fuchsia package server'
);
return
LaunchResult
.
failed
();
return
LaunchResult
.
failed
();
...
@@ -277,16 +279,17 @@ class FuchsiaDevice extends Device {
...
@@ -277,16 +279,17 @@ class FuchsiaDevice extends Device {
return
LaunchResult
.
failed
();
return
LaunchResult
.
failed
();
}
}
// Teach
amb
er about the package server.
// Teach
the package controll
er about the package server.
if
(!
await
fuchsiaDeviceTools
.
amberCtl
.
add
Src
(
this
,
fuchsiaPackageServer
))
{
if
(!
await
fuchsiaDeviceTools
.
amberCtl
.
add
RepoCfg
(
this
,
fuchsiaPackageServer
))
{
printError
(
'Failed to teach amber about the package server'
);
printError
(
'Failed to teach amber about the package server'
);
return
LaunchResult
.
failed
();
return
LaunchResult
.
failed
();
}
}
serverRegistered
=
true
;
serverRegistered
=
true
;
// Tell amber to prefetch the app.
// Tell the package controller to prefetch the app.
if
(!
await
fuchsiaDeviceTools
.
amberCtl
.
getUp
(
this
,
appName
))
{
if
(!
await
fuchsiaDeviceTools
.
amberCtl
.
pkgCtlResolve
(
printError
(
'Failed to get amber to prefetch the package'
);
this
,
fuchsiaPackageServer
,
appName
))
{
printError
(
'Failed to get pkgctl to prefetch the package'
);
return
LaunchResult
.
failed
();
return
LaunchResult
.
failed
();
}
}
...
@@ -298,15 +301,16 @@ class FuchsiaDevice extends Device {
...
@@ -298,15 +301,16 @@ class FuchsiaDevice extends Device {
// Instruct tiles_ctl to start the app.
// Instruct tiles_ctl to start the app.
final
String
fuchsiaUrl
=
final
String
fuchsiaUrl
=
'fuchsia-pkg://
fuchsia.com
/
$appName
#meta/
$appName
.cmx'
;
'fuchsia-pkg://
$packageServerName
/
$appName
#meta/
$appName
.cmx'
;
if
(!
await
fuchsiaDeviceTools
.
tilesCtl
.
add
(
this
,
fuchsiaUrl
,
<
String
>[]))
{
if
(!
await
fuchsiaDeviceTools
.
tilesCtl
.
add
(
this
,
fuchsiaUrl
,
<
String
>[]))
{
printError
(
'Failed to add the app to tiles'
);
printError
(
'Failed to add the app to tiles'
);
return
LaunchResult
.
failed
();
return
LaunchResult
.
failed
();
}
}
}
finally
{
}
finally
{
// Try to un-teach amber about the package server if needed.
// Try to un-teach the package controller about the package server if
// needed.
if
(
serverRegistered
)
{
if
(
serverRegistered
)
{
await
fuchsiaDeviceTools
.
amberCtl
.
rmSrc
(
this
,
fuchsiaPackageServer
);
await
fuchsiaDeviceTools
.
amberCtl
.
pkgCtlRepoRemove
(
this
,
fuchsiaPackageServer
);
}
}
// Shutdown the package server and delete the package repo;
// Shutdown the package server and delete the package repo;
fuchsiaPackageServer
?.
stop
();
fuchsiaPackageServer
?.
stop
();
...
...
packages/flutter_tools/lib/src/fuchsia/fuchsia_pm.dart
View file @
dfecafa4
...
@@ -166,6 +166,7 @@ class FuchsiaPM {
...
@@ -166,6 +166,7 @@ class FuchsiaPM {
/// Example usage:
/// Example usage:
/// var server = FuchsiaPackageServer(
/// var server = FuchsiaPackageServer(
/// '/path/to/repo',
/// '/path/to/repo',
/// 'server_name',
/// await FuchsiaDevFinder.resolve(deviceName),
/// await FuchsiaDevFinder.resolve(deviceName),
/// await freshPort());
/// await freshPort());
/// try {
/// try {
...
@@ -176,7 +177,7 @@ class FuchsiaPM {
...
@@ -176,7 +177,7 @@ class FuchsiaPM {
/// server.stop();
/// server.stop();
/// }
/// }
class
FuchsiaPackageServer
{
class
FuchsiaPackageServer
{
FuchsiaPackageServer
(
this
.
_repo
,
this
.
_host
,
this
.
_port
);
FuchsiaPackageServer
(
this
.
_repo
,
this
.
name
,
this
.
_host
,
this
.
_port
);
final
String
_repo
;
final
String
_repo
;
final
String
_host
;
final
String
_host
;
...
@@ -187,6 +188,9 @@ class FuchsiaPackageServer {
...
@@ -187,6 +188,9 @@ class FuchsiaPackageServer {
/// The url that can be used by the device to access this package server.
/// The url that can be used by the device to access this package server.
String
get
url
=>
'http://
$_host
:
$_port
'
;
String
get
url
=>
'http://
$_host
:
$_port
'
;
// The name used to reference the server by fuchsia-pkg:// urls.
final
String
name
;
/// Usees [FuchiaPM.newrepo] and [FuchsiaPM.serve] to spin up a new Fuchsia
/// Usees [FuchiaPM.newrepo] and [FuchsiaPM.serve] to spin up a new Fuchsia
/// package server.
/// package server.
///
///
...
...
packages/flutter_tools/test/fuchsia/fuchsia_device_test.dart
View file @
dfecafa4
...
@@ -695,6 +695,22 @@ class FakeFuchsiaAmberCtl implements FuchsiaAmberCtl {
...
@@ -695,6 +695,22 @@ class FakeFuchsiaAmberCtl implements FuchsiaAmberCtl {
Future
<
bool
>
getUp
(
FuchsiaDevice
device
,
String
packageName
)
async
{
Future
<
bool
>
getUp
(
FuchsiaDevice
device
,
String
packageName
)
async
{
return
true
;
return
true
;
}
}
@override
Future
<
bool
>
addRepoCfg
(
FuchsiaDevice
device
,
FuchsiaPackageServer
server
)
async
{
return
true
;
}
@override
Future
<
bool
>
pkgCtlResolve
(
FuchsiaDevice
device
,
FuchsiaPackageServer
server
,
String
packageName
)
async
{
return
true
;
}
@override
Future
<
bool
>
pkgCtlRepoRemove
(
FuchsiaDevice
device
,
FuchsiaPackageServer
server
)
async
{
return
true
;
}
}
}
class
FailingAmberCtl
implements
FuchsiaAmberCtl
{
class
FailingAmberCtl
implements
FuchsiaAmberCtl
{
...
@@ -712,6 +728,22 @@ class FailingAmberCtl implements FuchsiaAmberCtl {
...
@@ -712,6 +728,22 @@ class FailingAmberCtl implements FuchsiaAmberCtl {
Future
<
bool
>
getUp
(
FuchsiaDevice
device
,
String
packageName
)
async
{
Future
<
bool
>
getUp
(
FuchsiaDevice
device
,
String
packageName
)
async
{
return
false
;
return
false
;
}
}
@override
Future
<
bool
>
addRepoCfg
(
FuchsiaDevice
device
,
FuchsiaPackageServer
server
)
async
{
return
false
;
}
@override
Future
<
bool
>
pkgCtlResolve
(
FuchsiaDevice
device
,
FuchsiaPackageServer
server
,
String
packageName
)
async
{
return
false
;
}
@override
Future
<
bool
>
pkgCtlRepoRemove
(
FuchsiaDevice
device
,
FuchsiaPackageServer
server
)
async
{
return
false
;
}
}
}
class
FakeFuchsiaTilesCtl
implements
FuchsiaTilesCtl
{
class
FakeFuchsiaTilesCtl
implements
FuchsiaTilesCtl
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment