Skip to content

Commit af1216b

Browse files
DaliborKrdebarshiray
authored andcommitted
cmd, test/system: Deprecate containers using o.fd.Flatpak.SessionHelper
Starting from Toolbx 0.0.97, released in November 2020, Toolbx containers no longer need the org.freedesktop.Flatpak.SessionHelper D-Bus interface. This change was made to enable running toolbox(1) as root [1]. It is going to be five years in a few months, since this change was made, and it's becoming harder and harder to practically test backwards compatibility with these containers. All the host operating systems where Toolbx is regularly tested offer newer versions: * Arch Linux and Fedora offer the latest upstream releases * RHEL 8.10 offers at least 0.0.99.4 * Ubuntu offers at least 0.0.99.2 [2] Therefore, this is a good time to mark these older containers as deprecated, as has been done in the past in similar cases [3]. A deprecation notice is the precursor to actually dropping support for these old containers in the future. [1] Commit 71b5c8c 71b5c8c0a235249b #591 #267 [2] https://packages.ubuntu.com/jammy/podman-toolbox [3] Commit 9dc5281 9dc52814301c5a3f #336 #1684
1 parent 8d21757 commit af1216b

3 files changed

Lines changed: 90 additions & 2 deletions

File tree

‎src/cmd/run.go‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ func runCommand(container string,
256256
if entryPoint != "toolbox" {
257257
var builder strings.Builder
258258
fmt.Fprintf(&builder, "container %s is too old and no longer supported\n", container)
259-
fmt.Fprintf(&builder, "Recreate it with Toolbx version 0.0.17 or newer.")
259+
fmt.Fprintf(&builder, "Recreate it with Toolbx version 0.0.97 or newer.")
260260

261261
errMsg := builder.String()
262262
return errors.New(errMsg)
@@ -529,6 +529,9 @@ func callFlatpakSessionHelper(container podman.Container) error {
529529
return nil
530530
}
531531

532+
fmt.Fprintf(os.Stderr, "Warning: container %s uses deprecated features\n", name)
533+
fmt.Fprintf(os.Stderr, "Consider recreating it with Toolbx version 0.0.97 or newer.\n")
534+
532535
if _, err := utils.CallFlatpakSessionHelper(); err != nil {
533536
return err
534537
}

‎test/system/104-run.bats‎

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,21 @@ teardown() {
316316
assert [ ${#stderr_lines[@]} -eq 0 ]
317317
}
318318

319+
@test "run: Ensure that containers using o.fd.Flatpak.SessionHelper are deprecated" {
320+
local container="deprecated"
321+
322+
create_container_flatpak_session_helper "$container"
323+
324+
run --keep-empty-lines --separate-stderr "$TOOLBX" run --container "$container" true
325+
326+
assert_success
327+
assert [ ${#lines[@]} -eq 0 ]
328+
lines=("${stderr_lines[@]}")
329+
assert_line --index 0 "Warning: container $container uses deprecated features"
330+
assert_line --index 1 "Consider recreating it with Toolbx version 0.0.97 or newer."
331+
assert [ ${#stderr_lines[@]} -eq 2 ]
332+
}
333+
319334
@test "run: Try the non-existent default container with none other present" {
320335
local default_container_name
321336
default_container_name="$(get_system_id)-toolbox-$(get_system_version)"
@@ -860,6 +875,6 @@ teardown() {
860875
assert [ ${#lines[@]} -eq 0 ]
861876
lines=("${stderr_lines[@]}")
862877
assert_line --index 0 "Error: container $container is too old and no longer supported"
863-
assert_line --index 1 "Recreate it with Toolbx version 0.0.17 or newer."
878+
assert_line --index 1 "Recreate it with Toolbx version 0.0.97 or newer."
864879
assert [ ${#stderr_lines[@]} -eq 2 ]
865880
}

‎test/system/libs/helpers.bash‎

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -577,3 +577,73 @@ function is_fedora_rawhide() (
577577

578578
return 0
579579
)
580+
581+
582+
# Creates a container with org.freedesktop.Flatpak.SessionHelper D-Bus interface
583+
#
584+
# Pulling of an image is taken care of by the function
585+
#
586+
# Parameters:
587+
# ===========
588+
# - container - name of the container
589+
function create_container_flatpak_session_helper() (
590+
local container="$1"
591+
592+
local default_image
593+
default_image="$(get_default_image)"
594+
595+
pull_default_image
596+
597+
if ! gdbus call \
598+
--session \
599+
--dest org.freedesktop.Flatpak \
600+
--object-path /org/freedesktop/Flatpak/SessionHelper \
601+
--method org.freedesktop.Flatpak.SessionHelper.RequestSession; then
602+
echo "failed to call org.freedesktop.Flatpak.SessionHelper.RequestSession" >&2
603+
return 1
604+
fi
605+
606+
local user_id_real
607+
if ! user_id_real="$(id --real --user)"; then
608+
echo "failed to get the real user ID" >&2
609+
return 1
610+
fi
611+
612+
if ! podman create \
613+
--dns none \
614+
--env TOOLBOX_PATH="$TOOLBX" \
615+
--hostname toolbox \
616+
--ipc host \
617+
--label com.github.containers.toolbox=true \
618+
--label com.github.debarshiray.toolbox=true \
619+
--name "$container" \
620+
--network host \
621+
--no-hosts \
622+
--pid host \
623+
--privileged \
624+
--security-opt label=disable \
625+
--userns keep-id \
626+
--user root:root \
627+
--volume "$HOME":"$HOME":rslave \
628+
--volume "$TOOLBX":/usr/bin/toolbox \
629+
--volume "$XDG_RUNTIME_DIR":"$XDG_RUNTIME_DIR" \
630+
--volume "$XDG_RUNTIME_DIR/.flatpak-helper/monitor":/run/host/monitor \
631+
--volume /dev:/dev:rslave \
632+
--volume /etc:/run/host/etc \
633+
--volume /run:/run/host/run:rslave \
634+
--volume /tmp:/run/host/tmp:rslave \
635+
--volume /usr:/run/host/usr:rslave \
636+
--volume /var:/run/host/var:rslave \
637+
"$default_image" \
638+
toolbox init-container \
639+
--home "$HOME" \
640+
--monitor-host \
641+
--shell "$SHELL" \
642+
--uid "$user_id_real" \
643+
--user "$USER"; then
644+
echo "failed to create container $container" >&2
645+
return 1
646+
fi
647+
648+
return 0
649+
)

0 commit comments

Comments
 (0)