-+ The 3 state fields could possibly also go into their own struct.
-+
-+ All fields which deal with lists of packages, (Depends,
-+ Pre-Depends, Provides, Suggests, Recommends, Enhances), should each
-+ be handled by a single struct in pkg_t
-+
-+ All string fields for which there is a small set of possible
-+ values, (section, maintainer, architecture, maybe version?), that
-+ are reused among different packages -- for all such packages we
-+ should move from "char *"s to some atom datatype to share data
-+ storage and use less memory. We might even do reference counting,
-+ but probably not since most often we only create new pkg_t structs,
-+ we don't often free them. */
-+struct pkg
-+{
-+ char *name;
-+ unsigned long epoch;
-+ char *version;
-+ char *revision;
-+ char *familiar_revision;
-+ pkg_src_t *src;
-+ pkg_dest_t *dest;
-+ char *architecture;
-+ char *section;
-+ char *maintainer;
-+ char *description;
-+ pkg_state_want_t state_want;
-+ pkg_state_flag_t state_flag;
-+ pkg_state_status_t state_status;
-+ char **depends_str;
-+ int depends_count;
-+ char **pre_depends_str;
-+ int pre_depends_count;
-+ char **recommends_str;
-+ int recommends_count;
-+ char **suggests_str;
-+ int suggests_count;
-+ compound_depend_t * depends;
-+
-+ /* Abhaya: new conflicts */
-+ char **conflicts_str;
-+ compound_depend_t * conflicts;
-+ int conflicts_count;
-+
-+ char **replaces_str;
-+ int replaces_count;
-+ abstract_pkg_t ** replaces;
-+
-+ char **provides_str;
-+ int provides_count;
-+ abstract_pkg_t ** provides;
-+
-+ abstract_pkg_t *parent;
-+
-+ pkg_t *old_pkg; /* during upgrade, points from installee to previously installed */
-+
-+ char *filename;
-+ char *local_filename;
-+ char *url;
-+ char *tmp_unpack_dir;
-+ char *md5sum;
-+ char *size;
-+ char *installed_size;
-+ char *priority;
-+ char *source;
-+ conffile_list_t conffiles;
-+ time_t installed_time;
-+ /* As pointer for lazy evaluation */
-+ str_list_t *installed_files;
-+ /* XXX: CLEANUP: I'd like to perhaps come up with a better
-+ mechanism to avoid the problem here, (which is that the
-+ installed_files list was being freed from an inner loop while
-+ still being used within an outer loop. */
-+ int installed_files_ref_cnt;
-+ int essential;
-+ int arch_priority;
-+};
-+
-+pkg_t *pkg_new(void);
-+int pkg_init(pkg_t *pkg);
-+void pkg_deinit(pkg_t *pkg);
-+int pkg_init_from_file(pkg_t *pkg, const char *filename);
-+abstract_pkg_t *abstract_pkg_new(void);
-+int abstract_pkg_init(abstract_pkg_t *ab_pkg);
-+
-+/*
-+ * merges fields from newpkg into oldpkg.
-+ * Forcibly sets oldpkg state_status, state_want and state_flags if set_status is nonzero
-+ */
-+int pkg_merge(pkg_t *oldpkg, pkg_t *newpkg, int set_status);
-+
-+char *pkg_version_str_alloc(pkg_t *pkg);
-+
-+int pkg_compare_versions(const pkg_t *pkg, const pkg_t *ref_pkg);
-+int pkg_name_version_and_architecture_compare(void *a, void *b);
-+int abstract_pkg_name_compare(void *a, void *b);
-+
-+char * pkg_formatted_info(pkg_t *pkg );
-+char * pkg_formatted_field(pkg_t *pkg, const char *field );
-+
-+void set_flags_from_control(ipkg_conf_t *conf, pkg_t *pkg);
-+
-+void pkg_print_info(pkg_t *pkg, FILE *file);
-+void pkg_print_status(pkg_t * pkg, FILE * file);
-+void pkg_print_field(pkg_t *pkg, FILE *file, const char *field);
-+str_list_t *pkg_get_installed_files(pkg_t *pkg);
-+int pkg_free_installed_files(pkg_t *pkg);
-+int pkg_remove_installed_files_list(ipkg_conf_t *conf, pkg_t *pkg);
-+conffile_t *pkg_get_conffile(pkg_t *pkg, const char *file_name);
-+int pkg_run_script(struct ipkg_conf *conf, pkg_t *pkg,
-+ const char *script, const char *args);
-+
-+/* enum mappings */
-+char *pkg_state_want_to_str(pkg_state_want_t sw);
-+pkg_state_want_t pkg_state_want_from_str(char *str);
-+char *pkg_state_flag_to_str(pkg_state_flag_t sf);
-+pkg_state_flag_t pkg_state_flag_from_str(char *str);
-+char *pkg_state_status_to_str(pkg_state_status_t ss);
-+pkg_state_status_t pkg_state_status_from_str(char *str);
-+
-+int pkg_version_satisfied(pkg_t *it, pkg_t *ref, const char *op);
-+
-+int pkg_arch_supported(ipkg_conf_t *conf, pkg_t *pkg);
-+int pkg_info_preinstall_check(ipkg_conf_t *conf);
-+int pkg_free_installed_files(pkg_t *pkg);
-+
-+int pkg_write_filelist(ipkg_conf_t *conf, pkg_t *pkg);
-+int pkg_write_changed_filelists(ipkg_conf_t *conf);
-+
-+#endif
-diff -ruN busybox-1.1.1-old/archival/libipkg/pkg_depends.c busybox-1.1.1-new/archival/libipkg/pkg_depends.c
---- busybox-1.1.1-old/archival/libipkg/pkg_depends.c 1970-01-01 01:00:00.000000000 +0100
-+++ busybox-1.1.1-new/archival/libipkg/pkg_depends.c 2006-03-30 00:39:48.000000000 +0200
-@@ -0,0 +1,1029 @@
-+/* pkg_depends.c - the itsy package management system
-+
-+ Steven M. Ayer
-+
-+ Copyright (C) 2002 Compaq Computer Corporation
-+
-+ This program is free software; you can redistribute it and/or
-+ modify it under the terms of the GNU General Public License as
-+ published by the Free Software Foundation; either version 2, or (at
-+ your option) any later version.
-+
-+ This program is distributed in the hope that it will be useful, but
-+ WITHOUT ANY WARRANTY; without even the implied warranty of
-+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-+ General Public License for more details.
-+*/
-+
-+#include "ipkg.h"
-+#include <errno.h>
-+#include <ctype.h>
-+
-+#include "pkg.h"
-+#include "ipkg_utils.h"
-+#include "pkg_hash.h"
-+#include "ipkg_message.h"
-+#include "pkg_parse.h"
-+#include "hash_table.h"
-+
-+static int parseDepends(compound_depend_t *compound_depend, hash_table_t * hash, char * depend_str);
-+static depend_t * depend_init(void);
-+static void depend_deinit(depend_t *d);
-+static char ** add_unresolved_dep(pkg_t * pkg, char ** the_lost, int ref_ndx);
-+static char ** merge_unresolved(char ** oldstuff, char ** newstuff);
-+static int is_pkg_in_pkg_vec(pkg_vec_t * vec, pkg_t * pkg);
-+
-+static int pkg_installed_and_constraint_satisfied(pkg_t *pkg, void *cdata)
-+{
-+ depend_t *depend = (depend_t *)cdata;
-+ if ((pkg->state_status == SS_INSTALLED || pkg->state_status == SS_UNPACKED) && version_constraints_satisfied(depend, pkg))
-+ return 1;
-+ else
-+ return 0;
-+}
-+
-+static int pkg_constraint_satisfied(pkg_t *pkg, void *cdata)
-+{
-+ depend_t *depend = (depend_t *)cdata;
-+#if 0
-+ pkg_t * temp = pkg_new();
-+ int comparison;
-+ parseVersion(temp, depend->version);
-+ comparison = pkg_compare_versions(pkg, temp);
-+ free(temp);
-+
-+ fprintf(stderr, "%s: pkg=%s pkg->version=%s constraint=%p type=%d version=%s comparison=%d satisfied=%d\n",
-+ __FUNCTION__, pkg->name, pkg->version,
-+ depend, depend->constraint, depend->version,
-+ comparison, version_constraints_satisfied(depend, pkg));
-+#endif
-+ if (version_constraints_satisfied(depend, pkg))
-+ return 1;
-+ else
-+ return 0;
-+}
-+
-+/* returns ndependences or negative error value */
-+int pkg_hash_fetch_unsatisfied_dependencies(ipkg_conf_t *conf, pkg_t * pkg,
-+ pkg_vec_t *unsatisfied, char *** unresolved)
-+{
-+ pkg_t * satisfier_entry_pkg;
-+ register int i, j, k;
-+ int count, found;
-+ char ** the_lost;
-+ abstract_pkg_t * ab_pkg;
-+
-+ /*
-+ * this is a setup to check for redundant/cyclic dependency checks,
-+ * which are marked at the abstract_pkg level
-+ */
-+ if (!(ab_pkg = pkg->parent)) {
-+ fprintf(stderr, "%s:%d: something terribly wrong with pkg %s\n", __FUNCTION__, __LINE__, pkg->name);
-+ *unresolved = NULL;
-+ return 0;
-+ }
-+ if (ab_pkg->dependencies_checked) { /* avoid duplicate or cyclic checks */
-+ *unresolved = NULL;
-+ return 0;
-+ } else {
-+ ab_pkg->dependencies_checked = 1; /* mark it for subsequent visits */
-+ }
-+ /**/
-+
-+ count = pkg->pre_depends_count + pkg->depends_count + pkg->recommends_count + pkg->suggests_count;
-+ if (!count){
-+ *unresolved = NULL;
-+ return 0;
-+ }
-+
-+ the_lost = NULL;
-+
-+ /* foreach dependency */
-+ for (i = 0; i < count; i++) {
-+ compound_depend_t * compound_depend = &pkg->depends[i];
-+ depend_t ** possible_satisfiers = compound_depend->possibilities;;
-+ found = 0;
-+ satisfier_entry_pkg = NULL;