r4390 - in trunk/src/target/opkg: . libopkg tests
thomas at sita.openmoko.org
thomas at sita.openmoko.org
Tue Apr 22 18:27:49 CEST 2008
Author: thomas
Date: 2008-04-22 18:27:47 +0200 (Tue, 22 Apr 2008)
New Revision: 4390
Modified:
trunk/src/target/opkg/Makefile.am
trunk/src/target/opkg/libopkg/opkg.c
trunk/src/target/opkg/tests/libopkg_test.c
Log:
opkg: fix problems in opkg_install_package and implement opkg_remove_package
Modified: trunk/src/target/opkg/Makefile.am
===================================================================
--- trunk/src/target/opkg/Makefile.am 2008-04-22 11:14:35 UTC (rev 4389)
+++ trunk/src/target/opkg/Makefile.am 2008-04-22 16:27:47 UTC (rev 4390)
@@ -1,4 +1,4 @@
-SUBDIRS = libbb libopkg src
+SUBDIRS = libbb libopkg src tests
HOST_CPU=@host_cpu@
BUILD_CPU=@build_cpu@
Modified: trunk/src/target/opkg/libopkg/opkg.c
===================================================================
--- trunk/src/target/opkg/libopkg/opkg.c 2008-04-22 11:14:35 UTC (rev 4389)
+++ trunk/src/target/opkg/libopkg/opkg.c 2008-04-22 16:27:47 UTC (rev 4390)
@@ -25,6 +25,7 @@
#include "opkg_install.h"
#include "opkg_configure.h"
#include "opkg_download.h"
+#include "opkg_remove.h"
#include "sprintf_alloc.h"
#include "file_util.h"
@@ -246,7 +247,7 @@
opkg_install_package (opkg_t *opkg, const char *package_name, opkg_progress_callback_t progress_callback, void *user_data)
{
int err;
- char *package_id;
+ char *package_id = NULL;
progress_callback (opkg, 0, user_data);
@@ -257,6 +258,9 @@
/* ... */
pkg_info_preinstall_check (opkg->conf);
+ if (!package_id)
+ package_id = strdup (package_name);
+
/* unpack the package */
if (opkg->conf->multiple_providers)
{
@@ -267,23 +271,85 @@
err = opkg_install_by_name (opkg->conf, package_id);
}
+ if (err)
+ return err;
+
progress_callback (opkg, 75, user_data);
/* run configure scripts, etc. */
err = opkg_configure_packages (opkg->conf, NULL);
+ if (err)
+ return err;
/* write out status files and file lists */
opkg_conf_write_status_files (opkg->conf);
pkg_write_changed_filelists (opkg->conf);
progress_callback (opkg, 100, user_data);
- return err;
+ return 0;
}
int
opkg_remove_package (opkg_t *opkg, const char *package_name, opkg_progress_callback_t progress_callback, void *user_data)
{
- return 1;
+ pkg_t *pkg = NULL;
+ pkg_t *pkg_to_remove;
+
+ if (!opkg)
+ return 1;
+
+ if (!package_name)
+ return 1;
+
+ progress_callback (opkg, 0, user_data);
+
+ pkg_info_preinstall_check (opkg->conf);
+
+ pkg_vec_t *installed_pkgs = pkg_vec_alloc ();
+
+ pkg_hash_fetch_all_installed (&opkg->conf->pkg_hash, installed_pkgs);
+
+ progress_callback (opkg, 25, user_data);
+
+ pkg = pkg_hash_fetch_installed_by_name (&opkg->conf->pkg_hash, package_name);
+
+ if (pkg == NULL)
+ {
+ /* XXX: Error: Package not installed. */
+ return 1;
+ }
+
+ if (pkg->state_status == SS_NOT_INSTALLED)
+ {
+ /* XXX: Error: Package seems to be not installed (STATUS = NOT_INSTALLED). */
+ return 1;
+ }
+
+ progress_callback (opkg, 75, user_data);
+
+ if (opkg->conf->restrict_to_default_dest)
+ {
+ pkg_to_remove = pkg_hash_fetch_installed_by_name_dest (&opkg->conf->pkg_hash,
+ pkg->name,
+ opkg->conf->default_dest);
+ }
+ else
+ {
+ pkg_to_remove = pkg_hash_fetch_installed_by_name (&opkg->conf->pkg_hash, pkg->name );
+ }
+
+
+ progress_callback (opkg, 75, user_data);
+
+ opkg_remove_pkg (opkg->conf, pkg_to_remove, 0);
+
+ /* write out status files and file lists */
+ opkg_conf_write_status_files (opkg->conf);
+ pkg_write_changed_filelists (opkg->conf);
+
+
+ progress_callback (opkg, 100, user_data);
+ return 0;
}
int
Modified: trunk/src/target/opkg/tests/libopkg_test.c
===================================================================
--- trunk/src/target/opkg/tests/libopkg_test.c 2008-04-22 11:14:35 UTC (rev 4389)
+++ trunk/src/target/opkg/tests/libopkg_test.c 2008-04-22 16:27:47 UTC (rev 4390)
@@ -29,5 +29,9 @@
printf ("opkg_install_package returned %d\n", err);
+ err = opkg_remove_package (opkg, "aspell", progress_callback, "Removing...");
+
+ printf ("opkg_remove_package returned %d\n", err);
+
opkg_free (opkg);
}
More information about the commitlog
mailing list