#1440 Fix patch-iso
Merged 4 years ago by lsedlar. Opened 4 years ago by lsedlar.
lsedlar/pungi patch-iso  into  master

file modified
+3 -2
@@ -508,10 +508,11 @@ 

      write_discinfo(new_di_path, **data)

  

      if not disc_count or disc_count == 1:

-         data = iso.get_graft_points(compose, [tree_dir, iso_dir])

+         data = iso.get_graft_points(compose.paths.compose.topdir(), [tree_dir, iso_dir])

      else:

          data = iso.get_graft_points(

-             compose, [iso._paths_from_list(tree_dir, split_iso_data["files"]), iso_dir]

+             compose.paths.compose.topdir(),

+             [iso._paths_from_list(tree_dir, split_iso_data["files"]), iso_dir],

          )

  

      if compose.conf["createiso_break_hardlinks"]:

file modified
+15 -5
@@ -199,7 +199,9 @@ 

              buildinstall_dir = os.path.join(buildinstall_dir, variant.uid)

  

          copy_boot_images(buildinstall_dir, iso_dir)

-         files = iso.get_graft_points(compose, [buildinstall_dir, iso_dir])

+         files = iso.get_graft_points(

+             compose.paths.compose.topdir(), [buildinstall_dir, iso_dir]

+         )

  

          # We need to point efiboot.img to compose/ tree, because it was

          # modified in buildinstall phase and the file in work/ has different
@@ -215,19 +217,25 @@ 

  

          # Get packages...

          package_dir = compose.paths.compose.packages(arch, var)

-         for k, v in iso.get_graft_points(compose, [package_dir]).items():

+         for k, v in iso.get_graft_points(

+             compose.paths.compose.topdir(), [package_dir]

+         ).items():

              files[os.path.join(var.uid, "Packages", k)] = v

  

          # Get repodata...

          tree_dir = compose.paths.compose.repository(arch, var)

          repo_dir = os.path.join(tree_dir, "repodata")

-         for k, v in iso.get_graft_points(compose, [repo_dir]).items():

+         for k, v in iso.get_graft_points(

+             compose.paths.compose.topdir(), [repo_dir]

+         ).items():

              files[os.path.join(var.uid, "repodata", k)] = v

  

          if inherit_extra_files:

              # Get extra files...

              extra_files_dir = compose.paths.work.extra_files_dir(arch, var)

-             for k, v in iso.get_graft_points(compose, [extra_files_dir]).items():

+             for k, v in iso.get_graft_points(

+                 compose.paths.compose.topdir(), [extra_files_dir]

+             ).items():

                  files[os.path.join(var.uid, k)] = v

  

      extra_files_dir = compose.paths.work.extra_iso_extra_files_dir(arch, variant)
@@ -243,7 +251,9 @@ 

      )

  

      # Add extra files specific for the ISO

-     files.update(iso.get_graft_points(compose, [extra_files_dir]))

+     files.update(

+         iso.get_graft_points(compose.paths.compose.topdir(), [extra_files_dir])

+     )

  

      gp = "%s-graft-points" % iso_dir

      iso.write_graft_points(gp, files, exclude=["*/lost+found", "*/boot.iso"])

file modified
+3 -4
@@ -273,7 +273,7 @@ 

      raise RuntimeError("Could not read Volume ID")

  

  

- def get_graft_points(compose, paths, exclusive_paths=None, exclude=None):

+ def get_graft_points(compose_top_dir, paths, exclusive_paths=None, exclude=None):

      # path priority in ascending order (1st = lowest prio)

      # paths merge according to priority

      # exclusive paths override whole dirs
@@ -293,18 +293,17 @@ 

          tree = _scan_tree(i)

          result = _merge_trees(result, tree, exclusive=True)

  

-     # Resolve possible symlinks pointing outside of the compose.topdir.

+     # Resolve possible symlinks pointing outside of the compose top dir.

      # This fixes an issue if link_type is set to "symlink" and therefore

      # the RPM packages are symbolic links to /mnt/koji filesystem.

      # Without this, the symbolic links would be simply copied into the ISO

      # without the real RPMs.

-     topdir = compose.paths.compose.topdir()

      for key in result.keys():

          path = result[key]

          if os.path.islink(path):

              real_path = os.readlink(path)

              abspath = os.path.normpath(os.path.join(os.path.dirname(path), real_path))

-             if not abspath.startswith(topdir):

+             if not abspath.startswith(compose_top_dir):

                  result[key] = abspath

  

      # TODO: exclude

file modified
+1 -1
@@ -94,7 +94,7 @@ 

          volume_id = opts.volume_id or iso.get_volume_id(opts.source)

  

          # create graft points from mounted source iso + overlay dir

-         graft_points = iso.get_graft_points([work_dir] + opts.dirs)

+         graft_points = iso.get_graft_points(work_dir, [work_dir] + opts.dirs)

          # if ks.cfg is detected, patch syslinux + grub to use it

          if "ks.cfg" in graft_points:

              log.info("Adding ks.cfg to boot configs")

@@ -665,7 +665,12 @@ 

          six.assertCountEqual(

              self,

              ggp.call_args_list,

-             [mock.call(self.compose, [os.path.join(self.topdir, x)]) for x in gp],

+             [

+                 mock.call(

+                     self.compose.paths.compose.topdir(), [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)
@@ -734,7 +739,12 @@ 

          six.assertCountEqual(

              self,

              ggp.call_args_list,

-             [mock.call(self.compose, [os.path.join(self.topdir, x)]) for x in gp],

+             [

+                 mock.call(

+                     self.compose.paths.compose.topdir(), [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)
@@ -799,7 +809,12 @@ 

          six.assertCountEqual(

              self,

              ggp.call_args_list,

-             [mock.call(self.compose, [os.path.join(self.topdir, x)]) for x in gp],

+             [

+                 mock.call(

+                     self.compose.paths.compose.topdir(), [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)
@@ -890,8 +905,13 @@ 

          six.assertCountEqual(

              self,

              ggp.call_args_list,

-             [mock.call(self.compose, [os.path.join(self.topdir, x)]) for x in gp]

-             + [mock.call(self.compose, [bi_dir, iso_dir])],

+             [

+                 mock.call(

+                     self.compose.paths.compose.topdir(), [os.path.join(self.topdir, x)]

+                 )

+                 for x in gp

+             ]

+             + [mock.call(self.compose.paths.compose.topdir(), [bi_dir, iso_dir])],

          )

          self.assertEqual(len(wgp.call_args_list), 1)

          self.assertEqual(wgp.call_args_list[0][0][0], gp_file)

These are the commits from #1438.

This is probably not the best solution but I tried to be non-invasive as much as possible.

rebased onto 981b69c

4 years ago

4 new commits added

  • Fix formatting
  • Adapt tests to a new get_graft_points() argument
  • Fix pungi-patch-iso to work with a new compose top dir solution
  • Don't use compose in get_graft_points
4 years ago

I actually like the solution. The change to get_graft_points is a nice improvement even if it didn't fix a bug. I just added another commit to adjust formatting to make Jenkins happy.

Pull-Request has been merged by lsedlar

4 years ago

Thanks a lot for merge and help with the Jenkins!