summaryrefslogtreecommitdiffstats
path: root/meta/lib/oe/package_manager.py
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2014-08-29 15:25:15 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2014-09-03 11:09:03 +0100
commit45907b6d7fec3a929b51b7675962090dc627cd63 (patch)
tree8d167dd348b4d7df8ab3aa922af323ee9de140d3 /meta/lib/oe/package_manager.py
parentc5dc66430e8efa918afe5c8f502d3fcff3a0019d (diff)
downloadpoky-45907b6d7fec3a929b51b7675962090dc627cd63.tar.gz
package_manager: Add rpm v4 support
Currently the package manager code only supports rpm v5. To be useful outside of OE or with OE layers using v4, it makes sense to add in rpm v4 support. This takes a patch from "Bartosh, Eduard" <eduard.bartosh@intel.com> and enhances it to also include versions of the workarounds from poky-eurogiciel to allow rpm v4 usage with the class for image construction. (From OE-Core rev: fe21804c296bbb8b2b8b0c29e6e4890bc17f07fc) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oe/package_manager.py')
-rw-r--r--meta/lib/oe/package_manager.py110
1 files changed, 70 insertions, 40 deletions
diff --git a/meta/lib/oe/package_manager.py b/meta/lib/oe/package_manager.py
index 612c8357a6..86cef02d77 100644
--- a/meta/lib/oe/package_manager.py
+++ b/meta/lib/oe/package_manager.py
@@ -210,7 +210,7 @@ class PkgsList(object):
210 210
211 211
212class RpmPkgsList(PkgsList): 212class RpmPkgsList(PkgsList):
213 def __init__(self, d, rootfs_dir, arch_var=None, os_var=None): 213 def __init__(self, d, rootfs_dir, arch_var=None, os_var=None, rpm_version=5):
214 super(RpmPkgsList, self).__init__(d, rootfs_dir) 214 super(RpmPkgsList, self).__init__(d, rootfs_dir)
215 215
216 self.rpm_cmd = bb.utils.which(os.getenv('PATH'), "rpm") 216 self.rpm_cmd = bb.utils.which(os.getenv('PATH'), "rpm")
@@ -219,6 +219,8 @@ class RpmPkgsList(PkgsList):
219 self.ml_prefix_list, self.ml_os_list = \ 219 self.ml_prefix_list, self.ml_os_list = \
220 RpmIndexer(d, rootfs_dir).get_ml_prefix_and_os_list(arch_var, os_var) 220 RpmIndexer(d, rootfs_dir).get_ml_prefix_and_os_list(arch_var, os_var)
221 221
222 self.rpm_version = rpm_version
223
222 ''' 224 '''
223 Translate the RPM/Smart format names to the OE multilib format names 225 Translate the RPM/Smart format names to the OE multilib format names
224 ''' 226 '''
@@ -267,11 +269,16 @@ class RpmPkgsList(PkgsList):
267 269
268 def list(self, format=None): 270 def list(self, format=None):
269 if format == "deps": 271 if format == "deps":
272 if self.rpm_version == 4:
273 bb.fatal("'deps' format dependency listings are not supported with rpm 4 since rpmresolve does not work")
270 return self._list_pkg_deps() 274 return self._list_pkg_deps()
271 275
272 cmd = self.rpm_cmd + ' --root ' + self.rootfs_dir 276 cmd = self.rpm_cmd + ' --root ' + self.rootfs_dir
273 cmd += ' -D "_dbpath /var/lib/rpm" -qa' 277 cmd += ' -D "_dbpath /var/lib/rpm" -qa'
274 cmd += " --qf '[%{NAME} %{ARCH} %{VERSION} %{PACKAGEORIGIN}\n]'" 278 if self.rpm_version == 4:
279 cmd += " --qf '[%{NAME} %{ARCH} %{VERSION}\n]'"
280 else:
281 cmd += " --qf '[%{NAME} %{ARCH} %{VERSION} %{PACKAGEORIGIN}\n]'"
275 282
276 try: 283 try:
277 # bb.note(cmd) 284 # bb.note(cmd)
@@ -288,7 +295,10 @@ class RpmPkgsList(PkgsList):
288 pkg = line.split()[0] 295 pkg = line.split()[0]
289 arch = line.split()[1] 296 arch = line.split()[1]
290 ver = line.split()[2] 297 ver = line.split()[2]
291 pkgorigin = line.split()[3] 298 if self.rpm_version == 4:
299 pkgorigin = "unknown"
300 else:
301 pkgorigin = line.split()[3]
292 new_pkg, new_arch = self._pkg_translate_smart_to_oe(pkg, arch) 302 new_pkg, new_arch = self._pkg_translate_smart_to_oe(pkg, arch)
293 303
294 if format == "arch": 304 if format == "arch":
@@ -554,8 +564,17 @@ class RpmPM(PackageManager):
554 if not os.path.exists(self.d.expand('${T}/saved')): 564 if not os.path.exists(self.d.expand('${T}/saved')):
555 bb.utils.mkdirhier(self.d.expand('${T}/saved')) 565 bb.utils.mkdirhier(self.d.expand('${T}/saved'))
556 566
567 # Determine rpm version
568 cmd = "%s --version" % self.rpm_cmd
569 try:
570 output = subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True)
571 except subprocess.CalledProcessError as e:
572 bb.fatal("Getting rpm version failed. Command '%s' "
573 "returned %d:\n%s" % (cmd, e.returncode, e.output))
574 self.rpm_version = int(output.split()[-1].split('.')[0])
575
557 self.indexer = RpmIndexer(self.d, self.deploy_dir) 576 self.indexer = RpmIndexer(self.d, self.deploy_dir)
558 self.pkgs_list = RpmPkgsList(self.d, self.target_rootfs, arch_var, os_var) 577 self.pkgs_list = RpmPkgsList(self.d, self.target_rootfs, arch_var, os_var, self.rpm_version)
559 578
560 self.ml_prefix_list, self.ml_os_list = self.indexer.get_ml_prefix_and_os_list(arch_var, os_var) 579 self.ml_prefix_list, self.ml_os_list = self.indexer.get_ml_prefix_and_os_list(arch_var, os_var)
561 580
@@ -745,43 +764,46 @@ class RpmPM(PackageManager):
745 # After change the __db.* cache size, log file will not be 764 # After change the __db.* cache size, log file will not be
746 # generated automatically, that will raise some warnings, 765 # generated automatically, that will raise some warnings,
747 # so touch a bare log for rpm write into it. 766 # so touch a bare log for rpm write into it.
748 rpmlib_log = os.path.join(self.image_rpmlib, 'log', 'log.0000000001') 767 if self.rpm_version == 5:
749 if not os.path.exists(rpmlib_log): 768 rpmlib_log = os.path.join(self.image_rpmlib, 'log', 'log.0000000001')
750 bb.utils.mkdirhier(os.path.join(self.image_rpmlib, 'log')) 769 if not os.path.exists(rpmlib_log):
751 open(rpmlib_log, 'w+').close() 770 bb.utils.mkdirhier(os.path.join(self.image_rpmlib, 'log'))
752 771 open(rpmlib_log, 'w+').close()
753 DB_CONFIG_CONTENT = "# ================ Environment\n" \ 772
754 "set_data_dir .\n" \ 773 DB_CONFIG_CONTENT = "# ================ Environment\n" \
755 "set_create_dir .\n" \ 774 "set_data_dir .\n" \
756 "set_lg_dir ./log\n" \ 775 "set_create_dir .\n" \
757 "set_tmp_dir ./tmp\n" \ 776 "set_lg_dir ./log\n" \
758 "set_flags db_log_autoremove on\n" \ 777 "set_tmp_dir ./tmp\n" \
759 "\n" \ 778 "set_flags db_log_autoremove on\n" \
760 "# -- thread_count must be >= 8\n" \ 779 "\n" \
761 "set_thread_count 64\n" \ 780 "# -- thread_count must be >= 8\n" \
762 "\n" \ 781 "set_thread_count 64\n" \
763 "# ================ Logging\n" \ 782 "\n" \
764 "\n" \ 783 "# ================ Logging\n" \
765 "# ================ Memory Pool\n" \ 784 "\n" \
766 "set_cachesize 0 1048576 0\n" \ 785 "# ================ Memory Pool\n" \
767 "set_mp_mmapsize 268435456\n" \ 786 "set_cachesize 0 1048576 0\n" \
768 "\n" \ 787 "set_mp_mmapsize 268435456\n" \
769 "# ================ Locking\n" \ 788 "\n" \
770 "set_lk_max_locks 16384\n" \ 789 "# ================ Locking\n" \
771 "set_lk_max_lockers 16384\n" \ 790 "set_lk_max_locks 16384\n" \
772 "set_lk_max_objects 16384\n" \ 791 "set_lk_max_lockers 16384\n" \
773 "mutex_set_max 163840\n" \ 792 "set_lk_max_objects 16384\n" \
774 "\n" \ 793 "mutex_set_max 163840\n" \
775 "# ================ Replication\n" 794 "\n" \
776 795 "# ================ Replication\n"
777 db_config_dir = os.path.join(self.image_rpmlib, 'DB_CONFIG') 796
778 if not os.path.exists(db_config_dir): 797 db_config_dir = os.path.join(self.image_rpmlib, 'DB_CONFIG')
779 open(db_config_dir, 'w+').write(DB_CONFIG_CONTENT) 798 if not os.path.exists(db_config_dir):
799 open(db_config_dir, 'w+').write(DB_CONFIG_CONTENT)
780 800
781 # Create database so that smart doesn't complain (lazy init) 801 # Create database so that smart doesn't complain (lazy init)
782 cmd = "%s --root %s --dbpath /var/lib/rpm -qa > /dev/null" % ( 802 opt = "-qa"
783 self.rpm_cmd, 803 if self.rpm_version == 4:
784 self.target_rootfs) 804 opt = "--initdb"
805 cmd = "%s --root %s --dbpath /var/lib/rpm %s > /dev/null" % (
806 self.rpm_cmd, self.target_rootfs, opt)
785 try: 807 try:
786 subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True) 808 subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True)
787 except subprocess.CalledProcessError as e: 809 except subprocess.CalledProcessError as e:
@@ -818,6 +840,9 @@ class RpmPM(PackageManager):
818 # Write common configuration for host and target usage 840 # Write common configuration for host and target usage
819 self._invoke_smart('config --set rpm-nolinktos=1') 841 self._invoke_smart('config --set rpm-nolinktos=1')
820 self._invoke_smart('config --set rpm-noparentdirs=1') 842 self._invoke_smart('config --set rpm-noparentdirs=1')
843 check_signature = self.d.getVar('RPM_CHECK_SIGNATURES', True)
844 if check_signature and check_signature.strip() == "0":
845 self._invoke_smart('config --set rpm-check-signatures=false')
821 for i in self.d.getVar('BAD_RECOMMENDATIONS', True).split(): 846 for i in self.d.getVar('BAD_RECOMMENDATIONS', True).split():
822 self._invoke_smart('flag --set ignore-recommends %s' % i) 847 self._invoke_smart('flag --set ignore-recommends %s' % i)
823 848
@@ -856,6 +881,11 @@ class RpmPM(PackageManager):
856 # If we ever run into needing more the 899 scripts, we'll have to. 881 # If we ever run into needing more the 899 scripts, we'll have to.
857 # change num to start with 1000. 882 # change num to start with 1000.
858 # 883 #
884 if self.rpm_version == 4:
885 scriptletcmd = "$2 $3 $4\n"
886 else:
887 scriptletcmd = "$2 $1/$3 $4\n"
888
859 SCRIPTLET_FORMAT = "#!/bin/bash\n" \ 889 SCRIPTLET_FORMAT = "#!/bin/bash\n" \
860 "\n" \ 890 "\n" \
861 "export PATH=%s\n" \ 891 "export PATH=%s\n" \
@@ -866,7 +896,7 @@ class RpmPM(PackageManager):
866 "export INTERCEPT_DIR=%s\n" \ 896 "export INTERCEPT_DIR=%s\n" \
867 "export NATIVE_ROOT=%s\n" \ 897 "export NATIVE_ROOT=%s\n" \
868 "\n" \ 898 "\n" \
869 "$2 $1/$3 $4\n" \ 899 + scriptletcmd + \
870 "if [ $? -ne 0 ]; then\n" \ 900 "if [ $? -ne 0 ]; then\n" \
871 " if [ $4 -eq 1 ]; then\n" \ 901 " if [ $4 -eq 1 ]; then\n" \
872 " mkdir -p $1/etc/rpm-postinsts\n" \ 902 " mkdir -p $1/etc/rpm-postinsts\n" \