size_t l;
/* We shall match against a path. Let's ignore any prefix here though, as often there are many ways to
- * reach the same file. However, in this mode, let's validate any file suffix. */
+ * reach the same file. However, in this mode, let's validate any file suffix.
+ * But also ensure that we don't fail if both components don't have a '/' at all
+ * (strcspn returns the full length of the string in that case, which might not
+ * match as the versions might differ). */
l = strcspn(a, "/");
b = last_path_component(*image_name_or_path);
- if (strcspn(b, "/") != l)
+ if ((a[l] != '/') != !strchr(b, '/')) /* One is a directory, the other is not */
+ return false;
+
+ if (a[l] != 0 && strcspn(b, "/") != l)
return false;
underscore = strchr(b, '_');
if (underscore)
l = underscore - b;
+ else { /* Either component could be versioned */
+ underscore = strchr(a, '_');
+ if (underscore)
+ l = underscore - a;
+ }
if (!strneq(a, b, l))
return false;
status="$(portablectl is-attached --extension app1 minimal_0)"
[[ "${status}" == "running-runtime" ]]
+# Ensure that adding or removing a version to the image doesn't break reattaching
+cp /usr/share/app1.raw /tmp/app1_2.raw
+portablectl "${ARGS[@]}" reattach --now --runtime --extension /tmp/app1_2.raw /usr/share/minimal_1.raw app1
+
+systemctl is-active app1.service
+status="$(portablectl is-attached --extension app1_2 minimal_1)"
+[[ "${status}" == "running-runtime" ]]
+
portablectl "${ARGS[@]}" reattach --now --runtime --extension /usr/share/app1.raw /usr/share/minimal_1.raw app1
systemctl is-active app1.service