genode/repos/gems/run/depot_download.run
Norman Feske 2c8beb462f file-system session: root dir via session label
This patch changes the way of how the client-selected sub directory is
communicated to the server. The former opaque session argument is now
passed as last label element, which allows for the flexible tweaking
of this argument by init's session-routing and label-rewriting
mechansims. In particular, it alleviates the need for creating chroot
component instances.

This change requires the following four adaptations at the
configuration level:

- Each file-system session request must now carry a path starting
  with / as last session arguments. Hence, <vfs> <fs> nodes that
  feature a 'label' attributes must extend the attribute value
  with " -> /". For <fs> nodes with no label attribute, "/" is
  used as last label argument by default.

- For matching session-routing rules at init's configuration,
  the matching of full labels should be replaced by 'label_prefix'
  matches, excluding the last (path) argument.

- Wherever a label of a file-system session is rewritten by using
  init's 'label' attribute of a <parent> or <child> target node,
  the new attribute 'identity' should be used instead. This replaces
  the identity part of the label while preserving the client's
  directory argument.

- Analogously to the matching of session-routing rules, server-side
  policy-selection rules that formerly matched a concrete 'label'
  must be changed to match a 'label_prefix' instead.

As a good practice, 'label_prefix' values should end with " ->" if
possible, which clearly delimits the identity part of the label
used by the matching.

Issue #5445
2025-02-24 16:39:20 +01:00

177 lines
5.2 KiB
Plaintext

create_boot_directory
if {[have_board linux] || [have_board rpi3] || [have_board imx53_qsb_tz]} {
puts "Run script does not support this platform."
exit 0
}
if {[get_cmd_switch --autopilot] && [have_board virt_qemu_riscv]} {
puts "Autopilot mode is not supported on this platform."
exit 0
}
import_from_depot [depot_user]/src/[base_src] \
[depot_user]/pkg/[drivers_nic_pkg] \
[depot_user]/src/report_rom \
[depot_user]/src/fs_rom \
[depot_user]/src/vfs \
[depot_user]/src/vfs_lxip \
[depot_user]/src/vfs_pipe \
[depot_user]/src/fetchurl \
[depot_user]/src/libc \
[depot_user]/src/libssh \
[depot_user]/src/openssl \
[depot_user]/src/zlib \
[depot_user]/src/curl \
[depot_user]/src/init \
[depot_user]/src/chroot \
[depot_user]/src/extract \
[depot_user]/src/nic_router \
[depot_user]/src/libarchive \
[depot_user]/src/liblzma \
[depot_user]/src/verify
set config {
<config>
<parent-provides>
<service name="ROM"/>
<service name="IRQ"/>
<service name="IO_MEM"/>
<service name="IO_PORT"/>
<service name="PD"/>
<service name="RM"/>
<service name="CPU"/>
<service name="LOG"/>
</parent-provides>
<default-route>
<any-service> <parent/> <any-child/> </any-service>
</default-route>
<default caps="100" ram="1M"/>}
proc depot_user_download { user } {
return [exec cat [select_from_repositories sculpt/depot/$user/download]] }
proc depot_user_pubkey { user } {
return [exec cat [select_from_repositories sculpt/depot/$user/pubkey]] }
append config {
<start name="timer">
<provides> <service name="Timer"/> </provides>
</start>
<start name="drivers" caps="1200" ram="32M" managing_system="yes">
<binary name="init"/>
<route>
<service name="ROM" label="config"> <parent label="drivers.config"/> </service>
<service name="Timer"> <child name="timer"/> </service>
<service name="Uplink"> <child name="nic_router"/> </service>
<any-service> <parent/> </any-service>
</route>
</start>
<start name="nic_router" caps="200" ram="10M">
<provides>
<service name="Nic"/>
<service name="Uplink"/>
</provides>
<config verbose_domain_state="yes">
<policy label_prefix="depot_download" domain="downlink"/>
<policy label_prefix="drivers" domain="uplink"/>
<domain name="uplink">
<nat domain="downlink"
tcp-ports="16384"
udp-ports="16384"
icmp-ids="16384"/>
</domain>
<domain name="downlink" interface="10.0.3.1/24">
<dhcp-server ip_first="10.0.3.2" ip_last="10.0.3.2" dns_config_from="uplink"/>
<tcp dst="0.0.0.0/0"><permit-any domain="uplink" /></tcp>
<udp dst="0.0.0.0/0"><permit-any domain="uplink" /></udp>
<icmp dst="0.0.0.0/0" domain="uplink"/>
</domain>
</config>
</start>
<start name="vfs" ram="20M">
<provides> <service name="File_system"/> </provides>
<config>
<vfs>
<dir name="depot">
<dir name="genodelabs">
<ram/>
<inline name="download">} [depot_user_download genodelabs] {</inline>
<inline name="pubkey">} [depot_user_pubkey genodelabs] {</inline>
</dir>
</dir>
<dir name="public"> <ram/> </dir>
</vfs>
<policy label_prefix="depot_download -> depot ->" root="/depot" writeable="yes"/>
<policy label_prefix="depot_download -> public ->" root="/public" writeable="yes"/>
</config>
</start>
<start name="report_rom">
<provides> <service name="Report"/> <service name="ROM"/> </provides>
<config verbose="yes">
</config>
</start>
<start name="depot_download" caps="2000" ram="70M">
<binary name="init"/>
<route>
<service name="ROM" label="config">
<parent label="depot_download.config"/> </service>
<service name="Report"> <child name="report_rom"/> </service>
<service name="Nic"> <child name="nic_router"/> </service>
<service name="File_system"> <child name="vfs"/> </service>
<any-service> <parent/> <any-child/> </any-service>
</route>
</start>
</config>}
set fd [open [run_dir]/genode/installation w]
puts $fd {
<installation arch="x86_64">
<archive path="genodelabs/pkg/wm/2019-03-17"/>
<archive path="genodelabs/bin/x86_64/backdrop/2019-03-17"/>
<index path="genodelabs/index/19.02"/>
<index path="genodelabs/index/19.03"/>
</installation>}
close $fd
install_config $config
copy_file [genode_dir]/repos/gems/recipes/raw/depot_download/depot_download.config \
[run_dir]/genode/depot_download.config
build { app/depot_download_manager app/depot_query }
build_boot_image [build_artifacts]
append qemu_args " -nographic "
append_qemu_nic_args
# watch the state reports generated by the depot-download manager
set expected_pattern {}
append expected_pattern {.*path="genodelabs/pkg/wm/2019-03-17" state="done".*}
append expected_pattern {.*path="genodelabs/bin/x86_64/backdrop/2019-03-17" state="done".*}
append expected_pattern {.*path="genodelabs/index/19.02" state="done".*}
append expected_pattern {.*path="genodelabs/index/19.03" state="failed".*}
run_genode_until $expected_pattern 150