r4867 - trunk/src/target/opkg/libopkg
tick at docs.openmoko.org
tick at docs.openmoko.org
Sun Dec 14 12:10:14 CET 2008
Author: tick
Date: 2008-12-14 12:10:14 +0100 (Sun, 14 Dec 2008)
New Revision: 4867
Modified:
trunk/src/target/opkg/libopkg/active_list.c
trunk/src/target/opkg/libopkg/active_list.h
trunk/src/target/opkg/libopkg/opkg.c
trunk/src/target/opkg/libopkg/opkg_cmd.c
trunk/src/target/opkg/libopkg/opkg_upgrade.c
trunk/src/target/opkg/libopkg/opkg_upgrade.h
Log:
opkg: using active list to list upgradeable pkgs
Modified: trunk/src/target/opkg/libopkg/active_list.c
===================================================================
--- trunk/src/target/opkg/libopkg/active_list.c 2008-12-14 11:09:52 UTC (rev 4866)
+++ trunk/src/target/opkg/libopkg/active_list.c 2008-12-14 11:10:14 UTC (rev 4867)
@@ -18,6 +18,8 @@
#include "active_list.h"
#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
void active_list_init(struct active_list *ptr) {
@@ -103,3 +105,15 @@
list_add_tail(&node->node, &head->node);
node->depended = head;
}
+
+struct active_list * active_list_head_new() {
+ struct active_list * head = calloc(1, sizeof(struct active_list));
+ active_list_init(head);
+ return head;
+}
+
+void active_list_head_delete(struct active_list *head) {
+ active_list_clear(head);
+ free(head);
+}
+
Modified: trunk/src/target/opkg/libopkg/active_list.h
===================================================================
--- trunk/src/target/opkg/libopkg/active_list.h 2008-12-14 11:09:52 UTC (rev 4866)
+++ trunk/src/target/opkg/libopkg/active_list.h 2008-12-14 11:10:14 UTC (rev 4867)
@@ -26,6 +26,9 @@
struct active_list *depended;
};
+
+struct active_list * active_list_head_new();
+void active_list_head_delete(struct active_list *);
void active_list_init(struct active_list *ptr);
void active_list_clear(struct active_list *head);
void active_list_add_depend(struct active_list *node, struct active_list *depend);
Modified: trunk/src/target/opkg/libopkg/opkg.c
===================================================================
--- trunk/src/target/opkg/libopkg/opkg.c 2008-12-14 11:09:52 UTC (rev 4866)
+++ trunk/src/target/opkg/libopkg/opkg.c 2008-12-14 11:10:14 UTC (rev 4867)
@@ -940,32 +940,27 @@
int
opkg_list_upgradable_packages (opkg_t *opkg, opkg_package_callback_t callback, void *user_data)
{
- pkg_vec_t *all;
- int i;
+ struct active_list *head;
+ struct active_list *node;
+ pkg_t *old=NULL, *new = NULL;
+ static opkg_package_t* package=NULL;
+
opkg_assert (opkg);
opkg_assert (callback);
/* ensure all data is valid */
pkg_info_preinstall_check (opkg->conf);
- all = opkg_upgrade_all_list_get (opkg->conf);
- for (i = 0; i < all->len; i++)
- {
- pkg_t *old, *new;
- opkg_package_t *package;
-
- old = all->pkgs[i];
-
+ head = prepare_upgrade_list(opkg->conf);
+ for (node=active_list_next(head, head); node; active_list_next(head,node)) {
+ old = list_entry(node, pkg_t, list);
new = pkg_hash_fetch_best_installation_candidate_by_name(opkg->conf, old->name, NULL);
-
package = pkg_clone (new);
callback (opkg, package, user_data);
opkg_package_free (package);
}
-
- pkg_vec_free (all);
-
+ active_list_head_delete(head);
return 0;
}
Modified: trunk/src/target/opkg/libopkg/opkg_cmd.c
===================================================================
--- trunk/src/target/opkg/libopkg/opkg_cmd.c 2008-12-14 11:09:52 UTC (rev 4866)
+++ trunk/src/target/opkg/libopkg/opkg_cmd.c 2008-12-14 11:10:14 UTC (rev 4867)
@@ -786,12 +786,12 @@
static int opkg_list_upgradable_cmd(opkg_conf_t *conf, int argc, char **argv)
{
- pkg_vec_t *all = opkg_upgrade_all_list_get(conf);
+ struct active_list *head = prepare_upgrade_list(conf);
+ struct active_list *node=NULL;
pkg_t *_old_pkg, *_new_pkg;
char *old_v, *new_v;
- int i;
- for (i=0;i<all->len;i++) {
- _old_pkg = all->pkgs[i];
+ for (node = active_list_next(head, head); node;node = active_list_next(head,node)) {
+ _old_pkg = list_entry(node, pkg_t, list);
_new_pkg = pkg_hash_fetch_best_installation_candidate_by_name(conf, _old_pkg->name, NULL);
old_v = pkg_version_str_alloc(_old_pkg);
new_v = pkg_version_str_alloc(_new_pkg);
@@ -800,7 +800,7 @@
free(old_v);
free(new_v);
}
- pkg_vec_free(all);
+ active_list_head_delete(head);
return 0;
}
Modified: trunk/src/target/opkg/libopkg/opkg_upgrade.c
===================================================================
--- trunk/src/target/opkg/libopkg/opkg_upgrade.c 2008-12-14 11:09:52 UTC (rev 4866)
+++ trunk/src/target/opkg/libopkg/opkg_upgrade.c 2008-12-14 11:10:14 UTC (rev 4867)
@@ -78,17 +78,15 @@
return opkg_install_pkg(conf, new,1);
}
-
-
-pkg_vec_t *opkg_upgrade_all_list_get(opkg_conf_t *conf) {
- pkg_vec_t *all, *ans;
+struct active_list * prepare_upgrade_list (opkg_conf_t *conf) {
+ pkg_vec_t *all;
+ struct active_list * head = active_list_head_new();
int i;
/* ensure all data is valid */
pkg_info_preinstall_check (conf);
all = pkg_vec_alloc ();
- ans = pkg_vec_alloc ();
pkg_hash_fetch_all_installed (&conf->pkg_hash, all);
for (i = 0; i < all->len; i++)
{
@@ -103,9 +101,10 @@
cmp = pkg_compare_versions(old, new);
- if ( cmp < 0 )
- pkg_vec_insert(ans, old);
+ if ( cmp < 0 ) {
+ active_list_add(head, &old->list);
+ }
}
pkg_vec_free (all);
- return ans;
+ return head;
}
Modified: trunk/src/target/opkg/libopkg/opkg_upgrade.h
===================================================================
--- trunk/src/target/opkg/libopkg/opkg_upgrade.h 2008-12-14 11:09:52 UTC (rev 4866)
+++ trunk/src/target/opkg/libopkg/opkg_upgrade.h 2008-12-14 11:10:14 UTC (rev 4867)
@@ -12,6 +12,11 @@
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
*/
+#ifndef OPKG_UPGRADE_H
+#define OPKG_UPGRADE_H
+#include "active_list.h"
int opkg_upgrade_pkg(opkg_conf_t *conf, pkg_t *old);
-pkg_vec_t *opkg_upgrade_all_list_get(opkg_conf_t *conf);
+struct active_list * prepare_upgrade_list (opkg_conf_t *conf);
+
+#endif
More information about the commitlog
mailing list