Send commitlog mailing list submissions to
commitlog@lists.openmoko.org
To subscribe or unsubscribe via the World Wide Web, visit
http://lists.openmoko.org/mailman/listinfo/commitlog
or, via email, send a message with subject or body 'help' to
commitlog-requ...@lists.openmoko.org
You can reach the person managing the list at
commitlog-ow...@lists.openmoko.org
When replying, please edit your Subject line so it is more specific
than "Re: Contents of commitlog digest..."
Today's Topics:
1. r4863 - trunk/src/target/opkg/libopkg (t...@docs.openmoko.org)
2. r4864 - trunk/src/target/opkg/libopkg (t...@docs.openmoko.org)
3. r4865 - trunk/src/target/opkg (t...@docs.openmoko.org)
4. r4866 - trunk/src/target/opkg/libopkg (t...@docs.openmoko.org)
5. r4867 - trunk/src/target/opkg/libopkg (t...@docs.openmoko.org)
6. r4868 - trunk/src/target/opkg/libopkg (t...@docs.openmoko.org)
7. r4869 - trunk/src/target/opkg (t...@docs.openmoko.org)
--- Begin Message ---
Author: tick
Date: 2008-12-14 12:09:16 +0100 (Sun, 14 Dec 2008)
New Revision: 4863
Modified:
trunk/src/target/opkg/libopkg/active_list.c
trunk/src/target/opkg/libopkg/pkg.c
trunk/src/target/opkg/libopkg/pkg.h
Log:
opkg: introduce active list into pkg_t
Modified: trunk/src/target/opkg/libopkg/active_list.c
===================================================================
--- trunk/src/target/opkg/libopkg/active_list.c 2008-12-13 13:28:33 UTC (rev
4862)
+++ trunk/src/target/opkg/libopkg/active_list.c 2008-12-14 11:09:16 UTC (rev
4863)
@@ -86,6 +86,10 @@
}
void active_list_clear(struct active_list *head) {
list_head_clear(&head->node);
+ if (head->depend.next != &head->depend) {
+ list_head_clear(&head->depend);
+ }
+ active_list_init(head);
}
void active_list_add_depend(struct active_list *node, struct active_list
*depend) {
Modified: trunk/src/target/opkg/libopkg/pkg.c
===================================================================
--- trunk/src/target/opkg/libopkg/pkg.c 2008-12-13 13:28:33 UTC (rev 4862)
+++ trunk/src/target/opkg/libopkg/pkg.c 2008-12-14 11:09:16 UTC (rev 4863)
@@ -90,7 +90,6 @@
int pkg_init(pkg_t *pkg)
{
- memset(pkg, 0, sizeof(pkg_t));
pkg->name = NULL;
pkg->epoch = 0;
pkg->version = NULL;
@@ -112,6 +111,8 @@
pkg->recommends_str = NULL;
pkg->suggests_count = 0;
pkg->recommends_count = 0;
+
+ active_list_init(&pkg->list);
/* Abhaya: added init for conflicts fields */
pkg->conflicts = NULL;
@@ -183,7 +184,8 @@
pkg->state_flag = SF_OK;
pkg->state_status = SS_NOT_INSTALLED;
- //for (i = 0; i < pkg->replaces_count; i++)
+ active_list_clear(&pkg->list);
+
free (pkg->replaces);
pkg->replaces = NULL;
Modified: trunk/src/target/opkg/libopkg/pkg.h
===================================================================
--- trunk/src/target/opkg/libopkg/pkg.h 2008-12-13 13:28:33 UTC (rev 4862)
+++ trunk/src/target/opkg/libopkg/pkg.h 2008-12-14 11:09:16 UTC (rev 4863)
@@ -24,6 +24,7 @@
#include "pkg_vec.h"
#include "str_list.h"
+#include "active_list.h"
#include "pkg_src.h"
#include "pkg_dest.h"
#include "opkg_conf.h"
@@ -135,6 +136,7 @@
int recommends_count;
char **suggests_str;
int suggests_count;
+ struct active_list list; /* Used for installing|upgrading */
compound_depend_t * depends;
/* Abhaya: new conflicts */
--- End Message ---
--- Begin Message ---
Author: tick
Date: 2008-12-14 12:09:29 +0100 (Sun, 14 Dec 2008)
New Revision: 4864
Modified:
trunk/src/target/opkg/libopkg/opkg.c
Log:
opkg: trivial rename old_pkg_to_new to pkg_clone as a more readable name.
Modified: trunk/src/target/opkg/libopkg/opkg.c
===================================================================
--- trunk/src/target/opkg/libopkg/opkg.c 2008-12-14 11:09:16 UTC (rev
4863)
+++ trunk/src/target/opkg/libopkg/opkg.c 2008-12-14 11:09:29 UTC (rev
4864)
@@ -52,8 +52,11 @@
/** Private Functions ***/
+/**
+ * Clone a pkg_t
+ */
static opkg_package_t*
-old_pkg_to_new (pkg_t *old)
+pkg_clone (pkg_t *old)
{
opkg_package_t *new;
@@ -70,6 +73,8 @@
new->tags = sstrdup (old->tags);
new->url = sstrdup (old->url);
+#undef sstrdup
+
new->size = (old->size) ? atoi (old->size) : 0;
new->installed = (old->state_status == SS_INSTALLED);
@@ -418,7 +423,7 @@
new->state_flag |= SF_USER;
pdata.action = OPKG_INSTALL;
- pdata.package = old_pkg_to_new (new);
+ pdata.package = pkg_clone (new);
progress (pdata, 0);
@@ -448,7 +453,7 @@
continue;
opkg_package_free (pdata.package);
- pdata.package = old_pkg_to_new (pkg);
+ pdata.package = pkg_clone (pkg);
pdata.action = OPKG_DOWNLOAD;
if (pkg->src == NULL)
@@ -500,7 +505,7 @@
/* 75% of "install" progress is for downloading */
opkg_package_free (pdata.package);
- pdata.package = old_pkg_to_new (new);
+ pdata.package = pkg_clone (new);
pdata.action = OPKG_INSTALL;
progress (pdata, 75);
@@ -564,7 +569,7 @@
}
pdata.action = OPKG_REMOVE;
- pdata.package = old_pkg_to_new (pkg);
+ pdata.package = pkg_clone (pkg);
progress (pdata, 0);
@@ -640,7 +645,7 @@
}
pdata.action = OPKG_INSTALL;
- pdata.package = old_pkg_to_new (pkg);
+ pdata.package = pkg_clone (pkg);
progress (pdata, 0);
err = opkg_upgrade_pkg (opkg->conf, pkg);
@@ -701,7 +706,7 @@
{
pkg = installed->pkgs[i];
- pdata.package = old_pkg_to_new (pkg);
+ pdata.package = pkg_clone (pkg);
progress (pdata, 99 * i / installed->len);
opkg_package_free (pdata.package);
@@ -916,7 +921,7 @@
pkg = all->pkgs[i];
- package = old_pkg_to_new (pkg);
+ package = pkg_clone (pkg);
callback (opkg, package, user_data);
opkg_package_free (package);
}
@@ -948,7 +953,7 @@
new = pkg_hash_fetch_best_installation_candidate_by_name(opkg->conf,
old->name, NULL);
- package = old_pkg_to_new (new);
+ package = pkg_clone (new);
callback (opkg, package, user_data);
opkg_package_free (package);
}
@@ -1005,7 +1010,7 @@
}
/* match found */
- package = old_pkg_to_new (pkg);
+ package = pkg_clone (pkg);
break;
}
--- End Message ---
--- Begin Message ---
Author: tick
Date: 2008-12-14 12:09:38 +0100 (Sun, 14 Dec 2008)
New Revision: 4865
Modified:
trunk/src/target/opkg/TODO
Log:
opkg: update TODO
Modified: trunk/src/target/opkg/TODO
===================================================================
--- trunk/src/target/opkg/TODO 2008-12-14 11:09:29 UTC (rev 4864)
+++ trunk/src/target/opkg/TODO 2008-12-14 11:09:38 UTC (rev 4865)
@@ -50,3 +50,7 @@
3) Cleanup the code
3.a) Start with all comments marked "XXX: CLEANUP"
+
+3.b) Clean up out of date comments. That really confusing
+
+4) refactorying opkg_install_pkg into more precise functions
--- End Message ---
--- Begin Message ---
Author: tick
Date: 2008-12-14 12:09:52 +0100 (Sun, 14 Dec 2008)
New Revision: 4866
Modified:
trunk/src/target/opkg/libopkg/opkg.c
trunk/src/target/opkg/libopkg/opkg_install.c
Log:
opkg: trivial adding some comments
Modified: trunk/src/target/opkg/libopkg/opkg.c
===================================================================
--- trunk/src/target/opkg/libopkg/opkg.c 2008-12-14 11:09:38 UTC (rev
4865)
+++ trunk/src/target/opkg/libopkg/opkg.c 2008-12-14 11:09:52 UTC (rev
4866)
@@ -387,6 +387,12 @@
}
+/**
+ * @brief libopkg API: Install package
+ * @param opkg Then opkg handler
+ * @param package_name The name of package in which is going to install
+ * @param progress_callback The callback function that report the status to
caller.
+ */
int
opkg_install_package (opkg_t *opkg, const char *package_name,
opkg_progress_callback_t progress_callback, void *user_data)
{
Modified: trunk/src/target/opkg/libopkg/opkg_install.c
===================================================================
--- trunk/src/target/opkg/libopkg/opkg_install.c 2008-12-14 11:09:38 UTC
(rev 4865)
+++ trunk/src/target/opkg/libopkg/opkg_install.c 2008-12-14 11:09:52 UTC
(rev 4866)
@@ -748,7 +748,9 @@
}
}
-/* and now the meat... */
+/**
+ * @brief Really install a pkg_t
+ */
int opkg_install_pkg(opkg_conf_t *conf, pkg_t *pkg, int from_upgrade)
{
int err = 0;
--- End Message ---
--- Begin Message ---
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
--- End Message ---
--- Begin Message ---
Author: tick
Date: 2008-12-14 12:10:32 +0100 (Sun, 14 Dec 2008)
New Revision: 4868
Modified:
trunk/src/target/opkg/libopkg/active_list.c
trunk/src/target/opkg/libopkg/active_list.h
trunk/src/target/opkg/libopkg/opkg_upgrade.c
Log:
opkg: using active_list to list all the installed pkgs.
adding function that allows node move from one list to another
Modified: trunk/src/target/opkg/libopkg/active_list.c
===================================================================
--- trunk/src/target/opkg/libopkg/active_list.c 2008-12-14 11:10:14 UTC (rev
4867)
+++ trunk/src/target/opkg/libopkg/active_list.c 2008-12-14 11:10:32 UTC (rev
4868)
@@ -73,6 +73,18 @@
return prev;
}
+
+struct active_list *active_list_move_node(struct active_list *old_head, struct
active_list *new_head, struct active_list *node) {
+ struct active_list *prev;
+ if (!old_head || !new_head || !node)
+ return NULL;
+ if (old_head == new_head)
+ return node;
+ prev = active_list_prev(old_head, node);
+ active_list_add(new_head, node);
+ return prev;
+}
+
static void list_head_clear (struct list_head *head) {
struct active_list *next;
struct list_head *n, *ptr;
Modified: trunk/src/target/opkg/libopkg/active_list.h
===================================================================
--- trunk/src/target/opkg/libopkg/active_list.h 2008-12-14 11:10:14 UTC (rev
4867)
+++ trunk/src/target/opkg/libopkg/active_list.h 2008-12-14 11:10:32 UTC (rev
4868)
@@ -33,6 +33,7 @@
void active_list_clear(struct active_list *head);
void active_list_add_depend(struct active_list *node, struct active_list
*depend);
void active_list_add(struct active_list *head, struct active_list *node);
+struct active_list *active_list_move_node(struct active_list *old_head, struct
active_list *new_head, struct active_list *node);
struct active_list * active_list_next(struct active_list *head, struct
active_list *ptr);
Modified: trunk/src/target/opkg/libopkg/opkg_upgrade.c
===================================================================
--- trunk/src/target/opkg/libopkg/opkg_upgrade.c 2008-12-14 11:10:14 UTC
(rev 4867)
+++ trunk/src/target/opkg/libopkg/opkg_upgrade.c 2008-12-14 11:10:32 UTC
(rev 4868)
@@ -78,22 +78,36 @@
return opkg_install_pkg(conf, new,1);
}
+
+static void pkg_hash_check_installed_pkg_helper(const char *pkg_name, void
*entry, void *data) {
+ struct active_list * head = (struct active_list *) data;
+ abstract_pkg_t *ab_pkg = (abstract_pkg_t *)entry;
+ pkg_vec_t *pkg_vec = ab_pkg->pkgs;
+ int j;
+ if (pkg_vec) {
+ for (j = 0; j < pkg_vec->len; j++) {
+ pkg_t *pkg = pkg_vec->pkgs[j];
+ if (pkg->state_status == SS_INSTALLED || pkg->state_status ==
SS_UNPACKED) {
+ active_list_add(head, &pkg->list);
+ }
+ }
+ }
+}
+
struct active_list * prepare_upgrade_list (opkg_conf_t *conf) {
- pkg_vec_t *all;
struct active_list * head = active_list_head_new();
- int i;
+ struct active_list * all = active_list_head_new();
+ struct active_list *node=NULL;
/* ensure all data is valid */
pkg_info_preinstall_check (conf);
- all = pkg_vec_alloc ();
- pkg_hash_fetch_all_installed (&conf->pkg_hash, all);
- for (i = 0; i < all->len; i++)
- {
+ hash_table_foreach(&conf->pkg_hash, pkg_hash_check_installed_pkg_helper,
all);
+ for (node=active_list_next(all,all); node; node = active_list_next(all,
node)) {
pkg_t *old, *new;
int cmp;
- old = all->pkgs[i];
+ old = list_entry(node, pkg_t, list);
new = pkg_hash_fetch_best_installation_candidate_by_name(conf,
old->name, NULL);
if (new == NULL)
@@ -102,9 +116,9 @@
cmp = pkg_compare_versions(old, new);
if ( cmp < 0 ) {
- active_list_add(head, &old->list);
+ node = active_list_move_node(all, head, &old->list);
}
}
- pkg_vec_free (all);
+ active_list_head_delete(all);
return head;
}
--- End Message ---
--- Begin Message ---
Author: tick
Date: 2008-12-14 12:10:43 +0100 (Sun, 14 Dec 2008)
New Revision: 4869
Modified:
trunk/src/target/opkg/TODO
Log:
opkg: Update TODO and remark that pkg_hash_fetch_best_installation_candidate
is very slow and been called very often. This has a huge improve space.
Modified: trunk/src/target/opkg/TODO
===================================================================
--- trunk/src/target/opkg/TODO 2008-12-14 11:10:32 UTC (rev 4868)
+++ trunk/src/target/opkg/TODO 2008-12-14 11:10:43 UTC (rev 4869)
@@ -54,3 +54,9 @@
3.b) Clean up out of date comments. That really confusing
4) refactorying opkg_install_pkg into more precise functions
+4.1) refactory upgrade list first
+4.2) Finding canditate is linear search O(P*PN) and is very slow (been called
very frequently)
+ P provider
+ PN pkgs in a provider
+ It's can be O(P) if there we use hash table.
+ It should be refacotry to a faster one.
--- End Message ---
_______________________________________________
commitlog mailing list
commitlog@lists.openmoko.org
http://lists.openmoko.org/mailman/listinfo/commitlog