def _create(self): pkgs_to_install = self.manifest.parse_initial_manifest() deb_pre_process_cmds = self.d.getVar('DEB_PREPROCESS_COMMANDS', True) deb_post_process_cmds = self.d.getVar('DEB_POSTPROCESS_COMMANDS', True) alt_dir = self.d.expand("${IMAGE_ROOTFS}/var/lib/dpkg/alternatives") bb.utils.mkdirhier(alt_dir) # update PM index files self.pm.write_index() execute_pre_post_process(self.d, deb_pre_process_cmds) self.pm.update() for pkg_type in self.install_order: if pkg_type in pkgs_to_install: self.pm.install(pkgs_to_install[pkg_type], [False, True][pkg_type == Manifest.PKG_TYPE_ATTEMPT_ONLY]) self.pm.install_complementary() self._setup_dbg_rootfs(['/var/lib/dpkg']) self.pm.fix_broken_dependencies() self.pm.mark_packages("installed") self.pm.run_pre_post_installs() execute_pre_post_process(self.d, deb_post_process_cmds)
def create(self): bb.note("###### Generate rootfs #######") pre_process_cmds = self.d.getVar("ROOTFS_PREPROCESS_COMMAND", True) post_process_cmds = self.d.getVar("ROOTFS_POSTPROCESS_COMMAND", True) postinst_intercepts_dir = self.d.getVar("POSTINST_INTERCEPTS_DIR", True) if not postinst_intercepts_dir: postinst_intercepts_dir = self.d.expand( "${COREBASE}/scripts/postinst-intercepts") intercepts_dir = os.path.join(self.d.getVar('WORKDIR', True), "intercept_scripts") bb.utils.remove(intercepts_dir, True) bb.utils.mkdirhier(self.image_rootfs) bb.utils.mkdirhier(self.deploy_dir_image) shutil.copytree(postinst_intercepts_dir, intercepts_dir) shutil.copy( self.d.expand("${COREBASE}/meta/files/deploydir_readme.txt"), self.deploy_dir_image + "/README_-_DO_NOT_DELETE_FILES_IN_THIS_DIRECTORY.txt") execute_pre_post_process(self.d, pre_process_cmds) # call the package manager dependent create method self._create() sysconfdir = self.image_rootfs + self.d.getVar('sysconfdir', True) bb.utils.mkdirhier(sysconfdir) with open(sysconfdir + "/version", "w+") as ver: ver.write(self.d.getVar('BUILDNAME', True) + "\n") self._run_intercepts() execute_pre_post_process(self.d, post_process_cmds) if bb.utils.contains("IMAGE_FEATURES", "read-only-rootfs", True, False, self.d): delayed_postinsts = self._get_delayed_postinsts() if delayed_postinsts is not None: bb.fatal("The following packages could not be configured " "offline and rootfs is read-only: %s" % delayed_postinsts) if self.d.getVar('USE_DEVFS', True) != "1": self._create_devfs() self._uninstall_uneeded() self._insert_feed_uris() self._run_ldconfig() self._generate_kernel_module_deps() self._cleanup()
def _uninstall_unneeded(self): # Remove unneeded init script symlinks delayed_postinsts = self._get_delayed_postinsts() if delayed_postinsts is None: if os.path.exists( self.d.expand( "${IMAGE_ROOTFS}${sysconfdir}/init.d/run-postinsts")): self._exec_shell_cmd([ "update-rc.d", "-f", "-r", self.d.getVar('IMAGE_ROOTFS', True), "run-postinsts", "remove" ]) runtime_pkgmanage = bb.utils.contains("IMAGE_FEATURES", "package-management", True, False, self.d) sysvcompat_in_distro = bb.utils.contains("DISTRO_FEATURES", ["systemd", "sysvinit"], True, False, self.d) image_rorfs = bb.utils.contains("IMAGE_FEATURES", "read-only-rootfs", True, False, self.d) if sysvcompat_in_distro and not image_rorfs: pkg_to_remove = "" else: pkg_to_remove = "update-rc.d" if not runtime_pkgmanage: # Remove components that we don't need if we're not going to install # additional packages at runtime if delayed_postinsts is None: installed_pkgs_dir = self.d.expand( '${WORKDIR}/installed_pkgs.txt') pkgs_to_remove = list() with open(installed_pkgs_dir, "r+") as installed_pkgs: pkgs_installed = installed_pkgs.read().splitlines() for pkg_installed in pkgs_installed[:]: pkg = pkg_installed.split()[0] if pkg in [ "update-rc.d", "base-passwd", "shadow", "update-alternatives", pkg_to_remove, self.d.getVar("ROOTFS_BOOTSTRAP_INSTALL", True) ]: pkgs_to_remove.append(pkg) pkgs_installed.remove(pkg_installed) if len(pkgs_to_remove) > 0: self.pm.remove(pkgs_to_remove, False) # Update installed_pkgs.txt open(installed_pkgs_dir, "w+").write('\n'.join(pkgs_installed)) else: self._save_postinsts() post_uninstall_cmds = self.d.getVar("ROOTFS_POSTUNINSTALL_COMMAND", True) execute_pre_post_process(self.d, post_uninstall_cmds) if not runtime_pkgmanage: # Remove the package manager data files self.pm.remove_packaging_data()
def _uninstall_unneeded(self): # Remove unneeded init script symlinks delayed_postinsts = self._get_delayed_postinsts() if delayed_postinsts is None: if os.path.exists(self.d.expand("${IMAGE_ROOTFS}${sysconfdir}/init.d/run-postinsts")): self._exec_shell_cmd(["update-rc.d", "-f", "-r", self.d.getVar('IMAGE_ROOTFS', True), "run-postinsts", "remove"]) image_rorfs = bb.utils.contains("IMAGE_FEATURES", "read-only-rootfs", True, False, self.d) if image_rorfs: # Remove components that we don't need if it's a read-only rootfs unneeded_pkgs = self.d.getVar("ROOTFS_RO_UNNEEDED", True).split() pkgs_installed = image_list_installed_packages(self.d) pkgs_to_remove = [pkg for pkg in pkgs_installed if pkg in unneeded_pkgs] if len(pkgs_to_remove) > 0: self.pm.remove(pkgs_to_remove, False) if delayed_postinsts: self._save_postinsts() if image_rorfs: bb.warn("There are post install scripts " "in a read-only rootfs") post_uninstall_cmds = self.d.getVar("ROOTFS_POSTUNINSTALL_COMMAND", True) execute_pre_post_process(self.d, post_uninstall_cmds) runtime_pkgmanage = bb.utils.contains("IMAGE_FEATURES", "package-management", True, False, self.d) if not runtime_pkgmanage: # Remove the package manager data files self.pm.remove_packaging_data()
def populate(self): self.mkdirhier(self.sdk_output) # call backend dependent implementation self._populate() # Don't ship any libGL in the SDK self.remove( os.path.join(self.sdk_output, self.sdk_native_path, self.d.getVar('libdir_nativesdk', True).strip('/'), "libGL*")) # Fix or remove broken .la files self.remove( os.path.join(self.sdk_output, self.sdk_native_path, self.d.getVar('libdir_nativesdk', True).strip('/'), "*.la")) # Link the ld.so.cache file into the hosts filesystem link_name = os.path.join(self.sdk_output, self.sdk_native_path, self.sysconfdir, "ld.so.cache") self.mkdirhier(os.path.dirname(link_name)) os.symlink("/etc/ld.so.cache", link_name) execute_pre_post_process( self.d, self.d.getVar('SDK_POSTPROCESS_COMMAND', True))
def _populate(self): bb.note("Installing TARGET packages") self._populate_sysroot(self.target_pm, self.target_manifest) self.target_pm.install_complementary(self.d.getVar('SDKIMAGE_INSTALL_COMPLEMENTARY')) execute_pre_post_process(self.d, self.d.getVar("POPULATE_SDK_POST_TARGET_COMMAND")) self._copy_apt_dir_to(os.path.join(self.sdk_target_sysroot, "etc", "apt")) if not bb.utils.contains("SDKIMAGE_FEATURES", "package-management", True, False, self.d): self.target_pm.remove_packaging_data() bb.note("Installing NATIVESDK packages") self._populate_sysroot(self.host_pm, self.host_manifest) execute_pre_post_process(self.d, self.d.getVar("POPULATE_SDK_POST_HOST_COMMAND")) self._copy_apt_dir_to(os.path.join(self.sdk_output, self.sdk_native_path, "etc", "apt")) if not bb.utils.contains("SDKIMAGE_FEATURES", "package-management", True, False, self.d): self.host_pm.remove_packaging_data() native_dpkg_state_dir = os.path.join(self.sdk_output, self.sdk_native_path, "var", "lib", "dpkg") self.mkdirhier(native_dpkg_state_dir) for f in glob.glob(os.path.join(self.sdk_output, "var", "lib", "dpkg", "*")): self.movefile(f, native_dpkg_state_dir) self.remove(os.path.join(self.sdk_output, "var"), True)
def _populate(self): bb.note("Installing TARGET packages") self._populate_sysroot(self.target_pm, self.target_manifest) self.target_pm.install_complementary(self.d.getVar('SDKIMAGE_INSTALL_COMPLEMENTARY', True)) execute_pre_post_process(self.d, self.d.getVar("POPULATE_SDK_POST_TARGET_COMMAND", True)) bb.note("Installing NATIVESDK packages") self._populate_sysroot(self.host_pm, self.host_manifest) execute_pre_post_process(self.d, self.d.getVar("POPULATE_SDK_POST_HOST_COMMAND", True)) target_sysconfdir = os.path.join(self.sdk_target_sysroot, self.sysconfdir) host_sysconfdir = os.path.join(self.sdk_host_sysroot, self.sysconfdir) bb.utils.mkdirhier(target_sysconfdir) shutil.copy(self.target_conf, target_sysconfdir) os.chmod(os.path.join(target_sysconfdir, os.path.basename(self.target_conf)), 0644) bb.utils.mkdirhier(host_sysconfdir) shutil.copy(self.host_conf, host_sysconfdir) os.chmod(os.path.join(host_sysconfdir, os.path.basename(self.host_conf)), 0644) native_opkg_state_dir = os.path.join(self.sdk_output, self.sdk_native_path, self.d.getVar('localstatedir_nativesdk', True).strip('/'), "lib", "opkg") bb.utils.mkdirhier(native_opkg_state_dir) for f in glob.glob(os.path.join(self.sdk_output, "var", "lib", "opkg", "*")): bb.utils.movefile(f, native_opkg_state_dir) bb.utils.remove(os.path.join(self.sdk_output, "var"), True)
def _create(self): pkgs_to_install = self.manifest.parse_initial_manifest() rpm_pre_process_cmds = self.d.getVar('RPM_PREPROCESS_COMMANDS', True) rpm_post_process_cmds = self.d.getVar('RPM_POSTPROCESS_COMMANDS', True) # update PM index files self.pm.write_index() execute_pre_post_process(self.d, rpm_pre_process_cmds) if self.progress_reporter: self.progress_reporter.next_stage() self.pm.dump_all_available_pkgs() if self.inc_rpm_image_gen == "1": self._create_incremental(pkgs_to_install) if self.progress_reporter: self.progress_reporter.next_stage() self.pm.update() pkgs = [] pkgs_attempt = [] for pkg_type in pkgs_to_install: if pkg_type == Manifest.PKG_TYPE_ATTEMPT_ONLY: pkgs_attempt += pkgs_to_install[pkg_type] else: pkgs += pkgs_to_install[pkg_type] if self.progress_reporter: self.progress_reporter.next_stage() self.pm.install(pkgs) if self.progress_reporter: self.progress_reporter.next_stage() self.pm.install(pkgs_attempt, True) if self.progress_reporter: self.progress_reporter.next_stage() self.pm.install_complementary() if self.progress_reporter: self.progress_reporter.next_stage() self._setup_dbg_rootfs(['/etc/rpm', '/var/lib/rpm', '/var/lib/smart']) execute_pre_post_process(self.d, rpm_post_process_cmds) if self.inc_rpm_image_gen == "1": self.pm.backup_packaging_data() self.pm.rpm_setup_smart_target_config() if self.progress_reporter: self.progress_reporter.next_stage()
def _create(self): pkgs_to_install = self.manifest.parse_initial_manifest() rpm_pre_process_cmds = self.d.getVar('RPM_PREPROCESS_COMMANDS') rpm_post_process_cmds = self.d.getVar('RPM_POSTPROCESS_COMMANDS') # update PM index files self.pm.write_index() execute_pre_post_process(self.d, rpm_pre_process_cmds) if self.progress_reporter: self.progress_reporter.next_stage() self.pm.dump_all_available_pkgs() if self.inc_rpm_image_gen == "1": self._create_incremental(pkgs_to_install) if self.progress_reporter: self.progress_reporter.next_stage() self.pm.update() pkgs = [] pkgs_attempt = [] for pkg_type in pkgs_to_install: if pkg_type == Manifest.PKG_TYPE_ATTEMPT_ONLY: pkgs_attempt += pkgs_to_install[pkg_type] else: pkgs += pkgs_to_install[pkg_type] if self.progress_reporter: self.progress_reporter.next_stage() self.pm.install(pkgs) if self.progress_reporter: self.progress_reporter.next_stage() self.pm.install(pkgs_attempt, True) if self.progress_reporter: self.progress_reporter.next_stage() self.pm.install_complementary() if self.progress_reporter: self.progress_reporter.next_stage() self._setup_dbg_rootfs(['/etc/rpm', '/var/lib/rpm', '/var/lib/smart']) execute_pre_post_process(self.d, rpm_post_process_cmds) if self.inc_rpm_image_gen == "1": self.pm.backup_packaging_data() self.pm.rpm_setup_smart_target_config() if self.progress_reporter: self.progress_reporter.next_stage()
def _create(self): pkgs_to_install = self.manifest.parse_initial_manifest() opkg_pre_process_cmds = self.d.getVar('OPKG_PREPROCESS_COMMANDS') opkg_post_process_cmds = self.d.getVar('OPKG_POSTPROCESS_COMMANDS') # update PM index files, unless users provide their own feeds if (self.d.getVar('BUILD_IMAGES_FROM_FEEDS') or "") != "1": self.pm.write_index() execute_pre_post_process(self.d, opkg_pre_process_cmds) if self.progress_reporter: self.progress_reporter.next_stage() # Steps are a bit different in order, skip next self.progress_reporter.next_stage() self.pm.update() self.pm.handle_bad_recommendations() if self.progress_reporter: self.progress_reporter.next_stage() if self.inc_opkg_image_gen == "1": self._remove_extra_packages(pkgs_to_install) if self.progress_reporter: self.progress_reporter.next_stage() for pkg_type in self.install_order: if pkg_type in pkgs_to_install: # For multilib, we perform a sanity test before final install # If sanity test fails, it will automatically do a bb.fatal() # and the installation will stop if pkg_type == Manifest.PKG_TYPE_MULTILIB: self._multilib_test_install(pkgs_to_install[pkg_type]) self.pm.install(pkgs_to_install[pkg_type], [False, True ][pkg_type == Manifest.PKG_TYPE_ATTEMPT_ONLY]) if self.progress_reporter: self.progress_reporter.next_stage() self.pm.install_complementary() if self.progress_reporter: self.progress_reporter.next_stage() opkg_lib_dir = self.d.getVar('OPKGLIBDIR') opkg_dir = os.path.join(opkg_lib_dir, 'opkg') self._setup_dbg_rootfs([opkg_dir]) execute_pre_post_process(self.d, opkg_post_process_cmds) if self.inc_opkg_image_gen == "1": self.pm.backup_packaging_data() if self.progress_reporter: self.progress_reporter.next_stage()
def _populate(self): bb.note("Installing TARGET packages") self._populate_sysroot(self.target_pm, self.target_manifest) self.target_pm.install_complementary( self.d.getVar('SDKIMAGE_INSTALL_COMPLEMENTARY', True)) execute_pre_post_process( self.d, self.d.getVar("POPULATE_SDK_POST_TARGET_COMMAND", True)) self._copy_apt_dir_to( os.path.join(self.sdk_target_sysroot, "etc", "apt")) bb.note("Installing NATIVESDK packages") self._populate_sysroot(self.host_pm, self.host_manifest) execute_pre_post_process( self.d, self.d.getVar("POPULATE_SDK_POST_HOST_COMMAND", True)) self._copy_apt_dir_to( os.path.join(self.sdk_output, self.sdk_native_path, "etc", "apt")) native_dpkg_state_dir = os.path.join(self.sdk_output, self.sdk_native_path, "var", "lib", "dpkg") bb.utils.mkdirhier(native_dpkg_state_dir) for f in glob.glob( os.path.join(self.sdk_output, "var", "lib", "dpkg", "*")): bb.utils.movefile(f, native_dpkg_state_dir) bb.utils.remove(os.path.join(self.sdk_output, "var"), True)
def create(self): bb.note("###### Generate images #######") pre_process_cmds = self.d.getVar("IMAGE_PREPROCESS_COMMAND", True) post_process_cmds = self.d.getVar("IMAGE_POSTPROCESS_COMMAND", True) execute_pre_post_process(self.d, pre_process_cmds) self._remove_old_symlinks() image_cmd_groups = self._get_imagecmds() for image_cmds in image_cmd_groups: # create the images in parallel nproc = multiprocessing.cpu_count() pool = bb.utils.multiprocessingpool(nproc) results = list(pool.imap(generate_image, image_cmds)) pool.close() pool.join() for result in results: if result is not None: bb.fatal(result) for image_type, subimages, script in image_cmds: bb.note("Creating symlinks for %s image ..." % image_type) self._create_symlinks(subimages) execute_pre_post_process(self.d, post_process_cmds)
def create(self): bb.note("###### Generate rootfs #######") pre_process_cmds = self.d.getVar("ROOTFS_PREPROCESS_COMMAND", True) post_process_cmds = self.d.getVar("ROOTFS_POSTPROCESS_COMMAND", True) postinst_intercepts_dir = self.d.getVar("POSTINST_INTERCEPTS_DIR", True) if not postinst_intercepts_dir: postinst_intercepts_dir = self.d.expand("${COREBASE}/scripts/postinst-intercepts") intercepts_dir = os.path.join(self.d.getVar('WORKDIR', True), "intercept_scripts") bb.utils.remove(intercepts_dir, True) bb.utils.mkdirhier(self.image_rootfs) bb.utils.mkdirhier(self.deploy_dir_image) shutil.copytree(postinst_intercepts_dir, intercepts_dir) shutil.copy(self.d.expand("${COREBASE}/meta/files/deploydir_readme.txt"), self.deploy_dir_image + "/README_-_DO_NOT_DELETE_FILES_IN_THIS_DIRECTORY.txt") execute_pre_post_process(self.d, pre_process_cmds) # call the package manager dependent create method self._create() sysconfdir = self.image_rootfs + self.d.getVar('sysconfdir', True) bb.utils.mkdirhier(sysconfdir) with open(sysconfdir + "/version", "w+") as ver: ver.write(self.d.getVar('BUILDNAME', True) + "\n") self._run_intercepts() execute_pre_post_process(self.d, post_process_cmds) if bb.utils.contains("IMAGE_FEATURES", "read-only-rootfs", True, False, self.d): delayed_postinsts = self._get_delayed_postinsts() if delayed_postinsts is not None: bb.fatal("The following packages could not be configured " "offline and rootfs is read-only: %s" % delayed_postinsts) if self.d.getVar('USE_DEVFS', True) != "1": self._create_devfs() self._uninstall_unneeded() self._insert_feed_uris() self._run_ldconfig() if self.d.getVar('USE_DEPMOD', True) != "0": self._generate_kernel_module_deps() self._cleanup() self._log_check()
def _create(self): pkgs_to_install = self.manifest.parse_initial_manifest() opkg_pre_process_cmds = self.d.getVar('OPKG_PREPROCESS_COMMANDS') opkg_post_process_cmds = self.d.getVar('OPKG_POSTPROCESS_COMMANDS') # update PM index files, unless users provide their own feeds if (self.d.getVar('BUILD_IMAGES_FROM_FEEDS') or "") != "1": self.pm.write_index() execute_pre_post_process(self.d, opkg_pre_process_cmds) if self.progress_reporter: self.progress_reporter.next_stage() # Steps are a bit different in order, skip next self.progress_reporter.next_stage() self.pm.update() self.pm.handle_bad_recommendations() if self.progress_reporter: self.progress_reporter.next_stage() if self.inc_opkg_image_gen == "1": self._remove_extra_packages(pkgs_to_install) if self.progress_reporter: self.progress_reporter.next_stage() for pkg_type in self.install_order: if pkg_type in pkgs_to_install: # For multilib, we perform a sanity test before final install # If sanity test fails, it will automatically do a bb.fatal() # and the installation will stop if pkg_type == Manifest.PKG_TYPE_MULTILIB: self._multilib_test_install(pkgs_to_install[pkg_type]) self.pm.install(pkgs_to_install[pkg_type], [False, True][pkg_type == Manifest.PKG_TYPE_ATTEMPT_ONLY]) if self.progress_reporter: self.progress_reporter.next_stage() self.pm.install_complementary() if self.progress_reporter: self.progress_reporter.next_stage() opkg_lib_dir = self.d.getVar('OPKGLIBDIR') opkg_dir = os.path.join(opkg_lib_dir, 'opkg') self._setup_dbg_rootfs([opkg_dir]) execute_pre_post_process(self.d, opkg_post_process_cmds) if self.inc_opkg_image_gen == "1": self.pm.backup_packaging_data() if self.progress_reporter: self.progress_reporter.next_stage()
def create(self): bb.note("###### Generate images #######") pre_process_cmds = self.d.getVar("IMAGE_PREPROCESS_COMMAND", True) post_process_cmds = self.d.getVar("IMAGE_POSTPROCESS_COMMAND", True) execute_pre_post_process(self.d, pre_process_cmds) self._remove_old_symlinks() image_cmd_groups = self._get_imagecmds() # Process the debug filesystem... debugfs_d = bb.data.createCopy(self.d) if self.d.getVar('IMAGE_GEN_DEBUGFS', True) == "1": bb.note("Processing debugfs image(s) ...") orig_d = self.d self.d = debugfs_d self.d.setVar('IMAGE_ROOTFS', orig_d.getVar('IMAGE_ROOTFS', True) + '-dbg') self.d.setVar('IMAGE_NAME', orig_d.getVar('IMAGE_NAME', True) + '-dbg') self.d.setVar('IMAGE_LINK_NAME', orig_d.getVar('IMAGE_LINK_NAME', True) + '-dbg') debugfs_image_fstypes = orig_d.getVar('IMAGE_FSTYPES_DEBUGFS', True) if debugfs_image_fstypes: self.d.setVar('IMAGE_FSTYPES', orig_d.getVar('IMAGE_FSTYPES_DEBUGFS', True)) self._remove_old_symlinks() image_cmd_groups += self._get_imagecmds("debugfs.") self.d = orig_d self._write_wic_env() for image_cmds in image_cmd_groups: # create the images in parallel nproc = multiprocessing.cpu_count() pool = bb.utils.multiprocessingpool(nproc) results = list(pool.imap(generate_image, image_cmds)) pool.close() pool.join() for result in results: if result is not None: bb.fatal(result) for image_type, subimages, script, sprefix in image_cmds: if sprefix == 'debugfs.': bb.note("Creating symlinks for %s debugfs image ..." % image_type) orig_d = self.d self.d = debugfs_d self._create_symlinks(subimages) self.d = orig_d else: bb.note("Creating symlinks for %s image ..." % image_type) self._create_symlinks(subimages) execute_pre_post_process(self.d, post_process_cmds)
def _uninstall_unneeded(self): # Remove the run-postinsts package if no delayed postinsts are found delayed_postinsts = self._get_delayed_postinsts() if delayed_postinsts is None: if os.path.exists( self.d.expand( "${IMAGE_ROOTFS}${sysconfdir}/init.d/run-postinsts") ) or os.path.exists( self.d.expand( "${IMAGE_ROOTFS}${systemd_unitdir}/system/run-postinsts.service" )): self.pm.remove(["run-postinsts"]) image_rorfs = bb.utils.contains("IMAGE_FEATURES", "read-only-rootfs", True, False, self.d) image_rorfs_force = self.d.getVar('FORCE_RO_REMOVE') if image_rorfs or image_rorfs_force == "1": # Remove components that we don't need if it's a read-only rootfs unneeded_pkgs = self.d.getVar("ROOTFS_RO_UNNEEDED").split() pkgs_installed = image_list_installed_packages(self.d) # Make sure update-alternatives is removed last. This is # because its database has to available while uninstalling # other packages, allowing alternative symlinks of packages # to be uninstalled or to be managed correctly otherwise. provider = self.d.getVar("VIRTUAL-RUNTIME_update-alternatives") pkgs_to_remove = sorted( [pkg for pkg in pkgs_installed if pkg in unneeded_pkgs], key=lambda x: x == provider) # update-alternatives provider is removed in its own remove() # call because all package managers do not guarantee the packages # are removed in the order they given in the list (which is # passed to the command line). The sorting done earlier is # utilized to implement the 2-stage removal. if len(pkgs_to_remove) > 1: self.pm.remove(pkgs_to_remove[:-1], False) if len(pkgs_to_remove) > 0: self.pm.remove([pkgs_to_remove[-1]], False) if delayed_postinsts: self._save_postinsts() if image_rorfs: bb.warn("There are post install scripts " "in a read-only rootfs") post_uninstall_cmds = self.d.getVar("ROOTFS_POSTUNINSTALL_COMMAND") execute_pre_post_process(self.d, post_uninstall_cmds) runtime_pkgmanage = bb.utils.contains("IMAGE_FEATURES", "package-management", True, False, self.d) if not runtime_pkgmanage: # Remove the package manager data files self.pm.remove_packaging_data()
def _uninstall_unneeded(self): # Remove unneeded init script symlinks delayed_postinsts = self._get_delayed_postinsts() if delayed_postinsts is None: if os.path.exists( self.d.expand( "${IMAGE_ROOTFS}${sysconfdir}/init.d/run-postinsts")): self._exec_shell_cmd([ "update-rc.d", "-f", "-r", self.d.getVar('IMAGE_ROOTFS', True), "run-postinsts", "remove" ]) runtime_pkgmanage = bb.utils.contains("IMAGE_FEATURES", "package-management", True, False, self.d) sysvcompat_in_distro = bb.utils.contains("DISTRO_FEATURES", ["systemd", "sysvinit"], True, False, self.d) image_rorfs = bb.utils.contains("IMAGE_FEATURES", "read-only-rootfs", True, False, self.d) if sysvcompat_in_distro and not image_rorfs: pkg_to_remove = "" else: pkg_to_remove = "update-rc.d" if image_rorfs: # Remove components that we don't need if it's a read-only rootfs pkgs_installed = image_list_installed_packages(self.d) pkgs_to_remove = list() for pkg in pkgs_installed: if pkg in [ "update-rc.d", "base-passwd", "shadow", "update-alternatives", pkg_to_remove, self.d.getVar("ROOTFS_BOOTSTRAP_INSTALL", True) ]: pkgs_to_remove.append(pkg) if len(pkgs_to_remove) > 0: self.pm.remove(pkgs_to_remove, False) if delayed_postinsts: self._save_postinsts() if image_rorfs: bb.warn("There are post install scripts " "in a read-only rootfs") post_uninstall_cmds = self.d.getVar("ROOTFS_POSTUNINSTALL_COMMAND", True) execute_pre_post_process(self.d, post_uninstall_cmds) if not runtime_pkgmanage: # Remove the package manager data files self.pm.remove_packaging_data()
def _uninstall_unneeded(self): # Remove unneeded init script symlinks delayed_postinsts = self._get_delayed_postinsts() if delayed_postinsts is None: if os.path.exists(self.d.expand("${IMAGE_ROOTFS}${sysconfdir}/init.d/run-postinsts")): self._exec_shell_cmd(["update-rc.d", "-f", "-r", self.d.getVar('IMAGE_ROOTFS', True), "run-postinsts", "remove"]) runtime_pkgmanage = bb.utils.contains("IMAGE_FEATURES", "package-management", True, False, self.d) sysvcompat_in_distro = bb.utils.contains("DISTRO_FEATURES", [ "systemd", "sysvinit" ], True, False, self.d) image_rorfs = bb.utils.contains("IMAGE_FEATURES", "read-only-rootfs", True, False, self.d) if sysvcompat_in_distro and not image_rorfs: pkg_to_remove = "" else: pkg_to_remove = "update-rc.d" if not runtime_pkgmanage: # Remove components that we don't need if we're not going to install # additional packages at runtime if delayed_postinsts is None: installed_pkgs_dir = self.d.expand('${WORKDIR}/installed_pkgs.txt') pkgs_to_remove = list() with open(installed_pkgs_dir, "r+") as installed_pkgs: pkgs_installed = installed_pkgs.read().splitlines() for pkg_installed in pkgs_installed[:]: pkg = pkg_installed.split()[0] if pkg in ["update-rc.d", "base-passwd", "shadow", "update-alternatives", pkg_to_remove, self.d.getVar("ROOTFS_BOOTSTRAP_INSTALL", True) ]: pkgs_to_remove.append(pkg) pkgs_installed.remove(pkg_installed) if len(pkgs_to_remove) > 0: self.pm.remove(pkgs_to_remove, False) # Update installed_pkgs.txt open(installed_pkgs_dir, "w+").write('\n'.join(pkgs_installed)) else: self._save_postinsts() post_uninstall_cmds = self.d.getVar("ROOTFS_POSTUNINSTALL_COMMAND", True) execute_pre_post_process(self.d, post_uninstall_cmds) if not runtime_pkgmanage: # Remove the package manager data files self.pm.remove_packaging_data()
def populate(self): bb.utils.mkdirhier(self.sdk_output) # call backend dependent implementation self._populate() # Don't ship any libGL in the SDK bb.utils.remove( os.path.join(self.sdk_output, self.sdk_native_path, self.d.getVar('libdir_nativesdk', True).strip('/'), "libGL*")) # Fix or remove broken .la files bb.utils.remove( os.path.join(self.sdk_output, self.sdk_native_path, self.d.getVar('libdir_nativesdk', True).strip('/'), "*.la")) # Remove any broken links in sdk target sysroot bb.note("SDK scanning Link in %s" % self.sdk_target_sysroot) lnk_pths = [] for root, dirs, files in os.walk(self.sdk_target_sysroot): lnk_pths += [ os.path.join(root, d) for d in dirs if os.path.islink(os.path.join(root, d)) ] lnk_pths += [ os.path.join(root, f) for f in files if os.path.islink(os.path.join(root, f)) ] for lnk in lnk_pths: try: os.stat(lnk) except OSError: bb.note("SDK Broken Link Removing: %s -> %s" % (lnk, os.readlink(lnk))) os.unlink(lnk) pass # Link the ld.so.cache file into the hosts filesystem link_name = os.path.join(self.sdk_output, self.sdk_native_path, self.sysconfdir, "ld.so.cache") bb.utils.mkdirhier(os.path.dirname(link_name)) os.symlink("/etc/ld.so.cache", link_name) execute_pre_post_process( self.d, self.d.getVar('SDK_POSTPROCESS_COMMAND', True))
def _uninstall_unneeded(self): # Remove unneeded init script symlinks delayed_postinsts = self._get_delayed_postinsts() if delayed_postinsts is None: if os.path.exists(self.d.expand("${IMAGE_ROOTFS}${sysconfdir}/init.d/run-postinsts")): self._exec_shell_cmd(["update-rc.d", "-f", "-r", self.d.getVar('IMAGE_ROOTFS'), "run-postinsts", "remove"]) image_rorfs = bb.utils.contains("IMAGE_FEATURES", "read-only-rootfs", True, False, self.d) image_rorfs_force = self.d.getVar('FORCE_RO_REMOVE') if image_rorfs or image_rorfs_force == "1": # Remove components that we don't need if it's a read-only rootfs unneeded_pkgs = self.d.getVar("ROOTFS_RO_UNNEEDED").split() pkgs_installed = image_list_installed_packages(self.d) # Make sure update-alternatives is removed last. This is # because its database has to available while uninstalling # other packages, allowing alternative symlinks of packages # to be uninstalled or to be managed correctly otherwise. provider = self.d.getVar("VIRTUAL-RUNTIME_update-alternatives") pkgs_to_remove = sorted([pkg for pkg in pkgs_installed if pkg in unneeded_pkgs], key=lambda x: x == provider) # update-alternatives provider is removed in its own remove() # call because all package managers do not guarantee the packages # are removed in the order they given in the list (which is # passed to the command line). The sorting done earlier is # utilized to implement the 2-stage removal. if len(pkgs_to_remove) > 1: self.pm.remove(pkgs_to_remove[:-1], False) if len(pkgs_to_remove) > 0: self.pm.remove([pkgs_to_remove[-1]], False) if delayed_postinsts: self._save_postinsts() if image_rorfs: bb.warn("There are post install scripts " "in a read-only rootfs") post_uninstall_cmds = self.d.getVar("ROOTFS_POSTUNINSTALL_COMMAND") execute_pre_post_process(self.d, post_uninstall_cmds) runtime_pkgmanage = bb.utils.contains("IMAGE_FEATURES", "package-management", True, False, self.d) if not runtime_pkgmanage: # Remove the package manager data files self.pm.remove_packaging_data()
def _populate(self): bb.note("Installing TARGET packages") self._populate_sysroot(self.target_pm, self.target_manifest) self.target_pm.install_complementary(self.d.getVar('SDKIMAGE_INSTALL_COMPLEMENTARY')) execute_pre_post_process(self.d, self.d.getVar("POPULATE_SDK_POST_TARGET_COMMAND")) if not bb.utils.contains("SDKIMAGE_FEATURES", "package-management", True, False, self.d): self.target_pm.remove_packaging_data() bb.note("Installing NATIVESDK packages") self._populate_sysroot(self.host_pm, self.host_manifest) execute_pre_post_process(self.d, self.d.getVar("POPULATE_SDK_POST_HOST_COMMAND")) if not bb.utils.contains("SDKIMAGE_FEATURES", "package-management", True, False, self.d): self.host_pm.remove_packaging_data() # Move host RPM library data native_rpm_state_dir = os.path.join(self.sdk_output, self.sdk_native_path, self.d.getVar('localstatedir_nativesdk').strip('/'), "lib", "rpm" ) self.mkdirhier(native_rpm_state_dir) for f in glob.glob(os.path.join(self.sdk_output, "var", "lib", "rpm", "*")): self.movefile(f, native_rpm_state_dir) self.remove(os.path.join(self.sdk_output, "var"), True) # Move host sysconfig data native_sysconf_dir = os.path.join(self.sdk_output, self.sdk_native_path, self.d.getVar('sysconfdir', True).strip('/'), ) self.mkdirhier(native_sysconf_dir) for f in glob.glob(os.path.join(self.sdk_output, "etc", "rpm*")): self.movefile(f, native_sysconf_dir) for f in glob.glob(os.path.join(self.sdk_output, "etc", "dnf", "*")): self.movefile(f, native_sysconf_dir) self.remove(os.path.join(self.sdk_output, "etc"), True)
def _uninstall_unneeded(self): # Remove unneeded init script symlinks delayed_postinsts = self._get_delayed_postinsts() if delayed_postinsts is None: if os.path.exists( self.d.expand( "${IMAGE_ROOTFS}${sysconfdir}/init.d/run-postinsts")): self._exec_shell_cmd([ "update-rc.d", "-f", "-r", self.d.getVar('IMAGE_ROOTFS'), "run-postinsts", "remove" ]) image_rorfs = bb.utils.contains("IMAGE_FEATURES", "read-only-rootfs", True, False, self.d) image_rorfs_force = self.d.getVar('FORCE_RO_REMOVE') if image_rorfs or image_rorfs_force == "1": # Remove components that we don't need if it's a read-only rootfs unneeded_pkgs = self.d.getVar("ROOTFS_RO_UNNEEDED").split() pkgs_installed = image_list_installed_packages(self.d) # Make sure update-alternatives is last on the command line, so # that it is removed last. This makes sure that its database is # available while uninstalling packages, allowing alternative # symlinks of packages to be uninstalled to be managed correctly. provider = self.d.getVar("VIRTUAL-RUNTIME_update-alternatives") pkgs_to_remove = sorted( [pkg for pkg in pkgs_installed if pkg in unneeded_pkgs], key=lambda x: x == provider) if len(pkgs_to_remove) > 0: self.pm.remove(pkgs_to_remove, False) if delayed_postinsts: self._save_postinsts() if image_rorfs: bb.warn("There are post install scripts " "in a read-only rootfs") post_uninstall_cmds = self.d.getVar("ROOTFS_POSTUNINSTALL_COMMAND") execute_pre_post_process(self.d, post_uninstall_cmds) runtime_pkgmanage = bb.utils.contains("IMAGE_FEATURES", "package-management", True, False, self.d) if not runtime_pkgmanage: # Remove the package manager data files self.pm.remove_packaging_data()
def _populate(self): bb.note("Installing TARGET packages") self._populate_sysroot(self.target_pm, self.target_manifest) self.target_pm.install_complementary( self.d.getVar('SDKIMAGE_INSTALL_COMPLEMENTARY')) execute_pre_post_process( self.d, self.d.getVar("POPULATE_SDK_POST_TARGET_COMMAND")) if not bb.utils.contains("SDKIMAGE_FEATURES", "package-management", True, False, self.d): self.target_pm.remove_packaging_data() bb.note("Installing NATIVESDK packages") self._populate_sysroot(self.host_pm, self.host_manifest) execute_pre_post_process( self.d, self.d.getVar("POPULATE_SDK_POST_HOST_COMMAND")) if not bb.utils.contains("SDKIMAGE_FEATURES", "package-management", True, False, self.d): self.host_pm.remove_packaging_data() # Move host RPM library data native_rpm_state_dir = os.path.join( self.sdk_output, self.sdk_native_path, self.d.getVar('localstatedir_nativesdk').strip('/'), "lib", "rpm") self.mkdirhier(native_rpm_state_dir) for f in glob.glob( os.path.join(self.sdk_output, "var", "lib", "rpm", "*")): self.movefile(f, native_rpm_state_dir) self.remove(os.path.join(self.sdk_output, "var"), True) # Move host sysconfig data native_sysconf_dir = os.path.join( self.sdk_output, self.sdk_native_path, self.d.getVar('sysconfdir', True).strip('/'), ) self.mkdirhier(native_sysconf_dir) for f in glob.glob(os.path.join(self.sdk_output, "etc", "rpm*")): self.movefile(f, native_sysconf_dir) for f in glob.glob(os.path.join(self.sdk_output, "etc", "dnf", "*")): self.movefile(f, native_sysconf_dir) self.remove(os.path.join(self.sdk_output, "etc"), True)
def _uninstall_unneeded(self): # Remove unneeded init script symlinks delayed_postinsts = self._get_delayed_postinsts() if delayed_postinsts is None: if os.path.exists(self.d.expand("${IMAGE_ROOTFS}${sysconfdir}/init.d/run-postinsts")): self._exec_shell_cmd(["update-rc.d", "-f", "-r", self.d.getVar('IMAGE_ROOTFS', True), "run-postinsts", "remove"]) runtime_pkgmanage = bb.utils.contains("IMAGE_FEATURES", "package-management", True, False, self.d) sysvcompat_in_distro = bb.utils.contains("DISTRO_FEATURES", [ "systemd", "sysvinit" ], True, False, self.d) image_rorfs = bb.utils.contains("IMAGE_FEATURES", "read-only-rootfs", True, False, self.d) if sysvcompat_in_distro and not image_rorfs: pkg_to_remove = "" else: pkg_to_remove = "update-rc.d" if image_rorfs: # Remove components that we don't need if it's a read-only rootfs pkgs_installed = image_list_installed_packages(self.d) pkgs_to_remove = list() for pkg in pkgs_installed: if pkg in ["update-rc.d", "base-passwd", "shadow", "update-alternatives", pkg_to_remove, self.d.getVar("ROOTFS_BOOTSTRAP_INSTALL", True) ]: pkgs_to_remove.append(pkg) if len(pkgs_to_remove) > 0: self.pm.remove(pkgs_to_remove, False) if delayed_postinsts: self._save_postinsts() if image_rorfs: bb.warn("There are post install scripts " "in a read-only rootfs") post_uninstall_cmds = self.d.getVar("ROOTFS_POSTUNINSTALL_COMMAND", True) execute_pre_post_process(self.d, post_uninstall_cmds) if not runtime_pkgmanage: # Remove the package manager data files self.pm.remove_packaging_data()
def populate(self): bb.utils.mkdirhier(self.sdk_output) # call backend dependent implementation self._populate() # Don't ship any libGL in the SDK bb.utils.remove( os.path.join( self.sdk_output, self.sdk_native_path, self.d.getVar("libdir_nativesdk", True).strip("/"), "libGL*" ) ) # Fix or remove broken .la files bb.utils.remove( os.path.join( self.sdk_output, self.sdk_native_path, self.d.getVar("libdir_nativesdk", True).strip("/"), "*.la" ) ) # Remove any broken links in sdk target sysroot bb.note("SDK scanning Link in %s" % self.sdk_target_sysroot) lnk_pths = [] for root, dirs, files in os.walk(self.sdk_target_sysroot): lnk_pths += [os.path.join(root, d) for d in dirs if os.path.islink(os.path.join(root, d))] lnk_pths += [os.path.join(root, f) for f in files if os.path.islink(os.path.join(root, f))] for lnk in lnk_pths: try: os.stat(lnk) except OSError: bb.note("SDK Broken Link Removing: %s -> %s" % (lnk, os.readlink(lnk))) os.unlink(lnk) pass # Link the ld.so.cache file into the hosts filesystem link_name = os.path.join(self.sdk_output, self.sdk_native_path, self.sysconfdir, "ld.so.cache") bb.utils.mkdirhier(os.path.dirname(link_name)) os.symlink("/etc/ld.so.cache", link_name) execute_pre_post_process(self.d, self.d.getVar("SDK_POSTPROCESS_COMMAND", True))
def _populate(self): bb.note("Installing TARGET packages") self._populate_sysroot(self.target_pm, self.target_manifest) execute_pre_post_process(self.d, self.d.getVar("POPULATE_SDK_POST_TARGET_COMMAND", True)) self._copy_apt_dir_to(os.path.join(self.sdk_target_sysroot, "etc", "apt")) bb.note("Installing NATIVESDK packages") self._populate_sysroot(self.host_pm, self.host_manifest) execute_pre_post_process(self.d, self.d.getVar("POPULATE_SDK_POST_HOST_COMMAND", True)) self._copy_apt_dir_to(os.path.join(self.sdk_output, self.sdk_native_path, "etc", "apt")) native_dpkg_state_dir = os.path.join(self.sdk_output, self.sdk_native_path, "var", "lib", "dpkg") bb.utils.mkdirhier(native_dpkg_state_dir) for f in glob.glob(os.path.join(self.sdk_output, "var", "lib", "dpkg", "*")): bb.utils.movefile(f, native_dpkg_state_dir) bb.utils.remove(os.path.join(self.sdk_output, "var"), True)
def _create(self): pkgs_to_install = self.manifest.parse_initial_manifest() opkg_pre_process_cmds = self.d.getVar('OPKG_PREPROCESS_COMMANDS', True) opkg_post_process_cmds = self.d.getVar('OPKG_POSTPROCESS_COMMANDS', True) rootfs_post_install_cmds = self.d.getVar('ROOTFS_POSTINSTALL_COMMAND', True) # update PM index files, unless users provide their own feeds if (self.d.getVar('BUILD_IMAGES_FROM_FEEDS', True) or "") != "1": self.pm.write_index() execute_pre_post_process(self.d, opkg_pre_process_cmds) self.pm.update() self.pm.handle_bad_recommendations() for pkg_type in self.install_order: if pkg_type in pkgs_to_install: # For multilib, we perform a sanity test before final install # If sanity test fails, it will automatically do a bb.fatal() # and the installation will stop if pkg_type == Manifest.PKG_TYPE_MULTILIB: self._multilib_test_install(pkgs_to_install[pkg_type]) self.pm.install(pkgs_to_install[pkg_type], [False, True][pkg_type == Manifest.PKG_TYPE_ATTEMPT_ONLY]) self.pm.install_complementary() execute_pre_post_process(self.d, opkg_post_process_cmds) execute_pre_post_process(self.d, rootfs_post_install_cmds)
def create(self): bb.note("###### Generate rootfs #######") pre_process_cmds = self.d.getVar("ROOTFS_PREPROCESS_COMMAND") post_process_cmds = self.d.getVar("ROOTFS_POSTPROCESS_COMMAND") rootfs_post_install_cmds = self.d.getVar('ROOTFS_POSTINSTALL_COMMAND') bb.utils.mkdirhier(self.image_rootfs) bb.utils.mkdirhier(self.deploydir) execute_pre_post_process(self.d, pre_process_cmds) if self.progress_reporter: self.progress_reporter.next_stage() # call the package manager dependent create method self._create() sysconfdir = self.image_rootfs + self.d.getVar('sysconfdir') bb.utils.mkdirhier(sysconfdir) with open(sysconfdir + "/version", "w+") as ver: ver.write(self.d.getVar('BUILDNAME') + "\n") execute_pre_post_process(self.d, rootfs_post_install_cmds) self.pm.run_intercepts() execute_pre_post_process(self.d, post_process_cmds) if self.progress_reporter: self.progress_reporter.next_stage() if bb.utils.contains("IMAGE_FEATURES", "read-only-rootfs", True, False, self.d): delayed_postinsts = self._get_delayed_postinsts() if delayed_postinsts is not None: bb.fatal("The following packages could not be configured " "offline and rootfs is read-only: %s" % delayed_postinsts) if self.d.getVar('USE_DEVFS') != "1": self._create_devfs() self._uninstall_unneeded() if self.progress_reporter: self.progress_reporter.next_stage() self._insert_feed_uris() self._run_ldconfig() if self.d.getVar('USE_DEPMOD') != "0": self._generate_kernel_module_deps() self._cleanup() self._log_check() if self.progress_reporter: self.progress_reporter.next_stage()
def _populate(self): execute_pre_post_process(self.d, self.d.getVar("POPULATE_SDK_PRE_TARGET_COMMAND")) bb.note("Installing TARGET packages") self._populate_sysroot(self.target_pm, self.target_manifest) self.target_pm.install_complementary(self.d.getVar('SDKIMAGE_INSTALL_COMPLEMENTARY')) execute_pre_post_process(self.d, self.d.getVar("POPULATE_SDK_POST_TARGET_COMMAND")) self._copy_apt_dir_to(os.path.join(self.sdk_target_sysroot, "etc", "apt")) if not bb.utils.contains("SDKIMAGE_FEATURES", "package-management", True, False, self.d): self.target_pm.remove_packaging_data() bb.note("Installing NATIVESDK packages") self._populate_sysroot(self.host_pm, self.host_manifest) self.install_locales(self.host_pm) execute_pre_post_process(self.d, self.d.getVar("POPULATE_SDK_POST_HOST_COMMAND")) self._copy_apt_dir_to(os.path.join(self.sdk_output, self.sdk_native_path, "etc", "apt")) if not bb.utils.contains("SDKIMAGE_FEATURES", "package-management", True, False, self.d): self.host_pm.remove_packaging_data() native_dpkg_state_dir = os.path.join(self.sdk_output, self.sdk_native_path, "var", "lib", "dpkg") self.mkdirhier(native_dpkg_state_dir) for f in glob.glob(os.path.join(self.sdk_output, "var", "lib", "dpkg", "*")): self.movefile(f, native_dpkg_state_dir) self.remove(os.path.join(self.sdk_output, "var"), True)
def populate(self): bb.utils.mkdirhier(self.sdk_output) # call backend dependent implementation self._populate() # Don't ship any libGL in the SDK bb.utils.remove(os.path.join(self.sdk_output, self.sdk_native_path, self.d.getVar('libdir_nativesdk', True).strip('/'), "libGL*")) # Fix or remove broken .la files bb.utils.remove(os.path.join(self.sdk_output, self.sdk_native_path, self.d.getVar('libdir_nativesdk', True).strip('/'), "*.la")) # Link the ld.so.cache file into the hosts filesystem link_name = os.path.join(self.sdk_output, self.sdk_native_path, self.sysconfdir, "ld.so.cache") os.symlink("/etc/ld.so.cache", link_name) execute_pre_post_process(self.d, self.d.getVar('SDK_POSTPROCESS_COMMAND', True))
def _populate(self): execute_pre_post_process( self.d, self.d.getVar("POPULATE_SDK_PRE_TARGET_COMMAND")) bb.note("Installing TARGET packages") self._populate_sysroot(self.target_pm, self.target_manifest) self.target_pm.install_complementary( self.d.getVar('SDKIMAGE_INSTALL_COMPLEMENTARY')) self.target_pm.run_intercepts(populate_sdk='target') execute_pre_post_process( self.d, self.d.getVar("POPULATE_SDK_POST_TARGET_COMMAND")) if not bb.utils.contains("SDKIMAGE_FEATURES", "package-management", True, False, self.d): self.target_pm.remove_packaging_data() bb.note("Installing NATIVESDK packages") self._populate_sysroot(self.host_pm, self.host_manifest) self.install_locales(self.host_pm) self.host_pm.run_intercepts(populate_sdk='host') execute_pre_post_process( self.d, self.d.getVar("POPULATE_SDK_POST_HOST_COMMAND")) if not bb.utils.contains("SDKIMAGE_FEATURES", "package-management", True, False, self.d): self.host_pm.remove_packaging_data() target_sysconfdir = os.path.join(self.sdk_target_sysroot, self.sysconfdir) host_sysconfdir = os.path.join(self.sdk_host_sysroot, self.sysconfdir) self.mkdirhier(target_sysconfdir) shutil.copy(self.target_conf, target_sysconfdir) os.chmod( os.path.join(target_sysconfdir, os.path.basename(self.target_conf)), 0o644) self.mkdirhier(host_sysconfdir) shutil.copy(self.host_conf, host_sysconfdir) os.chmod( os.path.join(host_sysconfdir, os.path.basename(self.host_conf)), 0o644) native_opkg_state_dir = os.path.join( self.sdk_output, self.sdk_native_path, self.d.getVar('localstatedir_nativesdk').strip('/'), "lib", "opkg") self.mkdirhier(native_opkg_state_dir) for f in glob.glob( os.path.join(self.sdk_output, "var", "lib", "opkg", "*")): self.movefile(f, native_opkg_state_dir) self.remove(os.path.join(self.sdk_output, "var"), True)
def _create(self): pkgs_to_install = self.manifest.parse_initial_manifest() opkg_pre_process_cmds = self.d.getVar('OPKG_PREPROCESS_COMMANDS', True) opkg_post_process_cmds = self.d.getVar('OPKG_POSTPROCESS_COMMANDS', True) rootfs_post_install_cmds = self.d.getVar('ROOTFS_POSTINSTALL_COMMAND', True) # update PM index files, unless users provide their own feeds if (self.d.getVar('BUILD_IMAGES_FROM_FEEDS', True) or "") != "1": self.pm.write_index() execute_pre_post_process(self.d, opkg_pre_process_cmds) self.pm.update() self.pm.handle_bad_recommendations() if self.inc_opkg_image_gen == "1": self._remove_extra_packages(pkgs_to_install) for pkg_type in self.install_order: if pkg_type in pkgs_to_install: # For multilib, we perform a sanity test before final install # If sanity test fails, it will automatically do a bb.fatal() # and the installation will stop if pkg_type == Manifest.PKG_TYPE_MULTILIB: self._multilib_test_install(pkgs_to_install[pkg_type]) self.pm.install(pkgs_to_install[pkg_type], [False, True][pkg_type == Manifest.PKG_TYPE_ATTEMPT_ONLY]) if self.split_debug_fs: globs = self.d.getVar('IMAGE_INSTALL_COMPLEMENTARY', True) globs_debug_fs = self.d.getVar('IMAGE_INSTALL_COMPLEMENTARY_DEBUG', True) self.pm.install_complementary(globs_debug_fs, extra_args=self.pm.opkg_extra_debug_args) # install the extra packages specified by the user that would only # go to split-debug file-system extra_debug_packages = self.d.getVar('EXTRA_DEBUG_PACKAGES', True) self.pm.install(re.split(" +", extra_debug_packages), attempt_only=True, extra_args=self.pm.opkg_extra_debug_args) self.pm.install_complementary() execute_pre_post_process(self.d, opkg_post_process_cmds) execute_pre_post_process(self.d, rootfs_post_install_cmds) if self.inc_opkg_image_gen == "1": self.pm.backup_packaging_data()
def _populate(self): execute_pre_post_process(self.d, self.d.getVar("POPULATE_SDK_PRE_TARGET_COMMAND")) bb.note("Installing TARGET packages") self._populate_sysroot(self.target_pm, self.target_manifest) self.target_pm.install_complementary(self.d.getVar('SDKIMAGE_INSTALL_COMPLEMENTARY')) self.target_pm.run_intercepts(populate_sdk='target') execute_pre_post_process(self.d, self.d.getVar("POPULATE_SDK_POST_TARGET_COMMAND")) if not bb.utils.contains("SDKIMAGE_FEATURES", "package-management", True, False, self.d): self.target_pm.remove_packaging_data() bb.note("Installing NATIVESDK packages") self._populate_sysroot(self.host_pm, self.host_manifest) self.install_locales(self.host_pm) self.host_pm.run_intercepts(populate_sdk='host') execute_pre_post_process(self.d, self.d.getVar("POPULATE_SDK_POST_HOST_COMMAND")) if not bb.utils.contains("SDKIMAGE_FEATURES", "package-management", True, False, self.d): self.host_pm.remove_packaging_data() target_sysconfdir = os.path.join(self.sdk_target_sysroot, self.sysconfdir) host_sysconfdir = os.path.join(self.sdk_host_sysroot, self.sysconfdir) self.mkdirhier(target_sysconfdir) shutil.copy(self.target_conf, target_sysconfdir) os.chmod(os.path.join(target_sysconfdir, os.path.basename(self.target_conf)), 0o644) self.mkdirhier(host_sysconfdir) shutil.copy(self.host_conf, host_sysconfdir) os.chmod(os.path.join(host_sysconfdir, os.path.basename(self.host_conf)), 0o644) native_opkg_state_dir = os.path.join(self.sdk_output, self.sdk_native_path, self.d.getVar('localstatedir_nativesdk').strip('/'), "lib", "opkg") self.mkdirhier(native_opkg_state_dir) for f in glob.glob(os.path.join(self.sdk_output, "var", "lib", "opkg", "*")): self.movefile(f, native_opkg_state_dir) self.remove(os.path.join(self.sdk_output, "var"), True)
def _create(self): pkgs_to_install = self.manifest.parse_initial_manifest() opkg_pre_process_cmds = self.d.getVar('OPKG_PREPROCESS_COMMANDS', True) opkg_post_process_cmds = self.d.getVar('OPKG_POSTPROCESS_COMMANDS', True) rootfs_post_install_cmds = self.d.getVar('ROOTFS_POSTINSTALL_COMMAND', True) # update PM index files, unless users provide their own feeds if (self.d.getVar('BUILD_IMAGES_FROM_FEEDS', True) or "") != "1": self.pm.write_index() execute_pre_post_process(self.d, opkg_pre_process_cmds) self.pm.update() self.pm.handle_bad_recommendations() if self.inc_opkg_image_gen == "1": self._remove_extra_packages(pkgs_to_install) for pkg_type in self.install_order: if pkg_type in pkgs_to_install: # For multilib, we perform a sanity test before final install # If sanity test fails, it will automatically do a bb.fatal() # and the installation will stop if pkg_type == Manifest.PKG_TYPE_MULTILIB: self._multilib_test_install(pkgs_to_install[pkg_type]) self.pm.install(pkgs_to_install[pkg_type], [False, True ][pkg_type == Manifest.PKG_TYPE_ATTEMPT_ONLY]) self.pm.install_complementary() self._setup_dbg_rootfs(['/var/lib/opkg']) execute_pre_post_process(self.d, opkg_post_process_cmds) execute_pre_post_process(self.d, rootfs_post_install_cmds) if self.inc_opkg_image_gen == "1": self.pm.backup_packaging_data()