Index: ipkg_cmd.c
===================================================================
RCS file: /cvs/familiar/dist/ipkg/C/ipkg_cmd.c,v
retrieving revision 1.89
diff -u -3 -p -u -r1.89 ipkg_cmd.c
--- ipkg_cmd.c	29 Mar 2004 21:13:12 -0000	1.89
+++ ipkg_cmd.c	2 Apr 2004 15:44:17 -0000
@@ -139,7 +139,7 @@ ipkg_cmd_t *ipkg_cmd_find(const char *na
 }
 
 #ifdef IPKG_LIB
-int ipkg_cmd_exec(ipkg_cmd_t *cmd, ipkg_conf_t *conf, int argc, const char **argv, void *userdata)
+int ipkg_cmd_exec(ipkg_cmd_t *cmd, ipkg_conf_t *conf, int argc, char **argv, void *userdata)
 {
 	int result;
 	p_userdata = userdata;
@@ -148,7 +148,7 @@ int ipkg_cmd_exec(ipkg_cmd_t *cmd, ipkg_
 	return result;
 }
 #else
-int ipkg_cmd_exec(ipkg_cmd_t *cmd, ipkg_conf_t *conf, int argc, const char **argv)
+int ipkg_cmd_exec(ipkg_cmd_t *cmd, ipkg_conf_t *conf, int argc, char **argv)
 {
      return (cmd->fun)(conf, argc, argv);
 }
Index: ipkg_cmd.h
===================================================================
RCS file: /cvs/familiar/dist/ipkg/C/ipkg_cmd.h,v
retrieving revision 1.12
diff -u -3 -p -u -r1.12 ipkg_cmd.h
--- ipkg_cmd.h	12 Jan 2004 16:07:36 -0000	1.12
+++ ipkg_cmd.h	2 Apr 2004 15:44:17 -0000
@@ -18,7 +18,7 @@
 #ifndef IPKG_CMD_H
 #define IPKG_CMD_H
 
-typedef int (*ipkg_cmd_fun_t)(ipkg_conf_t *conf, int argc, const char **argv);
+typedef int (*ipkg_cmd_fun_t)(ipkg_conf_t *conf, int argc, char **argv);
 
 struct ipkg_cmd
 {
@@ -31,7 +31,7 @@ typedef struct ipkg_cmd ipkg_cmd_t;
 ipkg_cmd_t *ipkg_cmd_find(const char *name);
 #ifdef IPKG_LIB
 int ipkg_cmd_exec(ipkg_cmd_t *cmd, ipkg_conf_t *conf, int argc, 
-                  const char **argv, void *userdata);
+                  char **argv, void *userdata);
 #else
 int ipkg_cmd_exec(ipkg_cmd_t *cmd, ipkg_conf_t *conf, int argc, const char **argv);
 #endif
Index: ipkg_conf.h
===================================================================
RCS file: /cvs/familiar/dist/ipkg/C/ipkg_conf.h,v
retrieving revision 1.32
diff -u -3 -p -u -r1.32 ipkg_conf.h
--- ipkg_conf.h	19 Jan 2004 23:12:12 -0000	1.32
+++ ipkg_conf.h	2 Apr 2004 15:44:17 -0000
@@ -101,5 +101,6 @@ int ipkg_conf_init(ipkg_conf_t *conf, co
 void ipkg_conf_deinit(ipkg_conf_t *conf);
 
 int ipkg_conf_write_status_files(ipkg_conf_t *conf);
+char * root_filename_alloc( ipkg_conf_t *conf, char *filename);
 
 #endif
Index: ipkg_install.c
===================================================================
RCS file: /cvs/familiar/dist/ipkg/C/ipkg_install.c,v
retrieving revision 1.82
diff -u -3 -p -u -r1.82 ipkg_install.c
--- ipkg_install.c	17 Mar 2004 21:17:37 -0000	1.82
+++ ipkg_install.c	2 Apr 2004 15:44:17 -0000
@@ -103,7 +103,7 @@ int ipkg_install_from_file(ipkg_conf_t *
 
      pkg->local_filename = strdup(filename);
 
-     if (old) {
+     if (old && old->state_status != SS_NOT_INSTALLED ) {
 	  old_version = pkg_version_str_alloc(old);
 	  new_version = pkg_version_str_alloc(pkg);
 
@@ -133,15 +133,16 @@ ipkg_error_t ipkg_install_by_name(ipkg_c
      char *old_version, *new_version;
 
      old = pkg_hash_fetch_installed_by_name(&conf->pkg_hash, pkg_name);
-    
+
      new = pkg_hash_fetch_best_installation_candidate_by_name(conf, pkg_name);
      if (new == NULL) {
 	  return IPKG_PKG_HAS_NO_CANDIDATE;
      }
 
      new->state_flag |= SF_USER;
-     if (old) {
-	  old_version = pkg_version_str_alloc(old);
+     if (old ) {
+       old_version = pkg_version_str_alloc(old);
+       if( old->state_status != SS_NOT_INSTALLED  ) {
 	  new_version = pkg_version_str_alloc(new);
 
 	  cmp = pkg_compare_versions(old, new);
@@ -169,8 +170,14 @@ ipkg_error_t ipkg_install_by_name(ipkg_c
 	       new->dest = old->dest;
 	       old->state_want = SW_DEINSTALL;
 	  }
+       } else {
+            ipkg_message(conf, IPKG_DEBUG, 
+		         "Package %s : "
+                         "\n\t%s is scheduled but not installed\n",
+                         pkg_name, old_version);
+	   free(old_version);
+       }
      }
-
      /* XXX: CLEANUP: The error code of ipkg_install_by_name is really
 	supposed to be an ipkg_error_t, but ipkg_install_pkg could
 	return any kind of integer, (might be errno from a syscall,
@@ -280,6 +287,8 @@ int name_mark_dependencies_for_installat
 	  return IPKG_PKG_HAS_NO_CANDIDATE;
      }
      if (old) {
+       old_version = pkg_version_str_alloc(old);
+       if( old->state_status != SS_NOT_INSTALLED  ) {
 	  old_version = pkg_version_str_alloc(old);
 	  new_version = pkg_version_str_alloc(new);
 
@@ -309,6 +318,14 @@ int name_mark_dependencies_for_installat
 	       old->state_want = SW_DEINSTALL;
 	       old->state_flag |= SF_OBSOLETE;
 	  }
+        } else {
+           /* in this case old == pkg */
+           ipkg_message(conf, IPKG_DEBUG, 
+		         "Package %s : "
+                         "\n\t%s is scheduled but not installed\n",
+                         pkg_name, old_version);
+	   free(old_version);
+        }
      }
      return pkg_mark_dependencies_for_installation(conf, new, pkgs_needed);
 }
@@ -438,8 +455,9 @@ static int update_file_ownership(ipkg_co
 	  pkg_t *owner = file_hash_get_file_owner(conf, new_file);
 	  if (!new_file)
 	       ipkg_message(conf, IPKG_ERROR, "Null new_file for new_pkg=%s\n", new_pkg->name);
-	  if (!owner || (owner == old_pkg))
+	  if (!owner || (owner == old_pkg)) {
 	       file_hash_set_file_owner(conf, new_file, new_pkg);
+	  }
      }
      if (old_pkg) {
 	  str_list_t *old_list = pkg_get_installed_files(old_pkg);
@@ -631,11 +649,14 @@ static void ipkg_install_pkg_sigint_hand
 /* compares versions of pkg and old_pkg, returns 0 if OK to proceed with installation of pkg, 1 otherwise */
 static int ipkg_install_check_downgrade(ipkg_conf_t *conf, pkg_t *pkg, pkg_t *old_pkg)
 {	  
-     if (old_pkg) {
+     int rc = 0; /* default -> allow install */
+
+     if (old_pkg ) {
+       /* make sure old package REALLY is installed */
+       if( old_pkg->state_status != SS_NOT_INSTALLED ) {
 	  char *old_version = pkg_version_str_alloc(old_pkg);
 	  char *new_version = pkg_version_str_alloc(pkg);
 	  int cmp = pkg_compare_versions(old_pkg, pkg);
-	  int rc = 0;
 
 	  if (cmp > 0) {
 	       ipkg_message(conf, IPKG_NOTICE,
@@ -647,14 +668,12 @@ static int ipkg_install_check_downgrade(
 			    "Upgrading %s on %s from %s to %s...\n",
 			    pkg->name, old_pkg->dest->name, old_version, new_version);
 	       pkg->dest = old_pkg->dest;
-	       rc = 0;
 	  } else /* cmp == 0 */ {
 	       if (conf->force_reinstall) {
 		    ipkg_message(conf, IPKG_NOTICE,
 				 "Reinstalling %s (%s) on %s...\n",
 				 pkg->name, new_version, old_pkg->dest->name);
 		    pkg->dest = old_pkg->dest;
-		    rc = 0;
 	       } else {
 		    ipkg_message(conf, IPKG_NOTICE,
 				 "Not installing %s (%s) on %s -- already installed.\n",
@@ -664,14 +683,16 @@ static int ipkg_install_check_downgrade(
 	  } 
 	  free(old_version);
 	  free(new_version);
-	  return rc;
+        } else {
+          pkg->dest = old_pkg->dest;
+        }
      } else {
 	  char *version = pkg_version_str_alloc(pkg);
 	  ipkg_message(conf, IPKG_NOTICE,
 		       "Installing %s (%s) to %s...\n",
 		       pkg->name, version, pkg->dest->name);
-	  return 0;
      }
+     return 0;
 }
 
 /* and now the meat... */
@@ -713,7 +734,15 @@ int ipkg_install_pkg(ipkg_conf_t *conf, 
      if (err) { return err; }
 
      pkg->state_want = SW_INSTALL;
-     if (old_pkg) old_pkg->state_want = SW_DEINSTALL; /* needed for check_data_file_clashes of dependences */
+
+     if (old_pkg && old_pkg->state_status != SS_NOT_INSTALLED ) {
+        /* needed for check_data_file_clashes of dependences 
+
+           but NOT if not-installed because then old_pkg == pkg (see
+           check_data_file_clashes
+        */
+        old_pkg->state_want = SW_DEINSTALL; 
+     }
 
      /* Abhaya: conflicts check */
      err = check_conflicts_for(conf, pkg);
@@ -798,7 +827,7 @@ int ipkg_install_pkg(ipkg_conf_t *conf, 
 	  if (conf->noaction) return 0;
 
 	  /* point of no return: no unwinding after this */
-	  if (old_pkg && !conf->force_reinstall) {
+	  if (old_pkg && old_pkg != pkg && !conf->force_reinstall) {
 	       old_pkg->state_want = SW_DEINSTALL;
 
 	       if (old_pkg->state_flag & SF_NOPRUNE) {
@@ -830,7 +859,7 @@ int ipkg_install_pkg(ipkg_conf_t *conf, 
 	  pkg->state_flag &= ~SF_PREFER;
 	  ipkg_message(conf, IPKG_DEBUG, "   pkg=%s old_state_flag=%x state_flag=%x\n", pkg->name, old_state_flag, pkg->state_flag);
 
-	  if (old_pkg && !conf->force_reinstall) {
+	  if (old_pkg && old_pkg != pkg && !conf->force_reinstall) {
 	       old_pkg->state_status = SS_NOT_INSTALLED;
 	  }
 
@@ -948,7 +977,7 @@ static int preinst_configure(ipkg_conf_t
      int err;
      char *preinst_args;
 
-     if (old_pkg) {
+     if (old_pkg && old_pkg != pkg ) {
 	  char *old_version = pkg_version_str_alloc(old_pkg);
 	  sprintf_alloc(&preinst_args, "upgrade %s", old_version);
 	  free(old_version);
@@ -992,7 +1021,7 @@ static int backup_modified_conffiles(ipk
      if (conf->noaction) return 0;
 
      /* Backup all modified conffiles */
-     if (old_pkg) {
+     if (old_pkg && old_pkg != pkg ) {
 	  for (iter = old_pkg->conffiles.head; iter; iter = iter->next) {
 	       char *cf_name;
 	       
@@ -1036,7 +1065,7 @@ static int backup_modified_conffiles_unw
 {
      conffile_list_elt_t *iter;
 
-     if (old_pkg) {
+     if (old_pkg && old_pkg != pkg ) {
 	  for (iter = old_pkg->conffiles.head; iter; iter = iter->next) {
 	       backup_remove(iter->data->name);
 	  }
@@ -1092,6 +1121,18 @@ static int check_data_file_clashes(ipkg_
 
 	       owner = file_hash_get_file_owner(conf, filename);
 
+	       /* in some situations, the WANT flag can be set to
+                  install but the STATUS flag is still not-installed
+
+                  then it CAN be that the owern of a file that
+                  is know by ipkg is the SAME as the package
+                  we are about to install
+               */
+
+               if( owner == pkg ) {
+                   continue;
+               }
+
 	       /* Pre-existing files are OK if owned by the pkg being upgraded. */
 	       if (owner && old_pkg) {
 		    if (strcmp(owner->name, old_pkg->name) == 0) {
@@ -1170,7 +1211,7 @@ static int remove_obsolesced_files(ipkg_
      str_list_t *new_files;
      str_list_elt_t *nf;
 
-     if (old_pkg == NULL) {
+     if (old_pkg == NULL || old_pkg == pkg ) {
 	  return 0;
      }
 
@@ -1251,7 +1292,7 @@ static int install_maintainer_scripts(ip
      int ret;
      char *prefix;
 
-     if (old_pkg)
+     if (old_pkg && old_pkg != pkg )
 	  remove_obsolete_maintainer_scripts(conf, pkg, old_pkg);
      sprintf_alloc(&prefix, "%s.", pkg->name);
      ret = pkg_extract_control_files_to_dir_with_prefix(pkg,
@@ -1632,7 +1673,7 @@ int ipkg_process_actions_install(ipkg_co
 	  pkg_t *pkg = pkgs_to_install->pkgs[i];
 	  pkg_t *old_pkg = pkg->old_pkg;
 
-	  if (old_pkg) {
+	  if (old_pkg && old_pkg != pkg ) {
 	       old_pkg->state_want = SW_DEINSTALL;
 
 	       if (old_pkg->state_flag & SF_NOPRUNE) {
@@ -1662,7 +1703,7 @@ int ipkg_process_actions_install(ipkg_co
 
 	  pkg->state_status = SS_UNPACKED;
 
-	  if (old_pkg) {
+	  if (old_pkg && old_pkg != pkg ) {
 	       old_pkg->state_status = SS_NOT_INSTALLED;
 	  }
 
@@ -1686,7 +1727,7 @@ int ipkg_process_actions_unwind_prerm(ip
 	  pkg_t *pkg = pkgs_to_install->pkgs[i];
 	  pkg_t *old_pkg = pkg->old_pkg;
 
-	  if (old_pkg) {
+	  if (old_pkg && old_pkg != pkg ) {
 	       if (old_pkg->state_flags & SF_POSTRM_UPGRADE)
 		    postrm_upgrade_old_pkg_unwind(conf, pkg, old_pkg);
 	       if (old_pkg->state_flags & SF_CHECK_DATA_FILE_CLASHES)
Index: ipkg_message.c
===================================================================
RCS file: /cvs/familiar/dist/ipkg/C/ipkg_message.c,v
retrieving revision 1.4
diff -u -3 -p -u -r1.4 ipkg_message.c
--- ipkg_message.c	6 Nov 2003 15:37:50 -0000	1.4
+++ ipkg_message.c	2 Apr 2004 15:44:17 -0000
@@ -43,19 +43,30 @@ ipkg_message (ipkg_conf_t * conf, messag
 #include "libipkg.h"
 
 //#define ipkg_message(conf, level, fmt, arg...) ipkg_cb_message(conf, level, fmt, ## arg)
+static char * Fmt_Buffer = 0;
+static long Fmt_BufLen = 0;
 
 void
 ipkg_message (ipkg_conf_t * conf, message_level_t level, char *fmt, ...)
 {
 	va_list ap;
-	char ts[128];
+	long cl;
 
 	if (ipkg_cb_message)
 	{
-		va_start (ap, fmt);
-		vsnprintf (ts,128,fmt, ap);
-		va_end (ap);
-		ipkg_cb_message(conf,level,ts);
+		do { 
+                  va_start (ap, fmt);
+                  cl = vsnprintf (Fmt_Buffer,Fmt_BufLen,fmt, ap);
+                  va_end (ap);
+                  if( cl < Fmt_BufLen ) {
+                    // we had space enough
+                    break;
+                  }
+                  // buffer too small
+                  Fmt_BufLen += 128;
+                  Fmt_Buffer = realloc( Fmt_Buffer, sizeof( char ) * Fmt_BufLen );
+		} while( 1 );
+		ipkg_cb_message(conf,level,Fmt_Buffer);
 	}
 }
 #endif
Index: ipkg_remove.c
===================================================================
RCS file: /cvs/familiar/dist/ipkg/C/ipkg_remove.c,v
retrieving revision 1.39
diff -u -3 -p -u -r1.39 ipkg_remove.c
--- ipkg_remove.c	10 Mar 2004 21:27:35 -0000	1.39
+++ ipkg_remove.c	2 Apr 2004 15:44:18 -0000
@@ -185,6 +185,20 @@ int ipkg_remove_pkg(ipkg_conf_t *conf, p
      if ((parent_pkg = pkg->parent) == NULL)
 	  return 0;
 
+     if( pkg->state_status == SS_NOT_INSTALLED ) {
+       // pending to be installed -> revert
+       pkg->state_want = SW_UNKNOWN;
+       ipkg_state_changed++;
+
+       printf("Reverting install request for package %s to %s...\n", 
+              pkg->name, pkg->dest->name);
+       fflush(stdout);
+       pkg->state_status = SS_NOT_INSTALLED;
+       if (parent_pkg) 
+           parent_pkg->state_status = SS_NOT_INSTALLED;
+        return 0;
+     }
+
      /* only attempt to remove dependent installed packages if
       * force_depends is not specified or the package is being
       * replaced.
Index: libipkg.c
===================================================================
RCS file: /cvs/familiar/dist/ipkg/C/libipkg.c,v
retrieving revision 1.9
diff -u -3 -p -u -r1.9 libipkg.c
--- libipkg.c	8 Mar 2004 23:48:38 -0000	1.9
+++ libipkg.c	2 Apr 2004 15:44:18 -0000
@@ -62,7 +62,7 @@ ipkg_deinit (args_t * args)
 
 int
 ipkg_packages_list(args_t *args, 
-                   const char *packages, 
+                   char *packages, 
                    ipkg_list_callback cblist,
                    void *userdata)
 {
@@ -92,7 +92,7 @@ ipkg_packages_list(args_t *args, 
 
 int
 ipkg_packages_status(args_t *args,
-                     const char *packages,
+                     char *packages,
                      ipkg_status_callback cbstatus,
                      void *userdata)
 {
@@ -124,7 +124,7 @@ ipkg_packages_status(args_t *args,
 
 int
 ipkg_packages_info(args_t *args,
-                   const char *packages,
+                   char *packages,
                    ipkg_status_callback cbstatus,
                    void *userdata)
 {
@@ -155,7 +155,7 @@ ipkg_packages_info(args_t *args,
 
 
 int
-ipkg_packages_install (args_t * args, const char *name)
+ipkg_packages_install (args_t * args, char *name)
 {
 	ipkg_cmd_t *cmd;
 	ipkg_conf_t ipkg_conf;
@@ -182,7 +182,7 @@ ipkg_packages_install (args_t * args, co
 
 
 int
-ipkg_packages_remove(args_t *args, const char *name, int purge)
+ipkg_packages_remove(args_t *args, char *name, int purge)
 {
 	ipkg_cmd_t *cmd;
 	ipkg_conf_t ipkg_conf;
@@ -261,7 +261,7 @@ ipkg_packages_upgrade(args_t *args)
 
 
 int
-ipkg_packages_download (args_t * args, const char *name)
+ipkg_packages_download (args_t * args, char *name)
 {
 	ipkg_cmd_t *cmd;
 	ipkg_conf_t ipkg_conf;
@@ -289,7 +289,7 @@ ipkg_packages_download (args_t * args, c
 
 int
 ipkg_package_files(args_t *args, 
-                   const char *name, 
+                   char *name, 
                    ipkg_list_callback cblist,
                    void *userdata)
 {
@@ -323,7 +323,7 @@ ipkg_package_files(args_t *args, 
 
 int 
 ipkg_file_search(args_t *args, 
-                const char *file,
+                char *file,
 				ipkg_list_callback cblist,
                 void *userdata)
 {
@@ -355,7 +355,7 @@ ipkg_file_search(args_t *args, 
 
 
 int 
-ipkg_file_what(args_t *args, const char *file, const char* command)
+ipkg_file_what(args_t *args, char *file, const char* command)
 {
 	ipkg_cmd_t *cmd;
 	ipkg_conf_t ipkg_conf;
@@ -495,7 +495,7 @@ ipkg_op (int argc, char *argv[])
 		args_usage (NULL);
 	}
 
-	err = ipkg_cmd_exec (cmd, &ipkg_conf, argc - optind, (const char **) (argv + optind), NULL);
+	err = ipkg_cmd_exec (cmd, &ipkg_conf, argc - optind, (char **) (argv + optind), NULL);
 
 	ipkg_conf_deinit (&ipkg_conf);
 
Index: libipkg.h
===================================================================
RCS file: /cvs/familiar/dist/ipkg/C/libipkg.h,v
retrieving revision 1.4
diff -u -3 -p -u -r1.4 libipkg.h
--- libipkg.h	5 Feb 2004 16:26:00 -0000	1.4
+++ libipkg.h	2 Apr 2004 15:44:18 -0000
@@ -43,30 +43,30 @@ extern int ipkg_init (ipkg_message_callb
 
 extern int ipkg_deinit (args_t *args);
 extern int ipkg_packages_list(args_t *args, 
-                              const char *packages, 
+                              char *packages, 
                               ipkg_list_callback cblist,
                               void *userdata);
 extern int ipkg_packages_status(args_t *args, 
-                                const char *packages, 
+                                char *packages, 
                                 ipkg_status_callback cbstatus,
-								void *userdata);
+                                void *userdata);
 extern int ipkg_packages_info(args_t *args,
-                              const char *packages,
+                              char *packages,
                               ipkg_status_callback cbstatus,
                               void *userdata);
-extern int ipkg_packages_install(args_t *args, const char *name);
-extern int ipkg_packages_remove(args_t *args, const char *name, int purge);
+extern int ipkg_packages_install(args_t *args, char *name);
+extern int ipkg_packages_remove(args_t *args, char *name, int purge);
 extern int ipkg_lists_update(args_t *args);
 extern int ipkg_packages_upgrade(args_t *args);
-extern int ipkg_packages_download(args_t *args, const char *name);
+extern int ipkg_packages_download(args_t *args, char *name);
 extern int ipkg_package_files(args_t *args,
-                              const char *name,
-							  ipkg_list_callback cblist,
-							  void *userdata);
+                              char *name,
+                              ipkg_list_callback cblist,
+                              void *userdata);
 extern int ipkg_file_search(args_t *args,
-                            const char *file,
-							ipkg_list_callback cblist,
-							void *userdata);
+                            char *file,
+                            ipkg_list_callback cblist,
+                            void *userdata);
 extern int ipkg_package_whatdepends(args_t *args, const char *file);
 extern int ipkg_package_whatrecommends(args_t *args, const char *file);
 extern int ipkg_package_whatprovides(args_t *args, const char *file);
Index: pkg.c
===================================================================
RCS file: /cvs/familiar/dist/ipkg/C/pkg.c,v
retrieving revision 1.85
diff -u -3 -p -u -r1.85 pkg.c
--- pkg.c	17 Mar 2004 21:17:37 -0000	1.85
+++ pkg.c	2 Apr 2004 15:44:18 -0000
@@ -702,7 +702,7 @@ char * pkg_formatted_field(pkg_t *pkg, c
 	          return NULL;
                }
                temp[0]='\0';
-               snprintf(temp, 29, "Installed-Time: %ul\n", pkg->installed_time);
+               snprintf(temp, 29, "Installed-Time: %ul\n", (unsigned int)pkg->installed_time);
 	  }
      }
 	  break;
@@ -1140,7 +1140,7 @@ int pkg_name_version_and_architecture_co
      if (vercmp)
 	  return vercmp;
      if (!a->arch_priority || !b->arch_priority) {
-       fprintf(stderr, "pkg_name_version_and_architecture_compare: a=%p a->arch_priority=%p b=%p b->arch_priority=%p\n",
+       fprintf(stderr, "pkg_name_version_and_architecture_compare: a=%p a->arch_priority=%d b=%p b->arch_priority=%d\n",
 	       a, a->arch_priority, b, b->arch_priority);
        return 0;
      }
@@ -1510,7 +1510,7 @@ char *pkg_state_flag_to_str(pkg_state_fl
      }
 }
 
-pkg_state_flag_t pkg_state_flag_from_str(char *str)
+pkg_state_flag_t pkg_state_flag_from_str(const char *str)
 {
      int i;
      int sf = SF_OK;
@@ -1550,7 +1550,7 @@ char *pkg_state_status_to_str(pkg_state_
      return "<STATE_STATUS_UNKNOWN>";
 }
 
-pkg_state_status_t pkg_state_status_from_str(char *str)
+pkg_state_status_t pkg_state_status_from_str(const char *str)
 {
      int i;
 
Index: pkg.h
===================================================================
RCS file: /cvs/familiar/dist/ipkg/C/pkg.h,v
retrieving revision 1.45
diff -u -3 -p -u -r1.45 pkg.h
--- pkg.h	17 Mar 2004 21:17:37 -0000	1.45
+++ pkg.h	2 Apr 2004 15:44:18 -0000
@@ -214,9 +214,9 @@ int pkg_run_script(struct ipkg_conf *con
 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);
+pkg_state_flag_t pkg_state_flag_from_str( const char *str);
 char *pkg_state_status_to_str(pkg_state_status_t ss);
-pkg_state_status_t pkg_state_status_from_str(char *str);
+pkg_state_status_t pkg_state_status_from_str(const char *str);
 
 int pkg_version_satisfied(pkg_t *it, pkg_t *ref, const char *op);
 
Index: pkg_extract.c
===================================================================
RCS file: /cvs/familiar/dist/ipkg/C/pkg_extract.c,v
retrieving revision 1.8
diff -u -3 -p -u -r1.8 pkg_extract.c
--- pkg_extract.c	22 Aug 2003 20:41:55 -0000	1.8
+++ pkg_extract.c	2 Apr 2004 15:44:18 -0000
@@ -87,7 +87,7 @@ int pkg_extract_data_files_to_dir(pkg_t 
 
 int pkg_extract_data_file_names_to_file(pkg_t *pkg, const char *file_name)
 {
-     int err;
+     int err = 0;
      char *line, *data_file;
      FILE *file;
      FILE *tmp;
Index: pkg_hash.c
===================================================================
RCS file: /cvs/familiar/dist/ipkg/C/pkg_hash.c,v
retrieving revision 1.65
diff -u -3 -p -u -r1.65 pkg_hash.c
--- pkg_hash.c	17 Mar 2004 21:17:37 -0000	1.65
+++ pkg_hash.c	2 Apr 2004 15:44:18 -0000
@@ -324,26 +324,14 @@ pkg_t *pkg_hash_fetch_installed_by_name_
     if(!(vec = pkg_vec_fetch_by_name(hash, pkg_name)))
 	return NULL;
     
-    for(i = 0; i < vec->len; i++)
-	if((vec->pkgs[i]->state_status == SS_INSTALLED || vec->pkgs[i]->state_status == SS_UNPACKED)
-	   && vec->pkgs[i]->dest == dest)
-	    return vec->pkgs[i];
-    
-    return NULL;
-}
-
-pkg_t *pkg_hash_fetch_installed_by_name(hash_table_t *hash,
-					const char *pkg_name)
-{
-    pkg_vec_t * vec;
-    register int i;
-
-    if(!(vec = pkg_vec_fetch_by_name(hash, pkg_name)))
-	return NULL;
-    
-    for(i = 0; i < vec->len; i++)
-	if (vec->pkgs[i]->state_status == SS_INSTALLED || vec->pkgs[i]->state_status == SS_UNPACKED)
+    for(i = 0; i < vec->len; i++) {
+	if(( vec->pkgs[i]->state_want == SW_INSTALL ||
+	     vec->pkgs[i]->state_status == SS_INSTALLED || 
+	     vec->pkgs[i]->state_status == SS_UNPACKED)
+	   && (dest==0 || vec->pkgs[i]->dest == dest) ) {
 	    return vec->pkgs[i];
+	}
+    }
     
     return NULL;
 }
Index: pkg_hash.h
===================================================================
RCS file: /cvs/familiar/dist/ipkg/C/pkg_hash.h,v
retrieving revision 1.19
diff -u -3 -p -u -r1.19 pkg_hash.h
--- pkg_hash.h	10 Apr 2003 21:43:51 -0000	1.19
+++ pkg_hash.h	2 Apr 2004 15:44:18 -0000
@@ -45,11 +45,12 @@ abstract_pkg_vec_t *pkg_hash_fetch_all_i
 pkg_t *pkg_hash_fetch_best_installation_candidate(ipkg_conf_t *conf, abstract_pkg_t *apkg, 
 						  int (*constraint_fcn)(pkg_t *pkg, void *data), void *cdata);
 pkg_t *pkg_hash_fetch_best_installation_candidate_by_name(ipkg_conf_t *conf, const char *name);
-pkg_t *pkg_hash_fetch_installed_by_name(hash_table_t *hash,
-					const char *pkg_name);
 pkg_t *pkg_hash_fetch_installed_by_name_dest(hash_table_t *hash,
 					     const char *pkg_name,
 					     pkg_dest_t *dest);
+#define pkg_hash_fetch_installed_by_name(hash,pkg_name) \
+      pkg_hash_fetch_installed_by_name_dest(hash,pkg_name,0)
+
 
 pkg_t *file_hash_get_file_owner(ipkg_conf_t *conf, const char *file_name);
 int file_hash_set_file_owner(ipkg_conf_t *conf, const char *file_name, pkg_t *pkg);
Index: libbb/unarchive.c
===================================================================
RCS file: /cvs/familiar/dist/ipkg/C/libbb/unarchive.c,v
retrieving revision 1.3
diff -u -3 -p -u -r1.3 unarchive.c
--- libbb/unarchive.c	20 Feb 2004 22:28:06 -0000	1.3
+++ libbb/unarchive.c	2 Apr 2004 15:44:18 -0000
@@ -753,7 +753,7 @@ char *deb_extract(const char *package_fi
                 /*fprintf(stderr, __FUNCTION__ ":%d: done\n", __LINE__);*/
 		return output_buffer; 
 	} else {
-		error_msg_and_die("invalid magic");
+		error_msg_and_die("invalid x xxmagic");
 	}
 
 }

