summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorticktock35 <ticktock35@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358>2008-12-15 00:12:39 (EST)
committer ticktock35 <ticktock35@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358>2008-12-15 00:12:39 (EST)
commitd0de5e2ecd8ea32731c56350925640f11f177ac8 (patch)
tree2eb367e92166650b7cea5b06b54454cab8ad2ecc
parentb6ceb5e11ae20ede9b30979d4b54c56f84e89eaf (diff)
opkg: implement new opkg_upgrade_package and opkg_upgrade_all functions
git-svn-id: http://opkg.googlecode.com/svn/trunk@87 e8e0d7a0-c8d9-11dd-a880-a1081c7ac358
-rw-r--r--libopkg/opkg.c71
1 files changed, 69 insertions, 2 deletions
diff --git a/libopkg/opkg.c b/libopkg/opkg.c
index fc7bd3f..e72693c 100644
--- a/libopkg/opkg.c
+++ b/libopkg/opkg.c
@@ -406,13 +406,80 @@ opkg_remove_package (opkg_t *opkg, const char *package_name, opkg_progress_callb
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