Support generating ISOs when using link_type="symlink".

When `link_type = "symlink"` is used, the packages are in fact symlinks
to /mnt/koji. When graft points file is generated, the paths in this graft
points file point to symlinks and therefore symlinks are copied into the
generated ISO file instead of real files.

In this commit, the code to generate the graft points file is changed
so it resolves the symlink to real file stored on /mnt/koji. To make
this code safer, it does such resolving only in case the symlink points
outside of `compose.paths.compose.topdir()`. Therefore you can still
generate ISO file with symlink pointing to file stored within the ISO
file itself, although this is not done currently afaik.

The main reason for this is to be able to generate ISO files even
without hardlinks (which would need read-write access on /mnt/koji)
and without copying all the packages from /mnt/koji to local storage.

Signed-off-by: Jan Kaluza <jkaluza@redhat.com>
This commit is contained in:
Jan Kaluza 2020-01-03 15:48:12 +01:00 committed by lsedlar
parent 02ace28fe4
commit fcf1442f71
4 changed files with 31 additions and 16 deletions

View file

@ -562,7 +562,7 @@ class GetIsoContentsTest(helpers.PungiTestCase):
'work/x86_64/Server/extra-iso-extra-files': {'EULA': '/mnt/EULA'},
}
ggp.side_effect = lambda x: gp[x[0][len(self.topdir) + 1:]]
ggp.side_effect = lambda compose, x: gp[x[0][len(self.topdir) + 1:]]
gp_file = os.path.join(self.topdir, 'work/x86_64/iso/my.iso-graft-points')
self.assertEqual(
@ -589,7 +589,7 @@ class GetIsoContentsTest(helpers.PungiTestCase):
six.assertCountEqual(
self,
ggp.call_args_list,
[mock.call([os.path.join(self.topdir, x)]) for x in gp]
[mock.call(self.compose, [os.path.join(self.topdir, x)]) for x in gp]
)
self.assertEqual(len(wgp.call_args_list), 1)
self.assertEqual(wgp.call_args_list[0][0][0], gp_file)
@ -623,7 +623,7 @@ class GetIsoContentsTest(helpers.PungiTestCase):
"work/x86_64/Server/extra-iso-extra-files": {"EULA": "/mnt/EULA"},
}
ggp.side_effect = lambda x: gp[x[0][len(self.topdir) + 1:]]
ggp.side_effect = lambda compose, x: gp[x[0][len(self.topdir) + 1:]]
gp_file = os.path.join(self.topdir, "work/x86_64/iso/my.iso-graft-points")
self.assertEqual(
@ -652,7 +652,7 @@ class GetIsoContentsTest(helpers.PungiTestCase):
six.assertCountEqual(
self,
ggp.call_args_list,
[mock.call([os.path.join(self.topdir, x)]) for x in gp]
[mock.call(self.compose, [os.path.join(self.topdir, x)]) for x in gp]
)
self.assertEqual(len(wgp.call_args_list), 1)
self.assertEqual(wgp.call_args_list[0][0][0], gp_file)
@ -684,7 +684,7 @@ class GetIsoContentsTest(helpers.PungiTestCase):
'work/src/Server/extra-iso-extra-files': {'EULA': '/mnt/EULA'},
}
ggp.side_effect = lambda x: gp[x[0][len(self.topdir) + 1:]]
ggp.side_effect = lambda compose, x: gp[x[0][len(self.topdir) + 1:]]
gp_file = os.path.join(self.topdir, 'work/src/iso/my.iso-graft-points')
self.assertEqual(
@ -711,7 +711,7 @@ class GetIsoContentsTest(helpers.PungiTestCase):
six.assertCountEqual(
self,
ggp.call_args_list,
[mock.call([os.path.join(self.topdir, x)]) for x in gp]
[mock.call(self.compose, [os.path.join(self.topdir, x)]) for x in gp]
)
self.assertEqual(len(wgp.call_args_list), 1)
self.assertEqual(wgp.call_args_list[0][0][0], gp_file)
@ -756,7 +756,7 @@ class GetIsoContentsTest(helpers.PungiTestCase):
'images/efiboot.img': os.path.join(iso_dir, 'images/efiboot.img'),
}
ggp.side_effect = lambda x: gp[x[0][len(self.topdir) + 1:]] if len(x) == 1 else bi_gp
ggp.side_effect = lambda compose, x: gp[x[0][len(self.topdir) + 1:]] if len(x) == 1 else bi_gp
gp_file = os.path.join(self.topdir, 'work/x86_64/iso/my.iso-graft-points')
self.assertEqual(
@ -790,7 +790,8 @@ class GetIsoContentsTest(helpers.PungiTestCase):
six.assertCountEqual(
self,
ggp.call_args_list,
[mock.call([os.path.join(self.topdir, x)]) for x in gp] + [mock.call([bi_dir, iso_dir])]
[mock.call(self.compose, [os.path.join(self.topdir, x)]) for x in gp] + [
mock.call(self.compose, [bi_dir, iso_dir])]
)
self.assertEqual(len(wgp.call_args_list), 1)
self.assertEqual(wgp.call_args_list[0][0][0], gp_file)