-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sysupdate.d: Add way to drop binaries into $BOOT #27794
Conversation
b77bf16
to
2a6564b
Compare
I think this is ready for another look |
2a6564b
to
dca5db6
Compare
anyway, I think we should do the PathRelativeTo= idea as per suggestions above. can you rework? |
dca5db6
to
2592f82
Compare
Done. I didn't implement the test as you suggested because it turns out to be rather finicky/annoying to get working (I'd have to figure out how to build sysupdate without the CLI so that I can graft a test onto it) and I feel isn't worth all that much (since it'd have to be manually updated and thus doesn't really prevent diverging...) My work on the test before I scrapped itdiff --git a/src/sysupdate/meson.build b/src/sysupdate/meson.build
index 2f8c2305da..c42ca043c5 100644
--- a/src/sysupdate/meson.build
+++ b/src/sysupdate/meson.build
@@ -20,3 +20,22 @@ systemd_sysupdate_sources = files(
'sysupdate.c',
'sysupdate.h',
)
+
+############################################################
+
+tests += [
+ {
+ 'sources' : files(
+ 'sysupdate-resource.c',
+ 'sysupdate-resource.h',
+ 'test-resource.c',
+ ),
+ 'link_with' : [
+ libshared,
+ libshared_fdisk,
+ ],
+ 'dependencies': [
+ libfdisk,
+ ],
+ },
+]
diff --git a/src/sysupdate/sysupdate-resource.h b/src/sysupdate/sysupdate-resource.h
index 960f463c58..ee786311c2 100644
--- a/src/sysupdate/sysupdate-resource.h
+++ b/src/sysupdate/sysupdate-resource.h
@@ -68,7 +68,7 @@ static inline bool RESOURCE_IS_URL(ResourceType t) {
typedef enum PathRelativeTo {
/* Please make sure to folow the naming of the corresponding PartitionDesignator enum values,
- * where this makes sense, like for the following three. */
+ * where this makes sense, like for the following cases. Make sure to update the test too! */
PATH_RELATIVE_TO_ROOT,
PATH_RELATIVE_TO_ESP,
PATH_RELATIVE_TO_XBOOTLDR,
diff --git a/src/sysupdate/test-resource.c b/src/sysupdate/test-resource.c
new file mode 100644
index 0000000000..d9d5d1d967
--- /dev/null
+++ b/src/sysupdate/test-resource.c
@@ -0,0 +1,29 @@
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+
+/* Some unit tests for the helper functions in sysupdate-reousrce. */
+
+#include "gpt.h"
+#include "log.h"
+#include "sysupdate-resource.h"
+#include "tests.h"
+
+TEST(path_relative_to_to_string) {
+ /* Make sure that PathRelativeTo's to_string function matches
+ * those in PartitionDesignator */
+
+ struct {
+ PathRelativeTo relative_to;
+ PartitionDesignator designator;
+ } cases[] = {
+ { PATH_RELATIVE_TO_ROOT, PARTITION_ROOT },
+ { PATH_RELATIVE_TO_ESP, PARTITION_ESP },
+ { PATH_RELATIVE_TO_XBOOTLDR, PARTITION_XBOOTLDR },
+ };
+
+ for (size_t i = 0; i < ELEMENTSOF(cases); i++) {
+ assert(streq_ptr(path_relative_to_to_string(cases[i].relative_to),
+ partition_designator_to_string(cases[i].designator)));
+ }
+}
+
+DEFINE_TEST_MAIN(LOG_DEBUG); |
There's an integration test that uses scripts, there is already one for sysupdate ( |
2592f82
to
73d5e73
Compare
eda90c6
to
59c303c
Compare
looks excellent, good to go if you address the oom issue. thanks! |
59c303c
to
a521ff9
Compare
Looks like CI failure is my fault. I'll investigate tomorrow |
So CI was failing because the behavior of sysupdate changed in a way that breaks the pre-existing parts of the test. The test previously deleted Prior to my changes, if With my changes, sysupdate |
a521ff9
to
9b7cc69
Compare
9b7cc69
to
4dc257f
Compare
hmm, still ci failures |
As described in the BLS, we should place binaries into the XBOOTLDR directory if it is available, otherwise into the ESP. Thus, we might need to put binaries into /boot or into /efi depending on the existence of the XBOOTLDR partition. With this change, we introduce a new PathRelativeTo= config option that makes this functionality possible
4dc257f
to
7e96ae6
Compare
The test passed but then I had a silly oversight on cleanup :( Anyway, should hopefully be fixed now 🤞. Thanks for your patience |
Thanks! |
As described in the BLS, we should place binaries into the XBOOTLDR directory if it is available, otherwise into the ESP. Thus, we might need to put binaries into /boot or into /efi depending on the existence of the XBOOTLDR partition.
With this change, if the Path= config option in the file starts with $BOOT, we replace that with either /boot or /efi, depending on what is available on the system.