From fc3b5063ca206cfcf547961ad6d4fb90b49e2686 Mon Sep 17 00:00:00 2001 From: Jan Kaluza Date: Thu, 5 Mar 2020 09:32:03 +0100 Subject: [PATCH] Do not skip symlinks when searching for old compose. ODCS creates symlinks to real directories containing the composes. The directory structure is similar to following one: - `./nightly/Fedora-Rawhide-20200304.n.0` -> `../odcs-3` - `./nightly/Fedora-Rawhide-20200305.n.0` -> `../odcs-4` - `./nightly/latest-Fedora-Rawhide` -> `../odcs-5` The current Pungi code to search for old composes skips symlinks and therefore old ODCS composes are not found. This commit removes this check and therefore symlinks are allowed when searching for old compose. I think this check existed to prevent using `latest-*` symlink as source for the compose. But this is not possible, because the code checks that the old compose directory name has certain pattern constructed from release_short, release_version, ... The `latest-*` symlink definitely does not match this pattern. I also executed test compose and it worked as expected. Signed-off-by: Jan Kaluza --- pungi/util.py | 3 --- tests/test_util.py | 10 +++++++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/pungi/util.py b/pungi/util.py index 9f080c37..97dd6eda 100644 --- a/pungi/util.py +++ b/pungi/util.py @@ -532,9 +532,6 @@ def find_old_compose( if not os.path.isdir(path): continue - if os.path.islink(path): - continue - status_path = os.path.join(path, "STATUS") if not os.path.isfile(status_path): continue diff --git a/tests/test_util.py b/tests/test_util.py index 055a36a1..a5fc894d 100644 --- a/tests/test_util.py +++ b/tests/test_util.py @@ -465,10 +465,14 @@ class TestFindOldCompose(unittest.TestCase): old = util.find_old_compose(self.tmp_dir + "/file", "Fedora", "Rawhide", "") self.assertIsNone(old) - def test_skips_symlink(self): - os.symlink(self.tmp_dir, self.tmp_dir + "/Fedora-Rawhide-20160229.0") + def test_do_not_skip_symlink(self): + touch(self.tmp_dir + "/Fedora-Rawhide-20160228.n.10/STATUS", "FINISHED") + os.symlink( + self.tmp_dir + "/Fedora-Rawhide-20160228.n.10", + self.tmp_dir + "/Fedora-Rawhide-20160229.n.0", + ) old = util.find_old_compose(self.tmp_dir, "Fedora", "Rawhide", "") - self.assertIsNone(old) + self.assertEqual(old, self.tmp_dir + "/Fedora-Rawhide-20160229.n.0") def test_finds_layered_product(self): touch(self.tmp_dir + "/Fedora-Rawhide-Base-1-20160229.0/STATUS", "FINISHED")