Re: fx serve

41 views
Skip to first unread message

Amit Uttamchandani

unread,
Jan 5, 2021, 11:54:21 AM1/5/21
to Geevarghese V K, pkg...@fuchsia.dev, discuss
+pkg...@fuchsia.dev give you a more detailed response on listing packages.

On Mon, Jan 4, 2021 at 8:18 AM Amit Uttamchandani <amit...@google.com> wrote:

The other sections on that page go through the lifecycle of building and serving a product as well as triggering a system update.

On Mon, Jan 4, 2021 at 6:04 AM Geevarghese V K <jince...@gmail.com> wrote:
Dear team,

What is the purpose of fx serve? When we need to run this command? How to know which all packages are available to push after running this command?

--
All posts must follow the Fuchsia Code of Conduct https://fuchsia.dev/fuchsia-src/CODE_OF_CONDUCT or may be removed.
---
You received this message because you are subscribed to the Google Groups "discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to discuss+u...@fuchsia.dev.
To view this discussion on the web visit https://groups.google.com/a/fuchsia.dev/d/msgid/discuss/6fa2191d-a697-49d8-82e3-e4675259ab07n%40fuchsia.dev.

John Wittrock

unread,
Jan 5, 2021, 4:50:04 PM1/5/21
to Amit Uttamchandani, Geevarghese V K, pkg...@fuchsia.dev, discuss
Hello!

To understand why we need `fx serve` it's useful to understand how packaging works on Fuchsia.There are three types of packages which a Fuchsia device can use, and they behave slightly differently with respect to how they're made available on the device. 

Critically, most packages are not built into the base image that you build and pave onto a device, they're made available in "universe" for later download when the device is running. At runtime the device can choose to "resolve" a universe package, which downloads the most recent version of the package from the update server and check that it's authentic. See this doc for more information on what happens when you build a Fuchsia checkout with respect to packages. 

What `fx serve` does in this case is run the package server on your 'host' device, which is the device you built Fuchsia on. The 'target' is the device you'll be running Fuchsia on. When `fx serve` is ready to serve packages you'll see a 'Ready to push packages' log in your `fx serve` output. 

You shouldn't have to actually push packages very often. If you're building with v1 components, you should be able to use the `run` command to automatically resolve and run components in packages your package server has available, which will pull the new versions down from the package server. Here's an end-to-end example of building and running a new component, including `fx serve`.

If you want to list the packages which were built when you built Fuchsia and are available to the package resolver, you can use `fx list-packages`.

Hope that helps.

john

To unsubscribe from this group and stop receiving emails from it, send an email to pkg-dev+u...@fuchsia.dev.

Geevarghese V K

unread,
Jan 5, 2021, 11:49:03 PM1/5/21
to discuss, John Wittrock, Geevarghese V K, pkg...@fuchsia.dev, discuss, Amit Uttamchandani
In a real hardware how does this mechanism work?

Suppose using NUC, target will be your NUC device.
But what about host? Do we need fx serve for real hardwares?

John Wittrock

unread,
Jan 6, 2021, 9:28:20 AM1/6/21
to pkg-dev, Geevarghese V K, John Wittrock, pkg...@fuchsia.dev, discuss, Amit Uttamchandani
Indeed, this works with real hardware. You can run a NUC with a set of base packages, but if you decide you need `rolldice.cmx` for some reason and you want to run it, you can run `fx serve` and then `fx shell run fuchsia-pkg://rolldice#meta/rolldice.cmx` and you should see its output printed on your shell. Assuming rolldice was part of universe and not paved with the base image, that command running means:

- your NUC reached out to the package server configured on the host and asked if it knew anything about a package called 'rolldice', and if so what its most recent version was
- the package server responded with a new version and its merkle root 
- your NUC downloaded and cached all the blobs that make up the package, verified that all of the blobs matched their hashes in the package manifest, and pkg-resolver returned a directory handle to the package
- your NUC ran `rolldice.cmx` from the cached package

A key aspect of fuchsia (as you can see from the front page of fuchsia.dev is this concept of easy updatability for packages which don't have to be updated as a monolith, and may not all exist on the device at the time the device is paved. 

A package server as run by `fx serve` is just a vanilla HTTP server serving a directory tree of TUF metadata and package blobs. In the case of `fx serve` the server is `pm serve` and the directory tree it's serving is at `${FUCHSIA_BUILD_DIR}/amber_files`. 

Many utilities you'd expect to use on a shell in a core build are actually downloaded on-demand, like `ls` and `cat`. To use those, you should be running `fx serve` to serve their respective packages. If you're doing development which you expect to break the netstack or otherwise compromise a connection to the package server, you can build packages into the base image by including them using `--with-base //path/to/my/package` in your `fx set line`. That means that you will have them regardless of your networking situation, but also means they cannot be updated without running an OTA, for which you need a connection to the package server anyway. On-demand package resolution like this makes development faster and keeps our images small, but does require a connection to your host. Then again, so does ssh, so you should have one anyway!
Reply all
Reply to author
Forward
0 new messages