r4395 - trunk/src/target/opkg/libopkg

thomas at sita.openmoko.org thomas at sita.openmoko.org
Thu Apr 24 13:03:32 CEST 2008


Author: thomas
Date: 2008-04-24 13:03:31 +0200 (Thu, 24 Apr 2008)
New Revision: 4395

Modified:
   trunk/src/target/opkg/libopkg/opkg.c
Log:
opkg: implement new opkg_upgrade_package and opkg_upgrade_all functions


Modified: trunk/src/target/opkg/libopkg/opkg.c
===================================================================
--- trunk/src/target/opkg/libopkg/opkg.c	2008-04-23 15:40:38 UTC (rev 4394)
+++ trunk/src/target/opkg/libopkg/opkg.c	2008-04-24 11:03:31 UTC (rev 4395)
@@ -406,13 +406,80 @@
 int
 opkg_upgrade_package (opkg_t *opkg, const char *package_name, opkg_progress_callback_t progress_callback, void *user_data)
 {
-  return 1;
+  pkg_t *pkg;
+
+  opkg_assert (opkg != NULL);
+  opkg_assert (package_name != NULL);
+
+  progress (0);
+
+  pkg_info_preinstall_check (opkg->conf);
+
+  if (opkg->conf->restrict_to_default_dest)
+  {
+    pkg = pkg_hash_fetch_installed_by_name_dest (&opkg->conf->pkg_hash,
+                                                 package_name,
+                                                 opkg->conf->default_dest);
+    if (pkg == NULL)
+    {
+      /* XXX: Error: Package not installed in default_dest */
+      return 1;
+    }
+  }
+  else
+  {
+    pkg = pkg_hash_fetch_installed_by_name (&opkg->conf->pkg_hash,
+                                            package_name);
+  }
+
+  if (!pkg)
+  {
+    /* XXX: Error: Package not installed */
+    return 1;
+  }
+
+  progress (25);
+
+  opkg_upgrade_pkg (opkg->conf, pkg);
+  progress (75);
+
+  opkg_configure_packages (opkg->conf, NULL);
+  progress (100);
+  return 0;
 }
 
 int
 opkg_upgrade_all (opkg_t *opkg, opkg_progress_callback_t progress_callback, void *user_data)
 {
-  return 1;
+  pkg_vec_t *installed;
+  int err = 0;
+  int i;
+  pkg_t *pkg;
+
+  opkg_assert (opkg != NULL);
+  progress (0);
+
+  installed = pkg_vec_alloc ();
+  pkg_info_preinstall_check (opkg->conf);
+
+  pkg_hash_fetch_all_installed (&opkg->conf->pkg_hash, installed);
+  for (i = 0; i < installed->len; i++)
+  {
+    pkg = installed->pkgs[i];
+    err += opkg_upgrade_pkg (opkg->conf, pkg);
+    progress (100 * i / installed->len);
+  }
+  pkg_vec_free (installed);
+
+  if (err)
+    return 1;
+
+  err = opkg_configure_packages (opkg->conf, NULL);
+  if (err)
+    return 1;
+
+  progress (100);
+  return 0;
 }
 
 int





More information about the commitlog mailing list