2023-03-14 13:18:13 +00:00
|
|
|
assert_spec linux
|
|
|
|
|
|
|
|
create_boot_directory
|
|
|
|
|
|
|
|
import_from_depot [depot_user]/src/[base_src] \
|
|
|
|
[depot_user]/src/report_rom \
|
|
|
|
[depot_user]/src/vfs \
|
|
|
|
[depot_user]/src/lx_fs \
|
|
|
|
[depot_user]/src/vfs_import \
|
|
|
|
[depot_user]/src/init
|
|
|
|
|
|
|
|
create_tar_from_depot_binaries [run_dir]/genode/depot.tar \
|
|
|
|
[depot_user]/pkg/chroot \
|
|
|
|
[depot_user]/pkg/system_shell \
|
|
|
|
[depot_user]/pkg/fonts_fs \
|
|
|
|
[depot_user]/pkg/wm \
|
|
|
|
[depot_user]/pkg/nano3d \
|
|
|
|
[depot_user]/pkg/window_layouter \
|
|
|
|
[depot_user]/pkg/motif_decorator \
|
|
|
|
[depot_user]/pkg/themed_decorator \
|
|
|
|
[depot_user]/pkg/sticks_blue_backdrop
|
|
|
|
|
|
|
|
if { [get_cmd_switch --autopilot] } {
|
|
|
|
import_from_depot [depot_user]/src/depot_remove
|
|
|
|
} else {
|
|
|
|
build { app/depot_remove }
|
|
|
|
}
|
|
|
|
|
|
|
|
install_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"/>
|
|
|
|
|
|
|
|
<start name="timer">
|
|
|
|
<resource name="RAM" quantum="1M"/>
|
|
|
|
<provides> <service name="Timer"/> </provides>
|
|
|
|
</start>
|
|
|
|
|
|
|
|
<start name="report_rom">
|
|
|
|
<resource name="RAM" quantum="100M"/>
|
|
|
|
<provides> <service name="Report"/> <service name="ROM"/> </provides>
|
|
|
|
<config verbose="yes"/>
|
|
|
|
</start>
|
|
|
|
|
|
|
|
<start name="lx_fs" ld="no">
|
|
|
|
<resource name="RAM" quantum="100M"/>
|
|
|
|
<provides> <service name="File_system"/> </provides>
|
|
|
|
<config>
|
|
|
|
<policy label="depot_remove -> " root="/depot" writeable="yes"/>
|
|
|
|
</config>
|
|
|
|
</start>
|
|
|
|
|
|
|
|
<start name="depot_remove">
|
|
|
|
<resource name="RAM" quantum="2M"/>
|
|
|
|
<route>
|
|
|
|
<service name="ROM" label="config"> <parent label="depot_remove_config"/> </service>
|
|
|
|
<service name="File_system"> <child name="lx_fs"/> </service>
|
|
|
|
<any-service> <parent/> <any-child/> </any-service>
|
|
|
|
</route>
|
|
|
|
</start>
|
|
|
|
|
|
|
|
</config>}
|
|
|
|
|
|
|
|
exec mkdir [run_dir]/genode/depot
|
|
|
|
exec tar xvf [run_dir]/genode/depot.tar -C [run_dir]/genode/depot
|
|
|
|
exec chmod -R +r [run_dir]/genode/depot
|
|
|
|
|
|
|
|
if { [get_cmd_switch --autopilot] } {
|
|
|
|
build_boot_image {}
|
|
|
|
} else {
|
|
|
|
build_boot_image [build_artifacts]
|
|
|
|
}
|
|
|
|
|
|
|
|
proc install_test_config { args } {
|
|
|
|
set fd [open [run_dir]/genode/depot_remove_config w]
|
|
|
|
puts $fd "[join $args {}]"
|
|
|
|
close $fd
|
|
|
|
}
|
|
|
|
|
2023-06-23 11:24:24 +00:00
|
|
|
proc pkg_path { name } {
|
|
|
|
return [depot_user]/pkg/$name/[_current_depot_archive_version pkg $name] }
|
2023-03-14 13:18:13 +00:00
|
|
|
|
2023-06-23 11:24:24 +00:00
|
|
|
proc collect_pkg_dependencies { path } {
|
2023-03-14 13:18:13 +00:00
|
|
|
|
2023-06-23 11:24:24 +00:00
|
|
|
set fd [open [run_dir]/genode/depot/$path/archives r]
|
|
|
|
set pkg_deps [split [string trim [read $fd]]]
|
|
|
|
close $fd
|
2023-03-14 13:18:13 +00:00
|
|
|
|
2023-06-23 11:24:24 +00:00
|
|
|
return $pkg_deps
|
|
|
|
}
|
2023-03-14 13:18:13 +00:00
|
|
|
|
2023-06-23 11:24:24 +00:00
|
|
|
proc build_depot_context { } {
|
|
|
|
set context [dict create]
|
|
|
|
dict set context archives_to_delete { }
|
|
|
|
dict set context archives_to_keep { }
|
|
|
|
|
|
|
|
# collect every PKGs and dependencies in the keep list
|
|
|
|
foreach dir [glob -type d "[run_dir]/genode/depot/[depot_user]/pkg/*"] {
|
|
|
|
dict with context {
|
|
|
|
set path [pkg_path [file tail $dir]]
|
|
|
|
set dependencies [collect_pkg_dependencies $path]
|
|
|
|
|
|
|
|
foreach dependency $dependencies {
|
|
|
|
set idx [lsearch -exact $archives_to_keep $dependency]
|
|
|
|
if { $idx == -1 } {
|
|
|
|
lappend archives_to_keep $dependency
|
|
|
|
}
|
2023-03-14 13:18:13 +00:00
|
|
|
}
|
2023-06-23 11:24:24 +00:00
|
|
|
lappend archives_to_keep $path
|
2023-03-14 13:18:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return $context
|
|
|
|
}
|
|
|
|
|
2023-06-23 11:24:24 +00:00
|
|
|
proc mark_pkg_for_deletion { context name } {
|
2023-03-14 13:18:13 +00:00
|
|
|
|
2023-06-23 11:24:24 +00:00
|
|
|
# collect pkg versioned path and its dependencies
|
|
|
|
set path [pkg_path $name]
|
|
|
|
set archives [collect_pkg_dependencies $path]
|
|
|
|
lappend archives $path
|
2023-03-14 13:18:13 +00:00
|
|
|
|
2023-06-23 11:24:24 +00:00
|
|
|
# compute archive(s) still referenced by another PKG that must be kept
|
|
|
|
foreach dir [glob -type d "[run_dir]/genode/depot/[depot_user]/pkg/*"] {
|
|
|
|
if { [file tail $dir] == $name } continue
|
2023-03-14 13:18:13 +00:00
|
|
|
|
2023-06-23 11:24:24 +00:00
|
|
|
set pkg_path [pkg_path [file tail $dir]]
|
|
|
|
set pkg_dependencies [collect_pkg_dependencies $pkg_path]
|
2023-03-14 13:18:13 +00:00
|
|
|
|
2023-06-23 11:24:24 +00:00
|
|
|
foreach archive $archives {
|
|
|
|
set idx [lsearch -exact $pkg_dependencies $archive]
|
|
|
|
# remove the archive from deletion list if listed in other PKG dependencies
|
|
|
|
if { $idx != -1 } {
|
|
|
|
set archive_idx [lsearch -exact $archives $archive]
|
|
|
|
set archives [lreplace $archives $archive_idx $archive_idx]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-03-14 13:18:13 +00:00
|
|
|
|
2023-06-23 11:24:24 +00:00
|
|
|
# remove archives to delete from keep list and put them into deletion list
|
|
|
|
foreach archive $archives {
|
|
|
|
dict with context {
|
|
|
|
set idx [lsearch -exact $archives_to_keep $archive]
|
|
|
|
if { $idx != -1 } {
|
|
|
|
set archives_to_keep [lreplace $archives_to_keep $idx $idx]
|
|
|
|
}
|
|
|
|
set idx [lsearch -exact $archives_to_delete $archive]
|
|
|
|
if { $idx == -1 } {
|
|
|
|
lappend archives_to_delete $archive
|
2023-03-14 13:18:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-06-23 11:24:24 +00:00
|
|
|
return $context
|
|
|
|
}
|
|
|
|
|
|
|
|
proc mark_pkg_to_keep { context name } {
|
|
|
|
|
|
|
|
# collect pkg versioned path and its dependencies
|
|
|
|
set path [pkg_path $name]
|
|
|
|
set dependencies [collect_pkg_dependencies $path]
|
|
|
|
lappend dependencies $path
|
|
|
|
|
|
|
|
# ensure archives are not into deletion list but in keep list
|
|
|
|
foreach archive $dependencies {
|
|
|
|
dict with context {
|
|
|
|
set idx [lsearch -exact $archives_to_delete $archive]
|
|
|
|
if { $idx != -1 } {
|
|
|
|
set archives_to_delete [lreplace $archives_to_delete $idx $idx]
|
|
|
|
}
|
|
|
|
set idx [lsearch -exact $archives_to_keep $archive]
|
|
|
|
if { $idx == -1 } {
|
|
|
|
lappend archives_to_keep $archive
|
|
|
|
}
|
|
|
|
}
|
2023-03-14 13:18:13 +00:00
|
|
|
}
|
|
|
|
|
2023-06-23 11:24:24 +00:00
|
|
|
return $context
|
|
|
|
}
|
2023-03-14 13:18:13 +00:00
|
|
|
|
2023-06-23 11:24:24 +00:00
|
|
|
proc mark_all_for_deletion { context } {
|
|
|
|
dict with context {
|
|
|
|
set archives_to_delete [concat $archives_to_delete $archives_to_keep]
|
|
|
|
set archives_to_keep { }
|
|
|
|
}
|
2023-03-14 13:18:13 +00:00
|
|
|
return $context
|
|
|
|
}
|
|
|
|
|
|
|
|
proc check_depot_state { context } {
|
|
|
|
|
|
|
|
foreach archive [dict get $context archives_to_delete] {
|
|
|
|
|
|
|
|
regexp [_depot_archive_versioned_path_pattern] $archive dummy archive_user archive_type archive_name
|
|
|
|
|
|
|
|
if { $archive_type == "src" } {
|
2023-06-16 10:13:55 +00:00
|
|
|
set archive $archive_user/bin/[depot_spec]/$archive_name/[_current_depot_archive_version src $archive_name]
|
2023-03-14 13:18:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if { [file isdirectory [run_dir]/genode/depot/$archive] } {
|
|
|
|
puts "ERROR: $archive is present but should has been deleted."
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach archive [dict get $context archives_to_keep] {
|
|
|
|
|
|
|
|
regexp [_depot_archive_versioned_path_pattern] $archive dummy archive_user archive_type archive_name
|
|
|
|
|
|
|
|
if { $archive_type == "src" } {
|
2023-06-16 10:13:55 +00:00
|
|
|
set archive $archive_user/bin/[depot_spec]/$archive_name/[_current_depot_archive_version src $archive_name]
|
2023-03-14 13:18:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if { ![file isdirectory [run_dir]/genode/depot/$archive] } {
|
|
|
|
puts "ERROR: $archive should still be there but it has been deleted."
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
2023-06-23 11:24:24 +00:00
|
|
|
puts "\n--------------- TEST 1 --- Delete nano3d"
|
2023-03-14 13:18:13 +00:00
|
|
|
|
2023-06-23 11:24:24 +00:00
|
|
|
set context [mark_pkg_for_deletion [build_depot_context] "nano3d"]
|
2023-03-14 13:18:13 +00:00
|
|
|
|
|
|
|
install_test_config {
|
2023-06-16 10:13:55 +00:00
|
|
|
<config arch="} [depot_spec] {" report="yes">
|
2023-03-14 13:18:13 +00:00
|
|
|
<remove user="} [depot_user] {" pkg="nano3d"/>
|
|
|
|
<vfs> <dir name="depot"> <fs/> </dir> </vfs>
|
2023-06-23 11:24:24 +00:00
|
|
|
</config>}
|
2023-03-14 13:18:13 +00:00
|
|
|
|
|
|
|
run_genode_until ".*</removed_archives>" 10
|
|
|
|
|
|
|
|
if { [check_depot_state $context] } {
|
|
|
|
puts " TEST 1 --- Delete nano3d -- ERROR"
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
puts " TEST 1 --- Delete nano3d -- SUCCESS"
|
2023-06-23 11:24:24 +00:00
|
|
|
puts "\n--------------- TEST 2 --- Delete non existing archive"
|
2023-03-14 13:18:13 +00:00
|
|
|
|
2023-06-23 11:24:24 +00:00
|
|
|
set context [build_depot_context]
|
2023-03-14 13:18:13 +00:00
|
|
|
|
|
|
|
install_test_config {
|
2023-06-16 10:13:55 +00:00
|
|
|
<config arch="} [depot_spec] {" report="yes">
|
2023-03-14 13:18:13 +00:00
|
|
|
<remove user="} [depot_user] {" pkg="nano3d"/>
|
|
|
|
<vfs> <dir name="depot"> <fs/> </dir> </vfs>
|
2023-06-23 11:24:24 +00:00
|
|
|
</config>}
|
2023-03-14 13:18:13 +00:00
|
|
|
|
|
|
|
run_genode_until ".*<removed_archives/>" 10
|
|
|
|
|
|
|
|
if { [check_depot_state $context] } {
|
|
|
|
puts " TEST 2 --- Delete non existing archive -- ERROR"
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
puts " TEST 2 --- Delete non existing archive -- SUCCESS"
|
|
|
|
|
2023-06-23 11:24:24 +00:00
|
|
|
puts "\n--------------- TEST 3 --- Delete a PKG archive with deps to keep"
|
2023-03-14 13:18:13 +00:00
|
|
|
|
2023-06-23 11:24:24 +00:00
|
|
|
set context [mark_pkg_for_deletion [build_depot_context] "fonts_fs"]
|
2023-03-14 13:18:13 +00:00
|
|
|
|
|
|
|
install_test_config {
|
2023-06-16 10:13:55 +00:00
|
|
|
<config arch="} [depot_spec] {" report="yes">
|
2023-03-14 13:18:13 +00:00
|
|
|
<remove user="} [depot_user] {" pkg="fonts_fs"/>
|
|
|
|
<vfs> <dir name="depot"> <fs/> </dir> </vfs>
|
2023-06-23 11:24:24 +00:00
|
|
|
</config>}
|
2023-03-14 13:18:13 +00:00
|
|
|
|
|
|
|
run_genode_until ".*</removed_archives>" 10
|
|
|
|
|
|
|
|
if { [check_depot_state $context] } {
|
|
|
|
puts " TEST 3 --- Delete a PKG archive with deps to keep --- ERROR"
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
puts " TEST 3 --- Delete a PKG archive with deps to keep --- SUCCESS"
|
|
|
|
|
2023-06-23 11:32:20 +00:00
|
|
|
puts "\n--------------- TEST 4 --- Remove all, keep themed_decorator and chroot PKGS"
|
2023-03-14 13:18:13 +00:00
|
|
|
|
2023-06-23 11:24:24 +00:00
|
|
|
set context [mark_all_for_deletion [build_depot_context]]
|
|
|
|
set context [mark_pkg_to_keep $context "themed_decorator"]
|
2023-06-23 11:32:20 +00:00
|
|
|
set context [mark_pkg_to_keep $context "chroot"]
|
2023-03-14 13:18:13 +00:00
|
|
|
|
|
|
|
install_test_config {
|
2023-06-16 10:13:55 +00:00
|
|
|
<config arch="} [depot_spec] {" report="yes">
|
2023-03-14 13:18:13 +00:00
|
|
|
<remove-all>
|
|
|
|
<keep user="} [depot_user] {" pkg="themed_decorator"/>
|
2023-06-23 11:32:20 +00:00
|
|
|
<keep user="} [depot_user] {" pkg="chroot"/>
|
2023-03-14 13:18:13 +00:00
|
|
|
</remove-all>
|
|
|
|
<vfs> <dir name="depot"> <fs/> </dir> </vfs>
|
2023-06-23 11:24:24 +00:00
|
|
|
</config>}
|
2023-03-14 13:18:13 +00:00
|
|
|
|
|
|
|
run_genode_until ".*</removed_archives>" 10
|
|
|
|
|
2023-06-23 11:24:24 +00:00
|
|
|
if { [check_depot_state $context] } {
|
2023-06-23 11:32:20 +00:00
|
|
|
puts " TEST 4 --- Remove all, keep themed_decorator and chroot PKGS --- ERROR"
|
2023-03-14 13:18:13 +00:00
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
2023-06-23 11:32:20 +00:00
|
|
|
puts " TEST 4 --- Remove all, keep themed_decorator and chroot PKGS --- SUCCESS"
|
2023-03-14 13:18:13 +00:00
|
|
|
|
2023-06-23 11:32:20 +00:00
|
|
|
puts "\n--------------- TEST 5 --- Remove all --- SUCCESS"
|
|
|
|
|
|
|
|
set context [mark_all_for_deletion [build_depot_context]]
|
|
|
|
|
|
|
|
install_test_config {
|
|
|
|
<config arch="} [depot_spec] {" report="yes">
|
|
|
|
<remove-all/>
|
|
|
|
<vfs> <dir name="depot"> <fs/> </dir> </vfs>
|
|
|
|
</config>}
|
|
|
|
|
|
|
|
run_genode_until ".*</removed_archives>" 10
|
|
|
|
|
|
|
|
if { [check_depot_state $context] } {
|
|
|
|
puts " TEST 5 --- Remove all --- ERROR"
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
puts " TEST 5 --- Remove all --- SUCCESS"
|