summaryrefslogtreecommitdiffstats
path: root/meta/lib/oe/rootfs.py
diff options
context:
space:
mode:
authorAlexander Kanavin <alexander.kanavin@linux.intel.com>2018-04-03 18:45:20 +0300
committerRichard Purdie <richard.purdie@linuxfoundation.org>2018-04-05 14:49:07 +0100
commitae661039394f3e056d02c7e1f1d79511d82cb99b (patch)
tree73b2632b263583c3232ac2a788446e827985ae9a /meta/lib/oe/rootfs.py
parent19cd7a1776df6610cf9721275d6ef69115f9426a (diff)
downloadpoky-ae661039394f3e056d02c7e1f1d79511d82cb99b.tar.gz
package_manager.py: move intercept running logic from rootfs class to PackageManager class
This allows running the intercepts when creating SDKs, which previously wasn't possible, as SDK code does not use the rootfs class, and calls into PackageManager methods directly. (From OE-Core rev: f830388c5e9125f385a42acd7365d1235967b57c) Signed-off-by: Alexander Kanavin <alexander.kanavin@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oe/rootfs.py')
-rw-r--r--meta/lib/oe/rootfs.py64
1 files changed, 1 insertions, 63 deletions
diff --git a/meta/lib/oe/rootfs.py b/meta/lib/oe/rootfs.py
index 600a685d68..f8f717c050 100644
--- a/meta/lib/oe/rootfs.py
+++ b/meta/lib/oe/rootfs.py
@@ -92,10 +92,6 @@ class Rootfs(object, metaclass=ABCMeta):
92 self.d.getVar('PACKAGE_FEED_ARCHS')) 92 self.d.getVar('PACKAGE_FEED_ARCHS'))
93 93
94 94
95 @abstractmethod
96 def _handle_intercept_failure(self, failed_script):
97 pass
98
99 """ 95 """
100 The _cleanup() method should be used to clean-up stuff that we don't really 96 The _cleanup() method should be used to clean-up stuff that we don't really
101 want to end up on target. For example, in the case of RPM, the DB locks. 97 want to end up on target. For example, in the case of RPM, the DB locks.
@@ -197,7 +193,7 @@ class Rootfs(object, metaclass=ABCMeta):
197 193
198 execute_pre_post_process(self.d, rootfs_post_install_cmds) 194 execute_pre_post_process(self.d, rootfs_post_install_cmds)
199 195
200 self._run_intercepts() 196 self.pm.run_intercepts()
201 197
202 execute_pre_post_process(self.d, post_process_cmds) 198 execute_pre_post_process(self.d, post_process_cmds)
203 199
@@ -283,50 +279,6 @@ class Rootfs(object, metaclass=ABCMeta):
283 # Remove the package manager data files 279 # Remove the package manager data files
284 self.pm.remove_packaging_data() 280 self.pm.remove_packaging_data()
285 281
286 def _postpone_to_first_boot(self, postinst_intercept_hook):
287 with open(postinst_intercept_hook) as intercept:
288 registered_pkgs = None
289 for line in intercept.read().split("\n"):
290 m = re.match("^##PKGS:(.*)", line)
291 if m is not None:
292 registered_pkgs = m.group(1).strip()
293 break
294
295 if registered_pkgs is not None:
296 bb.note("The postinstalls for the following packages "
297 "will be postponed for first boot: %s" %
298 registered_pkgs)
299
300 # call the backend dependent handler
301 self._handle_intercept_failure(registered_pkgs)
302
303
304 def _run_intercepts(self):
305 intercepts_dir = self.pm.intercepts_dir
306
307 bb.note("Running intercept scripts:")
308 os.environ['D'] = self.image_rootfs
309 os.environ['STAGING_DIR_NATIVE'] = self.d.getVar('STAGING_DIR_NATIVE')
310 for script in os.listdir(intercepts_dir):
311 script_full = os.path.join(intercepts_dir, script)
312
313 if script == "postinst_intercept" or not os.access(script_full, os.X_OK):
314 continue
315
316 if script == "delay_to_first_boot":
317 self._postpone_to_first_boot(script_full)
318 continue
319
320 bb.note("> Executing %s intercept ..." % script)
321
322 try:
323 output = subprocess.check_output(script_full, stderr=subprocess.STDOUT)
324 if output: bb.note(output.decode("utf-8"))
325 except subprocess.CalledProcessError as e:
326 bb.warn("The postinstall intercept hook '%s' failed, details in log.do_rootfs" % script)
327 bb.note("Exit code %d. Output:\n%s" % (e.returncode, e.output.decode("utf-8")))
328 self._postpone_to_first_boot(script_full)
329
330 def _run_ldconfig(self): 282 def _run_ldconfig(self):
331 if self.d.getVar('LDCONFIGDEPEND'): 283 if self.d.getVar('LDCONFIGDEPEND'):
332 bb.note("Executing: ldconfig -r" + self.image_rootfs + "-c new -v") 284 bb.note("Executing: ldconfig -r" + self.image_rootfs + "-c new -v")
@@ -519,14 +471,6 @@ class RpmRootfs(Rootfs):
519 self._log_check_warn() 471 self._log_check_warn()
520 self._log_check_error() 472 self._log_check_error()
521 473
522 def _handle_intercept_failure(self, registered_pkgs):
523 rpm_postinsts_dir = self.image_rootfs + self.d.expand('${sysconfdir}/rpm-postinsts/')
524 bb.utils.mkdirhier(rpm_postinsts_dir)
525
526 # Save the package postinstalls in /etc/rpm-postinsts
527 for pkg in registered_pkgs.split():
528 self.pm.save_rpmpostinst(pkg)
529
530 def _cleanup(self): 474 def _cleanup(self):
531 self.pm._invoke_dnf(["clean", "all"]) 475 self.pm._invoke_dnf(["clean", "all"])
532 476
@@ -707,9 +651,6 @@ class DpkgRootfs(DpkgOpkgRootfs):
707 src_postinst_dir = self.d.expand("${IMAGE_ROOTFS}/var/lib/dpkg/info") 651 src_postinst_dir = self.d.expand("${IMAGE_ROOTFS}/var/lib/dpkg/info")
708 return self._save_postinsts_common(dst_postinst_dir, src_postinst_dir) 652 return self._save_postinsts_common(dst_postinst_dir, src_postinst_dir)
709 653
710 def _handle_intercept_failure(self, registered_pkgs):
711 self.pm.mark_packages("unpacked", registered_pkgs.split())
712
713 def _log_check(self): 654 def _log_check(self):
714 self._log_check_warn() 655 self._log_check_warn()
715 self._log_check_error() 656 self._log_check_error()
@@ -978,9 +919,6 @@ class OpkgRootfs(DpkgOpkgRootfs):
978 src_postinst_dir = self.d.expand("${IMAGE_ROOTFS}${OPKGLIBDIR}/opkg/info") 919 src_postinst_dir = self.d.expand("${IMAGE_ROOTFS}${OPKGLIBDIR}/opkg/info")
979 return self._save_postinsts_common(dst_postinst_dir, src_postinst_dir) 920 return self._save_postinsts_common(dst_postinst_dir, src_postinst_dir)
980 921
981 def _handle_intercept_failure(self, registered_pkgs):
982 self.pm.mark_packages("unpacked", registered_pkgs.split())
983
984 def _log_check(self): 922 def _log_check(self):
985 self._log_check_warn() 923 self._log_check_warn()
986 self._log_check_error() 924 self._log_check_error()