summaryrefslogtreecommitdiffstats
path: root/libopkg
diff options
context:
space:
mode:
authorticktock35 <ticktock35@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358>2008-12-15 00:11:12 (EST)
committer ticktock35 <ticktock35@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358>2008-12-15 00:11:12 (EST)
commitbd09c115217e960cc1dff73d322e3e9581cf2d33 (patch)
treea2f52c696e32554b72f7a80c356b8b6f97f0267f /libopkg
parent20d4f5551c46c3be45255fc31c08f2b8be679fc3 (diff)
opkg: add progress callbacks to libopkg api
libopkg: fix opkg_install_package() git-svn-id: http://opkg.googlecode.com/svn/trunk@80 e8e0d7a0-c8d9-11dd-a880-a1081c7ac358
Diffstat (limited to 'libopkg')
-rw-r--r--libopkg/opkg.c45
-rw-r--r--libopkg/opkg.h11
2 files changed, 41 insertions, 15 deletions
diff --git a/libopkg/opkg.c b/libopkg/opkg.c
index b4aff13..7340a06 100644
--- a/libopkg/opkg.c
+++ b/libopkg/opkg.c
@@ -243,59 +243,72 @@ opkg_set_option (opkg_t *opkg, char *option, void *value)
}
int
-opkg_install_package (opkg_t *opkg, char *package_name)
+opkg_install_package (opkg_t *opkg, const char *package_name, opkg_progress_callback_t progress_callback, void *user_data)
{
int err;
+ char *package_id;
+ progress_callback (opkg, 0, user_data);
+
+ /* download the package */
+ opkg_prepare_url_for_install (opkg->conf, package_name, &package_id);
+ progress_callback (opkg, 50, user_data);
+
+ /* ... */
pkg_info_preinstall_check (opkg->conf);
+ /* unpack the package */
if (opkg->conf->multiple_providers)
{
- err = opkg_install_multi_by_name (opkg->conf, package_name);
+ err = opkg_install_multi_by_name (opkg->conf, package_id);
}
else
{
- err = opkg_install_by_name (opkg->conf, package_name);
+ err = opkg_install_by_name (opkg->conf, package_id);
}
- err = opkg_configure_packages (opkg->conf, NULL);
+ progress_callback (opkg, 75, user_data);
- if (opkg->conf->noaction)
- return err;
+ /* run configure scripts, etc. */
+ err = opkg_configure_packages (opkg->conf, NULL);
+ /* 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;
}
int
-opkg_remove_package (opkg_t *opkg, char *package_name)
+opkg_remove_package (opkg_t *opkg, const char *package_name, opkg_progress_callback_t progress_callback, void *user_data)
{
return 1;
}
int
-opkg_upgrade_package (opkg_t *opkg, char *package_name)
+opkg_upgrade_package (opkg_t *opkg, const char *package_name, opkg_progress_callback_t progress_callback, void *user_data)
{
return 1;
}
int
-opkg_upgrade_all (opkg_t *opkg)
+opkg_upgrade_all (opkg_t *opkg, opkg_progress_callback_t progress_callback, void *user_data)
{
return 1;
}
int
-opkg_update_package_lists (opkg_t *opkg)
+opkg_update_package_lists (opkg_t *opkg, opkg_progress_callback_t progress_callback, void *user_data)
{
char *tmp;
int err;
char *lists_dir;
pkg_src_list_elt_t *iter;
pkg_src_t *src;
+ int sources_list_count, sources_done;
+ progress_callback (opkg, 0, user_data);
sprintf_alloc (&lists_dir, "%s",
(opkg->conf->restrict_to_default_dest)
@@ -330,6 +343,15 @@ opkg_update_package_lists (opkg_t *opkg)
return 1;
}
+ /* cout the number of sources so we can give some progress updates */
+ sources_list_count = 0;
+ sources_done = 0;
+ iter = opkg->conf->pkg_src_list.head;
+ while (iter)
+ {
+ sources_list_count++;
+ iter = iter->next;
+ }
for (iter = opkg->conf->pkg_src_list.head; iter; iter = iter->next)
{
@@ -420,6 +442,9 @@ opkg_update_package_lists (opkg_t *opkg)
*/
#endif
free (list_file_name);
+
+ sources_done++;
+ progress_callback (opkg, 100 * sources_done / sources_list_count, user_data);
}
rmdir (tmp);
free (tmp);
diff --git a/libopkg/opkg.h b/libopkg/opkg.h
index 0ee1887..b35635a 100644
--- a/libopkg/opkg.h
+++ b/libopkg/opkg.h
@@ -16,6 +16,7 @@
*/
typedef struct _opkg_t opkg_t;
+typedef void (*opkg_progress_callback_t) (opkg_t *opkg, int percentage, void *user_data);
opkg_t* opkg_new ();
void opkg_free (opkg_t *opkg);
@@ -23,8 +24,8 @@ void opkg_get_option (opkg_t *opkg, char *option, void **value);
void opkg_set_option (opkg_t *opkg, char *option, void *value);
int opkg_read_config_files (opkg_t *opkg);
-int opkg_install_package (opkg_t *opkg, char *package_name);
-int opkg_remove_package (opkg_t *opkg, char *package_name);
-int opkg_upgrade_package (opkg_t *opkg, char *package_name);
-int opkg_upgrade_all (opkg_t *opkg);
-int opkg_update_package_lists (opkg_t *opkg);
+int opkg_install_package (opkg_t *opkg, const char *package_name, opkg_progress_callback_t callback, void *user_data);
+int opkg_remove_package (opkg_t *opkg, const char *package_name, opkg_progress_callback_t callback, void *user_data);
+int opkg_upgrade_package (opkg_t *opkg, const char *package_name, opkg_progress_callback_t callback, void *user_data);
+int opkg_upgrade_all (opkg_t *opkg, opkg_progress_callback_t callback, void *user_data);
+int opkg_update_package_lists (opkg_t *opkg, opkg_progress_callback_t callback, void *user_data);