summaryrefslogtreecommitdiffstats
path: root/meta/lib/oe/package_manager.py
diff options
context:
space:
mode:
authorLeonardo Sandoval <leonardo.sandoval.gonzalez@linux.intel.com>2015-10-05 13:12:23 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-12-09 08:48:25 +0000
commit6650357f13a52ad6a789cd79ec283218537c4aba (patch)
treeadc83098dd8bbdf5b425d03f73c185b4dbe6d322 /meta/lib/oe/package_manager.py
parentd7baeb5fad2630986556d4af38a2e2c67f7250c2 (diff)
downloadpoky-6650357f13a52ad6a789cd79ec283218537c4aba.tar.gz
lib/oe/package_manager: Introducing PACKAGE_FEED_BASE_PATHS/PACKAGE_FEED_ARCHS
The recently introduced PACKAGE_FEED_PREFIX is not flexible enough for constructing URIs, because the same PREFIX is used for all PACKAGE_FEED_URIS. Also, the string 'PREFIX' is confusing because it is not at the beginning of the URI. The variable PACKAGE_FEED_BASE_PATHS replaces PACKAGE_FEED_PREFIX, allowing multiple base paths to be appended on each PACKAGE_FEED_URIS. In the other hand, a new variable called PACKAGE_FEED_ARCHS, similar in concept to PACKAGE_BASE_PATHS, defines package architectures defined by the user. To demonstrate the usage of the PACKAGE_FEED_URIS, PACKAGE_FEED_BASE_PATHS and PACKAGE_FEED_ARCHS, let's assume these variables are set on local.conf PACKAGE_FEED_URIS = "https://example.com/packagerepos/release \ https://example.com/packagerepos/updates" PACKAGE_FEED_BASE_PATHS = "rpm rpm-dev" PACKAGE_FEED_ARCHS = "all core2-64" the resulting feeds would be https://example.com/packagerepos/release/rpm/all https://example.com/packagerepos/release/rpm/core2-64 https://example.com/packagerepos/release/rpm-dev/all https://example.com/packagerepos/release/rpm-dev/core2-64 https://example.com/packagerepos/updates/rpm/all https://example.com/packagerepos/updates/rpm/core2-64 https://example.com/packagerepos/updates/rpm-dev/all https://example.com/packagerepos/updates/rpm-dev/core2-64 (From OE-Core rev: 229723a20095e80bde29e4b3398047f62f972170) Signed-off-by: Leonardo Sandoval <leonardo.sandoval.gonzalez@linux.intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com> 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.py154
1 files changed, 99 insertions, 55 deletions
diff --git a/meta/lib/oe/package_manager.py b/meta/lib/oe/package_manager.py
index d6104b3843..fd9caa31c8 100644
--- a/meta/lib/oe/package_manager.py
+++ b/meta/lib/oe/package_manager.py
@@ -8,7 +8,7 @@ import re
8import bb 8import bb
9import tempfile 9import tempfile
10import oe.utils 10import oe.utils
11 11import string
12 12
13# this can be used by all PM backends to create the index files in parallel 13# this can be used by all PM backends to create the index files in parallel
14def create_index(arg): 14def create_index(arg):
@@ -535,7 +535,8 @@ class PackageManager(object):
535 self.deploy_dir = None 535 self.deploy_dir = None
536 self.deploy_lock = None 536 self.deploy_lock = None
537 self.feed_uris = self.d.getVar('PACKAGE_FEED_URIS', True) or "" 537 self.feed_uris = self.d.getVar('PACKAGE_FEED_URIS', True) or ""
538 self.feed_prefix = self.d.getVar('PACKAGE_FEED_PREFIX', True) or "" 538 self.feed_base_paths = self.d.getVar('PACKAGE_FEED_BASE_PATHS', True) or ""
539 self.feed_archs = self.d.getVar('PACKAGE_FEED_ARCHS', True)
539 540
540 """ 541 """
541 Update the package manager package database. 542 Update the package manager package database.
@@ -643,6 +644,25 @@ class PackageManager(object):
643 644
644 self.deploy_lock = None 645 self.deploy_lock = None
645 646
647 """
648 Construct URIs based on the following pattern: uri/base_path where 'uri'
649 and 'base_path' correspond to each element of the corresponding array
650 argument leading to len(uris) x len(base_paths) elements on the returned
651 array
652 """
653 def construct_uris(self, uris, base_paths):
654 def _append(arr1, arr2, sep='/'):
655 res = []
656 narr1 = map(lambda a: string.rstrip(a, sep), arr1)
657 narr2 = map(lambda a: string.lstrip(string.rstrip(a, sep), sep), arr2)
658 for a1 in narr1:
659 if arr2:
660 for a2 in narr2:
661 res.append("%s%s%s" % (a1, sep, a2))
662 else:
663 res.append(a1)
664 return res
665 return _append(uris, base_paths)
646 666
647class RpmPM(PackageManager): 667class RpmPM(PackageManager):
648 def __init__(self, 668 def __init__(self,
@@ -686,42 +706,55 @@ class RpmPM(PackageManager):
686 if self.feed_uris == "": 706 if self.feed_uris == "":
687 return 707 return
688 708
689 # List must be prefered to least preferred order 709 arch_list = []
690 default_platform_extra = set() 710 if self.feed_archs is not None:
691 platform_extra = set() 711 # User define feed architectures
692 bbextendvariant = self.d.getVar('BBEXTENDVARIANT', True) or "" 712 arch_list = self.feed_archs.split()
693 for mlib in self.ml_os_list: 713 else:
694 for arch in self.ml_prefix_list[mlib]: 714 # List must be prefered to least preferred order
695 plt = arch.replace('-', '_') + '-.*-' + self.ml_os_list[mlib] 715 default_platform_extra = set()
696 if mlib == bbextendvariant: 716 platform_extra = set()
697 default_platform_extra.add(plt) 717 bbextendvariant = self.d.getVar('BBEXTENDVARIANT', True) or ""
698 else: 718 for mlib in self.ml_os_list:
699 platform_extra.add(plt) 719 for arch in self.ml_prefix_list[mlib]:
720 plt = arch.replace('-', '_') + '-.*-' + self.ml_os_list[mlib]
721 if mlib == bbextendvariant:
722 default_platform_extra.add(plt)
723 else:
724 platform_extra.add(plt)
700 725
701 platform_extra = platform_extra.union(default_platform_extra) 726 platform_extra = platform_extra.union(default_platform_extra)
702 727
703 arch_list = [] 728 for canonical_arch in platform_extra:
704 for canonical_arch in platform_extra: 729 arch = canonical_arch.split('-')[0]
705 arch = canonical_arch.split('-')[0] 730 if not os.path.exists(os.path.join(self.deploy_dir, arch)):
706 if not os.path.exists(os.path.join(self.deploy_dir, arch)): 731 continue
707 continue 732 arch_list.append(arch)
708 arch_list.append(arch) 733
734 feed_uris = self.construct_uris(self.feed_uris.split(), self.feed_base_paths.split())
709 735
710 uri_iterator = 0 736 uri_iterator = 0
711 channel_priority = 10 + 5 * len(self.feed_uris.split()) * len(arch_list) 737 channel_priority = 10 + 5 * len(feed_uris) * (len(arch_list) if arch_list else 1)
712 738
713 for uri in self.feed_uris.split(): 739 for uri in feed_uris:
714 full_uri = uri 740 if arch_list:
715 if self.feed_prefix: 741 for arch in arch_list:
716 full_uri = os.path.join(uri, self.feed_prefix) 742 bb.note('Note: adding Smart channel url%d%s (%s)' %
717 for arch in arch_list: 743 (uri_iterator, arch, channel_priority))
718 bb.note('Note: adding Smart channel url%d%s (%s)' % 744 self._invoke_smart('channel --add url%d-%s type=rpm-md baseurl=%s/%s -y'
719 (uri_iterator, arch, channel_priority)) 745 % (uri_iterator, arch, uri, arch))
720 self._invoke_smart('channel --add url%d-%s type=rpm-md baseurl=%s/%s -y' 746 self._invoke_smart('channel --set url%d-%s priority=%d' %
721 % (uri_iterator, arch, full_uri, arch)) 747 (uri_iterator, arch, channel_priority))
722 self._invoke_smart('channel --set url%d-%s priority=%d' % 748 channel_priority -= 5
723 (uri_iterator, arch, channel_priority)) 749 else:
750 bb.note('Note: adding Smart channel url%d (%s)' %
751 (uri_iterator, channel_priority))
752 self._invoke_smart('channel --add url%d type=rpm-md baseurl=%s -y'
753 % (uri_iterator, uri))
754 self._invoke_smart('channel --set url%d priority=%d' %
755 (uri_iterator, channel_priority))
724 channel_priority -= 5 756 channel_priority -= 5
757
725 uri_iterator += 1 758 uri_iterator += 1
726 759
727 ''' 760 '''
@@ -1513,21 +1546,26 @@ class OpkgPM(PackageManager):
1513 rootfs_config = os.path.join('%s/etc/opkg/base-feeds.conf' 1546 rootfs_config = os.path.join('%s/etc/opkg/base-feeds.conf'
1514 % self.target_rootfs) 1547 % self.target_rootfs)
1515 1548
1549 feed_uris = self.construct_uris(self.feed_uris.split(), self.feed_base_paths.split())
1550 archs = self.pkg_archs.split() if self.feed_archs is None else self.feed_archs.split()
1551
1516 with open(rootfs_config, "w+") as config_file: 1552 with open(rootfs_config, "w+") as config_file:
1517 uri_iterator = 0 1553 uri_iterator = 0
1518 for uri in self.feed_uris.split(): 1554 for uri in feed_uris:
1519 full_uri = uri 1555 if archs:
1520 if self.feed_prefix: 1556 for arch in archs:
1521 full_uri = os.path.join(uri, self.feed_prefix) 1557 if (self.feed_archs is None) and (not os.path.exists(os.path.join(self.deploy_dir, arch))):
1522 1558 continue
1523 for arch in self.pkg_archs.split(): 1559 bb.note('Note: adding opkg feed url-%s-%d (%s)' %
1524 if not os.path.exists(os.path.join(self.deploy_dir, arch)): 1560 (arch, uri_iterator, uri))
1525 continue 1561 config_file.write("src/gz uri-%s-%d %s/%s\n" %
1526 bb.note('Note: adding opkg feed url-%s-%d (%s)' % 1562 (arch, uri_iterator, uri, arch))
1527 (arch, uri_iterator, full_uri)) 1563 else:
1564 bb.note('Note: adding opkg feed url-%d (%s)' %
1565 (uri_iterator, uri))
1566 config_file.write("src/gz uri-%d %s\n" %
1567 (uri_iterator, uri))
1528 1568
1529 config_file.write("src/gz uri-%s-%d %s/%s\n" %
1530 (arch, uri_iterator, full_uri, arch))
1531 uri_iterator += 1 1569 uri_iterator += 1
1532 1570
1533 def update(self): 1571 def update(self):
@@ -1873,20 +1911,26 @@ class DpkgPM(PackageManager):
1873 % self.target_rootfs) 1911 % self.target_rootfs)
1874 arch_list = [] 1912 arch_list = []
1875 1913
1876 for arch in self.all_arch_list: 1914 if self.feed_archs is None:
1877 if not os.path.exists(os.path.join(self.deploy_dir, arch)): 1915 for arch in self.all_arch_list:
1878 continue 1916 if not os.path.exists(os.path.join(self.deploy_dir, arch)):
1879 arch_list.append(arch) 1917 continue
1918 arch_list.append(arch)
1919 else:
1920 arch_list = self.feed_archs.split()
1921
1922 feed_uris = self.construct_uris(self.feed_uris.split(), self.feed_base_paths.split())
1880 1923
1881 with open(sources_conf, "w+") as sources_file: 1924 with open(sources_conf, "w+") as sources_file:
1882 for uri in self.feed_uris.split(): 1925 for uri in feed_uris:
1883 full_uri = uri 1926 if arch_list:
1884 if self.feed_prefix: 1927 for arch in arch_list:
1885 full_uri = os.path.join(uri, self.feed_prefix) 1928 bb.note('Note: adding dpkg channel at (%s)' % uri)
1886 for arch in arch_list: 1929 sources_file.write("deb %s/%s ./\n" %
1930 (uri, arch))
1931 else:
1887 bb.note('Note: adding dpkg channel at (%s)' % uri) 1932 bb.note('Note: adding dpkg channel at (%s)' % uri)
1888 sources_file.write("deb %s/%s ./\n" % 1933 sources_file.write("deb %s ./\n" % uri)
1889 (full_uri, arch))
1890 1934
1891 def _create_configs(self, archs, base_archs): 1935 def _create_configs(self, archs, base_archs):
1892 base_archs = re.sub("_", "-", base_archs) 1936 base_archs = re.sub("_", "-", base_archs)