summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaurentiu Palcu <laurentiu.palcu@intel.com>2014-01-22 14:15:02 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2014-02-11 11:53:40 +0000
commit080ce635164e3b4d6036205c1ec3419dd629615d (patch)
treefa1450d331311540ae6762dfb7eecef17a56a461
parent0b47dc4491701877068727e20e9147b5f3e635c0 (diff)
downloadpoky-080ce635164e3b4d6036205c1ec3419dd629615d.tar.gz
lib/oe/package_manager.py: fixes for dpkg backend
This commit contains the following fixes: * pass the apt config directory to the DpkgPM constructor, so one can instantiate this class multiple times and give it different config files (like for creating SDK); * change constructor argument name from 'dpkg_archs' to 'base_archs'; * export APT_CONFIG environment variable before calling apt-get, not in constructor. If done in constructor, the last class instantiation, sets the environment, which is note desireable; (From OE-Core rev: dc626cbcfd37c940bb8739b14d3ab8097e1760ea) Signed-off-by: Laurentiu Palcu <laurentiu.palcu@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/lib/oe/package_manager.py24
1 files changed, 16 insertions, 8 deletions
diff --git a/meta/lib/oe/package_manager.py b/meta/lib/oe/package_manager.py
index e06ded401a..e802edd492 100644
--- a/meta/lib/oe/package_manager.py
+++ b/meta/lib/oe/package_manager.py
@@ -349,19 +349,20 @@ class OpkgPM(PackageManager):
349 349
350 350
351class DpkgPM(PackageManager): 351class DpkgPM(PackageManager):
352 def __init__(self, d, target_rootfs, archs, dpkg_arch): 352 def __init__(self, d, target_rootfs, archs, base_archs, apt_conf_dir=None):
353 super(DpkgPM, self).__init__(d) 353 super(DpkgPM, self).__init__(d)
354 self.target_rootfs = target_rootfs 354 self.target_rootfs = target_rootfs
355 self.deploy_dir = self.d.getVar('DEPLOY_DIR_DEB', True) 355 self.deploy_dir = self.d.getVar('DEPLOY_DIR_DEB', True)
356 self.apt_conf_dir = self.d.expand("${APTCONF_TARGET}/apt") 356 if apt_conf_dir is None:
357 self.apt_conf_dir = self.d.expand("${APTCONF_TARGET}/apt")
358 else:
359 self.apt_conf_dir = apt_conf_dir
357 self.apt_conf_file = os.path.join(self.apt_conf_dir, "apt.conf") 360 self.apt_conf_file = os.path.join(self.apt_conf_dir, "apt.conf")
358 self.apt_get_cmd = bb.utils.which(os.getenv('PATH'), "apt-get") 361 self.apt_get_cmd = bb.utils.which(os.getenv('PATH'), "apt-get")
359 362
360 self.apt_args = d.getVar("APT_ARGS", True) 363 self.apt_args = d.getVar("APT_ARGS", True)
361 364
362 os.environ['APT_CONFIG'] = self.apt_conf_file 365 self._create_configs(archs, base_archs)
363
364 self._create_configs(archs, dpkg_arch)
365 366
366 """ 367 """
367 This function will change a package's status in /var/lib/dpkg/status file. 368 This function will change a package's status in /var/lib/dpkg/status file.
@@ -437,6 +438,8 @@ class DpkgPM(PackageManager):
437 self.mark_packages("unpacked", failed_pkgs) 438 self.mark_packages("unpacked", failed_pkgs)
438 439
439 def update(self): 440 def update(self):
441 os.environ['APT_CONFIG'] = self.apt_conf_file
442
440 cmd = "%s update" % self.apt_get_cmd 443 cmd = "%s update" % self.apt_get_cmd
441 444
442 try: 445 try:
@@ -446,6 +449,8 @@ class DpkgPM(PackageManager):
446 "returned %d" % (e.cmd, e.returncode)) 449 "returned %d" % (e.cmd, e.returncode))
447 450
448 def install(self, pkgs, attempt_only=False): 451 def install(self, pkgs, attempt_only=False):
452 os.environ['APT_CONFIG'] = self.apt_conf_file
453
449 cmd = "%s %s install --force-yes --allow-unauthenticated %s" % \ 454 cmd = "%s %s install --force-yes --allow-unauthenticated %s" % \
450 (self.apt_get_cmd, self.apt_args, ' '.join(pkgs)) 455 (self.apt_get_cmd, self.apt_args, ' '.join(pkgs))
451 456
@@ -474,6 +479,7 @@ class DpkgPM(PackageManager):
474 479
475 def remove(self, pkgs, with_dependencies=True): 480 def remove(self, pkgs, with_dependencies=True):
476 if with_dependencies: 481 if with_dependencies:
482 os.environ['APT_CONFIG'] = self.apt_conf_file
477 cmd = "%s remove %s" % (self.apt_get_cmd, ' '.join(pkgs)) 483 cmd = "%s remove %s" % (self.apt_get_cmd, ' '.join(pkgs))
478 else: 484 else:
479 cmd = "%s --admindir=%s/var/lib/dpkg --instdir=%s" \ 485 cmd = "%s --admindir=%s/var/lib/dpkg --instdir=%s" \
@@ -532,8 +538,8 @@ class DpkgPM(PackageManager):
532 538
533 open(os.path.join(tmpdir, "stamps", "DEB_PACKAGE_INDEX_CLEAN"), "w+").close() 539 open(os.path.join(tmpdir, "stamps", "DEB_PACKAGE_INDEX_CLEAN"), "w+").close()
534 540
535 def _create_configs(self, archs, dpkg_arch): 541 def _create_configs(self, archs, base_archs):
536 dpkg_arch = re.sub("_", "-", dpkg_arch) 542 base_archs = re.sub("_", "-", base_archs)
537 543
538 if os.path.exists(self.apt_conf_dir): 544 if os.path.exists(self.apt_conf_dir):
539 bb.utils.remove(self.apt_conf_dir, True) 545 bb.utils.remove(self.apt_conf_dir, True)
@@ -573,7 +579,7 @@ class DpkgPM(PackageManager):
573 with open(self.d.expand("${STAGING_ETCDIR_NATIVE}/apt/apt.conf.sample")) as apt_conf_sample: 579 with open(self.d.expand("${STAGING_ETCDIR_NATIVE}/apt/apt.conf.sample")) as apt_conf_sample:
574 for line in apt_conf_sample.read().split("\n"): 580 for line in apt_conf_sample.read().split("\n"):
575 line = re.sub("Architecture \".*\";", 581 line = re.sub("Architecture \".*\";",
576 "Architecture \"%s\";" % dpkg_arch, line) 582 "Architecture \"%s\";" % base_archs, line)
577 line = re.sub("#ROOTFS#", self.target_rootfs, line) 583 line = re.sub("#ROOTFS#", self.target_rootfs, line)
578 line = re.sub("#APTCONF#", self.apt_conf_dir, line) 584 line = re.sub("#APTCONF#", self.apt_conf_dir, line)
579 585
@@ -593,6 +599,8 @@ class DpkgPM(PackageManager):
593 bb.utils.remove(self.target_rootfs + "/var/lib/dpkg/", True) 599 bb.utils.remove(self.target_rootfs + "/var/lib/dpkg/", True)
594 600
595 def fix_broken_dependencies(self): 601 def fix_broken_dependencies(self):
602 os.environ['APT_CONFIG'] = self.apt_conf_file
603
596 cmd = "%s %s -f install" % (self.apt_get_cmd, self.apt_args) 604 cmd = "%s %s -f install" % (self.apt_get_cmd, self.apt_args)
597 605
598 try: 606 try: