]> code.ossystems Code Review - openembedded-core.git/commitdiff
rootfs.py, package_manager.py, sdk.py: Fix building from feeds feature for opkg
authorLaurentiu Palcu <laurentiu.palcu@intel.com>
Wed, 5 Feb 2014 09:08:34 +0000 (11:08 +0200)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Tue, 11 Feb 2014 11:50:32 +0000 (11:50 +0000)
When using opkg as the PM backend, one has the option to provide custom
feeds to create the rootfs from.

This commit:
 * fixes this in the refactored code;
 * moves the custom config creation code to python;
 * clean up the package-ipk.bbclass;

Signed-off-by: Laurentiu Palcu <laurentiu.palcu@intel.com>
meta/classes/rootfs_ipk.bbclass
meta/lib/oe/package_manager.py
meta/lib/oe/rootfs.py
meta/lib/oe/sdk.py

index 9d63450dd1ecfb7313e0d4ae2edc3705e56462f9..6d4f9facc079c7f7abe53c74ceab3a169245ee28 100644 (file)
@@ -23,35 +23,6 @@ OPKGLIBDIR = "${localstatedir}/lib"
 
 MULTILIBRE_ALLOW_REP = "${OPKGLIBDIR}/opkg"
 
-ipk_insert_feed_uris () {
-
-       echo "Building from feeds activated!"
-
-       for line in ${IPK_FEED_URIS}
-       do
-               # strip leading and trailing spaces/tabs, then split into name and uri
-               line_clean="`echo "$line"|sed 's/^[ \t]*//;s/[ \t]*$//'`"
-               feed_name="`echo "$line_clean" | sed -n 's/\(.*\)##\(.*\)/\1/p'`"
-               feed_uri="`echo "$line_clean" | sed -n 's/\(.*\)##\(.*\)/\2/p'`"
-
-               echo "Added $feed_name feed with URL $feed_uri"
-
-               # insert new feed-sources
-               echo "src/gz $feed_name $feed_uri" >> ${IPKGCONF_TARGET}
-       done
-
-       # Allow to use package deploy directory contents as quick devel-testing
-       # feed. This creates individual feed configs for each arch subdir of those
-       # specified as compatible for the current machine.
-       # NOTE: Development-helper feature, NOT a full-fledged feed.
-       if [ -n "${FEED_DEPLOYDIR_BASE_URI}" ]; then
-               for arch in ${PACKAGE_ARCHS}
-               do
-                       echo "src/gz local-$arch ${FEED_DEPLOYDIR_BASE_URI}/$arch" >> ${IMAGE_ROOTFS}/etc/opkg/local-$arch-feed.conf
-           done
-       fi
-}
-
 python () {
 
     if d.getVar('BUILD_IMAGES_FROM_FEEDS', True):
@@ -60,7 +31,7 @@ python () {
         flags = flags.replace("do_deploy", "")
         flags = flags.replace("do_populate_sysroot", "")
         d.setVarFlag('do_rootfs', 'recrdeptask', flags)
-        d.setVar('OPKG_PREPROCESS_COMMANDS', "ipk_insert_feed_uris")
+        d.setVar('OPKG_PREPROCESS_COMMANDS', "")
         d.setVar('OPKG_POSTPROCESS_COMMANDS', '')
 }
 
index 969292c0931362a7fc6277113e57dbbc6d04964b..d3e8a0885b0b7878d70873702e55078aa353794e 100644 (file)
@@ -805,7 +805,10 @@ class OpkgPM(PackageManager):
 
         bb.utils.mkdirhier(self.opkg_dir)
 
-        self._create_config()
+        if (self.d.getVar('BUILD_IMAGES_FROM_FEEDS', True) or "") != "1":
+            self._create_config()
+        else:
+            self._create_custom_config()
 
     """
     This function will change a package's status in /var/lib/opkg/status file.
@@ -835,6 +838,45 @@ class OpkgPM(PackageManager):
 
         os.rename(status_file + ".tmp", status_file)
 
+    def _create_custom_config(self):
+        bb.note("Building from feeds activated!")
+
+        with open(self.config_file, "w+") as config_file:
+            priority = 1
+            for arch in self.pkg_archs.split():
+                config_file.write("arch %s %d\n" % (arch, priority))
+                priority += 5
+
+            for line in (self.d.getVar('IPK_FEED_URIS', True) or "").split():
+                feed_match = re.match("^[ \t]*(.*)##([^ \t]*)[ \t]*$", line)
+
+                if feed_match is not None:
+                    feed_name = feed_match.group(1)
+                    feed_uri = feed_match.group(2)
+
+                    bb.note("Add %s feed with URL %s" % (feed_name, feed_uri))
+
+                    config_file.write("src/gz %s %s\n" % (feed_name, feed_uri))
+
+            """
+            Allow to use package deploy directory contents as quick devel-testing
+            feed. This creates individual feed configs for each arch subdir of those
+            specified as compatible for the current machine.
+            NOTE: Development-helper feature, NOT a full-fledged feed.
+            """
+            if (self.d.getVar('FEED_DEPLOYDIR_BASE_URI', True) or "") != "":
+                for arch in self.pkg_archs.split():
+                    cfg_file_name = os.path.join(self.target_rootfs,
+                                                 self.d.getVar("sysconfdir", True),
+                                                 "opkg",
+                                                 "local-%s-feed.conf" % arch)
+
+                    with open(cfg_file_name, "w+") as cfg_file:
+                        cfg_file.write("src/gz local-%s %s/%s" %
+                                       arch,
+                                       self.d.getVar('FEED_DEPLOYDIR_BASE_URI', True),
+                                       arch)
+
     def _create_config(self):
         with open(self.config_file, "w+") as config_file:
             priority = 1
@@ -847,7 +889,8 @@ class OpkgPM(PackageManager):
             for arch in self.pkg_archs.split():
                 pkgs_dir = os.path.join(self.deploy_dir, arch)
                 if os.path.isdir(pkgs_dir):
-                    config_file.write("src oe-%s file:%s\n" % (arch, pkgs_dir))
+                    config_file.write("src oe-%s file:%s\n" %
+                                      (arch, pkgs_dir))
 
     def update(self):
         self.deploy_dir_lock()
index 95c275875f12a01354748e0fef7ecf068a9ca540..7455a865a444a2d3b819db5e30444055b8b6e43b 100644 (file)
@@ -534,8 +534,9 @@ class OpkgRootfs(Rootfs):
         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
-        self.pm.write_index()
+        # 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)
 
index b54e51697c5596d14841a0a96557250340e83498..518076e75d3ec1d8b5fca1fbac6c30e5bff86a5c 100644 (file)
@@ -216,7 +216,9 @@ class OpkgSdk(Sdk):
     def _populate_sysroot(self, pm, manifest):
         pkgs_to_install = manifest.parse_initial_manifest()
 
-        pm.write_index()
+        if (self.d.getVar('BUILD_IMAGES_FROM_FEEDS', True) or "") != "1":
+            pm.write_index()
+
         pm.update()
 
         for pkg_type in self.install_order: