From cf7888840130d1fe718c36f2a1155c06ffb90e92 Mon Sep 17 00:00:00 2001 From: Matthew Leeds Date: Mon, 26 Mar 2018 00:01:39 -0700 Subject: [PATCH] create-usb: Update summary in destination repo Currently the create-usb command only generates a summary file in the destination repo if one doesn't already exist, which means if one does exist it becomes out of date after the new refs are pulled. This commit makes ostree regenerate the summary regardless of whether it exists, so that consumers such as ostree_repo_find_remotes_async() (and at a higher level, GNOME Software) get an accurate picture of the refs available on the mount. This commit also updates one of the unit tests to check that the summary is accurate after a second pull into the same repo. Since any user of the create-usb command is using collection IDs they are new enough to be using the unsigned summary support. While it would technically be possible to use summary signatures on a repo and use the create-usb command on it (a scenario broken by this commit), the create-usb command is designed for P2P distribution of refs, which requires use of unsigned summary support. So this is a legitimate narrowing of the tool. Fixes https://github.com/ostreedev/ostree/issues/1465 Closes: #1543 Approved by: cgwalters --- src/ostree/ot-builtin-create-usb.c | 6 +----- tests/test-create-usb.sh | 5 ++++- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/ostree/ot-builtin-create-usb.c b/src/ostree/ot-builtin-create-usb.c index 02b55b94..07a214c6 100644 --- a/src/ostree/ot-builtin-create-usb.c +++ b/src/ostree/ot-builtin-create-usb.c @@ -201,11 +201,7 @@ ostree_builtin_create_usb (int argc, /* FIXME: It should be possible to work without this, but find_remotes_cb() in * ostree-repo-pull.c currently assumes a summary file (signed or unsigned) is * present. */ - struct stat stbuf; - if (!glnx_fstatat_allow_noent (ostree_repo_get_dfd (dest_repo), "summary", &stbuf, 0, error)) - return FALSE; - if (errno == ENOENT && - !ostree_repo_regenerate_summary (dest_repo, NULL, cancellable, error)) + if (!ostree_repo_regenerate_summary (dest_repo, NULL, cancellable, error)) return FALSE; /* Add the symlinks .ostree/repos.d/@symlink_name → @dest_repo_path, unless diff --git a/tests/test-create-usb.sh b/tests/test-create-usb.sh index 310385d9..392352fd 100755 --- a/tests/test-create-usb.sh +++ b/tests/test-create-usb.sh @@ -96,7 +96,10 @@ ${CMD_PREFIX} ostree --repo=dest-mount3/.ostree/repos.d/00-generated refs --coll assert_file_has_content dest-refs "^(org.example.Collection1, test-1)$" assert_file_has_content dest-refs "^(org.example.Collection1, test-2)$" assert_file_has_content dest-refs "^(org.example.Collection1, test-3)$" -assert_has_file dest-mount3/.ostree/repos.d/00-generated/summary +${CMD_PREFIX} ostree --repo=dest-mount3/.ostree/repos.d/00-generated summary -v > dest-summary +assert_file_has_content dest-summary "(org.example.Collection1, test-1)$" +assert_file_has_content dest-summary "(org.example.Collection1, test-2)$" +assert_file_has_content dest-summary "(org.example.Collection1, test-3)$" echo "ok 4 adding ref to an existing usb"