Skip to content

Commit 1b380a4

Browse files
DaliborKrdebarshiray
authored andcommitted
cmd, test/system: Deprecate containers using o.fd.Flatpak.SessionHelper
#1684
1 parent 8d21757 commit 1b380a4

File tree

3 files changed

+73
-2
lines changed

3 files changed

+73
-2
lines changed

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 Toolbox 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 Toolbox 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: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -577,3 +577,56 @@ 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 - name of the container
589+
function create_container_flatpak_session_helper() (
590+
local container_name="$1"
591+
592+
local default_image
593+
default_image="$(get_default_image)"
594+
595+
pull_default_image
596+
597+
gdbus call \
598+
--session \
599+
--dest org.freedesktop.Flatpak \
600+
--object-path /org/freedesktop/Flatpak/SessionHelper \
601+
--method org.freedesktop.Flatpak.SessionHelper.RequestSession
602+
603+
podman_cmd=(
604+
podman create \
605+
--dns none \
606+
--env TOOLBOX_PATH="$TOOLBX" \
607+
--name "$container_name" \
608+
--network host \
609+
--no-hosts \
610+
--pid host \
611+
--privileged \
612+
--userns=keep-id \
613+
--user root:root \
614+
--volume "$HOME":"$HOME":rslave \
615+
--volume "$TOOLBX":/usr/bin/toolbox \
616+
--volume "$XDG_RUNTIME_DIR":"$XDG_RUNTIME_DIR" \
617+
--volume "$XDG_RUNTIME_DIR/.flatpak-helper/monitor":/run/host/monitor \
618+
--volume /etc:/run/host/etc \
619+
--volume /usr:/run/host/usr:rslave \
620+
"$default_image" \
621+
toolbox init-container \
622+
--home "$HOME" \
623+
--shell "$SHELL" \
624+
--uid "$(id -ru)" \
625+
--user "$USER"
626+
)
627+
628+
# Print the full command
629+
# printf "%q " "${podman_cmd[@]}" >> /tmp/toolbox_podman_command.log
630+
631+
"${podman_cmd[@]}" || fail "Podman couldn't create container '$container_name'"
632+
)

0 commit comments

Comments
 (0)