portablectl: fix detaching when an extension image has been deleted

This commit is contained in:
Luca Boccassi
2023-11-10 12:58:45 +00:00
committed by Frantisek Sumsal
parent 4e3c9c8c0b
commit ba8eda568c
2 changed files with 9 additions and 2 deletions
+4 -1
View File
@@ -108,7 +108,10 @@ static int attach_extensions_to_message(sd_bus_message *m, const char *method, c
STRV_FOREACH(p, extensions) {
_cleanup_free_ char *resolved_extension_image = NULL;
r = determine_image(*p, false, &resolved_extension_image);
r = determine_image(
*p,
startswith_strv(method, STRV_MAKE("Get", "Detach")),
&resolved_extension_image);
if (r < 0)
return r;
+5 -1
View File
@@ -186,7 +186,11 @@ status="$(portablectl is-attached --extension /tmp/app10.raw /usr/share/minimal_
portablectl inspect --force --cat --extension /tmp/app10.raw /usr/share/minimal_0.raw app0 | grep -q -F "Extension Release: /tmp/app10.raw"
portablectl detach --force --now --runtime --extension /tmp/app10.raw /usr/share/minimal_0.raw app0
# Ensure that we can detach even when an image has been deleted already (stop the unit manually as
# portablectl won't find it)
rm -f /tmp/app10.raw
systemctl stop app0.service
portablectl detach --force --runtime --extension /tmp/app10.raw /usr/share/minimal_0.raw app0
# portablectl also accepts confexts
portablectl "${ARGS[@]}" attach --now --runtime --extension /usr/share/app0.raw --extension /usr/share/conf0.raw /usr/share/minimal_0.raw app0