summaryrefslogtreecommitdiffstats
path: root/meta/lib/oe
diff options
context:
space:
mode:
authorDavid Nyström <david.c.nystrom@gmail.com>2014-02-27 21:20:37 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2014-03-07 15:05:07 +0000
commit7af3eb8434c3347b44a906a8d557cccf2cf3ba97 (patch)
treefd039a9ccf12abc4678a2cd26b191a72aa78c6fb /meta/lib/oe
parentff8d8fbc9e49bf9a6e7499a9550b343f5bf4942a (diff)
downloadpoky-7af3eb8434c3347b44a906a8d557cccf2cf3ba97.tar.gz
do_rootfs: Added PACKAGE_FEED_URIS functionality
Adding a common interface to add predefined package manager channels to prebuilt rootfs:es. Adding PACKAGE_FEED_URIS = "http://myre.po/repo/, will assume repo directories named (rpm,ipk,deb) as subdirectories and statically add them to the rootfs, using the same PKG_ARCHs as the build which produced the images. Tested with RPM, IPK and DEB. deb feed functionality seem broken, is anyone using this ? (From OE-Core rev: 9b8811045546ad67b4695d980f09636d5506e50c) Signed-off-by: David Nyström <david.c.nystrom@gmail.com> Signed-off-by: David Nyström <david.nystrom@enea.com> Signed-off-by: Saul Wold <sgw@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oe')
-rw-r--r--meta/lib/oe/package_manager.py89
-rw-r--r--meta/lib/oe/rootfs.py16
2 files changed, 92 insertions, 13 deletions
diff --git a/meta/lib/oe/package_manager.py b/meta/lib/oe/package_manager.py
index 355ed44553..1279b50e99 100644
--- a/meta/lib/oe/package_manager.py
+++ b/meta/lib/oe/package_manager.py
@@ -223,6 +223,7 @@ class PackageManager(object):
223 self.d = d 223 self.d = d
224 self.deploy_dir = None 224 self.deploy_dir = None
225 self.deploy_lock = None 225 self.deploy_lock = None
226 self.feed_uris = self.d.getVar('PACKAGE_FEED_URIS', True) or ""
226 227
227 """ 228 """
228 Update the package manager package database. 229 Update the package manager package database.
@@ -262,6 +263,10 @@ class PackageManager(object):
262 def list_installed(self, format=None): 263 def list_installed(self, format=None):
263 pass 264 pass
264 265
266 @abstractmethod
267 def insert_feeds_uris(self):
268 pass
269
265 """ 270 """
266 Install complementary packages based upon the list of currently installed 271 Install complementary packages based upon the list of currently installed
267 packages e.g. locales, *-dev, *-dbg, etc. This will only attempt to install 272 packages e.g. locales, *-dev, *-dbg, etc. This will only attempt to install
@@ -358,6 +363,46 @@ class RpmPM(PackageManager):
358 363
359 self.ml_prefix_list, self.ml_os_list = self.indexer.get_ml_prefix_and_os_list(arch_var, os_var) 364 self.ml_prefix_list, self.ml_os_list = self.indexer.get_ml_prefix_and_os_list(arch_var, os_var)
360 365
366
367 def insert_feeds_uris(self):
368 if self.feed_uris == "":
369 return
370
371 # List must be prefered to least preferred order
372 default_platform_extra = set()
373 platform_extra = set()
374 bbextendvariant = self.d.getVar('BBEXTENDVARIANT', True) or ""
375 for mlib in self.ml_os_list:
376 for arch in self.ml_prefix_list[mlib]:
377 plt = arch.replace('-', '_') + '-.*-' + self.ml_os_list[mlib]
378 if mlib == bbextendvariant:
379 default_platform_extra.add(plt)
380 else:
381 platform_extra.add(plt)
382
383 platform_extra = platform_extra.union(default_platform_extra)
384
385 arch_list = []
386 for canonical_arch in platform_extra:
387 arch = canonical_arch.split('-')[0]
388 if not os.path.exists(os.path.join(self.deploy_dir, arch)):
389 continue
390 arch_list.append(arch)
391
392 uri_iterator = 0
393 channel_priority = 10 + 5 * len(self.feed_uris.split()) * len(arch_list)
394
395 for uri in self.feed_uris.split():
396 for arch in arch_list:
397 bb.note('Note: adding Smart channel url%d%s (%s)' %
398 (uri_iterator, arch, channel_priority))
399 self._invoke_smart('channel --add url%d-%s type=rpm-md baseurl=%s/rpm/%s -y'
400 % (uri_iterator, arch, uri, arch))
401 self._invoke_smart('channel --set url%d-%s priority=%d' %
402 (uri_iterator, arch, channel_priority))
403 channel_priority -= 5
404 uri_iterator += 1
405
361 ''' 406 '''
362 Create configs for rpm and smart, and multilib is supported 407 Create configs for rpm and smart, and multilib is supported
363 ''' 408 '''
@@ -964,7 +1009,6 @@ class OpkgPM(PackageManager):
964 1009
965 self.deploy_dir = self.d.getVar("DEPLOY_DIR_IPK", True) 1010 self.deploy_dir = self.d.getVar("DEPLOY_DIR_IPK", True)
966 self.deploy_lock_file = os.path.join(self.deploy_dir, "deploy.lock") 1011 self.deploy_lock_file = os.path.join(self.deploy_dir, "deploy.lock")
967
968 self.opkg_cmd = bb.utils.which(os.getenv('PATH'), "opkg-cl") 1012 self.opkg_cmd = bb.utils.which(os.getenv('PATH'), "opkg-cl")
969 self.opkg_args = "-f %s -o %s " % (self.config_file, target_rootfs) 1013 self.opkg_args = "-f %s -o %s " % (self.config_file, target_rootfs)
970 self.opkg_args += self.d.getVar("OPKG_ARGS", True) 1014 self.opkg_args += self.d.getVar("OPKG_ARGS", True)
@@ -1070,6 +1114,29 @@ class OpkgPM(PackageManager):
1070 config_file.write("src oe-%s file:%s\n" % 1114 config_file.write("src oe-%s file:%s\n" %
1071 (arch, pkgs_dir)) 1115 (arch, pkgs_dir))
1072 1116
1117 def insert_feeds_uris(self):
1118 if self.feed_uris == "":
1119 return
1120
1121 rootfs_config = os.path.join('%s/etc/opkg/base-feeds.conf'
1122 % self.target_rootfs)
1123
1124 with open(rootfs_config, "w+") as config_file:
1125 uri_iterator = 0
1126 for uri in self.feed_uris.split():
1127 config_file.write("src/gz url-%d %s/ipk\n" %
1128 (uri_iterator, uri))
1129
1130 for arch in self.pkg_archs.split():
1131 if not os.path.exists(os.path.join(self.deploy_dir, arch)):
1132 continue
1133 bb.note('Note: adding opkg channel url-%s-%d (%s)' %
1134 (arch, uri_iterator, uri))
1135
1136 config_file.write("src/gz uri-%s-%d %s/ipk/%s\n" %
1137 (arch, uri_iterator, uri, arch))
1138 uri_iterator += 1
1139
1073 def update(self): 1140 def update(self):
1074 self.deploy_dir_lock() 1141 self.deploy_dir_lock()
1075 1142
@@ -1433,6 +1500,26 @@ class DpkgPM(PackageManager):
1433 if result is not None: 1500 if result is not None:
1434 bb.fatal(result) 1501 bb.fatal(result)
1435 1502
1503 def insert_feeds_uris(self):
1504 if self.feed_uris == "":
1505 return
1506
1507 sources_conf = os.path.join("%s/etc/apt/sources.list"
1508 % self.target_rootfs)
1509 arch_list = []
1510 archs = self.d.getVar('PACKAGE_ARCHS', True)
1511 for arch in archs.split():
1512 if not os.path.exists(os.path.join(self.deploy_dir, arch)):
1513 continue
1514 arch_list.append(arch)
1515
1516 with open(sources_conf, "w+") as sources_file:
1517 for uri in self.feed_uris.split():
1518 for arch in arch_list:
1519 bb.note('Note: adding dpkg channel at (%s)' % uri)
1520 sources_file.write("deb %s/deb/%s ./\n" %
1521 (uri, arch))
1522
1436 def _create_configs(self, archs, base_archs): 1523 def _create_configs(self, archs, base_archs):
1437 base_archs = re.sub("_", "-", base_archs) 1524 base_archs = re.sub("_", "-", base_archs)
1438 1525
diff --git a/meta/lib/oe/rootfs.py b/meta/lib/oe/rootfs.py
index 90c0504b31..30a1321db1 100644
--- a/meta/lib/oe/rootfs.py
+++ b/meta/lib/oe/rootfs.py
@@ -41,9 +41,10 @@ class Rootfs(object):
41 def _log_check(self): 41 def _log_check(self):
42 pass 42 pass
43 43
44 @abstractmethod
45 def _insert_feed_uris(self): 44 def _insert_feed_uris(self):
46 pass 45 if base_contains("IMAGE_FEATURES", "package-management",
46 True, False, self.d):
47 self.pm.insert_feeds_uris()
47 48
48 @abstractmethod 49 @abstractmethod
49 def _handle_intercept_failure(self, failed_script): 50 def _handle_intercept_failure(self, failed_script):
@@ -349,9 +350,6 @@ class RpmRootfs(Rootfs):
349 if found_error == 6: 350 if found_error == 6:
350 bb.fatal(message) 351 bb.fatal(message)
351 352
352 def _insert_feed_uris(self):
353 pass
354
355 def _handle_intercept_failure(self, registered_pkgs): 353 def _handle_intercept_failure(self, registered_pkgs):
356 rpm_postinsts_dir = self.image_rootfs + self.d.expand('${sysconfdir}/rpm-postinsts/') 354 rpm_postinsts_dir = self.image_rootfs + self.d.expand('${sysconfdir}/rpm-postinsts/')
357 bb.utils.mkdirhier(rpm_postinsts_dir) 355 bb.utils.mkdirhier(rpm_postinsts_dir)
@@ -372,6 +370,7 @@ class DpkgRootfs(Rootfs):
372 d.getVar('PACKAGE_ARCHS', True), 370 d.getVar('PACKAGE_ARCHS', True),
373 d.getVar('DPKG_ARCH', True)) 371 d.getVar('DPKG_ARCH', True))
374 372
373
375 def _create(self): 374 def _create(self):
376 pkgs_to_install = self.manifest.parse_initial_manifest() 375 pkgs_to_install = self.manifest.parse_initial_manifest()
377 376
@@ -432,9 +431,6 @@ class DpkgRootfs(Rootfs):
432 def _log_check(self): 431 def _log_check(self):
433 pass 432 pass
434 433
435 def _insert_feed_uris(self):
436 pass
437
438 434
439class OpkgRootfs(Rootfs): 435class OpkgRootfs(Rootfs):
440 def __init__(self, d, manifest_dir): 436 def __init__(self, d, manifest_dir):
@@ -698,10 +694,6 @@ class OpkgRootfs(Rootfs):
698 def _log_check(self): 694 def _log_check(self):
699 pass 695 pass
700 696
701 def _insert_feed_uris(self):
702 pass
703
704
705def create_rootfs(d, manifest_dir=None): 697def create_rootfs(d, manifest_dir=None):
706 env_bkp = os.environ.copy() 698 env_bkp = os.environ.copy()
707 699