r3879 - in trunk/src/target/ipkg: . familiar intercept libbb

thomas at sita.openmoko.org thomas at sita.openmoko.org
Fri Jan 18 12:29:14 CET 2008


Author: thomas
Date: 2008-01-18 12:28:48 +0100 (Fri, 18 Jan 2008)
New Revision: 3879

Added:
   trunk/src/target/ipkg/familiar/libopkg-control.in
   trunk/src/target/ipkg/familiar/libopkg-dev-control.in
   trunk/src/target/ipkg/libopkg.c
   trunk/src/target/ipkg/libopkg.h
   trunk/src/target/ipkg/libopkg.pc.in
   trunk/src/target/ipkg/opkg-frontend.c
   trunk/src/target/ipkg/opkg.c
   trunk/src/target/ipkg/opkg.h
   trunk/src/target/ipkg/opkg.h.in
   trunk/src/target/ipkg/opkg_cmd.c
   trunk/src/target/ipkg/opkg_cmd.h
   trunk/src/target/ipkg/opkg_conf.c
   trunk/src/target/ipkg/opkg_conf.h
   trunk/src/target/ipkg/opkg_configure.c
   trunk/src/target/ipkg/opkg_configure.h
   trunk/src/target/ipkg/opkg_download.c
   trunk/src/target/ipkg/opkg_download.h
   trunk/src/target/ipkg/opkg_extract_test.c
   trunk/src/target/ipkg/opkg_hash_test.c
   trunk/src/target/ipkg/opkg_install.c
   trunk/src/target/ipkg/opkg_install.h
   trunk/src/target/ipkg/opkg_message.c
   trunk/src/target/ipkg/opkg_message.h
   trunk/src/target/ipkg/opkg_remove.c
   trunk/src/target/ipkg/opkg_remove.h
   trunk/src/target/ipkg/opkg_upgrade.c
   trunk/src/target/ipkg/opkg_upgrade.h
   trunk/src/target/ipkg/opkg_utils.c
   trunk/src/target/ipkg/opkg_utils.h
Removed:
   trunk/src/target/ipkg/familiar/libipkg-control.in
   trunk/src/target/ipkg/familiar/libipkg-dev-control.in
   trunk/src/target/ipkg/ipkg-frontend.c
   trunk/src/target/ipkg/ipkg.c
   trunk/src/target/ipkg/ipkg.h
   trunk/src/target/ipkg/ipkg.h.in
   trunk/src/target/ipkg/ipkg_cmd.c
   trunk/src/target/ipkg/ipkg_cmd.h
   trunk/src/target/ipkg/ipkg_conf.c
   trunk/src/target/ipkg/ipkg_conf.h
   trunk/src/target/ipkg/ipkg_configure.c
   trunk/src/target/ipkg/ipkg_configure.h
   trunk/src/target/ipkg/ipkg_download.c
   trunk/src/target/ipkg/ipkg_download.h
   trunk/src/target/ipkg/ipkg_extract_test.c
   trunk/src/target/ipkg/ipkg_hash_test.c
   trunk/src/target/ipkg/ipkg_install.c
   trunk/src/target/ipkg/ipkg_install.h
   trunk/src/target/ipkg/ipkg_message.c
   trunk/src/target/ipkg/ipkg_message.h
   trunk/src/target/ipkg/ipkg_remove.c
   trunk/src/target/ipkg/ipkg_remove.h
   trunk/src/target/ipkg/ipkg_upgrade.c
   trunk/src/target/ipkg/ipkg_upgrade.h
   trunk/src/target/ipkg/ipkg_utils.c
   trunk/src/target/ipkg/ipkg_utils.h
   trunk/src/target/ipkg/libipkg.c
   trunk/src/target/ipkg/libipkg.h
   trunk/src/target/ipkg/libipkg.pc.in
Modified:
   trunk/src/target/ipkg/AUTHORS
   trunk/src/target/ipkg/ChangeLog
   trunk/src/target/ipkg/INSTALL
   trunk/src/target/ipkg/Makefile.am
   trunk/src/target/ipkg/README
   trunk/src/target/ipkg/TODO
   trunk/src/target/ipkg/args.c
   trunk/src/target/ipkg/args.h
   trunk/src/target/ipkg/conffile.c
   trunk/src/target/ipkg/conffile.h
   trunk/src/target/ipkg/conffile_list.c
   trunk/src/target/ipkg/configure.ac
   trunk/src/target/ipkg/familiar/control-unstripped.in
   trunk/src/target/ipkg/familiar/control.in
   trunk/src/target/ipkg/file_util.c
   trunk/src/target/ipkg/hash_table.c
   trunk/src/target/ipkg/hash_table.h
   trunk/src/target/ipkg/intercept/depmod
   trunk/src/target/ipkg/intercept/ldconfig
   trunk/src/target/ipkg/intercept/update-modules
   trunk/src/target/ipkg/libbb/libbb.h
   trunk/src/target/ipkg/libbb/unarchive.c
   trunk/src/target/ipkg/md5.c
   trunk/src/target/ipkg/nv_pair.c
   trunk/src/target/ipkg/nv_pair_list.c
   trunk/src/target/ipkg/pkg.c
   trunk/src/target/ipkg/pkg.h
   trunk/src/target/ipkg/pkg_depends.c
   trunk/src/target/ipkg/pkg_depends.h
   trunk/src/target/ipkg/pkg_dest.c
   trunk/src/target/ipkg/pkg_dest.h
   trunk/src/target/ipkg/pkg_dest_list.c
   trunk/src/target/ipkg/pkg_extract.c
   trunk/src/target/ipkg/pkg_hash.c
   trunk/src/target/ipkg/pkg_hash.h
   trunk/src/target/ipkg/pkg_parse.c
   trunk/src/target/ipkg/pkg_src.c
   trunk/src/target/ipkg/pkg_src_list.c
   trunk/src/target/ipkg/pkg_vec.c
   trunk/src/target/ipkg/pkg_vec.h
   trunk/src/target/ipkg/sprintf_alloc.c
   trunk/src/target/ipkg/str_list.c
   trunk/src/target/ipkg/str_util.c
   trunk/src/target/ipkg/update-alternatives
   trunk/src/target/ipkg/user.c
   trunk/src/target/ipkg/void_list.c
   trunk/src/target/ipkg/xregex.c
   trunk/src/target/ipkg/xsystem.c
Log:
* Rename ipkg to opkg


Modified: trunk/src/target/ipkg/AUTHORS
===================================================================
--- trunk/src/target/ipkg/AUTHORS	2008-01-18 11:05:46 UTC (rev 3878)
+++ trunk/src/target/ipkg/AUTHORS	2008-01-18 11:28:48 UTC (rev 3879)
@@ -1,5 +1,5 @@
-ipkg actually is maintained by Pierluigi Frullani <pigi at frumar.it>
+opkg actually is maintained by Pierluigi Frullani <pigi at frumar.it>
 
-ipkg is being written by Carl Worth <cworth at handhelds.org> and Steve
+opkg is being written by Carl Worth <cworth at handhelds.org> and Steve
 Ayer <steven.ayer at compaq.com>
 

Modified: trunk/src/target/ipkg/ChangeLog
===================================================================
--- trunk/src/target/ipkg/ChangeLog	2008-01-18 11:05:46 UTC (rev 3878)
+++ trunk/src/target/ipkg/ChangeLog	2008-01-18 11:28:48 UTC (rev 3879)
@@ -34,7 +34,7 @@
 
 2006-02-02 pigi ( pigi at frumar.it)
         * Version update to 0.99.158
-        * Modified the way upgrade handle the removing of a package, to be sure that ipkg doesn't break busybox upgrade
+        * Modified the way upgrade handle the removing of a package, to be sure that opkg doesn't break busybox upgrade
         *          this should fix #1503
         
 2006-01-30 pigi ( pigi at frumar.it)
@@ -55,10 +55,10 @@
 2005-12-15 pigi ( pigi at frumar.it)
         * Version update to 0.99.155
         * Added a function to remove the package that is being upgraded.
-        * Fixed a problem when installing by hand. Now ipkg knows that a package has been selected by hand, 
+        * Fixed a problem when installing by hand. Now opkg knows that a package has been selected by hand, 
         *       and, if every check returns ok, it install the wanted package, instead of selecting one from feed.
         *       Moreover, now downgrade should works again.
-        * Fixed the "Replaces" bug. Now ipkg is able to replace a package also if it doesn't conflict.
+        * Fixed the "Replaces" bug. Now opkg is able to replace a package also if it doesn't conflict.
         * Other minor changes in debug options
 
 2005-09-15 pigi ( pigi at frumar.it)
@@ -68,11 +68,11 @@
         * Added a little fix for an off-by-one error in checking for depends.
 
 2005-07-29 pigi ( pigi at frumar.it)
-        * Applied a patch for the GNU tar compatibility . Now ipkg can handle filenames > 100 char.
+        * Applied a patch for the GNU tar compatibility . Now opkg can handle filenames > 100 char.
 
 2005-07-29 pigi ( pigi at frumar.it)
 	* Version update to 0.99.153
-        * Fixed a problem with Provides:. Now ipkg is able to install foo when foo is provided by bar, and is able to determine the best candidate based on 
+        * Fixed a problem with Provides:. Now opkg is able to install foo when foo is provided by bar, and is able to determine the best candidate based on 
         * package name. This also fix #1328
 
 2005-07-06 pigi ( pigi at frumar.it)
@@ -89,7 +89,7 @@
 
 2005-05-11 pigi ( pigi at frumar.it)
 	* Version update to 0.99.149
-        * Added the possibility to choice the ipkglibdir from configure ( --with-libipkgdir )
+        * Added the possibility to choice the opkglibdir from configure ( --with-libopkgdir )
 
 2005-04-10 pigi ( pigi at frumar.it)
 	* Version update to 0.99.148
@@ -100,38 +100,38 @@
 
 2005-03-30 pigi ( pigi at frumar.it)
 	* Version update to 0.99.147
-        * Found a bug in ipkg_install when freeing a cursor 
+        * Found a bug in opkg_install when freeing a cursor 
 
 2005-03-28 pigi ( pigi at frumar.it)
 	* Version update to 0.99.146
-        * Modified the ipkg_error messaging to collect all the messages at the end of the program
+        * Modified the opkg_error messaging to collect all the messages at the end of the program
 
 2005-03-26 pigi ( pigi at frumar.it)
         * Little bug in message when "depends broken" 
 
 2005-03-14 pigi ( pigi at frumar.it)
 	* Version update to 0.99.145
-	* Found a bug in ipkg remove when a package was depending in itself and ipkg where asked to "-recursive"
+	* Found a bug in opkg remove when a package was depending in itself and opkg where asked to "-recursive"
           This fix bug # 1301
         * A very little beautify in args.c
 
 2005-03-07 pigi ( pigi at frumar.it)
-	* Added the check for md5 in resolv_conf_file. Now ipkg ask for confirmation only it the files differ
+	* Added the check for md5 in resolv_conf_file. Now opkg ask for confirmation only it the files differ
 
 2005-02-22 pigi ( pigi at frumar.it)
 	* Version update to 0.99.144
-	* A little fix suggested by drw in ipkg_conf.c
-	* Changed the ipkg.h to be build in automake for oe mechanism . This will enhance the building phase 
+	* A little fix suggested by drw in opkg_conf.c
+	* Changed the opkg.h to be build in automake for oe mechanism . This will enhance the building phase 
           by honouring the lib hierarchy choose by users
         * Changes in automake to honour the new building mechanism
 
 2005-02-20 pigi ( pigi at frumar.it)
 	* Version update to 0.99.143
-	* libipkg.h: reverting the previous modify
-        * ipkg_conf.c: fixing a probable bug in list_dir that fix problems with opie-packagemanager ( tanks to drw for signaling)
+	* libopkg.h: reverting the previous modify
+        * opkg_conf.c: fixing a probable bug in list_dir that fix problems with opie-packagemanager ( tanks to drw for signaling)
 
 2005-02-20 pigi ( pigi at frumar.it)
-	* libipkg.h: added some define to fix the broken external interface after 0.99.139 and lists_dir
+	* libopkg.h: added some define to fix the broken external interface after 0.99.139 and lists_dir
 
 2005-02-17 pigi ( pigi at frumar.it)
 	* pkg_depends.c: applied patch from rjt at cambridgebroadband.com to remove some c99ism 
@@ -142,16 +142,16 @@
 
 2005-02-06 pigi ( pigi at frumar.it)
 	* Version update to 0.99.141
-        * Added space in ipkg_message to give more readible messages
+        * Added space in opkg_message to give more readible messages
         * Corrected a problem when creating the directories in pkg_dest_init
 
 2005-02-05 pigi ( pigi at frumar.it)
 	* Version update to 0.99.140
-        * Fixed the bug in ipkg_conf for a wrong pointer.
+        * Fixed the bug in opkg_conf for a wrong pointer.
 
 2005-02-05 pigi ( pigi at frumar.it)
 	* Version update to 0.99.139
-        * Fixed the "replaces" problem  reported by pb_. Now ipkg is able to resolve a "replace/conflict" reference
+        * Fixed the "replaces" problem  reported by pb_. Now opkg is able to resolve a "replace/conflict" reference
         * Added the possibility to keep the lists file in a different location. Fullfill enh #1276
 
 2005-02-02 pigi ( pigi at frumar.it)
@@ -163,7 +163,7 @@
 	* libbb.h: patch for the uclib 
 
 2005-01-14 pigi ( pigi at frumar.it)
-	* ipkg_install.c: applied patch from rjt at cambridgebroadband.com to remove some c99ism 
+	* opkg_install.c: applied patch from rjt at cambridgebroadband.com to remove some c99ism 
 
 2005-01-14 jamey ( jamey at handhelds.org )
 	* pkg_hash.c: applied patch from Jean Tourrilhes to allow default
@@ -191,7 +191,7 @@
 	* Version update to 0.99.134
         * Added a new option for listing only the installed packages. Asked by pb_ but really important
 	* Little modification to autoconfigure.sh 
- 	* removed fileutils dependencies that has disappeared from 0.8 in control-cl.in  control-unstripped.in libipkg-control.in  
+ 	* removed fileutils dependencies that has disappeared from 0.8 in control-cl.in  control-unstripped.in libopkg-control.in  
 
 2004-11-18 pigi ( pigi at frumar.it)
 	* Version update to 0.99.133
@@ -205,8 +205,8 @@
 2004-09-20 pigi ( pigi at frumar.it)
 	* Version update to 0.99.131
         * Added a lot of debug info in DEBUG2
-        * Added a check in ipkg_install.c to permit replacing of existing file when installing a package
-        * from a file ( not an upgrade ) when ipkg find a file clash but the owner of the package is the 
+        * Added a check in opkg_install.c to permit replacing of existing file when installing a package
+        * from a file ( not an upgrade ) when opkg find a file clash but the owner of the package is the 
         * same. That should fix the #1246
 
 2004-09-02 pigi ( pigi at frumar.it)
@@ -218,13 +218,13 @@
 
 2004-09-01 pigi ( pigi at frumar.it)
         * Applied patches from pb_ (bug #1244)
-        * Added EXTRADIST = ipkg.c and others in Makefile.am as in ipkg.0.99.xxx.tar.gz the ipkg.c was missing. ( 
+        * Added EXTRADIST = opkg.c and others in Makefile.am as in opkg.0.99.xxx.tar.gz the opkg.c was missing. ( 
           reported by odvard12 at yahoo.com )
 	* Version update to 0.99.129
 
 2004-08-19 Florian <florian.boor at kernelconcepts.de>
 	* Version update to 0.99.128
-	* libipkg.c, ipkg_cmd.c: Fixed return value zero if installation
+	* libopkg.c, opkg_cmd.c: Fixed return value zero if installation
 	  failed. Changed text because failing to install a package
           is not necessarily a bug :-)
 	* Makefile.in, libbb/Makefile.in: Removed autogenerated files.
@@ -244,7 +244,7 @@
 	* configure.ac: updated to 0.99.126
 2004-06-12 florian <florian.boor at kernelconcepts.de>
 	* Makefile.am: Added some missing headers to the list.
-	* libipkg.pc.in: Fixed hardcoded prefix... tsts
+	* libopkg.pc.in: Fixed hardcoded prefix... tsts
 2004-06-12 pigi ( pigi at frumar.it)
         * pb_ patch for setuid bit in unarchive
 2004-06-05 pigi ( pigi at frumar.it)
@@ -255,8 +255,8 @@
 2004-05-21 pigi ( pigi at frumar.it)
 	* configure.ac: updated to 0.99.124
         * import the kergoth patch for Makefile.am to fix the linking problems on arch <> arm
-        * added the ipkg remove <regexp> feature.
-        * fixed the ipkg usage message, 'cause in "ifdef LIBIPKG" we don't have the ipkg info field version.
+        * added the opkg remove <regexp> feature.
+        * fixed the opkg usage message, 'cause in "ifdef LIBOPKG" we don't have the opkg info field version.
         * added the message "No package removed" if no package has been removed. This to avoid misunderstanding
           with the successfully done message at the exit of execution.
 2004-05-16 pigi ( pigi at frumar.it)
@@ -264,16 +264,16 @@
         * Anothere little fix. Added the version number in control.in. This should fix definitelly the problem with dependencies
 2004-05-16 pigi ( pigi at frumar.it)
 	* configure.ac: updated to 0.99.122-2
-        * New subrelease released to correct the problem for dependencies (libipkg >= 0.99.122-1) in ipkg control file
+        * New subrelease released to correct the problem for dependencies (libopkg >= 0.99.122-1) in opkg control file
 2004-05-14 pigi ( pigi at frumar.it)
 	* configure.ac: updated to 0.99.122-1
         * needed for a recompilation with the libtool updated. This could fix the #1209 created by my old libtool version
         * cleaned the cvs dir by removing the really unneeded busybox directory
 2004-05-10 pigi ( pigi at frumar.it)
 	* configure.ac: updated to 0.99.122
-        * pb_, cworth and I discussed a bit on ipkg output to users. We agreed on removing some confusing
+        * pb_, cworth and I discussed a bit on opkg output to users. We agreed on removing some confusing
         * messages, moving them to a debug level of verbosity.
-        * I do added also some message to user indicating the phase ipkg is in, and a global ending message
+        * I do added also some message to user indicating the phase opkg is in, and a global ending message
         * informing the user for the status of operation.
         * This fixes the #1206, and hopefully does not introduce others ;-) 
 2004-05-03 pigi ( pigi at frumar.it)
@@ -295,7 +295,7 @@
         * I' ve also included the fix for the empty lists as for bug # 1136 reported and suggested by k.vangelder at chello.nl 
 2004-03-17 pigi ( pigi at frumar.it)
         *  Added the implement for Essential in status file. This is needed to avoid the unintentional remove
-           of essential packages. In effect the command "ipkg remove ipkg" worked without problems, but then
+           of essential packages. In effect the command "opkg remove opkg" worked without problems, but then
            it was difficult to reinstall. This fix the bug # 867
 2004-03-15 jamey <jamey at handhelds.org>
 	* configure.ac: updated to 0.99.117
@@ -312,18 +312,18 @@
            the default.
            This fixes the bug #1099
 2004-03-07 pigi ( pigi at frumar.it)
-        *  Minimal changes for a clean compile in libipkg.c ( so we can close the bug# 1119 )
+        *  Minimal changes for a clean compile in libopkg.c ( so we can close the bug# 1119 )
 2004-03-03 pigi ( pigi at frumar.it)
         * Missing \n in Size and Source Fields.
 2004-03-03 pigi ( pigi at frumar.it)
-        * Florian noticed a free missiing in ipkg_cmd.c ( should sleep more at night ) 
+        * Florian noticed a free missiing in opkg_cmd.c ( should sleep more at night ) 
           it was in an (almost) unsed part of the code ( old code ) but, just in case...
         * Changed a comment in pkg.c ( it was in italian ) and added a bit of explain in 
           pkg_formatted_field
 2004-03-02 jamey <jamey at handhelds.org>
 	* configure.ac: updated to 0.99.116
 	* pkg.h: from Pigi: pkg_formatted_info and pkg_formatted_field now allocate the strings they fill in
-	* pkg.c, ipkg_cmd.c: from Pigi: updated to the new pkg.h interface 
+	* pkg.c, opkg_cmd.c: from Pigi: updated to the new pkg.h interface 
 2004-02-29 florian <florian.boor at kernelconcepts.de>
 	pkg.c: Pigi and me poked around a little bit and located the cause of
 	       latest segfault. strncat is not used correctly in pkg_formatted_info
@@ -332,14 +332,14 @@
 		   BUT: There are many similar bugs remaining!
 2004-02-24 jamey <jamey at handhelds.org>
 	* configure.ac: updated to 0.99.115
-	* ipkg_cmd.c: segv caught by pigi: buffer freed in loop but used on next iterations.  bug squashed.
+	* opkg_cmd.c: segv caught by pigi: buffer freed in loop but used on next iterations.  bug squashed.
 	* user.c: realloc question buffer if it is too short so that messages are not truncated.
 2004-02-20 jamey <jamey at handhelds.org>
 	* configure.ac: updated to 0.99.114
 	* libbb/unarchive.c: patch from pigi at frumar.it: fix erroneous invalid header checksum message
 2004-02-19 jamey <jamey.hicks at hp.com>
 	* configure.ac: update to 0.99.113
-	* libipkg.c: patch from drw to fix ipkg list
+	* libopkg.c: patch from drw to fix opkg list
 2004-02-19 florian <florian.boor at kernelconcepts.de>
 	* Some minor changes to make code compile on more compilers.
 2004-02-14 jamey <jamey.hicks at hp.com>
@@ -350,20 +350,20 @@
         * pkg.c: wim delvaux's patch for status file in other destinations
 2004-01-23 florian <florian.boor at kernelconcepts.de>
 	* Applied Dan's patch that adds a package download command to
-	  libipkg.	
+	  libopkg.	
 2004-01-20 florian <florian.boor at kernelconcepts.de>
 	* Applied Dan's changes to work incuded from a C++ app.	
 2004-01-15 jamey
 	* configure.ac: updated to 0.99.110
-	* libipkg.c: added default callbacks for output
-	* ipkg_conf.c: default verbosity to 1
+	* libopkg.c: added default callbacks for output
+	* opkg_conf.c: default verbosity to 1
 2004-01-12 jamey
 	* configure.ac: updated to 0.99.109
-	* ipkg_install.c: fix potential segv sprintf_alloc with fewer args than required by format string (yay valgrind)
+	* opkg_install.c: fix potential segv sprintf_alloc with fewer args than required by format string (yay valgrind)
 	* sprintf_alloc.c: add null pointer checking
 2004-01-12 jamey
 	* configure.ac: updated to 0.99.108
-	* Makefile.am, familiar/: use ipkg-cl as default executable, install as ipkg via update-alternatives
+	* Makefile.am, familiar/: use opkg-cl as default executable, install as opkg via update-alternatives
 2004-01-12 jamey
 	* configure.ac: updated to 0.99.107
 	* void_list.c: check for null data
@@ -372,78 +372,78 @@
 	* Added void* parameter to some callbacks. 
 
 2003-12-02 florian <florian.boor at kernelconcepts.de>
-	* Added familiar/ipkg-cl.control.in, which is a prototype of
-	  control file for ipkg-cl package creation.
+	* Added familiar/opkg-cl.control.in, which is a prototype of
+	  control file for opkg-cl package creation.
 2003-12-01 florian <florian.boor at kernelconcepts.de>
-	* added ipkg command line tool using libipkg, binary is known as ipkg-cl
-	* ipkg-frontend.c: source for this tool
+	* added opkg command line tool using libopkg, binary is known as opkg-cl
+	* opkg-frontend.c: source for this tool
 	* libbb/Makefile.am: Removed changing of CFLAGS, this avoids a nasty warning.
-	* Makefile.am: Same fix and addition of new target creating ipkg-cl.
+	* Makefile.am: Same fix and addition of new target creating opkg-cl.
 	* removed ltmain.sh, libtool which seem to be created by autostuff
 	
 2003-12-01 jamey
 	* configure.ac: updated to 0.99.106
-	* pkg.c, ipkg_conf.c: check for null pointers (null pkg->dest in particular)
+	* pkg.c, opkg_conf.c: check for null pointers (null pkg->dest in particular)
 2003-11-11 jamey
 	* configure.ac: updated to 0.99.105
-	* ipkg_conf.c: added verbosity option to conf file
+	* opkg_conf.c: added verbosity option to conf file
 2003-11-11 jamey
 	* configure.ac: updated to 0.99.104
-	* ipkg_install.c: removed spurious calls to fflush, remove obsolete maintainer scripts on upgrade
-	* ipkg_remove.c: remove unused function: remove_conffiles
+	* opkg_install.c: removed spurious calls to fflush, remove obsolete maintainer scripts on upgrade
+	* opkg_remove.c: remove unused function: remove_conffiles
 2003-11-11 jamey
 	* configure.ac: updated to 0.99.103
-	* libipkg.pc.in, configure.ac: pkgconfig for libipkg
-	* ipkg_conf.c, pkg.c: check for error on fopen
+	* libopkg.pc.in, configure.ac: pkgconfig for libopkg
+	* opkg_conf.c, pkg.c: check for error on fopen
 	* pkg_hash.c: reduced verbosity
 	* libtool: arm-linux-strip does not support --strip-debug on .a files
 2003-11-10 jamey
 	* configure.ac: updated to 0.99.102
-	* ipkg_cmd.c: compute architecture_priority of packages in database before doing download command
-	* conffile.c file_util.[ch] ipkg_install.c: better separation of installation root filenames and actual filenames
+	* opkg_cmd.c: compute architecture_priority of packages in database before doing download command
+	* conffile.c file_util.[ch] opkg_install.c: better separation of installation root filenames and actual filenames
 	* pkg.h: added prototype for pkg_free_installed_files
 2003-11-10 jamey
 	* configure.ac: updated to 0.99.101
-	* libipkg changes
+	* libopkg changes
 	* generate .list files from file_hash
 2003-11-05 jamey
 	* configure.ac: updated to 0.99.100
-	* ipkg_install.c: fix segv: was passing conflictee->parent instead of conflictee
+	* opkg_install.c: fix segv: was passing conflictee->parent instead of conflictee
 2003-10-08 jamey
 	* configure.ac: updated to 0.99.99
-	* ipkg_install.c: use the root_dir after stripping off offline_root prefix
+	* opkg_install.c: use the root_dir after stripping off offline_root prefix
 2003-10-08 jamey
 	* configure.ac: updated to 0.99.98
 	* pkg_hash.c: fixed segv if replaced_by->len was 0
-	* ipkg_cmd.c: ipkg remove with no arguments will remove non-user leaf packages
-	* ipkg_remove.[ch]: export pkg_has_installed_dependents
+	* opkg_cmd.c: opkg remove with no arguments will remove non-user leaf packages
+	* opkg_remove.[ch]: export pkg_has_installed_dependents
 	* pkg_depends.c: add pkg->parent to pkg->provides
-	* ipkg_install.c: strip offline_root prefix off of conffile name so comparing the md5sums should work
+	* opkg_install.c: strip offline_root prefix off of conffile name so comparing the md5sums should work
 	* pkg.c: missing comma added
 2003-10-01 jamey
 	* configure.ac: updated to 0.99.97
-	* ipkg_cmd.c: added whatdependsrec command to show what recursively depends on a package or packages
+	* opkg_cmd.c: added whatdependsrec command to show what recursively depends on a package or packages
 	* pkg_vec.[ch]: added pkg_vec_clear_marks and pkg_vec_mark_if_matches
 	* args.c: usage string updated
 2003-09-28 jamey
 	* configure.ac: updated to 0.99.96
-	* ipkg_conf.c: adjusted verbosity
-	* ipkg_install.c: only remove replacee if it is also conflicted, per debian standard
+	* opkg_conf.c: adjusted verbosity
+	* opkg_install.c: only remove replacee if it is also conflicted, per debian standard
 	* pkg_depends.c: only add to replaced_by if it also conflicts, per debian standard
 		added pkg_provides, pkg_replaces, pkg_conflicts
 	* pkg_hash.c: adjusted verbosity	          
 2003-09-28 jamey
 	* configure.ac: updated to 0.99.95
-	* args.[ch], ipkg_cmd.c, ipkg_conf.[ch], ipkg_download.c, ipkg_install.c, ipkg_remove.c, pkg.[ch]:
-	   Implemented -test mode for ipkg.
+	* args.[ch], opkg_cmd.c, opkg_conf.[ch], opkg_download.c, opkg_install.c, opkg_remove.c, pkg.[ch]:
+	   Implemented -test mode for opkg.
 2003-09-28 jamey
 	* configure.ac: updated to 0.99.94
 	* pkg_hash.c: fix pkg_hash_fetch_best_installation_candidate so
 	that one can install another provider of an installed package name
 2003-09-26 jamey
 	* configure.ac: updated to 0.99.93
-	* ipkg_install.c: corrected message level depending on conf->force_depend
-	* ipkg_conf.c: check for duplicate src entries
+	* opkg_install.c: corrected message level depending on conf->force_depend
+	* opkg_conf.c: check for duplicate src entries
 	* nv_pair_list.[ch]: added nv_pair_list_find
 2003-09-16 jamey
 	* configure.ac: updated to 0.99.92
@@ -462,8 +462,8 @@
 	* pkg_hash.c: updated old_pkg->installed_files list when setting file owner if it was previously owned by old_pkg
 	* pkg_extract.c: use installed_file list if it exists in pkg_extract_data_file_names_to_file
 	* pkg.[ch]: added pkg_write_filelist() and pkg_write_changed_filelists()
-	* ipkg_remove.c: do not call ipkg_conf_write_status_files from ipkg_remove
-	* ipkg_install.c: use ipkg_write_filelist()
+	* opkg_remove.c: do not call opkg_conf_write_status_files from opkg_remove
+	* opkg_install.c: use opkg_write_filelist()
 	* ipgk_cmd.c: after writing status file, write any changed pkg filelists
 2003-08-20 11:02  jamey
 	* configure.ac: updated to 0.99.89
@@ -471,7 +471,7 @@
 2003-08-06 18:34  jamey
 	* configure.ac: updated to 0.99.88
 	* pkg_hash: bug 942, declare internal induction variable
-	* ipkg_cmd.c, ipkg_conf.[ch], pkg_src.[ch], pkg_src_list.[ch]: bug 604, support Packages.gz
+	* opkg_cmd.c, opkg_conf.[ch], pkg_src.[ch], pkg_src_list.[ch]: bug 604, support Packages.gz
 2003-08-06 18:34  jamey
 	* configure.ac: updated to 0.99.87
 	* pkg.c: remove extra printing of Suggests field
@@ -479,20 +479,20 @@
 	* pkg_depends.c: print info about recommendations as Notice instead of DEBUG
 2003-07-11 18:34  jamey
 	* configure.ac: updated to 0.99.86
-	* ipkg.h, ipkg_cmd.c, ipkg_configure.c, ipkg_install.c, ipkg_remove.c: only write status file if something changed.
+	* opkg.h, opkg_cmd.c, opkg_configure.c, opkg_install.c, opkg_remove.c: only write status file if something changed.
 2003-07-11 18:34  jamey
 	* configure.ac: updated to 0.99.85
 	* pkg.c, pkg.h, pkg_depends.c, pkg_depends.h, pkg_parse.c: bug 885:
 	  add recommends and suggests
-	* args.c, ipkg_cmd.c, ipkg_cmd.h: add ipkg configure command
+	* args.c, opkg_cmd.c, opkg_cmd.h: add opkg configure command
 	* pkg_vec.c: apply patch for bug 883
 2003-05-11 Jamey Hicks <jamey at handhelds.org>
 	* configure.ac: updated to 0.99.84
-	* pkg.c, ipkg-compare-versions.c: fix problem where . and - were not treated as separators in version comparison
+	* pkg.c, opkg-compare-versions.c: fix problem where . and - were not treated as separators in version comparison
 2003-04-11 Jamey Hicks <jamey at handhelds.org>
 	* configure.ac: updated to 0.99.83
-	* ipkg_install.c: use pkg->installed_size instead of pkg->size
-	* ipkg_cmd.c, ipkg_conf.c: put lists under offline_root if specified
+	* opkg_install.c: use pkg->installed_size instead of pkg->size
+	* opkg_cmd.c, opkg_conf.c: put lists under offline_root if specified
 2003-04-11 Jamey Hicks <jamey at handhelds.org>
 	* configure.ac: updated to 0.99.82
 	* pkg_hash.c: ignore Replaces directive when a package replaces itself
@@ -507,26 +507,26 @@
 2003-04-07 Jamey Hicks <jamey at handhelds.org>
 	* configure.ac: updated to 0.99.79
 	* pkg_hash.c: default architecture to host_cpu if unspecified
-	* ipkg_install.c, ipkg_download.c: refuse to install package with no architecture
+	* opkg_install.c, opkg_download.c: refuse to install package with no architecture
 2003-04-07 Jamey Hicks <jamey at handhelds.org>
 	* configure.ac: updated to 0.99.78
-	* args.[ch], ipkg_conf.[ch]: added query_all (-A)
-	* ipkg_cmd.c: finished implementing whatdepends, whatrequires, whatprovides, and whatconflicts
+	* args.[ch], opkg_conf.[ch]: added query_all (-A)
+	* opkg_cmd.c: finished implementing whatdepends, whatrequires, whatprovides, and whatconflicts
 2003-04-03 Jamey Hicks <jamey at handhelds.org>
 	* configure.ac: updated to 0.99.77
-	* ipkg_cmd.c: implemented whatdepends
-	* ipkg_conf.c: fixed typo
+	* opkg_cmd.c: implemented whatdepends
+	* opkg_conf.c: fixed typo
 2003-04-03 Jamey Hicks <jamey at handhelds.org>
 	* configure.ac: updated to 0.99.76
 	* args.c: was zeroing args structure too late
-	* ipkg_conf.c: test for existence of /etc/ipkg.conf before trying to load it
+	* opkg_conf.c: test for existence of /etc/opkg.conf before trying to load it
 2003-04-03 Jamey Hicks <jamey at handhelds.org>
 	* configure.ac: updated to 0.99.75
 	* familiar/rules: update postinst only to generate ipaqarch.conf if none exists
 	* args.[ch]: added -t or --tmp-dir option to specify tmp-dir
 2003-04-03 Jamey Hicks <jamey at handhelds.org>
 	* configure.ac: updated to 0.99.74
-	* ipkg_cmd.c: avoid segv by only calling xregfree after xregcomp was called
+	* opkg_cmd.c: avoid segv by only calling xregfree after xregcomp was called
 	* pkg_hash.c: prefer pkgs that are marked hold/prefer, next
 	abstract pkgs that are installed, next latest pkg if one provider,
 	give up if multiple providers are acceptable -- let user decide
@@ -539,7 +539,7 @@
 2003-04-03 Jamey Hicks <jamey at handhelds.org>
 	* configure.ac: updated to 0.99.71
 	* pkg.c: Added pkg_name_version_and_architecture_compare and abstract_pkg_name_compare
-	* ipkg_cmd.c: allow multiple fields for info and status command.
+	* opkg_cmd.c: allow multiple fields for info and status command.
 	Allow posix regexp's for package name in status, info, and list
 	commands.
 	* pkg_remove.c: fixed type error
@@ -547,27 +547,27 @@
 	* pkg_hash.c: Provides functionality seems to be working again
 2003-04-02 Jamey Hicks <jamey at handhelds.org>
 	* configure.ac: updated to 0.99.70
-	* args.c, args.h, ipkg_conf.c, ipkg_conf.h, ipkg_install.c: implemented nodeps option
+	* args.c, args.h, opkg_conf.c, opkg_conf.h, opkg_install.c: implemented nodeps option
 	* pkg_vec.[ch]: added [abstract_]pkg_vec_{contains,sort}
 	* pkg.c: print which script not being run in offline root mode
 2003-04-02 Jamey Hicks <jamey at handhelds.org>
 	* configure.ac: updated to 0.99.69
 	* pkg_vec.c: compare architecture to architecture, not to name
-	* ipkg_utils.c: do not exit, instead return NULL
-	* ipkg_install.c: do not exit, instead return -EINVAL
-	* ipkg_download.c: make sure to set pkg dest
-	* ipkg_cmd.c: notice instead of info for writing status file message
+	* opkg_utils.c: do not exit, instead return NULL
+	* opkg_install.c: do not exit, instead return -EINVAL
+	* opkg_download.c: make sure to set pkg dest
+	* opkg_cmd.c: notice instead of info for writing status file message
 2003-04-02 Jamey Hicks <jamey at handhelds.org>
 	* configure.ac: updated to 0.99.68
 	* pkg_vec.c, pkg_depends.c: pkg_t's are the same if they have same name, version, and architecture 
 2003-04-01 Jamey Hicks <jamey at handhelds.org>
 	* configure.ac: updated to 0.99.67
-	* ipkg_install.c: one last check for supported architecture in ipkg_install_pkg
+	* opkg_install.c: one last check for supported architecture in opkg_install_pkg
 	* pkg.c: make pkg_print_field less fragile by using strcasecmp,
 	added support to print Conflicts
 	* pkg_hash.c: if multiple candidates with right architecture
 	satisfy constraint_fcn, return latest version
-	* ipkg_cmd.c: when verbosity > 1, show if conffiles have been
+	* opkg_cmd.c: when verbosity > 1, show if conffiles have been
 	modified in info command
 	* hash_table.c, hash_table.h: count number of elements in hash
 	tables
@@ -580,30 +580,30 @@
 	* pkg_parse.c, pkg.c: added Installed-Time as field saved to status file
 2003-04-01 Jamey Hicks <jamey at handhelds.org>
 	* configure.ac: updated to 0.99.65
-	* ipkg_cmd.c, ipkg_conf.c: applied ipkg dest installation patch from Ben Lau <benlau at linux.org.hk>
-	* ipkg_cmd.c: fixed probably segv when using offline_root, fixed problem installing from local file.
-	* ipkg_conf.c: 
-	  - Do not add default architectures if ipkg configuration files include architecture definitions.
-	  - Look for /etc/ipkg/*.conf under offline root if using offline root mode
+	* opkg_cmd.c, opkg_conf.c: applied opkg dest installation patch from Ben Lau <benlau at linux.org.hk>
+	* opkg_cmd.c: fixed probably segv when using offline_root, fixed problem installing from local file.
+	* opkg_conf.c: 
+	  - Do not add default architectures if opkg configuration files include architecture definitions.
+	  - Look for /etc/opkg/*.conf under offline root if using offline root mode
 	* void_list.h: added void_list_empty()
 	* nv_pair_list.h: added nv_pair_list_empty()
 2003-03-28 14:30  Jamey Hicks <jamey at handhelds.org> 
 	* configure.ac: 0.99.64
-	* pkg_hash.c: change fprintf stderr to ipkg_message
+	* pkg_hash.c: change fprintf stderr to opkg_message
 	* pkg.h: added SF_MARKED and abstract_pkg_t state_flag field
 	* pkg.c: include Provides, Replaces, and Architecture in status
 	file
-	* ipkg_remove.c: make sure to print each dependent package only
+	* opkg_remove.c: make sure to print each dependent package only
 	once
-	* ipkg_message.h: added IPKG_DEBUG2
-	* ipkg_install.c: modify message and level depending on
+	* opkg_message.h: added OPKG_DEBUG2
+	* opkg_install.c: modify message and level depending on
 	force_depends
-	* ipkg_cmd.c: call pkg_info_preinstall_check before any
+	* opkg_cmd.c: call pkg_info_preinstall_check before any
 	install/upgrade/remove action
 	* ChangeLog, autoconfigure.sh, includes.h,
-	ipkg_conf.c, ipkg_remove.c, pkg.c, pkg.h, update-alternatives,
+	opkg_conf.c, opkg_remove.c, pkg.c, pkg.h, update-alternatives,
 	xregex.h: applied kergoth's update-alternatives patch
-	* ipkg_cmd.c, ipkg_remove.c: remove maybe_broken_removal... which
+	* opkg_cmd.c, opkg_remove.c: remove maybe_broken_removal... which
 	was an expensive no-op; before removing package, make sure that
 	nothing is installed that depends on the apkgs **provided** by a
 	package
@@ -612,112 +612,112 @@
 	of file obsolescence and package replacements in progress
 2003-03-27 18:26  jamey
 	* autoconfigure.sh: accidentally committed /usr/local/bin calls
-	* ipkg_conf.c: needed a strdup, set default verbosity back to 0
+	* opkg_conf.c: needed a strdup, set default verbosity back to 0
 	* familiar/postinst: default architecture priorities
-	* Makefile.in, autoconfigure.sh, ipkg_cmd.c, ipkg_conf.c, pkg.c:
+	* Makefile.in, autoconfigure.sh, opkg_cmd.c, opkg_conf.c, pkg.c:
 	both name and value in nv_pair_list must be actual strings
 	* pkg_hash.c: do not try to invoke NULL constraint_fcn
-	* ipkg_install.c: added file_hash_{set,get}_file_owner, created
+	* opkg_install.c: added file_hash_{set,get}_file_owner, created
 	check_downgrade
-	* ipkg_conf.c, ipkg_conf.h, ipkg_remove.c, pkg.c, pkg_hash.c,
+	* opkg_conf.c, opkg_conf.h, opkg_remove.c, pkg.c, pkg_hash.c,
 	pkg_hash.h: added file_hash_{set,get}_file_owner
 	* hash_table.c: check for key already being present in
 	hash_table_insert
 	* configure.ac: update to 0.99.63
-	* ipkg_hash_test.c: update due to new prototypes
-	* ipkg_conf.c: missed a conversion from str_list to nv_pair_list
-	* ipkg_install.c: minor tweaks
+	* opkg_hash_test.c: update due to new prototypes
+	* opkg_conf.c: missed a conversion from str_list to nv_pair_list
+	* opkg_install.c: minor tweaks
 	* pkg.c, pkg.h: added pkg_info_preinstall_check to update
 	pkg->arch_priority
 	* pkg_depends.c, pkg_depends.h: use constrained
 	pkg_hash_fetch_best_installation_candidate in
 	pkg_hash_fetch_unsatisfied_dependencies
-	* pkg_hash.c, pkg_hash.h, ipkg_cmd.c, ipkg_upgrade.c: split
+	* pkg_hash.c, pkg_hash.h, opkg_cmd.c, opkg_upgrade.c: split
 	pkg_hash_fetch_best_installation_candidate into a by name and a
 	constrained version
-	* ipkg_install.c: block SIGINT while doing core of package
+	* opkg_install.c: block SIGINT while doing core of package
 	installation (single package)
-	* ipkg_conf.c, ipkg_conf.h: support for architecture priority
+	* opkg_conf.c, opkg_conf.h: support for architecture priority
 	* pkg_depends.c: cleanup, reindent
 	* pkg.c, pkg.h: support for architecture_priority
-	* ipkg_cmd.c: installed SIGINT handler when upgrading or removing,
+	* opkg_cmd.c: installed SIGINT handler when upgrading or removing,
 	support for architecture_priority
 	* pkg_hash.c: added support for architecture priority, reindented
 	* pkg_vec.c: minor cleanup
 2003-03-24  Jamey Hicks <jamey at handhelds.org>
 	* configure.ac: updated to 0.99.61
-	* familiar/postinst: mkdir -p /etc/ipkg
+	* familiar/postinst: mkdir -p /etc/opkg
 2003-03-24  Jamey Hicks <jamey at handhelds.org>
 	* configure.ac: updated to 0.99.61
-	* ipkg_conf.c: read configuration from all *.conf files in /etc/ipkg/
-	* familiar/postinst: create /etc/ipkg/*.conf according to platform ipkg is installed on
+	* opkg_conf.c: read configuration from all *.conf files in /etc/opkg/
+	* familiar/postinst: create /etc/opkg/*.conf according to platform opkg is installed on
 2003-03-20  Jamey Hicks <jamey at handhelds.org>
 	* configure.ac: updated to 0.99.60
 	* various: added support for package architectures
 	* configure.ac: do not test for malloc
-2003-03-17  Aman Gupta <ipkg at themastermind1.net>
+2003-03-17  Aman Gupta <opkg at themastermind1.net>
 	* configure.ac: updated to 0.99.59
 	* args.c: show all verbosity levels in usage info
 	* args.h: changed default verbosity level to 1
-	* ipkg_cmd.c: ipkg_multiple_files_scan() was useless, switch to using 
-	ipkg_prepare_url_for_install()
-	* ipkg_install.c: fix --force-reinstall
-	* ipkg_remove.c: stop removing of modified conffiles
+	* opkg_cmd.c: opkg_multiple_files_scan() was useless, switch to using 
+	opkg_prepare_url_for_install()
+	* opkg_install.c: fix --force-reinstall
+	* opkg_remove.c: stop removing of modified conffiles
 2003-03-04  Jamey Hicks <jamey at handhelds.org>
 	* configure.ac: updated to 0.99.56
-	* ipkg_message.c: show error messages by default
-	* ipkg_message.h: protect against multiple inclusion
-	* conffile.[ch]: switch to ipkg_message, added conf argument to conffile_has_been_modified
-	* ipkg.h: move EXTENSION macros here
+	* opkg_message.c: show error messages by default
+	* opkg_message.h: protect against multiple inclusion
+	* conffile.[ch]: switch to opkg_message, added conf argument to conffile_has_been_modified
+	* opkg.h: move EXTENSION macros here
 	* pkg_depends.c: minor cleanup
 	* pkg.h: added prefer and obsolete flags
 	* pkg.c: parse and unparse SF_PREFER and SF_OBSOLETE
-	* ipkg_install.[ch]: 
+	* opkg_install.[ch]: 
 	  - added {pkg,name}_mark_dependencies_for_installation, 
 	  - added conf argument to conffile_has_been_modified 
-	  - missing ifdef IPKG_DEBUG_NO_TMP_CLEANUP
-	* ipkg_remove.c: added conf argument to conffile_has_been_modified
-	* ipkg_download.c: added ipkg_prepare_for_install
+	  - missing ifdef OPKG_DEBUG_NO_TMP_CLEANUP
+	* opkg_remove.c: added conf argument to conffile_has_been_modified
+	* opkg_download.c: added opkg_prepare_for_install
 2003-03-01  Jamey Hicks <jamey at handhelds.org>
 	* configure.ac: updated to 0.99.55
-	* ipkg.h: wrap #if 0 around definition of of IPKG_DEBUG_NO_TMP_CLEANUP
+	* opkg.h: wrap #if 0 around definition of of OPKG_DEBUG_NO_TMP_CLEANUP
 2003-03-01  Jamey Hicks <jamey at handhelds.org>
 	* configure.ac: updated to 0.99.54
-	* ipkg_install.c: make old package SW_DEINSTALL during ipkg installation
-	* ipkg_cmd.[ch]: added some code to install packages marked SW_INSTALL, but have not enabled this code yet.
+	* opkg_install.c: make old package SW_DEINSTALL during opkg installation
+	* opkg_cmd.[ch]: added some code to install packages marked SW_INSTALL, but have not enabled this code yet.
 2003-03-01  Jamey Hicks <jamey at handhelds.org>
 	* configure.ac: updated to 0.99.53
 	* pkg_depends.c: let SW_INSTALL satisfy dependences (instead of SS_INSTALL)
 2003-03-01  Daniele Nicolodi <daniele at grinta.net>	
-	* ipkg_install.c: indentation fixes and finish switch to message
+	* opkg_install.c: indentation fixes and finish switch to message
 	facility
-	* ipkg_cmd.c: indentation fixes, switch to message facility and
+	* opkg_cmd.c: indentation fixes, switch to message facility and
 	some code cleanup
-	* ipkg_message.c (ipkg_message): check for a NULL *conf parameter
-	* ipkg_message.h: renamed IPKG_ERR in IPKG_ERROR
+	* opkg_message.c (opkg_message): check for a NULL *conf parameter
+	* opkg_message.h: renamed OPKG_ERR in OPKG_ERROR
 2003-02-28  Jamey Hicks <jamey at handhelds.org> (patch from Daniele Nicolodi <daniele at grinta.net>)
 	* configure.ac: incremented version to 0.99.5
-	* ipkg_message.[ch]: added message facility
+	* opkg_message.[ch]: added message facility
 	* args.[ch]: verbosity control
-	* ipkg_conf.[ch]: verbosity control
-	* ipkg_install.c: switch to using message factility
+	* opkg_conf.[ch]: verbosity control
+	* opkg_install.c: switch to using message factility
 2003-02-28  Jamey Hicks <jamey at handhelds.org>
 	* configure.ac: incremented version to 0.99.51
-	* ipkg_cmd.c: added ipkg_statisfy_all_dependences, called after
+	* opkg_cmd.c: added opkg_statisfy_all_dependences, called after
 	install/upgrade of packages to handle packages that were split and
 	no longer provide all the resources they used to provide.
 2003-02-27  Jamey Hicks <jamey at handhelds.org>
 	* configure.ac: incremented version to 0.99.50
-	* ipkg_cmd.c: write out status after doing an upgrade
+	* opkg_cmd.c: write out status after doing an upgrade
 2003-02-27  Jamey Hicks <jamey at handhelds.org> (another patch from pb)
 	* configure.ac: incremented version to 0.99.49
 	* pkg_parse.c, pkg.c: do not treat deb revision specially
 2003-02-27  Jamey Hicks <jamey at handhelds.org> (another patch from pb)
 	* configure.ac: incremented version number to 0.99.48
-	* args.c: added help for ipkg flags sub-command
-	* ipkg_cmd.c: added ipkg_flag_cmd, do not upgrade package marked hold
-	* ipkg_install.c: do not remove obsolesced files if old_pkg is flagged noprune
-	* ipkg_remove.c: pkg->state_flag is a bitvector now
+	* args.c: added help for opkg flags sub-command
+	* opkg_cmd.c: added opkg_flag_cmd, do not upgrade package marked hold
+	* opkg_install.c: do not remove obsolesced files if old_pkg is flagged noprune
+	* opkg_remove.c: pkg->state_flag is a bitvector now
 	* pkg.c: pkg->state_flag is a bitvector now
 	* pkg.h: pkg->state_flag is a bitvector now
 2003-02-27  Jamey Hicks <jamey at handhelds.org> (another patch from pb)
@@ -730,9 +730,9 @@
 2003-02-24  Jamey Hicks <jamey at handhelds.org> (per patch from Philip Blundell <pb at handhelds.org>)
 	* configure.ac: incremented version to 0.99.45
 	* file_util.c: include space for null in line_size
-	* ipkg_cmd.c: sigint handler while configuring packages
-	* ipkg_install.c: state_status != SS_INSTALLED and != SS_UNPACKED
-	* ipkg_remove.c: missing i++
+	* opkg_cmd.c: sigint handler while configuring packages
+	* opkg_install.c: state_status != SS_INSTALLED and != SS_UNPACKED
+	* opkg_remove.c: missing i++
 	* pkg.c: do not run scripts in offline_root mode
 	* pkg_depends.c: every package provides itself
 	* pkg_hash.c: better handling of packges provided by multiple providers
@@ -741,25 +741,25 @@
 	* args.c: added doc for -force-overwrite
 2002-11-26  Jamey Hicks <jamey at handhelds.org>
 	* configure.ac: incremented version number to 0.99.43
-	* ipkg_install.c: completely skip the space check when -force_space asserted
+	* opkg_install.c: completely skip the space check when -force_space asserted
 2002-11-23  Jamey Hicks <jamey at handhelds.org>
 	* configure.ac: incremented version number to 0.99.42
 	* args.c: missed one spot checking for -force_space or -force-space    
 2002-11-23  Jamey Hicks <jamey at handhelds.org>
 	* configure.ac: incremented version number to 0.99.41
-	* ipkg_install.c: added -force_space option to override out of space check
+	* opkg_install.c: added -force_space option to override out of space check
 2002-11-23  Aman Gupta  <oz at themastermind1.net>
 	* configure.ac: incremented version number to 0.99.40
-	* ipkg_configure.c: updated to match new text output format
-	* ipkg_install.c: updated to new text output format
+	* opkg_configure.c: updated to match new text output format
+	* opkg_install.c: updated to new text output format
 			  fixed problems where ipks installed from file or
 			  http were being installed over newer ipks of the
 			  same name
-	* ipkg_remove.c: updated to new text output format
-			 made ipkg remove do what ipkg purge originally did,
+	* opkg_remove.c: updated to new text output format
+			 made opkg remove do what opkg purge originally did,
 			 by having it remove conffiles, and status entries for
-			 ipks that are removed. ipkg_purge now calls
-			 ipkg_remove
+			 ipks that are removed. opkg_purge now calls
+			 opkg_remove
 2002-11-22  Jamey Hicks <jamey.hicks at hp.com>
 	* configure.ac: incremented version number to 0.99.39
         * applied patches from Aman Gupta for better handling of dests
@@ -771,18 +771,18 @@
 	* pkg_hash.c: moved internals of hash_tables out of pkg_hash.c
 2002-10-29  Jamey Hicks <jamey.hicks at hp.com>
 	* configure.ac: incremented version number to 0.99.37
-	* ipkg_cmd.c: ipkg_upgrade_cmd now installs uninstalled packages
+	* opkg_cmd.c: opkg_upgrade_cmd now installs uninstalled packages
   	              instead of getting a segv 
 2002-10-29  Jamey Hicks <jamey.hicks at hp.com>
 	* configure.ac: incremented version number to 0.99.36
 	* changed verbose_get to verbose_wget as documented
 2002-08-08  Jamey Hicks <jamey.hicks at hp.com>
 	* configure.ac: incremented version number to 0.99.34
-	* ipkg_cmd.c: fixed problem stringifying HOST_CPU
+	* opkg_cmd.c: fixed problem stringifying HOST_CPU
 	* Makefile.am: helped fix problem stringifying HOST_CPU
 2002-08-08  Jamey Hicks <jamey.hicks at hp.com>
 	* configure.ac: incremented version number to 0.99.33
-	* ipkg_cmd.c, args.c: added print-architecture and print-installation-architecture commands
+	* opkg_cmd.c, args.c: added print-architecture and print-installation-architecture commands
 	* Makefile.am: added defines for HOST_CPU and BUILD_CPU to CFLAGS and package: target
 2002-08-08  Jamey Hicks <jamey.hicks at hp.com>
 	* configure.ac: incremented version number to 0.99.32
@@ -790,10 +790,10 @@
 2002-08-07  Jamey Hicks <jamey.hicks at hp.com>
 	* configure.ac: incremented version number to 0.99.31
 	* other: applied multiple providers patch from philip blundell
-	* ipkg_cmd.c: implemented compare_versions cmd
+	* opkg_cmd.c: implemented compare_versions cmd
 2002-07-25  Jamey Hicks <jamey.hicks at hp.com>
 	* configure.ac: incremented version number to 0.99.30
-	* ipkg_conf.c: added offline_root_pre_script_cmd and offline_root_post_script_cmd
+	* opkg_conf.c: added offline_root_pre_script_cmd and offline_root_post_script_cmd
 	* pkg.c: execute scripts in chroot'ed environment running
 	pre_script_cmd and post_script_cmd before and after the pkg script. 
 2002-07-24  Jamey Hicks <jamey.hicks at hp.com>
@@ -801,11 +801,11 @@
 	* pkg.c: fixed a segv when printing Replaces field
 2002-07-24  Jamey Hicks <jamey.hicks at hp.com>
 	* configure.ac: incremented version number to 0.99.28
-	* ipkg_cmd.c: merged functionality from ipkg_install_cmd into
-	ipkg_upgrade_cmd with an eye towards unifying these two commands. 
-	* ipkg_install.c: installing a package that replaces other
+	* opkg_cmd.c: merged functionality from opkg_install_cmd into
+	opkg_upgrade_cmd with an eye towards unifying these two commands. 
+	* opkg_install.c: installing a package that replaces other
 	packages removes them first.  (Upgrade does not do replacements automatically).
-	* ipkg_remove.c: ipkg_remove_pkg will remove a package with
+	* opkg_remove.c: opkg_remove_pkg will remove a package with
 	installed dependents if state_flag == SF_REPLACE.
 2002-07-24  Jamey Hicks <jamey.hicks at hp.com>
 	* configure.ac: incremented version number to 0.99.27
@@ -821,17 +821,17 @@
 	* various files: trying to stomp a segv in conflicts checking.  
 2002-07-17  Jamey Hicks <jamey.hicks at hp.com>
 	* configure.ac: incremented version number to 0.99.23
-	* ipkg_remove.c: do not do recursive removal if force-depends is
+	* opkg_remove.c: do not do recursive removal if force-depends is
 	  specified
 	* other-files: other cleanups to reduce code clutter
 2002-07-16  Jamey Hicks <jamey.hicks at hp.com>
 	* configure.ac: incremented version number to 0.99.22
 	* user.[ch]: moved user interaction procedure here
-	* args.[ch], ipkg_conf.[ch]: added force_removal_of_dependent_packages
+	* args.[ch], opkg_conf.[ch]: added force_removal_of_dependent_packages
 	* pkg.h: added state_status to abstract_pkg_t
-	* ipkg_remove.c: If package has installed dependents, then only
+	* opkg_remove.c: If package has installed dependents, then only
 	remove if force_removal_of_dependent_packages is asserted in
-	ipkg.conf or on command line.  Will add user interaction option later.
+	opkg.conf or on command line.  Will add user interaction option later.
 2002-07-16  Jamey Hicks <jamey.hicks at hp.com>
 	* configure.ac: incremented version number to 0.99.21 after
 	applying dependent removal and conflicts patch.
@@ -839,15 +839,15 @@
 2002-07-14  Jamey Hicks <jamey.hicks at hp.com>
 	
 	* configure.ac: incremented version number to 0.99.20
-	* ipkg_download.c: removed useless -N flag from wget 
+	* opkg_download.c: removed useless -N flag from wget 
 	* update-alternatives: 'head -1' -> 'head -n 1', no sort -k 2 for busybox
 	
 2002-07-15  Karthikeyan K  <karthik at innvo.com>
 	
-	* ipkg_remove.c (ipkg_remove_dependant_pkgs): removed setting the 
+	* opkg_remove.c (opkg_remove_dependant_pkgs): removed setting the 
 	dependencies_checked variable in the while loop b4 actually checking
 	the dependencies of that package.
-	* ipkg_cmd.c (ipkg_multiple_files_scan): added check for ".ipk" and
+	* opkg_cmd.c (opkg_multiple_files_scan): added check for ".ipk" and
 	".deb" extension, so that no caching is attempted on  arguments that
 	are not local files
 	* pkg_depends.c (pkg_hash_fetch_conflicts): while returning NULL,
@@ -875,9 +875,9 @@
 	found before returning
 
 2002-07-04  Abhaya Shenoy  <abhaya at innvo.com>
-	* ipkg_install.c (check_conflicts_for): new function to call
+	* opkg_install.c (check_conflicts_for): new function to call
 	pkg_hash_fetch_conflicts and print offending packages
-	(ipkg_install_pkg): added call to check_conflicts_for
+	(opkg_install_pkg): added call to check_conflicts_for
 	* pkg.c (pkg_merge): provides from oldpkg should be given
 	priority
 	(pkg_init): init of conflicts, conflicts_count fields
@@ -893,25 +893,25 @@
 
 2002-07-04  Karthikeyan K  <karthik at innvo.com>
 	
-	* ipkg_cmd.c (ipkg_multiple_files_scan): new function to handle installation
+	* opkg_cmd.c (opkg_multiple_files_scan): new function to handle installation
 	of already downloaded files
-	(ipkg_install_cmd): added call to ipkg_multiple_files_scan
-	(ipkg_remove_cmd): added call to possible_broken_removal_of_packages
-	* ipkg_install.c (ipkg_install_pkg): added check to remove redundant upgrade
+	(opkg_install_cmd): added call to opkg_multiple_files_scan
+	(opkg_remove_cmd): added call to possible_broken_removal_of_packages
+	* opkg_install.c (opkg_install_pkg): added check to remove redundant upgrade
 	when a package to be installed is already installed as a dependancy of
 	another
-	* ipkg_remove.c (possible_broken_removal_of_packages): new fnuction 
+	* opkg_remove.c (possible_broken_removal_of_packages): new fnuction 
 	to check that all packages can be removed, before actually starting to
 	remove them
-	(ipkg_remove_dependant_pkgs): new function to remove dependant packages
-	(ipkg_remove_pkg): added call to ipkg_remove_dependant_pkgs
+	(opkg_remove_dependant_pkgs): new function to remove dependant packages
+	(opkg_remove_pkg): added call to opkg_remove_dependant_pkgs
 	* pkg.c (abstract_pkg_init): initialized dependencies_checked
 	* pkg_hash.c (pkg_hash_dump): added more information to hash dump
 	
 2002-07-03  Jamey Hicks <jamey.hicks at hp.com>
 	
 	* configure.ac: incremented version number to 0.99.16
-	* ipkg_install.c: defensive programming in case pkg contains no Size: clause
+	* opkg_install.c: defensive programming in case pkg contains no Size: clause
 	
 2002-07-02  Jamey Hicks <jamey.hicks at hp.com>
 	
@@ -926,10 +926,10 @@
 2002-06-17  Jamey Hicks	<jamey.hicks at hp.com>
 	
 	* configure.ac: incremented version number to 0.99.12
-	* args.h, ipkg_conf.h, ipkg_install.c: Added force_overwrite
-	option.  When this is asserted, ipkg will overwrite files that
+	* args.h, opkg_conf.h, opkg_install.c: Added force_overwrite
+	option.  When this is asserted, opkg will overwrite files that
 	have no owner or that belong to other packages.
-	* ipkg_conf.c, ipkg_dest.c: Update status file atomically, keeping
+	* opkg_conf.c, opkg_dest.c: Update status file atomically, keeping
 	old copy of status file if cannot update new status file.  Applied
 	patch from Jukka Santala for this fix.
 	
@@ -956,48 +956,48 @@
 	* familiar/rules (binary-arch): Fixed to use "make install-strip"
 	rather than "make install" and a strip command.
 
-	* ipkg_cmd.c (ipkg_install_cmd): Moved an error message up from
-	ipkg_install_by_name, (eventually all error messages should come
-	up out of what will become libipkg, (pkg.c, ipkg_install.c, etc.)
-	and into ipkg_cmd.c and friends).
-	(ipkg_upgrade_pkg): Pushed downgrade check down into
-	ipkg_install_by_name so that "ipkg install foo" will do the
+	* opkg_cmd.c (opkg_install_cmd): Moved an error message up from
+	opkg_install_by_name, (eventually all error messages should come
+	up out of what will become libopkg, (pkg.c, opkg_install.c, etc.)
+	and into opkg_cmd.c and friends).
+	(opkg_upgrade_pkg): Pushed downgrade check down into
+	opkg_install_by_name so that "opkg install foo" will do the
 	downgrade check.
 
-	* ipkg.h: Rename some ipkg_error_t error codes to be more
+	* opkg.h: Rename some opkg_error_t error codes to be more
 	consistent.
 
-	* ipkg_install.c (resolve_conffiles): Added missing removal of
+	* opkg_install.c (resolve_conffiles): Added missing removal of
 	backed-up modified conffiles, (which led to bizarre, bogus
 	conffile prompting the next time the package was upgraded).
 	(user_prefers_old_conffile): Fixed reversed arguments to diff in
 	interactive conffiles prompting.
-	(ipkg_install_by_name): Fixed "ipkg install foo" to never
-	downgrade foo, (just like "ipkg upgrade foo").
+	(opkg_install_by_name): Fixed "opkg install foo" to never
+	downgrade foo, (just like "opkg upgrade foo").
 
 	* familiar/rules: Added installation of
-	/usr/share/doc/ipkg/copyright file. Fixed so that ipkg.conf goes
+	/usr/share/doc/opkg/copyright file. Fixed so that opkg.conf goes
 	to /etc, not /usr/etc, (but still keep binary in /usr/bin not
-	/bin). Changed name of installed binary from ipkg-unstable to
-	ipkg.
+	/bin). Changed name of installed binary from opkg-unstable to
+	opkg.
 
 	* familiar/control.in (Package): Changed package name from
-	ipkg-unstable to ipkg.
+	opkg-unstable to opkg.
 
 	* pkg_parse.c (parseVersion): Fixed to ignore whitespace at
 	beginning of version string.
 	(pkg_parse_raw): Fixed segfault if a package record list ends with
 	a package paragraph without a final blank line.
 
-	* ipkg_install.c (check_data_file_clashes): Improved wording of
+	* opkg_install.c (check_data_file_clashes): Improved wording of
 	file clash error message.
 
-	* ipkg_download.c (ipkg_download_pkg): Fixed segfault if package
+	* opkg_download.c (opkg_download_pkg): Fixed segfault if package
 	has no src, (occurs if package had benn installed locally, then
 	was removed (but not purged), then tried to reinstall eithout it
-	existing in any /usr/lib/ipkg/lists/* file).
+	existing in any /usr/lib/opkg/lists/* file).
 
-	* etc/ipkg.conf: Added a default ipkg.conf to the distribution.
+	* etc/opkg.conf: Added a default opkg.conf to the distribution.
 
 2002-03-13  Carl Worth  <cworth at east.isi.edu>
 
@@ -1006,14 +1006,14 @@
 	* RELEASE_NOTES: Added release notes for 0.99.7.
 
 	* pkg.c (pkg_run_script): Added support to export
-	IPKG_OFFLINE_ROOT. This is really a nasty hack as it means scripts
-	need to be modified to check IPKG_OFFLINE_ROOT. I'd really prefer
+	OPKG_OFFLINE_ROOT. This is really a nasty hack as it means scripts
+	need to be modified to check OPKG_OFFLINE_ROOT. I'd really prefer
 	coming up with a good, reliable chroot system. But for now this
 	will let update-alternatives work, (which already does examine
-	IPKG_OFFLINE_ROOT).
+	OPKG_OFFLINE_ROOT).
 	(pkg_run_script): Added missing brace.
 
-	* ipkg_conf.c (ipkg_conf_init): Reworked significantly to properly
+	* opkg_conf.c (opkg_conf_init): Reworked significantly to properly
 	set up the pkg_dest_list stuff to account for offline_root.
 
 	* args.c (args_parse): Added support for -force_defaults in
@@ -1026,12 +1026,12 @@
 
 	* RELEASE_NOTES: Added release notes for 0.99.6.
 
-	* ipkg_download.c (ipkg_download): Fixed bug in handling of
+	* opkg_download.c (opkg_download): Fixed bug in handling of
 	"file://" URLs.
 
-	* ipkg.c (main): Fixed to abort if ipkg_conf_init fails.
+	* opkg.c (main): Fixed to abort if opkg_conf_init fails.
 
-	* ipkg_conf.c (ipkg_conf_init): Fixed to complain if given an
+	* opkg_conf.c (opkg_conf_init): Fixed to complain if given an
 	unknown dest.
 
 	* pkg.c (pkg_print_field): Fixed several fields to not print if
@@ -1045,33 +1045,33 @@
 	* RELEASE_NOTES: Added release notes for 0.99.5.
 
 	* familiar/rules (binary-arch): Added strip back in in preparation
-	of non-unstable release of ipkg.
+	of non-unstable release of opkg.
 
 	* str_util.c (str_starts_with): Added convenience function.
 
 	* pkg_extract.c (pkg_extract_data_file_names_to_file): Fixed
 	filenames in *.list files to be compatible with dpkg and the old
-	ipkg, (no prefix of "." for example).
+	opkg, (no prefix of "." for example).
 
 	* pkg.c (pkg_run_script): Added export of PKG_ROOT for the benefit
 	of maintainer scripts.
 
-	* ipkg_remove.c (ipkg_remove_pkg): Complain and abort if user
+	* opkg_remove.c (opkg_remove_pkg): Complain and abort if user
 	attempts to remove an essential package, (also inform them of the
 	force option if they insist).
 
-	* ipkg_install.c (ipkg_install_pkg): Added message about whether
+	* opkg_install.c (opkg_install_pkg): Added message about whether
 	installing or upgrading.
 
-	* ipkg_download.c (ipkg_download): Added support for "file://"
+	* opkg_download.c (opkg_download): Added support for "file://"
 	URLs, (untested).
-	(ipkg_download): Added support for wget proxy options.
+	(opkg_download): Added support for wget proxy options.
 
-	* ipkg_conf.c (ipkg_conf_init): Added proxy support to ipkg_conf,
+	* opkg_conf.c (opkg_conf_init): Added proxy support to opkg_conf,
 	(http_proxy, ftp_proxy, no_proxy, proxy_user, and proxy_passwd).
 
-	* ipkg_cmd.c (ipkg_upgrade_pkg): Moved Upgrading message from
-	ipkg_upgrade_cmd to ipkg_install_pkg.
+	* opkg_cmd.c (opkg_upgrade_pkg): Moved Upgrading message from
+	opkg_upgrade_cmd to opkg_install_pkg.
 
 	* args.c (args_parse): Added new option
 	-force-removal-of-essential-packages, (which is intentionally
@@ -1100,7 +1100,7 @@
 	* pkg.c (pkg_merge): Made pkg_merge a NOP if oldpkg == newpkg.
 	(pkg_print_field): Don't print MD5sum field if NULL.
 
-	* ipkg_install.c (satisfy_dependencies_for): Now returns error
+	* opkg_install.c (satisfy_dependencies_for): Now returns error
 	status if one or more of the dependencies fail to install cleanly.
 	(unpack_pkg_control_files): Fixed to not tack on a bunch of
 	NULL-valued conffiles entries if non-NULL conffiles already
@@ -1109,15 +1109,15 @@
 	(unpack_pkg_control_files): Cleaned up conffile filenames to not
 	have ugly things like "///" inside them.
 
-	* ipkg_download.c (ipkg_download): Cleaned up error message.
-	(ipkg_download): Now uses new file_move function.
-	(ipkg_download_pkg): Created new function, (from old code in ipkg_install).
+	* opkg_download.c (opkg_download): Cleaned up error message.
+	(opkg_download): Now uses new file_move function.
+	(opkg_download_pkg): Created new function, (from old code in opkg_install).
 
-	* ipkg_cmd.c (ipkg_download_cmd): Added new "ipkg download"
+	* opkg_cmd.c (opkg_download_cmd): Added new "opkg download"
 	command.
 
 	* file_util.c (file_move): Created file_move, (from code that had
-	been in ipkg_download).
+	been in opkg_download).
 	(file_copy): Added error message on failure.
 
 	* conffile.c (conffile_has_been_modified): Eliminated crash if
@@ -1139,25 +1139,25 @@
 
 	* pkg_hash.c (pkg_hash_pkg_owning_file): Moved this function in
 	from pkg_dest.c. Also, updated it to use pkg_get_installed rather
-	than mucking around inside /usr/lib/ipkg and globbing for *.list
+	than mucking around inside /usr/lib/opkg and globbing for *.list
 	files.
 	(pkg_hash_fetch_best_installation_candidate): Fixed to only return
 	a package that actually could be installed, (ie. it must have
 	either a local_filename or a non-NULL src from which it could be
-	downloaded). This prevents a segfault during "ipkg upgrade".
+	downloaded). This prevents a segfault during "opkg upgrade".
 
 	* pkg.c (pkg_get_installed_files): Fixed to not do strange things
 	to filenames such as: "//./bin/sh"
 
-	* ipkg_cmd.c (ipkg_files_cmd): Added pkg_free_installed_files to
+	* opkg_cmd.c (opkg_files_cmd): Added pkg_free_installed_files to
 	conserve a bit of memory.
-	(ipkg_search_cmd): Updated to use pkg_get_installed rather than
-	mucking around inside /usr/lib/ipkg and globbing for *.list files.
+	(opkg_search_cmd): Updated to use pkg_get_installed rather than
+	mucking around inside /usr/lib/opkg and globbing for *.list files.
 
 	* pkg.c (pkg_free_installed_files): Added this function to free up
 	memory from pkg_get_installed_files.
 
-	* ipkg_conf.c (ipkg_conf_set_option): Added force_reinstall option
+	* opkg_conf.c (opkg_conf_set_option): Added force_reinstall option
 	to allow reinstallation of an installed package.
 
 	* args.c (args_parse): Added -force-reinstall option to enable
@@ -1169,7 +1169,7 @@
 	* busybox-0.60.2/libbb/unarchive.c (free_header_ar): Added
 	function to plug memory leak.
 
-	* ipkg_install.c (check_data_file_clashes): Fixed crash if no
+	* opkg_install.c (check_data_file_clashes): Fixed crash if no
 	package can be found owning the pre-existing file.
 
 	* pkg_dest.c (pkg_dest_deinit): Fixed bug that pkg_dest was
@@ -1225,13 +1225,13 @@
 	(pkg_print_status): Fixed pkg_print_status to work whether or not
 	the package is installed.
 
-	* ipkg_utils.c (read_raw_pkgs_from_file): Moved fclose out of
+	* opkg_utils.c (read_raw_pkgs_from_file): Moved fclose out of
 	read_raw_pkgs_from_stream and into this function where it belongs,
 	(since the fopen occurs here).
 	(trim_alloc): Fixed trim to not free data passed in. Changed the
 	name to make it obvious that it is allocating memory.
 
-	* ipkg_install.c (ipkg_install_from_file): Fixed to be more robust
+	* opkg_install.c (opkg_install_from_file): Fixed to be more robust
 	to the fact that hash_insert_pkg sometimes frees the data that I
 	pass into it (!).
 	(satisfy_dependencies_for): Cosmetic change to messages.
@@ -1240,7 +1240,7 @@
 	file if necessary.
 	(satisfy_dependencies_for): Added pkg_vec_deinit to plug memory
 	leak.
-	(ipkg_install_pkg): Added "run ipkg update?" hint to error
+	(opkg_install_pkg): Added "run opkg update?" hint to error
 	message.
 	(backup_modified_conffiles): Made more robust to the case that a
 	conffile has disappeared.
@@ -1251,50 +1251,50 @@
 	(cleanup_temporary_files): Added missing closedir to plug a memory
 	leak.
 
-	* ipkg_download.c (ipkg_download): Cosmetic change to error
+	* opkg_download.c (opkg_download): Cosmetic change to error
 	messages.
 
-	* ipkg_conf.c (ipkg_conf_parse_file): Plugged some small memory
+	* opkg_conf.c (opkg_conf_parse_file): Plugged some small memory
 	leaks.
-	(ipkg_conf_set_option): Changed configuration options from
+	(opkg_conf_set_option): Changed configuration options from
 	force-depends, force-defaults to force_depdends, force_defaults to
-	be compatible with old ipkg.conf files.
-	(ipkg_conf_set_option): Fixed bug in parsing options.
-	(ipkg_conf_write_status_files): Fixed to list all interesting
+	be compatible with old opkg.conf files.
+	(opkg_conf_set_option): Fixed bug in parsing options.
+	(opkg_conf_write_status_files): Fixed to list all interesting
 	packages, (any with non-default state), in status file rather than
 	just installed files.
-	(ipkg_conf_write_status_files): Plugged a memory leak.
+	(opkg_conf_write_status_files): Plugged a memory leak.
 
-	* ipkg_cmd.c (ipkg_status_cmd): Changed "ipkg status" to use
+	* opkg_cmd.c (opkg_status_cmd): Changed "opkg status" to use
 	pkg_print_info so it is much more verbose, (includes fields such
 	as Maintainer, etc. that are merged in from the lists files).
 
-	* ipkg.h (IPKG_DEBUG_NO_TMP_CLEANUP): Added compile-time option to
+	* opkg.h (OPKG_DEBUG_NO_TMP_CLEANUP): Added compile-time option to
 	preserve temporary files for easier debugging.
 
 	* file_util.c (file_md5sum_alloc): cosmetic changes to variable
 	names.
 	
-	* ipkg_conf.c (ipkg_conf_init): Added support for offline_root
+	* opkg_conf.c (opkg_conf_init): Added support for offline_root
 	configuration file option.
 
 	* args.c (args_init): Added support for -o, -offline,
 	-offline-root command-line arguments. (Although they don't really
 	have any effect yet).
 
-	* ipkg_install.c (ipkg_install_pkg): Changed back to marking
+	* opkg_install.c (opkg_install_pkg): Changed back to marking
 	package as installed before postinst, (the pkg_run_script wanted
-	to find the scripts in /usr/lib/ipkg/info). Actually, it could
+	to find the scripts in /usr/lib/opkg/info). Actually, it could
 	probably find the script in either place at this point so maybe it
 	doesn't really matter.
 
 2002-03-07  Carl Worth  <cworth at east.isi.edu>
 
-	* ipkg_install.c (ipkg_install_pkg): Changed to only mark package
-	as installed after running ipkg_configure, (to run the postinst
+	* opkg_install.c (opkg_install_pkg): Changed to only mark package
+	as installed after running opkg_configure, (to run the postinst
 	script).
 
-	* RELEASED ipkg-unstable 0.99.0
+	* RELEASED opkg-unstable 0.99.0
 
 	* Updated all instances of "XXX" in the code to indicate one of
 	the following categories:
@@ -1304,43 +1304,43 @@
 	XXX: FEATURE: Comment describes a useful feature request.
 	
 	* pkg.c (pkg_print_status): Added the Depends field to package
-	paragraphs in the status file, ("ipkg remove" will need this).
+	paragraphs in the status file, ("opkg remove" will need this).
 
-	* ipkg_install.c (satisfy_dependencies_for): Fixed "ipkg install"
+	* opkg_install.c (satisfy_dependencies_for): Fixed "opkg install"
 	to not complain several times about "Package foo already
 	installed" when doing large recursive installs.
-	(ipkg_install_pkg): "ipkg install foo" for an installed package
+	(opkg_install_pkg): "opkg install foo" for an installed package
 	will now check and install any missing dependencies before exiting
 	with "Package foo is alrady installed."
 
 2002-03-06  Carl Worth  <cworth at east.isi.edu>
 
 	* pkg_dest.c (pkg_dest_pkg_owning_file_alloc): Moved this function
-	here from ipkg_install.c. Also plugged a memory leak in it with
+	here from opkg_install.c. Also plugged a memory leak in it with
 	globfree.
 
 	* pkg.c (pkg_remove_installed_files_list): Fixed bug that
-	prevented package.list file from ever being removed during "ipkg
+	prevented package.list file from ever being removed during "opkg
 	remove".
 
-	* ipkg_remove.c (remove_data_files_and_list): Fixed noisy and
-	spurious warnings about non-empty directories. "ipkg remove"
+	* opkg_remove.c (remove_data_files_and_list): Fixed noisy and
+	spurious warnings about non-empty directories. "opkg remove"
 	should now only say anything if a directory that was solely
 	provided by that package is non-empty.
 
-	* ipkg_cmd.c (ipkg_install_pending_cmd): Plugged memory leak with
+	* opkg_cmd.c (opkg_install_pending_cmd): Plugged memory leak with
 	globfree.
 
-	* ipkg_install.c: *Many* fixes to enable "ipkg upgrade" to more or
+	* opkg_install.c: *Many* fixes to enable "opkg upgrade" to more or
 	less work. Primarily fixing file clash identification and conffile
-	handling/resolution. "ipkg upgrade" has now worked correctly on
+	handling/resolution. "opkg upgrade" has now worked correctly on
 	several test cases!
 
-	* ipkg_install.c (unpack_pkg_control_files): Now initializes
+	* opkg_install.c (unpack_pkg_control_files): Now initializes
 	conffiles list from the contents of conffiles control file,
 	(leaves md5sum calculation until the actual conffiles are
 	extracted later).
-	(ipkg_install_pkg): Separated backup_modified_conffiles and
+	(opkg_install_pkg): Separated backup_modified_conffiles and
 	check_data_file_clashes into separate functions.
 	(preinst_configure): Simplified this function pushing its old
 	logic into pkg.c:pkg_run_script.
@@ -1394,10 +1394,10 @@
 	* pkg.c (pkg_print_field): Added support for printing Conffiles
 	field.
 
-	* ipkg_install.c (remove_obsolesced_files): With the fixed
+	* opkg_install.c (remove_obsolesced_files): With the fixed
 	pkg_get_installed_files_list from below, this function now seems
 	to work!
-	(ipkg_install_pkg): Fixed to mark old package as uninstalled after
+	(opkg_install_pkg): Fixed to mark old package as uninstalled after
 	upgrading.
 
 	* pkg.c (pkg_get_installed_files_list): Fixed so that it's
@@ -1405,9 +1405,9 @@
 	package, (it pulls the list of data files straight out of the
 	package).
 
-	* ipkg_cmd.c (ipkg_upgrade_cmd): Fixed ipkg_upgrade to not choke
+	* opkg_cmd.c (opkg_upgrade_cmd): Fixed opkg_upgrade to not choke
 	if asked to upgrade an un-installed package.
-	(ipkg_upgrade_pkg): Fixed printing of version numbers.
+	(opkg_upgrade_pkg): Fixed printing of version numbers.
 
 	* file_util.c (file_mkdir_hier): Abstracted call to libbb
 	make_directory into new file_mkdir_hier. At this point, the only
@@ -1420,12 +1420,12 @@
 
 2002-03-04  Carl Worth  <cworth at east.isi.edu>
 
-	* ipkg_conf.c (ipkg_conf_init): Added support to ipkg_conf to
+	* opkg_conf.c (opkg_conf_init): Added support to opkg_conf to
 	pickup command-line arguments for "force-defaults" and
 	"force-depends". Things set on the command-line should take
 	precedence over things found in the configuration file.
 
-	* ipkg_cmd.c (ipkg_search_cmd): Fixed formatting of "ipkg search"
+	* opkg_cmd.c (opkg_search_cmd): Fixed formatting of "opkg search"
 	output.
 
 	* pkg_depends.c (pkg_hash_fetch_unsatisfied_dependencies):
@@ -1434,37 +1434,37 @@
 	* xregex.c (xregexec): Removed useless error messages from NOMATCH
 	calls to regexec.
 
-	* ipkg_install.c (satisfy_dependencies_for): Added support for new
+	* opkg_install.c (satisfy_dependencies_for): Added support for new
 	"unresolved" argument in
 	pkg_hash_fetch_unsatisfied_dependencies. Cleaned up warning/error
 	messages.
 
-	* ipkg_cmd.c (ipkg_search_cmd): Implemented first-cut of "ipkg search".
+	* opkg_cmd.c (opkg_search_cmd): Implemented first-cut of "opkg search".
 
 	* pkg_depends.c (pkg_hash_fetch_unsatisfied_dependencies): Fixed
 	to set *unresolved to NULL if depends is NULL.
 
 2002-03-01  Carl Worth  <cworth at east.isi.edu>
 
-	* RELEASED ipkg-unstable 0.98.0
+	* RELEASED opkg-unstable 0.98.0
 
-	* ipkg_configure.c (ipkg_configure): Added flushing of stdout,
+	* opkg_configure.c (opkg_configure): Added flushing of stdout,
 	(here and in a few other modules).
 
 	* file_util.c (file_copy): Implemented this function here as one
 	step toward isolating the calls into libbb functions. Updated old
-	copy_file calls to file_copy in both ipkg_download.c and
-	ipkg_install.c.
+	copy_file calls to file_copy in both opkg_download.c and
+	opkg_install.c.
 
-	* ipkg_install.c, ipkg_remove.c: Demoted several "XXX" comments to
+	* opkg_install.c, opkg_remove.c: Demoted several "XXX" comments to
 	DPKG_INCOMPATIBILITY as I really don't intend on addressing them
 	any time soon, (if ever).
 
-	* ipkg_cmd.c (ipkg_files_cmd): Fixed "ipkg files" from crashing on
+	* opkg_cmd.c (opkg_files_cmd): Fixed "opkg files" from crashing on
 	uninstalled packages.
 
 	* familiar/rules: Added support for easy building of an
-	ipkg.ipk. The version number and the architecture are
+	opkg.ipk. The version number and the architecture are
 	automatically sucked in correctly from autoconf magic, (even when
 	cross-compiling). Maybe autoconf will start paying off with
 	benefits rather than pain, (finally!).
@@ -1472,28 +1472,28 @@
 	* configure.ac: Removed MEMCMP and STAT checks which were breaking
 	cross-compilation.
 
-	* ipkg_cmd.c (ipkg_upgrade_pkg): BIG bugfix: Package version
+	* opkg_cmd.c (opkg_upgrade_pkg): BIG bugfix: Package version
 	comparison was sign-reversed, (hence it would never upgrade).
 
 2002-02-28  Carl Worth  <cworth at east.isi.edu>
 
-	* ipkg_download.c (ipkg_download): Changed from
+	* opkg_download.c (opkg_download): Changed from
 	system("/bin/cp",...) to copy_file(...)
 
 	* replace/strndup.c: Implemented an (untested) replacement for
 	strndup.
 
 	* configure.ac: Added AC_CANONICAL_HOST to automatically set the
-	correct architecture type in the ipkg control file.
+	correct architecture type in the opkg control file.
 
 	* configure.ac: Changed version number to 0.98.0 in preparation
 	for alpha release.
 
-	* familiar/rules: Added support for easy building of an ipkg.ipk.
+	* familiar/rules: Added support for easy building of an opkg.ipk.
 
 2002-02-27  Carl Worth  <cworth at east.isi.edu>
 
-	* ipkg_install.c (ipkg_install_pkg): Fixed to abort on failed
+	* opkg_install.c (opkg_install_pkg): Fixed to abort on failed
 	download.
 
 	* pkg.c (pkg_run_script): Fixed bug that was preventing any
@@ -1505,7 +1505,7 @@
 	schedule.
 
 	* pkg_parse.c (pkg_parse_raw): Added parsing of "MD5Sum" in
-	addition to "MD5sum" to accomodate bug in old ipkg.
+	addition to "MD5sum" to accomodate bug in old opkg.
 
 	* void_list.c (void_list_remove): Added new remove function, (also
 	adjusts a forward iterator). Required new list->pre_head member
@@ -1514,26 +1514,26 @@
 	* pkg.c (pkg_init): Changed pkg->conffiles to be of the new
 	conffile_list_t datatype.
 	(pkg_remove_installed_files_list): Pulled this function into
-	pkg.c, (from ipkg_remove.c), so the mallocs and frees would be in
+	pkg.c, (from opkg_remove.c), so the mallocs and frees would be in
 	the same C file.
 	(pkg_get_conffile): Added this convenience function.
 
-	* ipkg_remove.c: Fixed several bugs. ipkg_remove now actually
+	* opkg_remove.c: Fixed several bugs. opkg_remove now actually
 	works for simple packages!
 
-	* ipkg_install.c (ipkg_install_pkg): Don't re-install if a package
+	* opkg_install.c (opkg_install_pkg): Don't re-install if a package
 	is already installed.
-	(ipkg_install_pkg): Fixed major bug that all of ipkg_install's
+	(opkg_install_pkg): Fixed major bug that all of opkg_install's
 	work was always being unwound even when successful.
 
-	* ipkg_cmd.c (ipkg_files_cmd): Fixed to use
+	* opkg_cmd.c (opkg_files_cmd): Fixed to use
 	pkg_get_installed_files_list rather than a private implementation
 	that sifted through the file lists on disk.
 
 	* str_util.c (str_ends_with): Added this convenient function.
 	(str_chomp): Another convenience.
 
-	* ipkg_conf.c: Moved chomp to str_util.c (str_chomp), since
+	* opkg_conf.c: Moved chomp to str_util.c (str_chomp), since
 	someone else wanted it too.
 
 2002-02-26  Carl Worth  <cworth at east.isi.edu>
@@ -1555,42 +1555,42 @@
 	* pkg.c (pkg_run_script): Changed to return return value of
 	script.
 
-	* ipkg_remove.c: Fleshed out initial version of all ipkg_remove.c
+	* opkg_remove.c: Fleshed out initial version of all opkg_remove.c
 	functions.
 
-	* ipkg_configure.c (ipkg_configure): Added check on return value
+	* opkg_configure.c (opkg_configure): Added check on return value
 	of pkg_run script. Added comments about dpkg compliance.
 
-	* ipkg_cmd.c (ipkg_purge_cmd): Added ipkg_purge_cmd
+	* opkg_cmd.c (opkg_purge_cmd): Added opkg_purge_cmd
 
 2002-02-20  Carl Worth  <cworth at east.isi.edu>
 
 	* Added USC copyright statements, (and Compaq stubs as necessary)
 
-	* ipkg_install.c: At this point "ipkg install" on a simple
+	* opkg_install.c: At this point "opkg install" on a simple
 	package, (no scripts and no dependencies), works just fine. It
 	might even do some of the script and dependency handling correctly
-	too, but I haven't tested that yet. "ipkg install libc6" is a nice
+	too, but I haven't tested that yet. "opkg install libc6" is a nice
 	little test that should complete without any errors or
-	warnings. Follow that up with "ipkg status" to see that it worked.
+	warnings. Follow that up with "opkg status" to see that it worked.
 
 	* pkg.c (pkg_run_script): Added convenience method for running
 	package scripts.
 
-	* ipkg_install.c: Fixed several bugs:
+	* opkg_install.c: Fixed several bugs:
 	(unpack_pkg_control_files): control files now extract to the
 	correct temporary directory.
-	(ipkg_install_pkg): pkg->state_want is now properly set to SW_INSTALL
-	(ipkg_install_pkg): status file now gets written after installation
+	(opkg_install_pkg): pkg->state_want is now properly set to SW_INSTALL
+	(opkg_install_pkg): status file now gets written after installation
 	(cleanup_temporary_files): All temporary files are cleaned up.
 
-	* ipkg_configure.c (ipkg_configure): Fleshed out a very simple
-	ipkg_configure, (simply runs "postinst configure"). Maybe it will
+	* opkg_configure.c (opkg_configure): Fleshed out a very simple
+	opkg_configure, (simply runs "postinst configure"). Maybe it will
 	need to be smarter at some point. Moved unwritten conffiles stuff
-	back to ipkg_install.c.
+	back to opkg_install.c.
 
-	* ipkg_conf.c (ipkg_conf_write_status_files): Moved this function
-	from ipkg_utils to ipkg_conf since it needs access to the
+	* opkg_conf.c (opkg_conf_write_status_files): Moved this function
+	from opkg_utils to opkg_conf since it needs access to the
 	pkg_dest_list.
 
 	* pkg_vec.c (marry_two_packages): Added several missing fields,
@@ -1600,29 +1600,29 @@
 
 2002-02-19  Carl Worth  <cworth at east.isi.edu>
 
-	* ipkg_install.c: several little bug fixes. "ipkg install" will
+	* opkg_install.c: several little bug fixes. "opkg install" will
 	now actually install files from a package! There are still some
 	bugs, (eg. postinst scripts are not called -- probably other
 	things as well). But, it's coming together now.
 
 	* pkg_dest.c (pkg_dest_init): now creates all necessary directories
 
-	* ipkg_download.c (ipkg_download): Fixed misleading parameter name.
+	* opkg_download.c (opkg_download): Fixed misleading parameter name.
 
-	* ipkg_conf.c (ipkg_conf_deinit): Now cleans up tmd_dir on deinit
-	ipkg.c: now calls ipkg_conf_deinit before exiting.
-	(ipkg_conf_add_nv): Fixed to set default_dest when parsing first
-	dest in ipkg.conf
+	* opkg_conf.c (opkg_conf_deinit): Now cleans up tmd_dir on deinit
+	opkg.c: now calls opkg_conf_deinit before exiting.
+	(opkg_conf_add_nv): Fixed to set default_dest when parsing first
+	dest in opkg.conf
 
-	* ipkg_cmd.c (ipkg_list_cmd): Fixed ugly bug in ipkg_list that led
+	* opkg_cmd.c (opkg_list_cmd): Fixed ugly bug in opkg_list that led
 	to infinite loops, segfaults, string corruption, and other bizarre
 	behavior.
 
-	* Added many files as we are approaching the first functional ipkg
+	* Added many files as we are approaching the first functional opkg
 	implementation in C:
 	file_util.c: convenience for testing if file_exists, reading files, etc.
-	ipkg_configure.c: mostly just a stub so far
-	ipkg_download.c: convenient function to download a file
+	opkg_configure.c: mostly just a stub so far
+	opkg_download.c: convenient function to download a file
 	nv_pair.c: data structure to hold a name-value pair
 	nv_pair_list.c: data structure to hold a list of nv_pair_t
 	pkg_dest.c: data structure for everything a pkg destination wants
@@ -1636,36 +1636,36 @@
 	void_list.c: generic linked-list data structure and functions
 	xsystem.c: wrapper around system() with error checking
 
-	* ipkg_remove.c: Just added some stubs. Nothing really works at
+	* opkg_remove.c: Just added some stubs. Nothing really works at
 	all yet.
 
-	* ipkg_install.c: Large rework of ipkg_install. It's now close to
+	* opkg_install.c: Large rework of opkg_install. It's now close to
 	actually being usable, (but it's not quite there yet). Revamped to
 	match dpkg install order more closely, (with all the stubs in case
 	we ever want to call all the scripts that dpkg does). Also updated
 	to use a more recent deb_extract from libbb.
 
-	* ipkg_extract_test.c (main): Added support for a third arg, (the
+	* opkg_extract_test.c (main): Added support for a third arg, (the
 	filename to extract to the buffer).
 
-	* ipkg_conf.c (ipkg_conf_init): Added several fields to
-	ipkg_conf_t: pkg_src_list, pkg_dest_list ,
+	* opkg_conf.c (opkg_conf_init): Added several fields to
+	opkg_conf_t: pkg_src_list, pkg_dest_list ,
 	restrict_to_default_dest, default_dest, tmp_dir, lists_dir,
 	pending_dir, force_depends, and pkg_hash. There's still a bit of
-	tension between options stored in the config file, (ipkg_conf_t),
+	tension between options stored in the config file, (opkg_conf_t),
 	and command-line arguments, (args_t).
 
-	* ipkg_cmd.c: First version that is approaching usability. The
-	following commands are more-or-less in place: "ipkg update", "ipkg
-	list", "ipkg info", "ipkg status". While the rest are in various
+	* opkg_cmd.c: First version that is approaching usability. The
+	following commands are more-or-less in place: "opkg update", "opkg
+	list", "opkg info", "opkg status". While the rest are in various
 	states of being partiallyy written or written but untested.
-	(ipkg_upgrade_cmd): Added support for restricting to a dest.  Many
+	(opkg_upgrade_cmd): Added support for restricting to a dest.  Many
 	other changes, largely involving plugging into the pkg_hash for
 	real for the first time, and adding multiple dest support.
 
-	* ipkg.c: Added support for setting the dest on the command-line.
+	* opkg.c: Added support for setting the dest on the command-line.
 
-	* args.c: Added support for IPKG_CONF_DIR environment variable and
+	* args.c: Added support for OPKG_CONF_DIR environment variable and
 	-f, -conf, and -conf-file options.
 
 	* configure.ac: Added lots of little bits suggested by autoscan.
@@ -1729,13 +1729,13 @@
 	(pkg_hash_fetch_installed_by_name_dest): Added this function to
 	support pkg_dest
 
-	* ipkg_utils.h: Added GPL blurb
-	(IPKG_UTILS_H): Added multiple include protection
+	* opkg_utils.h: Added GPL blurb
+	(OPKG_UTILS_H): Added multiple include protection
 
-	* ipkg_utils.c:
+	* opkg_utils.c:
 	(read_raw_pkgs_from_file): broke read_raw_pkgs into
 	read_raw_pkgs_from_file and read_raw-pkgs_from_stream
-	(ipkg_write_status_file): Fixed return value
+	(opkg_write_status_file): Fixed return value
 	(print_pkg_status): Moved this function to pkg.c:pkg_print_status
 	(line_is_blank): Fixed const char handling
 
@@ -1750,12 +1750,12 @@
 
 2001-12-11  Carl Worth  <cworth at east.isi.edu>
 
-	* ipkg_conf.c: Now parses /etc/ipkg.conf, (and doesn't do anything
+	* opkg_conf.c: Now parses /etc/opkg.conf, (and doesn't do anything
 	with it).
 
-	* ipkg.c: Started work on ipkg main, (not much here yet).
+	* opkg.c: Started work on opkg main, (not much here yet).
 
-	* ipkg_cmd.h: Added a tiny thing to abstract top-level ipkg
+	* opkg_cmd.h: Added a tiny thing to abstract top-level opkg
 	commands, (not finished).
 
 	* Set up autoconf and friends

Modified: trunk/src/target/ipkg/INSTALL
===================================================================
--- trunk/src/target/ipkg/INSTALL	2008-01-18 11:05:46 UTC (rev 3878)
+++ trunk/src/target/ipkg/INSTALL	2008-01-18 11:28:48 UTC (rev 3879)
@@ -1,4 +1,4 @@
-ipkg uses autoconf and friends for configuration. The familiar steps of:
+opkg uses autoconf and friends for configuration. The familiar steps of:
 
 	./configure
 	make

Modified: trunk/src/target/ipkg/Makefile.am
===================================================================
--- trunk/src/target/ipkg/Makefile.am	2008-01-18 11:05:46 UTC (rev 3878)
+++ trunk/src/target/ipkg/Makefile.am	2008-01-18 11:28:48 UTC (rev 3879)
@@ -3,38 +3,38 @@
 
 HOST_CPU=@host_cpu@
 BUILD_CPU=@build_cpu@
-IPKGLIBDIR=@ipkglibdir@ 
-ALL_CFLAGS=-g -O -Wall -DHOST_CPU_STR=\"@host_cpu@\" -DBUILD_CPU=@build_cpu@ -DLIBDIR=\"@libdir@\" -DIPKGLIBDIR=\"@ipkglibdir@\" -DDATADIR=\"@datadir@\"
+OPKGLIBDIR=@opkglibdir@ 
+ALL_CFLAGS=-g -O -Wall -DHOST_CPU_STR=\"@host_cpu@\" -DBUILD_CPU=@build_cpu@ -DLIBDIR=\"@libdir@\" -DOPKGLIBDIR=\"@opkglibdir@\" -DDATADIR=\"@datadir@\"
 
-bin_PROGRAMS = ipkg-cl
+bin_PROGRAMS = opkg-cl
 
-lib_LTLIBRARIES = libipkg.la
+lib_LTLIBRARIES = libopkg.la
 
 bin_SCRIPTS = update-alternatives
 
-interceptdir = $(datadir)/ipkg/intercept
+interceptdir = $(datadir)/opkg/intercept
 intercept_DATA = intercept/ldconfig intercept/depmod intercept/update-modules
 
 install-data-hook:
-	chmod +x $(DESTDIR)$(datadir)/ipkg/intercept/*
+	chmod +x $(DESTDIR)$(datadir)/opkg/intercept/*
 
-# ipkg_LDADD = libbb/libbb.a replace/libreplace.a
+# opkg_LDADD = libbb/libbb.a replace/libreplace.a
 
-#ipkg_cl_LDADD = libipkg.la libbb/libbb.la replace/libreplace.a 
-ipkg_cl_LDADD = libipkg.la libbb/libbb.la 
+#opkg_cl_LDADD = libopkg.la libbb/libbb.la replace/libreplace.a 
+opkg_cl_LDADD = libopkg.la libbb/libbb.la 
 
-libipkg_includedir=$(includedir)/libipkg
+libopkg_includedir=$(includedir)/libopkg
 
-libipkg_include_HEADERS= \
+libopkg_include_HEADERS= \
 	args.h \
 	conffile.h \
 	conffile_list.h \
 	config.h \
 	hash_table.h \
 	includes.h \
-	ipkg_conf.h \
-	ipkg.h \
-	ipkg_message.h \
+	opkg_conf.h \
+	opkg.h \
+	opkg_message.h \
 	nv_pair.h \
 	nv_pair_list.h \
 	pkg_depends.h \
@@ -47,41 +47,41 @@
 	pkg_vec.h \
 	str_list.h \
 	void_list.h \
-	libipkg.h 
+	libopkg.h 
 
 #\ replace/replace.h
 
-#libipkg_la_LIBADD = libbb/libbb.la replace/libreplace.a
-libipkg_la_LIBADD = libbb/libbb.la $(CURL_LIBS)
+#libopkg_la_LIBADD = libbb/libbb.la replace/libreplace.a
+libopkg_la_LIBADD = libbb/libbb.la $(CURL_LIBS)
 
-ipkg_core_sources = args.c args.h ipkg.c \
+opkg_core_sources = args.c args.h opkg.c \
 		    user.c user.h 
-ipkg_libcore_sources = args.c args.h libipkg.c libipkg.h ipkg.h\
+opkg_libcore_sources = args.c args.h libopkg.c libopkg.h opkg.h\
 		    user.c user.h 
-ipkg_cmd_sources = ipkg_cmd.c ipkg_cmd.h \
-		   ipkg_configure.c ipkg_configure.h \
-		   ipkg_download.c ipkg_download.h \
-		   ipkg_install.c ipkg_install.h \
-		   ipkg_upgrade.c ipkg_upgrade.h \
-		   ipkg_remove.c ipkg_remove.h
-ipkg_db_sources = ipkg_conf.c ipkg_conf.h \
-		  ipkg_utils.c ipkg_utils.h pkg.c pkg.h hash_table.h \
+opkg_cmd_sources = opkg_cmd.c opkg_cmd.h \
+		   opkg_configure.c opkg_configure.h \
+		   opkg_download.c opkg_download.h \
+		   opkg_install.c opkg_install.h \
+		   opkg_upgrade.c opkg_upgrade.h \
+		   opkg_remove.c opkg_remove.h
+opkg_db_sources = opkg_conf.c opkg_conf.h \
+		  opkg_utils.c opkg_utils.h pkg.c pkg.h hash_table.h \
 		  pkg_depends.c pkg_depends.h pkg_extract.c pkg_extract.h \
 		  hash_table.c pkg_hash.c pkg_hash.h pkg_parse.c pkg_parse.h \
 		  pkg_vec.c pkg_vec.h
-ipkg_list_sources = conffile.c conffile.h conffile_list.c conffile_list.h \
+opkg_list_sources = conffile.c conffile.h conffile_list.c conffile_list.h \
 		    nv_pair.c nv_pair.h nv_pair_list.c nv_pair_list.h \
 		    pkg_dest.c pkg_dest.h pkg_dest_list.c pkg_dest_list.h \
 		    pkg_src.c pkg_src.h pkg_src_list.c pkg_src_list.h \
 		    str_list.c str_list.h void_list.c void_list.h
-ipkg_util_sources = file_util.c file_util.h ipkg_message.h ipkg_message.c md5.c md5.h \
+opkg_util_sources = file_util.c file_util.h opkg_message.h opkg_message.c md5.c md5.h \
 		    sprintf_alloc.c sprintf_alloc.h str_util.c str_util.h \
 		    xregex.c xregex.h xsystem.c xsystem.h
 
-# ipkg_SOURCES = $(ipkg_core_sources) $(ipkg_cmd_sources) $(ipkg_db_sources) \
-#	       $(ipkg_util_sources) $(ipkg_list_sources)
+# opkg_SOURCES = $(opkg_core_sources) $(opkg_cmd_sources) $(opkg_db_sources) \
+#	       $(opkg_util_sources) $(opkg_list_sources)
 
-EXTRA_DIST = ipkg.c update-alternatives $(intercept_DATA)
+EXTRA_DIST = opkg.c update-alternatives $(intercept_DATA)
 
 MAINTAINERCLEANFILES= \
 	configure \
@@ -92,26 +92,26 @@
 	.Makefile.am.swp \
 	aclocal.m4
 
-libipkg_la_SOURCES = $(ipkg_libcore_sources) $(ipkg_cmd_sources) $(ipkg_db_sources) \
-	       $(ipkg_util_sources) $(ipkg_list_sources)
+libopkg_la_SOURCES = $(opkg_libcore_sources) $(opkg_cmd_sources) $(opkg_db_sources) \
+	       $(opkg_util_sources) $(opkg_list_sources)
 
-ipkg_cl_SOURCES = ipkg-frontend.c
+opkg_cl_SOURCES = opkg-frontend.c
 
-libipkg_la_CFLAGS = -DIPKG_LIB $(ALL_CFLAGS)  $(CURL_CFLAGS)
+libopkg_la_CFLAGS = -DOPKG_LIB $(ALL_CFLAGS)  $(CURL_CFLAGS)
 
-ipkg_CFLAGS = $(ALL_CFLAGS) $(CURL_CFLAGS)
+opkg_CFLAGS = $(ALL_CFLAGS) $(CURL_CFLAGS)
 
-ipkg_cl_CFLAGS = -DIPKG_LIB $(ALL_CFLAGS)
+opkg_cl_CFLAGS = -DOPKG_LIB $(ALL_CFLAGS)
 
-noinst_PROGRAMS = ipkg_hash_test ipkg_extract_test
+noinst_PROGRAMS = opkg_hash_test opkg_extract_test
 
-ipkg_hash_test_LDADD = libbb/libbb.la
-ipkg_hash_test_SOURCES = ipkg_hash_test.c $(ipkg_db_sources) $(ipkg_util_sources) $(ipkg_list_sources)
-ipkg_hash_test_CFLAGS = $(ALL_CFLAGS)
+opkg_hash_test_LDADD = libbb/libbb.la
+opkg_hash_test_SOURCES = opkg_hash_test.c $(opkg_db_sources) $(opkg_util_sources) $(opkg_list_sources)
+opkg_hash_test_CFLAGS = $(ALL_CFLAGS)
 
-ipkg_extract_test_LDADD = libbb/libbb.la
-ipkg_extract_test_SOURCES = ipkg_extract_test.c $(ipkg_db_sources) $(ipkg_util_sources) $(ipkg_list_sources)
-ipkg_extract_test_CFLAGS = $(ALL_CFLAGS)
+opkg_extract_test_LDADD = libbb/libbb.la
+opkg_extract_test_SOURCES = opkg_extract_test.c $(opkg_db_sources) $(opkg_util_sources) $(opkg_list_sources)
+opkg_extract_test_CFLAGS = $(ALL_CFLAGS)
 
 package: all-recursive
 	STRIPPROG=$(STRIP) familiar/rules INSTALL=$$PWD/install-sh  binary-arch

Modified: trunk/src/target/ipkg/README
===================================================================
--- trunk/src/target/ipkg/README	2008-01-18 11:05:46 UTC (rev 3878)
+++ trunk/src/target/ipkg/README	2008-01-18 11:28:48 UTC (rev 3879)
@@ -1,3 +0,0 @@
-ipkg - The Itsy Package Management System
-
-See http://www.handhelds.org/moin/moin.cgi/Ipkg for more details about ipkg.

Modified: trunk/src/target/ipkg/TODO
===================================================================
--- trunk/src/target/ipkg/TODO	2008-01-18 11:05:46 UTC (rev 3878)
+++ trunk/src/target/ipkg/TODO	2008-01-18 11:28:48 UTC (rev 3879)
@@ -1,12 +1,12 @@
 
-Things to do for ipkg, in a partial order:
+Things to do for opkg, in a partial order:
 
 0) Play with configure to check for strdup/strndup ( to works with replace/replace.h stuffs )
 
-1) Fix incompatibilities between current C-based ipkg and original
-sh-based ipkg.
+1) Fix incompatibilities between current C-based opkg and original
+sh-based opkg.
 
-1.a) Fix ipkg.conf options for http_proxy and friends. DONE:
+1.a) Fix opkg.conf options for http_proxy and friends. DONE:
      http_proxy tested, (ftp_proxy, no_proxy, proxy_user, and
      proxy_passwd have not been tested).
 
@@ -18,7 +18,7 @@
 
 1.e) Fix offline_root mode. DONE: tested.
 
-2) Release ipkg as ipkg, (no longer as ipkg-unstable). This depends on
+2) Release opkg as opkg, (no longer as opkg-unstable). This depends on
    all of (1) being DONE. Although I might let this release proceed
    without offline_root --- only Jamey will complain. ;-)
 
@@ -26,7 +26,7 @@
 
 3.a) fix all code marked "XXX: BUG"
 
-3.b) fix all outstanding ipkg bugzilla bugs
+3.b) fix all outstanding opkg bugzilla bugs
 
 3.c) conffiles support seems broken again. It's prompting on just
      about every file. It might be because of file names beginning
@@ -47,34 +47,34 @@
 
 3.g) Audit all dpkg package fields for both parsing and printing support.
 
-3.h) "ipkg status" and "ipkg info" need to complain about unknown
+3.h) "opkg status" and "opkg info" need to complain about unknown
   packages. For that matter, these two commands should probably just
   become aliases to the same functionality.
 
-  Jamey thinks ipkg status should be brief give one line per package, while
-  ipkg info can continue to be verbose. 7/23/2002.
+  Jamey thinks opkg status should be brief give one line per package, while
+  opkg info can continue to be verbose. 7/23/2002.
 
-3.i) Currently "ipkg install foo" will upgrade foo if possible. The
+3.i) Currently "opkg install foo" will upgrade foo if possible. The
   "Package foo is already installed" check needs to be moved up to
   avoid this.
 
-  Jamey thinkgs that "ipkg install foo" should upgrade foo.  7/23/2002.
+  Jamey thinkgs that "opkg install foo" should upgrade foo.  7/23/2002.
 
 4) Implement new features
 
 4.a) start with all "XXX: FEATURE" comments
 
-4.b) implement all accepted ipkg bugzilla feature requests, (also
-     check old post "Subject: Reinventing ipkg" to see if we forgot
+4.b) implement all accepted opkg bugzilla feature requests, (also
+     check old post "Subject: Reinventing opkg" to see if we forgot
      any of the good ideas we had once upon a time)
 
-4.c) ipkg remove needs to (prompt first) then remove packages for
+4.c) opkg remove needs to (prompt first) then remove packages for
      which the dependencies will no longer be met. DONE. 7/19/2002.
 
 4.d) Add support for:
-	ipkg install foo from some-feed
-	ipkg install foo-0.4.3
-	ipkg install foo-latest # Only needed if we add a feed-order-priority option
+	opkg install foo from some-feed
+	opkg install foo-0.4.3
+	opkg install foo-latest # Only needed if we add a feed-order-priority option
      or something like that.
 
 4.e) Orphaned dependency management (what is this -Jamey 7/23/2002)
@@ -89,7 +89,7 @@
      eliminate some library calls, (glob, regcomp)? Can we get
      something like uclibc to work well?
 
-4.h) Add support for a deb-src in /etc/ipkg.conf. (ARGH! Name clash
+4.h) Add support for a deb-src in /etc/opkg.conf. (ARGH! Name clash
      alert! In apt-land, deb-src means something very different than
      what I would mean here. Hrm... Maybe src-deb would be cleaner? )
 
@@ -98,10 +98,10 @@
 4.i) Figure out a clever chroot mechanism for running maintainer scripts in
      offline_root mode.
 
-4.j) Implement ipkg history mechanism, with undo and redo?  Keep track of
-     packages removed/installed by each call to ipkg.
+4.j) Implement opkg history mechanism, with undo and redo?  Keep track of
+     packages removed/installed by each call to opkg.
 
-5) release ipkg-1.0.0
+5) release opkg-1.0.0
 
 6) Cleanup the code
 

Modified: trunk/src/target/ipkg/args.c
===================================================================
--- trunk/src/target/ipkg/args.c	2008-01-18 11:05:46 UTC (rev 3878)
+++ trunk/src/target/ipkg/args.c	2008-01-18 11:28:48 UTC (rev 3879)
@@ -20,7 +20,7 @@
 #include <string.h>
 #include <unistd.h>
 
-#include "ipkg.h"
+#include "opkg.h"
 
 #include "config.h"
 #include "args.h"
@@ -53,7 +53,7 @@
 
      args->dest = ARGS_DEFAULT_DEST;
 
-     conf_file_dir = getenv("IPKG_CONF_DIR");
+     conf_file_dir = getenv("OPKG_CONF_DIR");
      if (conf_file_dir == NULL || conf_file_dir[0] == '\0') {
 	  conf_file_dir = ARGS_DEFAULT_CONF_FILE_DIR;
      }
@@ -226,10 +226,10 @@
 void args_usage(char *complaint)
 {
      if (complaint) {
-	  fprintf(stderr, "ipkg: %s\n", complaint);
+	  fprintf(stderr, "opkg: %s\n", complaint);
      }
      print_version();
-     fprintf(stderr, "usage: ipkg [options...] sub-command [arguments...]\n");
+     fprintf(stderr, "usage: opkg [options...] sub-command [arguments...]\n");
      fprintf(stderr, "where sub-command is one of:\n");
     
      fprintf(stderr, "\nPackage Manipulation:\n");
@@ -247,7 +247,7 @@
      fprintf(stderr, "\tlist_installed		List all and only the installed packages and description \n");
      fprintf(stderr, "\tfiles <pkg>		List all files belonging to <pkg>\n");
      fprintf(stderr, "\tsearch <file|regexp>		Search for a package providing <file>\n");
-#ifndef IPKG_LIB
+#ifndef OPKG_LIB
      fprintf(stderr, "\tinfo [pkg|regexp [<field>]]	Display all/some info fields for <pkg> or all\n");
      fprintf(stderr, "\tstatus [pkg|regexp [<field>]]	Display all/some status fields for <pkg> or all\n");
 #else
@@ -273,7 +273,7 @@
      fprintf(stderr, "\t                         1 normal messages (default)\n");
      fprintf(stderr, "\t                         2 informative messages\n");
      fprintf(stderr, "\t                         3 debug output\n");
-     fprintf(stderr, "\t-f <conf_file>		Use <conf_file> as the ipkg configuration file\n");
+     fprintf(stderr, "\t-f <conf_file>		Use <conf_file> as the opkg configuration file\n");
      fprintf(stderr, "\t-conf <conf_file>	Default configuration file location\n");
      fprintf(stderr, "				is %s/%s\n", ARGS_DEFAULT_CONF_FILE_DIR, ARGS_DEFAULT_CONF_FILE_NAME);
      fprintf(stderr, "\t-d <dest_name>		Use <dest_name> as the the root directory for\n");
@@ -285,27 +285,27 @@
      fprintf(stderr, "\t-offline <offline_root>	offline installation of packages.\n");
      fprintf(stderr, "\t-verbose_wget		more wget messages\n");
     
-     fprintf(stderr, "\tForce Options (use when ipkg is too smart for its own good):\n");
+     fprintf(stderr, "\tForce Options (use when opkg is too smart for its own good):\n");
      fprintf(stderr, "\t-force-depends		Make dependency checks warnings instead of errors\n");
      fprintf(stderr, "\t				Install/remove package in spite of failed dependences\n");
-     fprintf(stderr, "\t-force-defaults		Use default options for questions asked by ipkg.\n");
+     fprintf(stderr, "\t-force-defaults		Use default options for questions asked by opkg.\n");
      fprintf(stderr, "				(no prompts). Note that this will not prevent\n");
      fprintf(stderr, "				package installation scripts from prompting.\n");
-     fprintf(stderr, "\t-force-reinstall 	Allow ipkg to reinstall a package.\n");
-     fprintf(stderr, "\t-force-overwrite 	Allow ipkg to overwrite files from another package during an install.\n");
-     fprintf(stderr, "\t-force-downgrade 	Allow ipkg to downgrade packages.\n");
+     fprintf(stderr, "\t-force-reinstall 	Allow opkg to reinstall a package.\n");
+     fprintf(stderr, "\t-force-overwrite 	Allow opkg to overwrite files from another package during an install.\n");
+     fprintf(stderr, "\t-force-downgrade 	Allow opkg to downgrade packages.\n");
      fprintf(stderr, "\t-force_space            Install even if there does not seem to be enough space.\n");
      fprintf(stderr, "\t-noaction               No action -- test only\n");
      fprintf(stderr, "\t-nodeps                 Do not follow dependences\n");
      fprintf(stderr, "\t-force-removal-of-dependent-packages\n");
-     fprintf(stderr, "\t-recursive	 	Allow ipkg to remove package and all that depend on it.\n");
+     fprintf(stderr, "\t-recursive	 	Allow opkg to remove package and all that depend on it.\n");
      fprintf(stderr, "\t-test                   No action -- test only\n");
      fprintf(stderr, "\t-t	 	        Specify tmp-dir.\n");
      fprintf(stderr, "\t--tmp-dir 	        Specify tmp-dir.\n");
      fprintf(stderr, "\n");
      fprintf(stderr, "\tregexp could be something like 'pkgname*' '*file*' or similar\n");
-     fprintf(stderr, "\teg: ipkg info 'libstd*'  or ipkg search '*libop*' or ipkg remove 'libncur*'\n");
-     /* -force-removal-of-essential-packages	Let ipkg remove essential packages. 
+     fprintf(stderr, "\teg: opkg info 'libstd*'  or opkg search '*libop*' or opkg remove 'libncur*'\n");
+     /* -force-removal-of-essential-packages	Let opkg remove essential packages. 
 	Using this option is almost guaranteed to break your system, hence this option
 	is not even advertised in the usage statement. */
      exit(1);
@@ -313,5 +313,5 @@
 
 static void print_version(void)
 {
-     fprintf(stderr, "ipkg version %s\n", VERSION);
+     fprintf(stderr, "opkg version %s\n", VERSION);
 }

Modified: trunk/src/target/ipkg/args.h
===================================================================
--- trunk/src/target/ipkg/args.h	2008-01-18 11:05:46 UTC (rev 3878)
+++ trunk/src/target/ipkg/args.h	2008-01-18 11:28:48 UTC (rev 3879)
@@ -46,7 +46,7 @@
 typedef struct args args_t;
 
 #define ARGS_DEFAULT_CONF_FILE_DIR "/etc"
-#define ARGS_DEFAULT_CONF_FILE_NAME "ipkg.conf"
+#define ARGS_DEFAULT_CONF_FILE_NAME "opkg.conf"
 #define ARGS_DEFAULT_DEST NULL
 #define ARGS_DEFAULT_FORCE_DEFAULTS 0
 #define ARGS_DEFAULT_FORCE_DEPENDS 0

Modified: trunk/src/target/ipkg/conffile.c
===================================================================
--- trunk/src/target/ipkg/conffile.c	2008-01-18 11:05:46 UTC (rev 3878)
+++ trunk/src/target/ipkg/conffile.c	2008-01-18 11:28:48 UTC (rev 3879)
@@ -18,8 +18,8 @@
 #include <string.h>
 #include <stdlib.h>
 
-#include "ipkg.h"
-#include "ipkg_message.h"
+#include "opkg.h"
+#include "opkg_message.h"
 
 #include "conffile.h"
 #include "file_util.h"
@@ -35,7 +35,7 @@
     nv_pair_deinit(conffile);
 }
 
-int conffile_has_been_modified(ipkg_conf_t *conf, conffile_t *conffile)
+int conffile_has_been_modified(opkg_conf_t *conf, conffile_t *conffile)
 {
     char *md5sum;
     char *filename = conffile->name;
@@ -43,7 +43,7 @@
     int ret;
 
     if (conffile->value == NULL) {
-	 ipkg_message(conf, IPKG_NOTICE, "%s: conffile %s has no md5sum\n", __FUNCTION__, conffile->name);
+	 opkg_message(conf, OPKG_NOTICE, "%s: conffile %s has no md5sum\n", __FUNCTION__, conffile->name);
 	 return 1;
     }
 
@@ -53,7 +53,7 @@
 
     ret = strcmp(md5sum, conffile->value);
     if (ret) {
-      ipkg_message(conf, IPKG_NOTICE, "%s: conffile %s: \t\nold md5=%s \t\nnew md5=%s\n", __FUNCTION__,
+      opkg_message(conf, OPKG_NOTICE, "%s: conffile %s: \t\nold md5=%s \t\nnew md5=%s\n", __FUNCTION__,
               conffile->name, md5sum, conffile->value);
     }
 

Modified: trunk/src/target/ipkg/conffile.h
===================================================================
--- trunk/src/target/ipkg/conffile.h	2008-01-18 11:05:46 UTC (rev 3878)
+++ trunk/src/target/ipkg/conffile.h	2008-01-18 11:28:48 UTC (rev 3879)
@@ -24,7 +24,7 @@
 
 int conffile_init(conffile_t *conffile, const char *file_name, const char *md5sum);
 void conffile_deinit(conffile_t *conffile);
-int conffile_has_been_modified(struct ipkg_conf *conf, conffile_t *conffile);
+int conffile_has_been_modified(struct opkg_conf *conf, conffile_t *conffile);
 
 #endif
 

Modified: trunk/src/target/ipkg/conffile_list.c
===================================================================
--- trunk/src/target/ipkg/conffile_list.c	2008-01-18 11:05:46 UTC (rev 3878)
+++ trunk/src/target/ipkg/conffile_list.c	2008-01-18 11:28:48 UTC (rev 3879)
@@ -15,7 +15,7 @@
    General Public License for more details.
 */
 
-#include "ipkg.h"
+#include "opkg.h"
 
 #include "conffile_list.h"
 

Modified: trunk/src/target/ipkg/configure.ac
===================================================================
--- trunk/src/target/ipkg/configure.ac	2008-01-18 11:05:46 UTC (rev 3878)
+++ trunk/src/target/ipkg/configure.ac	2008-01-18 11:28:48 UTC (rev 3879)
@@ -1,6 +1,6 @@
 # Process this file with autoconf to produce a configure script
-AC_INIT(ipkg.c)
-AM_INIT_AUTOMAKE([ipkg], [0.99.163])
+AC_INIT(opkg.c)
+AM_INIT_AUTOMAKE([opkg], [0.99.163])
 AM_CONFIG_HEADER(config.h)
 
 AC_CANONICAL_HOST
@@ -19,7 +19,7 @@
 AM_PROG_INSTALL_STRIP
 AC_PROG_LIBTOOL
 
-# Checks for libraries (hah! ipkg is pretty much self-contained)
+# Checks for libraries (hah! opkg is pretty much self-contained)
 PKG_CHECK_MODULES(CURL, libcurl)
 
 # Checks for header files
@@ -51,23 +51,23 @@
 AC_FUNC_VPRINTF
 AC_CHECK_FUNCS([memmove memset mkdir regcomp strchr strcspn strdup strerror strndup strrchr strstr strtol strtoul sysinfo utime])
 
-ipkglibdir=
-AC_ARG_WITH(ipkglibdir,
-[  --with-ipkglibdir=DIR   specifies directory to put status and info files.
-                          "/ipkg" is always added so if you want your files 
-                          to be in /usr/lib/ipkg you should indicate 
-                          --with-ipkglibdir=/usr/lib ],
+opkglibdir=
+AC_ARG_WITH(opkglibdir,
+[  --with-opkglibdir=DIR   specifies directory to put status and info files.
+                          "/opkg" is always added so if you want your files 
+                          to be in /usr/lib/opkg you should indicate 
+                          --with-opkglibdir=/usr/lib ],
 [case "${withval}" in
-yes)    AC_MSG_ERROR(bad value ${withval} given for ipkg libs directories ) ;;
+yes)    AC_MSG_ERROR(bad value ${withval} given for opkg libs directories ) ;;
 no)     ;;
-*)      ipkglibdir=$with_ipkglibdir ;;
+*)      opkglibdir=$with_opkglibdir ;;
 esac])
 
 # Default local prefix if it is empty
-if test x$ipkglibdir = x; then
-        ipkglibdir=/usr/lib
+if test x$opkglibdir = x; then
+        opkglibdir=/usr/lib
 fi
 
-AC_SUBST(ipkglibdir)
+AC_SUBST(opkglibdir)
 
-AC_OUTPUT(Makefile etc/Makefile familiar/Makefile familiar/control familiar/control-unstripped familiar/libipkg-control  familiar/libipkg-dev-control libbb/Makefile libipkg.pc ipkg.h)
+AC_OUTPUT(Makefile etc/Makefile familiar/Makefile familiar/control familiar/control-unstripped familiar/libopkg-control  familiar/libopkg-dev-control libbb/Makefile libopkg.pc opkg.h)

Modified: trunk/src/target/ipkg/familiar/control-unstripped.in
===================================================================
--- trunk/src/target/ipkg/familiar/control-unstripped.in	2008-01-18 11:05:46 UTC (rev 3878)
+++ trunk/src/target/ipkg/familiar/control-unstripped.in	2008-01-18 11:28:48 UTC (rev 3879)
@@ -1,22 +1,22 @@
-Package: ipkg-unstripped
-Replaces: ipkg
+Package: opkg-unstripped
+Replaces: opkg
 Version: @VERSION@
 Section: base
 Priority: required
 Essential: yes
 Architecture: @host_cpu@
 Maintainer: Jamey Hicks <jamey at handhelds.org>
-Source: http://www.handhelds.org/packages/ipkg/ipkg-@VERSION@.tar.gz
+Source: http://www.handhelds.org/packages/opkg/opkg-@VERSION@.tar.gz
 Depends: libc6, busybox 
 Description: lightweight package management system
- ipkg is the Itsy Package Management System, for handling
+ opkg is the Itsy Package Management System, for handling
  installation and removal of packages on a system. It can
  recursively follow dependencies and download all packages
  necessary to install a particular package.
  .
- ipkg knows how to install both .ipk and .deb packages.
+ opkg knows how to install both .ipk and .deb packages.
  .
- ipkg is intended to serve the same functions (and more) for
+ opkg is intended to serve the same functions (and more) for
  Familiar that dpkg and apt serve for Debian, (while taking
  up much less space).
 

Modified: trunk/src/target/ipkg/familiar/control.in
===================================================================
--- trunk/src/target/ipkg/familiar/control.in	2008-01-18 11:05:46 UTC (rev 3878)
+++ trunk/src/target/ipkg/familiar/control.in	2008-01-18 11:28:48 UTC (rev 3879)
@@ -1,21 +1,21 @@
-Package: ipkg
+Package: opkg
 Version: @VERSION@
 Section: base
 Priority: required
 Essential: yes
 Architecture: @host_cpu@
 Maintainer: Pierluigi Frullani <pigi at frumar.it>
-Source: http://www.handhelds.org/packages/ipkg/ipkg-@VERSION@.tar.gz
-Depends: libc6, libipkg (>= @VERSION@)
+Source: http://www.handhelds.org/packages/opkg/opkg-@VERSION@.tar.gz
+Depends: libc6, libopkg (>= @VERSION@)
 Description: lightweight package management system
- ipkg is the Itsy Package Management System, for handling
+ opkg is the Itsy Package Management System, for handling
  installation and removal of packages on a system. It can
  recursively follow dependencies and download all packages
  necessary to install a particular package.
  .
- ipkg knows how to install both .ipk and .deb packages.
+ opkg knows how to install both .ipk and .deb packages.
  .
- ipkg is intended to serve the same functions (and more) for
+ opkg is intended to serve the same functions (and more) for
  Familiar that dpkg and apt serve for Debian, (while taking
  up much less space).
 

Deleted: trunk/src/target/ipkg/familiar/libipkg-control.in
===================================================================
--- trunk/src/target/ipkg/familiar/libipkg-control.in	2008-01-18 11:05:46 UTC (rev 3878)
+++ trunk/src/target/ipkg/familiar/libipkg-control.in	2008-01-18 11:28:48 UTC (rev 3879)
@@ -1,21 +0,0 @@
-Package: libipkg
-Version: @VERSION@
-Section: base
-Priority: optional
-Essential: yes
-Architecture: @host_cpu@
-Maintainer: Jamey Hicks <jamey at handhelds.org>
-Source: http://www.handhelds.org/packages/ipkg/ipkg-@VERSION@.tar.gz
-Depends: libc6, busybox
-Description: lightweight package management system
- ipkg is the Itsy Package Management System, for handling
- installation and removal of packages on a system. It can
- recursively follow dependencies and download all packages
- necessary to install a particular package.
- .
- ipkg knows how to install both .ipk and .deb packages.
- .
- ipkg is intended to serve the same functions (and more) for
- Familiar that dpkg and apt serve for Debian, (while taking
- up much less space).
-

Deleted: trunk/src/target/ipkg/familiar/libipkg-dev-control.in
===================================================================
--- trunk/src/target/ipkg/familiar/libipkg-dev-control.in	2008-01-18 11:05:46 UTC (rev 3878)
+++ trunk/src/target/ipkg/familiar/libipkg-dev-control.in	2008-01-18 11:28:48 UTC (rev 3879)
@@ -1,21 +0,0 @@
-Package: libipkg-dev
-Version: @VERSION@
-Section: base
-Priority: optional
-Essential: yes
-Architecture: @host_cpu@
-Maintainer: Jamey Hicks <jamey at handhelds.org>
-Source: http://www.handhelds.org/packages/ipkg/ipkg-@VERSION@.tar.gz
-Depends: libipkg
-Description: lightweight package management system
- ipkg is the Itsy Package Management System, for handling
- installation and removal of packages on a system. It can
- recursively follow dependencies and download all packages
- necessary to install a particular package.
- .
- ipkg knows how to install both .ipk and .deb packages.
- .
- ipkg is intended to serve the same functions (and more) for
- Familiar that dpkg and apt serve for Debian, (while taking
- up much less space).
-

Copied: trunk/src/target/ipkg/familiar/libopkg-control.in (from rev 3877, trunk/src/target/ipkg/familiar/libipkg-control.in)
===================================================================
--- trunk/src/target/ipkg/familiar/libipkg-control.in	2008-01-18 10:03:14 UTC (rev 3877)
+++ trunk/src/target/ipkg/familiar/libopkg-control.in	2008-01-18 11:28:48 UTC (rev 3879)
@@ -0,0 +1,21 @@
+Package: libopkg
+Version: @VERSION@
+Section: base
+Priority: optional
+Essential: yes
+Architecture: @host_cpu@
+Maintainer: Jamey Hicks <jamey at handhelds.org>
+Source: http://www.handhelds.org/packages/opkg/opkg-@VERSION@.tar.gz
+Depends: libc6, busybox
+Description: lightweight package management system
+ opkg is the Itsy Package Management System, for handling
+ installation and removal of packages on a system. It can
+ recursively follow dependencies and download all packages
+ necessary to install a particular package.
+ .
+ opkg knows how to install both .ipk and .deb packages.
+ .
+ opkg is intended to serve the same functions (and more) for
+ Familiar that dpkg and apt serve for Debian, (while taking
+ up much less space).
+

Copied: trunk/src/target/ipkg/familiar/libopkg-dev-control.in (from rev 3877, trunk/src/target/ipkg/familiar/libipkg-dev-control.in)
===================================================================
--- trunk/src/target/ipkg/familiar/libipkg-dev-control.in	2008-01-18 10:03:14 UTC (rev 3877)
+++ trunk/src/target/ipkg/familiar/libopkg-dev-control.in	2008-01-18 11:28:48 UTC (rev 3879)
@@ -0,0 +1,21 @@
+Package: libopkg-dev
+Version: @VERSION@
+Section: base
+Priority: optional
+Essential: yes
+Architecture: @host_cpu@
+Maintainer: Jamey Hicks <jamey at handhelds.org>
+Source: http://www.handhelds.org/packages/opkg/opkg-@VERSION@.tar.gz
+Depends: libopkg
+Description: lightweight package management system
+ opkg is the Itsy Package Management System, for handling
+ installation and removal of packages on a system. It can
+ recursively follow dependencies and download all packages
+ necessary to install a particular package.
+ .
+ opkg knows how to install both .ipk and .deb packages.
+ .
+ opkg is intended to serve the same functions (and more) for
+ Familiar that dpkg and apt serve for Debian, (while taking
+ up much less space).
+

Modified: trunk/src/target/ipkg/file_util.c
===================================================================
--- trunk/src/target/ipkg/file_util.c	2008-01-18 11:05:46 UTC (rev 3878)
+++ trunk/src/target/ipkg/file_util.c	2008-01-18 11:28:48 UTC (rev 3879)
@@ -15,7 +15,7 @@
    General Public License for more details.
 */
 
-#include "ipkg.h"
+#include "opkg.h"
 #include <sys/types.h>
 #include <sys/stat.h>
 
@@ -107,7 +107,7 @@
 }
 
 /* I put these here to keep libbb dependencies from creeping all over
-   the ipkg code */
+   the opkg code */
 int file_copy(const char *src, const char *dest)
 {
     int err;

Modified: trunk/src/target/ipkg/hash_table.c
===================================================================
--- trunk/src/target/ipkg/hash_table.c	2008-01-18 11:05:46 UTC (rev 3878)
+++ trunk/src/target/ipkg/hash_table.c	2008-01-18 11:28:48 UTC (rev 3879)
@@ -1,4 +1,4 @@
-/* hash.c - hash tables for ipkg
+/* hash.c - hash tables for opkg
 
    Steven M. Ayer, Jamey Hicks
    
@@ -20,7 +20,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include "hash_table.h"
-#include "ipkg_message.h"
+#include "opkg_message.h"
 
 
 static int hash_index(hash_table_t *hash, const char *pkg_name);
@@ -92,7 +92,7 @@
     if (hash_entry->key) 
     {
       if (strcmp(key, hash_entry->key) == 0) {
-         // ipkg_message(NULL, IPKG_DEBUG, "Function: %s. Key found for '%s' \n", __FUNCTION__, key);
+         // opkg_message(NULL, OPKG_DEBUG, "Function: %s. Key found for '%s' \n", __FUNCTION__, key);
 	 return hash_entry->data;
       }
     }
@@ -105,11 +105,11 @@
 {
      int ndx= hash_index(hash, key);
      hash_entry_t *hash_entry = hash->entries + ndx;
-     if (0) ipkg_message(NULL, IPKG_DEBUG2, "Function: %s. Inserting in hash for '%s' \n", __FUNCTION__, key);
+     if (0) opkg_message(NULL, OPKG_DEBUG2, "Function: %s. Inserting in hash for '%s' \n", __FUNCTION__, key);
      if (hash_entry->key) {
 	  if (strcmp(hash_entry->key, key) == 0) {
 	       /* alread in table, update the value */
-               if (0) ipkg_message(NULL, IPKG_DEBUG2, "Function: %s. Value already in hash for '%s' \n", __FUNCTION__, key);
+               if (0) opkg_message(NULL, OPKG_DEBUG2, "Function: %s. Value already in hash for '%s' \n", __FUNCTION__, key);
 	       hash_entry->data = value;
 	       return 0;
 	  } else {
@@ -118,7 +118,7 @@
 		* then add a new entry
 		* before we can hook up the value
 		*/
-               if (0) ipkg_message(NULL, IPKG_DEBUG2, "Function: %s. Value already in hash by collision for '%s' \n", __FUNCTION__, key);
+               if (0) opkg_message(NULL, OPKG_DEBUG2, "Function: %s. Value already in hash by collision for '%s' \n", __FUNCTION__, key);
 	       while (hash_entry->next)
 		    hash_entry = hash_entry->next;
 	       hash_entry->next = (hash_entry_t *)malloc(sizeof(hash_entry_t));

Modified: trunk/src/target/ipkg/hash_table.h
===================================================================
--- trunk/src/target/ipkg/hash_table.h	2008-01-18 11:05:46 UTC (rev 3878)
+++ trunk/src/target/ipkg/hash_table.h	2008-01-18 11:28:48 UTC (rev 3879)
@@ -1,4 +1,4 @@
-/* hash.h - hash tables for ipkg
+/* hash.h - hash tables for opkg
 
    Steven M. Ayer, Jamey Hicks
    

Modified: trunk/src/target/ipkg/intercept/depmod
===================================================================
--- trunk/src/target/ipkg/intercept/depmod	2008-01-18 11:05:46 UTC (rev 3878)
+++ trunk/src/target/ipkg/intercept/depmod	2008-01-18 11:28:48 UTC (rev 3879)
@@ -1,9 +1,9 @@
 #!/bin/sh
 
 if [ "x$1" = "x-a" ] || [ "x$1" = "x-A" ]; then
-  if [ ! -f $IPKG_INTERCEPT_DIR/depmod ]; then
-    echo "depmod -A" > $IPKG_INTERCEPT_DIR/depmod
-    chmod +x $IPKG_INTERCEPT_DIR/depmod
+  if [ ! -f $OPKG_INTERCEPT_DIR/depmod ]; then
+    echo "depmod -A" > $OPKG_INTERCEPT_DIR/depmod
+    chmod +x $OPKG_INTERCEPT_DIR/depmod
   fi
   exit 0
 fi

Modified: trunk/src/target/ipkg/intercept/ldconfig
===================================================================
--- trunk/src/target/ipkg/intercept/ldconfig	2008-01-18 11:05:46 UTC (rev 3878)
+++ trunk/src/target/ipkg/intercept/ldconfig	2008-01-18 11:28:48 UTC (rev 3879)
@@ -1,7 +1,7 @@
 #!/bin/sh
 
-if [ ! -f $IPKG_INTERCEPT_DIR/ldconfig ]; then
-  echo "ldconfig" > $IPKG_INTERCEPT_DIR/ldconfig
-  chmod +x $IPKG_INTERCEPT_DIR/ldconfig
+if [ ! -f $OPKG_INTERCEPT_DIR/ldconfig ]; then
+  echo "ldconfig" > $OPKG_INTERCEPT_DIR/ldconfig
+  chmod +x $OPKG_INTERCEPT_DIR/ldconfig
 fi
 

Modified: trunk/src/target/ipkg/intercept/update-modules
===================================================================
--- trunk/src/target/ipkg/intercept/update-modules	2008-01-18 11:05:46 UTC (rev 3878)
+++ trunk/src/target/ipkg/intercept/update-modules	2008-01-18 11:28:48 UTC (rev 3879)
@@ -1,7 +1,7 @@
 #!/bin/sh
 
-if [ ! -f $IPKG_INTERCEPT_DIR/update-modules ]; then
-  echo "update-modules" > $IPKG_INTERCEPT_DIR/update-modules
-  chmod +x $IPKG_INTERCEPT_DIR/update-modules
+if [ ! -f $OPKG_INTERCEPT_DIR/update-modules ]; then
+  echo "update-modules" > $OPKG_INTERCEPT_DIR/update-modules
+  chmod +x $OPKG_INTERCEPT_DIR/update-modules
 fi
 

Deleted: trunk/src/target/ipkg/ipkg-frontend.c
===================================================================
--- trunk/src/target/ipkg/ipkg-frontend.c	2008-01-18 11:05:46 UTC (rev 3878)
+++ trunk/src/target/ipkg/ipkg-frontend.c	2008-01-18 11:28:48 UTC (rev 3879)
@@ -1,28 +0,0 @@
-/* ipkg-frontend.c - the itsy package management system
-
-   Florina Boor
-
-   Copyright (C) 2003 kernel concepts
-
-   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.
-   
-   ipkg command line frontend using libipkg
-   
-*/
-
-#include "libipkg.h"
-
-/* This is really small, eh? ;-) */
-
-int main(int argc, char *argv[])
-{
-	return ipkg_op(argc,argv);	
-}

Deleted: trunk/src/target/ipkg/ipkg.c
===================================================================
--- trunk/src/target/ipkg/ipkg.c	2008-01-18 11:05:46 UTC (rev 3878)
+++ trunk/src/target/ipkg/ipkg.c	2008-01-18 11:28:48 UTC (rev 3879)
@@ -1,81 +0,0 @@
-/* ipkg.c - the itsy package management system
-
-   Carl D. Worth
-
-   Copyright (C) 2001 University of Southern California
-
-   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 "args.h"
-#include "ipkg_conf.h"
-#include "ipkg_cmd.h"
-
-int main(int argc, const char *argv[])
-{
-    int err, optind;
-    args_t args;
-    char *cmd_name;
-    ipkg_cmd_t *cmd;
-    ipkg_conf_t ipkg_conf;
-
-    error_list=NULL;
-
-    args_init(&args);
-	
-    optind = args_parse(&args, argc, argv);
-    if (optind == argc || optind < 0) {
-	args_usage("ipkg must have one sub-command argument");
-    }
-
-    cmd_name = argv[optind++];
-
-    err = ipkg_conf_init(&ipkg_conf, &args);
-    if (err) {
-	return err;
-    }
-
-    args_deinit(&args);
-
-    cmd = ipkg_cmd_find(cmd_name);
-    if (cmd == NULL) {
-	fprintf(stderr, "%s: unknown sub-command %s\n", argv[0], cmd_name);
-	args_usage(NULL);
-    }
-
-    if (cmd->requires_args && optind == argc) {
-	fprintf(stderr, "%s: the ``%s'' command requires at least one argument\n",
-		__FUNCTION__, cmd_name);
-	args_usage(NULL);
-    }
-
-    err = ipkg_cmd_exec(cmd, &ipkg_conf, argc - optind, argv + optind);
-
-    if ( err == 0 ) {
-       ipkg_message(ipkg_conf, IPKG_NOTICE, "Succesfully done.\n");
-    } else {
-       ipkg_message(ipkg_conf, IPKG_NOTICE, "Error returned. Return value is %d\n.",err);
-
-}
-
-    }
-    /* XXX: FEATURE request: run ldconfig and/or depmod after package needing them are installed or removed */  
-    // ipkg_global_postinst();
-
-    ipkg_conf_deinit(&ipkg_conf);
-
-    return err;
-}
-
-
-

Deleted: trunk/src/target/ipkg/ipkg.h
===================================================================
--- trunk/src/target/ipkg/ipkg.h	2008-01-18 11:05:46 UTC (rev 3878)
+++ trunk/src/target/ipkg/ipkg.h	2008-01-18 11:28:48 UTC (rev 3879)
@@ -1,68 +0,0 @@
-/* ipkg.h - the itsy package management system
-
-   Carl D. Worth
-
-   Copyright (C) 2001 University of Southern California
-
-   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.
-*/
-
-#ifndef IPKG_H
-#define IPKG_H
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#if 0
-#define IPKG_DEBUG_NO_TMP_CLEANUP
-#endif
-
-#include "includes.h"
-#include "ipkg_conf.h"
-#include "ipkg_message.h"
-
-#define IPKG_PKG_EXTENSION ".ipk"
-#define DPKG_PKG_EXTENSION ".deb"
-
-#define IPKG_LEGAL_PKG_NAME_CHARS "abcdefghijklmnopqrstuvwxyz0123456789.+-"
-#define IPKG_PKG_VERSION_SEP_CHAR '_'
-
-#define IPKG_STATE_DIR_PREFIX IPKGLIBDIR"/ipkg"
-#define IPKG_LISTS_DIR_SUFFIX "lists"
-#define IPKG_INFO_DIR_SUFFIX "info"
-#define IPKG_STATUS_FILE_SUFFIX "status"
-
-#define IPKG_BACKUP_SUFFIX "-ipkg.backup"
-
-#define IPKG_LIST_DESCRIPTION_LENGTH 128
-
-enum ipkg_error {
-    IPKG_SUCCESS = 0,
-    IPKG_PKG_DEPS_UNSATISFIED,
-    IPKG_PKG_IS_ESSENTIAL,
-    IPKG_PKG_HAS_DEPENDENTS,
-    IPKG_PKG_HAS_NO_CANDIDATE
-};
-typedef enum ipkg_error ipkg_error_t;
-
-extern int ipkg_state_changed;
-
-
-struct errlist {
-    char * errmsg;
-    struct errlist * next;
-} ;
-
-struct errlist* error_list;
-
-
-#endif

Deleted: trunk/src/target/ipkg/ipkg.h.in
===================================================================
--- trunk/src/target/ipkg/ipkg.h.in	2008-01-18 11:05:46 UTC (rev 3878)
+++ trunk/src/target/ipkg/ipkg.h.in	2008-01-18 11:28:48 UTC (rev 3879)
@@ -1,68 +0,0 @@
-/* ipkg.h - the itsy package management system
-
-   Carl D. Worth
-
-   Copyright (C) 2001 University of Southern California
-
-   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.
-*/
-
-#ifndef IPKG_H
-#define IPKG_H
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#if 0
-#define IPKG_DEBUG_NO_TMP_CLEANUP
-#endif
-
-#include "includes.h"
-#include "ipkg_conf.h"
-#include "ipkg_message.h"
-
-#define IPKG_PKG_EXTENSION ".ipk"
-#define DPKG_PKG_EXTENSION ".deb"
-
-#define IPKG_LEGAL_PKG_NAME_CHARS "abcdefghijklmnopqrstuvwxyz0123456789.+-"
-#define IPKG_PKG_VERSION_SEP_CHAR '_'
-
-#define IPKG_STATE_DIR_PREFIX IPKGLIBDIR"/ipkg"
-#define IPKG_LISTS_DIR_SUFFIX "lists"
-#define IPKG_INFO_DIR_SUFFIX "info"
-#define IPKG_STATUS_FILE_SUFFIX "status"
-
-#define IPKG_BACKUP_SUFFIX "-ipkg.backup"
-
-#define IPKG_LIST_DESCRIPTION_LENGTH 128
-
-enum ipkg_error {
-    IPKG_SUCCESS = 0,
-    IPKG_PKG_DEPS_UNSATISFIED,
-    IPKG_PKG_IS_ESSENTIAL,
-    IPKG_PKG_HAS_DEPENDENTS,
-    IPKG_PKG_HAS_NO_CANDIDATE
-};
-typedef enum ipkg_error ipkg_error_t;
-
-extern int ipkg_state_changed;
-
-
-struct errlist {
-    char * errmsg;
-    struct errlist * next;
-} ;
-
-struct errlist* error_list;
-
-
-#endif

Deleted: trunk/src/target/ipkg/ipkg_cmd.c
===================================================================
--- trunk/src/target/ipkg/ipkg_cmd.c	2008-01-18 11:05:46 UTC (rev 3878)
+++ trunk/src/target/ipkg/ipkg_cmd.c	2008-01-18 11:28:48 UTC (rev 3879)
@@ -1,1432 +0,0 @@
-/* ipkg_cmd.c - the itsy package management system
-
-   Carl D. Worth
-
-   Copyright (C) 2001 University of Southern California
-
-   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 <string.h>
-
-#include "ipkg.h"
-#include <libgen.h>
-#include <glob.h>
-#include <errno.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <signal.h>
-#include <stdio.h>
-#include <dirent.h>
-
-#include "ipkg_conf.h"
-#include "ipkg_cmd.h"
-#include "ipkg_message.h"
-#include "pkg.h"
-#include "pkg_dest.h"
-#include "pkg_parse.h"
-#include "sprintf_alloc.h"
-#include "pkg.h"
-#include "file_util.h"
-#include "str_util.h"
-#include "libbb/libbb.h"
-
-#include <fnmatch.h>
-
-
-#include "ipkg_download.h"
-#include "ipkg_install.h"
-#include "ipkg_upgrade.h"
-#include "ipkg_remove.h"
-#include "ipkg_configure.h"
-#include "ipkg_message.h"
-
-#ifdef IPKG_LIB
-#include "libipkg.h"
-static void *p_userdata = NULL;
-#endif
-
-static int ipkg_update_cmd(ipkg_conf_t *conf, int argc, char **argv);
-static int ipkg_upgrade_cmd(ipkg_conf_t *conf, int argc, char **argv);
-static int ipkg_list_cmd(ipkg_conf_t *conf, int argc, char **argv);
-static int ipkg_info_cmd(ipkg_conf_t *conf, int argc, char **argv);
-static int ipkg_status_cmd(ipkg_conf_t *conf, int argc, char **argv);
-static int ipkg_install_pending_cmd(ipkg_conf_t *conf, int argc, char **argv);
-static int ipkg_install_cmd(ipkg_conf_t *conf, int argc, char **argv);
-static int ipkg_list_installed_cmd(ipkg_conf_t *conf, int argc, char **argv);
-static int ipkg_remove_cmd(ipkg_conf_t *conf, int argc, char **argv);
-static int ipkg_purge_cmd(ipkg_conf_t *conf, int argc, char **argv);
-static int ipkg_flag_cmd(ipkg_conf_t *conf, int argc, char **argv);
-static int ipkg_files_cmd(ipkg_conf_t *conf, int argc, char **argv);
-static int ipkg_search_cmd(ipkg_conf_t *conf, int argc, char **argv);
-static int ipkg_download_cmd(ipkg_conf_t *conf, int argc, char **argv);
-static int ipkg_depends_cmd(ipkg_conf_t *conf, int argc, char **argv);
-static int ipkg_whatdepends_cmd(ipkg_conf_t *conf, int argc, char **argv);
-static int ipkg_whatdepends_recursively_cmd(ipkg_conf_t *conf, int argc, char **argv);
-static int ipkg_whatsuggests_cmd(ipkg_conf_t *conf, int argc, char **argv);
-static int ipkg_whatrecommends_cmd(ipkg_conf_t *conf, int argc, char **argv);
-static int ipkg_whatprovides_cmd(ipkg_conf_t *conf, int argc, char **argv);
-static int ipkg_whatconflicts_cmd(ipkg_conf_t *conf, int argc, char **argv);
-static int ipkg_whatreplaces_cmd(ipkg_conf_t *conf, int argc, char **argv);
-static int ipkg_compare_versions_cmd(ipkg_conf_t *conf, int argc, char **argv);
-static int ipkg_print_architecture_cmd(ipkg_conf_t *conf, int argc, char **argv);
-static int ipkg_configure_cmd(ipkg_conf_t *conf, int argc, char **argv);
-
-/* XXX: CLEANUP: The usage strings should be incorporated into this
-   array for easier maintenance */
-static ipkg_cmd_t cmds[] = {
-     {"update", 0, (ipkg_cmd_fun_t)ipkg_update_cmd}, 
-     {"upgrade", 0, (ipkg_cmd_fun_t)ipkg_upgrade_cmd},
-     {"list", 0, (ipkg_cmd_fun_t)ipkg_list_cmd},
-     {"list_installed", 0, (ipkg_cmd_fun_t)ipkg_list_installed_cmd},
-     {"info", 0, (ipkg_cmd_fun_t)ipkg_info_cmd},
-     {"flag", 1, (ipkg_cmd_fun_t)ipkg_flag_cmd},
-     {"status", 0, (ipkg_cmd_fun_t)ipkg_status_cmd},
-     {"install_pending", 0, (ipkg_cmd_fun_t)ipkg_install_pending_cmd},
-     {"install", 1, (ipkg_cmd_fun_t)ipkg_install_cmd},
-     {"remove", 1, (ipkg_cmd_fun_t)ipkg_remove_cmd},
-     {"purge", 1, (ipkg_cmd_fun_t)ipkg_purge_cmd},
-     {"configure", 0, (ipkg_cmd_fun_t)ipkg_configure_cmd},
-     {"files", 1, (ipkg_cmd_fun_t)ipkg_files_cmd},
-     {"search", 1, (ipkg_cmd_fun_t)ipkg_search_cmd},
-     {"download", 1, (ipkg_cmd_fun_t)ipkg_download_cmd},
-     {"compare_versions", 1, (ipkg_cmd_fun_t)ipkg_compare_versions_cmd},
-     {"compare-versions", 1, (ipkg_cmd_fun_t)ipkg_compare_versions_cmd},
-     {"print-architecture", 0, (ipkg_cmd_fun_t)ipkg_print_architecture_cmd},
-     {"print_architecture", 0, (ipkg_cmd_fun_t)ipkg_print_architecture_cmd},
-     {"print-installation-architecture", 0, (ipkg_cmd_fun_t)ipkg_print_architecture_cmd},
-     {"print_installation_architecture", 0, (ipkg_cmd_fun_t)ipkg_print_architecture_cmd},
-     {"depends", 1, (ipkg_cmd_fun_t)ipkg_depends_cmd},
-     {"whatdepends", 1, (ipkg_cmd_fun_t)ipkg_whatdepends_cmd},
-     {"whatdependsrec", 1, (ipkg_cmd_fun_t)ipkg_whatdepends_recursively_cmd},
-     {"whatrecommends", 1, (ipkg_cmd_fun_t)ipkg_whatrecommends_cmd},
-     {"whatsuggests", 1, (ipkg_cmd_fun_t)ipkg_whatsuggests_cmd},
-     {"whatprovides", 1, (ipkg_cmd_fun_t)ipkg_whatprovides_cmd},
-     {"whatreplaces", 1, (ipkg_cmd_fun_t)ipkg_whatreplaces_cmd},
-     {"whatconflicts", 1, (ipkg_cmd_fun_t)ipkg_whatconflicts_cmd},
-};
-
-int ipkg_state_changed;
-static void write_status_files_if_changed(ipkg_conf_t *conf)
-{
-     if (ipkg_state_changed && !conf->noaction) {
-	  ipkg_message(conf, IPKG_INFO,
-		       "  writing status file\n");
-	  ipkg_conf_write_status_files(conf);
-	  pkg_write_changed_filelists(conf);
-     } else { 
-	  ipkg_message(conf, IPKG_NOTICE, "Nothing to be done\n");
-     }
-}
-
-
-static int num_cmds = sizeof(cmds) / sizeof(ipkg_cmd_t);
-
-ipkg_cmd_t *ipkg_cmd_find(const char *name)
-{
-     int i;
-     ipkg_cmd_t *cmd;
-
-     for (i=0; i < num_cmds; i++) {
-	  cmd = &cmds[i];
-	  if (strcmp(name, cmd->name) == 0) {
-	       return cmd;
-	  }
-     }
-
-     return NULL;
-}
-
-#ifdef IPKG_LIB
-int ipkg_cmd_exec(ipkg_cmd_t *cmd, ipkg_conf_t *conf, int argc, const char **argv, void *userdata)
-{
-	int result;
-	p_userdata = userdata;
-      
-
-	result = (cmd->fun)(conf, argc, argv);
-        if ( result == 0 ) {
-           ipkg_message(conf, IPKG_NOTICE, "Successfully terminated.\n");
-        } else {
-           ipkg_message(conf, IPKG_NOTICE, "An error ocurred, return value: %d.\n", result);
-
-        }
-        if ( error_list ) {
-           reverse_error_list(&error_list);
-
-           ipkg_message(conf, IPKG_NOTICE, "Collected errors:\n");
-           /* Here we print the errors collected and free the list */
-           while (error_list != NULL) {
-                 ipkg_message(conf, IPKG_NOTICE, "%s",error_list->errmsg);
-                 error_list = error_list->next;
-
-           }
-           free_error_list(&error_list);
-
-        }
-   
-	p_userdata = NULL;
-	return result;
-}
-#else
-int ipkg_cmd_exec(ipkg_cmd_t *cmd, ipkg_conf_t *conf, int argc, const char **argv)
-{
-     return (cmd->fun)(conf, argc, argv);
-}
-#endif
-
-static int ipkg_update_cmd(ipkg_conf_t *conf, int argc, char **argv)
-{
-     int err;
-     int failures;
-     char *lists_dir;
-     pkg_src_list_elt_t *iter;
-     pkg_src_t *src;
-
- 
-    sprintf_alloc(&lists_dir, "%s", conf->restrict_to_default_dest ? conf->default_dest->lists_dir : conf->lists_dir);
- 
-    if (! file_is_dir(lists_dir)) {
-	  if (file_exists(lists_dir)) {
-	       ipkg_message(conf, IPKG_ERROR,
-			    "%s: ERROR: %s exists, but is not a directory\n",
-			    __FUNCTION__, lists_dir);
-	       free(lists_dir);
-	       return EINVAL;
-	  }
-	  err = file_mkdir_hier(lists_dir, 0755);
-	  if (err) {
-	       ipkg_message(conf, IPKG_ERROR,
-			    "%s: ERROR: failed to make directory %s: %s\n",
-			    __FUNCTION__, lists_dir, strerror(errno));
-	       free(lists_dir);
-	       return EINVAL;
-	  }	
-     } 
-
-     failures = 0;
-     for (iter = conf->pkg_src_list.head; iter; iter = iter->next) {
-	  char *url, *list_file_name;
-
-	  src = iter->data;
-
-	  if (src->extra_data)	/* debian style? */
-	      sprintf_alloc(&url, "%s/%s/%s", src->value, src->extra_data, 
-			    src->gzip ? "Packages.gz" : "Packages");
-	  else
-	      sprintf_alloc(&url, "%s/%s", src->value, src->gzip ? "Packages.gz" : "Packages");
-
-	  sprintf_alloc(&list_file_name, "%s/%s", lists_dir, src->name);
-	  if (src->gzip) {
-	      char *tmp;
-	      char *tmp_file_name;
-	      FILE *in, *out;
-
-	      tmp = strdup ("/tmp/ipkg.XXXXXX");
-
-	      if (mkdtemp (tmp) == NULL) {
-		  perror ("mkdtemp");
-		  failures++;
-		  continue;
-	      }
-	      
-	      sprintf_alloc (&tmp_file_name, "%s/%s.gz", tmp, src->name);
-	      err = ipkg_download(conf, url, tmp_file_name);
-	      if (err == 0) {
-		   ipkg_message (conf, IPKG_NOTICE, "Inflating %s\n", url);
-		   in = fopen (tmp_file_name, "r");
-		   out = fopen (list_file_name, "w");
-		   if (in && out)
-			unzip (in, out);
-		   else
-			err = 1;
-		   if (in)
-			fclose (in);
-		   if (out)
-			fclose (out);
-		   unlink (tmp_file_name);
-		   rmdir (tmp);
-		   free (tmp);
-	      }
-	  } else
-	      err = ipkg_download(conf, url, list_file_name);
-	  if (err) {
-	       failures++;
-	  } else {
-	       ipkg_message(conf, IPKG_NOTICE,
-			    "Updated list of available packages in %s\n",
-			    list_file_name);
-	  }
-	  free(url);
-	  free(list_file_name);
-     }
-     free(lists_dir);
-
-#ifdef CONFIG_CLEAR_SW_INSTALL_FLAG
-#warning here
-     /* clear SW_INSTALL on any package where state is SS_NOT_INSTALLED.
-      * this is a hack to work around poor bookkeeping in old ipkg upgrade code 
-      * -Jamey 3/1/03
-      */
-     {
-	  int i;
-	  int changed = 0;
-	  pkg_vec_t *available = pkg_vec_alloc();
-	  pkg_hash_fetch_available(&conf->pkg_hash, available);
-	  ipkg_message(conf, IPKG_DEBUG, "Clearing SW_INSTALL for SS_NOT_INSTALLED packages.\n");
-	  for (i = 0; i < available->len; i++) {
-	       pkg_t *pkg = available->pkgs[i];
-	       if (pkg->state_want == SW_INSTALL && pkg->state_status == SS_NOT_INSTALLED) {
-		    ipkg_message(conf, IPKG_DEBUG, "Clearing SW_INSTALL on package %s.\n", pkg->name);
-		    pkg->state_want = SW_UNKNOWN;
-		    changed = 1;
-	       }
-	  }
-	  pkg_vec_free(available);
-	  if (changed) {
-	       write_status_files_if_changed(conf);
-	  }
-     }
-#endif
-
-     return failures;
-}
-
-
-/* scan the args passed and cache the local filenames of the packages */
-int ipkg_multiple_files_scan(ipkg_conf_t *conf, int argc, char **argv)
-{
-     int i;
-     int err;
-    
-     /* 
-      * First scan through package names/urls
-      * For any urls, download the packages and install in database.
-      * For any files, install package info in database.
-      */
-     for (i = 0; i < argc; i ++) {
-	  char *filename = argv [i];
-	  //char *tmp = basename (tmp);
-	  //int tmplen = strlen (tmp);
-
-	  //if (strcmp (tmp + (tmplen - strlen (IPKG_PKG_EXTENSION)), IPKG_PKG_EXTENSION) != 0)
-	  //     continue;
-	  //if (strcmp (tmp + (tmplen - strlen (DPKG_PKG_EXTENSION)), DPKG_PKG_EXTENSION) != 0)
-	  //     continue;
-	
-          ipkg_message(conf, IPKG_DEBUG2, "Debug mfs: %s  \n",filename );
-
-	  err = ipkg_prepare_url_for_install(conf, filename, &argv[i]);
-	  if (err)
-	    return err;
-     }
-     return 0;
-}
-
-struct ipkg_intercept
-{
-    char *oldpath;
-    char *statedir;
-};
-
-typedef struct ipkg_intercept *ipkg_intercept_t;
-
-ipkg_intercept_t ipkg_prep_intercepts(ipkg_conf_t *conf)
-{
-    ipkg_intercept_t ctx;
-    char *newpath;
-    int gen;
-
-    ctx = malloc (sizeof (*ctx));
-    ctx->oldpath = strdup (getenv ("PATH"));
-
-    sprintf_alloc (&newpath, "%s/ipkg/intercept:%s", DATADIR, ctx->oldpath);
-    setenv ("PATH", newpath, 1);
-    free (newpath);
-    
-    gen = 0;
- retry:
-    sprintf_alloc (&ctx->statedir, "/tmp/ipkg-intercept-%d-%d", getpid (), gen);
-    if (mkdir (ctx->statedir, 0770) < 0) {
-	if (errno == EEXIST) {
-	    free (ctx->statedir);
-	    gen++;
-	    goto retry;
-	}
-	perror (ctx->statedir);
-	return NULL;
-    }
-    setenv ("IPKG_INTERCEPT_DIR", ctx->statedir, 1);
-    return ctx;
-}
-
-int ipkg_finalize_intercepts(ipkg_intercept_t ctx)
-{
-    char *cmd;
-    DIR *dir;
-    int err = 0;
-
-    setenv ("PATH", ctx->oldpath, 1);
-    free (ctx->oldpath);
-
-    dir = opendir (ctx->statedir);
-    if (dir) {
-	struct dirent *de;
-	while (de = readdir (dir), de != NULL) {
-	    char *path;
-	    
-	    if (de->d_name[0] == '.')
-		continue;
-	    
-	    sprintf_alloc (&path, "%s/%s", ctx->statedir, de->d_name);
-	    if (access (path, X_OK) == 0) {
-		if (system (path)) {
-		    err = errno;
-		    perror (de->d_name);
-		}
-	    }
-	    free (path);
-	}
-    } else
-	perror (ctx->statedir);
-	
-    sprintf_alloc (&cmd, "rm -rf %s", ctx->statedir);
-    system (cmd);
-    free (cmd);
-
-    free (ctx->statedir);
-    free (ctx);
-
-    return err;
-}
-
-int ipkg_configure_packages(ipkg_conf_t *conf, char *pkg_name)
-{
-     pkg_vec_t *all;
-     int i;
-     pkg_t *pkg;
-     ipkg_intercept_t ic;
-     int r, err = 0;
-
-     ipkg_message(conf, IPKG_INFO,
-		  "Configuring unpacked packages\n");
-     fflush( stdout );
-
-     all = pkg_vec_alloc();
-     pkg_hash_fetch_available(&conf->pkg_hash, all);
-
-     ic = ipkg_prep_intercepts (conf);
-    
-     for(i = 0; i < all->len; i++) {
-	  pkg = all->pkgs[i];
-
-	  if (pkg_name && fnmatch(pkg_name, pkg->name, 0)) 
-	       continue;
-
-	  if (pkg->state_status == SS_UNPACKED) {
-	       ipkg_message(conf, IPKG_NOTICE,
-			    "Configuring %s\n", pkg->name);
-	       fflush( stdout );
-	       r = ipkg_configure(conf, pkg);
-	       if (r == 0) {
-		    pkg->state_status = SS_INSTALLED;
-		    pkg->parent->state_status = SS_INSTALLED;
-		    pkg->state_flag &= ~SF_PREFER;
-	       } else {
-		    if (!err)
-			err = r;
-	       }
-	  }
-     }
-
-     r = ipkg_finalize_intercepts (ic);
-     if (r && !err)
-	 err = r;
-
-     pkg_vec_free(all);
-     return err;
-}
-
-static ipkg_conf_t *global_conf;
-
-static void sigint_handler(int sig)
-{
-     signal(sig, SIG_DFL);
-     ipkg_message(NULL, IPKG_NOTICE,
-		  "ipkg: interrupted. writing out status database\n");
-     write_status_files_if_changed(global_conf);
-     exit(128 + sig);
-}
-
-static int ipkg_install_cmd(ipkg_conf_t *conf, int argc, char **argv)
-{
-     int i;
-     char *arg;
-     int err=0;
-
-     global_conf = conf;
-     signal(SIGINT, sigint_handler);
-
-     /*
-      * Now scan through package names and install
-      */
-     for (i=0; i < argc; i++) {
-	  arg = argv[i];
-
-          ipkg_message(conf, IPKG_DEBUG2, "Debug install_cmd: %s  \n",arg );
-          err = ipkg_prepare_url_for_install(conf, arg, &argv[i]);
-          if (err != EINVAL && err != 0)
-              return err;
-     }
-     pkg_info_preinstall_check(conf);
-
-     for (i=0; i < argc; i++) {
-	  arg = argv[i];
-	  if (conf->multiple_providers)
-	       err = ipkg_install_multi_by_name(conf, arg);
-	  else{
-	       err = ipkg_install_by_name(conf, arg);
-          }
-	  if (err == IPKG_PKG_HAS_NO_CANDIDATE) {
-	       ipkg_message(conf, IPKG_ERROR,
-			    "Cannot find package %s.\n"
-			    "Check the spelling or perhaps run 'ipkg update'\n",
-			    arg);
-	  }
-     }
-
-     /* recheck to verify that all dependences are satisfied */
-     if (0) ipkg_satisfy_all_dependences(conf);
-
-     ipkg_configure_packages(conf, NULL);
-
-     write_status_files_if_changed(conf);
-
-     return err;
-}
-
-static int ipkg_upgrade_cmd(ipkg_conf_t *conf, int argc, char **argv)
-{
-     int i;
-     pkg_t *pkg;
-     int err;
-
-     global_conf = conf;
-     signal(SIGINT, sigint_handler);
-
-     if (argc) {
-	  for (i=0; i < argc; i++) {
-	       char *arg = argv[i];
-
-               err = ipkg_prepare_url_for_install(conf, arg, &arg);
-               if (err != EINVAL && err != 0)
-                   return err;
-	  }
-	  pkg_info_preinstall_check(conf);
-
-	  for (i=0; i < argc; i++) {
-	       char *arg = argv[i];
-	       if (conf->restrict_to_default_dest) {
-		    pkg = pkg_hash_fetch_installed_by_name_dest(&conf->pkg_hash,
-								argv[i],
-								conf->default_dest);
-		    if (pkg == NULL) {
-			 ipkg_message(conf, IPKG_NOTICE,
-				      "Package %s not installed in %s\n",
-				      argv[i], conf->default_dest->name);
-			 continue;
-		    }
-	       } else {
-		    pkg = pkg_hash_fetch_installed_by_name(&conf->pkg_hash,
-							   argv[i]);
-	       }
-	       if (pkg)
-		    ipkg_upgrade_pkg(conf, pkg);
-	       else {
-		    ipkg_install_by_name(conf, arg);
-               }
-	  }
-     } else {
-	  pkg_vec_t *installed = pkg_vec_alloc();
-
-	  pkg_info_preinstall_check(conf);
-
-	  pkg_hash_fetch_all_installed(&conf->pkg_hash, installed);
-	  for (i = 0; i < installed->len; i++) {
-	       pkg = installed->pkgs[i];
-	       ipkg_upgrade_pkg(conf, pkg);
-	  }
-	  pkg_vec_free(installed);
-     }
-
-     /* recheck to verify that all dependences are satisfied */
-     if (0) ipkg_satisfy_all_dependences(conf);
-
-     ipkg_configure_packages(conf, NULL);
-
-     write_status_files_if_changed(conf);
-
-     return 0;
-}
-
-static int ipkg_download_cmd(ipkg_conf_t *conf, int argc, char **argv)
-{
-     int i, err;
-     char *arg;
-     pkg_t *pkg;
-
-     pkg_info_preinstall_check(conf);
-     for (i = 0; i < argc; i++) {
-	  arg = argv[i];
-
-	  pkg = pkg_hash_fetch_best_installation_candidate_by_name(conf, arg);
-	  if (pkg == NULL) {
-	       ipkg_message(conf, IPKG_ERROR,
-			    "Cannot find package %s.\n"
-			    "Check the spelling or perhaps run 'ipkg update'\n",
-			    arg);
-	       continue;
-	  }
-
-	  err = ipkg_download_pkg(conf, pkg, ".");
-
-	  if (err) {
-	       ipkg_message(conf, IPKG_ERROR,
-			    "Failed to download %s\n", pkg->name);
-	  } else {
-	       ipkg_message(conf, IPKG_NOTICE,
-			    "Downloaded %s as %s\n",
-			    pkg->name, pkg->local_filename);
-	  }
-     }
-
-     return 0;
-}
-
-
-static int ipkg_list_cmd(ipkg_conf_t *conf, int argc, char **argv)
-{
-     int i ;
-     pkg_vec_t *available;
-     pkg_t *pkg;
-     char desc_short[IPKG_LIST_DESCRIPTION_LENGTH];
-     char *newline;
-     char *pkg_name = NULL;
-     char *version_str;
-
-     if (argc > 0) {
-	  pkg_name = argv[0];
-     }
-     available = pkg_vec_alloc();
-     pkg_hash_fetch_available(&conf->pkg_hash, available);
-     for (i=0; i < available->len; i++) {
-	  pkg = available->pkgs[i];
-	  /* if we have package name or pattern and pkg does not match, then skip it */
-	  if (pkg_name && fnmatch(pkg_name, pkg->name, 0)) 
-	       continue;
-	  if (pkg->description) {
-	       strncpy(desc_short, pkg->description, IPKG_LIST_DESCRIPTION_LENGTH);
-	  } else {
-	       desc_short[0] = '\0';
-	  }
-	  desc_short[IPKG_LIST_DESCRIPTION_LENGTH - 1] = '\0';
-	  newline = strchr(desc_short, '\n');
-	  if (newline) {
-	       *newline = '\0';
-	  }
-#ifndef IPKG_LIB
-	  printf("%s - %s\n", pkg->name, desc_short);
-#else
-	  if (ipkg_cb_list) {
-	  	version_str = pkg_version_str_alloc(pkg);
-	  	ipkg_cb_list(pkg->name,desc_short,
-		                             version_str,
-	                                 pkg->state_status,
-	                                 p_userdata);
-		free(version_str);
-	  }
-#endif
-     }
-     pkg_vec_free(available);
-
-     return 0;
-}
-
-
-static int ipkg_list_installed_cmd(ipkg_conf_t *conf, int argc, char **argv)
-{
-     int i ;
-     pkg_vec_t *available;
-     pkg_t *pkg;
-     char desc_short[IPKG_LIST_DESCRIPTION_LENGTH];
-     char *newline;
-     char *pkg_name = NULL;
-     char *version_str;
-
-     if (argc > 0) {
-	  pkg_name = argv[0];
-     }
-     available = pkg_vec_alloc();
-     pkg_hash_fetch_all_installed(&conf->pkg_hash, available);
-     for (i=0; i < available->len; i++) {
-	  pkg = available->pkgs[i];
-	  /* if we have package name or pattern and pkg does not match, then skip it */
-	  if (pkg_name && fnmatch(pkg_name, pkg->name, 0)) 
-	       continue;
-	  if (pkg->description) {
-	       strncpy(desc_short, pkg->description, IPKG_LIST_DESCRIPTION_LENGTH);
-	  } else {
-	       desc_short[0] = '\0';
-	  }
-	  desc_short[IPKG_LIST_DESCRIPTION_LENGTH - 1] = '\0';
-	  newline = strchr(desc_short, '\n');
-	  if (newline) {
-	       *newline = '\0';
-	  }
-#ifndef IPKG_LIB
-	  printf("%s - %s\n", pkg->name, desc_short);
-#else
-	  if (ipkg_cb_list) {
-	  	version_str = pkg_version_str_alloc(pkg);
-	  	ipkg_cb_list(pkg->name,desc_short,
-		                             version_str,
-	                                 pkg->state_status,
-	                                 p_userdata);
-		free(version_str);
-	  }
-#endif
-     }
-
-     return 0;
-}
-
-static int ipkg_info_status_cmd(ipkg_conf_t *conf, int argc, char **argv, int installed_only)
-{
-     int i;
-     pkg_vec_t *available;
-     pkg_t *pkg;
-     char *pkg_name = NULL;
-     char **pkg_fields = NULL;
-     int n_fields = 0;
-     char *buff ; // = (char *)malloc(1);
-
-     if (argc > 0) {
-	  pkg_name = argv[0];
-     }
-     if (argc > 1) {
-	  pkg_fields = &argv[1];
-	  n_fields = argc - 1;
-     }
-
-     available = pkg_vec_alloc();
-     if (installed_only)
-	  pkg_hash_fetch_all_installed(&conf->pkg_hash, available);
-     else
-	  pkg_hash_fetch_available(&conf->pkg_hash, available);
-     for (i=0; i < available->len; i++) {
-	  pkg = available->pkgs[i];
-	  if (pkg_name && fnmatch(pkg_name, pkg->name, 0)) {
-	       continue;
-	  }
-#ifndef IPKG_LIB
-	  if (n_fields) {
-	       for (j = 0; j < n_fields; j++)
-		    pkg_print_field(pkg, stdout, pkg_fields[j]);
-	  } else {
-	       pkg_print_info(pkg, stdout);
-	  }
-#else
-
-	  buff = pkg_formatted_info(pkg);
-          if ( buff ) {
-	       if (ipkg_cb_status) ipkg_cb_status(pkg->name,
-						  pkg->state_status,
-						  buff,
-						  p_userdata);
-/* 
-   We should not forget that actually the pointer is allocated. 
-   We need to free it :)  ( Thanks florian for seeing the error )
-*/
-               free(buff);
-          }
-#endif
-	  if (conf->verbosity > 1) {
-	       conffile_list_elt_t *iter;
-	       for (iter = pkg->conffiles.head; iter; iter = iter->next) {
-		    conffile_t *cf = iter->data;
-		    int modified = conffile_has_been_modified(conf, cf);
-		    ipkg_message(conf, IPKG_NOTICE, "conffile=%s md5sum=%s modified=%d\n",
-				 cf->name, cf->value, modified);
-	       }
-	  }
-     }
-#ifndef IPKG_LIB
-     if (buff)
-	  free(buff);
-#endif
-     pkg_vec_free(available);
-
-     return 0;
-}
-
-static int ipkg_info_cmd(ipkg_conf_t *conf, int argc, char **argv)
-{
-     return ipkg_info_status_cmd(conf, argc, argv, 0);
-}
-
-static int ipkg_status_cmd(ipkg_conf_t *conf, int argc, char **argv)
-{
-     return ipkg_info_status_cmd(conf, argc, argv, 1);
-}
-
-static int ipkg_configure_cmd(ipkg_conf_t *conf, int argc, char **argv)
-{
-     
-     int err;
-     if (argc > 0) {
-	  char *pkg_name = NULL;
-
-	  pkg_name = argv[0];
-
-	  err = ipkg_configure_packages (conf, pkg_name);
-     
-     } else {
-	  err = ipkg_configure_packages (conf, NULL);
-     }
-
-     write_status_files_if_changed(conf);
-
-     return err;
-}
-
-static int ipkg_install_pending_cmd(ipkg_conf_t *conf, int argc, char **argv)
-{
-     int i, err;
-     char *globpattern;
-     glob_t globbuf;
-    
-     sprintf_alloc(&globpattern, "%s/*" IPKG_PKG_EXTENSION, conf->pending_dir);
-     err = glob(globpattern, 0, NULL, &globbuf);
-     free(globpattern);
-     if (err) {
-	  return 0;
-     }
-
-     ipkg_message(conf, IPKG_NOTICE,
-		  "The following packages in %s will now be installed.\n",
-		  conf->pending_dir);
-     for (i = 0; i < globbuf.gl_pathc; i++) {
-	  ipkg_message(conf, IPKG_NOTICE,
-		       "%s%s", i == 0 ? "" : " ", globbuf.gl_pathv[i]);
-     }
-     ipkg_message(conf, IPKG_NOTICE, "\n");
-     for (i = 0; i < globbuf.gl_pathc; i++) {
-	  err = ipkg_install_from_file(conf, globbuf.gl_pathv[i]);
-	  if (err == 0) {
-	       err = unlink(globbuf.gl_pathv[i]);
-	       if (err) {
-		    ipkg_message(conf, IPKG_ERROR,
-				 "%s: ERROR: failed to unlink %s: %s\n",
-				 __FUNCTION__, globbuf.gl_pathv[i], strerror(err));
-		    return err;
-	       }
-	  }
-     }
-     globfree(&globbuf);
-
-     return err;
-}
-
-static int ipkg_remove_cmd(ipkg_conf_t *conf, int argc, char **argv)
-{
-     int i,a,done;
-     pkg_t *pkg;
-     pkg_t *pkg_to_remove;
-     pkg_vec_t *available;
-     char *pkg_name = NULL;
-     global_conf = conf;
-     signal(SIGINT, sigint_handler);
-
-// ENH: Add the "no pkg removed" just in case.
-
-    done = 0;
-
-     available = pkg_vec_alloc();
-     pkg_info_preinstall_check(conf);
-     if ( argc > 0 ) {
-        pkg_hash_fetch_all_installed(&conf->pkg_hash, available);
-        for (i=0; i < argc; i++) {
-           pkg_name = malloc(strlen(argv[i])+2);
-           strcpy(pkg_name,argv[i]);
-           for (a=0; a < available->len; a++) {
-               pkg = available->pkgs[a];
-	       if (pkg_name && fnmatch(pkg_name, pkg->name, 0)) {
-                  continue;
-               }
-               if (conf->restrict_to_default_dest) {
-	            pkg_to_remove = pkg_hash_fetch_installed_by_name_dest(&conf->pkg_hash,
-							        pkg->name,
-							        conf->default_dest);
-               } else {
-	            pkg_to_remove = pkg_hash_fetch_installed_by_name(&conf->pkg_hash, pkg->name );
-               }
-        
-               if (pkg == NULL) {
-	            ipkg_message(conf, IPKG_ERROR, "Package %s is not installed.\n", pkg->name);
-	            continue;
-               }
-               if (pkg->state_status == SS_NOT_INSTALLED) {    // Added the control, so every already removed package could be skipped
-	            ipkg_message(conf, IPKG_ERROR, "Package seems to be %s not installed (STATUS = NOT_INSTALLED).\n", pkg->name);
-                    continue;
-               }
-               ipkg_remove_pkg(conf, pkg_to_remove,0);
-               done = 1;
-           }
-           free (pkg_name);
-        }
-        pkg_vec_free(available);
-     } else {
-	  pkg_vec_t *installed_pkgs = pkg_vec_alloc();
-	  int i;
-	  int flagged_pkg_count = 0;
-	  int removed;
-
-	  pkg_hash_fetch_all_installed(&conf->pkg_hash, installed_pkgs);
-
-	  for (i = 0; i < installed_pkgs->len; i++) {
-	       pkg_t *pkg = installed_pkgs->pkgs[i];
-	       if (pkg->state_flag & SF_USER) {
-		    flagged_pkg_count++;
-	       } else {
-		    if (!pkg_has_installed_dependents(conf, pkg->parent, pkg, NULL))
-			 ipkg_message(conf, IPKG_NOTICE, "Non-user leaf package: %s\n", pkg->name);
-	       }
-	  }
-	  if (!flagged_pkg_count) {
-	       ipkg_message(conf, IPKG_NOTICE, "No packages flagged as installed by user, \n"
-			    "so refusing to uninstall unflagged non-leaf packages\n");
-	       return 0;
-	  }
-
-	  /* find packages not flagged SF_USER (i.e., installed to
-	   * satisfy a dependence) and not having any dependents, and
-	   * remove them */
-	  do {
-	       removed = 0;
-	       for (i = 0; i < installed_pkgs->len; i++) {
-		    pkg_t *pkg = installed_pkgs->pkgs[i];
-		    if (!(pkg->state_flag & SF_USER)
-			&& !pkg_has_installed_dependents(conf, pkg->parent, pkg, NULL)) {
-			 removed++;
-			 ipkg_message(conf, IPKG_NOTICE, "Removing non-user leaf package %s\n");
-			 ipkg_remove_pkg(conf, pkg,0);
-                         done = 1;
-		    }
-	       }
-	  } while (removed);
-	  pkg_vec_free(installed_pkgs);
-     }
-
-     if ( done == 0 ) 
-        ipkg_message(conf, IPKG_NOTICE, "No packages removed.\n");
-
-     write_status_files_if_changed(conf);
-     return 0;
-}
-
-static int ipkg_purge_cmd(ipkg_conf_t *conf, int argc, char **argv)
-{
-     int i;
-     pkg_t *pkg;
-
-     global_conf = conf;
-     signal(SIGINT, sigint_handler);
-
-     pkg_info_preinstall_check(conf);
-
-     for (i=0; i < argc; i++) {
-	  if (conf->restrict_to_default_dest) {
-	       pkg = pkg_hash_fetch_installed_by_name_dest(&conf->pkg_hash,
-							   argv[i],
-							   conf->default_dest);
-	  } else {
-	       pkg = pkg_hash_fetch_installed_by_name(&conf->pkg_hash, argv[i]);
-	  }
-
-	  if (pkg == NULL) {
-	       ipkg_message(conf, IPKG_ERROR,
-			    "Package %s is not installed.\n", argv[i]);
-	       continue;
-	  }
-	  ipkg_purge_pkg(conf, pkg);
-     }
-
-     write_status_files_if_changed(conf);
-     return 0;
-}
-
-static int ipkg_flag_cmd(ipkg_conf_t *conf, int argc, char **argv)
-{
-     int i;
-     pkg_t *pkg;
-     const char *flags = argv[0];
-    
-     global_conf = conf;
-     signal(SIGINT, sigint_handler);
-
-     for (i=1; i < argc; i++) {
-	  if (conf->restrict_to_default_dest) {
-	       pkg = pkg_hash_fetch_installed_by_name_dest(&conf->pkg_hash,
-							   argv[i],
-							   conf->default_dest);
-	  } else {
-	       pkg = pkg_hash_fetch_installed_by_name(&conf->pkg_hash, argv[i]);
-	  }
-
-	  if (pkg == NULL) {
-	       ipkg_message(conf, IPKG_ERROR,
-			    "Package %s is not installed.\n", argv[i]);
-	       continue;
-	  }
-          if (( strcmp(flags,"hold")==0)||( strcmp(flags,"noprune")==0)||
-              ( strcmp(flags,"user")==0)||( strcmp(flags,"ok")==0)) {
-	      pkg->state_flag = pkg_state_flag_from_str(flags);
-          }
-/* pb_ asked this feature 03292004 */
-/* Actually I will use only this two, but this is an open for various status */
-          if (( strcmp(flags,"installed")==0)||( strcmp(flags,"unpacked")==0)){
-	      pkg->state_status = pkg_state_status_from_str(flags);
-          }
-	  ipkg_state_changed++;
-	  ipkg_message(conf, IPKG_NOTICE,
-		       "Setting flags for package %s to %s\n",
-		       pkg->name, flags);
-     }
-
-     write_status_files_if_changed(conf);
-     return 0;
-}
-
-static int ipkg_files_cmd(ipkg_conf_t *conf, int argc, char **argv)
-{
-     pkg_t *pkg;
-     str_list_t *installed_files;
-     str_list_elt_t *iter;
-     char *pkg_version;
-     size_t buff_len = 8192;
-     size_t used_len;
-     char *buff ;
-
-     buff = (char *)malloc(buff_len);
-     if ( buff == NULL ) {
-        fprintf( stderr,"%s: Unable to allocate memory \n",__FUNCTION__);
-        return ENOMEM;
-     }
- 
-     if (argc < 1) {
-	  return EINVAL;
-     }
-
-     pkg = pkg_hash_fetch_installed_by_name(&conf->pkg_hash,
-					    argv[0]);
-     if (pkg == NULL) {
-	  ipkg_message(conf, IPKG_ERROR,
-		       "Package %s not installed.\n", argv[0]);
-	  return 0;
-     }
-
-     installed_files = pkg_get_installed_files(pkg);
-     pkg_version = pkg_version_str_alloc(pkg);
-
-#ifndef IPKG_LIB
-     printf("Package %s (%s) is installed on %s and has the following files:\n",
-	    pkg->name, pkg_version, pkg->dest->name);
-     for (iter = installed_files->head; iter; iter = iter->next) {
-	  puts(iter->data);
-     }
-#else
-     if (buff) {
-     try_again:
-	  used_len = snprintf(buff, buff_len, "Package %s (%s) is installed on %s and has the following files:\n",
-			      pkg->name, pkg_version, pkg->dest->name) + 1;
-	  if (used_len > buff_len) {
-	       buff_len *= 2;
-	       buff = realloc (buff, buff_len);
-	       goto try_again;
-	  }
-	  for (iter = installed_files->head; iter; iter = iter->next) {
-	       used_len += strlen (iter->data) + 1;
-	       while (buff_len <= used_len) {
-		    buff_len *= 2;
-		    buff = realloc (buff, buff_len);
-	       }
-	       strncat(buff, iter->data, buff_len);
-	       strncat(buff, "\n", buff_len);
-	  } 
-	  if (ipkg_cb_list) ipkg_cb_list(pkg->name,
-					 buff,
-					 pkg_version_str_alloc(pkg),
-					 pkg->state_status,
-					 p_userdata);
-	  free(buff);
-     }
-#endif
-
-     free(pkg_version);
-     pkg_free_installed_files(pkg);
-
-     return 0;
-}
-
-static int ipkg_depends_cmd(ipkg_conf_t *conf, int argc, char **argv)
-{
-
-     if (argc > 0) {
-	  pkg_vec_t *available_pkgs = pkg_vec_alloc();
-	  const char *rel_str = "depends on";
-	  int i;
-     
-	  pkg_info_preinstall_check(conf);
-
-	  if (conf->query_all)
-	       pkg_hash_fetch_available(&conf->pkg_hash, available_pkgs);
-	  else
-	       pkg_hash_fetch_all_installed(&conf->pkg_hash, available_pkgs);
-	  for (i = 0; i < argc; i++) {
-	       const char *target = argv[i];
-	       int j;
-
-	       ipkg_message(conf, IPKG_ERROR, "target=%s\n", target);
-
-	       for (j = 0; j < available_pkgs->len; j++) {
-		    pkg_t *pkg = available_pkgs->pkgs[j];
-		    if (fnmatch(target, pkg->name, 0) == 0) {
-			 int k;
-			 int count = pkg->depends_count + pkg->pre_depends_count;
-			 ipkg_message(conf, IPKG_ERROR, "What %s (arch=%s) %s\n",
-				      target, pkg->architecture, rel_str);
-			 for (k = 0; k < count; k++) {
-			      compound_depend_t *cdepend = &pkg->depends[k];
-			      int l;
-			      for (l = 0; l < cdepend->possibility_count; l++) {
-				   depend_t *possibility = cdepend->possibilities[l];
-				   ipkg_message(conf, IPKG_ERROR, "    %s", possibility->pkg->name);
-				   if (conf->verbosity > 0) {
-					// char *ver = abstract_pkg_version_str_alloc(possibility->pkg); 
-					ipkg_message(conf, IPKG_NOTICE, " %s", possibility->version);
-					if (possibility->version) {
-					     char *typestr = NULL;
-					     switch (possibility->constraint) {
-					     case NONE: typestr = "none"; break;
-					     case EARLIER: typestr = "<"; break;
-					     case EARLIER_EQUAL: typestr = "<="; break;
-					     case EQUAL: typestr = "="; break;
-					     case LATER_EQUAL: typestr = ">="; break;
-					     case LATER: typestr = ">"; break;
-					     }
-					     ipkg_message(conf, IPKG_NOTICE, " (%s %s)", typestr, possibility->version);
-					}
-					// free(ver);
-				   }
-				   ipkg_message(conf, IPKG_ERROR, "\n");
-			      }
-			 }
-		    }
-	       }
-	  }
-	  pkg_vec_free(available_pkgs);
-     }
-     return 0;
-}
-
-enum what_field_type {
-  WHATDEPENDS,
-  WHATCONFLICTS,
-  WHATPROVIDES,
-  WHATREPLACES,
-  WHATRECOMMENDS,
-  WHATSUGGESTS
-};
-
-static int ipkg_what_depends_conflicts_cmd(ipkg_conf_t *conf, enum what_field_type what_field_type, int recursive, int argc, char **argv)
-{
-
-     if (argc > 0) {
-	  pkg_vec_t *available_pkgs = pkg_vec_alloc();
-	  const char *rel_str = NULL;
-	  int i;
-	  int changed;
-
-	  switch (what_field_type) {
-	  case WHATDEPENDS: rel_str = "depends on"; break;
-	  case WHATCONFLICTS: rel_str = "conflicts with"; break;
-	  case WHATSUGGESTS: rel_str = "suggests"; break;
-	  case WHATRECOMMENDS: rel_str = "recommends"; break;
-	  case WHATPROVIDES: rel_str = "provides"; break;
-	  case WHATREPLACES: rel_str = "replaces"; break;
-	  }
-     
-	  if (conf->query_all)
-	       pkg_hash_fetch_available(&conf->pkg_hash, available_pkgs);
-	  else
-	       pkg_hash_fetch_all_installed(&conf->pkg_hash, available_pkgs);
-
-	  /* mark the root set */
-	  pkg_vec_clear_marks(available_pkgs);
-	  ipkg_message(conf, IPKG_NOTICE, "Root set:\n");
-	  for (i = 0; i < argc; i++) {
-	       const char *dependee_pattern = argv[i];
-	       pkg_vec_mark_if_matches(available_pkgs, dependee_pattern);
-	  }
-	  for (i = 0; i < available_pkgs->len; i++) {
-	       pkg_t *pkg = available_pkgs->pkgs[i];
-	       if (pkg->state_flag & SF_MARKED) {
-		    /* mark the parent (abstract) package */
-		    pkg_mark_provides(pkg);
-		    ipkg_message(conf, IPKG_NOTICE, "  %s\n", pkg->name);
-	       }
-	  }
-
-	  ipkg_message(conf, IPKG_NOTICE, "What %s root set\n", rel_str);
-	  do {
-	       int j;
-	       changed = 0;
-
-	       for (j = 0; j < available_pkgs->len; j++) {
-		    pkg_t *pkg = available_pkgs->pkgs[j];
-		    int k;
-		    int count = ((what_field_type == WHATCONFLICTS)
-				 ? pkg->conflicts_count
-				 : pkg->pre_depends_count + pkg->depends_count + pkg->recommends_count + pkg->suggests_count);
-		    /* skip this package if it is already marked */
-		    if (pkg->parent->state_flag & SF_MARKED) {
-			 continue;
-		    }
-		    for (k = 0; k < count; k++) {
-			 compound_depend_t *cdepend = 
-			      (what_field_type == WHATCONFLICTS) ? &pkg->conflicts[k] : &pkg->depends[k];
-			 int l;
-			 for (l = 0; l < cdepend->possibility_count; l++) {
-			      depend_t *possibility = cdepend->possibilities[l];
-			      if (possibility->pkg->state_flag & SF_MARKED) {
-				   /* mark the depending package so we won't visit it again */
-				   pkg->state_flag |= SF_MARKED;
-				   pkg_mark_provides(pkg);
-				   changed++;
-
-				   ipkg_message(conf, IPKG_NOTICE, "    %s", pkg->name);
-				   if (conf->verbosity > 0) {
-					char *ver = pkg_version_str_alloc(pkg); 
-					ipkg_message(conf, IPKG_NOTICE, " %s", ver);
-					ipkg_message(conf, IPKG_NOTICE, "\t%s %s", rel_str, possibility->pkg->name);
-					if (possibility->version) {
-					     char *typestr = NULL;
-					     switch (possibility->constraint) {
-					     case NONE: typestr = "none"; break;
-					     case EARLIER: typestr = "<"; break;
-					     case EARLIER_EQUAL: typestr = "<="; break;
-					     case EQUAL: typestr = "="; break;
-					     case LATER_EQUAL: typestr = ">="; break;
-					     case LATER: typestr = ">"; break;
-					     }
-					     ipkg_message(conf, IPKG_NOTICE, " (%s %s)", typestr, possibility->version);
-					}
-					free(ver);
-					if (!pkg_dependence_satisfiable(conf, possibility))
-					     ipkg_message(conf, IPKG_NOTICE, " unsatisfiable");
-				   }
-				   ipkg_message(conf, IPKG_NOTICE, "\n");
-				   goto next_package;
-			      }
-			 }
-		    }
-	       next_package:
-		    ;
-	       }
-	  } while (changed && recursive);
-	  pkg_vec_free(available_pkgs);
-     }
-
-     return 0;
-}
-
-int pkg_mark_provides(pkg_t *pkg)
-{
-     int provides_count = pkg->provides_count;
-     abstract_pkg_t **provides = pkg->provides;
-     int i;
-     pkg->parent->state_flag |= SF_MARKED;
-     for (i = 0; i < provides_count; i++) {
-	  provides[i]->state_flag |= SF_MARKED;
-     }
-     return 0;
-}
-
-static int ipkg_whatdepends_recursively_cmd(ipkg_conf_t *conf, int argc, char **argv)
-{
-     return ipkg_what_depends_conflicts_cmd(conf, WHATDEPENDS, 1, argc, argv);
-}
-static int ipkg_whatdepends_cmd(ipkg_conf_t *conf, int argc, char **argv)
-{
-     return ipkg_what_depends_conflicts_cmd(conf, WHATDEPENDS, 0, argc, argv);
-}
-
-static int ipkg_whatsuggests_cmd(ipkg_conf_t *conf, int argc, char **argv)
-{
-     return ipkg_what_depends_conflicts_cmd(conf, WHATSUGGESTS, 0, argc, argv);
-}
-
-static int ipkg_whatrecommends_cmd(ipkg_conf_t *conf, int argc, char **argv)
-{
-     return ipkg_what_depends_conflicts_cmd(conf, WHATRECOMMENDS, 0, argc, argv);
-}
-
-static int ipkg_whatconflicts_cmd(ipkg_conf_t *conf, int argc, char **argv)
-{
-     return ipkg_what_depends_conflicts_cmd(conf, WHATCONFLICTS, 0, argc, argv);
-}
-
-static int ipkg_what_provides_replaces_cmd(ipkg_conf_t *conf, enum what_field_type what_field_type, int argc, char **argv)
-{
-
-     if (argc > 0) {
-	  pkg_vec_t *available_pkgs = pkg_vec_alloc();
-	  const char *rel_str = (what_field_type == WHATPROVIDES ? "provides" : "replaces");
-	  int i;
-     
-	  pkg_info_preinstall_check(conf);
-
-	  if (conf->query_all)
-	       pkg_hash_fetch_available(&conf->pkg_hash, available_pkgs);
-	  else
-	       pkg_hash_fetch_all_installed(&conf->pkg_hash, available_pkgs);
-	  for (i = 0; i < argc; i++) {
-	       const char *target = argv[i];
-	       int j;
-
-	       ipkg_message(conf, IPKG_ERROR, "What %s %s\n",
-			    rel_str, target);
-	       for (j = 0; j < available_pkgs->len; j++) {
-		    pkg_t *pkg = available_pkgs->pkgs[j];
-		    int k;
-		    int count = (what_field_type == WHATPROVIDES) ? pkg->provides_count : pkg->replaces_count;
-		    for (k = 0; k < count; k++) {
-			 abstract_pkg_t *apkg = 
-			      ((what_field_type == WHATPROVIDES) 
-			       ? pkg->provides[k]
-			       : pkg->replaces[k]);
-			 if (fnmatch(target, apkg->name, 0) == 0) {
-			      ipkg_message(conf, IPKG_ERROR, "    %s", pkg->name);
-			      if (strcmp(target, apkg->name) != 0)
-				   ipkg_message(conf, IPKG_ERROR, "\t%s %s\n", rel_str, apkg->name);
-			      ipkg_message(conf, IPKG_ERROR, "\n");
-			 }
-		    }
-	       }
-	  }
-	  pkg_vec_free(available_pkgs);
-     }
-     return 0;
-}
-
-static int ipkg_whatprovides_cmd(ipkg_conf_t *conf, int argc, char **argv)
-{
-     return ipkg_what_provides_replaces_cmd(conf, WHATPROVIDES, argc, argv);
-}
-
-static int ipkg_whatreplaces_cmd(ipkg_conf_t *conf, int argc, char **argv)
-{
-     return ipkg_what_provides_replaces_cmd(conf, WHATREPLACES, argc, argv);
-}
-
-static int ipkg_search_cmd(ipkg_conf_t *conf, int argc, char **argv)
-{
-     int i;
-
-     pkg_vec_t *installed;
-     pkg_t *pkg;
-     str_list_t *installed_files;
-     str_list_elt_t *iter;
-     char *installed_file;
-
-     if (argc < 1) {
-	  return EINVAL;
-     }
- 
-     installed = pkg_vec_alloc();
-     pkg_hash_fetch_all_installed(&conf->pkg_hash, installed);
-
-     for (i=0; i < installed->len; i++) {
-	  pkg = installed->pkgs[i];
-
-	  installed_files = pkg_get_installed_files(pkg);
-
-	  for (iter = installed_files->head; iter; iter = iter->next) {
-	       installed_file = iter->data;
-	       if (fnmatch(argv[0], installed_file, 0)==0)  {
-#ifndef IPKG_LIB
-		    printf("%s: %s\n", pkg->name, installed_file);
-#else
-			if (ipkg_cb_list) ipkg_cb_list(pkg->name, 
-						       installed_file, 
-			                               pkg_version_str_alloc(pkg), 
-			                               pkg->state_status, p_userdata);
-#endif			   
-	       }		
-	  }
-
-	  pkg_free_installed_files(pkg);
-     }
-
-     /* XXX: CLEANUP: It's not obvious from the name of
-	pkg_hash_fetch_all_installed that we need to call
-	pkg_vec_free to avoid a memory leak. */
-     pkg_vec_free(installed);
-
-     return 0;
-}
-
-static int ipkg_compare_versions_cmd(ipkg_conf_t *conf, int argc, char **argv)
-{
-     if (argc == 3) {
-	  /* this is a bit gross */
-	  struct pkg p1, p2;
-	  parseVersion(&p1, argv[0]); 
-	  parseVersion(&p2, argv[2]); 
-	  return pkg_version_satisfied(&p1, &p2, argv[1]);
-     } else {
-	  ipkg_message(conf, IPKG_ERROR,
-		       "ipkg compare_versions <v1> <op> <v2>\n"
-		       "<op> is one of <= >= << >> =\n");
-	  return -1;
-     }
-}
-
-#ifndef HOST_CPU_STR
-#define HOST_CPU_STR__(X) #X
-#define HOST_CPU_STR_(X) HOST_CPU_STR__(X)
-#define HOST_CPU_STR HOST_CPU_STR_(HOST_CPU_FOO)
-#endif
-
-static int ipkg_print_architecture_cmd(ipkg_conf_t *conf, int argc, char **argv)
-{
-     nv_pair_list_elt_t *l;
-
-     l = conf->arch_list.head;
-     while (l) {
-	  nv_pair_t *nv = l->data;
-	  printf("arch %s %s\n", nv->name, nv->value);
-	  l = l->next;
-     }
-     return 0;
-}
-
-

Deleted: trunk/src/target/ipkg/ipkg_cmd.h
===================================================================
--- trunk/src/target/ipkg/ipkg_cmd.h	2008-01-18 11:05:46 UTC (rev 3878)
+++ trunk/src/target/ipkg/ipkg_cmd.h	2008-01-18 11:28:48 UTC (rev 3879)
@@ -1,46 +0,0 @@
-/* ipkg_cmd.h - the itsy package management system
-
-   Carl D. Worth
-
-   Copyright (C) 2001 University of Southern California
-
-   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.
-*/
-
-#ifndef IPKG_CMD_H
-#define IPKG_CMD_H
-
-typedef int (*ipkg_cmd_fun_t)(ipkg_conf_t *conf, int argc, const char **argv);
-
-struct ipkg_cmd
-{
-    char *name;
-    int requires_args;
-    ipkg_cmd_fun_t fun;
-};
-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);
-#else
-int ipkg_cmd_exec(ipkg_cmd_t *cmd, ipkg_conf_t *conf, int argc, const char **argv);
-#endif
-int ipkg_multiple_files_scan (ipkg_conf_t *conf, int argc, char *argv[]);
-/* install any packges with state_want == SW_INSTALL */
-int ipkg_install_wanted_packages(ipkg_conf_t *conf);
-/* ensure that all dependences are satisfied */
-int ipkg_configure_packages(ipkg_conf_t *conf, char *pkg_name);
-
-int pkg_mark_provides(pkg_t *pkg);
-
-#endif

Deleted: trunk/src/target/ipkg/ipkg_conf.c
===================================================================
--- trunk/src/target/ipkg/ipkg_conf.c	2008-01-18 11:05:46 UTC (rev 3878)
+++ trunk/src/target/ipkg/ipkg_conf.c	2008-01-18 11:28:48 UTC (rev 3879)
@@ -1,717 +0,0 @@
-/* ipkg_conf.c - the itsy package management system
-
-   Carl D. Worth
-
-   Copyright (C) 2001 University of Southern California
-
-   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 <glob.h>
-
-#include "ipkg.h"
-#include "ipkg_conf.h"
-
-#include "xregex.h"
-#include "sprintf_alloc.h"
-#include "ipkg_conf.h"
-#include "ipkg_message.h"
-#include "file_util.h"
-#include "str_util.h"
-#include "xsystem.h"
-
-static int ipkg_conf_parse_file(ipkg_conf_t *conf, const char *filename,
-				pkg_src_list_t *pkg_src_list,
-				nv_pair_list_t *tmp_dest_nv_pair_list,
-				char **tmp_lists_dir);
-static int ipkg_init_options_array(const ipkg_conf_t *conf, ipkg_option_t **options);
-static int ipkg_conf_set_option(const ipkg_option_t *options,
-				const char *name, const char *value);
-static int ipkg_conf_set_default_dest(ipkg_conf_t *conf,
-				      const char *default_dest_name);
-static int set_and_load_pkg_src_list(ipkg_conf_t *conf,
-				     pkg_src_list_t *nv_pair_list);
-static int set_and_load_pkg_dest_list(ipkg_conf_t *conf,
-				      nv_pair_list_t *nv_pair_list, char * lists_dir);
-
-int ipkg_init_options_array(const ipkg_conf_t *conf, ipkg_option_t **options)
-{
-     ipkg_option_t tmp[] = {
-	  { "force_defaults", IPKG_OPT_TYPE_BOOL, &conf->force_defaults },
-	  { "force_depends", IPKG_OPT_TYPE_BOOL, &conf->force_depends },
-	  { "force_overwrite", IPKG_OPT_TYPE_BOOL, &conf->force_overwrite },
-	  { "force_downgrade", IPKG_OPT_TYPE_BOOL, &conf->force_downgrade },
-	  { "force_reinstall", IPKG_OPT_TYPE_BOOL, &conf->force_reinstall },
-	  { "force_space", IPKG_OPT_TYPE_BOOL, &conf->force_space },
-	  { "ftp_proxy", IPKG_OPT_TYPE_STRING, &conf->ftp_proxy },
-	  { "http_proxy", IPKG_OPT_TYPE_STRING, &conf->http_proxy },
-	  { "multiple_providers", IPKG_OPT_TYPE_BOOL, &conf->multiple_providers },
-	  { "no_proxy", IPKG_OPT_TYPE_STRING, &conf->no_proxy },
-	  { "test", IPKG_OPT_TYPE_INT, &conf->noaction },
-	  { "noaction", IPKG_OPT_TYPE_INT, &conf->noaction },
-	  { "nodeps", IPKG_OPT_TYPE_BOOL, &conf->nodeps },
-	  { "offline_root", IPKG_OPT_TYPE_STRING, &conf->offline_root },
-	  { "offline_root_post_script_cmd", IPKG_OPT_TYPE_STRING, &conf->offline_root_post_script_cmd },
-	  { "offline_root_pre_script_cmd", IPKG_OPT_TYPE_STRING, &conf->offline_root_pre_script_cmd },
-	  { "proxy_passwd", IPKG_OPT_TYPE_STRING, &conf->proxy_passwd },
-	  { "proxy_user", IPKG_OPT_TYPE_STRING, &conf->proxy_user },
-	  { "query-all", IPKG_OPT_TYPE_BOOL, &conf->query_all },
-	  { "verbose-wget", IPKG_OPT_TYPE_BOOL, &conf->verbose_wget },
-	  { "verbosity", IPKG_OPT_TYPE_BOOL, &conf->verbosity },
-	  { NULL }
-     };
-
-     *options = (ipkg_option_t *)malloc(sizeof(tmp));
-     if ( options == NULL ){
-        fprintf(stderr,"%s: Unable to allocate memory\n",__FUNCTION__);
-        return -1;
-     }
-
-     memcpy(*options, tmp, sizeof(tmp));
-     return 0;
-};
-
-static void ipkg_conf_override_string(char **conf_str, char *arg_str) 
-{
-     if (arg_str) {
-	  if (*conf_str) {
-	       free(*conf_str);
-	  }
-	  *conf_str = strdup(arg_str);
-     }
-}
-
-static void ipkg_conf_free_string(char **conf_str)
-{
-     if (*conf_str) {
-	  free(*conf_str);
-	  *conf_str = NULL;
-     }
-}
-
-int ipkg_conf_init(ipkg_conf_t *conf, const args_t *args)
-{
-     int err;
-     char *tmp_dir_base;
-     nv_pair_list_t tmp_dest_nv_pair_list;
-     char * lists_dir =NULL;
-     glob_t globbuf;
-     char *etc_ipkg_conf_pattern = "/etc/ipkg/*.conf";
-     char *pending_dir  =NULL;
-
-     memset(conf, 0, sizeof(ipkg_conf_t));
-
-     pkg_src_list_init(&conf->pkg_src_list);
-
-     nv_pair_list_init(&tmp_dest_nv_pair_list);
-     pkg_dest_list_init(&conf->pkg_dest_list);
-
-     nv_pair_list_init(&conf->arch_list);
-
-     conf->restrict_to_default_dest = 0;
-     conf->default_dest = NULL;
-
-
-     if (args->tmp_dir)
-	  tmp_dir_base = args->tmp_dir;
-     else 
-	  tmp_dir_base = getenv("TMPDIR");
-     sprintf_alloc(&conf->tmp_dir, "%s/%s",
-		   tmp_dir_base ? tmp_dir_base : IPKG_CONF_DEFAULT_TMP_DIR_BASE,
-		   IPKG_CONF_TMP_DIR_SUFFIX);
-     conf->tmp_dir = mkdtemp(conf->tmp_dir);
-     if (conf->tmp_dir == NULL) {
-	  fprintf(stderr, "%s: Failed to create temporary directory `%s': %s\n",
-		  __FUNCTION__, conf->tmp_dir, strerror(errno));
-	  return errno;
-     }
-
-     conf->force_depends = 0;
-     conf->force_defaults = 0;
-     conf->force_overwrite = 0;
-     conf->force_downgrade = 0;
-     conf->force_reinstall = 0;
-     conf->force_space = 0;
-     conf->force_removal_of_essential_packages = 0;
-     conf->force_removal_of_dependent_packages = 0;
-     conf->nodeps = 0;
-     conf->verbose_wget = 0;
-     conf->offline_root = NULL;
-     conf->offline_root_pre_script_cmd = NULL;
-     conf->offline_root_post_script_cmd = NULL;
-     conf->multiple_providers = 0;
-     conf->verbosity = 1;
-     conf->noaction = 0;
-
-     conf->http_proxy = NULL;
-     conf->ftp_proxy = NULL;
-     conf->no_proxy = NULL;
-     conf->proxy_user = NULL;
-     conf->proxy_passwd = NULL;
-
-     pkg_hash_init("pkg-hash", &conf->pkg_hash, IPKG_CONF_DEFAULT_HASH_LEN);
-     hash_table_init("file-hash", &conf->file_hash, IPKG_CONF_DEFAULT_HASH_LEN);
-     hash_table_init("obs-file-hash", &conf->obs_file_hash, IPKG_CONF_DEFAULT_HASH_LEN);
-     lists_dir=(char *)malloc(1);
-     lists_dir[0]='\0';
-     if (args->conf_file) {
-	  struct stat stat_buf;
-	  err = stat(args->conf_file, &stat_buf);
-	  if (err == 0)
-	       if (ipkg_conf_parse_file(conf, args->conf_file,
-				    &conf->pkg_src_list, &tmp_dest_nv_pair_list,&lists_dir)<0) {
-                   /* Memory leakage from ipkg_conf_parse-file */
-                   return -1;
-               }
-                   
-     }
-
-     /* if (!lists_dir ){*/
-     if (strlen(lists_dir)<=1 ){
-        lists_dir = realloc(lists_dir,strlen(IPKG_CONF_LISTS_DIR)+2);
-        sprintf (lists_dir,"%s",IPKG_CONF_LISTS_DIR);
-     }
-
-     if (args->offline_root) {
-            char *tmp = malloc(strlen(lists_dir) + strlen(args->offline_root) + 1);
-            sprintf_alloc(&tmp, "%s/%s",args->offline_root,lists_dir);
-            free(lists_dir);
-            lists_dir = tmp;
-     }
-
-     pending_dir = malloc(strlen(lists_dir)+strlen("/pending")+5);
-     snprintf(pending_dir,strlen(lists_dir)+strlen("/pending") ,"%s%s",lists_dir,"/pending");
-
-     conf->lists_dir = strdup(lists_dir);
-     conf->pending_dir = strdup(pending_dir);
-
-     if (args->offline_root) 
-	  sprintf_alloc(&etc_ipkg_conf_pattern, "%s/etc/ipkg/*.conf", args->offline_root);
-     memset(&globbuf, 0, sizeof(globbuf));
-     err = glob(etc_ipkg_conf_pattern, 0, NULL, &globbuf);
-     if (!err) {
-	  int i;
-	  for (i = 0; i < globbuf.gl_pathc; i++) {
-	       if (globbuf.gl_pathv[i]) 
-		    if ( ipkg_conf_parse_file(conf, globbuf.gl_pathv[i], 
-				         &conf->pkg_src_list, &tmp_dest_nv_pair_list,&lists_dir)<0) {
-                        /* Memory leakage from ipkg_conf_parse-file */
-                        return -1;
-	            }
-	  }
-     }
-     globfree(&globbuf);
-
-     /* if no architectures were defined, then default all, noarch, and host architecture */
-     if (nv_pair_list_empty(&conf->arch_list)) {
-	  nv_pair_list_append(&conf->arch_list, "all", "1");
-	  nv_pair_list_append(&conf->arch_list, "noarch", "1");
-	  nv_pair_list_append(&conf->arch_list, HOST_CPU_STR, "10");
-     }
-
-     /* Even if there is no conf file, we'll need at least one dest. */
-     if (tmp_dest_nv_pair_list.head == NULL) {
-	  nv_pair_list_append(&tmp_dest_nv_pair_list,
-			      IPKG_CONF_DEFAULT_DEST_NAME,
-			      IPKG_CONF_DEFAULT_DEST_ROOT_DIR);
-     }
-
-     /* After parsing the file, set options from command-line, (so that
-	command-line arguments take precedence) */
-     /* XXX: CLEANUP: The interaction between args.c and ipkg_conf.c
-	really needs to be cleaned up. There is so much duplication
-	right now it is ridiculous. Maybe ipkg_conf_t should just save
-	a pointer to args_t (which could then not be freed), rather
-	than duplicating every field here? */
-     if (args->force_depends) {
-	  conf->force_depends = 1;
-     }
-     if (args->force_defaults) {
-	  conf->force_defaults = 1;
-     }
-     if (args->force_overwrite) {
-	  conf->force_overwrite = 1;
-     }
-     if (args->force_downgrade) {
-	  conf->force_downgrade = 1;
-     }
-     if (args->force_reinstall) {
-	  conf->force_reinstall = 1;
-     }
-     if (args->force_removal_of_dependent_packages) {
-	  conf->force_removal_of_dependent_packages = 1;
-     }
-     if (args->force_removal_of_essential_packages) {
-	  conf->force_removal_of_essential_packages = 1;
-     }
-     if (args->nodeps) {
-	  conf->nodeps = 1;
-     }
-     if (args->noaction) {
-	  conf->noaction = 1;
-     }
-     if (args->query_all) {
-	  conf->query_all = 1;
-     }
-     if (args->verbose_wget) {
-	  conf->verbose_wget = 1;
-     }
-     if (args->multiple_providers) {
-	  conf->multiple_providers = 1;
-     }
-     if (args->verbosity != conf->verbosity) {
-	  conf->verbosity = args->verbosity;
-     } 
-
-     ipkg_conf_override_string(&conf->offline_root, 
-			       args->offline_root);
-     ipkg_conf_override_string(&conf->offline_root_pre_script_cmd, 
-			       args->offline_root_pre_script_cmd);
-     ipkg_conf_override_string(&conf->offline_root_post_script_cmd, 
-			       args->offline_root_post_script_cmd);
-
-/* Pigi: added a flag to disable the checking of structures if the command does not need to 
-         read anything from there.
-*/
-     if ( !(args->nocheckfordirorfile)){
-        /* need to run load the source list before dest list -Jamey */
-        if ( !(args->noreadfeedsfile))
-           set_and_load_pkg_src_list(conf, &conf->pkg_src_list);
-   
-        /* Now that we have resolved conf->offline_root, we can commit to
-	   the directory names for the dests and load in all the package
-	   lists. */
-        set_and_load_pkg_dest_list(conf, &tmp_dest_nv_pair_list,lists_dir);
-   
-        if (args->dest) {
-	     err = ipkg_conf_set_default_dest(conf, args->dest);
-	     if (err) {
-	          return err;
-	     }
-        }
-     }
-     nv_pair_list_deinit(&tmp_dest_nv_pair_list);
-     free(lists_dir);
-     free(pending_dir);
-
-     return 0;
-}
-
-void ipkg_conf_deinit(ipkg_conf_t *conf)
-{
-#ifdef IPKG_DEBUG_NO_TMP_CLEANUP
-#error
-     fprintf(stderr, "%s: Not cleaning up %s since ipkg compiled "
-	     "with IPKG_DEBUG_NO_TMP_CLEANUP\n",
-	     __FUNCTION__, conf->tmp_dir);
-#else
-     int err;
-
-     err = rmdir(conf->tmp_dir);
-     if (err) {
-	  if (errno == ENOTEMPTY) {
-	       char *cmd;
-	       sprintf_alloc(&cmd, "rm -fr %s\n", conf->tmp_dir);
-	       err = xsystem(cmd);
-	       free(cmd);
-	  }
-	  if (err)
-	       fprintf(stderr, "WARNING: Unable to remove temporary directory: %s: %s\n", conf->tmp_dir, strerror(errno));
-     }
-#endif /* IPKG_DEBUG_NO_TMP_CLEANUP */
-
-     free(conf->tmp_dir); /*XXX*/
-
-     pkg_src_list_deinit(&conf->pkg_src_list);
-     pkg_dest_list_deinit(&conf->pkg_dest_list);
-     nv_pair_list_deinit(&conf->arch_list);
-     if (&conf->pkg_hash)
-	            pkg_hash_deinit(&conf->pkg_hash);
-     if (&conf->file_hash)
-	            hash_table_deinit(&conf->file_hash);
-     if (&conf->obs_file_hash)
-	            hash_table_deinit(&conf->obs_file_hash);
-
-     ipkg_conf_free_string(&conf->offline_root);
-     ipkg_conf_free_string(&conf->offline_root_pre_script_cmd);
-     ipkg_conf_free_string(&conf->offline_root_post_script_cmd);
-
-     if (conf->verbosity > 1) { 
-	  int i;
-	  hash_table_t *hashes[] = {
-	       &conf->pkg_hash,
-	       &conf->file_hash,
-	       &conf->obs_file_hash };
-	  for (i = 0; i < 3; i++) {
-	       hash_table_t *hash = hashes[i];
-	       int c = 0;
-	       int n_conflicts = 0;
-	       int j;
-	       for (j = 0; j < hash->n_entries; j++) {
-		    int len = 0;
-		    hash_entry_t *e = &hash->entries[j];
-		    if (e->next)
-			 n_conflicts++;
-		    while (e && e->key) {
-			 len++;
-			 e = e->next;
-		    }
-		    if (len > c) 
-			 c = len;
-	       }
-	       ipkg_message(conf, IPKG_DEBUG, "hash_table[%s] n_buckets=%d n_elements=%d max_conflicts=%d n_conflicts=%d\n", 
-			    hash->name, hash->n_entries, hash->n_elements, c, n_conflicts);
-	       hash_table_deinit(hash);
-	  }
-     }
-}
-
-static int ipkg_conf_set_default_dest(ipkg_conf_t *conf,
-				      const char *default_dest_name)
-{
-     pkg_dest_list_elt_t *iter;
-     pkg_dest_t *dest;
-
-     for (iter = conf->pkg_dest_list.head; iter; iter = iter->next) {
-	  dest = iter->data;
-	  if (strcmp(dest->name, default_dest_name) == 0) {
-	       conf->default_dest = dest;
-	       conf->restrict_to_default_dest = 1;
-	       return 0;
-	  }
-     }
-
-     fprintf(stderr, "ERROR: Unknown dest name: `%s'\n", default_dest_name);
-
-     return 1;
-}
-
-static int set_and_load_pkg_src_list(ipkg_conf_t *conf, pkg_src_list_t *pkg_src_list)
-{
-     pkg_src_list_elt_t *iter;
-     pkg_src_t *src;
-     char *list_file;
-
-     for (iter = pkg_src_list->head; iter; iter = iter->next) {
-          src = iter->data;
-	  if (src == NULL) {
-	       continue;
-	  }
-
-	  sprintf_alloc(&list_file, "%s/%s", 
-			  conf->restrict_to_default_dest ? conf->default_dest->lists_dir : conf->lists_dir, 
-			  src->name);
-
-	  if (file_exists(list_file)) {
-	       pkg_hash_add_from_file(conf, list_file, src, NULL, 0);
-	  }
-	  free(list_file);
-     }
-
-     return 0;
-}
-
-static int set_and_load_pkg_dest_list(ipkg_conf_t *conf, nv_pair_list_t *nv_pair_list, char *lists_dir )
-{
-     nv_pair_list_elt_t *iter;
-     nv_pair_t *nv_pair;
-     pkg_dest_t *dest;
-     char *root_dir;
-
-     for (iter = nv_pair_list->head; iter; iter = iter->next) {
-	  nv_pair = iter->data;
-
-	  if (conf->offline_root) {
-	       sprintf_alloc(&root_dir, "%s%s", conf->offline_root, nv_pair->value);
-	  } else {
-	       root_dir = strdup(nv_pair->value);
-	  }
-	  dest = pkg_dest_list_append(&conf->pkg_dest_list, nv_pair->name, root_dir, lists_dir);
-	  free(root_dir);
-	  if (dest == NULL) {
-	       continue;
-	  }
-	  if (conf->default_dest == NULL) {
-	       conf->default_dest = dest;
-	  }
-	  if (file_exists(dest->status_file_name)) {
-	       pkg_hash_add_from_file(conf, dest->status_file_name,
-				      NULL, dest, 1);
-	  }
-     }
-
-     return 0;
-}
-
-static int ipkg_conf_parse_file(ipkg_conf_t *conf, const char *filename,
-				pkg_src_list_t *pkg_src_list,
-				nv_pair_list_t *tmp_dest_nv_pair_list,
-				char **lists_dir)
-{
-     int err;
-     ipkg_option_t * options;
-     FILE *file = fopen(filename, "r");
-     regex_t valid_line_re, comment_re;
-#define regmatch_size 12
-     regmatch_t regmatch[regmatch_size];
-
-     if (ipkg_init_options_array(conf, &options)<0)
-        return ENOMEM;
-
-     if (file == NULL) {
-	  fprintf(stderr, "%s: failed to open %s: %s\n",
-		  __FUNCTION__, filename, strerror(errno));
-	  free(options);
-	  return errno;
-     }
-     ipkg_message(conf, IPKG_NOTICE, "loading conf file %s\n", filename);
-
-     err = xregcomp(&comment_re, 
-		    "^[[:space:]]*(#.*|[[:space:]]*)$",
-		    REG_EXTENDED);
-     if (err) {
-	  free(options);
-	  return err;
-     }
-     err = xregcomp(&valid_line_re, "^[[:space:]]*(\"([^\"]*)\"|([^[:space:]]*))[[:space:]]*(\"([^\"]*)\"|([^[:space:]]*))[[:space:]]*(\"([^\"]*)\"|([^[:space:]]*))([[:space:]]+([^[:space:]]+))?[[:space:]]*$", REG_EXTENDED);
-     if (err) {
-	  free(options);
-	  return err;
-     }
-
-     while(1) {
-	  int line_num = 0;
-	  char *line;
-	  char *type, *name, *value, *extra;
-
-	  line = file_read_line_alloc(file);
-	  line_num++;
-	  if (line == NULL) {
-	       break;
-	  }
-
-	  str_chomp(line);
-
-	  if (regexec(&comment_re, line, 0, 0, 0) == 0) {
-	       goto NEXT_LINE;
-	  }
-
-	  if (regexec(&valid_line_re, line, regmatch_size, regmatch, 0) == REG_NOMATCH) {
-	       str_chomp(line);
-	       fprintf(stderr, "%s:%d: Ignoring invalid line: `%s'\n",
-		       filename, line_num, line);
-	       goto NEXT_LINE;
-	  }
-
-	  /* This has to be so ugly to deal with optional quotation marks */
-	  if (regmatch[2].rm_so > 0) {
-	       type = strndup(line + regmatch[2].rm_so,
-			      regmatch[2].rm_eo - regmatch[2].rm_so);
-	  } else {
-	       type = strndup(line + regmatch[3].rm_so,
-			      regmatch[3].rm_eo - regmatch[3].rm_so);
-	  }
-	  if (regmatch[5].rm_so > 0) {
-	       name = strndup(line + regmatch[5].rm_so,
-			      regmatch[5].rm_eo - regmatch[5].rm_so);
-	  } else {
-	       name = strndup(line + regmatch[6].rm_so,
-			      regmatch[6].rm_eo - regmatch[6].rm_so);
-	  }
-	  if (regmatch[8].rm_so > 0) {
-	       value = strndup(line + regmatch[8].rm_so,
-			       regmatch[8].rm_eo - regmatch[8].rm_so);
-	  } else {
-	       value = strndup(line + regmatch[9].rm_so,
-			       regmatch[9].rm_eo - regmatch[9].rm_so);
-	  }
-	  extra = NULL;
-	  if (regmatch[11].rm_so > 0) {
-	       extra = strndup (line + regmatch[11].rm_so,
-				regmatch[11].rm_eo - regmatch[11].rm_so);
-	  }
-
-	  /* We use the tmp_dest_nv_pair_list below instead of
-	     conf->pkg_dest_list because we might encounter an
-	     offline_root option later and that would invalidate the
-	     directories we would have computed in
-	     pkg_dest_list_init. (We do a similar thing with
-	     tmp_src_nv_pair_list for sake of symmetry.) */
-	  if (strcmp(type, "option") == 0) {
-	       ipkg_conf_set_option(options, name, value);
-	  } else if (strcmp(type, "src") == 0) {
-	       if (!nv_pair_list_find(pkg_src_list, name)) {
-		    pkg_src_list_append (pkg_src_list, name, value, extra, 0);
-	       } else {
-		    ipkg_message(conf, IPKG_ERROR, "ERROR: duplicate src declaration.  Skipping:\n\t src %s %s\n",
-				 name, value);
-	       }
-	  } else if (strcmp(type, "src/gz") == 0) {
-	       if (!nv_pair_list_find(pkg_src_list, name)) {
-		    pkg_src_list_append (pkg_src_list, name, value, extra, 1);
-	       } else {
-		    ipkg_message(conf, IPKG_ERROR, "ERROR: duplicate src declaration.  Skipping:\n\t src %s %s\n",
-				 name, value);
-	       }
-	  } else if (strcmp(type, "dest") == 0) {
-	       nv_pair_list_append(tmp_dest_nv_pair_list, name, value);
-	  } else if (strcmp(type, "lists_dir") == 0) {
-	       *lists_dir = realloc(*lists_dir,strlen(value)+1);
-               if (*lists_dir == NULL) {
-		    ipkg_message(conf, IPKG_ERROR, "ERROR: Not enough memory\n");
-	            free(options);
-	            return EINVAL;
-               }
-               sprintf (*lists_dir,"%s",value);
-	  } else if (strcmp(type, "arch") == 0) {
-	       ipkg_message(conf, IPKG_INFO, "supported arch %s priority (%s)\n", name, value);
-	       if (!value) {
-		    ipkg_message(conf, IPKG_NOTICE, "defaulting architecture %s priority to 10\n", name);
-		    value = strdup("10");
-	       }
-	       nv_pair_list_append(&conf->arch_list, strdup(name), strdup(value));
-	  } else {
-	       fprintf(stderr, "WARNING: Ignoring unknown configuration "
-		       "parameter: %s %s %s\n", type, name, value);
-	       free(options);
-	       return EINVAL;
-	  }
-
-	  free(type);
-	  free(name);
-	  free(value);
-	  if (extra)
-	       free (extra);
-
-     NEXT_LINE:
-	  free(line);
-     }
-
-     free(options);
-     regfree(&comment_re);
-     regfree(&valid_line_re);
-     fclose(file);
-
-     return 0;
-}
-
-static int ipkg_conf_set_option(const ipkg_option_t *options,
-				const char *name, const char *value)
-{
-     int i = 0;
-     while (options[i].name) {
-	  if (strcmp(options[i].name, name) == 0) {
-	       switch (options[i].type) {
-	       case IPKG_OPT_TYPE_BOOL:
-		    *((int *)options[i].value) = 1;
-		    return 0;
-	       case IPKG_OPT_TYPE_INT:
-		    if (value) {
-			 *((int *)options[i].value) = atoi(value);
-			 return 0;
-		    } else {
-			 printf("%s: Option %s need an argument\n",
-				__FUNCTION__, name);
-			 return EINVAL;
-		    }		    
-	       case IPKG_OPT_TYPE_STRING:
-		    if (value) {
-			 *((char **)options[i].value) = strdup(value);
-			 return 0;
-		    } else {
-			 printf("%s: Option %s need an argument\n",
-				__FUNCTION__, name);
-			 return EINVAL;
-		    }
-	       }
-	  }
-	  i++;
-     }
-    
-     fprintf(stderr, "%s: Unrecognized option: %s=%s\n",
-	     __FUNCTION__, name, value);
-     return EINVAL;
-}
-
-int ipkg_conf_write_status_files(ipkg_conf_t *conf)
-{
-     pkg_dest_list_elt_t *iter;
-     pkg_dest_t *dest;
-     pkg_vec_t *all;
-     pkg_t *pkg;
-     register int i;
-     int err;
-
-     if (conf->noaction)
-	  return 0;
-     for (iter = conf->pkg_dest_list.head; iter; iter = iter->next) {
-	  dest = iter->data;
-	  dest->status_file = fopen(dest->status_file_tmp_name, "w");
-	  if (dest->status_file == NULL) {
-	       fprintf(stderr, "%s: Can't open status file: %s for writing: %s\n",
-		       __FUNCTION__, dest->status_file_name, strerror(errno));
-	  }
-     }
-
-     all = pkg_vec_alloc();
-     pkg_hash_fetch_available(&conf->pkg_hash, all);
-
-     for(i = 0; i < all->len; i++) {
-	  pkg = all->pkgs[i];
-	  /* We don't need most uninstalled packages in the status file */
-	  if (pkg->state_status == SS_NOT_INSTALLED
-	      && (pkg->state_want == SW_UNKNOWN
-		  || pkg->state_want == SW_DEINSTALL
-		  || pkg->state_want == SW_PURGE)) {
-	       continue;
-	  }
-	  if (!pkg) {
-	    fprintf(stderr, "Null package\n");
-	  }
-	  if (pkg->dest == NULL) {
-	       fprintf(stderr, "%s: ERROR: Can't write status for "
-		       "package %s since it has a NULL dest\n",
-		       __FUNCTION__, pkg->name);
-	       continue;
-	  }
-	  if (pkg->dest->status_file) {
-	       pkg_print_status(pkg, pkg->dest->status_file);
-	  }
-     }
-
-     pkg_vec_free(all);
-
-     for (iter = conf->pkg_dest_list.head; iter; iter = iter->next) {
-	  dest = iter->data;
-	  if (dest->status_file) {
-	       err = ferror(dest->status_file);
-	       fclose(dest->status_file);
-	       dest->status_file = NULL;
-	       if (!err) {
-		    file_move(dest->status_file_tmp_name, dest->status_file_name);
-	       } else {
-		    fprintf(stderr, "%s: ERROR: An error has occurred writing %s, "
-			    "retaining old %s\n", __FUNCTION__, 
-			    dest->status_file_tmp_name, dest->status_file_name);
-	       }
-	  }
-     }
-
-     return 0;
-}
-
-
-char *root_filename_alloc(ipkg_conf_t *conf, char *filename)
-{
-     char *root_filename;
-     sprintf_alloc(&root_filename, "%s%s", (conf->offline_root ? conf->offline_root : ""), filename);
-     return root_filename;
-}

Deleted: trunk/src/target/ipkg/ipkg_conf.h
===================================================================
--- trunk/src/target/ipkg/ipkg_conf.h	2008-01-18 11:05:46 UTC (rev 3878)
+++ trunk/src/target/ipkg/ipkg_conf.h	2008-01-18 11:28:48 UTC (rev 3879)
@@ -1,107 +0,0 @@
-/* ipkg_conf.h - the itsy package management system
-
-   Carl D. Worth
-
-   Copyright (C) 2001 University of Southern California
-
-   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.
-*/
-
-#ifndef IPKG_CONF_H
-#define IPKG_CONF_H
-
-typedef struct ipkg_conf ipkg_conf_t;
-
-#include "hash_table.h"
-#include "ipkg.h"
-#include "args.h"
-#include "pkg.h"
-#include "pkg_hash.h"
-#include "pkg_src_list.h"
-#include "pkg_dest_list.h"
-#include "nv_pair_list.h"
-
-#define IPKG_CONF_DEFAULT_TMP_DIR_BASE "/tmp"
-#define IPKG_CONF_TMP_DIR_SUFFIX "ipkg-XXXXXX"
-#define IPKG_CONF_LISTS_DIR  IPKG_STATE_DIR_PREFIX "/lists"
-#define IPKG_CONF_PENDING_DIR IPKG_STATE_DIR_PREFIX "/pending"
-
-/* In case the config file defines no dest */
-#define IPKG_CONF_DEFAULT_DEST_NAME "root"
-#define IPKG_CONF_DEFAULT_DEST_ROOT_DIR "/"
-
-#define IPKG_CONF_DEFAULT_HASH_LEN 1024
-
-struct ipkg_conf
-{
-     pkg_src_list_t pkg_src_list;
-     pkg_dest_list_t pkg_dest_list;
-     nv_pair_list_t arch_list;
-
-     int restrict_to_default_dest;
-     pkg_dest_t *default_dest;
-
-     char *tmp_dir;
-     const char *lists_dir;
-     const char *pending_dir;
-
-     /* options */
-     int force_depends;
-     int force_defaults;
-     int force_overwrite;
-     int force_downgrade;
-     int force_reinstall;
-     int force_space;
-     int force_removal_of_dependent_packages;
-     int force_removal_of_essential_packages;
-     int nodeps; /* do not follow dependences */
-     int verbose_wget;
-     int multiple_providers;
-     char *offline_root;
-     char *offline_root_pre_script_cmd;
-     char *offline_root_post_script_cmd;
-     int query_all;
-     int verbosity;
-     int noaction;
-
-     /* proxy options */
-     char *http_proxy;
-     char *ftp_proxy;
-     char *no_proxy;
-     char *proxy_user;
-     char *proxy_passwd;
-
-     hash_table_t pkg_hash;
-     hash_table_t file_hash;
-     hash_table_t obs_file_hash;
-};
-
-enum ipkg_option_type {
-     IPKG_OPT_TYPE_BOOL,
-     IPKG_OPT_TYPE_INT,
-     IPKG_OPT_TYPE_STRING
-};
-typedef enum ipkg_option_type ipkg_option_type_t;
-
-typedef struct ipkg_option ipkg_option_t;
-struct ipkg_option {
-     const char *name;
-     const ipkg_option_type_t type;
-     const void *value;
-};
-
-int ipkg_conf_init(ipkg_conf_t *conf, const args_t *args);
-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

Deleted: trunk/src/target/ipkg/ipkg_configure.c
===================================================================
--- trunk/src/target/ipkg/ipkg_configure.c	2008-01-18 11:05:46 UTC (rev 3878)
+++ trunk/src/target/ipkg/ipkg_configure.c	2008-01-18 11:28:48 UTC (rev 3879)
@@ -1,40 +0,0 @@
-/* ipkg_configure.c - the itsy package management system
-
-   Carl D. Worth
-
-   Copyright (C) 2001 University of Southern California
-
-   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 "ipkg_configure.h"
-
-int ipkg_configure(ipkg_conf_t *conf, pkg_t *pkg)
-{
-    int err;
-
-    /* DPKG_INCOMPATIBILITY:
-       dpkg actually does some conffile handling here, rather than at the
-       end of ipkg_install(). Do we care? */
-    /* DPKG_INCOMPATIBILITY:
-       dpkg actually includes a version number to this script call */
-    err = pkg_run_script(conf, pkg, "postinst", "configure");
-    if (err) {
-	printf("ERROR: %s.postinst returned %d\n", pkg->name, err);
-	return err;
-    }
-
-    ipkg_state_changed++;
-    return 0;
-}
-

Deleted: trunk/src/target/ipkg/ipkg_configure.h
===================================================================
--- trunk/src/target/ipkg/ipkg_configure.h	2008-01-18 11:05:46 UTC (rev 3878)
+++ trunk/src/target/ipkg/ipkg_configure.h	2008-01-18 11:28:48 UTC (rev 3879)
@@ -1,25 +0,0 @@
-/* ipkg_configure.h - the itsy package management system
-
-   Carl D. Worth
-
-   Copyright (C) 2001 University of Southern California
-
-   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.
-*/
-
-#ifndef IPKG_CONFIGURE_H
-#define IPKG_CONFIGURE_H
-
-#include "ipkg_conf.h"
-
-int ipkg_configure(ipkg_conf_t *ipkg_conf, pkg_t *pkg);
-
-#endif

Deleted: trunk/src/target/ipkg/ipkg_download.c
===================================================================
--- trunk/src/target/ipkg/ipkg_download.c	2008-01-18 11:05:46 UTC (rev 3878)
+++ trunk/src/target/ipkg/ipkg_download.c	2008-01-18 11:28:48 UTC (rev 3879)
@@ -1,244 +0,0 @@
-/* vi: set noexpandtab sw=4 sts=4: */
-/* ipkg_download.c - the itsy package management system
-
-   Carl D. Worth
-
-   Copyright (C) 2001 University of Southern California
-   Copyright (C) 2008 OpenMoko Inc
-
-   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 <curl/curl.h>
-
-#include "ipkg.h"
-#include "ipkg_download.h"
-#include "ipkg_message.h"
-
-#include "sprintf_alloc.h"
-#include "xsystem.h"
-#include "file_util.h"
-#include "str_util.h"
-
-
-int
-curl_progress_func (void* data,
-                         double t, /* dltotal */
-                         double d, /* dlnow */
-                         double ultotal,
-                         double ulnow)
-{
-    int i;
-    int p = d*100/t;
-    printf ("\r%3d%% |", p);
-    for (i = 1; i < 73; i++)
-    {
-	if (i <= p)
-	    printf ("=");
-	else
-	    printf ("-");
-    }
-    printf ("|");
-    fflush(stdout);
-    return 0;
-}
-
-int ipkg_download(ipkg_conf_t *conf, const char *src, const char *dest_file_name)
-{
-    int err = 0;
-
-    char *src_basec = strdup(src);
-    char *src_base = basename(src_basec);
-    char *tmp_file_location;
-    char *cmd;
-
-    ipkg_message(conf,IPKG_NOTICE,"Downloading %s\n", src);
-	
-    fflush(stdout);
-    
-    if (str_starts_with(src, "file:")) {
-	int ret;
-	const char *file_src = src + 5;
-	ipkg_message(conf,IPKG_INFO,"Copying %s to %s...", file_src, dest_file_name);
-	ret = file_copy(src + 5, dest_file_name);
-	ipkg_message(conf,IPKG_INFO,"Done\n");
-	return ret;
-    }
-
-    sprintf_alloc(&tmp_file_location, "%s/%s", conf->tmp_dir, src_base);
-    err = unlink(tmp_file_location);
-    if (err && errno != ENOENT) {
-	ipkg_message(conf,IPKG_ERROR, "%s: ERROR: failed to unlink %s: %s\n",
-		__FUNCTION__, tmp_file_location, strerror(errno));
-	free(tmp_file_location);
-	return errno;
-    }
-
-    if (conf->http_proxy) {
-	ipkg_message(conf,IPKG_DEBUG,"Setting environment variable: http_proxy = %s\n", conf->http_proxy);
-	setenv("http_proxy", conf->http_proxy, 1);
-    }
-    if (conf->ftp_proxy) {
-	ipkg_message(conf,IPKG_DEBUG,"Setting environment variable: ftp_proxy = %s\n", conf->ftp_proxy);
-	setenv("ftp_proxy", conf->ftp_proxy, 1);
-    }
-    if (conf->no_proxy) {
-	ipkg_message(conf,IPKG_DEBUG,"Setting environment variable: no_proxy = %s\n", conf->no_proxy);
-	setenv("no_proxy", conf->no_proxy, 1);
-    }
-
-    /* XXX: BUG rewrite to use execvp or else busybox's internal wget -Jamey 7/23/2002 */ 
-#if 0
-    sprintf_alloc(&cmd, "wget --passive-ftp %s %s%s %s%s %s -P %s %s",
-		  (conf->http_proxy || conf->ftp_proxy) ? "--proxy=on" : "",
-		  conf->proxy_user ? "--proxy-user=" : "",
-		  conf->proxy_user ? conf->proxy_user : "",
-		  conf->proxy_passwd ? "--proxy-passwd=" : "",
-		  conf->proxy_passwd ? conf->proxy_passwd : "",
-		  conf->verbose_wget ? "" : "-q",
-		  conf->tmp_dir,
-		  src);
-    err = xsystem(cmd);
-    if (err) {
-	if (err != -1) {
-	    ipkg_message(conf,IPKG_ERROR, "%s: ERROR: Command failed with return value %d: `%s'\n",
-		    __FUNCTION__, err, cmd);
-	} 
-	unlink(tmp_file_location);
-	free(tmp_file_location);
-	free(src_basec);
-	free(cmd);
-	return EINVAL;
-    }
-    free(cmd);
-#endif
-    CURL *curl;
-    CURLcode res;
-    FILE * file = fopen (tmp_file_location, "w");
-
-    curl = curl_easy_init ();
-    if (curl)
-    {
-	curl_easy_setopt (curl, CURLOPT_URL, src);
-	curl_easy_setopt (curl, CURLOPT_WRITEDATA, file);
-	curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0);
-	curl_easy_setopt (curl, CURLOPT_PROGRESSFUNCTION, curl_progress_func);
-	res = curl_easy_perform (curl);
-	curl_easy_cleanup (curl);
-	fclose (file);
-
-    }
-    else
-	return -1;
-
-    printf ("\n");
-
-    err = file_move(tmp_file_location, dest_file_name);
-
-    free(tmp_file_location);
-    free(src_basec);
-
-    if (err) {
-	return err;
-    }
-
-    return 0;
-}
-
-int ipkg_download_pkg(ipkg_conf_t *conf, pkg_t *pkg, const char *dir)
-{
-    int err;
-    char *url;
-
-    if (pkg->src == NULL) {
-	ipkg_message(conf,IPKG_ERROR, "ERROR: Package %s (parent %s) is not available from any configured src.\n",
-		pkg->name, pkg->parent->name);
-	return -1;
-    }
-
-    sprintf_alloc(&url, "%s/%s", pkg->src->value, pkg->filename);
-
-    /* XXX: BUG: The pkg->filename might be something like
-       "../../foo.ipk". While this is correct, and exactly what we
-       want to use to construct url above, here we actually need to
-       use just the filename part, without any directory. */
-    sprintf_alloc(&pkg->local_filename, "%s/%s", dir, pkg->filename);
-
-    err = ipkg_download(conf, url, pkg->local_filename);
-    free(url);
-
-    return err;
-}
-
-/*
- * Downloads file from url, installs in package database, return package name. 
- */
-int ipkg_prepare_url_for_install(ipkg_conf_t *conf, const char *url, char **namep)
-{
-     int err = 0;
-     pkg_t *pkg;
-     pkg = pkg_new();
-     if (pkg == NULL)
-	  return ENOMEM;
-
-     if (str_starts_with(url, "http://")
-	 || str_starts_with(url, "ftp://")) {
-	  char *tmp_file;
-	  char *file_basec = strdup(url);
-	  char *file_base = basename(file_basec);
-
-	  sprintf_alloc(&tmp_file, "%s/%s", conf->tmp_dir, file_base);
-	  err = ipkg_download(conf, url, tmp_file);
-	  if (err)
-	       return err;
-
-	  err = pkg_init_from_file(pkg, tmp_file);
-	  if (err)
-	       return err;
-	  pkg->local_filename = strdup(tmp_file);
-
-	  free(tmp_file);
-	  free(file_basec);
-
-     } else if (strcmp(&url[strlen(url) - 4], IPKG_PKG_EXTENSION) == 0
-		|| strcmp(&url[strlen(url) - 4], DPKG_PKG_EXTENSION) == 0) {
-
-	  err = pkg_init_from_file(pkg, url);
-	  if (err)
-	       return err;
-	  pkg->local_filename = strdup(url);
-	  ipkg_message(conf, IPKG_DEBUG2, "Package %s provided by hand \(%s\).\n", pkg->name,pkg->local_filename);
-          pkg->provided_by_hand = 1;
-
-     } else {
-       pkg_deinit(pkg);
-       free(pkg);
-       return 0;
-     }
-
-     if (!pkg->architecture) {
-	  ipkg_message(conf, IPKG_ERROR, "Package %s has no Architecture defined.\n", pkg->name);
-	  return -EINVAL;
-     }
-
-     pkg->dest = conf->default_dest;
-     pkg->state_want = SW_INSTALL;
-     pkg->state_flag |= SF_PREFER;
-     pkg = hash_insert_pkg(&conf->pkg_hash, pkg, 1,conf);  
-     if ( pkg == NULL ){
-        fprintf(stderr, "%s : This should never happen. Report this Bug in bugzilla please \n ",__FUNCTION__);
-        return 0;
-     }
-     if (namep) {
-	  *namep = strdup(pkg->name);
-     }
-     return 0;
-}

Deleted: trunk/src/target/ipkg/ipkg_download.h
===================================================================
--- trunk/src/target/ipkg/ipkg_download.h	2008-01-18 11:05:46 UTC (rev 3878)
+++ trunk/src/target/ipkg/ipkg_download.h	2008-01-18 11:28:48 UTC (rev 3879)
@@ -1,30 +0,0 @@
-/* ipkg_download.h - the itsy package management system
-
-   Carl D. Worth
-
-   Copyright (C) 2001 University of Southern California
-
-   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.
-*/
-
-#ifndef IPKG_DOWNLOAD_H
-#define IPKG_DOWNLOAD_H
-
-#include "ipkg_conf.h"
-
-int ipkg_download(ipkg_conf_t *conf, const char *src, const char *dest_file_name);
-int ipkg_download_pkg(ipkg_conf_t *conf, pkg_t *pkg, const char *dir);
-/*
- * Downloads file from url, installs in package database, return package name. 
- */
-int ipkg_prepare_url_for_install(ipkg_conf_t *conf, const char *url, char **namep);
-
-#endif

Deleted: trunk/src/target/ipkg/ipkg_extract_test.c
===================================================================
--- trunk/src/target/ipkg/ipkg_extract_test.c	2008-01-18 11:05:46 UTC (rev 3878)
+++ trunk/src/target/ipkg/ipkg_extract_test.c	2008-01-18 11:28:48 UTC (rev 3879)
@@ -1,46 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include "libbb/libbb.h"
-
-/*
- * build thus: 
-
- * gcc -o ipkg_extract_test ipkg_extract_test.c -I./busybox-0.60.2/libbb -L./busybox-0.60.2 -lbb
- *
- */
-const char * applet_name;
-
-int main(int argc, char * argv[])
-{
-  /*
-   * see libbb.h and let your imagination run wild
-   * or, set the last item below to extract_one_to_buffer, and you get the control file in 
-   * "returned"
-   * or, set the last one to extract_all_to_fs, and, well, guess what happens
-   */
-
-    /* enum extract_functions_e dowhat = extract_control_tar_gz | extract_unconditional | extract_one_to_buffer; */
-    enum extract_functions_e dowhat = extract_control_tar_gz | extract_all_to_fs | extract_preserve_date;
-  char * returned;
-  char * filename;
-  
-  if(argc < 2){
-    fprintf(stderr, "syntax: %s <ipkg file> [<file_to_extract>]\n", argv[0]);
-    exit(0);
-  }
-  
-  if (argc < 3){
-    filename=NULL;
-  } else {
-    filename = argv[2];
-  }
-
-  returned = deb_extract(argv[1], stdout, dowhat, NULL, filename);
-  
-  if(returned)
-    fprintf(stderr, "returned %s\n", returned);
-  else
-    fprintf(stderr, "extract returned nuthin'\n");
-
-  return 0;
-}

Deleted: trunk/src/target/ipkg/ipkg_hash_test.c
===================================================================
--- trunk/src/target/ipkg/ipkg_hash_test.c	2008-01-18 11:05:46 UTC (rev 3878)
+++ trunk/src/target/ipkg/ipkg_hash_test.c	2008-01-18 11:28:48 UTC (rev 3879)
@@ -1,79 +0,0 @@
-/* ipkg_hash_test.c - the itsy package management system
-
-   Carl D. Worth
-
-   Copyright (C) 2001 University of Southern California
-
-   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 "hash_table.h"
-#include "ipkg_utils.h"
-#include "pkg_hash.h"
-
-int main(int argc, char *argv[])
-{
-     ipkg_conf_t conf;
-     hash_table_t *hash = &conf.pkg_hash;
-     pkg_vec_t * pkg_vec;
-
-    if (argc < 3) {
-	fprintf(stderr, "Usage: %s <pkgs_file1> <pkgs_file2> [pkg_name...]\n", argv[0]);
-	exit(1);
-    }
-    pkg_hash_init("test", hash, 1024);
-
-    pkg_hash_add_from_file(&conf, argv[1], NULL, NULL, 0);
-    pkg_hash_add_from_file(&conf, argv[2], NULL, NULL, 0);
-
-    if (argc < 4) {
-	pkg_print_info( pkg_hash_fetch_by_name_version(hash, "libc6", "2.2.3-2"), stdout);
-	/*	for(i = 0; i < pkg_vec->len; i++)
-		pkg_print(pkg_vec->pkgs[i], stdout);
-	*/
-    } else {
-	int i, j, k;
-	char **unresolved;
-
-	pkg_vec_t * dep_vec;
-	for (i = 3; i < argc; i++) {
-	    pkg_vec = pkg_vec_fetch_by_name(hash, argv[i]);
-	    if (pkg_vec == NULL) {
-		fprintf(stderr, "*** WARNING: Unknown package: %s\n\n", argv[i]);
-		continue;
-	    }
-
-	    for(j = 0; j < pkg_vec->len; j++){
-		pkg_print_info(pkg_vec->pkgs[j], stdout);
-		dep_vec = pkg_vec_alloc();
-		pkg_hash_fetch_unsatisfied_dependencies(&conf,
-							pkg_vec->pkgs[j],
-							dep_vec,
-							&unresolved);
-		if(dep_vec){
-		    fprintf(stderr, "and the unsatisfied dependencies are:\n");
-		    for(k = 0; k < dep_vec->len; k++){
-			fprintf(stderr, "%s version %s\n", dep_vec->pkgs[k]->name, dep_vec->pkgs[k]->version);
-		    }
-		}
-		
-		fputs("", stdout);
-		
-	    }
- 	}
-    }
-
-    pkg_hash_deinit(hash);
-
-    return 0;
-}

Deleted: trunk/src/target/ipkg/ipkg_install.c
===================================================================
--- trunk/src/target/ipkg/ipkg_install.c	2008-01-18 11:05:46 UTC (rev 3878)
+++ trunk/src/target/ipkg/ipkg_install.c	2008-01-18 11:28:48 UTC (rev 3879)
@@ -1,1942 +0,0 @@
-/* ipkg_install.c - the itsy package management system
-
-   Carl D. Worth
-
-   Copyright (C) 2001 University of Southern California
-
-   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 <dirent.h>
-#include <glob.h>
-#include <time.h>
-#include <signal.h>
-typedef void (*sighandler_t)(int);
-
-#include "pkg.h"
-#include "pkg_hash.h"
-#include "pkg_extract.h"
-
-#include "ipkg_install.h"
-#include "ipkg_configure.h"
-#include "ipkg_download.h"
-#include "ipkg_remove.h"
-
-#include "ipkg_utils.h"
-#include "ipkg_message.h"
-
-#include "sprintf_alloc.h"
-#include "file_util.h"
-#include "str_util.h"
-#include "xsystem.h"
-#include "user.h"
-
-int satisfy_dependencies_for(ipkg_conf_t *conf, pkg_t *pkg);
-static int verify_pkg_installable(ipkg_conf_t *conf, pkg_t *pkg);
-static int unpack_pkg_control_files(ipkg_conf_t *conf, pkg_t *pkg);
-
-static int prerm_upgrade_old_pkg(ipkg_conf_t *conf, pkg_t *pkg, pkg_t *old_pkg);
-static int prerm_upgrade_old_pkg_unwind(ipkg_conf_t *conf, pkg_t *pkg, pkg_t *old_pkg);
-static int prerm_deconfigure_conflictors(ipkg_conf_t *conf, pkg_t *pkg, pkg_vec_t *conflictors);
-static int prerm_deconfigure_conflictors_unwind(ipkg_conf_t *conf, pkg_t *pkg, pkg_vec_t *conflictors);
-static int preinst_configure(ipkg_conf_t *conf, pkg_t *pkg, pkg_t *old_pkg);
-static int preinst_configure_unwind(ipkg_conf_t *conf, pkg_t *pkg, pkg_t *old_pkg);
-static int check_data_file_clashes(ipkg_conf_t *conf, pkg_t *pkg, pkg_t *old_pkg);
-static int check_data_file_clashes_change(ipkg_conf_t *conf, pkg_t *pkg, pkg_t *old_pkg);
-static int check_data_file_clashes_unwind(ipkg_conf_t *conf, pkg_t *pkg, pkg_t *old_pkg);
-static int backup_modified_conffiles(ipkg_conf_t *conf, pkg_t *pkg, pkg_t *old_pkg);
-static int backup_modified_conffiles_unwind(ipkg_conf_t *conf, pkg_t *pkg, pkg_t *old_pkg);
-static int postrm_upgrade_old_pkg(ipkg_conf_t *conf, pkg_t *pkg, pkg_t *old_pkg);
-static int postrm_upgrade_old_pkg_unwind(ipkg_conf_t *conf, pkg_t *pkg, pkg_t *old_pkg);
-
-static int remove_obsolesced_files(ipkg_conf_t *conf, pkg_t *pkg, pkg_t *old_pkg);
-static int install_maintainer_scripts(ipkg_conf_t *conf, pkg_t *pkg, pkg_t *old_pkg);
-static int remove_disappeared(ipkg_conf_t *conf, pkg_t *pkg);
-static int install_data_files(ipkg_conf_t *conf, pkg_t *pkg);
-static int resolve_conffiles(ipkg_conf_t *conf, pkg_t *pkg);
-
-static int cleanup_temporary_files(ipkg_conf_t *conf, pkg_t *pkg);
-
-static int user_prefers_old_conffile(const char *file, const char *backup);
-
-static char *backup_filename_alloc(const char *file_name);
-static int backup_make_backup(ipkg_conf_t *conf, const char *file_name);
-static int backup_exists_for(const char *file_name);
-static int backup_remove(const char *file_name);
-
-
-int ipkg_install_from_file(ipkg_conf_t *conf, const char *filename)
-{
-     int err, cmp;
-     pkg_t *pkg, *old;
-     char *old_version, *new_version;
-
-     pkg = pkg_new();
-     if (pkg == NULL) {
-	  return ENOMEM;
-     }
-
-     err = pkg_init_from_file(pkg, filename);
-     if (err) {
-	  return err;
-     }
-
-     if (!pkg->architecture) {
-	  ipkg_message(conf, IPKG_ERROR, "Package %s has no Architecture defined.\n", pkg->name);
-	  return -EINVAL;
-     }
-
-     /* XXX: CLEANUP: hash_insert_pkg has a nasty side effect of possibly
-	freeing the pkg that we pass in. It might be nice to clean this up
-	if possible.  */
-     pkg = hash_insert_pkg(&conf->pkg_hash, pkg, 1,conf);
-     old = pkg_hash_fetch_installed_by_name(&conf->pkg_hash, pkg->name);
-
-     pkg->local_filename = strdup(filename);
-
-     if (old) {
-	  old_version = pkg_version_str_alloc(old);
-	  new_version = pkg_version_str_alloc(pkg);
-
-	  cmp = pkg_compare_versions(old, pkg);
-          if ( (conf->force_downgrade==1) && (cmp > 0) ){     /* We've been asked to allow downgrade  and version is precedent */
-             cmp = -1 ;                                       /* then we force ipkg to downgrade */ 
-                                                              /* We need to use a value < 0 because in the 0 case we are asking to */
-                                                              /* reinstall, and some check could fail asking the "force-reinstall" option */
-          } 
-	  if (cmp > 0) {
-	         ipkg_message(conf, IPKG_NOTICE,
-			      "Not downgrading package %s on %s from %s to %s.\n",
-			      old->name, old->dest->name, old_version, new_version);
-	         pkg->state_want = SW_DEINSTALL;
-	         pkg->state_flag |= SF_OBSOLETE;
-	         free(old_version);
-	         free(new_version);
-	         return 0;
-	  } else {
-	       free(old_version);
-	       free(new_version);
-	  }
-     }
-
-     ipkg_message(conf, IPKG_DEBUG2,"Function: %s calling ipkg_install_pkg \n",__FUNCTION__);
-     return ipkg_install_pkg(conf, pkg,0);
-}
-
-ipkg_error_t ipkg_install_by_name(ipkg_conf_t *conf, const char *pkg_name)
-{
-     int cmp;
-     pkg_t *old, *new;
-     char *old_version, *new_version;
-
-     ipkg_message(conf, IPKG_DEBUG2, " Getting old  from pkg_hash_fetch \n" );
-     old = pkg_hash_fetch_installed_by_name(&conf->pkg_hash, pkg_name);
-     if ( old ) 
-        ipkg_message(conf, IPKG_DEBUG2, " Old versions from pkg_hash_fetch %s \n",  old->version );
-    
-     ipkg_message(conf, IPKG_DEBUG2, " Getting new  from pkg_hash_fetch \n" );
-     new = pkg_hash_fetch_best_installation_candidate_by_name(conf, pkg_name);
-     if ( new ) 
-        ipkg_message(conf, IPKG_DEBUG2, " New versions from pkg_hash_fetch %s \n",  new->version );
-
-/* Pigi Basically here is broken the version stuff.
-   What's happening is that nothing provide the version to differents 
-   functions, so the returned struct is always the latest.
-   That's why the install by name don't work.
-*/
-     ipkg_message(conf, IPKG_DEBUG2, " Versions from pkg_hash_fetch in %s ", __FUNCTION__ );
-
-     if ( old ) 
-        ipkg_message(conf, IPKG_DEBUG2, " old %s ", old->version );
-     if ( new ) 
-        ipkg_message(conf, IPKG_DEBUG2, " new %s ", new->version );
-     ipkg_message(conf, IPKG_DEBUG2, " \n");
-
-     if (new == NULL) {
-	  return IPKG_PKG_HAS_NO_CANDIDATE;
-     }
-
-     new->state_flag |= SF_USER;
-     if (old) {
-	  old_version = pkg_version_str_alloc(old);
-	  new_version = pkg_version_str_alloc(new);
-
-	  cmp = pkg_compare_versions(old, new);
-          if ( (conf->force_downgrade==1) && (cmp > 0) ){     /* We've been asked to allow downgrade  and version is precedent */
-	     ipkg_message(conf, IPKG_DEBUG, " Forcing downgrade \n");
-             cmp = -1 ;                                       /* then we force ipkg to downgrade */ 
-                                                              /* We need to use a value < 0 because in the 0 case we are asking to */
-                                                              /* reinstall, and some check could fail asking the "force-reinstall" option */
-          } 
-	  ipkg_message(conf, IPKG_DEBUG, 
-		       "Comparing visible versions of pkg %s:"
-		       "\n\t%s is installed "
-		       "\n\t%s is available "
-		       "\n\t%d was comparison result\n",
-		       pkg_name, old_version, new_version, cmp);
-	  if (cmp == 0 && !conf->force_reinstall) {
-	       ipkg_message(conf, IPKG_NOTICE,
-			    "Package %s (%s) installed in %s is up to date.\n",
-			    old->name, old_version, old->dest->name);
-	       free(old_version);
-	       free(new_version);
-	       return 0;
-	  } else if (cmp > 0) {
-	       ipkg_message(conf, IPKG_NOTICE,
-			    "Not downgrading package %s on %s from %s to %s.\n",
-			    old->name, old->dest->name, old_version, new_version);
-	       free(old_version);
-	       free(new_version);
-	       return 0;
-	  } else if (cmp < 0) {
-	       new->dest = old->dest;
-	       old->state_want = SW_DEINSTALL;    /* Here probably the problem for bug 1277 */
-	  }
-     }
-
-     /* 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,
-	etc.). This is a real mess and will need to be cleaned up if
-	anyone ever wants to make a nice libipkg. */
-
-     ipkg_message(conf, IPKG_DEBUG2,"Function: %s calling ipkg_install_pkg \n",__FUNCTION__);
-     return ipkg_install_pkg(conf, new,0);
-}
-
-ipkg_error_t ipkg_install_multi_by_name(ipkg_conf_t *conf, const char *pkg_name)
-{
-     abstract_pkg_vec_t *providers = pkg_hash_fetch_all_installation_candidates (&conf->pkg_hash, pkg_name);
-     int i;
-     ipkg_error_t err;
-     abstract_pkg_t *ppkg ;
-
-     if (providers == NULL)
-	  return IPKG_PKG_HAS_NO_CANDIDATE;
-
-     for (i = 0; i < providers->len; i++) {
-	  ppkg = abstract_pkg_vec_get(providers, i);
-          ipkg_message(conf, IPKG_DEBUG2,"Function: %s calling ipkg_install_by_name %d \n",__FUNCTION__, i);
-	  err = ipkg_install_by_name(conf, ppkg->name);
-	  if (err)
-	       return err;
-/* XXX Maybe ppkg should be freed ? */
-     }
-     return 0;
-}
-
-/*
- * Walk dependence graph starting with pkg, collect packages to be
- * installed into pkgs_needed, in dependence order.
- */
-int pkg_mark_dependencies_for_installation(ipkg_conf_t *conf, pkg_t *pkg, pkg_vec_t *pkgs_needed)
-{
-     int i, err;
-     pkg_vec_t *depends = pkg_vec_alloc();
-     char **unresolved = NULL;
-     int ndepends;
-
-     ndepends = pkg_hash_fetch_unsatisfied_dependencies(conf, 
-							pkg, depends, 
-							&unresolved);
-
-     if (unresolved) {
-	  ipkg_message(conf, IPKG_ERROR,
-		       "%s: Cannot satisfy the following dependencies for %s:\n\t",
-		       conf->force_depends ? "Warning" : "ERROR", pkg->name);
-	  while (*unresolved) {
-	       ipkg_message(conf, IPKG_ERROR, " %s", *unresolved);
-	       unresolved++;
-	  }
-	  ipkg_message(conf, IPKG_ERROR, "\n");
-	  if (! conf->force_depends) {
-	       ipkg_message(conf, IPKG_INFO,
-			    "This could mean that your package list is out of date or that the packages\n"
-			    "mentioned above do not yet exist (try 'ipkg update'). To proceed in spite\n"
-			    "of this problem try again with the '-force-depends' option.\n");
-	       pkg_vec_free(depends);
-	       return IPKG_PKG_DEPS_UNSATISFIED;
-	  }
-     }
-
-     if (ndepends <= 0) {
-	  pkg_vec_free(depends);
-	  return 0;
-     }
-
-     for (i = 0; i < depends->len; i++) {
-	  pkg_t *dep = depends->pkgs[i];
-	  /* The package was uninstalled when we started, but another
-	     dep earlier in this loop may have depended on it and pulled
-	     it in, so check first. */
-	  if ((dep->state_status != SS_INSTALLED)
-	      && (dep->state_status != SS_UNPACKED)
-	      && (dep->state_want != SW_INSTALL)) {
-
-	       /* Mark packages as to-be-installed */
-	       dep->state_want = SW_INSTALL;
-
-	       /* Dependencies should be installed the same place as pkg */
-	       if (dep->dest == NULL) {
-		    dep->dest = pkg->dest;
-	       }
-
-	       err = pkg_mark_dependencies_for_installation(conf, dep, pkgs_needed);
-	       if (err) {
-		    pkg_vec_free(depends);
-		    return err;
-	       }
-	  }
-     }
-     if (pkgs_needed)
-	  pkg_vec_insert(pkgs_needed, pkg);
-
-     pkg_vec_free(depends);
-
-     return 0;
-}
-
-int name_mark_dependencies_for_installation(ipkg_conf_t *conf, const char *pkg_name, pkg_vec_t *pkgs_needed)
-{
-     int cmp;
-     pkg_t *old, *new;
-     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;
-     }
-     if (old) {
-	  old_version = pkg_version_str_alloc(old);
-	  new_version = pkg_version_str_alloc(new);
-
-	  cmp = pkg_compare_versions(old, new);
-          if ( (conf->force_downgrade==1) && (cmp > 0) ){     /* We've been asked to allow downgrade  and version is precedent */
-	    ipkg_message(conf, IPKG_DEBUG, " Forcing downgrade ");
-             cmp = -1 ;                                       /* then we force ipkg to downgrade */ 
-                                                              /* We need to use a value < 0 because in the 0 case we are asking to */
-                                                              /* reinstall, and some check could fail asking the "force-reinstall" option */
-          } 
-	  ipkg_message(conf, IPKG_DEBUG, 
-		       "comparing visible versions of pkg %s:"
-		       "\n\t%s is installed "
-		       "\n\t%s is available "
-		       "\n\t%d was comparison result\n",
-		       pkg_name, old_version, new_version, cmp);
-	  if (cmp == 0 && !conf->force_reinstall) {
-	       ipkg_message(conf, IPKG_NOTICE,
-			    "Package %s (%s) installed in %s is up to date.\n",
-			    old->name, old_version, old->dest->name);
-	       free(old_version);
-	       free(new_version);
-	       return 0;
-	  } else if (cmp > 0) {
-	       ipkg_message(conf, IPKG_NOTICE,
-			    "Not downgrading package %s on %s from %s to %s.\n",
-			    old->name, old->dest->name, old_version, new_version);
-	       free(old_version);
-	       free(new_version);
-	       return 0;
-	  } else if (cmp < 0) {
-	       new->dest = old->dest;
-	       old->state_want = SW_DEINSTALL;
-	       old->state_flag |= SF_OBSOLETE;
-	  }
-     }
-     return pkg_mark_dependencies_for_installation(conf, new, pkgs_needed);
-}
-
-
-
-int satisfy_dependencies_for(ipkg_conf_t *conf, pkg_t *pkg)
-{
-     int i, err;
-     pkg_vec_t *depends = pkg_vec_alloc();
-     pkg_t *dep;
-     char **unresolved = NULL;
-     int ndepends;
-
-     ndepends = pkg_hash_fetch_unsatisfied_dependencies(conf, 
-							pkg, depends, 
-							&unresolved);
-
-     if (unresolved) {
-	  ipkg_message(conf, IPKG_ERROR,
-		       "%s: Cannot satisfy the following dependencies for %s:\n\t",
-		       conf->force_depends ? "Warning" : "ERROR", pkg->name);
-	  while (*unresolved) {
-	       ipkg_message(conf, IPKG_ERROR, " %s", *unresolved);
-	       unresolved++;
-	  }
-	  ipkg_message(conf, IPKG_ERROR, "\n");
-	  if (! conf->force_depends) {
-	       ipkg_message(conf, IPKG_INFO,
-			    "This could mean that your package list is out of date or that the packages\n"
-			    "mentioned above do not yet exist (try 'ipkg update'). To proceed in spite\n"
-			    "of this problem try again with the '-force-depends' option.\n");
-	       pkg_vec_free(depends);
-	       return IPKG_PKG_DEPS_UNSATISFIED;
-	  }
-     }
-
-     if (ndepends <= 0) {
-	  return 0;
-     }
-
-     /* Mark packages as to-be-installed */
-     for (i=0; i < depends->len; i++) {
-	  /* Dependencies should be installed the same place as pkg */
-	  if (depends->pkgs[i]->dest == NULL) {
-	       depends->pkgs[i]->dest = pkg->dest;
-	  }
-	  depends->pkgs[i]->state_want = SW_INSTALL;
-     }
-
-     for (i = 0; i < depends->len; i++) {
-	  dep = depends->pkgs[i];
-	  /* The package was uninstalled when we started, but another
-	     dep earlier in this loop may have depended on it and pulled
-	     it in, so check first. */
-	  if ((dep->state_status != SS_INSTALLED)
-	      && (dep->state_status != SS_UNPACKED)) {
-               ipkg_message(conf, IPKG_DEBUG2,"Function: %s calling ipkg_install_pkg \n",__FUNCTION__);
-	       err = ipkg_install_pkg(conf, dep,0);
-	       if (err) {
-		    pkg_vec_free(depends);
-		    return err;
-	       }
-	  }
-     }
-
-     pkg_vec_free(depends);
-
-     return 0;
-}
-
-
-/* check all packages have their dependences satisfied, e.g., in case an upgraded package split */ 
-int ipkg_satisfy_all_dependences(ipkg_conf_t *conf)
-{
-     if (conf->nodeps == 0) {
-	  int i;
-	  pkg_vec_t *installed = pkg_vec_alloc();
-	  pkg_hash_fetch_all_installed(&conf->pkg_hash, installed);
-	  for (i = 0; i < installed->len; i++) {
-	       pkg_t *pkg = installed->pkgs[i];
-	       satisfy_dependencies_for(conf, pkg);
-	  }
-	  pkg_vec_free(installed);
-     }
-     return 0;
-}
-
-
-
-static int check_conflicts_for(ipkg_conf_t *conf, pkg_t *pkg)
-{
-     int i;
-     pkg_vec_t *conflicts = NULL;
-     int level;
-     const char *prefix;
-     if (conf->force_depends) {
-	  level = IPKG_NOTICE;
-	  prefix = "Warning";
-     } else {
-	  level = IPKG_ERROR;
-	  prefix = "ERROR";
-     }
-
-     if (!conf->force_depends)
-	  conflicts = (pkg_vec_t *)pkg_hash_fetch_conflicts(&conf->pkg_hash, pkg);
-
-     if (conflicts) {
-	  ipkg_message(conf, level,
-		       "%s: The following packages conflict with %s:\n\t", prefix, pkg->name);
-	  i = 0;
-	  while (i < conflicts->len)
-	       ipkg_message(conf, level, " %s", conflicts->pkgs[i++]->name);
-	  ipkg_message(conf, level, "\n");
-	  pkg_vec_free(conflicts);
-	  return IPKG_PKG_DEPS_UNSATISFIED;
-     }
-     return 0;
-}
-
-static int update_file_ownership(ipkg_conf_t *conf, pkg_t *new_pkg, pkg_t *old_pkg)
-{
-     str_list_t *new_list = pkg_get_installed_files(new_pkg);
-     str_list_elt_t *iter;
-
-     for (iter = new_list->head; iter; iter = iter->next) {
-	  char *new_file = iter->data;
-	  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))
-	       file_hash_set_file_owner(conf, new_file, new_pkg);
-     }
-     if (old_pkg) {
-	  str_list_t *old_list = pkg_get_installed_files(old_pkg);
-	  for (iter = old_list->head; iter; iter = iter->next) {
-	       char *old_file = iter->data;
-	       pkg_t *owner = file_hash_get_file_owner(conf, old_file);
-	       if (owner == old_pkg) {
-		    /* obsolete */
-		    hash_table_insert(&conf->obs_file_hash, old_file, old_pkg);
-	       }
-	  }
-     }
-     return 0;
-}
-
-static int verify_pkg_installable(ipkg_conf_t *conf, pkg_t *pkg)
-{
-    /* XXX: FEATURE: Anything else needed here? Maybe a check on free space? */
-
-    /* sma 6.20.02:  yup; here's the first bit */
-    /* 
-     * XXX: BUG easy for cworth
-     * 1) please point the call below to the correct current root destination
-     * 2) we need to resolve how to check the required space for a pending pkg, 
-     *    my diddling with the .ipk file size below isn't going to cut it.
-     * 3) return a proper error code instead of 1
-     */
-     int comp_size, blocks_available;
-    
-     if (!conf->force_space && pkg->installed_size != NULL) {
-	  blocks_available = get_available_blocks(conf->default_dest->root_dir);
-
-	  comp_size = strtoul(pkg->installed_size, NULL, 0);
-	  /* round up a blocks count without doing fancy-but-slow casting jazz */ 
-	  comp_size = (int)((comp_size + 1023) / 1024);
-
-	  if (comp_size >= blocks_available) {
-	       ipkg_message(conf, IPKG_ERROR,
-			    "Only have %d available blocks on filesystem %s, pkg %s needs %d\n", 
-			    blocks_available, conf->default_dest->root_dir, pkg->name, comp_size);
-	       return ENOSPC;
-	  }
-     }
-     return 0;
-}
-
-static int unpack_pkg_control_files(ipkg_conf_t *conf, pkg_t *pkg)
-{
-     int err;
-     char *conffiles_file_name;
-     char *root_dir;
-     FILE *conffiles_file;
-
-     sprintf_alloc(&pkg->tmp_unpack_dir, "%s/%s-XXXXXX", conf->tmp_dir, pkg->name);
-
-     pkg->tmp_unpack_dir = mkdtemp(pkg->tmp_unpack_dir);
-     if (pkg->tmp_unpack_dir == NULL) {
-	  ipkg_message(conf, IPKG_ERROR,
-		       "%s: Failed to create temporary directory '%s': %s\n",
-		       __FUNCTION__, pkg->tmp_unpack_dir, strerror(errno));
-	  return errno;
-     }
-
-     err = pkg_extract_control_files_to_dir(pkg, pkg->tmp_unpack_dir);
-     if (err) {
-	  return err;
-     }
-
-     /* XXX: CLEANUP: There might be a cleaner place to read in the
-	conffiles. Seems like I should be able to get everything to go
-	through pkg_init_from_file. If so, maybe it would make sense to
-	move all of unpack_pkg_control_files to that function. */
-
-     /* Don't need to re-read conffiles if we already have it */
-     if (pkg->conffiles.head) {
-	  return 0;
-     }
-
-     sprintf_alloc(&conffiles_file_name, "%s/conffiles", pkg->tmp_unpack_dir);
-     if (! file_exists(conffiles_file_name)) {
-	  free(conffiles_file_name);
-	  return 0;
-     }
-    
-     conffiles_file = fopen(conffiles_file_name, "r");
-     if (conffiles_file == NULL) {
-	  fprintf(stderr, "%s: failed to open %s: %s\n",
-		  __FUNCTION__, conffiles_file_name, strerror(errno));
-	  free(conffiles_file_name);
-	  return errno;
-     }
-     free(conffiles_file_name);
-
-     while (1) {
-	  char *cf_name;
-	  char *cf_name_in_dest;
-
-	  cf_name = file_read_line_alloc(conffiles_file);
-	  if (cf_name == NULL) {
-	       break;
-	  }
-	  str_chomp(cf_name);
-	  if (cf_name[0] == '\0') {
-	       continue;
-	  }
-
-	  /* Prepend dest->root_dir to conffile name.
-	     Take pains to avoid multiple slashes. */
-	  root_dir = pkg->dest->root_dir;
-	  if (conf->offline_root)
-	       /* skip the offline_root prefix */
-	       root_dir = pkg->dest->root_dir + strlen(conf->offline_root);
-	  sprintf_alloc(&cf_name_in_dest, "%s%s", root_dir,
-			cf_name[0] == '/' ? (cf_name + 1) : cf_name);
-
-	  /* Can't get an md5sum now, (file isn't extracted yet).
-	     We'll wait until resolve_conffiles */
-	  conffile_list_append(&pkg->conffiles, cf_name_in_dest, NULL);
-
-	  free(cf_name);
-	  free(cf_name_in_dest);
-     }
-
-     fclose(conffiles_file);
-
-     return 0;
-}
-
-/* returns number of installed replacees */
-int pkg_get_installed_replacees(ipkg_conf_t *conf, pkg_t *pkg, pkg_vec_t *installed_replacees)
-{
-     abstract_pkg_t **replaces = pkg->replaces;
-     int replaces_count = pkg->replaces_count;
-     int i, j;
-     for (i = 0; i < replaces_count; i++) {
-	  abstract_pkg_t *ab_pkg = replaces[i];
-	  pkg_vec_t *pkg_vec = ab_pkg->pkgs;
-	  if (pkg_vec) {
-	       for (j = 0; j < pkg_vec->len; j++) {
-		    pkg_t *replacee = pkg_vec->pkgs[j];
-		    if (!pkg_conflicts(pkg, replacee))
-			 continue;
-		    if (replacee->state_status == SS_INSTALLED) {
-			 pkg_vec_insert(installed_replacees, replacee);
-		    }
-	       }
-	  }
-     }
-     return installed_replacees->len;
-}
-
-int pkg_remove_installed_replacees(ipkg_conf_t *conf, pkg_vec_t *replacees)
-{
-     int i;
-     int replaces_count = replacees->len;
-     for (i = 0; i < replaces_count; i++) {
-	  pkg_t *replacee = replacees->pkgs[i];
-	  int err;
-	  replacee->state_flag |= SF_REPLACE; /* flag it so remove won't complain */
-	  err = ipkg_remove_pkg(conf, replacee,0);
-	  if (err)
-	       return err;
-     }
-     return 0;
-}
-
-/* to unwind the removal: make sure they are installed */
-int pkg_remove_installed_replacees_unwind(ipkg_conf_t *conf, pkg_vec_t *replacees)
-{
-     int i, err;
-     int replaces_count = replacees->len;
-     for (i = 0; i < replaces_count; i++) {
-	  pkg_t *replacee = replacees->pkgs[i];
-	  if (replacee->state_status != SS_INSTALLED) {
-               ipkg_message(conf, IPKG_DEBUG2,"Function: %s calling ipkg_install_pkg \n",__FUNCTION__);
-	       err = ipkg_install_pkg(conf, replacee,0);
-	       if (err)
-		    return err;
-	  }
-     }
-     return 0;
-}
-
-int caught_sigint = 0;
-static void ipkg_install_pkg_sigint_handler(int sig)
-{
-     caught_sigint = sig;
-}
-
-/* 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, int message)
-{	  
-     if (old_pkg) {
-          char message_out[15];
-	  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;
-
-          memset(message_out,'\x0',15);
-          strncpy (message_out,"Upgrading ",strlen("Upgrading ")); 
-          if ( (conf->force_downgrade==1) && (cmp > 0) ){     /* We've been asked to allow downgrade  and version is precedent */
-             cmp = -1 ;                                       /* then we force ipkg to downgrade */ 
-             strncpy (message_out,"Downgrading ",strlen("Downgrading "));         /* We need to use a value < 0 because in the 0 case we are asking to */
-                                                              /* reinstall, and some check could fail asking the "force-reinstall" option */
-          } 
-
-	  if (cmp > 0) {
-	       ipkg_message(conf, IPKG_NOTICE,
-			    "Not downgrading package %s on %s from %s to %s.\n",
-			    old_pkg->name, old_pkg->dest->name, old_version, new_version);
-	       rc = 1;
-	  } else if (cmp < 0) {
-	       ipkg_message(conf, IPKG_NOTICE,
-			    "%s%s on %s from %s to %s...\n",
-			    message_out, 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",
-				 pkg->name, new_version, old_pkg->dest->name);
-		    rc = 1;
-	       }
-	  } 
-	  free(old_version);
-	  free(new_version);
-	  return rc;
-     } else {
-      char message_out[15] ;
-      memset(message_out,'\x0',15);
-      if ( message ) 
-          strncpy( message_out,"Upgrading ",strlen("Upgrading ") );
-      else
-          strncpy( message_out,"Installing ",strlen("Installing ") );
-	  char *version = pkg_version_str_alloc(pkg);
-      
-	  ipkg_message(conf, IPKG_NOTICE,
-		       "%s%s (%s) to %s...\n", message_out,
-		       pkg->name, version, pkg->dest->name);
-	  free(version);
-	  return 0;
-     }
-}
-
-/* and now the meat... */
-int ipkg_install_pkg(ipkg_conf_t *conf, pkg_t *pkg, int from_upgrade)
-{
-     int err = 0;
-     int message = 0;
-     pkg_t *old_pkg = NULL;
-     pkg_vec_t *replacees;
-     abstract_pkg_t *ab_pkg = NULL;
-     int old_state_flag;
-     char* file_md5;
-
-    
-     if ( from_upgrade ) 
-        message = 1;            /* Coming from an upgrade, and should change the output message */
-
-     if (!pkg) {
-	  ipkg_message(conf, IPKG_ERROR,
-		       "INTERNAL ERROR: null pkg passed to ipkg_install_pkg\n");
-	  return -EINVAL;
-     }
-
-     ipkg_message(conf, IPKG_DEBUG2, "Function: %s calling pkg_arch_supported %s \n", __FUNCTION__, __FUNCTION__);
-
-     if (!pkg_arch_supported(conf, pkg)) {
-	  ipkg_message(conf, IPKG_ERROR, "INTERNAL ERROR: architecture %s for pkg %s is unsupported.\n",
-		       pkg->architecture, pkg->name);
-	  return -EINVAL;
-     }
-     if (pkg->state_status == SS_INSTALLED && conf->force_reinstall == 0 && conf->nodeps == 0) {
-	  err = satisfy_dependencies_for(conf, pkg);
-	  if (err) { return err; }
-
-	  ipkg_message(conf, IPKG_NOTICE,
-		       "Package %s is already installed in %s.\n", 
-		       pkg->name, pkg->dest->name);
-	  return 0;
-     }
-
-     if (pkg->dest == NULL) {
-	  pkg->dest = conf->default_dest;
-     }
-
-     old_pkg = pkg_hash_fetch_installed_by_name(&conf->pkg_hash, pkg->name);
-
-     err = ipkg_install_check_downgrade(conf, pkg, old_pkg, message);
-     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 */
-     }
-
-
-     /* Abhaya: conflicts check */
-     err = check_conflicts_for(conf, pkg);
-     if (err) { return err; }
-    
-     /* this setup is to remove the upgrade scenario in the end when
-	installing pkg A, A deps B & B deps on A. So both B and A are
-	installed. Then A's installation is started resulting in an
-	uncecessary upgrade */ 
-     if (pkg->state_status == SS_INSTALLED
-	 && conf->force_reinstall == 0) return 0;
-    
-     err = verify_pkg_installable(conf, pkg);
-     if (err) { return err; }
-
-     if (pkg->local_filename == NULL) {
-	  err = ipkg_download_pkg(conf, pkg, conf->tmp_dir);
-	  if (err) {
-	       ipkg_message(conf, IPKG_ERROR,
-			    "Failed to download %s. Perhaps you need to run 'ipkg update'?\n",
-			    pkg->name);
-	       return err;
-	  }
-     }
-
-/* Check for md5 values */
-     if (pkg->md5sum)
-     {
-         file_md5 = file_md5sum_alloc(pkg->local_filename);
-         if (strcmp(file_md5, pkg->md5sum))
-         {
-              ipkg_message(conf, IPKG_ERROR,
-                           "Package %s md5sum mismatch. Either the ipkg or the package index are corrupt. Try 'ipkg update'.\n",
-                           pkg->name);
-              free(file_md5);
-              return err;
-         }
-         free(file_md5);
-     }
-
-     if (pkg->tmp_unpack_dir == NULL) {
-	  unpack_pkg_control_files(conf, pkg);
-     }
-
-     /* We should update the filelist here, so that upgrades of packages that split will not fail. -Jamey 27-MAR-03 */
-/* Pigi: check if it will pass from here when replacing. It seems to fail */
-/* That's rather strange that files don't change owner. Investigate !!!!!!*/
-     err = update_file_ownership(conf, pkg, old_pkg);
-     if (err) { return err; }
-
-     if (conf->nodeps == 0) {
-	  err = satisfy_dependencies_for(conf, pkg);
-	  if (err) { return err; }
-     }
-
-     replacees = pkg_vec_alloc();
-     pkg_get_installed_replacees(conf, pkg, replacees);
-
-     /* this next section we do with SIGINT blocked to prevent inconsistency between ipkg database and filesystem */
-     {
-	  sigset_t newset, oldset;
-	  sighandler_t old_handler = NULL;
-	  int use_signal = 0;
-	  caught_sigint = 0;
-	  if (use_signal) {
-	       old_handler = signal(SIGINT, ipkg_install_pkg_sigint_handler);
-	  } else {
-	       sigemptyset(&newset);
-	       sigaddset(&newset, SIGINT);
-	       sigprocmask(SIG_BLOCK, &newset, &oldset);
-	  }
-
-	  ipkg_state_changed++;
-	  pkg->state_flag |= SF_FILELIST_CHANGED;
-
-	  /* XXX: BUG: we really should treat replacement more like an upgrade
-	   *      Instead, we're going to remove the replacees 
-	   */
-	  err = pkg_remove_installed_replacees(conf, replacees);
-	  if (err) goto UNWIND_REMOVE_INSTALLED_REPLACEES;
-
-	  err = prerm_upgrade_old_pkg(conf, pkg, old_pkg);
-	  if (err) goto UNWIND_PRERM_UPGRADE_OLD_PKG;
-
-	  err = prerm_deconfigure_conflictors(conf, pkg, replacees);
-	  if (err) goto UNWIND_PRERM_DECONFIGURE_CONFLICTORS;
-
-	  err = preinst_configure(conf, pkg, old_pkg);
-	  if (err) goto UNWIND_PREINST_CONFIGURE;
-
-	  err = backup_modified_conffiles(conf, pkg, old_pkg);
-	  if (err) goto UNWIND_BACKUP_MODIFIED_CONFFILES;
-
-	  err = check_data_file_clashes(conf, pkg, old_pkg);
-	  if (err) goto UNWIND_CHECK_DATA_FILE_CLASHES;
-
-	  err = postrm_upgrade_old_pkg(conf, pkg, old_pkg);
-	  if (err) goto UNWIND_POSTRM_UPGRADE_OLD_PKG;
-
-	  if (conf->noaction) return 0;
-
-	  /* point of no return: no unwinding after this */
-	  if (old_pkg && !conf->force_reinstall) {
-	       old_pkg->state_want = SW_DEINSTALL;
-
-	       if (old_pkg->state_flag & SF_NOPRUNE) {
-		    ipkg_message(conf, IPKG_INFO,
-				 "  not removing obsolesced files because package marked noprune\n");
-	       } else {
-		    ipkg_message(conf, IPKG_INFO,
-				 "  removing obsolesced files\n");
-		    remove_obsolesced_files(conf, pkg, old_pkg);
-	       }
-               /* removing files from old package, to avoid ghost files */ 
-               remove_data_files_and_list(conf, old_pkg);
-/* Pigi : It should be better to remove also maintainer and postrem scripts here, just in case*/
-               remove_maintainer_scripts_except_postrm(conf, old_pkg);
-               remove_postrm(conf, old_pkg);
-/* Pigi */
-
-	  }
-
-
-	  ipkg_message(conf, IPKG_INFO,
-		       "  installing maintainer scripts\n");
-	  install_maintainer_scripts(conf, pkg, old_pkg);
-
-	  /* the following just returns 0 */
-	  remove_disappeared(conf, pkg);
-
-	  ipkg_message(conf, IPKG_INFO,
-		       "  installing data files\n");
-	  install_data_files(conf, pkg);
-
-/* read comments from function for detail but I will execute this here as all other tests are ok.*/
-	  err = check_data_file_clashes_change(conf, pkg, old_pkg);
-
-	  ipkg_message(conf, IPKG_INFO,
-		       "  resolving conf files\n");
-	  resolve_conffiles(conf, pkg);
-
-	  pkg->state_status = SS_UNPACKED;
-	  old_state_flag = pkg->state_flag;
-	  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) {
-	       old_pkg->state_status = SS_NOT_INSTALLED;
-	  }
-
-	  time(&pkg->installed_time);
-
-	  ipkg_message(conf, IPKG_INFO,
-		       "  cleanup temp files\n");
-	  cleanup_temporary_files(conf, pkg);
-
-	  ab_pkg = pkg->parent;
-	  if (ab_pkg)
-	       ab_pkg->state_status = pkg->state_status;
-
-	  ipkg_message(conf, IPKG_INFO, "Done.\n");
-
-	  if (use_signal)
-	       signal(SIGINT, old_handler);
-	  else
-	       sigprocmask(SIG_UNBLOCK, &newset, &oldset);
-
-	  return 0;
-     
-
-     UNWIND_POSTRM_UPGRADE_OLD_PKG:
-	  postrm_upgrade_old_pkg_unwind(conf, pkg, old_pkg);
-     UNWIND_CHECK_DATA_FILE_CLASHES:
-	  check_data_file_clashes_unwind(conf, pkg, old_pkg);
-     UNWIND_BACKUP_MODIFIED_CONFFILES:
-	  backup_modified_conffiles_unwind(conf, pkg, old_pkg);
-     UNWIND_PREINST_CONFIGURE:
-	  preinst_configure_unwind(conf, pkg, old_pkg);
-     UNWIND_PRERM_DECONFIGURE_CONFLICTORS:
-	  prerm_deconfigure_conflictors_unwind(conf, pkg, replacees);
-     UNWIND_PRERM_UPGRADE_OLD_PKG:
-	  prerm_upgrade_old_pkg_unwind(conf, pkg, old_pkg);
-     UNWIND_REMOVE_INSTALLED_REPLACEES:
-	  pkg_remove_installed_replacees_unwind(conf, replacees);
-
-	  ipkg_message(conf, IPKG_INFO,
-		       "  cleanup temp files\n");
-	  cleanup_temporary_files(conf, pkg);
-
-	  ipkg_message(conf, IPKG_INFO,
-		       "Failed.\n");
-	  if (use_signal)
-	       signal(SIGINT, old_handler);
-	  else
-	       sigprocmask(SIG_UNBLOCK, &newset, &oldset);
-
-	  return err;
-     }
-}
-
-static int prerm_upgrade_old_pkg(ipkg_conf_t *conf, pkg_t *pkg, pkg_t *old_pkg)
-{
-     /* DPKG_INCOMPATIBILITY:
-	dpkg does some things here that we don't do yet. Do we care?
-	
-	1. If a version of the package is already installed, call
-	   old-prerm upgrade new-version
-	2. If the script runs but exits with a non-zero exit status
-	   new-prerm failed-upgrade old-version
-	   Error unwind, for both the above cases:
-	   old-postinst abort-upgrade new-version
-     */
-     return 0;
-}
-
-static int prerm_upgrade_old_pkg_unwind(ipkg_conf_t *conf, pkg_t *pkg, pkg_t *old_pkg)
-{
-     /* DPKG_INCOMPATIBILITY:
-	dpkg does some things here that we don't do yet. Do we care?
-	(See prerm_upgrade_old_package for details)
-     */
-     return 0;
-}
-
-static int prerm_deconfigure_conflictors(ipkg_conf_t *conf, pkg_t *pkg, pkg_vec_t *conflictors)
-{
-     /* DPKG_INCOMPATIBILITY:
-	dpkg does some things here that we don't do yet. Do we care?
-	2. If a 'conflicting' package is being removed at the same time:
-		1. If any packages depended on that conflicting package and
-		   --auto-deconfigure is specified, call, for each such package:
-		   deconfigured's-prerm deconfigure \
-		   in-favour package-being-installed version \
-		   removing conflicting-package version
-		Error unwind:
-		   deconfigured's-postinst abort-deconfigure \
-		   in-favour package-being-installed-but-failed version \
-		   removing conflicting-package version
-
-		   The deconfigured packages are marked as requiring
-		   configuration, so that if --install is used they will be
-		   configured again if possible.
-		2. To prepare for removal of the conflicting package, call:
-		   conflictor's-prerm remove in-favour package new-version
-		Error unwind:
-		   conflictor's-postinst abort-remove in-favour package new-version
-     */
-     return 0;
-}
-
-static int prerm_deconfigure_conflictors_unwind(ipkg_conf_t *conf, pkg_t *pkg, pkg_vec_t *conflictors)
-{
-     /* DPKG_INCOMPATIBILITY: dpkg does some things here that we don't
-	do yet. Do we care?  (See prerm_deconfigure_conflictors for
-	details) */
-     return 0;
-}
-
-static int preinst_configure(ipkg_conf_t *conf, pkg_t *pkg, pkg_t *old_pkg)
-{
-     int err;
-     char *preinst_args;
-
-     if (old_pkg) {
-	  char *old_version = pkg_version_str_alloc(old_pkg);
-	  sprintf_alloc(&preinst_args, "upgrade %s", old_version);
-	  free(old_version);
-     } else if (pkg->state_status == SS_CONFIG_FILES) {
-	  char *pkg_version = pkg_version_str_alloc(pkg);
-	  sprintf_alloc(&preinst_args, "install %s", pkg_version);
-	  free(pkg_version);
-     } else {
-	  preinst_args = strdup("install");
-     }
-
-     err = pkg_run_script(conf, pkg, "preinst", preinst_args);
-     if (err) {
-	  ipkg_message(conf, IPKG_ERROR,
-		       "Aborting installation of %s\n", pkg->name);
-	  return 1;
-     }
-
-     free(preinst_args);
-
-     return 0;
-}
-
-static int preinst_configure_unwind(ipkg_conf_t *conf, pkg_t *pkg, pkg_t *old_pkg)
-{
-     /* DPKG_INCOMPATIBILITY:
-	dpkg does the following error unwind, should we?
-	pkg->postrm abort-upgrade old-version
-	OR pkg->postrm abort-install old-version
-	OR pkg->postrm abort-install
-     */
-     return 0;
-}
-
-static int backup_modified_conffiles(ipkg_conf_t *conf, pkg_t *pkg, pkg_t *old_pkg)
-{
-     int err;
-     conffile_list_elt_t *iter;
-     conffile_t *cf;
-
-     if (conf->noaction) return 0;
-
-     /* Backup all modified conffiles */
-     if (old_pkg) {
-	  for (iter = old_pkg->conffiles.head; iter; iter = iter->next) {
-	       char *cf_name;
-	       
-	       cf = iter->data;
-	       cf_name = root_filename_alloc(conf, cf->name);
-
-	       /* Don't worry if the conffile is just plain gone */
-	       if (file_exists(cf_name) && conffile_has_been_modified(conf, cf)) {
-		    err = backup_make_backup(conf, cf_name);
-		    if (err) {
-			 return err;
-		    }
-	       }
-	       free(cf_name);
-	  }
-     }
-
-     /* Backup all conffiles that were not conffiles in old_pkg */
-     for (iter = pkg->conffiles.head; iter; iter = iter->next) {
-	  char *cf_name;
-	  cf = iter->data;
-	  cf_name = root_filename_alloc(conf, cf->name);
-	  /* Ignore if this was a conffile in old_pkg as well */
-	  if (pkg_get_conffile(old_pkg, cf->name)) {
-	       continue;
-	  }
-
-	  if (file_exists(cf_name) && (! backup_exists_for(cf_name))) {
-	       err = backup_make_backup(conf, cf_name);
-	       if (err) {
-		    return err;
-	       }
-	  }
-	  free(cf_name);
-     }
-
-     return 0;
-}
-
-static int backup_modified_conffiles_unwind(ipkg_conf_t *conf, pkg_t *pkg, pkg_t *old_pkg)
-{
-     conffile_list_elt_t *iter;
-
-     if (old_pkg) {
-	  for (iter = old_pkg->conffiles.head; iter; iter = iter->next) {
-	       backup_remove(iter->data->name);
-	  }
-     }
-
-     for (iter = pkg->conffiles.head; iter; iter = iter->next) {
-	  backup_remove(iter->data->name);
-     }
-
-     return 0;
-}
-
-
-static int check_data_file_clashes(ipkg_conf_t *conf, pkg_t *pkg, pkg_t *old_pkg)
-{
-     /* DPKG_INCOMPATIBILITY:
-	ipkg takes a slightly different approach than dpkg at this
-	point.  dpkg installs each file in the new package while
-	creating a backup for any file that is replaced, (so that it
-	can unwind if necessary).  To avoid complexity and redundant
-	storage, ipkg doesn't do any installation until later, (at the
-	point at which dpkg removes the backups.
-	
-	But, we do have to check for data file clashes, since after
-	installing a package with a file clash, removing either of the
-	packages involved in the clash has the potential to break the
-	other package.
-     */
-     str_list_t *files_list;
-     str_list_elt_t *iter;
-
-     int clashes = 0;
-
-     files_list = pkg_get_installed_files(pkg);
-     for (iter = files_list->head; iter; iter = iter->next) {
-	  char *root_filename;
-	  char *filename = iter->data;
-	  root_filename = root_filename_alloc(conf, filename);
-	  if (file_exists(root_filename) && (! file_is_dir(root_filename))) {
-	       pkg_t *owner;
-	       pkg_t *obs;
-	       /* Pre-existing conffiles are OK */
-	       /* @@@@ should have way to check that it is a conffile -Jamey */
-	       if (backup_exists_for(root_filename)) {
-		    continue;
-	       }
-
-	       /* Pre-existing files are OK if force-overwrite was asserted. */ 
-	       if (conf->force_overwrite) {
-		    /* but we need to change who owns this file */
-		    file_hash_set_file_owner(conf, filename, pkg);
-		    continue;
-	       }
-
-	       owner = file_hash_get_file_owner(conf, filename);
-
-	       /* Pre-existing files are OK if owned by the pkg being upgraded. */
-	       if (owner && old_pkg) {
-		    if (strcmp(owner->name, old_pkg->name) == 0) {
-			 continue;
-		    }
-	       }
-
-	       /* Pre-existing files are OK if owned by a package replaced by new pkg. */
-	       if (owner) {
-                    ipkg_message(conf, IPKG_DEBUG2, "Checking for replaces for %s in package %s\n", filename, owner->name);
-		    if (pkg_replaces(pkg, owner)) {
-			 continue;
-		    }
-/* If the file that would be installed is owned by the same package, ( as per a reinstall or similar )
-   then it's ok to overwrite. */
-                    if (strcmp(owner->name,pkg->name)==0){
-			 ipkg_message(conf, IPKG_INFO, "Replacing pre-existing file %s owned by package %s\n", filename, owner->name);
-			 continue;
-                    }
-	       }
-
-	       /* Pre-existing files are OK if they are obsolete */
-	       obs = hash_table_get(&conf->obs_file_hash, filename);
-	       if (obs) {
-		    ipkg_message(conf, IPKG_INFO, "Pre-exiting file %s is obsolete.  obs_pkg=%s\n", filename, obs->name);
-		    continue;
-	       }
-
-	       /* We have found a clash. */
-	       ipkg_message(conf, IPKG_ERROR,
-			    "Package %s wants to install file %s\n"
-			    "\tBut that file is already provided by package ",
-			    pkg->name, filename);
-	       if (owner) {
-		    ipkg_message(conf, IPKG_ERROR,
-				 "%s\n", owner->name);
-	       } else {
-		    ipkg_message(conf, IPKG_ERROR,
-				 "<no package>\nPlease move this file out of the way and try again.\n");
-	       }
-	       clashes++;
-	  }
-	  free(root_filename);
-     }
-     pkg_free_installed_files(pkg);
-
-     return clashes;
-}
-
-static int check_data_file_clashes_change(ipkg_conf_t *conf, pkg_t *pkg, pkg_t *old_pkg)
-{
-    /* Basically that's the worst hack I could do to be able to change ownership of
-       file list, but, being that we have no way to unwind the mods, due to structure
-       of hash table, probably is the quickest hack too, whishing it would not slow-up thing too much.
-       What we do here is change the ownership of file in hash if a replace ( or similar events
-       happens )
-       Only the action that are needed to change name should be considered.
-       @@@ To change after 1.0 release.
-     */
-     str_list_t *files_list;
-     str_list_elt_t *iter;
-
-     int clashes = 0;
-
-     files_list = pkg_get_installed_files(pkg);
-     for (iter = files_list->head; iter; iter = iter->next) {
-	  char *root_filename;
-	  char *filename = iter->data;
-	  root_filename = root_filename_alloc(conf, filename);
-	  if (file_exists(root_filename) && (! file_is_dir(root_filename))) {
-	       pkg_t *owner;
-
-	       if (conf->force_overwrite) {
-		    /* but we need to change who owns this file */
-		    file_hash_set_file_owner(conf, filename, pkg);
-		    continue;
-	       }
-
-	       owner = file_hash_get_file_owner(conf, filename);
-
-	       /* Pre-existing files are OK if owned by a package replaced by new pkg. */
-	       if (owner) {
-		    if (pkg_replaces(pkg, owner)) {
-/* It's now time to change the owner of that file. 
-   It has been "replaced" from the new "Replaces", then I need to inform lists file about that.  */
-			 ipkg_message(conf, IPKG_INFO, "Replacing pre-existing file %s owned by package %s\n", filename, owner->name);
-		         file_hash_set_file_owner(conf, filename, pkg);
-			 continue;
-		    }
-	       }
-
-	  }
-	  free(root_filename);
-     }
-     pkg_free_installed_files(pkg);
-
-     return clashes;
-}
-
-static int check_data_file_clashes_unwind(ipkg_conf_t *conf, pkg_t *pkg, pkg_t *old_pkg)
-{
-     /* Nothing to do since check_data_file_clashes doesn't change state */
-     return 0;
-}
-
-static int postrm_upgrade_old_pkg(ipkg_conf_t *conf, pkg_t *pkg, pkg_t *old_pkg)
-{
-     /* DPKG_INCOMPATIBILITY: dpkg does the following here, should we?
-	1. If the package is being upgraded, call
-	   old-postrm upgrade new-version
-	2. If this fails, attempt:
-	   new-postrm failed-upgrade old-version
-	Error unwind, for both cases:
-	   old-preinst abort-upgrade new-version    */
-     return 0;
-}
-
-static int postrm_upgrade_old_pkg_unwind(ipkg_conf_t *conf, pkg_t *pkg, pkg_t *old_pkg)
-{
-     /* DPKG_INCOMPATIBILITY:
-	dpkg does some things here that we don't do yet. Do we care?
-	(See postrm_upgrade_old_pkg for details)
-     */
-    return 0;
-}
-
-static int remove_obsolesced_files(ipkg_conf_t *conf, pkg_t *pkg, pkg_t *old_pkg)
-{
-     int err;
-     str_list_t *old_files;
-     str_list_elt_t *of;
-     str_list_t *new_files;
-     str_list_elt_t *nf;
-
-     if (old_pkg == NULL) {
-	  return 0;
-     }
-
-     old_files = pkg_get_installed_files(old_pkg);
-     new_files = pkg_get_installed_files(pkg);
-
-     for (of = old_files->head; of; of = of->next) {
-	  pkg_t *owner;
-	  char *old, *new;
-	  old = of->data;
-	  for (nf = new_files->head; nf; nf = nf->next) {
-	       new = nf->data;
-	       if (strcmp(old, new) == 0) {
-		    goto NOT_OBSOLETE;
-	       }
-	  }
-	  if (file_is_dir(old)) {
-	       continue;
-	  }
-	  owner = file_hash_get_file_owner(conf, old);
-	  if (owner != old_pkg) {
-	       /* in case obsolete file no longer belongs to old_pkg */
-	       continue;
-	  }
- 
-	  /* old file is obsolete */
-	  ipkg_message(conf, IPKG_INFO,
-		       "    removing obsolete file %s\n", old);
-	  if (!conf->noaction) {
-	       err = unlink(old);
-	       if (err) {
-		    ipkg_message(conf, IPKG_ERROR, "    Warning: remove %s failed: %s\n", old,
-				 strerror(errno));
-	       }
-	  }
-
-     NOT_OBSOLETE:
-	  ;
-     }
-
-     pkg_free_installed_files(old_pkg);
-     pkg_free_installed_files(pkg);
-
-     return 0;
-}
-
-static int remove_obsolete_maintainer_scripts(ipkg_conf_t *conf, pkg_t *pkg, pkg_t *old_pkg)
-{
-     int i;
-     int err = 0;
-     char *globpattern;
-     glob_t globbuf;
-     if (0) {
-	  if (!pkg->dest) {
-	       ipkg_message(conf, IPKG_ERROR, "%s: no dest for package %s\n", __FUNCTION__, pkg->name);
-	       return -1;
-	  }
-	  sprintf_alloc(&globpattern, "%s/%s.*", pkg->dest->info_dir, pkg->name);
-	  err = glob(globpattern, 0, NULL, &globbuf);
-	  free(globpattern);
-	  if (err) {
-	       return err;
-	  }
-	  /* XXXX this should perhaps only remove the ones that are not overwritten in new package.  Jamey 11/11/2003 */
-	  for (i = 0; i < globbuf.gl_pathc; i++) {
-	       ipkg_message(conf, IPKG_DEBUG, "Removing control file %s from old_pkg %s\n",
-			    globbuf.gl_pathv[i], old_pkg->name);
-	       if (!conf->noaction)
-		    unlink(globbuf.gl_pathv[i]);
-	  }
-	  globfree(&globbuf);
-     }
-     return err;
-}
-
-static int install_maintainer_scripts(ipkg_conf_t *conf, pkg_t *pkg, pkg_t *old_pkg)
-{
-     int ret;
-     char *prefix;
-
-     if (old_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,
-							pkg->dest->info_dir,
-							prefix);
-     free(prefix);
-     return ret;
-}
-
-static int remove_disappeared(ipkg_conf_t *conf, pkg_t *pkg)
-{
-     /* DPKG_INCOMPATIBILITY:
-	This is a fairly sophisticated dpkg operation. Shall we
-	skip it? */
-     
-     /* Any packages all of whose files have been overwritten during the
-	installation, and which aren't required for dependencies, are
-	considered to have been removed. For each such package
-	1. disappearer's-postrm disappear overwriter overwriter-version
-	2. The package's maintainer scripts are removed
-	3. It is noted in the status database as being in a sane state,
-           namely not installed (any conffiles it may have are ignored,
-	   rather than being removed by dpkg). Note that disappearing
-	   packages do not have their prerm called, because dpkg doesn't
-	   know in advance that the package is going to vanish.
-     */
-     return 0;
-}
-
-static int install_data_files(ipkg_conf_t *conf, pkg_t *pkg)
-{
-     int err;
-
-     /* ipkg takes a slightly different approach to data file backups
-	than dpkg. Rather than removing backups at this point, we
-	actually do the data file installation now. See comments in
-	check_data_file_clashes() for more details. */
-    
-     ipkg_message(conf, IPKG_INFO,
-		  "    extracting data files to %s\n", pkg->dest->root_dir);
-     err = pkg_extract_data_files_to_dir(pkg, pkg->dest->root_dir);
-     if (err) {
-	  return err;
-     }
-
-     /* XXX: BUG or FEATURE : We are actually loosing the Essential flag,
-        so we can't save ourself from removing important packages
-        At this point we (should) have extracted the .control file, so it
-        would be a good idea to reload the data in it, and set the Essential 
-        state in *pkg. From now on the Essential is back in status file and
-        we can protect again.
-        We should operate this way:
-        fopen the file ( pkg->dest->root_dir/pkg->name.control )
-        check for "Essential" in it 
-        set the value in pkg->essential.
-        This new routine could be useful also for every other flag
-        Pigi: 16/03/2004 */
-     set_flags_from_control(conf, pkg) ;
-     
-     ipkg_message(conf, IPKG_DEBUG, "    Calling pkg_write_filelist from %s\n", __FUNCTION__);
-     err = pkg_write_filelist(conf, pkg);
-     if (err)
-	  return err;
-
-     /* XXX: FEATURE: ipkg should identify any files which existed
-	before installation and which were overwritten, (see
-	check_data_file_clashes()). What it must do is remove any such
-	files from the filelist of the old package which provided the
-	file. Otherwise, if the old package were removed at some point
-	it would break the new package. Removing the new package will
-	also break the old one, but this cannot be helped since the old
-	package's file has already been deleted. This is the importance
-	of check_data_file_clashes(), and only allowing ipkg to install
-	a clashing package with a user force. */
-
-     return 0;
-}
-
-static int resolve_conffiles(ipkg_conf_t *conf, pkg_t *pkg)
-{
-     conffile_list_elt_t *iter;
-     conffile_t *cf;
-     char *cf_backup;
-
-    char *md5sum;
-
-    
-     if (conf->noaction) return 0;
-
-     for (iter = pkg->conffiles.head; iter; iter = iter->next) {
-	  char *root_filename;
-	  cf = iter->data;
-	  root_filename = root_filename_alloc(conf, cf->name);
-
-	  /* Might need to initialize the md5sum for each conffile */
-	  if (cf->value == NULL) {
-	       cf->value = file_md5sum_alloc(root_filename);
-	  }
-
-	  if (!file_exists(root_filename)) {
-	       free(root_filename);
-	       continue;
-	  }
-
-	  cf_backup = backup_filename_alloc(root_filename);
-
-
-	  if (file_exists(cf_backup)) {
- /* Let's compute md5 to test if files are changed */
-	      md5sum = file_md5sum_alloc(cf_backup);
-               if (strcmp( cf->value,md5sum) != 0 ) {
-	          if (conf->force_defaults
-		      || user_prefers_old_conffile(cf->name, cf_backup) ) {
-		       rename(cf_backup, root_filename);
-	          }
-	       }
-	       unlink(cf_backup);
-	       free(md5sum);
-	  }
-
-	  free(cf_backup);
-	  free(root_filename);
-     }
-
-     return 0;
-}
-
-static int user_prefers_old_conffile(const char *file_name, const char *backup)
-{
-     char *response;
-     const char *short_file_name;
-
-     short_file_name = strrchr(file_name, '/');
-     if (short_file_name) {
-	  short_file_name++;
-     } else {
-	  short_file_name = file_name;
-     }
-
-     while (1) {
-	  response = get_user_response("    Configuration file '%s'\n"
-				       "    ==> File on system created by you or by a script.\n"
-				       "    ==> File also in package provided by package maintainer.\n"
-				       "       What would you like to do about it ?  Your options are:\n"
-				       "        Y or I  : install the package maintainer's version\n"
-				       "        N or O  : keep your currently-installed version\n"
-				       "          D     : show the differences between the versions (if diff is installed)\n"
-				       "     The default action is to keep your current version.\n"
-				       "    *** %s (Y/I/N/O/D) [default=N] ? ", file_name, short_file_name);
-	  if (strcmp(response, "y") == 0
-	      || strcmp(response, "i") == 0
-	      || strcmp(response, "yes") == 0) {
-	       free(response);
-	       return 0;
-	  }
-
-	  if (strcmp(response, "d") == 0) {
-	       char *cmd;
-
-	       free(response);
-	       /* XXX: BUG rewrite to use exec or busybox's internal diff */
-	       sprintf_alloc(&cmd, "diff -u %s %s", backup, file_name);
-	       xsystem(cmd);
-	       free(cmd);
-	       printf("    [Press ENTER to continue]\n");
-	       response = file_read_line_alloc(stdin);
-	       free(response);
-	       continue;
-	  }
-
-	  free(response);
-	  return 1;
-     }
-}
-
-/* XXX: CLEANUP: I'd like to move all of the code for
-   creating/cleaning pkg->tmp_unpack_dir directly into pkg.c. (Then,
-   it would make sense to cleanup pkg->tmp_unpack_dir directly from
-   pkg_deinit for example). */
-static int cleanup_temporary_files(ipkg_conf_t *conf, pkg_t *pkg)
-{
-     DIR *tmp_dir;
-     struct dirent *dirent;
-     char *tmp_file;
-
-#ifdef IPKG_DEBUG_NO_TMP_CLEANUP
-#error
-     ipkg_message(conf, IPKG_DEBUG,
-		  "%s: Not cleaning up %s since ipkg compiled with IPKG_DEBUG_NO_TMP_CLEANUP\n",
-		  __FUNCTION__, pkg->tmp_unpack_dir);
-     return 0;
-#endif
-
-     if (pkg->tmp_unpack_dir && file_is_dir(pkg->tmp_unpack_dir)) {
-	  tmp_dir = opendir(pkg->tmp_unpack_dir);
-	  if (tmp_dir) {
-	       while (1) {
-		    dirent = readdir(tmp_dir);
-		    if (dirent == NULL) {
-			 break;
-		    }
-		    sprintf_alloc(&tmp_file, "%s/%s",
-				  pkg->tmp_unpack_dir, dirent->d_name);
-		    if (! file_is_dir(tmp_file)) {
-			 unlink(tmp_file);
-		    }
-		    free(tmp_file);
-	       }
-	       closedir(tmp_dir);
-	       rmdir(pkg->tmp_unpack_dir);
-	       free(pkg->tmp_unpack_dir);
-	       pkg->tmp_unpack_dir = NULL;
-	  }
-     }
-
-     ipkg_message(conf, IPKG_INFO, "cleanup_temporary_files: pkg=%s local_filename=%s tmp_dir=%s\n",
-		  pkg->name, pkg->local_filename, conf->tmp_dir);
-     if (pkg->local_filename && strncmp(pkg->local_filename, conf->tmp_dir, strlen(conf->tmp_dir)) == 0) {
-	  unlink(pkg->local_filename);
-	  free(pkg->local_filename);
-	  pkg->local_filename = NULL;
-     }
-
-     return 0;
-}
-
-static char *backup_filename_alloc(const char *file_name)
-{
-     char *backup;
-
-     sprintf_alloc(&backup, "%s%s", file_name, IPKG_BACKUP_SUFFIX);
-
-     return backup;
-}
-
-int backup_make_backup(ipkg_conf_t *conf, const char *file_name)
-{
-     int err;
-     char *backup;
-    
-     backup = backup_filename_alloc(file_name);
-     err = file_copy(file_name, backup);
-     if (err) {
-	  ipkg_message(conf, IPKG_ERROR,
-		       "%s: Failed to copy %s to %s\n",
-		       __FUNCTION__, file_name, backup);
-     }
-
-     free(backup);
-
-     return err;
-}
-
-static int backup_exists_for(const char *file_name)
-{
-     int ret;
-     char *backup;
-
-     backup = backup_filename_alloc(file_name);
-
-     ret = file_exists(backup);
-
-     free(backup);
-
-     return ret;
-}
-
-static int backup_remove(const char *file_name)
-{
-     char *backup;
-
-     backup = backup_filename_alloc(file_name);
-     unlink(backup);
-     free(backup);
-
-     return 0;
-}
-
-
-
-#ifdef CONFIG_IPKG_PROCESS_ACTIONS
-
-int ipkg_remove_packages(ipkg_conf_t *conf, pkg_vec_t *pkgs_to_remove) 
-{
-     /* first, remove the packages that need removing */
-     for (i = 0 ; i < pkgs_to_remove->len; i++ ) {
-	  pkg_t *pkg = pkgs_to_remove->pkgs[i];
-	  err = ipkg_remove_pkg(conf, pkg,0);
-	  if (err) return err;
-     }
-     return 0;
-}
-
-int ipkg_process_actions_sanity_check(ipkg_conf_t *conf, pkg_vec_t *pkgs_to_remove, pkg_vec_t *pkgs_superseded, pkg_vec_t *pkgs_to_install)
-{
-     int i;
-     /* now one more pass checking on the ones that need to be installed */
-     for (i = 0 ; i < pkgs_to_install->len; i++ ) {
-	  pkg_t *pkg = pkgs_to_install->pkgs[i];
-	  if (pkg->dest == NULL)
-	       pkg->dest = conf->default_dest;
-
-	  pkg->state_want = SW_INSTALL;
-
-	  /* Abhaya: conflicts check */
-	  err = check_conflicts_for(conf, pkg);
-	  if (err) { return err; }
-     }
-     return 0;
-}
-
-int ipkg_process_actions_unpack_packages(ipkg_conf_t *conf, pkg_vec_t *pkgs_to_remove, pkg_vec_t *pkgs_to_install)
-{
-     int i;
-     /* now one more pass checking on the ones that need to be installed */
-     for (i = 0 ; i < pkgs_to_install->len; i++ ) {
-	  pkg_t *pkg = pkgs_to_install->pkgs[i];
-
-	  /* XXX: FEATURE: Need to really support Provides/Replaces: here at some point */
-	  pkg_vec_t *replacees = pkg_vec_alloc();
-	  pkg_get_installed_replacees(conf, pkg, replacees);
-
-	  /* XXX: BUG: we really should treat replacement more like an upgrade
-	   *      Instead, we're going to remove the replacees 
-	   */
-	  err = pkg_remove_installed_replacees(conf, replacees);
-	  if (err) return err;
-	  pkg->state_flag |= SF_REMOVED_REPLACEES;
-     }
-     return 0;
-}
-
-int ipkg_process_actions_unpack_packages(ipkg_conf_t *conf, pkg_vec_t *pkgs_to_remove, pkg_vec_t *pkgs_to_install)
-{
-     int i;
-     /* now one more pass checking on the ones that need to be installed */
-     for (i = 0 ; i < pkgs_to_install->len; i++ ) {
-	  pkg_t *pkg = pkgs_to_install->pkgs[i];
-	  if (pkg->local_filename == NULL) {
-	       err = ipkg_download_pkg(conf, pkg, conf->tmp_dir);
-	       if (err) {
-		    ipkg_message(conf, IPKG_ERROR,
-				 "Failed to download %s. Perhaps you need to run 'ipkg update'?\n",
-				 pkg->name);
-		    return err;
-	       }
-	  }
-	  if (pkg->tmp_unpack_dir == NULL) {
-	       err = unpack_pkg_control_files(conf, pkg);
-	       if (err) return err;
-	  }
-     }
-     return 0;
-}
-
-int ipkg_process_actions_prerm(ipkg_conf_t *conf, pkg_vec_t *pkgs_to_install)
-{
-     int i;
-     /* now one more pass checking on the ones that need to be installed */
-     for (i = 0 ; i < pkgs_to_install->len; i++ ) {
-	  pkg_t *pkg = pkgs_to_install->pkgs[i];
-	  pkg_t *old_pkg = pkg->old_pkg;
-
-	  err = prerm_upgrade_old_pkg(conf, pkg, old_pkg);
-	  if (err) return err;
-
-	  err = prerm_deconfigure_conflictors(conf, pkg, replacees);
-	  if (err) return err;
-
-	  err = preinst_configure(conf, pkg, old_pkg);
-	  if (err) return err;
-
-	  err = backup_modified_conffiles(conf, pkg, old_pkg);
-	  if (err) return err;
-
-	  err = postrm_upgrade_old_pkg(conf, pkg, old_pkg);
-	  if (err) return err;
-     }
-     return 0;
-}
-
-int ipkg_process_actions_install(ipkg_conf_t *conf, pkg_vec_t *pkgs_to_install)
-{
-     int i;
-     /* now one more pass checking on the ones that need to be installed */
-     for (i = 0 ; i < pkgs_to_install->len; i++ ) {
-	  pkg_t *pkg = pkgs_to_install->pkgs[i];
-	  pkg_t *old_pkg = pkg->old_pkg;
-
-	  if (old_pkg) {
-	       old_pkg->state_want = SW_DEINSTALL;
-
-	       if (old_pkg->state_flag & SF_NOPRUNE) {
-		    ipkg_message(conf, IPKG_INFO,
-				 "  not removing obsolesced files because package marked noprune\n");
-	       } else {
-		    ipkg_message(conf, IPKG_INFO,
-				 "  removing obsolesced files\n");
-		    remove_obsolesced_files(conf, pkg, old_pkg);
-	       }
-	  }
-
-	  ipkg_message(conf, IPKG_INFO,
-		       "  installing maintainer scripts\n");
-	  install_maintainer_scripts(conf, pkg, old_pkg);
-
-	  /* the following just returns 0 */
-	  remove_disappeared(conf, pkg);
-
-	  ipkg_message(conf, IPKG_INFO,
-		       "  installing data files\n");
-	  install_data_files(conf, pkg);
-
-	  ipkg_message(conf, IPKG_INFO,
-		       "  resolving conf files\n");
-	  resolve_conffiles(conf, pkg);
-
-	  pkg->state_status = SS_UNPACKED;
-
-	  if (old_pkg) {
-	       old_pkg->state_status = SS_NOT_INSTALLED;
-	  }
-
-	  time(&pkg->installed_time);
-
-	  ipkg_message(conf, IPKG_INFO,
-		       "  cleanup temp files\n");
-	  cleanup_temporary_files(conf, pkg);
-
-	  if (pkg->parent)
-	       pkg->parent->state_status = pkg->state_status;
-     }
-     return 0;
-}
-
-int ipkg_process_actions_unwind_prerm(ipkg_conf_t *conf, pkg_vec_t *pkgs_to_install)
-{
-     int i;
-     /* now one more pass checking on the ones that need to be installed */
-     for (i = 0 ; i < pkgs_to_install->len; i++ ) {
-	  pkg_t *pkg = pkgs_to_install->pkgs[i];
-	  pkg_t *old_pkg = pkg->old_pkg;
-
-	  if (old_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)
-		    check_data_file_clashes_unwind(conf, pkg, old_pkg);
-	       if (old_pkg->state_flags & SF_BACKUP_MODIFIED_CONFFILES)
-		    backup_modified_conffiles_unwind(conf, pkg, old_pkg);
-	       if (old_pkg->state_flags & SF_PREINST_CONFIGURE)
-		    preinst_configure_unwind(conf, pkg, old_pkg);
-	       if (old_pkg->state_flags & SF_DECONFIGURE_CONFLICTORS)
-		    prerm_deconfigure_conflictors_unwind(conf, pkg, replacees);
-	       if (old_pkg->state_flags & SF_PRERM_UPGRADE)
-		    prerm_upgrade_old_pkg_unwind(conf, pkg, old_pkg);
-
-	       if (old_pkg->state_flags & SF_REMOVED_REPLACEES)
-		    remove_installed_replacees_unwind(conf, pkg, old_pkg);
-
-	  }
-     }
-     return 0;
-}
-
-/* 
- * Perform all the actions.
- *
- * pkgs_to_remove are packages marked for removal.
- * pkgs_superseded are the old packages being replaced by upgrades.
- *
- * Assumes pkgs_to_install includes all dependences, recursively, sorted in installable order.
- */
-int ipkg_process_actions(ipkg_conf_t *conf, pkg_vec_t *pkgs_to_remove, pkg_vec_t *pkgs_superseded, pkg_vec_t *pkgs_to_install)
-{
-     int err;
-     int i;
-
-     err = ipkg_remove_packages(conf, pkgs_to_remove);
-     if (err) return err;
-
-     err = ipkg_process_actions_sanity_check(conf, pkgs_superseded, pkgs_to_install);
-     if (err) return err;
-
-     err = ipkg_process_actions_remove_replacees(conf, pkgs_to_install);
-     if (err) goto UNWIND;
-
-     /* @@@@ look at ipkg_install_pkg for handling replacements */
-     err = ipkg_process_actions_unpack_packages(conf, pkgs_to_install);
-     if (err) goto UNWIND;
-
-     /* 
-      * Now that we have the packages unpacked, we can look for data
-      * file clashes.  First, we mark the files from the superseded
-      * packages as obsolete.  Then we scan the files in
-      * pkgs_to_install, and only complain about clashes with
-      * non-obsolete files.
-      */
-
-     err = ipkg_process_actions_check_data_file_clashes(conf, pkgs_superseded, pkgs_to_install);
-     if (err) goto UNWIND;
-
-     /* this was before checking data file clashes */
-     err = ipkg_process_actions_prerm(conf, pkgs_superseded, pkgs_to_install);
-     if (err) goto UNWIND;
-
-     /* point of no return: no unwinding after this */
-     err = ipkg_process_actions_install(conf, pkgs_to_install);
-     if (err) return err;
-
-     ipkg_message(conf, IPKG_INFO, "Done.\n");
-     return 0;
-
- UNWIND:
-     ipkg_process_actions_unwind(conf, pkgs_to_install);
-
-     ipkg_message(conf, IPKG_INFO,
-		  "  cleanup temp files\n");
-     cleanup_temporary_files(conf, pkg);
-
-     ipkg_message(conf, IPKG_INFO,
-		  "Failed.\n");
-     return err;
-}
-
-#endif

Deleted: trunk/src/target/ipkg/ipkg_install.h
===================================================================
--- trunk/src/target/ipkg/ipkg_install.h	2008-01-18 11:05:46 UTC (rev 3878)
+++ trunk/src/target/ipkg/ipkg_install.h	2008-01-18 11:28:48 UTC (rev 3879)
@@ -1,35 +0,0 @@
-/* ipkg_install.h - the itsy package management system
-
-   Carl D. Worth
-
-   Copyright (C) 2001 University of Southern California
-
-   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.
-*/
-
-#ifndef IPKG_INSTALL_H
-#define IPKG_INSTALL_H
-
-#include "pkg.h"
-#include "ipkg_conf.h"
-
-ipkg_error_t ipkg_install_by_name(ipkg_conf_t *conf, const char *pkg_name);
-ipkg_error_t ipkg_install_multi_by_name(ipkg_conf_t *conf, const char *pkg_name);
-int ipkg_install_from_file(ipkg_conf_t *conf, const char *filename);
-int ipkg_install_pkg(ipkg_conf_t *conf, pkg_t *pkg,int from_upgrading);
-int satisfy_dependencies_for(ipkg_conf_t *conf, pkg_t *pkg);
-
-int ipkg_satisfy_all_dependences(ipkg_conf_t *conf);
-
-int pkg_mark_dependencies_for_installation(ipkg_conf_t *conf, pkg_t *pkg_name, pkg_vec_t *pkgs_needed);
-int name_mark_dependencies_for_installation(ipkg_conf_t *conf, const char *pkg_name, pkg_vec_t *pkgs_needed);
-
-#endif

Deleted: trunk/src/target/ipkg/ipkg_message.c
===================================================================
--- trunk/src/target/ipkg/ipkg_message.c	2008-01-18 11:05:46 UTC (rev 3878)
+++ trunk/src/target/ipkg/ipkg_message.c	2008-01-18 11:28:48 UTC (rev 3879)
@@ -1,61 +0,0 @@
-/* ipkg_message.c - the itsy package management system
-
-   Copyright (C) 2003 Daniele Nicolodi <daniele at grinta.net>
-
-   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 "ipkg_conf.h"
-#include "ipkg_message.h"
-
-#ifndef IPKG_LIB
-
-void
-ipkg_message (ipkg_conf_t * conf, message_level_t level, char *fmt, ...)
-{
-	va_list ap;
-
-	if (conf && (conf->verbosity < level))
-	{
-		return;
-	}
-	else
-	{
-
-		va_start (ap, fmt);
-		vprintf (fmt, ap);
-		va_end (ap);
-	}
-}
-
-#else
-
-#include "libipkg.h"
-
-//#define ipkg_message(conf, level, fmt, arg...) ipkg_cb_message(conf, level, fmt, ## arg)
-
-void
-ipkg_message (ipkg_conf_t * conf, message_level_t level, char *fmt, ...)
-{
-	va_list ap;
-	char ts[256];
-
-	if (ipkg_cb_message)
-	{
-		va_start (ap, fmt);
-		vsnprintf (ts,256,fmt, ap);
-		va_end (ap);
-		ipkg_cb_message(conf,level,ts);
-	}
-}
-#endif

Deleted: trunk/src/target/ipkg/ipkg_message.h
===================================================================
--- trunk/src/target/ipkg/ipkg_message.h	2008-01-18 11:05:46 UTC (rev 3878)
+++ trunk/src/target/ipkg/ipkg_message.h	2008-01-18 11:28:48 UTC (rev 3879)
@@ -1,32 +0,0 @@
-/* ipkg_message.h - the itsy package management system
-
-   Copyright (C) 2003 Daniele Nicolodi <daniele at grinta.net>
-
-   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.
-*/
-
-#ifndef _IPKG_MESSAGE_H_
-#define _IPKG_MESSAGE_H_
-
-#include "ipkg.h"
-#include "ipkg_conf.h"
-
-typedef enum {
-     IPKG_ERROR,	/* error conditions */
-     IPKG_NOTICE,	/* normal but significant condition */
-     IPKG_INFO,		/* informational message */
-     IPKG_DEBUG,	/* debug level message */
-     IPKG_DEBUG2,	/* more debug level message */
-} message_level_t;
-
-extern void ipkg_message(ipkg_conf_t *conf, message_level_t level, char *fmt, ...);
-
-#endif /* _IPKG_MESSAGE_H_ */

Deleted: trunk/src/target/ipkg/ipkg_remove.c
===================================================================
--- trunk/src/target/ipkg/ipkg_remove.c	2008-01-18 11:05:46 UTC (rev 3878)
+++ trunk/src/target/ipkg/ipkg_remove.c	2008-01-18 11:28:48 UTC (rev 3879)
@@ -1,383 +0,0 @@
-/* ipkg_remove.c - the itsy package management system
-
-   Carl D. Worth
-
-   Copyright (C) 2001 University of Southern California
-
-   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 "ipkg_message.h"
-
-#include <glob.h>
-
-#include "ipkg_remove.h"
-
-#include "file_util.h"
-#include "sprintf_alloc.h"
-#include "str_util.h"
-
-#include "ipkg_cmd.h"
-
-/*
- * Returns number of the number of packages depending on the packages provided by this package.
- * Every package implicitly provides itself.
- */
-int pkg_has_installed_dependents(ipkg_conf_t *conf, abstract_pkg_t *parent_apkg, pkg_t *pkg, abstract_pkg_t *** pdependents)
-{
-     int nprovides = pkg->provides_count;
-     abstract_pkg_t **provides = pkg->provides;
-     int n_installed_dependents = 0;
-     int i;
-     for (i = 0; i <= nprovides; i++) {
-	  abstract_pkg_t *providee = provides[i];
-	  abstract_pkg_t **dependers = providee->depended_upon_by;
-	  abstract_pkg_t *dep_ab_pkg;
-	  if (dependers == NULL)
-	       continue;
-	  while ((dep_ab_pkg = *dependers++) != NULL) {
-	       if (dep_ab_pkg->state_status == SS_INSTALLED){
-		    n_installed_dependents++;
-               }
-	  }
-
-     }
-     /* if caller requested the set of installed dependents */
-     if (pdependents) {
-	  int p = 0;
-	  abstract_pkg_t **dependents = (abstract_pkg_t **)malloc((n_installed_dependents+1)*sizeof(abstract_pkg_t *));
-
-          if ( dependents == NULL ){
-              fprintf(stderr,"%s Unable to allocate memory. REPORT THIS BUG IN BUGZILLA PLEASE\n", __FUNCTION__);
-              return -1;  
-          }
-
-	  *pdependents = dependents;
-	  for (i = 0; i <= nprovides; i++) {
-	       abstract_pkg_t *providee = provides[i];
-	       abstract_pkg_t **dependers = providee->depended_upon_by;
-	       abstract_pkg_t *dep_ab_pkg;
-	       if (dependers == NULL)
-		    continue;
-	       while ((dep_ab_pkg = *dependers++) != NULL) {
-		    if (dep_ab_pkg->state_status == SS_INSTALLED && !(dep_ab_pkg->state_flag & SF_MARKED)) {
-			 dependents[p++] = dep_ab_pkg;
-			 dep_ab_pkg->state_flag |= SF_MARKED;
-		    }
-	       }
-	  }
-	  dependents[p] = NULL;
-	  /* now clear the marks */
-	  for (i = 0; i < p; i++) {
-	       abstract_pkg_t *dep_ab_pkg = dependents[i];
-	       dep_ab_pkg->state_flag &= ~SF_MARKED;
-	  }
-     }
-     return n_installed_dependents;
-}
-
-int ipkg_remove_dependent_pkgs (ipkg_conf_t *conf, pkg_t *pkg, abstract_pkg_t **dependents)
-{
-    int i;
-    int a;
-    int count;
-    pkg_vec_t *dependent_pkgs = pkg_vec_alloc();
-    abstract_pkg_t * ab_pkg;
-
-    if((ab_pkg = pkg->parent) == NULL){
-	fprintf(stderr, "%s: unable to get dependent pkgs. pkg %s isn't in hash table\n",
-		__FUNCTION__, pkg->name);
-	return 0;
-    }
-    
-    if (dependents == NULL)
-	    return 0;
-
-    // here i am using the dependencies_checked
-    if (ab_pkg->dependencies_checked == 2) // variable to make out whether this package
-	return 0;			   // has already been encountered in the process
-	                                   // of marking packages for removal - Karthik
-    ab_pkg->dependencies_checked = 2;
-
-    i = 0;
-    count = 1;
-    while (dependents [i] != NULL) {
-        abstract_pkg_t *dep_ab_pkg = dependents[i];
-	
-	if (dep_ab_pkg->dependencies_checked == 2){
-	    i++;
-	    continue;	
-        }
-        if (dep_ab_pkg->state_status == SS_INSTALLED) {
-            for (a = 0; a < dep_ab_pkg->pkgs->len; a++) {
-                pkg_t *dep_pkg = dep_ab_pkg->pkgs->pkgs[a];
-                if (dep_pkg->state_status == SS_INSTALLED) {
-                    pkg_vec_insert(dependent_pkgs, dep_pkg);
-                    count++;
-                }
-            }
-        }
-	i++;
-	/* 1 - to keep track of visited ab_pkgs when checking for possiblility of a broken removal of pkgs.
-	 * 2 - to keep track of pkgs whose deps have been checked alrdy  - Karthik */	
-    }
-    
-    if (count == 1)
-	    return 0;
-    
-    
-    for (i = 0; i < dependent_pkgs->len; i++) {
-        int err = ipkg_remove_pkg(conf, dependent_pkgs->pkgs[i],0);
-        if (err)
-            return err;
-    }
-    return 0;
-}
-
-static int user_prefers_removing_dependents(ipkg_conf_t *conf, abstract_pkg_t *abpkg, pkg_t *pkg, abstract_pkg_t **dependents)
-{
-    abstract_pkg_t *dep_ab_pkg;
-    ipkg_message(conf, IPKG_ERROR, "Package %s is depended upon by packages:\n", pkg->name);
-    while ((dep_ab_pkg = *dependents++) != NULL) {
-	 if (dep_ab_pkg->state_status == SS_INSTALLED)
-	      ipkg_message(conf, IPKG_ERROR, "\t%s\n", dep_ab_pkg->name);
-    }
-    ipkg_message(conf, IPKG_ERROR, "These might cease to work if package %s is removed.\n\n", pkg->name);
-    ipkg_message(conf, IPKG_ERROR, "");
-    ipkg_message(conf, IPKG_ERROR, "You can force removal of this package with -force-depends.\n");
-    ipkg_message(conf, IPKG_ERROR, "You can force removal of this package and its dependents\n");
-    ipkg_message(conf, IPKG_ERROR, "with -force-removal-of-dependent-packages or -recursive\n");
-    ipkg_message(conf, IPKG_ERROR, "or by setting option force_removal_of_dependent_packages\n");
-    ipkg_message(conf, IPKG_ERROR, "in ipkg.conf.\n");
-    return 0;
-}
-
-int ipkg_remove_pkg(ipkg_conf_t *conf, pkg_t *pkg,int message)
-{
-/* Actually, when "message == 1" I have been called from an upgrade, and not from a normal remove
-   thus I wan't check for essential, as I'm upgrading.
-   I hope it won't break anything :) 
-*/
-     int err;
-     abstract_pkg_t *parent_pkg = NULL;
-	
-     if (pkg->essential && !message) {
-	  if (conf->force_removal_of_essential_packages) {
-	       fprintf(stderr, "WARNING: Removing essential package %s under your coercion.\n"
-		       "\tIf your system breaks, you get to keep both pieces\n",
-		       pkg->name);
-	  } else {
-	       fprintf(stderr, "ERROR: Refusing to remove essential package %s.\n"
-		       "\tRemoving an essential package may lead to an unusable system, but if\n"
-		       "\tyou enjoy that kind of pain, you can force ipkg to proceed against\n"
-		       "\tits will with the option: -force-removal-of-essential-packages\n",
-		       pkg->name);
-	       return IPKG_PKG_IS_ESSENTIAL;
-	  }
-     }
-
-     if ((parent_pkg = pkg->parent) == NULL)
-	  return 0;
-
-     /* only attempt to remove dependent installed packages if
-      * force_depends is not specified or the package is being
-      * replaced.
-      */
-     if (!conf->force_depends
-	 && !(pkg->state_flag & SF_REPLACE)) {
-	  abstract_pkg_t **dependents;
-	  int has_installed_dependents = 
-	       pkg_has_installed_dependents(conf, parent_pkg, pkg, &dependents);
-
-	  if (has_installed_dependents) {
-	       /*
-		* if this package is depended up by others, then either we should
-		* not remove it or we should remove it and all of its dependents 
-		*/
-
-	       if (!conf->force_removal_of_dependent_packages
-		   && !user_prefers_removing_dependents(conf, parent_pkg, pkg, dependents)) {
-		    return IPKG_PKG_HAS_DEPENDENTS;
-	       }
-
-	       /* remove packages depending on this package - Karthik */
-	       err = ipkg_remove_dependent_pkgs (conf, pkg, dependents);
-	       free(dependents);
-	       if (err) return err;
-	  }
-     }
-
-     if ( message==0 ){
-         printf("Removing package %s from %s...\n", pkg->name, pkg->dest->name);
-         fflush(stdout);
-     }
-     pkg->state_flag |= SF_FILELIST_CHANGED;
-
-     pkg->state_want = SW_DEINSTALL;
-     ipkg_state_changed++;
-
-     pkg_run_script(conf, pkg, "prerm", "remove");
-
-     /* DPKG_INCOMPATIBILITY: dpkg is slightly different here. It
-	maintains an empty filelist rather than deleting it. That seems
-	like a big pain, and I don't see that that should make a big
-	difference, but for anyone who wants tighter compatibility,
-	feel free to fix this. */
-     remove_data_files_and_list(conf, pkg);
-
-     pkg_run_script(conf, pkg, "postrm", "remove");
-
-     remove_maintainer_scripts_except_postrm(conf, pkg);
-
-     /* Aman Gupta - Since ipkg is made for handheld devices with limited
-      * space, it doesn't make sense to leave extra configurations, files, 
-      * and maintainer scripts left around. So, we make remove like purge, 
-      * and take out all the crap :) */
-
-     remove_postrm(conf, pkg);
-     pkg->state_status = SS_NOT_INSTALLED;
-
-     if (parent_pkg) 
-	  parent_pkg->state_status = SS_NOT_INSTALLED;
-
-     return 0;
-}
-
-int ipkg_purge_pkg(ipkg_conf_t *conf, pkg_t *pkg)
-{
-    ipkg_remove_pkg(conf, pkg,0);
-    return 0;
-}
-
-int remove_data_files_and_list(ipkg_conf_t *conf, pkg_t *pkg)
-{
-     str_list_t installed_dirs;
-     str_list_t *installed_files;
-     str_list_elt_t *iter;
-     char *file_name;
-     conffile_t *conffile;
-     int removed_a_dir;
-     pkg_t *owner;
-
-     str_list_init(&installed_dirs);
-     installed_files = pkg_get_installed_files(pkg);
-
-     for (iter = installed_files->head; iter; iter = iter->next) {
-	  file_name = iter->data;
-
-	  if (file_is_dir(file_name)) {
-	       str_list_append(&installed_dirs, strdup(file_name));
-	       continue;
-	  }
-
-	  conffile = pkg_get_conffile(pkg, file_name);
-	  if (conffile) {
-	       /* XXX: QUESTION: Is this right? I figure we only need to
-		  save the conffile if it has been modified. Is that what
-		  dpkg does? Or does dpkg preserve all conffiles? If so,
-		  this seems like a better thing to do to conserve
-		  space. */
-	       if (conffile_has_been_modified(conf, conffile)) {
-		    printf("  not deleting modified conffile %s\n", file_name);
-		    fflush(stdout);
-		    continue;
-	       }
-	  }
-
-	  ipkg_message(conf, IPKG_INFO, "  deleting %s (noaction=%d)\n", file_name, conf->noaction);
-	  if (!conf->noaction)
-	       unlink(file_name);
-     }
-
-     if (!conf->noaction) {
-	  do {
-	       removed_a_dir = 0;
-	       for (iter = installed_dirs.head; iter; iter = iter->next) {
-		    file_name = iter->data;
-	    
-		    if (rmdir(file_name) == 0) {
-			 ipkg_message(conf, IPKG_INFO, "  deleting %s\n", file_name);
-			 removed_a_dir = 1;
-			 str_list_remove(&installed_dirs, &iter);
-		    }
-	       }
-	  } while (removed_a_dir);
-     }
-
-     pkg_free_installed_files(pkg);
-     /* We have to remove the file list now, so that
-	find_pkg_owning_file does not always just report this package */
-     pkg_remove_installed_files_list(conf, pkg);
-
-     /* Don't print warning for dirs that are provided by other packages */
-     for (iter = installed_dirs.head; iter; iter = iter->next) {
-	  file_name = iter->data;
-
-	  owner = file_hash_get_file_owner(conf, file_name);
-	  if (owner) {
-	       free(iter->data);
-	       iter->data = NULL;
-	       str_list_remove(&installed_dirs, &iter);
-	  }
-     }
-
-     /* cleanup */
-     for (iter = installed_dirs.head; iter; iter = iter->next) {
-	  free(iter->data);
-	  iter->data = NULL;
-     }
-     str_list_deinit(&installed_dirs);
-
-     return 0;
-}
-
-int remove_maintainer_scripts_except_postrm(ipkg_conf_t *conf, pkg_t *pkg)
-{
-    int i, err;
-    char *globpattern;
-    glob_t globbuf;
-    
-    if (conf->noaction) return 0;
-
-    sprintf_alloc(&globpattern, "%s/%s.*",
-		  pkg->dest->info_dir, pkg->name);
-    err = glob(globpattern, 0, NULL, &globbuf);
-    free(globpattern);
-    if (err) {
-	return 0;
-    }
-
-    for (i = 0; i < globbuf.gl_pathc; i++) {
-	if (str_ends_with(globbuf.gl_pathv[i], ".postrm")) {
-	    continue;
-	}
-        ipkg_message(conf, IPKG_INFO, "  deleting %s\n", globbuf.gl_pathv[i]);
-	unlink(globbuf.gl_pathv[i]);
-    }
-    globfree(&globbuf);
-
-    return 0;
-}
-
-int remove_postrm(ipkg_conf_t *conf, pkg_t *pkg)
-{
-    char *postrm_file_name;
-
-    if (conf->noaction) return 0;
-
-    sprintf_alloc(&postrm_file_name, "%s/%s.postrm",
-		  pkg->dest->info_dir, pkg->name);
-    unlink(postrm_file_name);
-    free(postrm_file_name);
-
-    return 0;
-}

Deleted: trunk/src/target/ipkg/ipkg_remove.h
===================================================================
--- trunk/src/target/ipkg/ipkg_remove.h	2008-01-18 11:05:46 UTC (rev 3878)
+++ trunk/src/target/ipkg/ipkg_remove.h	2008-01-18 11:28:48 UTC (rev 3879)
@@ -1,33 +0,0 @@
-/* ipkg_remove.h - the itsy package management system
-
-   Carl D. Worth
-
-   Copyright (C) 2001 University of Southern California
-
-   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.
-*/
-
-#ifndef IPKG_REMOVE_H
-#define IPKG_REMOVE_H
-
-#include "pkg.h"
-#include "ipkg_conf.h"
-
-int ipkg_remove_pkg(ipkg_conf_t *conf, pkg_t *pkg,int message);
-int ipkg_purge_pkg(ipkg_conf_t *conf, pkg_t *pkg);
-int possible_broken_removal_of_packages (ipkg_conf_t *conf, pkg_t *pkg);
-int pkg_has_installed_dependents(ipkg_conf_t *conf, abstract_pkg_t *parent_apkg, pkg_t *pkg, abstract_pkg_t *** pdependents);
-int remove_data_files_and_list(ipkg_conf_t *conf, pkg_t *pkg);
-int remove_maintainer_scripts_except_postrm (ipkg_conf_t *conf, pkg_t *pkg);
-int remove_postrm (ipkg_conf_t *conf, pkg_t *pkg);
-
-
-#endif

Deleted: trunk/src/target/ipkg/ipkg_upgrade.c
===================================================================
--- trunk/src/target/ipkg/ipkg_upgrade.c	2008-01-18 11:05:46 UTC (rev 3878)
+++ trunk/src/target/ipkg/ipkg_upgrade.c	2008-01-18 11:28:48 UTC (rev 3879)
@@ -1,77 +0,0 @@
-/* ipkg_upgrade.c - the itsy package management system
-
-   Carl D. Worth
-   Copyright (C) 2001 University of Southern California
-
-   Copyright (C) 2003 Daniele Nicolodi <daniele at grinta.net>
-
-   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 "ipkg_install.h"
-#include "ipkg_message.h"
-
-int ipkg_upgrade_pkg(ipkg_conf_t *conf, pkg_t *old)
-{
-     pkg_t *new;
-     int cmp;
-     char *old_version, *new_version;
-
-     if (old->state_flag & SF_HOLD) {
-          ipkg_message(conf, IPKG_NOTICE,
-                       "Not upgrading package %s which is marked "
-                       "hold (flags=%#x)\n", old->name, old->state_flag);
-          return 0;
-     }
-
-     new = pkg_hash_fetch_best_installation_candidate_by_name(conf, old->name);
-     if (new == NULL) {
-          old_version = pkg_version_str_alloc(old);
-          ipkg_message(conf, IPKG_NOTICE,
-                       "Assuming locally installed package %s (%s) "
-                       "is up to date.\n", old->name, old_version);
-          free(old_version);
-          return 0;
-     }
-          
-     old_version = pkg_version_str_alloc(old);
-     new_version = pkg_version_str_alloc(new);
-               
-     cmp = pkg_compare_versions(old, new);
-     ipkg_message(conf, IPKG_DEBUG,
-                  "comparing visible versions of pkg %s:"
-                  "\n\t%s is installed "
-                  "\n\t%s is available "
-                  "\n\t%d was comparison result\n",
-                  old->name, old_version, new_version, cmp);
-     if (cmp == 0) {
-          ipkg_message(conf, IPKG_INFO,
-                       "Package %s (%s) installed in %s is up to date.\n",
-                       old->name, old_version, old->dest->name);
-          free(old_version);
-          free(new_version);
-          return 0;
-     } else if (cmp > 0) {
-          ipkg_message(conf, IPKG_NOTICE,
-                       "Not downgrading package %s on %s from %s to %s.\n",
-                       old->name, old->dest->name, old_version, new_version);
-          free(old_version);
-          free(new_version);
-          return 0;
-     } else if (cmp < 0) {
-          new->dest = old->dest;
-          old->state_want = SW_DEINSTALL;
-     }
-
-     new->state_flag |= SF_USER;
-     return ipkg_install_pkg(conf, new,1);
-}

Deleted: trunk/src/target/ipkg/ipkg_upgrade.h
===================================================================
--- trunk/src/target/ipkg/ipkg_upgrade.h	2008-01-18 11:05:46 UTC (rev 3878)
+++ trunk/src/target/ipkg/ipkg_upgrade.h	2008-01-18 11:28:48 UTC (rev 3879)
@@ -1,18 +0,0 @@
-/* ipkg_upgrade.c - the itsy package management system
-
-   Copyright (C) 2003 Daniele Nicolodi <daniele at grinta.net>
-
-   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"
-
-int ipkg_upgrade_pkg(ipkg_conf_t *conf, pkg_t *old);

Deleted: trunk/src/target/ipkg/ipkg_utils.c
===================================================================
--- trunk/src/target/ipkg/ipkg_utils.c	2008-01-18 11:05:46 UTC (rev 3878)
+++ trunk/src/target/ipkg/ipkg_utils.c	2008-01-18 11:28:48 UTC (rev 3879)
@@ -1,183 +0,0 @@
-/* ipkg_utils.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 <sys/vfs.h>
-
-#include "ipkg_utils.h"
-#include "pkg.h"
-#include "pkg_hash.h"
-
-void print_pkg_status(pkg_t * pkg, FILE * file);
-
-int get_available_blocks(char * filesystem)
-{
-     struct statfs sfs;
-
-     if(statfs(filesystem, &sfs)){
-	  fprintf(stderr, "bad statfs\n");
-	  return 0;
-     }
-     /*    fprintf(stderr, "reported fs type %x\n", sfs.f_type); */
-     return ((sfs.f_bavail * sfs.f_bsize) / 1024);
-}
-
-char **read_raw_pkgs_from_file(const char *file_name)
-{
-     FILE *fp; 
-     char **ret;
-    
-     if(!(fp = fopen(file_name, "r"))){
-	  fprintf(stderr, "can't get %s open for read\n", file_name);
-	  return NULL;
-     }
-
-     ret = read_raw_pkgs_from_stream(fp);
-
-     fclose(fp);
-
-     return ret;
-}
-
-char **read_raw_pkgs_from_stream(FILE *fp)
-{    
-     char **raw = NULL, *buf, *scout;
-     int count = 0;
-     size_t size = 512;
-     
-     buf = malloc (size);
-
-     while (fgets(buf, size, fp)) {
-	  while (strlen (buf) == (size - 1)
-		 && buf[size-2] != '\n') {
-	       size_t o = size - 1;
-	       size *= 2;
-	       buf = realloc (buf, size);
-	       if (fgets (buf + o, size - o, fp) == NULL)
-		    break;
-	  }
-	  
-	  if(!(count % 50))
-	       raw = realloc(raw, (count + 50) * sizeof(char *));
-	
-	  if((scout = strchr(buf, '\n')))
-	       *scout = '\0';
-
-	  raw[count++] = strdup(buf);
-     }
-    
-     raw = realloc(raw, (count + 1) * sizeof(char *));
-     raw[count] = NULL;
-
-     free (buf);
-    
-     return raw;
-}
-
-/* something to remove whitespace, a hash pooper */
-char *trim_alloc(char *line)
-{
-     char *new; 
-     char *dest, *src, *end;
-    
-     new = malloc(strlen(line) + 1);
-     if ( new == NULL ){
-        fprintf(stderr,"%s: Unable to allocate memory\n",__FUNCTION__);
-        return NULL;
-     }
-     dest = new, src = line, end = line + (strlen(line) - 1);
-
-     /* remove it from the front */    
-     while(src && 
-	   isspace(*src) &&
-	   *src)
-	  src++;
-     /* and now from the back */
-     while((end > src) &&
-	   isspace(*end))
-	  end--;
-     end++;
-     *end = '\0';
-     strcpy(new, src);
-     /* this does from the first space
-      *  blasting away any versions stuff in depends
-      while(src && 
-      !isspace(*src) &&
-      *src)
-      *dest++ = *src++;
-      *dest = '\0';
-      */
-    
-     return new;
-}
-
-int line_is_blank(const char *line)
-{
-     const char *s;
-
-     for (s = line; *s; s++) {
-	  if (!isspace(*s))
-	       return 0;
-     }
-     return 1;
-}
-
-void push_error_list(struct errlist ** errors, char * msg){
-  struct errlist *err_lst_tmp;
-
-
-  err_lst_tmp = malloc ( sizeof (err_lst_tmp) );
-  err_lst_tmp->errmsg=strdup(msg) ;
-  err_lst_tmp->next = *errors;
-  *errors = err_lst_tmp;
-}
-
-
-void reverse_error_list(struct errlist **errors){
-   struct errlist *result=NULL;
-   struct errlist *current= *errors;
-   struct errlist *next;
-
-   while ( current != NULL ) {
-      next = current->next;
-      current->next=result;
-      result=current;
-      current=next;
-   }
-   *errors=result;
-
-}
-
-       
-void free_error_list(){
-struct errlist *err_tmp_lst;
-
-  err_tmp_lst = error_list;
-
-    while (err_tmp_lst != NULL) {
-      free(err_tmp_lst->errmsg);
-      err_tmp_lst = error_list->next;
-      free(error_list);
-      error_list = err_tmp_lst;
-    }
-
-
-}
-
-       

Deleted: trunk/src/target/ipkg/ipkg_utils.h
===================================================================
--- trunk/src/target/ipkg/ipkg_utils.h	2008-01-18 11:05:46 UTC (rev 3878)
+++ trunk/src/target/ipkg/ipkg_utils.h	2008-01-18 11:28:48 UTC (rev 3879)
@@ -1,29 +0,0 @@
-/* ipkg_utils.h - 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.
-*/
-
-#ifndef IPKG_UTILS_H
-#define IPKG_UTILS_H
-
-#include "pkg.h"
-
-int get_available_blocks(char * filesystem);
-char **read_raw_pkgs_from_file(const char *file_name);
-char **read_raw_pkgs_from_stream(FILE *fp);
-char *trim_alloc(char * line);
-int line_is_blank(const char *line);
-
-#endif

Modified: trunk/src/target/ipkg/libbb/libbb.h
===================================================================
--- trunk/src/target/ipkg/libbb/libbb.h	2008-01-18 11:05:46 UTC (rev 3878)
+++ trunk/src/target/ipkg/libbb/libbb.h	2008-01-18 11:28:48 UTC (rev 3879)
@@ -27,7 +27,7 @@
 
 #include <netdb.h>
 
-// Include because of single use with ipkg
+// Include because of single use with opkg
 #define _BB_INTERNAL_H_
 #define L_archive_offset
 #define L_get_header_ar

Modified: trunk/src/target/ipkg/libbb/unarchive.c
===================================================================
--- trunk/src/target/ipkg/libbb/unarchive.c	2008-01-18 11:05:46 UTC (rev 3878)
+++ trunk/src/target/ipkg/libbb/unarchive.c	2008-01-18 11:28:48 UTC (rev 3879)
@@ -762,23 +762,23 @@
 		free(ared_file);
 		return(output_buffer);
 	} else if (strncmp(ar_magic, "\037\213", 2) == 0) {
-		/* it's a gz file, let's assume it's an ipkg */
-		int unzipped_ipkg_pid;
-		FILE *unzipped_ipkg_stream;
+		/* it's a gz file, let's assume it's an opkg */
+		int unzipped_opkg_pid;
+		FILE *unzipped_opkg_stream;
 		file_header_t *tar_header;
 		archive_offset = 0;
 		fseek(deb_stream, 0, SEEK_SET);
-		unzipped_ipkg_stream = gz_open(deb_stream, &unzipped_ipkg_pid);
+		unzipped_opkg_stream = gz_open(deb_stream, &unzipped_opkg_pid);
 		
-                /*fprintf(stderr, __FUNCTION__ ": processing ipkg %s -- ared_file=%s\n", package_filename, ared_file);*/
+                /*fprintf(stderr, __FUNCTION__ ": processing opkg %s -- ared_file=%s\n", package_filename, ared_file);*/
 		/* walk through outer tar file to find ared_file */
-		while ((tar_header = get_header_tar(unzipped_ipkg_stream)) != NULL) {
+		while ((tar_header = get_header_tar(unzipped_opkg_stream)) != NULL) {
                         int name_offset = 0;
                         if (strncmp(tar_header->name, "./", 2) == 0)
                                 name_offset = 2;
 			if (strcmp(ared_file, tar_header->name+name_offset) == 0) {
 				/* open a stream of decompressed data */
-				uncompressed_stream = gz_open(unzipped_ipkg_stream, &gunzip_pid);
+				uncompressed_stream = gz_open(unzipped_opkg_stream, &gunzip_pid);
 				archive_offset = 0;
                                 /*fprintf(stderr, __FUNCTION__ ":%d: here -- found file\n", __LINE__);*/
 				output_buffer = unarchive(uncompressed_stream, 
@@ -794,11 +794,11 @@
 				fclose(uncompressed_stream);
 				break;
 			}
-			seek_sub_file(unzipped_ipkg_stream, tar_header->size);
+			seek_sub_file(unzipped_opkg_stream, tar_header->size);
 			free_header_tar(tar_header);
 		}
-		gz_close(unzipped_ipkg_pid);
-		fclose(unzipped_ipkg_stream);
+		gz_close(unzipped_opkg_pid);
+		fclose(unzipped_opkg_stream);
 		fclose(deb_stream);
 		free(ared_file);
                 /*fprintf(stderr, __FUNCTION__ ":%d: done\n", __LINE__);*/

Deleted: trunk/src/target/ipkg/libipkg.c
===================================================================
--- trunk/src/target/ipkg/libipkg.c	2008-01-18 11:05:46 UTC (rev 3878)
+++ trunk/src/target/ipkg/libipkg.c	2008-01-18 11:28:48 UTC (rev 3879)
@@ -1,527 +0,0 @@
-/* ipkglib.c - the itsy package management system
-
-   Florina Boor
-
-   Copyright (C) 2003 kernel concepts
-
-   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.
-*/
-
-#ifdef IPKG_LIB
-
-#include "ipkg.h"
-#include "includes.h"
-#include "libipkg.h"
-
-#include "args.h"
-#include "ipkg_conf.h"
-#include "ipkg_cmd.h"
-#include "file_util.h"
-
-
-
-ipkg_message_callback ipkg_cb_message = NULL;
-ipkg_response_callback ipkg_cb_response = NULL;
-ipkg_status_callback ipkg_cb_status = NULL;
-ipkg_list_callback ipkg_cb_list = NULL;
-
-
-int
-ipkg_init (ipkg_message_callback mcall, 
-           ipkg_response_callback rcall,
-           args_t * args)
-{
-	ipkg_cb_message = mcall;
-	ipkg_cb_response = rcall;
-
-	args_init (args);
-
-	return 0;
-}
-
-
-int
-ipkg_deinit (args_t * args)
-{
-	args_deinit (args);
-	ipkg_cb_message = NULL;
-	ipkg_cb_response = NULL;
-
-	/* place other cleanup stuff here */
-
-	return 0;
-}
-
-
-int
-ipkg_packages_list(args_t *args, 
-                   const char *packages, 
-                   ipkg_list_callback cblist,
-                   void *userdata)
-{
-	ipkg_cmd_t *cmd;
-	ipkg_conf_t ipkg_conf;
-	int err;
-
-	err = ipkg_conf_init (&ipkg_conf, args);
-	if (err)
-	{
-		return err;
-	}
-
-	ipkg_cb_list = cblist;
-	/* we need to do this because of static declarations, 
-	 * maybe a good idea to change */
-	cmd = ipkg_cmd_find ("list");
-	if (packages)
-		err = ipkg_cmd_exec (cmd, &ipkg_conf, 1, &packages, userdata);
-	else
-		err = ipkg_cmd_exec (cmd, &ipkg_conf, 0, NULL, userdata);
-	ipkg_cb_list = NULL;
-	ipkg_conf_deinit (&ipkg_conf);
-	return (err);
-}
-
-
-int
-ipkg_packages_status(args_t *args,
-                     const char *packages,
-                     ipkg_status_callback cbstatus,
-                     void *userdata)
-{
-	ipkg_cmd_t *cmd;
-	ipkg_conf_t ipkg_conf;
-	int err;
-
-	err = ipkg_conf_init (&ipkg_conf, args);
-	if (err)
-	{
-		return err;
-	}
-
-	ipkg_cb_status = cbstatus;
-
-	/* we need to do this because of static declarations,
-	 * maybe a good idea to change */
-	cmd = ipkg_cmd_find ("status");
-	if (packages)
-		err = ipkg_cmd_exec (cmd, &ipkg_conf, 1, &packages, userdata);
-	else
-		err = ipkg_cmd_exec (cmd, &ipkg_conf, 0, NULL, userdata);
-
-	ipkg_cb_status = NULL;
-	ipkg_conf_deinit (&ipkg_conf);
-	return (err);
-}
-
-
-int
-ipkg_packages_info(args_t *args,
-                   const char *packages,
-                   ipkg_status_callback cbstatus,
-                   void *userdata)
-{
-	ipkg_cmd_t *cmd;
-	ipkg_conf_t ipkg_conf;
-	int err;
-
-	err = ipkg_conf_init (&ipkg_conf, args);
-	if (err)
-	{
-		return err;
-	}
-
-	ipkg_cb_status = cbstatus;
-
-	/* we need to do this because of static declarations,
-	 * maybe a good idea to change */
-	cmd = ipkg_cmd_find ("info");
-	if (packages)
-		err = ipkg_cmd_exec (cmd, &ipkg_conf, 1, &packages, userdata);
-	else
-		err = ipkg_cmd_exec (cmd, &ipkg_conf, 0, NULL, userdata);
-
-	ipkg_cb_status = NULL;
-	ipkg_conf_deinit (&ipkg_conf);
-	return (err);
-}
-
-
-int
-ipkg_packages_install (args_t * args, const char *name)
-{
-	ipkg_cmd_t *cmd;
-	ipkg_conf_t ipkg_conf;
-	int err;
-
-	/* this error should be handled in application */
-	if (!name || !strlen (name))
-		return (-1);
-
-	err = ipkg_conf_init (&ipkg_conf, args);
-	if (err)
-	{
-		return err;
-	}
-
-	/* we need to do this because of static declarations,
-	 * maybe a good idea to change */
-	cmd = ipkg_cmd_find ("install");
-	err = ipkg_cmd_exec (cmd, &ipkg_conf, 1, &name, NULL);
-
-	ipkg_conf_deinit(&ipkg_conf);
-	return (err);
-}
-
-
-int
-ipkg_packages_remove(args_t *args, const char *name, int purge)
-{
-	ipkg_cmd_t *cmd;
-	ipkg_conf_t ipkg_conf;
-	int err;
-
-	/* this error should be handled in application */
-	if (!name || !strlen (name))
-		return (-1);
-
-	err = ipkg_conf_init (&ipkg_conf, args);
-	if (err)
-	{
-		return err;
-	}
-
-	/* we need to do this because of static declarations, 
-	 * maybe a good idea to change */
-	if (purge)
-		cmd = ipkg_cmd_find ("purge");
-	else
-		cmd = ipkg_cmd_find ("remove");
-
-	err = ipkg_cmd_exec (cmd, &ipkg_conf, 1, &name, NULL);
-	
-	ipkg_conf_deinit(&ipkg_conf);
-	return (err);
-}
-
-
-int 
-ipkg_lists_update(args_t *args)
-{
-	ipkg_cmd_t *cmd;
-	ipkg_conf_t ipkg_conf;
-	int err;
-
-	err = ipkg_conf_init (&ipkg_conf, args);
-	if (err)
-	{
-		return err;
-	}
-
-	/* we need to do this because of static declarations, 
-	 * maybe a good idea to change */
-	cmd = ipkg_cmd_find ("update");
-
-	err = ipkg_cmd_exec (cmd, &ipkg_conf, 0, NULL, NULL);
-	
-	ipkg_conf_deinit(&ipkg_conf);
-	return (err);
-}
-
-
-int 
-ipkg_packages_upgrade(args_t *args)
-{
-	ipkg_cmd_t *cmd;
-	ipkg_conf_t ipkg_conf;
-	int err;
-
-	err = ipkg_conf_init (&ipkg_conf, args);
-	if (err)
-	{
-		return err;
-	}
-
-	/* we need to do this because of static declarations, 
-	 * maybe a good idea to change */
-	cmd = ipkg_cmd_find ("upgrade");
-
-	err = ipkg_cmd_exec (cmd, &ipkg_conf, 0, NULL, NULL);
-	
-	ipkg_conf_deinit(&ipkg_conf);
-	return (err);
-}
-
-
-int
-ipkg_packages_download (args_t * args, const char *name)
-{
-	ipkg_cmd_t *cmd;
-	ipkg_conf_t ipkg_conf;
-	int err;
-
-	/* this error should be handled in application */
-	if (!name || !strlen (name))
-		return (-1);
-
-	err = ipkg_conf_init (&ipkg_conf, args);
-	if (err)
-	{
-		return err;
-	}
-
-	/* we need to do this because of static declarations,
-	 * maybe a good idea to change */
-	cmd = ipkg_cmd_find ("download");
-	err = ipkg_cmd_exec (cmd, &ipkg_conf, 1, &name, NULL);
-
-	ipkg_conf_deinit(&ipkg_conf);
-	return (err);
-}
-
-
-int
-ipkg_package_files(args_t *args, 
-                   const char *name, 
-                   ipkg_list_callback cblist,
-                   void *userdata)
-{
-	ipkg_cmd_t *cmd;
-	ipkg_conf_t ipkg_conf;
-	int err;
-
-	/* this error should be handled in application */
-	if (!name || !strlen (name))
-		return (-1);
-
-	err = ipkg_conf_init (&ipkg_conf, args);
-	if (err)
-	{
-		return err;
-	}
-
-	ipkg_cb_list = cblist;
-	
-	/* we need to do this because of static declarations, 
-	 * maybe a good idea to change */
-	cmd = ipkg_cmd_find ("files");
-
-	err = ipkg_cmd_exec (cmd, &ipkg_conf, 1, &name, userdata);
-	
-	ipkg_cb_list = NULL;
-	ipkg_conf_deinit(&ipkg_conf);
-	return (err);
-}
-
-
-int 
-ipkg_file_search(args_t *args, 
-                const char *file,
-				ipkg_list_callback cblist,
-                void *userdata)
-{
-	ipkg_cmd_t *cmd;
-	ipkg_conf_t ipkg_conf;
-	int err;
-	
-	/* this error should be handled in application */
-	if (!file || !strlen (file))
-		return (-1);
-
-	err = ipkg_conf_init (&ipkg_conf, args);
-	if (err)
-	{
-		return err;
-	}
-
-	ipkg_cb_list = cblist;
-
-	/* we need to do this because of static declarations, 
-	 * maybe a good idea to change */
-	cmd = ipkg_cmd_find ("search");
-	err = ipkg_cmd_exec (cmd, &ipkg_conf, 1, &file, userdata);
-	
-	ipkg_cb_list = NULL;
-	ipkg_conf_deinit(&ipkg_conf);
-	return(err);
-}
-
-
-int 
-ipkg_file_what(args_t *args, const char *file, const char* command)
-{
-	ipkg_cmd_t *cmd;
-	ipkg_conf_t ipkg_conf;
-	int err;
-	
-	/* this error should be handled in application */
-	if (!file || !strlen (file))
-		return (-1);
-
-	err = ipkg_conf_init (&ipkg_conf, args);
-	if (err)
-	{
-		return err;
-	}
-
-	/* we need to do this because of static declarations, 
-	 * maybe a good idea to change */
-	cmd = ipkg_cmd_find (command);
-	err = ipkg_cmd_exec (cmd, &ipkg_conf, 1, &file, NULL);
-	
-	ipkg_conf_deinit(&ipkg_conf);
-	return(err);
-}
-
-#define ipkg_package_whatdepends(args,file) ipkg_file_what(args,file,"whatdepends")
-#define ipkg_package_whatrecommends(args, file) ipkg_file_what(args,file,"whatrecommends")
-#define ipkg_package_whatprovides(args, file) ipkg_file_what(args,file,"whatprovides")
-#define ipkg_package_whatconflicts(args, file) ipkg_file_what(args,file,"whatconflicts")
-#define ipkg_package_whatreplaces(args, file) ipkg_file_what(args,file,"whatreplaces")
-
-
-int default_ipkg_message_callback(ipkg_conf_t *conf, message_level_t level, 
-				  char *msg)
-{
-     if (conf && (conf->verbosity < level)) {
-	  return 0;
-     } else {
-#ifdef IPKG_LIB
-          if ( level == IPKG_ERROR ){
-             push_error_list(&error_list, msg); 
-//	     printf(msg);
-          } else
-#endif
-	     printf(msg);
-     }
-     return 0;
-}
-
-int default_ipkg_list_callback(char *name, char *desc, char *version, 
-			       pkg_state_status_t status, void *userdata)
-{
-     if (desc)
-	  printf("%s - %s - %s\n", name, version, desc);
-     else
-	  printf("%s - %s\n", name, version);
-     return 0;
-}
-
-int default_ipkg_files_callback(char *name, char *desc, char *version,
-                   pkg_state_status_t status, void *userdata)
-{
-     if (desc)
-	  printf("%s\n", desc);
-     return 0;
-}
-
-int default_ipkg_status_callback(char *name, int istatus, char *desc,
-				 void *userdata)
-{
-     printf("%s\n", desc);
-     return 0;
-}
-
-char* default_ipkg_response_callback(char *question)
-{
-     char *response = NULL;
-     printf(question);
-     fflush(stdout);
-     do {
-	  response = (char *)file_read_line_alloc(stdin);
-     } while (response == NULL);
-     return response;
-}
-
-/* This is used for backward compatibility */
-int
-ipkg_op (int argc, char *argv[])
-{
-	int err, optind;
-	args_t args;
-	char *cmd_name;
-	ipkg_cmd_t *cmd;
-	ipkg_conf_t ipkg_conf;
-
-	args_init (&args);
-
-	optind = args_parse (&args, argc, argv);
-	if (optind == argc || optind < 0)
-	{
-		args_usage ("ipkg must have one sub-command argument");
-	}
-
-	cmd_name = argv[optind++];
-/* Pigi: added a flag to disable the checking of structures if the command does not need to 
-         read anything from there.
-*/
-        if ( !strcmp(cmd_name,"print-architecture") ||
-             !strcmp(cmd_name,"print_architecture") ||
-             !strcmp(cmd_name,"print-installation-architecture") ||
-             !strcmp(cmd_name,"print_installation_architecture") )
-           args.nocheckfordirorfile = 1;
-
-/* Pigi: added a flag to disable the reading of feed files  if the command does not need to 
-         read anything from there.
-*/
-        if ( !strcmp(cmd_name,"flag") ||
-             !strcmp(cmd_name,"configure") ||
-             !strcmp(cmd_name,"remove") ||
-             !strcmp(cmd_name,"files") ||
-             !strcmp(cmd_name,"search") ||
-             !strcmp(cmd_name,"compare_versions") ||
-             !strcmp(cmd_name,"compare-versions") ||
-             !strcmp(cmd_name,"list_installed") ||
-             !strcmp(cmd_name,"list-installed") ||
-             !strcmp(cmd_name,"status") )
-           args.noreadfeedsfile = 1;
-
-
-	err = ipkg_conf_init (&ipkg_conf, &args);
-	if (err)
-	{
-		return err;
-	}
-
-	args_deinit (&args);
-
-	ipkg_cb_message = default_ipkg_message_callback;
-	ipkg_cb_response = default_ipkg_response_callback;
-	ipkg_cb_status = default_ipkg_status_callback;
- 	if ( strcmp(cmd_name, "files")==0)
-	     ipkg_cb_list = default_ipkg_files_callback;
- 	else
-	     ipkg_cb_list = default_ipkg_list_callback;
-
-	cmd = ipkg_cmd_find (cmd_name);
-	if (cmd == NULL)
-	{
-		fprintf (stderr, "%s: unknown sub-command %s\n", argv[0],
-			 cmd_name);
-		args_usage (NULL);
-	}
-
-	if (cmd->requires_args && optind == argc)
-	{
-		fprintf (stderr,
-			 "%s: the ``%s'' command requires at least one argument\n",
-			 __FUNCTION__, cmd_name);
-		args_usage (NULL);
-	}
-
-	err = ipkg_cmd_exec (cmd, &ipkg_conf, argc - optind, (const char **) (argv + optind), NULL);
-
-	ipkg_conf_deinit (&ipkg_conf);
-
-	return err;
-}
-
-#endif /* IPKG_LIB */

Deleted: trunk/src/target/ipkg/libipkg.h
===================================================================
--- trunk/src/target/ipkg/libipkg.h	2008-01-18 11:05:46 UTC (rev 3878)
+++ trunk/src/target/ipkg/libipkg.h	2008-01-18 11:28:48 UTC (rev 3879)
@@ -1,88 +0,0 @@
-/* ipkglib.h - the itsy package management system
-
-   Florian Boor <florian.boor at kernelconcepts.de>
-
-   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.
-*/
-
-#ifndef IPKGLIB_H
-#define IPKGLIB_H
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-
-#ifdef IPKG_LIB
-
-#include "ipkg_conf.h"
-#include "ipkg_message.h"
-
-#include "args.h"
-#include "pkg.h"
-
-typedef int (*ipkg_message_callback)(ipkg_conf_t *conf, message_level_t level, 
-	char *msg);
-typedef int (*ipkg_list_callback)(char *name, char *desc, char *version, 
-	pkg_state_status_t status, void *userdata);
-typedef int (*ipkg_status_callback)(char *name, int istatus, char *desc,
-	void *userdata);
-typedef char* (*ipkg_response_callback)(char *question);
-
-extern int ipkg_op(int argc, char *argv[]); /* ipkglib.c */
-extern int ipkg_init (ipkg_message_callback mcall, 
-                      ipkg_response_callback rcall,
-					  args_t * args);
-
-extern int ipkg_deinit (args_t *args);
-extern int ipkg_packages_list(args_t *args, 
-                              const char *packages, 
-                              ipkg_list_callback cblist,
-                              void *userdata);
-extern int ipkg_packages_status(args_t *args, 
-                                const char *packages, 
-                                ipkg_status_callback cbstatus,
-								void *userdata);
-extern int ipkg_packages_info(args_t *args,
-                              const 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_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_package_files(args_t *args,
-                              const 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);
-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);
-extern int ipkg_package_whatconflicts(args_t *args, const char *file);
-extern int ipkg_package_whatreplaces(args_t *args, const char *file);
-
-extern ipkg_message_callback ipkg_cb_message; /* ipkglib.c */
-extern ipkg_response_callback ipkg_cb_response;
-extern ipkg_status_callback ipkg_cb_status;
-extern ipkg_list_callback ipkg_cb_list;
-extern void push_error_list(struct errlist **errors,char * msg);
-extern void reverse_error_list(struct errlist **errors);
-extern void free_error_list();
-
-#endif
-
-
-#endif

Deleted: trunk/src/target/ipkg/libipkg.pc.in
===================================================================
--- trunk/src/target/ipkg/libipkg.pc.in	2008-01-18 11:05:46 UTC (rev 3878)
+++ trunk/src/target/ipkg/libipkg.pc.in	2008-01-18 11:28:48 UTC (rev 3879)
@@ -1,11 +0,0 @@
-prefix=@prefix@
-exec_prefix=${prefix}
-libdir=${exec_prefix}/lib
-includedir=${prefix}/include
-
-Name: libipkg
-Description: ipkg package manager library
-Version: @VERSION@
-Libs: -L${libdir} -lipkg
-Cflags: -I${includedir}/libipkg
-

Copied: trunk/src/target/ipkg/libopkg.c (from rev 3877, trunk/src/target/ipkg/libipkg.c)
===================================================================
--- trunk/src/target/ipkg/libipkg.c	2008-01-18 10:03:14 UTC (rev 3877)
+++ trunk/src/target/ipkg/libopkg.c	2008-01-18 11:28:48 UTC (rev 3879)
@@ -0,0 +1,527 @@
+/* opkglib.c - the itsy package management system
+
+   Florina Boor
+
+   Copyright (C) 2003 kernel concepts
+
+   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.
+*/
+
+#ifdef OPKG_LIB
+
+#include "opkg.h"
+#include "includes.h"
+#include "libopkg.h"
+
+#include "args.h"
+#include "opkg_conf.h"
+#include "opkg_cmd.h"
+#include "file_util.h"
+
+
+
+opkg_message_callback opkg_cb_message = NULL;
+opkg_response_callback opkg_cb_response = NULL;
+opkg_status_callback opkg_cb_status = NULL;
+opkg_list_callback opkg_cb_list = NULL;
+
+
+int
+opkg_init (opkg_message_callback mcall, 
+           opkg_response_callback rcall,
+           args_t * args)
+{
+	opkg_cb_message = mcall;
+	opkg_cb_response = rcall;
+
+	args_init (args);
+
+	return 0;
+}
+
+
+int
+opkg_deinit (args_t * args)
+{
+	args_deinit (args);
+	opkg_cb_message = NULL;
+	opkg_cb_response = NULL;
+
+	/* place other cleanup stuff here */
+
+	return 0;
+}
+
+
+int
+opkg_packages_list(args_t *args, 
+                   const char *packages, 
+                   opkg_list_callback cblist,
+                   void *userdata)
+{
+	opkg_cmd_t *cmd;
+	opkg_conf_t opkg_conf;
+	int err;
+
+	err = opkg_conf_init (&opkg_conf, args);
+	if (err)
+	{
+		return err;
+	}
+
+	opkg_cb_list = cblist;
+	/* we need to do this because of static declarations, 
+	 * maybe a good idea to change */
+	cmd = opkg_cmd_find ("list");
+	if (packages)
+		err = opkg_cmd_exec (cmd, &opkg_conf, 1, &packages, userdata);
+	else
+		err = opkg_cmd_exec (cmd, &opkg_conf, 0, NULL, userdata);
+	opkg_cb_list = NULL;
+	opkg_conf_deinit (&opkg_conf);
+	return (err);
+}
+
+
+int
+opkg_packages_status(args_t *args,
+                     const char *packages,
+                     opkg_status_callback cbstatus,
+                     void *userdata)
+{
+	opkg_cmd_t *cmd;
+	opkg_conf_t opkg_conf;
+	int err;
+
+	err = opkg_conf_init (&opkg_conf, args);
+	if (err)
+	{
+		return err;
+	}
+
+	opkg_cb_status = cbstatus;
+
+	/* we need to do this because of static declarations,
+	 * maybe a good idea to change */
+	cmd = opkg_cmd_find ("status");
+	if (packages)
+		err = opkg_cmd_exec (cmd, &opkg_conf, 1, &packages, userdata);
+	else
+		err = opkg_cmd_exec (cmd, &opkg_conf, 0, NULL, userdata);
+
+	opkg_cb_status = NULL;
+	opkg_conf_deinit (&opkg_conf);
+	return (err);
+}
+
+
+int
+opkg_packages_info(args_t *args,
+                   const char *packages,
+                   opkg_status_callback cbstatus,
+                   void *userdata)
+{
+	opkg_cmd_t *cmd;
+	opkg_conf_t opkg_conf;
+	int err;
+
+	err = opkg_conf_init (&opkg_conf, args);
+	if (err)
+	{
+		return err;
+	}
+
+	opkg_cb_status = cbstatus;
+
+	/* we need to do this because of static declarations,
+	 * maybe a good idea to change */
+	cmd = opkg_cmd_find ("info");
+	if (packages)
+		err = opkg_cmd_exec (cmd, &opkg_conf, 1, &packages, userdata);
+	else
+		err = opkg_cmd_exec (cmd, &opkg_conf, 0, NULL, userdata);
+
+	opkg_cb_status = NULL;
+	opkg_conf_deinit (&opkg_conf);
+	return (err);
+}
+
+
+int
+opkg_packages_install (args_t * args, const char *name)
+{
+	opkg_cmd_t *cmd;
+	opkg_conf_t opkg_conf;
+	int err;
+
+	/* this error should be handled in application */
+	if (!name || !strlen (name))
+		return (-1);
+
+	err = opkg_conf_init (&opkg_conf, args);
+	if (err)
+	{
+		return err;
+	}
+
+	/* we need to do this because of static declarations,
+	 * maybe a good idea to change */
+	cmd = opkg_cmd_find ("install");
+	err = opkg_cmd_exec (cmd, &opkg_conf, 1, &name, NULL);
+
+	opkg_conf_deinit(&opkg_conf);
+	return (err);
+}
+
+
+int
+opkg_packages_remove(args_t *args, const char *name, int purge)
+{
+	opkg_cmd_t *cmd;
+	opkg_conf_t opkg_conf;
+	int err;
+
+	/* this error should be handled in application */
+	if (!name || !strlen (name))
+		return (-1);
+
+	err = opkg_conf_init (&opkg_conf, args);
+	if (err)
+	{
+		return err;
+	}
+
+	/* we need to do this because of static declarations, 
+	 * maybe a good idea to change */
+	if (purge)
+		cmd = opkg_cmd_find ("purge");
+	else
+		cmd = opkg_cmd_find ("remove");
+
+	err = opkg_cmd_exec (cmd, &opkg_conf, 1, &name, NULL);
+	
+	opkg_conf_deinit(&opkg_conf);
+	return (err);
+}
+
+
+int 
+opkg_lists_update(args_t *args)
+{
+	opkg_cmd_t *cmd;
+	opkg_conf_t opkg_conf;
+	int err;
+
+	err = opkg_conf_init (&opkg_conf, args);
+	if (err)
+	{
+		return err;
+	}
+
+	/* we need to do this because of static declarations, 
+	 * maybe a good idea to change */
+	cmd = opkg_cmd_find ("update");
+
+	err = opkg_cmd_exec (cmd, &opkg_conf, 0, NULL, NULL);
+	
+	opkg_conf_deinit(&opkg_conf);
+	return (err);
+}
+
+
+int 
+opkg_packages_upgrade(args_t *args)
+{
+	opkg_cmd_t *cmd;
+	opkg_conf_t opkg_conf;
+	int err;
+
+	err = opkg_conf_init (&opkg_conf, args);
+	if (err)
+	{
+		return err;
+	}
+
+	/* we need to do this because of static declarations, 
+	 * maybe a good idea to change */
+	cmd = opkg_cmd_find ("upgrade");
+
+	err = opkg_cmd_exec (cmd, &opkg_conf, 0, NULL, NULL);
+	
+	opkg_conf_deinit(&opkg_conf);
+	return (err);
+}
+
+
+int
+opkg_packages_download (args_t * args, const char *name)
+{
+	opkg_cmd_t *cmd;
+	opkg_conf_t opkg_conf;
+	int err;
+
+	/* this error should be handled in application */
+	if (!name || !strlen (name))
+		return (-1);
+
+	err = opkg_conf_init (&opkg_conf, args);
+	if (err)
+	{
+		return err;
+	}
+
+	/* we need to do this because of static declarations,
+	 * maybe a good idea to change */
+	cmd = opkg_cmd_find ("download");
+	err = opkg_cmd_exec (cmd, &opkg_conf, 1, &name, NULL);
+
+	opkg_conf_deinit(&opkg_conf);
+	return (err);
+}
+
+
+int
+opkg_package_files(args_t *args, 
+                   const char *name, 
+                   opkg_list_callback cblist,
+                   void *userdata)
+{
+	opkg_cmd_t *cmd;
+	opkg_conf_t opkg_conf;
+	int err;
+
+	/* this error should be handled in application */
+	if (!name || !strlen (name))
+		return (-1);
+
+	err = opkg_conf_init (&opkg_conf, args);
+	if (err)
+	{
+		return err;
+	}
+
+	opkg_cb_list = cblist;
+	
+	/* we need to do this because of static declarations, 
+	 * maybe a good idea to change */
+	cmd = opkg_cmd_find ("files");
+
+	err = opkg_cmd_exec (cmd, &opkg_conf, 1, &name, userdata);
+	
+	opkg_cb_list = NULL;
+	opkg_conf_deinit(&opkg_conf);
+	return (err);
+}
+
+
+int 
+opkg_file_search(args_t *args, 
+                const char *file,
+				opkg_list_callback cblist,
+                void *userdata)
+{
+	opkg_cmd_t *cmd;
+	opkg_conf_t opkg_conf;
+	int err;
+	
+	/* this error should be handled in application */
+	if (!file || !strlen (file))
+		return (-1);
+
+	err = opkg_conf_init (&opkg_conf, args);
+	if (err)
+	{
+		return err;
+	}
+
+	opkg_cb_list = cblist;
+
+	/* we need to do this because of static declarations, 
+	 * maybe a good idea to change */
+	cmd = opkg_cmd_find ("search");
+	err = opkg_cmd_exec (cmd, &opkg_conf, 1, &file, userdata);
+	
+	opkg_cb_list = NULL;
+	opkg_conf_deinit(&opkg_conf);
+	return(err);
+}
+
+
+int 
+opkg_file_what(args_t *args, const char *file, const char* command)
+{
+	opkg_cmd_t *cmd;
+	opkg_conf_t opkg_conf;
+	int err;
+	
+	/* this error should be handled in application */
+	if (!file || !strlen (file))
+		return (-1);
+
+	err = opkg_conf_init (&opkg_conf, args);
+	if (err)
+	{
+		return err;
+	}
+
+	/* we need to do this because of static declarations, 
+	 * maybe a good idea to change */
+	cmd = opkg_cmd_find (command);
+	err = opkg_cmd_exec (cmd, &opkg_conf, 1, &file, NULL);
+	
+	opkg_conf_deinit(&opkg_conf);
+	return(err);
+}
+
+#define opkg_package_whatdepends(args,file) opkg_file_what(args,file,"whatdepends")
+#define opkg_package_whatrecommends(args, file) opkg_file_what(args,file,"whatrecommends")
+#define opkg_package_whatprovides(args, file) opkg_file_what(args,file,"whatprovides")
+#define opkg_package_whatconflicts(args, file) opkg_file_what(args,file,"whatconflicts")
+#define opkg_package_whatreplaces(args, file) opkg_file_what(args,file,"whatreplaces")
+
+
+int default_opkg_message_callback(opkg_conf_t *conf, message_level_t level, 
+				  char *msg)
+{
+     if (conf && (conf->verbosity < level)) {
+	  return 0;
+     } else {
+#ifdef OPKG_LIB
+          if ( level == OPKG_ERROR ){
+             push_error_list(&error_list, msg); 
+//	     printf(msg);
+          } else
+#endif
+	     printf(msg);
+     }
+     return 0;
+}
+
+int default_opkg_list_callback(char *name, char *desc, char *version, 
+			       pkg_state_status_t status, void *userdata)
+{
+     if (desc)
+	  printf("%s - %s - %s\n", name, version, desc);
+     else
+	  printf("%s - %s\n", name, version);
+     return 0;
+}
+
+int default_opkg_files_callback(char *name, char *desc, char *version,
+                   pkg_state_status_t status, void *userdata)
+{
+     if (desc)
+	  printf("%s\n", desc);
+     return 0;
+}
+
+int default_opkg_status_callback(char *name, int istatus, char *desc,
+				 void *userdata)
+{
+     printf("%s\n", desc);
+     return 0;
+}
+
+char* default_opkg_response_callback(char *question)
+{
+     char *response = NULL;
+     printf(question);
+     fflush(stdout);
+     do {
+	  response = (char *)file_read_line_alloc(stdin);
+     } while (response == NULL);
+     return response;
+}
+
+/* This is used for backward compatibility */
+int
+opkg_op (int argc, char *argv[])
+{
+	int err, optind;
+	args_t args;
+	char *cmd_name;
+	opkg_cmd_t *cmd;
+	opkg_conf_t opkg_conf;
+
+	args_init (&args);
+
+	optind = args_parse (&args, argc, argv);
+	if (optind == argc || optind < 0)
+	{
+		args_usage ("opkg must have one sub-command argument");
+	}
+
+	cmd_name = argv[optind++];
+/* Pigi: added a flag to disable the checking of structures if the command does not need to 
+         read anything from there.
+*/
+        if ( !strcmp(cmd_name,"print-architecture") ||
+             !strcmp(cmd_name,"print_architecture") ||
+             !strcmp(cmd_name,"print-installation-architecture") ||
+             !strcmp(cmd_name,"print_installation_architecture") )
+           args.nocheckfordirorfile = 1;
+
+/* Pigi: added a flag to disable the reading of feed files  if the command does not need to 
+         read anything from there.
+*/
+        if ( !strcmp(cmd_name,"flag") ||
+             !strcmp(cmd_name,"configure") ||
+             !strcmp(cmd_name,"remove") ||
+             !strcmp(cmd_name,"files") ||
+             !strcmp(cmd_name,"search") ||
+             !strcmp(cmd_name,"compare_versions") ||
+             !strcmp(cmd_name,"compare-versions") ||
+             !strcmp(cmd_name,"list_installed") ||
+             !strcmp(cmd_name,"list-installed") ||
+             !strcmp(cmd_name,"status") )
+           args.noreadfeedsfile = 1;
+
+
+	err = opkg_conf_init (&opkg_conf, &args);
+	if (err)
+	{
+		return err;
+	}
+
+	args_deinit (&args);
+
+	opkg_cb_message = default_opkg_message_callback;
+	opkg_cb_response = default_opkg_response_callback;
+	opkg_cb_status = default_opkg_status_callback;
+ 	if ( strcmp(cmd_name, "files")==0)
+	     opkg_cb_list = default_opkg_files_callback;
+ 	else
+	     opkg_cb_list = default_opkg_list_callback;
+
+	cmd = opkg_cmd_find (cmd_name);
+	if (cmd == NULL)
+	{
+		fprintf (stderr, "%s: unknown sub-command %s\n", argv[0],
+			 cmd_name);
+		args_usage (NULL);
+	}
+
+	if (cmd->requires_args && optind == argc)
+	{
+		fprintf (stderr,
+			 "%s: the ``%s'' command requires at least one argument\n",
+			 __FUNCTION__, cmd_name);
+		args_usage (NULL);
+	}
+
+	err = opkg_cmd_exec (cmd, &opkg_conf, argc - optind, (const char **) (argv + optind), NULL);
+
+	opkg_conf_deinit (&opkg_conf);
+
+	return err;
+}
+
+#endif /* OPKG_LIB */

Copied: trunk/src/target/ipkg/libopkg.h (from rev 3877, trunk/src/target/ipkg/libipkg.h)
===================================================================
--- trunk/src/target/ipkg/libipkg.h	2008-01-18 10:03:14 UTC (rev 3877)
+++ trunk/src/target/ipkg/libopkg.h	2008-01-18 11:28:48 UTC (rev 3879)
@@ -0,0 +1,88 @@
+/* opkglib.h - the itsy package management system
+
+   Florian Boor <florian.boor at kernelconcepts.de>
+
+   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.
+*/
+
+#ifndef OPKGLIB_H
+#define OPKGLIB_H
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+
+#ifdef OPKG_LIB
+
+#include "opkg_conf.h"
+#include "opkg_message.h"
+
+#include "args.h"
+#include "pkg.h"
+
+typedef int (*opkg_message_callback)(opkg_conf_t *conf, message_level_t level, 
+	char *msg);
+typedef int (*opkg_list_callback)(char *name, char *desc, char *version, 
+	pkg_state_status_t status, void *userdata);
+typedef int (*opkg_status_callback)(char *name, int istatus, char *desc,
+	void *userdata);
+typedef char* (*opkg_response_callback)(char *question);
+
+extern int opkg_op(int argc, char *argv[]); /* opkglib.c */
+extern int opkg_init (opkg_message_callback mcall, 
+                      opkg_response_callback rcall,
+					  args_t * args);
+
+extern int opkg_deinit (args_t *args);
+extern int opkg_packages_list(args_t *args, 
+                              const char *packages, 
+                              opkg_list_callback cblist,
+                              void *userdata);
+extern int opkg_packages_status(args_t *args, 
+                                const char *packages, 
+                                opkg_status_callback cbstatus,
+								void *userdata);
+extern int opkg_packages_info(args_t *args,
+                              const char *packages,
+                              opkg_status_callback cbstatus,
+                              void *userdata);
+extern int opkg_packages_install(args_t *args, const char *name);
+extern int opkg_packages_remove(args_t *args, const char *name, int purge);
+extern int opkg_lists_update(args_t *args);
+extern int opkg_packages_upgrade(args_t *args);
+extern int opkg_packages_download(args_t *args, const char *name);
+extern int opkg_package_files(args_t *args,
+                              const char *name,
+							  opkg_list_callback cblist,
+							  void *userdata);
+extern int opkg_file_search(args_t *args,
+                            const char *file,
+							opkg_list_callback cblist,
+							void *userdata);
+extern int opkg_package_whatdepends(args_t *args, const char *file);
+extern int opkg_package_whatrecommends(args_t *args, const char *file);
+extern int opkg_package_whatprovides(args_t *args, const char *file);
+extern int opkg_package_whatconflicts(args_t *args, const char *file);
+extern int opkg_package_whatreplaces(args_t *args, const char *file);
+
+extern opkg_message_callback opkg_cb_message; /* opkglib.c */
+extern opkg_response_callback opkg_cb_response;
+extern opkg_status_callback opkg_cb_status;
+extern opkg_list_callback opkg_cb_list;
+extern void push_error_list(struct errlist **errors,char * msg);
+extern void reverse_error_list(struct errlist **errors);
+extern void free_error_list();
+
+#endif
+
+
+#endif

Copied: trunk/src/target/ipkg/libopkg.pc.in (from rev 3877, trunk/src/target/ipkg/libipkg.pc.in)
===================================================================
--- trunk/src/target/ipkg/libipkg.pc.in	2008-01-18 10:03:14 UTC (rev 3877)
+++ trunk/src/target/ipkg/libopkg.pc.in	2008-01-18 11:28:48 UTC (rev 3879)
@@ -0,0 +1,11 @@
+prefix=@prefix@
+exec_prefix=${prefix}
+libdir=${exec_prefix}/lib
+includedir=${prefix}/include
+
+Name: libopkg
+Description: opkg package manager library
+Version: @VERSION@
+Libs: -L${libdir} -lopkg
+Cflags: -I${includedir}/libopkg
+

Modified: trunk/src/target/ipkg/md5.c
===================================================================
--- trunk/src/target/ipkg/md5.c	2008-01-18 11:05:46 UTC (rev 3878)
+++ trunk/src/target/ipkg/md5.c	2008-01-18 11:28:48 UTC (rev 3879)
@@ -20,8 +20,8 @@
 /* Written by Ulrich Drepper <drepper at gnu.ai.mit.edu> */
 /* Hacked to work with BusyBox by Alfred M. Szmidt <ams at trillian.itslinux.org> */
 
-/* Sucked directly into ipkg since the md5sum functions aren't in libbb
-   Dropped a few functions since ipkg only needs md5_stream.
+/* Sucked directly into opkg since the md5sum functions aren't in libbb
+   Dropped a few functions since opkg only needs md5_stream.
    Got rid of evil, twisted defines of FALSE=1 and TRUE=0
    6 March 2002 Carl Worth <cworth at east.isi.edu>
 */

Modified: trunk/src/target/ipkg/nv_pair.c
===================================================================
--- trunk/src/target/ipkg/nv_pair.c	2008-01-18 11:05:46 UTC (rev 3878)
+++ trunk/src/target/ipkg/nv_pair.c	2008-01-18 11:28:48 UTC (rev 3879)
@@ -15,7 +15,7 @@
    General Public License for more details.
 */
 
-#include "ipkg.h"
+#include "opkg.h"
 
 #include "nv_pair.h"
 #include "str_util.h"

Modified: trunk/src/target/ipkg/nv_pair_list.c
===================================================================
--- trunk/src/target/ipkg/nv_pair_list.c	2008-01-18 11:05:46 UTC (rev 3878)
+++ trunk/src/target/ipkg/nv_pair_list.c	2008-01-18 11:28:48 UTC (rev 3879)
@@ -15,7 +15,7 @@
    General Public License for more details.
 */
 
-#include "ipkg.h"
+#include "opkg.h"
 
 #include "nv_pair.h"
 #include "void_list.h"

Copied: trunk/src/target/ipkg/opkg-frontend.c (from rev 3877, trunk/src/target/ipkg/ipkg-frontend.c)
===================================================================
--- trunk/src/target/ipkg/ipkg-frontend.c	2008-01-18 10:03:14 UTC (rev 3877)
+++ trunk/src/target/ipkg/opkg-frontend.c	2008-01-18 11:28:48 UTC (rev 3879)
@@ -0,0 +1,28 @@
+/* opkg-frontend.c - the itsy package management system
+
+   Florina Boor
+
+   Copyright (C) 2003 kernel concepts
+
+   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.
+   
+   opkg command line frontend using libopkg
+   
+*/
+
+#include "libopkg.h"
+
+/* This is really small, eh? ;-) */
+
+int main(int argc, char *argv[])
+{
+	return opkg_op(argc,argv);	
+}

Copied: trunk/src/target/ipkg/opkg.c (from rev 3877, trunk/src/target/ipkg/ipkg.c)
===================================================================
--- trunk/src/target/ipkg/ipkg.c	2008-01-18 10:03:14 UTC (rev 3877)
+++ trunk/src/target/ipkg/opkg.c	2008-01-18 11:28:48 UTC (rev 3879)
@@ -0,0 +1,81 @@
+/* opkg.c - the itsy package management system
+
+   Carl D. Worth
+
+   Copyright (C) 2001 University of Southern California
+
+   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 "opkg.h"
+
+#include "args.h"
+#include "opkg_conf.h"
+#include "opkg_cmd.h"
+
+int main(int argc, const char *argv[])
+{
+    int err, optind;
+    args_t args;
+    char *cmd_name;
+    opkg_cmd_t *cmd;
+    opkg_conf_t opkg_conf;
+
+    error_list=NULL;
+
+    args_init(&args);
+	
+    optind = args_parse(&args, argc, argv);
+    if (optind == argc || optind < 0) {
+	args_usage("opkg must have one sub-command argument");
+    }
+
+    cmd_name = argv[optind++];
+
+    err = opkg_conf_init(&opkg_conf, &args);
+    if (err) {
+	return err;
+    }
+
+    args_deinit(&args);
+
+    cmd = opkg_cmd_find(cmd_name);
+    if (cmd == NULL) {
+	fprintf(stderr, "%s: unknown sub-command %s\n", argv[0], cmd_name);
+	args_usage(NULL);
+    }
+
+    if (cmd->requires_args && optind == argc) {
+	fprintf(stderr, "%s: the ``%s'' command requires at least one argument\n",
+		__FUNCTION__, cmd_name);
+	args_usage(NULL);
+    }
+
+    err = opkg_cmd_exec(cmd, &opkg_conf, argc - optind, argv + optind);
+
+    if ( err == 0 ) {
+       opkg_message(opkg_conf, OPKG_NOTICE, "Succesfully done.\n");
+    } else {
+       opkg_message(opkg_conf, OPKG_NOTICE, "Error returned. Return value is %d\n.",err);
+
+}
+
+    }
+    /* XXX: FEATURE request: run ldconfig and/or depmod after package needing them are installed or removed */  
+    // opkg_global_postinst();
+
+    opkg_conf_deinit(&opkg_conf);
+
+    return err;
+}
+
+
+

Copied: trunk/src/target/ipkg/opkg.h (from rev 3877, trunk/src/target/ipkg/ipkg.h)
===================================================================
--- trunk/src/target/ipkg/ipkg.h	2008-01-18 10:03:14 UTC (rev 3877)
+++ trunk/src/target/ipkg/opkg.h	2008-01-18 11:28:48 UTC (rev 3879)
@@ -0,0 +1,68 @@
+/* opkg.h - the itsy package management system
+
+   Carl D. Worth
+
+   Copyright (C) 2001 University of Southern California
+
+   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.
+*/
+
+#ifndef OPKG_H
+#define OPKG_H
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#if 0
+#define OPKG_DEBUG_NO_TMP_CLEANUP
+#endif
+
+#include "includes.h"
+#include "opkg_conf.h"
+#include "opkg_message.h"
+
+#define OPKG_PKG_EXTENSION ".ipk"
+#define DPKG_PKG_EXTENSION ".deb"
+
+#define OPKG_LEGAL_PKG_NAME_CHARS "abcdefghijklmnopqrstuvwxyz0123456789.+-"
+#define OPKG_PKG_VERSION_SEP_CHAR '_'
+
+#define OPKG_STATE_DIR_PREFIX OPKGLIBDIR"/opkg"
+#define OPKG_LISTS_DIR_SUFFIX "lists"
+#define OPKG_INFO_DIR_SUFFIX "info"
+#define OPKG_STATUS_FILE_SUFFIX "status"
+
+#define OPKG_BACKUP_SUFFIX "-opkg.backup"
+
+#define OPKG_LIST_DESCRIPTION_LENGTH 128
+
+enum opkg_error {
+    OPKG_SUCCESS = 0,
+    OPKG_PKG_DEPS_UNSATISFIED,
+    OPKG_PKG_IS_ESSENTIAL,
+    OPKG_PKG_HAS_DEPENDENTS,
+    OPKG_PKG_HAS_NO_CANDIDATE
+};
+typedef enum opkg_error opkg_error_t;
+
+extern int opkg_state_changed;
+
+
+struct errlist {
+    char * errmsg;
+    struct errlist * next;
+} ;
+
+struct errlist* error_list;
+
+
+#endif

Copied: trunk/src/target/ipkg/opkg.h.in (from rev 3877, trunk/src/target/ipkg/ipkg.h.in)
===================================================================
--- trunk/src/target/ipkg/ipkg.h.in	2008-01-18 10:03:14 UTC (rev 3877)
+++ trunk/src/target/ipkg/opkg.h.in	2008-01-18 11:28:48 UTC (rev 3879)
@@ -0,0 +1,68 @@
+/* opkg.h - the itsy package management system
+
+   Carl D. Worth
+
+   Copyright (C) 2001 University of Southern California
+
+   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.
+*/
+
+#ifndef OPKG_H
+#define OPKG_H
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#if 0
+#define OPKG_DEBUG_NO_TMP_CLEANUP
+#endif
+
+#include "includes.h"
+#include "opkg_conf.h"
+#include "opkg_message.h"
+
+#define OPKG_PKG_EXTENSION ".ipk"
+#define DPKG_PKG_EXTENSION ".deb"
+
+#define OPKG_LEGAL_PKG_NAME_CHARS "abcdefghijklmnopqrstuvwxyz0123456789.+-"
+#define OPKG_PKG_VERSION_SEP_CHAR '_'
+
+#define OPKG_STATE_DIR_PREFIX OPKGLIBDIR"/opkg"
+#define OPKG_LISTS_DIR_SUFFIX "lists"
+#define OPKG_INFO_DIR_SUFFIX "info"
+#define OPKG_STATUS_FILE_SUFFIX "status"
+
+#define OPKG_BACKUP_SUFFIX "-opkg.backup"
+
+#define OPKG_LIST_DESCRIPTION_LENGTH 128
+
+enum opkg_error {
+    OPKG_SUCCESS = 0,
+    OPKG_PKG_DEPS_UNSATISFIED,
+    OPKG_PKG_IS_ESSENTIAL,
+    OPKG_PKG_HAS_DEPENDENTS,
+    OPKG_PKG_HAS_NO_CANDIDATE
+};
+typedef enum opkg_error opkg_error_t;
+
+extern int opkg_state_changed;
+
+
+struct errlist {
+    char * errmsg;
+    struct errlist * next;
+} ;
+
+struct errlist* error_list;
+
+
+#endif

Copied: trunk/src/target/ipkg/opkg_cmd.c (from rev 3877, trunk/src/target/ipkg/ipkg_cmd.c)
===================================================================
--- trunk/src/target/ipkg/ipkg_cmd.c	2008-01-18 10:03:14 UTC (rev 3877)
+++ trunk/src/target/ipkg/opkg_cmd.c	2008-01-18 11:28:48 UTC (rev 3879)
@@ -0,0 +1,1432 @@
+/* opkg_cmd.c - the itsy package management system
+
+   Carl D. Worth
+
+   Copyright (C) 2001 University of Southern California
+
+   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 <string.h>
+
+#include "opkg.h"
+#include <libgen.h>
+#include <glob.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <signal.h>
+#include <stdio.h>
+#include <dirent.h>
+
+#include "opkg_conf.h"
+#include "opkg_cmd.h"
+#include "opkg_message.h"
+#include "pkg.h"
+#include "pkg_dest.h"
+#include "pkg_parse.h"
+#include "sprintf_alloc.h"
+#include "pkg.h"
+#include "file_util.h"
+#include "str_util.h"
+#include "libbb/libbb.h"
+
+#include <fnmatch.h>
+
+
+#include "opkg_download.h"
+#include "opkg_install.h"
+#include "opkg_upgrade.h"
+#include "opkg_remove.h"
+#include "opkg_configure.h"
+#include "opkg_message.h"
+
+#ifdef OPKG_LIB
+#include "libopkg.h"
+static void *p_userdata = NULL;
+#endif
+
+static int opkg_update_cmd(opkg_conf_t *conf, int argc, char **argv);
+static int opkg_upgrade_cmd(opkg_conf_t *conf, int argc, char **argv);
+static int opkg_list_cmd(opkg_conf_t *conf, int argc, char **argv);
+static int opkg_info_cmd(opkg_conf_t *conf, int argc, char **argv);
+static int opkg_status_cmd(opkg_conf_t *conf, int argc, char **argv);
+static int opkg_install_pending_cmd(opkg_conf_t *conf, int argc, char **argv);
+static int opkg_install_cmd(opkg_conf_t *conf, int argc, char **argv);
+static int opkg_list_installed_cmd(opkg_conf_t *conf, int argc, char **argv);
+static int opkg_remove_cmd(opkg_conf_t *conf, int argc, char **argv);
+static int opkg_purge_cmd(opkg_conf_t *conf, int argc, char **argv);
+static int opkg_flag_cmd(opkg_conf_t *conf, int argc, char **argv);
+static int opkg_files_cmd(opkg_conf_t *conf, int argc, char **argv);
+static int opkg_search_cmd(opkg_conf_t *conf, int argc, char **argv);
+static int opkg_download_cmd(opkg_conf_t *conf, int argc, char **argv);
+static int opkg_depends_cmd(opkg_conf_t *conf, int argc, char **argv);
+static int opkg_whatdepends_cmd(opkg_conf_t *conf, int argc, char **argv);
+static int opkg_whatdepends_recursively_cmd(opkg_conf_t *conf, int argc, char **argv);
+static int opkg_whatsuggests_cmd(opkg_conf_t *conf, int argc, char **argv);
+static int opkg_whatrecommends_cmd(opkg_conf_t *conf, int argc, char **argv);
+static int opkg_whatprovides_cmd(opkg_conf_t *conf, int argc, char **argv);
+static int opkg_whatconflicts_cmd(opkg_conf_t *conf, int argc, char **argv);
+static int opkg_whatreplaces_cmd(opkg_conf_t *conf, int argc, char **argv);
+static int opkg_compare_versions_cmd(opkg_conf_t *conf, int argc, char **argv);
+static int opkg_print_architecture_cmd(opkg_conf_t *conf, int argc, char **argv);
+static int opkg_configure_cmd(opkg_conf_t *conf, int argc, char **argv);
+
+/* XXX: CLEANUP: The usage strings should be incorporated into this
+   array for easier maintenance */
+static opkg_cmd_t cmds[] = {
+     {"update", 0, (opkg_cmd_fun_t)opkg_update_cmd}, 
+     {"upgrade", 0, (opkg_cmd_fun_t)opkg_upgrade_cmd},
+     {"list", 0, (opkg_cmd_fun_t)opkg_list_cmd},
+     {"list_installed", 0, (opkg_cmd_fun_t)opkg_list_installed_cmd},
+     {"info", 0, (opkg_cmd_fun_t)opkg_info_cmd},
+     {"flag", 1, (opkg_cmd_fun_t)opkg_flag_cmd},
+     {"status", 0, (opkg_cmd_fun_t)opkg_status_cmd},
+     {"install_pending", 0, (opkg_cmd_fun_t)opkg_install_pending_cmd},
+     {"install", 1, (opkg_cmd_fun_t)opkg_install_cmd},
+     {"remove", 1, (opkg_cmd_fun_t)opkg_remove_cmd},
+     {"purge", 1, (opkg_cmd_fun_t)opkg_purge_cmd},
+     {"configure", 0, (opkg_cmd_fun_t)opkg_configure_cmd},
+     {"files", 1, (opkg_cmd_fun_t)opkg_files_cmd},
+     {"search", 1, (opkg_cmd_fun_t)opkg_search_cmd},
+     {"download", 1, (opkg_cmd_fun_t)opkg_download_cmd},
+     {"compare_versions", 1, (opkg_cmd_fun_t)opkg_compare_versions_cmd},
+     {"compare-versions", 1, (opkg_cmd_fun_t)opkg_compare_versions_cmd},
+     {"print-architecture", 0, (opkg_cmd_fun_t)opkg_print_architecture_cmd},
+     {"print_architecture", 0, (opkg_cmd_fun_t)opkg_print_architecture_cmd},
+     {"print-installation-architecture", 0, (opkg_cmd_fun_t)opkg_print_architecture_cmd},
+     {"print_installation_architecture", 0, (opkg_cmd_fun_t)opkg_print_architecture_cmd},
+     {"depends", 1, (opkg_cmd_fun_t)opkg_depends_cmd},
+     {"whatdepends", 1, (opkg_cmd_fun_t)opkg_whatdepends_cmd},
+     {"whatdependsrec", 1, (opkg_cmd_fun_t)opkg_whatdepends_recursively_cmd},
+     {"whatrecommends", 1, (opkg_cmd_fun_t)opkg_whatrecommends_cmd},
+     {"whatsuggests", 1, (opkg_cmd_fun_t)opkg_whatsuggests_cmd},
+     {"whatprovides", 1, (opkg_cmd_fun_t)opkg_whatprovides_cmd},
+     {"whatreplaces", 1, (opkg_cmd_fun_t)opkg_whatreplaces_cmd},
+     {"whatconflicts", 1, (opkg_cmd_fun_t)opkg_whatconflicts_cmd},
+};
+
+int opkg_state_changed;
+static void write_status_files_if_changed(opkg_conf_t *conf)
+{
+     if (opkg_state_changed && !conf->noaction) {
+	  opkg_message(conf, OPKG_INFO,
+		       "  writing status file\n");
+	  opkg_conf_write_status_files(conf);
+	  pkg_write_changed_filelists(conf);
+     } else { 
+	  opkg_message(conf, OPKG_NOTICE, "Nothing to be done\n");
+     }
+}
+
+
+static int num_cmds = sizeof(cmds) / sizeof(opkg_cmd_t);
+
+opkg_cmd_t *opkg_cmd_find(const char *name)
+{
+     int i;
+     opkg_cmd_t *cmd;
+
+     for (i=0; i < num_cmds; i++) {
+	  cmd = &cmds[i];
+	  if (strcmp(name, cmd->name) == 0) {
+	       return cmd;
+	  }
+     }
+
+     return NULL;
+}
+
+#ifdef OPKG_LIB
+int opkg_cmd_exec(opkg_cmd_t *cmd, opkg_conf_t *conf, int argc, const char **argv, void *userdata)
+{
+	int result;
+	p_userdata = userdata;
+      
+
+	result = (cmd->fun)(conf, argc, argv);
+        if ( result == 0 ) {
+           opkg_message(conf, OPKG_NOTICE, "Successfully terminated.\n");
+        } else {
+           opkg_message(conf, OPKG_NOTICE, "An error ocurred, return value: %d.\n", result);
+
+        }
+        if ( error_list ) {
+           reverse_error_list(&error_list);
+
+           opkg_message(conf, OPKG_NOTICE, "Collected errors:\n");
+           /* Here we print the errors collected and free the list */
+           while (error_list != NULL) {
+                 opkg_message(conf, OPKG_NOTICE, "%s",error_list->errmsg);
+                 error_list = error_list->next;
+
+           }
+           free_error_list(&error_list);
+
+        }
+   
+	p_userdata = NULL;
+	return result;
+}
+#else
+int opkg_cmd_exec(opkg_cmd_t *cmd, opkg_conf_t *conf, int argc, const char **argv)
+{
+     return (cmd->fun)(conf, argc, argv);
+}
+#endif
+
+static int opkg_update_cmd(opkg_conf_t *conf, int argc, char **argv)
+{
+     int err;
+     int failures;
+     char *lists_dir;
+     pkg_src_list_elt_t *iter;
+     pkg_src_t *src;
+
+ 
+    sprintf_alloc(&lists_dir, "%s", conf->restrict_to_default_dest ? conf->default_dest->lists_dir : conf->lists_dir);
+ 
+    if (! file_is_dir(lists_dir)) {
+	  if (file_exists(lists_dir)) {
+	       opkg_message(conf, OPKG_ERROR,
+			    "%s: ERROR: %s exists, but is not a directory\n",
+			    __FUNCTION__, lists_dir);
+	       free(lists_dir);
+	       return EINVAL;
+	  }
+	  err = file_mkdir_hier(lists_dir, 0755);
+	  if (err) {
+	       opkg_message(conf, OPKG_ERROR,
+			    "%s: ERROR: failed to make directory %s: %s\n",
+			    __FUNCTION__, lists_dir, strerror(errno));
+	       free(lists_dir);
+	       return EINVAL;
+	  }	
+     } 
+
+     failures = 0;
+     for (iter = conf->pkg_src_list.head; iter; iter = iter->next) {
+	  char *url, *list_file_name;
+
+	  src = iter->data;
+
+	  if (src->extra_data)	/* debian style? */
+	      sprintf_alloc(&url, "%s/%s/%s", src->value, src->extra_data, 
+			    src->gzip ? "Packages.gz" : "Packages");
+	  else
+	      sprintf_alloc(&url, "%s/%s", src->value, src->gzip ? "Packages.gz" : "Packages");
+
+	  sprintf_alloc(&list_file_name, "%s/%s", lists_dir, src->name);
+	  if (src->gzip) {
+	      char *tmp;
+	      char *tmp_file_name;
+	      FILE *in, *out;
+
+	      tmp = strdup ("/tmp/opkg.XXXXXX");
+
+	      if (mkdtemp (tmp) == NULL) {
+		  perror ("mkdtemp");
+		  failures++;
+		  continue;
+	      }
+	      
+	      sprintf_alloc (&tmp_file_name, "%s/%s.gz", tmp, src->name);
+	      err = opkg_download(conf, url, tmp_file_name);
+	      if (err == 0) {
+		   opkg_message (conf, OPKG_NOTICE, "Inflating %s\n", url);
+		   in = fopen (tmp_file_name, "r");
+		   out = fopen (list_file_name, "w");
+		   if (in && out)
+			unzip (in, out);
+		   else
+			err = 1;
+		   if (in)
+			fclose (in);
+		   if (out)
+			fclose (out);
+		   unlink (tmp_file_name);
+		   rmdir (tmp);
+		   free (tmp);
+	      }
+	  } else
+	      err = opkg_download(conf, url, list_file_name);
+	  if (err) {
+	       failures++;
+	  } else {
+	       opkg_message(conf, OPKG_NOTICE,
+			    "Updated list of available packages in %s\n",
+			    list_file_name);
+	  }
+	  free(url);
+	  free(list_file_name);
+     }
+     free(lists_dir);
+
+#ifdef CONFIG_CLEAR_SW_INSTALL_FLAG
+#warning here
+     /* clear SW_INSTALL on any package where state is SS_NOT_INSTALLED.
+      * this is a hack to work around poor bookkeeping in old opkg upgrade code 
+      * -Jamey 3/1/03
+      */
+     {
+	  int i;
+	  int changed = 0;
+	  pkg_vec_t *available = pkg_vec_alloc();
+	  pkg_hash_fetch_available(&conf->pkg_hash, available);
+	  opkg_message(conf, OPKG_DEBUG, "Clearing SW_INSTALL for SS_NOT_INSTALLED packages.\n");
+	  for (i = 0; i < available->len; i++) {
+	       pkg_t *pkg = available->pkgs[i];
+	       if (pkg->state_want == SW_INSTALL && pkg->state_status == SS_NOT_INSTALLED) {
+		    opkg_message(conf, OPKG_DEBUG, "Clearing SW_INSTALL on package %s.\n", pkg->name);
+		    pkg->state_want = SW_UNKNOWN;
+		    changed = 1;
+	       }
+	  }
+	  pkg_vec_free(available);
+	  if (changed) {
+	       write_status_files_if_changed(conf);
+	  }
+     }
+#endif
+
+     return failures;
+}
+
+
+/* scan the args passed and cache the local filenames of the packages */
+int opkg_multiple_files_scan(opkg_conf_t *conf, int argc, char **argv)
+{
+     int i;
+     int err;
+    
+     /* 
+      * First scan through package names/urls
+      * For any urls, download the packages and install in database.
+      * For any files, install package info in database.
+      */
+     for (i = 0; i < argc; i ++) {
+	  char *filename = argv [i];
+	  //char *tmp = basename (tmp);
+	  //int tmplen = strlen (tmp);
+
+	  //if (strcmp (tmp + (tmplen - strlen (OPKG_PKG_EXTENSION)), OPKG_PKG_EXTENSION) != 0)
+	  //     continue;
+	  //if (strcmp (tmp + (tmplen - strlen (DPKG_PKG_EXTENSION)), DPKG_PKG_EXTENSION) != 0)
+	  //     continue;
+	
+          opkg_message(conf, OPKG_DEBUG2, "Debug mfs: %s  \n",filename );
+
+	  err = opkg_prepare_url_for_install(conf, filename, &argv[i]);
+	  if (err)
+	    return err;
+     }
+     return 0;
+}
+
+struct opkg_intercept
+{
+    char *oldpath;
+    char *statedir;
+};
+
+typedef struct opkg_intercept *opkg_intercept_t;
+
+opkg_intercept_t opkg_prep_intercepts(opkg_conf_t *conf)
+{
+    opkg_intercept_t ctx;
+    char *newpath;
+    int gen;
+
+    ctx = malloc (sizeof (*ctx));
+    ctx->oldpath = strdup (getenv ("PATH"));
+
+    sprintf_alloc (&newpath, "%s/opkg/intercept:%s", DATADIR, ctx->oldpath);
+    setenv ("PATH", newpath, 1);
+    free (newpath);
+    
+    gen = 0;
+ retry:
+    sprintf_alloc (&ctx->statedir, "/tmp/opkg-intercept-%d-%d", getpid (), gen);
+    if (mkdir (ctx->statedir, 0770) < 0) {
+	if (errno == EEXIST) {
+	    free (ctx->statedir);
+	    gen++;
+	    goto retry;
+	}
+	perror (ctx->statedir);
+	return NULL;
+    }
+    setenv ("OPKG_INTERCEPT_DIR", ctx->statedir, 1);
+    return ctx;
+}
+
+int opkg_finalize_intercepts(opkg_intercept_t ctx)
+{
+    char *cmd;
+    DIR *dir;
+    int err = 0;
+
+    setenv ("PATH", ctx->oldpath, 1);
+    free (ctx->oldpath);
+
+    dir = opendir (ctx->statedir);
+    if (dir) {
+	struct dirent *de;
+	while (de = readdir (dir), de != NULL) {
+	    char *path;
+	    
+	    if (de->d_name[0] == '.')
+		continue;
+	    
+	    sprintf_alloc (&path, "%s/%s", ctx->statedir, de->d_name);
+	    if (access (path, X_OK) == 0) {
+		if (system (path)) {
+		    err = errno;
+		    perror (de->d_name);
+		}
+	    }
+	    free (path);
+	}
+    } else
+	perror (ctx->statedir);
+	
+    sprintf_alloc (&cmd, "rm -rf %s", ctx->statedir);
+    system (cmd);
+    free (cmd);
+
+    free (ctx->statedir);
+    free (ctx);
+
+    return err;
+}
+
+int opkg_configure_packages(opkg_conf_t *conf, char *pkg_name)
+{
+     pkg_vec_t *all;
+     int i;
+     pkg_t *pkg;
+     opkg_intercept_t ic;
+     int r, err = 0;
+
+     opkg_message(conf, OPKG_INFO,
+		  "Configuring unpacked packages\n");
+     fflush( stdout );
+
+     all = pkg_vec_alloc();
+     pkg_hash_fetch_available(&conf->pkg_hash, all);
+
+     ic = opkg_prep_intercepts (conf);
+    
+     for(i = 0; i < all->len; i++) {
+	  pkg = all->pkgs[i];
+
+	  if (pkg_name && fnmatch(pkg_name, pkg->name, 0)) 
+	       continue;
+
+	  if (pkg->state_status == SS_UNPACKED) {
+	       opkg_message(conf, OPKG_NOTICE,
+			    "Configuring %s\n", pkg->name);
+	       fflush( stdout );
+	       r = opkg_configure(conf, pkg);
+	       if (r == 0) {
+		    pkg->state_status = SS_INSTALLED;
+		    pkg->parent->state_status = SS_INSTALLED;
+		    pkg->state_flag &= ~SF_PREFER;
+	       } else {
+		    if (!err)
+			err = r;
+	       }
+	  }
+     }
+
+     r = opkg_finalize_intercepts (ic);
+     if (r && !err)
+	 err = r;
+
+     pkg_vec_free(all);
+     return err;
+}
+
+static opkg_conf_t *global_conf;
+
+static void sigint_handler(int sig)
+{
+     signal(sig, SIG_DFL);
+     opkg_message(NULL, OPKG_NOTICE,
+		  "opkg: interrupted. writing out status database\n");
+     write_status_files_if_changed(global_conf);
+     exit(128 + sig);
+}
+
+static int opkg_install_cmd(opkg_conf_t *conf, int argc, char **argv)
+{
+     int i;
+     char *arg;
+     int err=0;
+
+     global_conf = conf;
+     signal(SIGINT, sigint_handler);
+
+     /*
+      * Now scan through package names and install
+      */
+     for (i=0; i < argc; i++) {
+	  arg = argv[i];
+
+          opkg_message(conf, OPKG_DEBUG2, "Debug install_cmd: %s  \n",arg );
+          err = opkg_prepare_url_for_install(conf, arg, &argv[i]);
+          if (err != EINVAL && err != 0)
+              return err;
+     }
+     pkg_info_preinstall_check(conf);
+
+     for (i=0; i < argc; i++) {
+	  arg = argv[i];
+	  if (conf->multiple_providers)
+	       err = opkg_install_multi_by_name(conf, arg);
+	  else{
+	       err = opkg_install_by_name(conf, arg);
+          }
+	  if (err == OPKG_PKG_HAS_NO_CANDIDATE) {
+	       opkg_message(conf, OPKG_ERROR,
+			    "Cannot find package %s.\n"
+			    "Check the spelling or perhaps run 'opkg update'\n",
+			    arg);
+	  }
+     }
+
+     /* recheck to verify that all dependences are satisfied */
+     if (0) opkg_satisfy_all_dependences(conf);
+
+     opkg_configure_packages(conf, NULL);
+
+     write_status_files_if_changed(conf);
+
+     return err;
+}
+
+static int opkg_upgrade_cmd(opkg_conf_t *conf, int argc, char **argv)
+{
+     int i;
+     pkg_t *pkg;
+     int err;
+
+     global_conf = conf;
+     signal(SIGINT, sigint_handler);
+
+     if (argc) {
+	  for (i=0; i < argc; i++) {
+	       char *arg = argv[i];
+
+               err = opkg_prepare_url_for_install(conf, arg, &arg);
+               if (err != EINVAL && err != 0)
+                   return err;
+	  }
+	  pkg_info_preinstall_check(conf);
+
+	  for (i=0; i < argc; i++) {
+	       char *arg = argv[i];
+	       if (conf->restrict_to_default_dest) {
+		    pkg = pkg_hash_fetch_installed_by_name_dest(&conf->pkg_hash,
+								argv[i],
+								conf->default_dest);
+		    if (pkg == NULL) {
+			 opkg_message(conf, OPKG_NOTICE,
+				      "Package %s not installed in %s\n",
+				      argv[i], conf->default_dest->name);
+			 continue;
+		    }
+	       } else {
+		    pkg = pkg_hash_fetch_installed_by_name(&conf->pkg_hash,
+							   argv[i]);
+	       }
+	       if (pkg)
+		    opkg_upgrade_pkg(conf, pkg);
+	       else {
+		    opkg_install_by_name(conf, arg);
+               }
+	  }
+     } else {
+	  pkg_vec_t *installed = pkg_vec_alloc();
+
+	  pkg_info_preinstall_check(conf);
+
+	  pkg_hash_fetch_all_installed(&conf->pkg_hash, installed);
+	  for (i = 0; i < installed->len; i++) {
+	       pkg = installed->pkgs[i];
+	       opkg_upgrade_pkg(conf, pkg);
+	  }
+	  pkg_vec_free(installed);
+     }
+
+     /* recheck to verify that all dependences are satisfied */
+     if (0) opkg_satisfy_all_dependences(conf);
+
+     opkg_configure_packages(conf, NULL);
+
+     write_status_files_if_changed(conf);
+
+     return 0;
+}
+
+static int opkg_download_cmd(opkg_conf_t *conf, int argc, char **argv)
+{
+     int i, err;
+     char *arg;
+     pkg_t *pkg;
+
+     pkg_info_preinstall_check(conf);
+     for (i = 0; i < argc; i++) {
+	  arg = argv[i];
+
+	  pkg = pkg_hash_fetch_best_installation_candidate_by_name(conf, arg);
+	  if (pkg == NULL) {
+	       opkg_message(conf, OPKG_ERROR,
+			    "Cannot find package %s.\n"
+			    "Check the spelling or perhaps run 'opkg update'\n",
+			    arg);
+	       continue;
+	  }
+
+	  err = opkg_download_pkg(conf, pkg, ".");
+
+	  if (err) {
+	       opkg_message(conf, OPKG_ERROR,
+			    "Failed to download %s\n", pkg->name);
+	  } else {
+	       opkg_message(conf, OPKG_NOTICE,
+			    "Downloaded %s as %s\n",
+			    pkg->name, pkg->local_filename);
+	  }
+     }
+
+     return 0;
+}
+
+
+static int opkg_list_cmd(opkg_conf_t *conf, int argc, char **argv)
+{
+     int i ;
+     pkg_vec_t *available;
+     pkg_t *pkg;
+     char desc_short[OPKG_LIST_DESCRIPTION_LENGTH];
+     char *newline;
+     char *pkg_name = NULL;
+     char *version_str;
+
+     if (argc > 0) {
+	  pkg_name = argv[0];
+     }
+     available = pkg_vec_alloc();
+     pkg_hash_fetch_available(&conf->pkg_hash, available);
+     for (i=0; i < available->len; i++) {
+	  pkg = available->pkgs[i];
+	  /* if we have package name or pattern and pkg does not match, then skip it */
+	  if (pkg_name && fnmatch(pkg_name, pkg->name, 0)) 
+	       continue;
+	  if (pkg->description) {
+	       strncpy(desc_short, pkg->description, OPKG_LIST_DESCRIPTION_LENGTH);
+	  } else {
+	       desc_short[0] = '\0';
+	  }
+	  desc_short[OPKG_LIST_DESCRIPTION_LENGTH - 1] = '\0';
+	  newline = strchr(desc_short, '\n');
+	  if (newline) {
+	       *newline = '\0';
+	  }
+#ifndef OPKG_LIB
+	  printf("%s - %s\n", pkg->name, desc_short);
+#else
+	  if (opkg_cb_list) {
+	  	version_str = pkg_version_str_alloc(pkg);
+	  	opkg_cb_list(pkg->name,desc_short,
+		                             version_str,
+	                                 pkg->state_status,
+	                                 p_userdata);
+		free(version_str);
+	  }
+#endif
+     }
+     pkg_vec_free(available);
+
+     return 0;
+}
+
+
+static int opkg_list_installed_cmd(opkg_conf_t *conf, int argc, char **argv)
+{
+     int i ;
+     pkg_vec_t *available;
+     pkg_t *pkg;
+     char desc_short[OPKG_LIST_DESCRIPTION_LENGTH];
+     char *newline;
+     char *pkg_name = NULL;
+     char *version_str;
+
+     if (argc > 0) {
+	  pkg_name = argv[0];
+     }
+     available = pkg_vec_alloc();
+     pkg_hash_fetch_all_installed(&conf->pkg_hash, available);
+     for (i=0; i < available->len; i++) {
+	  pkg = available->pkgs[i];
+	  /* if we have package name or pattern and pkg does not match, then skip it */
+	  if (pkg_name && fnmatch(pkg_name, pkg->name, 0)) 
+	       continue;
+	  if (pkg->description) {
+	       strncpy(desc_short, pkg->description, OPKG_LIST_DESCRIPTION_LENGTH);
+	  } else {
+	       desc_short[0] = '\0';
+	  }
+	  desc_short[OPKG_LIST_DESCRIPTION_LENGTH - 1] = '\0';
+	  newline = strchr(desc_short, '\n');
+	  if (newline) {
+	       *newline = '\0';
+	  }
+#ifndef OPKG_LIB
+	  printf("%s - %s\n", pkg->name, desc_short);
+#else
+	  if (opkg_cb_list) {
+	  	version_str = pkg_version_str_alloc(pkg);
+	  	opkg_cb_list(pkg->name,desc_short,
+		                             version_str,
+	                                 pkg->state_status,
+	                                 p_userdata);
+		free(version_str);
+	  }
+#endif
+     }
+
+     return 0;
+}
+
+static int opkg_info_status_cmd(opkg_conf_t *conf, int argc, char **argv, int installed_only)
+{
+     int i;
+     pkg_vec_t *available;
+     pkg_t *pkg;
+     char *pkg_name = NULL;
+     char **pkg_fields = NULL;
+     int n_fields = 0;
+     char *buff ; // = (char *)malloc(1);
+
+     if (argc > 0) {
+	  pkg_name = argv[0];
+     }
+     if (argc > 1) {
+	  pkg_fields = &argv[1];
+	  n_fields = argc - 1;
+     }
+
+     available = pkg_vec_alloc();
+     if (installed_only)
+	  pkg_hash_fetch_all_installed(&conf->pkg_hash, available);
+     else
+	  pkg_hash_fetch_available(&conf->pkg_hash, available);
+     for (i=0; i < available->len; i++) {
+	  pkg = available->pkgs[i];
+	  if (pkg_name && fnmatch(pkg_name, pkg->name, 0)) {
+	       continue;
+	  }
+#ifndef OPKG_LIB
+	  if (n_fields) {
+	       for (j = 0; j < n_fields; j++)
+		    pkg_print_field(pkg, stdout, pkg_fields[j]);
+	  } else {
+	       pkg_print_info(pkg, stdout);
+	  }
+#else
+
+	  buff = pkg_formatted_info(pkg);
+          if ( buff ) {
+	       if (opkg_cb_status) opkg_cb_status(pkg->name,
+						  pkg->state_status,
+						  buff,
+						  p_userdata);
+/* 
+   We should not forget that actually the pointer is allocated. 
+   We need to free it :)  ( Thanks florian for seeing the error )
+*/
+               free(buff);
+          }
+#endif
+	  if (conf->verbosity > 1) {
+	       conffile_list_elt_t *iter;
+	       for (iter = pkg->conffiles.head; iter; iter = iter->next) {
+		    conffile_t *cf = iter->data;
+		    int modified = conffile_has_been_modified(conf, cf);
+		    opkg_message(conf, OPKG_NOTICE, "conffile=%s md5sum=%s modified=%d\n",
+				 cf->name, cf->value, modified);
+	       }
+	  }
+     }
+#ifndef OPKG_LIB
+     if (buff)
+	  free(buff);
+#endif
+     pkg_vec_free(available);
+
+     return 0;
+}
+
+static int opkg_info_cmd(opkg_conf_t *conf, int argc, char **argv)
+{
+     return opkg_info_status_cmd(conf, argc, argv, 0);
+}
+
+static int opkg_status_cmd(opkg_conf_t *conf, int argc, char **argv)
+{
+     return opkg_info_status_cmd(conf, argc, argv, 1);
+}
+
+static int opkg_configure_cmd(opkg_conf_t *conf, int argc, char **argv)
+{
+     
+     int err;
+     if (argc > 0) {
+	  char *pkg_name = NULL;
+
+	  pkg_name = argv[0];
+
+	  err = opkg_configure_packages (conf, pkg_name);
+     
+     } else {
+	  err = opkg_configure_packages (conf, NULL);
+     }
+
+     write_status_files_if_changed(conf);
+
+     return err;
+}
+
+static int opkg_install_pending_cmd(opkg_conf_t *conf, int argc, char **argv)
+{
+     int i, err;
+     char *globpattern;
+     glob_t globbuf;
+    
+     sprintf_alloc(&globpattern, "%s/*" OPKG_PKG_EXTENSION, conf->pending_dir);
+     err = glob(globpattern, 0, NULL, &globbuf);
+     free(globpattern);
+     if (err) {
+	  return 0;
+     }
+
+     opkg_message(conf, OPKG_NOTICE,
+		  "The following packages in %s will now be installed.\n",
+		  conf->pending_dir);
+     for (i = 0; i < globbuf.gl_pathc; i++) {
+	  opkg_message(conf, OPKG_NOTICE,
+		       "%s%s", i == 0 ? "" : " ", globbuf.gl_pathv[i]);
+     }
+     opkg_message(conf, OPKG_NOTICE, "\n");
+     for (i = 0; i < globbuf.gl_pathc; i++) {
+	  err = opkg_install_from_file(conf, globbuf.gl_pathv[i]);
+	  if (err == 0) {
+	       err = unlink(globbuf.gl_pathv[i]);
+	       if (err) {
+		    opkg_message(conf, OPKG_ERROR,
+				 "%s: ERROR: failed to unlink %s: %s\n",
+				 __FUNCTION__, globbuf.gl_pathv[i], strerror(err));
+		    return err;
+	       }
+	  }
+     }
+     globfree(&globbuf);
+
+     return err;
+}
+
+static int opkg_remove_cmd(opkg_conf_t *conf, int argc, char **argv)
+{
+     int i,a,done;
+     pkg_t *pkg;
+     pkg_t *pkg_to_remove;
+     pkg_vec_t *available;
+     char *pkg_name = NULL;
+     global_conf = conf;
+     signal(SIGINT, sigint_handler);
+
+// ENH: Add the "no pkg removed" just in case.
+
+    done = 0;
+
+     available = pkg_vec_alloc();
+     pkg_info_preinstall_check(conf);
+     if ( argc > 0 ) {
+        pkg_hash_fetch_all_installed(&conf->pkg_hash, available);
+        for (i=0; i < argc; i++) {
+           pkg_name = malloc(strlen(argv[i])+2);
+           strcpy(pkg_name,argv[i]);
+           for (a=0; a < available->len; a++) {
+               pkg = available->pkgs[a];
+	       if (pkg_name && fnmatch(pkg_name, pkg->name, 0)) {
+                  continue;
+               }
+               if (conf->restrict_to_default_dest) {
+	            pkg_to_remove = pkg_hash_fetch_installed_by_name_dest(&conf->pkg_hash,
+							        pkg->name,
+							        conf->default_dest);
+               } else {
+	            pkg_to_remove = pkg_hash_fetch_installed_by_name(&conf->pkg_hash, pkg->name );
+               }
+        
+               if (pkg == NULL) {
+	            opkg_message(conf, OPKG_ERROR, "Package %s is not installed.\n", pkg->name);
+	            continue;
+               }
+               if (pkg->state_status == SS_NOT_INSTALLED) {    // Added the control, so every already removed package could be skipped
+	            opkg_message(conf, OPKG_ERROR, "Package seems to be %s not installed (STATUS = NOT_INSTALLED).\n", pkg->name);
+                    continue;
+               }
+               opkg_remove_pkg(conf, pkg_to_remove,0);
+               done = 1;
+           }
+           free (pkg_name);
+        }
+        pkg_vec_free(available);
+     } else {
+	  pkg_vec_t *installed_pkgs = pkg_vec_alloc();
+	  int i;
+	  int flagged_pkg_count = 0;
+	  int removed;
+
+	  pkg_hash_fetch_all_installed(&conf->pkg_hash, installed_pkgs);
+
+	  for (i = 0; i < installed_pkgs->len; i++) {
+	       pkg_t *pkg = installed_pkgs->pkgs[i];
+	       if (pkg->state_flag & SF_USER) {
+		    flagged_pkg_count++;
+	       } else {
+		    if (!pkg_has_installed_dependents(conf, pkg->parent, pkg, NULL))
+			 opkg_message(conf, OPKG_NOTICE, "Non-user leaf package: %s\n", pkg->name);
+	       }
+	  }
+	  if (!flagged_pkg_count) {
+	       opkg_message(conf, OPKG_NOTICE, "No packages flagged as installed by user, \n"
+			    "so refusing to uninstall unflagged non-leaf packages\n");
+	       return 0;
+	  }
+
+	  /* find packages not flagged SF_USER (i.e., installed to
+	   * satisfy a dependence) and not having any dependents, and
+	   * remove them */
+	  do {
+	       removed = 0;
+	       for (i = 0; i < installed_pkgs->len; i++) {
+		    pkg_t *pkg = installed_pkgs->pkgs[i];
+		    if (!(pkg->state_flag & SF_USER)
+			&& !pkg_has_installed_dependents(conf, pkg->parent, pkg, NULL)) {
+			 removed++;
+			 opkg_message(conf, OPKG_NOTICE, "Removing non-user leaf package %s\n");
+			 opkg_remove_pkg(conf, pkg,0);
+                         done = 1;
+		    }
+	       }
+	  } while (removed);
+	  pkg_vec_free(installed_pkgs);
+     }
+
+     if ( done == 0 ) 
+        opkg_message(conf, OPKG_NOTICE, "No packages removed.\n");
+
+     write_status_files_if_changed(conf);
+     return 0;
+}
+
+static int opkg_purge_cmd(opkg_conf_t *conf, int argc, char **argv)
+{
+     int i;
+     pkg_t *pkg;
+
+     global_conf = conf;
+     signal(SIGINT, sigint_handler);
+
+     pkg_info_preinstall_check(conf);
+
+     for (i=0; i < argc; i++) {
+	  if (conf->restrict_to_default_dest) {
+	       pkg = pkg_hash_fetch_installed_by_name_dest(&conf->pkg_hash,
+							   argv[i],
+							   conf->default_dest);
+	  } else {
+	       pkg = pkg_hash_fetch_installed_by_name(&conf->pkg_hash, argv[i]);
+	  }
+
+	  if (pkg == NULL) {
+	       opkg_message(conf, OPKG_ERROR,
+			    "Package %s is not installed.\n", argv[i]);
+	       continue;
+	  }
+	  opkg_purge_pkg(conf, pkg);
+     }
+
+     write_status_files_if_changed(conf);
+     return 0;
+}
+
+static int opkg_flag_cmd(opkg_conf_t *conf, int argc, char **argv)
+{
+     int i;
+     pkg_t *pkg;
+     const char *flags = argv[0];
+    
+     global_conf = conf;
+     signal(SIGINT, sigint_handler);
+
+     for (i=1; i < argc; i++) {
+	  if (conf->restrict_to_default_dest) {
+	       pkg = pkg_hash_fetch_installed_by_name_dest(&conf->pkg_hash,
+							   argv[i],
+							   conf->default_dest);
+	  } else {
+	       pkg = pkg_hash_fetch_installed_by_name(&conf->pkg_hash, argv[i]);
+	  }
+
+	  if (pkg == NULL) {
+	       opkg_message(conf, OPKG_ERROR,
+			    "Package %s is not installed.\n", argv[i]);
+	       continue;
+	  }
+          if (( strcmp(flags,"hold")==0)||( strcmp(flags,"noprune")==0)||
+              ( strcmp(flags,"user")==0)||( strcmp(flags,"ok")==0)) {
+	      pkg->state_flag = pkg_state_flag_from_str(flags);
+          }
+/* pb_ asked this feature 03292004 */
+/* Actually I will use only this two, but this is an open for various status */
+          if (( strcmp(flags,"installed")==0)||( strcmp(flags,"unpacked")==0)){
+	      pkg->state_status = pkg_state_status_from_str(flags);
+          }
+	  opkg_state_changed++;
+	  opkg_message(conf, OPKG_NOTICE,
+		       "Setting flags for package %s to %s\n",
+		       pkg->name, flags);
+     }
+
+     write_status_files_if_changed(conf);
+     return 0;
+}
+
+static int opkg_files_cmd(opkg_conf_t *conf, int argc, char **argv)
+{
+     pkg_t *pkg;
+     str_list_t *installed_files;
+     str_list_elt_t *iter;
+     char *pkg_version;
+     size_t buff_len = 8192;
+     size_t used_len;
+     char *buff ;
+
+     buff = (char *)malloc(buff_len);
+     if ( buff == NULL ) {
+        fprintf( stderr,"%s: Unable to allocate memory \n",__FUNCTION__);
+        return ENOMEM;
+     }
+ 
+     if (argc < 1) {
+	  return EINVAL;
+     }
+
+     pkg = pkg_hash_fetch_installed_by_name(&conf->pkg_hash,
+					    argv[0]);
+     if (pkg == NULL) {
+	  opkg_message(conf, OPKG_ERROR,
+		       "Package %s not installed.\n", argv[0]);
+	  return 0;
+     }
+
+     installed_files = pkg_get_installed_files(pkg);
+     pkg_version = pkg_version_str_alloc(pkg);
+
+#ifndef OPKG_LIB
+     printf("Package %s (%s) is installed on %s and has the following files:\n",
+	    pkg->name, pkg_version, pkg->dest->name);
+     for (iter = installed_files->head; iter; iter = iter->next) {
+	  puts(iter->data);
+     }
+#else
+     if (buff) {
+     try_again:
+	  used_len = snprintf(buff, buff_len, "Package %s (%s) is installed on %s and has the following files:\n",
+			      pkg->name, pkg_version, pkg->dest->name) + 1;
+	  if (used_len > buff_len) {
+	       buff_len *= 2;
+	       buff = realloc (buff, buff_len);
+	       goto try_again;
+	  }
+	  for (iter = installed_files->head; iter; iter = iter->next) {
+	       used_len += strlen (iter->data) + 1;
+	       while (buff_len <= used_len) {
+		    buff_len *= 2;
+		    buff = realloc (buff, buff_len);
+	       }
+	       strncat(buff, iter->data, buff_len);
+	       strncat(buff, "\n", buff_len);
+	  } 
+	  if (opkg_cb_list) opkg_cb_list(pkg->name,
+					 buff,
+					 pkg_version_str_alloc(pkg),
+					 pkg->state_status,
+					 p_userdata);
+	  free(buff);
+     }
+#endif
+
+     free(pkg_version);
+     pkg_free_installed_files(pkg);
+
+     return 0;
+}
+
+static int opkg_depends_cmd(opkg_conf_t *conf, int argc, char **argv)
+{
+
+     if (argc > 0) {
+	  pkg_vec_t *available_pkgs = pkg_vec_alloc();
+	  const char *rel_str = "depends on";
+	  int i;
+     
+	  pkg_info_preinstall_check(conf);
+
+	  if (conf->query_all)
+	       pkg_hash_fetch_available(&conf->pkg_hash, available_pkgs);
+	  else
+	       pkg_hash_fetch_all_installed(&conf->pkg_hash, available_pkgs);
+	  for (i = 0; i < argc; i++) {
+	       const char *target = argv[i];
+	       int j;
+
+	       opkg_message(conf, OPKG_ERROR, "target=%s\n", target);
+
+	       for (j = 0; j < available_pkgs->len; j++) {
+		    pkg_t *pkg = available_pkgs->pkgs[j];
+		    if (fnmatch(target, pkg->name, 0) == 0) {
+			 int k;
+			 int count = pkg->depends_count + pkg->pre_depends_count;
+			 opkg_message(conf, OPKG_ERROR, "What %s (arch=%s) %s\n",
+				      target, pkg->architecture, rel_str);
+			 for (k = 0; k < count; k++) {
+			      compound_depend_t *cdepend = &pkg->depends[k];
+			      int l;
+			      for (l = 0; l < cdepend->possibility_count; l++) {
+				   depend_t *possibility = cdepend->possibilities[l];
+				   opkg_message(conf, OPKG_ERROR, "    %s", possibility->pkg->name);
+				   if (conf->verbosity > 0) {
+					// char *ver = abstract_pkg_version_str_alloc(possibility->pkg); 
+					opkg_message(conf, OPKG_NOTICE, " %s", possibility->version);
+					if (possibility->version) {
+					     char *typestr = NULL;
+					     switch (possibility->constraint) {
+					     case NONE: typestr = "none"; break;
+					     case EARLIER: typestr = "<"; break;
+					     case EARLIER_EQUAL: typestr = "<="; break;
+					     case EQUAL: typestr = "="; break;
+					     case LATER_EQUAL: typestr = ">="; break;
+					     case LATER: typestr = ">"; break;
+					     }
+					     opkg_message(conf, OPKG_NOTICE, " (%s %s)", typestr, possibility->version);
+					}
+					// free(ver);
+				   }
+				   opkg_message(conf, OPKG_ERROR, "\n");
+			      }
+			 }
+		    }
+	       }
+	  }
+	  pkg_vec_free(available_pkgs);
+     }
+     return 0;
+}
+
+enum what_field_type {
+  WHATDEPENDS,
+  WHATCONFLICTS,
+  WHATPROVIDES,
+  WHATREPLACES,
+  WHATRECOMMENDS,
+  WHATSUGGESTS
+};
+
+static int opkg_what_depends_conflicts_cmd(opkg_conf_t *conf, enum what_field_type what_field_type, int recursive, int argc, char **argv)
+{
+
+     if (argc > 0) {
+	  pkg_vec_t *available_pkgs = pkg_vec_alloc();
+	  const char *rel_str = NULL;
+	  int i;
+	  int changed;
+
+	  switch (what_field_type) {
+	  case WHATDEPENDS: rel_str = "depends on"; break;
+	  case WHATCONFLICTS: rel_str = "conflicts with"; break;
+	  case WHATSUGGESTS: rel_str = "suggests"; break;
+	  case WHATRECOMMENDS: rel_str = "recommends"; break;
+	  case WHATPROVIDES: rel_str = "provides"; break;
+	  case WHATREPLACES: rel_str = "replaces"; break;
+	  }
+     
+	  if (conf->query_all)
+	       pkg_hash_fetch_available(&conf->pkg_hash, available_pkgs);
+	  else
+	       pkg_hash_fetch_all_installed(&conf->pkg_hash, available_pkgs);
+
+	  /* mark the root set */
+	  pkg_vec_clear_marks(available_pkgs);
+	  opkg_message(conf, OPKG_NOTICE, "Root set:\n");
+	  for (i = 0; i < argc; i++) {
+	       const char *dependee_pattern = argv[i];
+	       pkg_vec_mark_if_matches(available_pkgs, dependee_pattern);
+	  }
+	  for (i = 0; i < available_pkgs->len; i++) {
+	       pkg_t *pkg = available_pkgs->pkgs[i];
+	       if (pkg->state_flag & SF_MARKED) {
+		    /* mark the parent (abstract) package */
+		    pkg_mark_provides(pkg);
+		    opkg_message(conf, OPKG_NOTICE, "  %s\n", pkg->name);
+	       }
+	  }
+
+	  opkg_message(conf, OPKG_NOTICE, "What %s root set\n", rel_str);
+	  do {
+	       int j;
+	       changed = 0;
+
+	       for (j = 0; j < available_pkgs->len; j++) {
+		    pkg_t *pkg = available_pkgs->pkgs[j];
+		    int k;
+		    int count = ((what_field_type == WHATCONFLICTS)
+				 ? pkg->conflicts_count
+				 : pkg->pre_depends_count + pkg->depends_count + pkg->recommends_count + pkg->suggests_count);
+		    /* skip this package if it is already marked */
+		    if (pkg->parent->state_flag & SF_MARKED) {
+			 continue;
+		    }
+		    for (k = 0; k < count; k++) {
+			 compound_depend_t *cdepend = 
+			      (what_field_type == WHATCONFLICTS) ? &pkg->conflicts[k] : &pkg->depends[k];
+			 int l;
+			 for (l = 0; l < cdepend->possibility_count; l++) {
+			      depend_t *possibility = cdepend->possibilities[l];
+			      if (possibility->pkg->state_flag & SF_MARKED) {
+				   /* mark the depending package so we won't visit it again */
+				   pkg->state_flag |= SF_MARKED;
+				   pkg_mark_provides(pkg);
+				   changed++;
+
+				   opkg_message(conf, OPKG_NOTICE, "    %s", pkg->name);
+				   if (conf->verbosity > 0) {
+					char *ver = pkg_version_str_alloc(pkg); 
+					opkg_message(conf, OPKG_NOTICE, " %s", ver);
+					opkg_message(conf, OPKG_NOTICE, "\t%s %s", rel_str, possibility->pkg->name);
+					if (possibility->version) {
+					     char *typestr = NULL;
+					     switch (possibility->constraint) {
+					     case NONE: typestr = "none"; break;
+					     case EARLIER: typestr = "<"; break;
+					     case EARLIER_EQUAL: typestr = "<="; break;
+					     case EQUAL: typestr = "="; break;
+					     case LATER_EQUAL: typestr = ">="; break;
+					     case LATER: typestr = ">"; break;
+					     }
+					     opkg_message(conf, OPKG_NOTICE, " (%s %s)", typestr, possibility->version);
+					}
+					free(ver);
+					if (!pkg_dependence_satisfiable(conf, possibility))
+					     opkg_message(conf, OPKG_NOTICE, " unsatisfiable");
+				   }
+				   opkg_message(conf, OPKG_NOTICE, "\n");
+				   goto next_package;
+			      }
+			 }
+		    }
+	       next_package:
+		    ;
+	       }
+	  } while (changed && recursive);
+	  pkg_vec_free(available_pkgs);
+     }
+
+     return 0;
+}
+
+int pkg_mark_provides(pkg_t *pkg)
+{
+     int provides_count = pkg->provides_count;
+     abstract_pkg_t **provides = pkg->provides;
+     int i;
+     pkg->parent->state_flag |= SF_MARKED;
+     for (i = 0; i < provides_count; i++) {
+	  provides[i]->state_flag |= SF_MARKED;
+     }
+     return 0;
+}
+
+static int opkg_whatdepends_recursively_cmd(opkg_conf_t *conf, int argc, char **argv)
+{
+     return opkg_what_depends_conflicts_cmd(conf, WHATDEPENDS, 1, argc, argv);
+}
+static int opkg_whatdepends_cmd(opkg_conf_t *conf, int argc, char **argv)
+{
+     return opkg_what_depends_conflicts_cmd(conf, WHATDEPENDS, 0, argc, argv);
+}
+
+static int opkg_whatsuggests_cmd(opkg_conf_t *conf, int argc, char **argv)
+{
+     return opkg_what_depends_conflicts_cmd(conf, WHATSUGGESTS, 0, argc, argv);
+}
+
+static int opkg_whatrecommends_cmd(opkg_conf_t *conf, int argc, char **argv)
+{
+     return opkg_what_depends_conflicts_cmd(conf, WHATRECOMMENDS, 0, argc, argv);
+}
+
+static int opkg_whatconflicts_cmd(opkg_conf_t *conf, int argc, char **argv)
+{
+     return opkg_what_depends_conflicts_cmd(conf, WHATCONFLICTS, 0, argc, argv);
+}
+
+static int opkg_what_provides_replaces_cmd(opkg_conf_t *conf, enum what_field_type what_field_type, int argc, char **argv)
+{
+
+     if (argc > 0) {
+	  pkg_vec_t *available_pkgs = pkg_vec_alloc();
+	  const char *rel_str = (what_field_type == WHATPROVIDES ? "provides" : "replaces");
+	  int i;
+     
+	  pkg_info_preinstall_check(conf);
+
+	  if (conf->query_all)
+	       pkg_hash_fetch_available(&conf->pkg_hash, available_pkgs);
+	  else
+	       pkg_hash_fetch_all_installed(&conf->pkg_hash, available_pkgs);
+	  for (i = 0; i < argc; i++) {
+	       const char *target = argv[i];
+	       int j;
+
+	       opkg_message(conf, OPKG_ERROR, "What %s %s\n",
+			    rel_str, target);
+	       for (j = 0; j < available_pkgs->len; j++) {
+		    pkg_t *pkg = available_pkgs->pkgs[j];
+		    int k;
+		    int count = (what_field_type == WHATPROVIDES) ? pkg->provides_count : pkg->replaces_count;
+		    for (k = 0; k < count; k++) {
+			 abstract_pkg_t *apkg = 
+			      ((what_field_type == WHATPROVIDES) 
+			       ? pkg->provides[k]
+			       : pkg->replaces[k]);
+			 if (fnmatch(target, apkg->name, 0) == 0) {
+			      opkg_message(conf, OPKG_ERROR, "    %s", pkg->name);
+			      if (strcmp(target, apkg->name) != 0)
+				   opkg_message(conf, OPKG_ERROR, "\t%s %s\n", rel_str, apkg->name);
+			      opkg_message(conf, OPKG_ERROR, "\n");
+			 }
+		    }
+	       }
+	  }
+	  pkg_vec_free(available_pkgs);
+     }
+     return 0;
+}
+
+static int opkg_whatprovides_cmd(opkg_conf_t *conf, int argc, char **argv)
+{
+     return opkg_what_provides_replaces_cmd(conf, WHATPROVIDES, argc, argv);
+}
+
+static int opkg_whatreplaces_cmd(opkg_conf_t *conf, int argc, char **argv)
+{
+     return opkg_what_provides_replaces_cmd(conf, WHATREPLACES, argc, argv);
+}
+
+static int opkg_search_cmd(opkg_conf_t *conf, int argc, char **argv)
+{
+     int i;
+
+     pkg_vec_t *installed;
+     pkg_t *pkg;
+     str_list_t *installed_files;
+     str_list_elt_t *iter;
+     char *installed_file;
+
+     if (argc < 1) {
+	  return EINVAL;
+     }
+ 
+     installed = pkg_vec_alloc();
+     pkg_hash_fetch_all_installed(&conf->pkg_hash, installed);
+
+     for (i=0; i < installed->len; i++) {
+	  pkg = installed->pkgs[i];
+
+	  installed_files = pkg_get_installed_files(pkg);
+
+	  for (iter = installed_files->head; iter; iter = iter->next) {
+	       installed_file = iter->data;
+	       if (fnmatch(argv[0], installed_file, 0)==0)  {
+#ifndef OPKG_LIB
+		    printf("%s: %s\n", pkg->name, installed_file);
+#else
+			if (opkg_cb_list) opkg_cb_list(pkg->name, 
+						       installed_file, 
+			                               pkg_version_str_alloc(pkg), 
+			                               pkg->state_status, p_userdata);
+#endif			   
+	       }		
+	  }
+
+	  pkg_free_installed_files(pkg);
+     }
+
+     /* XXX: CLEANUP: It's not obvious from the name of
+	pkg_hash_fetch_all_installed that we need to call
+	pkg_vec_free to avoid a memory leak. */
+     pkg_vec_free(installed);
+
+     return 0;
+}
+
+static int opkg_compare_versions_cmd(opkg_conf_t *conf, int argc, char **argv)
+{
+     if (argc == 3) {
+	  /* this is a bit gross */
+	  struct pkg p1, p2;
+	  parseVersion(&p1, argv[0]); 
+	  parseVersion(&p2, argv[2]); 
+	  return pkg_version_satisfied(&p1, &p2, argv[1]);
+     } else {
+	  opkg_message(conf, OPKG_ERROR,
+		       "opkg compare_versions <v1> <op> <v2>\n"
+		       "<op> is one of <= >= << >> =\n");
+	  return -1;
+     }
+}
+
+#ifndef HOST_CPU_STR
+#define HOST_CPU_STR__(X) #X
+#define HOST_CPU_STR_(X) HOST_CPU_STR__(X)
+#define HOST_CPU_STR HOST_CPU_STR_(HOST_CPU_FOO)
+#endif
+
+static int opkg_print_architecture_cmd(opkg_conf_t *conf, int argc, char **argv)
+{
+     nv_pair_list_elt_t *l;
+
+     l = conf->arch_list.head;
+     while (l) {
+	  nv_pair_t *nv = l->data;
+	  printf("arch %s %s\n", nv->name, nv->value);
+	  l = l->next;
+     }
+     return 0;
+}
+
+

Copied: trunk/src/target/ipkg/opkg_cmd.h (from rev 3877, trunk/src/target/ipkg/ipkg_cmd.h)
===================================================================
--- trunk/src/target/ipkg/ipkg_cmd.h	2008-01-18 10:03:14 UTC (rev 3877)
+++ trunk/src/target/ipkg/opkg_cmd.h	2008-01-18 11:28:48 UTC (rev 3879)
@@ -0,0 +1,46 @@
+/* opkg_cmd.h - the itsy package management system
+
+   Carl D. Worth
+
+   Copyright (C) 2001 University of Southern California
+
+   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.
+*/
+
+#ifndef OPKG_CMD_H
+#define OPKG_CMD_H
+
+typedef int (*opkg_cmd_fun_t)(opkg_conf_t *conf, int argc, const char **argv);
+
+struct opkg_cmd
+{
+    char *name;
+    int requires_args;
+    opkg_cmd_fun_t fun;
+};
+typedef struct opkg_cmd opkg_cmd_t;
+
+opkg_cmd_t *opkg_cmd_find(const char *name);
+#ifdef OPKG_LIB
+int opkg_cmd_exec(opkg_cmd_t *cmd, opkg_conf_t *conf, int argc, 
+                  const char **argv, void *userdata);
+#else
+int opkg_cmd_exec(opkg_cmd_t *cmd, opkg_conf_t *conf, int argc, const char **argv);
+#endif
+int opkg_multiple_files_scan (opkg_conf_t *conf, int argc, char *argv[]);
+/* install any packges with state_want == SW_INSTALL */
+int opkg_install_wanted_packages(opkg_conf_t *conf);
+/* ensure that all dependences are satisfied */
+int opkg_configure_packages(opkg_conf_t *conf, char *pkg_name);
+
+int pkg_mark_provides(pkg_t *pkg);
+
+#endif

Copied: trunk/src/target/ipkg/opkg_conf.c (from rev 3877, trunk/src/target/ipkg/ipkg_conf.c)
===================================================================
--- trunk/src/target/ipkg/ipkg_conf.c	2008-01-18 10:03:14 UTC (rev 3877)
+++ trunk/src/target/ipkg/opkg_conf.c	2008-01-18 11:28:48 UTC (rev 3879)
@@ -0,0 +1,717 @@
+/* opkg_conf.c - the itsy package management system
+
+   Carl D. Worth
+
+   Copyright (C) 2001 University of Southern California
+
+   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 <glob.h>
+
+#include "opkg.h"
+#include "opkg_conf.h"
+
+#include "xregex.h"
+#include "sprintf_alloc.h"
+#include "opkg_conf.h"
+#include "opkg_message.h"
+#include "file_util.h"
+#include "str_util.h"
+#include "xsystem.h"
+
+static int opkg_conf_parse_file(opkg_conf_t *conf, const char *filename,
+				pkg_src_list_t *pkg_src_list,
+				nv_pair_list_t *tmp_dest_nv_pair_list,
+				char **tmp_lists_dir);
+static int opkg_init_options_array(const opkg_conf_t *conf, opkg_option_t **options);
+static int opkg_conf_set_option(const opkg_option_t *options,
+				const char *name, const char *value);
+static int opkg_conf_set_default_dest(opkg_conf_t *conf,
+				      const char *default_dest_name);
+static int set_and_load_pkg_src_list(opkg_conf_t *conf,
+				     pkg_src_list_t *nv_pair_list);
+static int set_and_load_pkg_dest_list(opkg_conf_t *conf,
+				      nv_pair_list_t *nv_pair_list, char * lists_dir);
+
+int opkg_init_options_array(const opkg_conf_t *conf, opkg_option_t **options)
+{
+     opkg_option_t tmp[] = {
+	  { "force_defaults", OPKG_OPT_TYPE_BOOL, &conf->force_defaults },
+	  { "force_depends", OPKG_OPT_TYPE_BOOL, &conf->force_depends },
+	  { "force_overwrite", OPKG_OPT_TYPE_BOOL, &conf->force_overwrite },
+	  { "force_downgrade", OPKG_OPT_TYPE_BOOL, &conf->force_downgrade },
+	  { "force_reinstall", OPKG_OPT_TYPE_BOOL, &conf->force_reinstall },
+	  { "force_space", OPKG_OPT_TYPE_BOOL, &conf->force_space },
+	  { "ftp_proxy", OPKG_OPT_TYPE_STRING, &conf->ftp_proxy },
+	  { "http_proxy", OPKG_OPT_TYPE_STRING, &conf->http_proxy },
+	  { "multiple_providers", OPKG_OPT_TYPE_BOOL, &conf->multiple_providers },
+	  { "no_proxy", OPKG_OPT_TYPE_STRING, &conf->no_proxy },
+	  { "test", OPKG_OPT_TYPE_INT, &conf->noaction },
+	  { "noaction", OPKG_OPT_TYPE_INT, &conf->noaction },
+	  { "nodeps", OPKG_OPT_TYPE_BOOL, &conf->nodeps },
+	  { "offline_root", OPKG_OPT_TYPE_STRING, &conf->offline_root },
+	  { "offline_root_post_script_cmd", OPKG_OPT_TYPE_STRING, &conf->offline_root_post_script_cmd },
+	  { "offline_root_pre_script_cmd", OPKG_OPT_TYPE_STRING, &conf->offline_root_pre_script_cmd },
+	  { "proxy_passwd", OPKG_OPT_TYPE_STRING, &conf->proxy_passwd },
+	  { "proxy_user", OPKG_OPT_TYPE_STRING, &conf->proxy_user },
+	  { "query-all", OPKG_OPT_TYPE_BOOL, &conf->query_all },
+	  { "verbose-wget", OPKG_OPT_TYPE_BOOL, &conf->verbose_wget },
+	  { "verbosity", OPKG_OPT_TYPE_BOOL, &conf->verbosity },
+	  { NULL }
+     };
+
+     *options = (opkg_option_t *)malloc(sizeof(tmp));
+     if ( options == NULL ){
+        fprintf(stderr,"%s: Unable to allocate memory\n",__FUNCTION__);
+        return -1;
+     }
+
+     memcpy(*options, tmp, sizeof(tmp));
+     return 0;
+};
+
+static void opkg_conf_override_string(char **conf_str, char *arg_str) 
+{
+     if (arg_str) {
+	  if (*conf_str) {
+	       free(*conf_str);
+	  }
+	  *conf_str = strdup(arg_str);
+     }
+}
+
+static void opkg_conf_free_string(char **conf_str)
+{
+     if (*conf_str) {
+	  free(*conf_str);
+	  *conf_str = NULL;
+     }
+}
+
+int opkg_conf_init(opkg_conf_t *conf, const args_t *args)
+{
+     int err;
+     char *tmp_dir_base;
+     nv_pair_list_t tmp_dest_nv_pair_list;
+     char * lists_dir =NULL;
+     glob_t globbuf;
+     char *etc_opkg_conf_pattern = "/etc/opkg/*.conf";
+     char *pending_dir  =NULL;
+
+     memset(conf, 0, sizeof(opkg_conf_t));
+
+     pkg_src_list_init(&conf->pkg_src_list);
+
+     nv_pair_list_init(&tmp_dest_nv_pair_list);
+     pkg_dest_list_init(&conf->pkg_dest_list);
+
+     nv_pair_list_init(&conf->arch_list);
+
+     conf->restrict_to_default_dest = 0;
+     conf->default_dest = NULL;
+
+
+     if (args->tmp_dir)
+	  tmp_dir_base = args->tmp_dir;
+     else 
+	  tmp_dir_base = getenv("TMPDIR");
+     sprintf_alloc(&conf->tmp_dir, "%s/%s",
+		   tmp_dir_base ? tmp_dir_base : OPKG_CONF_DEFAULT_TMP_DIR_BASE,
+		   OPKG_CONF_TMP_DIR_SUFFIX);
+     conf->tmp_dir = mkdtemp(conf->tmp_dir);
+     if (conf->tmp_dir == NULL) {
+	  fprintf(stderr, "%s: Failed to create temporary directory `%s': %s\n",
+		  __FUNCTION__, conf->tmp_dir, strerror(errno));
+	  return errno;
+     }
+
+     conf->force_depends = 0;
+     conf->force_defaults = 0;
+     conf->force_overwrite = 0;
+     conf->force_downgrade = 0;
+     conf->force_reinstall = 0;
+     conf->force_space = 0;
+     conf->force_removal_of_essential_packages = 0;
+     conf->force_removal_of_dependent_packages = 0;
+     conf->nodeps = 0;
+     conf->verbose_wget = 0;
+     conf->offline_root = NULL;
+     conf->offline_root_pre_script_cmd = NULL;
+     conf->offline_root_post_script_cmd = NULL;
+     conf->multiple_providers = 0;
+     conf->verbosity = 1;
+     conf->noaction = 0;
+
+     conf->http_proxy = NULL;
+     conf->ftp_proxy = NULL;
+     conf->no_proxy = NULL;
+     conf->proxy_user = NULL;
+     conf->proxy_passwd = NULL;
+
+     pkg_hash_init("pkg-hash", &conf->pkg_hash, OPKG_CONF_DEFAULT_HASH_LEN);
+     hash_table_init("file-hash", &conf->file_hash, OPKG_CONF_DEFAULT_HASH_LEN);
+     hash_table_init("obs-file-hash", &conf->obs_file_hash, OPKG_CONF_DEFAULT_HASH_LEN);
+     lists_dir=(char *)malloc(1);
+     lists_dir[0]='\0';
+     if (args->conf_file) {
+	  struct stat stat_buf;
+	  err = stat(args->conf_file, &stat_buf);
+	  if (err == 0)
+	       if (opkg_conf_parse_file(conf, args->conf_file,
+				    &conf->pkg_src_list, &tmp_dest_nv_pair_list,&lists_dir)<0) {
+                   /* Memory leakage from opkg_conf_parse-file */
+                   return -1;
+               }
+                   
+     }
+
+     /* if (!lists_dir ){*/
+     if (strlen(lists_dir)<=1 ){
+        lists_dir = realloc(lists_dir,strlen(OPKG_CONF_LISTS_DIR)+2);
+        sprintf (lists_dir,"%s",OPKG_CONF_LISTS_DIR);
+     }
+
+     if (args->offline_root) {
+            char *tmp = malloc(strlen(lists_dir) + strlen(args->offline_root) + 1);
+            sprintf_alloc(&tmp, "%s/%s",args->offline_root,lists_dir);
+            free(lists_dir);
+            lists_dir = tmp;
+     }
+
+     pending_dir = malloc(strlen(lists_dir)+strlen("/pending")+5);
+     snprintf(pending_dir,strlen(lists_dir)+strlen("/pending") ,"%s%s",lists_dir,"/pending");
+
+     conf->lists_dir = strdup(lists_dir);
+     conf->pending_dir = strdup(pending_dir);
+
+     if (args->offline_root) 
+	  sprintf_alloc(&etc_opkg_conf_pattern, "%s/etc/opkg/*.conf", args->offline_root);
+     memset(&globbuf, 0, sizeof(globbuf));
+     err = glob(etc_opkg_conf_pattern, 0, NULL, &globbuf);
+     if (!err) {
+	  int i;
+	  for (i = 0; i < globbuf.gl_pathc; i++) {
+	       if (globbuf.gl_pathv[i]) 
+		    if ( opkg_conf_parse_file(conf, globbuf.gl_pathv[i], 
+				         &conf->pkg_src_list, &tmp_dest_nv_pair_list,&lists_dir)<0) {
+                        /* Memory leakage from opkg_conf_parse-file */
+                        return -1;
+	            }
+	  }
+     }
+     globfree(&globbuf);
+
+     /* if no architectures were defined, then default all, noarch, and host architecture */
+     if (nv_pair_list_empty(&conf->arch_list)) {
+	  nv_pair_list_append(&conf->arch_list, "all", "1");
+	  nv_pair_list_append(&conf->arch_list, "noarch", "1");
+	  nv_pair_list_append(&conf->arch_list, HOST_CPU_STR, "10");
+     }
+
+     /* Even if there is no conf file, we'll need at least one dest. */
+     if (tmp_dest_nv_pair_list.head == NULL) {
+	  nv_pair_list_append(&tmp_dest_nv_pair_list,
+			      OPKG_CONF_DEFAULT_DEST_NAME,
+			      OPKG_CONF_DEFAULT_DEST_ROOT_DIR);
+     }
+
+     /* After parsing the file, set options from command-line, (so that
+	command-line arguments take precedence) */
+     /* XXX: CLEANUP: The interaction between args.c and opkg_conf.c
+	really needs to be cleaned up. There is so much duplication
+	right now it is ridiculous. Maybe opkg_conf_t should just save
+	a pointer to args_t (which could then not be freed), rather
+	than duplicating every field here? */
+     if (args->force_depends) {
+	  conf->force_depends = 1;
+     }
+     if (args->force_defaults) {
+	  conf->force_defaults = 1;
+     }
+     if (args->force_overwrite) {
+	  conf->force_overwrite = 1;
+     }
+     if (args->force_downgrade) {
+	  conf->force_downgrade = 1;
+     }
+     if (args->force_reinstall) {
+	  conf->force_reinstall = 1;
+     }
+     if (args->force_removal_of_dependent_packages) {
+	  conf->force_removal_of_dependent_packages = 1;
+     }
+     if (args->force_removal_of_essential_packages) {
+	  conf->force_removal_of_essential_packages = 1;
+     }
+     if (args->nodeps) {
+	  conf->nodeps = 1;
+     }
+     if (args->noaction) {
+	  conf->noaction = 1;
+     }
+     if (args->query_all) {
+	  conf->query_all = 1;
+     }
+     if (args->verbose_wget) {
+	  conf->verbose_wget = 1;
+     }
+     if (args->multiple_providers) {
+	  conf->multiple_providers = 1;
+     }
+     if (args->verbosity != conf->verbosity) {
+	  conf->verbosity = args->verbosity;
+     } 
+
+     opkg_conf_override_string(&conf->offline_root, 
+			       args->offline_root);
+     opkg_conf_override_string(&conf->offline_root_pre_script_cmd, 
+			       args->offline_root_pre_script_cmd);
+     opkg_conf_override_string(&conf->offline_root_post_script_cmd, 
+			       args->offline_root_post_script_cmd);
+
+/* Pigi: added a flag to disable the checking of structures if the command does not need to 
+         read anything from there.
+*/
+     if ( !(args->nocheckfordirorfile)){
+        /* need to run load the source list before dest list -Jamey */
+        if ( !(args->noreadfeedsfile))
+           set_and_load_pkg_src_list(conf, &conf->pkg_src_list);
+   
+        /* Now that we have resolved conf->offline_root, we can commit to
+	   the directory names for the dests and load in all the package
+	   lists. */
+        set_and_load_pkg_dest_list(conf, &tmp_dest_nv_pair_list,lists_dir);
+   
+        if (args->dest) {
+	     err = opkg_conf_set_default_dest(conf, args->dest);
+	     if (err) {
+	          return err;
+	     }
+        }
+     }
+     nv_pair_list_deinit(&tmp_dest_nv_pair_list);
+     free(lists_dir);
+     free(pending_dir);
+
+     return 0;
+}
+
+void opkg_conf_deinit(opkg_conf_t *conf)
+{
+#ifdef OPKG_DEBUG_NO_TMP_CLEANUP
+#error
+     fprintf(stderr, "%s: Not cleaning up %s since opkg compiled "
+	     "with OPKG_DEBUG_NO_TMP_CLEANUP\n",
+	     __FUNCTION__, conf->tmp_dir);
+#else
+     int err;
+
+     err = rmdir(conf->tmp_dir);
+     if (err) {
+	  if (errno == ENOTEMPTY) {
+	       char *cmd;
+	       sprintf_alloc(&cmd, "rm -fr %s\n", conf->tmp_dir);
+	       err = xsystem(cmd);
+	       free(cmd);
+	  }
+	  if (err)
+	       fprintf(stderr, "WARNING: Unable to remove temporary directory: %s: %s\n", conf->tmp_dir, strerror(errno));
+     }
+#endif /* OPKG_DEBUG_NO_TMP_CLEANUP */
+
+     free(conf->tmp_dir); /*XXX*/
+
+     pkg_src_list_deinit(&conf->pkg_src_list);
+     pkg_dest_list_deinit(&conf->pkg_dest_list);
+     nv_pair_list_deinit(&conf->arch_list);
+     if (&conf->pkg_hash)
+	            pkg_hash_deinit(&conf->pkg_hash);
+     if (&conf->file_hash)
+	            hash_table_deinit(&conf->file_hash);
+     if (&conf->obs_file_hash)
+	            hash_table_deinit(&conf->obs_file_hash);
+
+     opkg_conf_free_string(&conf->offline_root);
+     opkg_conf_free_string(&conf->offline_root_pre_script_cmd);
+     opkg_conf_free_string(&conf->offline_root_post_script_cmd);
+
+     if (conf->verbosity > 1) { 
+	  int i;
+	  hash_table_t *hashes[] = {
+	       &conf->pkg_hash,
+	       &conf->file_hash,
+	       &conf->obs_file_hash };
+	  for (i = 0; i < 3; i++) {
+	       hash_table_t *hash = hashes[i];
+	       int c = 0;
+	       int n_conflicts = 0;
+	       int j;
+	       for (j = 0; j < hash->n_entries; j++) {
+		    int len = 0;
+		    hash_entry_t *e = &hash->entries[j];
+		    if (e->next)
+			 n_conflicts++;
+		    while (e && e->key) {
+			 len++;
+			 e = e->next;
+		    }
+		    if (len > c) 
+			 c = len;
+	       }
+	       opkg_message(conf, OPKG_DEBUG, "hash_table[%s] n_buckets=%d n_elements=%d max_conflicts=%d n_conflicts=%d\n", 
+			    hash->name, hash->n_entries, hash->n_elements, c, n_conflicts);
+	       hash_table_deinit(hash);
+	  }
+     }
+}
+
+static int opkg_conf_set_default_dest(opkg_conf_t *conf,
+				      const char *default_dest_name)
+{
+     pkg_dest_list_elt_t *iter;
+     pkg_dest_t *dest;
+
+     for (iter = conf->pkg_dest_list.head; iter; iter = iter->next) {
+	  dest = iter->data;
+	  if (strcmp(dest->name, default_dest_name) == 0) {
+	       conf->default_dest = dest;
+	       conf->restrict_to_default_dest = 1;
+	       return 0;
+	  }
+     }
+
+     fprintf(stderr, "ERROR: Unknown dest name: `%s'\n", default_dest_name);
+
+     return 1;
+}
+
+static int set_and_load_pkg_src_list(opkg_conf_t *conf, pkg_src_list_t *pkg_src_list)
+{
+     pkg_src_list_elt_t *iter;
+     pkg_src_t *src;
+     char *list_file;
+
+     for (iter = pkg_src_list->head; iter; iter = iter->next) {
+          src = iter->data;
+	  if (src == NULL) {
+	       continue;
+	  }
+
+	  sprintf_alloc(&list_file, "%s/%s", 
+			  conf->restrict_to_default_dest ? conf->default_dest->lists_dir : conf->lists_dir, 
+			  src->name);
+
+	  if (file_exists(list_file)) {
+	       pkg_hash_add_from_file(conf, list_file, src, NULL, 0);
+	  }
+	  free(list_file);
+     }
+
+     return 0;
+}
+
+static int set_and_load_pkg_dest_list(opkg_conf_t *conf, nv_pair_list_t *nv_pair_list, char *lists_dir )
+{
+     nv_pair_list_elt_t *iter;
+     nv_pair_t *nv_pair;
+     pkg_dest_t *dest;
+     char *root_dir;
+
+     for (iter = nv_pair_list->head; iter; iter = iter->next) {
+	  nv_pair = iter->data;
+
+	  if (conf->offline_root) {
+	       sprintf_alloc(&root_dir, "%s%s", conf->offline_root, nv_pair->value);
+	  } else {
+	       root_dir = strdup(nv_pair->value);
+	  }
+	  dest = pkg_dest_list_append(&conf->pkg_dest_list, nv_pair->name, root_dir, lists_dir);
+	  free(root_dir);
+	  if (dest == NULL) {
+	       continue;
+	  }
+	  if (conf->default_dest == NULL) {
+	       conf->default_dest = dest;
+	  }
+	  if (file_exists(dest->status_file_name)) {
+	       pkg_hash_add_from_file(conf, dest->status_file_name,
+				      NULL, dest, 1);
+	  }
+     }
+
+     return 0;
+}
+
+static int opkg_conf_parse_file(opkg_conf_t *conf, const char *filename,
+				pkg_src_list_t *pkg_src_list,
+				nv_pair_list_t *tmp_dest_nv_pair_list,
+				char **lists_dir)
+{
+     int err;
+     opkg_option_t * options;
+     FILE *file = fopen(filename, "r");
+     regex_t valid_line_re, comment_re;
+#define regmatch_size 12
+     regmatch_t regmatch[regmatch_size];
+
+     if (opkg_init_options_array(conf, &options)<0)
+        return ENOMEM;
+
+     if (file == NULL) {
+	  fprintf(stderr, "%s: failed to open %s: %s\n",
+		  __FUNCTION__, filename, strerror(errno));
+	  free(options);
+	  return errno;
+     }
+     opkg_message(conf, OPKG_NOTICE, "loading conf file %s\n", filename);
+
+     err = xregcomp(&comment_re, 
+		    "^[[:space:]]*(#.*|[[:space:]]*)$",
+		    REG_EXTENDED);
+     if (err) {
+	  free(options);
+	  return err;
+     }
+     err = xregcomp(&valid_line_re, "^[[:space:]]*(\"([^\"]*)\"|([^[:space:]]*))[[:space:]]*(\"([^\"]*)\"|([^[:space:]]*))[[:space:]]*(\"([^\"]*)\"|([^[:space:]]*))([[:space:]]+([^[:space:]]+))?[[:space:]]*$", REG_EXTENDED);
+     if (err) {
+	  free(options);
+	  return err;
+     }
+
+     while(1) {
+	  int line_num = 0;
+	  char *line;
+	  char *type, *name, *value, *extra;
+
+	  line = file_read_line_alloc(file);
+	  line_num++;
+	  if (line == NULL) {
+	       break;
+	  }
+
+	  str_chomp(line);
+
+	  if (regexec(&comment_re, line, 0, 0, 0) == 0) {
+	       goto NEXT_LINE;
+	  }
+
+	  if (regexec(&valid_line_re, line, regmatch_size, regmatch, 0) == REG_NOMATCH) {
+	       str_chomp(line);
+	       fprintf(stderr, "%s:%d: Ignoring invalid line: `%s'\n",
+		       filename, line_num, line);
+	       goto NEXT_LINE;
+	  }
+
+	  /* This has to be so ugly to deal with optional quotation marks */
+	  if (regmatch[2].rm_so > 0) {
+	       type = strndup(line + regmatch[2].rm_so,
+			      regmatch[2].rm_eo - regmatch[2].rm_so);
+	  } else {
+	       type = strndup(line + regmatch[3].rm_so,
+			      regmatch[3].rm_eo - regmatch[3].rm_so);
+	  }
+	  if (regmatch[5].rm_so > 0) {
+	       name = strndup(line + regmatch[5].rm_so,
+			      regmatch[5].rm_eo - regmatch[5].rm_so);
+	  } else {
+	       name = strndup(line + regmatch[6].rm_so,
+			      regmatch[6].rm_eo - regmatch[6].rm_so);
+	  }
+	  if (regmatch[8].rm_so > 0) {
+	       value = strndup(line + regmatch[8].rm_so,
+			       regmatch[8].rm_eo - regmatch[8].rm_so);
+	  } else {
+	       value = strndup(line + regmatch[9].rm_so,
+			       regmatch[9].rm_eo - regmatch[9].rm_so);
+	  }
+	  extra = NULL;
+	  if (regmatch[11].rm_so > 0) {
+	       extra = strndup (line + regmatch[11].rm_so,
+				regmatch[11].rm_eo - regmatch[11].rm_so);
+	  }
+
+	  /* We use the tmp_dest_nv_pair_list below instead of
+	     conf->pkg_dest_list because we might encounter an
+	     offline_root option later and that would invalidate the
+	     directories we would have computed in
+	     pkg_dest_list_init. (We do a similar thing with
+	     tmp_src_nv_pair_list for sake of symmetry.) */
+	  if (strcmp(type, "option") == 0) {
+	       opkg_conf_set_option(options, name, value);
+	  } else if (strcmp(type, "src") == 0) {
+	       if (!nv_pair_list_find(pkg_src_list, name)) {
+		    pkg_src_list_append (pkg_src_list, name, value, extra, 0);
+	       } else {
+		    opkg_message(conf, OPKG_ERROR, "ERROR: duplicate src declaration.  Skipping:\n\t src %s %s\n",
+				 name, value);
+	       }
+	  } else if (strcmp(type, "src/gz") == 0) {
+	       if (!nv_pair_list_find(pkg_src_list, name)) {
+		    pkg_src_list_append (pkg_src_list, name, value, extra, 1);
+	       } else {
+		    opkg_message(conf, OPKG_ERROR, "ERROR: duplicate src declaration.  Skipping:\n\t src %s %s\n",
+				 name, value);
+	       }
+	  } else if (strcmp(type, "dest") == 0) {
+	       nv_pair_list_append(tmp_dest_nv_pair_list, name, value);
+	  } else if (strcmp(type, "lists_dir") == 0) {
+	       *lists_dir = realloc(*lists_dir,strlen(value)+1);
+               if (*lists_dir == NULL) {
+		    opkg_message(conf, OPKG_ERROR, "ERROR: Not enough memory\n");
+	            free(options);
+	            return EINVAL;
+               }
+               sprintf (*lists_dir,"%s",value);
+	  } else if (strcmp(type, "arch") == 0) {
+	       opkg_message(conf, OPKG_INFO, "supported arch %s priority (%s)\n", name, value);
+	       if (!value) {
+		    opkg_message(conf, OPKG_NOTICE, "defaulting architecture %s priority to 10\n", name);
+		    value = strdup("10");
+	       }
+	       nv_pair_list_append(&conf->arch_list, strdup(name), strdup(value));
+	  } else {
+	       fprintf(stderr, "WARNING: Ignoring unknown configuration "
+		       "parameter: %s %s %s\n", type, name, value);
+	       free(options);
+	       return EINVAL;
+	  }
+
+	  free(type);
+	  free(name);
+	  free(value);
+	  if (extra)
+	       free (extra);
+
+     NEXT_LINE:
+	  free(line);
+     }
+
+     free(options);
+     regfree(&comment_re);
+     regfree(&valid_line_re);
+     fclose(file);
+
+     return 0;
+}
+
+static int opkg_conf_set_option(const opkg_option_t *options,
+				const char *name, const char *value)
+{
+     int i = 0;
+     while (options[i].name) {
+	  if (strcmp(options[i].name, name) == 0) {
+	       switch (options[i].type) {
+	       case OPKG_OPT_TYPE_BOOL:
+		    *((int *)options[i].value) = 1;
+		    return 0;
+	       case OPKG_OPT_TYPE_INT:
+		    if (value) {
+			 *((int *)options[i].value) = atoi(value);
+			 return 0;
+		    } else {
+			 printf("%s: Option %s need an argument\n",
+				__FUNCTION__, name);
+			 return EINVAL;
+		    }		    
+	       case OPKG_OPT_TYPE_STRING:
+		    if (value) {
+			 *((char **)options[i].value) = strdup(value);
+			 return 0;
+		    } else {
+			 printf("%s: Option %s need an argument\n",
+				__FUNCTION__, name);
+			 return EINVAL;
+		    }
+	       }
+	  }
+	  i++;
+     }
+    
+     fprintf(stderr, "%s: Unrecognized option: %s=%s\n",
+	     __FUNCTION__, name, value);
+     return EINVAL;
+}
+
+int opkg_conf_write_status_files(opkg_conf_t *conf)
+{
+     pkg_dest_list_elt_t *iter;
+     pkg_dest_t *dest;
+     pkg_vec_t *all;
+     pkg_t *pkg;
+     register int i;
+     int err;
+
+     if (conf->noaction)
+	  return 0;
+     for (iter = conf->pkg_dest_list.head; iter; iter = iter->next) {
+	  dest = iter->data;
+	  dest->status_file = fopen(dest->status_file_tmp_name, "w");
+	  if (dest->status_file == NULL) {
+	       fprintf(stderr, "%s: Can't open status file: %s for writing: %s\n",
+		       __FUNCTION__, dest->status_file_name, strerror(errno));
+	  }
+     }
+
+     all = pkg_vec_alloc();
+     pkg_hash_fetch_available(&conf->pkg_hash, all);
+
+     for(i = 0; i < all->len; i++) {
+	  pkg = all->pkgs[i];
+	  /* We don't need most uninstalled packages in the status file */
+	  if (pkg->state_status == SS_NOT_INSTALLED
+	      && (pkg->state_want == SW_UNKNOWN
+		  || pkg->state_want == SW_DEINSTALL
+		  || pkg->state_want == SW_PURGE)) {
+	       continue;
+	  }
+	  if (!pkg) {
+	    fprintf(stderr, "Null package\n");
+	  }
+	  if (pkg->dest == NULL) {
+	       fprintf(stderr, "%s: ERROR: Can't write status for "
+		       "package %s since it has a NULL dest\n",
+		       __FUNCTION__, pkg->name);
+	       continue;
+	  }
+	  if (pkg->dest->status_file) {
+	       pkg_print_status(pkg, pkg->dest->status_file);
+	  }
+     }
+
+     pkg_vec_free(all);
+
+     for (iter = conf->pkg_dest_list.head; iter; iter = iter->next) {
+	  dest = iter->data;
+	  if (dest->status_file) {
+	       err = ferror(dest->status_file);
+	       fclose(dest->status_file);
+	       dest->status_file = NULL;
+	       if (!err) {
+		    file_move(dest->status_file_tmp_name, dest->status_file_name);
+	       } else {
+		    fprintf(stderr, "%s: ERROR: An error has occurred writing %s, "
+			    "retaining old %s\n", __FUNCTION__, 
+			    dest->status_file_tmp_name, dest->status_file_name);
+	       }
+	  }
+     }
+
+     return 0;
+}
+
+
+char *root_filename_alloc(opkg_conf_t *conf, char *filename)
+{
+     char *root_filename;
+     sprintf_alloc(&root_filename, "%s%s", (conf->offline_root ? conf->offline_root : ""), filename);
+     return root_filename;
+}

Copied: trunk/src/target/ipkg/opkg_conf.h (from rev 3877, trunk/src/target/ipkg/ipkg_conf.h)
===================================================================
--- trunk/src/target/ipkg/ipkg_conf.h	2008-01-18 10:03:14 UTC (rev 3877)
+++ trunk/src/target/ipkg/opkg_conf.h	2008-01-18 11:28:48 UTC (rev 3879)
@@ -0,0 +1,107 @@
+/* opkg_conf.h - the itsy package management system
+
+   Carl D. Worth
+
+   Copyright (C) 2001 University of Southern California
+
+   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.
+*/
+
+#ifndef OPKG_CONF_H
+#define OPKG_CONF_H
+
+typedef struct opkg_conf opkg_conf_t;
+
+#include "hash_table.h"
+#include "opkg.h"
+#include "args.h"
+#include "pkg.h"
+#include "pkg_hash.h"
+#include "pkg_src_list.h"
+#include "pkg_dest_list.h"
+#include "nv_pair_list.h"
+
+#define OPKG_CONF_DEFAULT_TMP_DIR_BASE "/tmp"
+#define OPKG_CONF_TMP_DIR_SUFFIX "opkg-XXXXXX"
+#define OPKG_CONF_LISTS_DIR  OPKG_STATE_DIR_PREFIX "/lists"
+#define OPKG_CONF_PENDING_DIR OPKG_STATE_DIR_PREFIX "/pending"
+
+/* In case the config file defines no dest */
+#define OPKG_CONF_DEFAULT_DEST_NAME "root"
+#define OPKG_CONF_DEFAULT_DEST_ROOT_DIR "/"
+
+#define OPKG_CONF_DEFAULT_HASH_LEN 1024
+
+struct opkg_conf
+{
+     pkg_src_list_t pkg_src_list;
+     pkg_dest_list_t pkg_dest_list;
+     nv_pair_list_t arch_list;
+
+     int restrict_to_default_dest;
+     pkg_dest_t *default_dest;
+
+     char *tmp_dir;
+     const char *lists_dir;
+     const char *pending_dir;
+
+     /* options */
+     int force_depends;
+     int force_defaults;
+     int force_overwrite;
+     int force_downgrade;
+     int force_reinstall;
+     int force_space;
+     int force_removal_of_dependent_packages;
+     int force_removal_of_essential_packages;
+     int nodeps; /* do not follow dependences */
+     int verbose_wget;
+     int multiple_providers;
+     char *offline_root;
+     char *offline_root_pre_script_cmd;
+     char *offline_root_post_script_cmd;
+     int query_all;
+     int verbosity;
+     int noaction;
+
+     /* proxy options */
+     char *http_proxy;
+     char *ftp_proxy;
+     char *no_proxy;
+     char *proxy_user;
+     char *proxy_passwd;
+
+     hash_table_t pkg_hash;
+     hash_table_t file_hash;
+     hash_table_t obs_file_hash;
+};
+
+enum opkg_option_type {
+     OPKG_OPT_TYPE_BOOL,
+     OPKG_OPT_TYPE_INT,
+     OPKG_OPT_TYPE_STRING
+};
+typedef enum opkg_option_type opkg_option_type_t;
+
+typedef struct opkg_option opkg_option_t;
+struct opkg_option {
+     const char *name;
+     const opkg_option_type_t type;
+     const void *value;
+};
+
+int opkg_conf_init(opkg_conf_t *conf, const args_t *args);
+void opkg_conf_deinit(opkg_conf_t *conf);
+
+int opkg_conf_write_status_files(opkg_conf_t *conf);
+char *root_filename_alloc(opkg_conf_t *conf, char *filename);
+
+#endif

Copied: trunk/src/target/ipkg/opkg_configure.c (from rev 3877, trunk/src/target/ipkg/ipkg_configure.c)
===================================================================
--- trunk/src/target/ipkg/ipkg_configure.c	2008-01-18 10:03:14 UTC (rev 3877)
+++ trunk/src/target/ipkg/opkg_configure.c	2008-01-18 11:28:48 UTC (rev 3879)
@@ -0,0 +1,40 @@
+/* opkg_configure.c - the itsy package management system
+
+   Carl D. Worth
+
+   Copyright (C) 2001 University of Southern California
+
+   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 "opkg.h"
+
+#include "opkg_configure.h"
+
+int opkg_configure(opkg_conf_t *conf, pkg_t *pkg)
+{
+    int err;
+
+    /* DPKG_INCOMPATIBILITY:
+       dpkg actually does some conffile handling here, rather than at the
+       end of opkg_install(). Do we care? */
+    /* DPKG_INCOMPATIBILITY:
+       dpkg actually includes a version number to this script call */
+    err = pkg_run_script(conf, pkg, "postinst", "configure");
+    if (err) {
+	printf("ERROR: %s.postinst returned %d\n", pkg->name, err);
+	return err;
+    }
+
+    opkg_state_changed++;
+    return 0;
+}
+

Copied: trunk/src/target/ipkg/opkg_configure.h (from rev 3877, trunk/src/target/ipkg/ipkg_configure.h)
===================================================================
--- trunk/src/target/ipkg/ipkg_configure.h	2008-01-18 10:03:14 UTC (rev 3877)
+++ trunk/src/target/ipkg/opkg_configure.h	2008-01-18 11:28:48 UTC (rev 3879)
@@ -0,0 +1,25 @@
+/* opkg_configure.h - the itsy package management system
+
+   Carl D. Worth
+
+   Copyright (C) 2001 University of Southern California
+
+   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.
+*/
+
+#ifndef OPKG_CONFIGURE_H
+#define OPKG_CONFIGURE_H
+
+#include "opkg_conf.h"
+
+int opkg_configure(opkg_conf_t *opkg_conf, pkg_t *pkg);
+
+#endif

Copied: trunk/src/target/ipkg/opkg_download.c (from rev 3877, trunk/src/target/ipkg/ipkg_download.c)
===================================================================
--- trunk/src/target/ipkg/ipkg_download.c	2008-01-18 10:03:14 UTC (rev 3877)
+++ trunk/src/target/ipkg/opkg_download.c	2008-01-18 11:28:48 UTC (rev 3879)
@@ -0,0 +1,244 @@
+/* vi: set noexpandtab sw=4 sts=4: */
+/* opkg_download.c - the itsy package management system
+
+   Carl D. Worth
+
+   Copyright (C) 2001 University of Southern California
+   Copyright (C) 2008 OpenMoko Inc
+
+   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 <curl/curl.h>
+
+#include "opkg.h"
+#include "opkg_download.h"
+#include "opkg_message.h"
+
+#include "sprintf_alloc.h"
+#include "xsystem.h"
+#include "file_util.h"
+#include "str_util.h"
+
+
+int
+curl_progress_func (void* data,
+                         double t, /* dltotal */
+                         double d, /* dlnow */
+                         double ultotal,
+                         double ulnow)
+{
+    int i;
+    int p = d*100/t;
+    printf ("\r%3d%% |", p);
+    for (i = 1; i < 73; i++)
+    {
+	if (i <= p)
+	    printf ("=");
+	else
+	    printf ("-");
+    }
+    printf ("|");
+    fflush(stdout);
+    return 0;
+}
+
+int opkg_download(opkg_conf_t *conf, const char *src, const char *dest_file_name)
+{
+    int err = 0;
+
+    char *src_basec = strdup(src);
+    char *src_base = basename(src_basec);
+    char *tmp_file_location;
+    char *cmd;
+
+    opkg_message(conf,OPKG_NOTICE,"Downloading %s\n", src);
+	
+    fflush(stdout);
+    
+    if (str_starts_with(src, "file:")) {
+	int ret;
+	const char *file_src = src + 5;
+	opkg_message(conf,OPKG_INFO,"Copying %s to %s...", file_src, dest_file_name);
+	ret = file_copy(src + 5, dest_file_name);
+	opkg_message(conf,OPKG_INFO,"Done\n");
+	return ret;
+    }
+
+    sprintf_alloc(&tmp_file_location, "%s/%s", conf->tmp_dir, src_base);
+    err = unlink(tmp_file_location);
+    if (err && errno != ENOENT) {
+	opkg_message(conf,OPKG_ERROR, "%s: ERROR: failed to unlink %s: %s\n",
+		__FUNCTION__, tmp_file_location, strerror(errno));
+	free(tmp_file_location);
+	return errno;
+    }
+
+    if (conf->http_proxy) {
+	opkg_message(conf,OPKG_DEBUG,"Setting environment variable: http_proxy = %s\n", conf->http_proxy);
+	setenv("http_proxy", conf->http_proxy, 1);
+    }
+    if (conf->ftp_proxy) {
+	opkg_message(conf,OPKG_DEBUG,"Setting environment variable: ftp_proxy = %s\n", conf->ftp_proxy);
+	setenv("ftp_proxy", conf->ftp_proxy, 1);
+    }
+    if (conf->no_proxy) {
+	opkg_message(conf,OPKG_DEBUG,"Setting environment variable: no_proxy = %s\n", conf->no_proxy);
+	setenv("no_proxy", conf->no_proxy, 1);
+    }
+
+    /* XXX: BUG rewrite to use execvp or else busybox's internal wget -Jamey 7/23/2002 */ 
+#if 0
+    sprintf_alloc(&cmd, "wget --passive-ftp %s %s%s %s%s %s -P %s %s",
+		  (conf->http_proxy || conf->ftp_proxy) ? "--proxy=on" : "",
+		  conf->proxy_user ? "--proxy-user=" : "",
+		  conf->proxy_user ? conf->proxy_user : "",
+		  conf->proxy_passwd ? "--proxy-passwd=" : "",
+		  conf->proxy_passwd ? conf->proxy_passwd : "",
+		  conf->verbose_wget ? "" : "-q",
+		  conf->tmp_dir,
+		  src);
+    err = xsystem(cmd);
+    if (err) {
+	if (err != -1) {
+	    opkg_message(conf,OPKG_ERROR, "%s: ERROR: Command failed with return value %d: `%s'\n",
+		    __FUNCTION__, err, cmd);
+	} 
+	unlink(tmp_file_location);
+	free(tmp_file_location);
+	free(src_basec);
+	free(cmd);
+	return EINVAL;
+    }
+    free(cmd);
+#endif
+    CURL *curl;
+    CURLcode res;
+    FILE * file = fopen (tmp_file_location, "w");
+
+    curl = curl_easy_init ();
+    if (curl)
+    {
+	curl_easy_setopt (curl, CURLOPT_URL, src);
+	curl_easy_setopt (curl, CURLOPT_WRITEDATA, file);
+	curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0);
+	curl_easy_setopt (curl, CURLOPT_PROGRESSFUNCTION, curl_progress_func);
+	res = curl_easy_perform (curl);
+	curl_easy_cleanup (curl);
+	fclose (file);
+
+    }
+    else
+	return -1;
+
+    printf ("\n");
+
+    err = file_move(tmp_file_location, dest_file_name);
+
+    free(tmp_file_location);
+    free(src_basec);
+
+    if (err) {
+	return err;
+    }
+
+    return 0;
+}
+
+int opkg_download_pkg(opkg_conf_t *conf, pkg_t *pkg, const char *dir)
+{
+    int err;
+    char *url;
+
+    if (pkg->src == NULL) {
+	opkg_message(conf,OPKG_ERROR, "ERROR: Package %s (parent %s) is not available from any configured src.\n",
+		pkg->name, pkg->parent->name);
+	return -1;
+    }
+
+    sprintf_alloc(&url, "%s/%s", pkg->src->value, pkg->filename);
+
+    /* XXX: BUG: The pkg->filename might be something like
+       "../../foo.ipk". While this is correct, and exactly what we
+       want to use to construct url above, here we actually need to
+       use just the filename part, without any directory. */
+    sprintf_alloc(&pkg->local_filename, "%s/%s", dir, pkg->filename);
+
+    err = opkg_download(conf, url, pkg->local_filename);
+    free(url);
+
+    return err;
+}
+
+/*
+ * Downloads file from url, installs in package database, return package name. 
+ */
+int opkg_prepare_url_for_install(opkg_conf_t *conf, const char *url, char **namep)
+{
+     int err = 0;
+     pkg_t *pkg;
+     pkg = pkg_new();
+     if (pkg == NULL)
+	  return ENOMEM;
+
+     if (str_starts_with(url, "http://")
+	 || str_starts_with(url, "ftp://")) {
+	  char *tmp_file;
+	  char *file_basec = strdup(url);
+	  char *file_base = basename(file_basec);
+
+	  sprintf_alloc(&tmp_file, "%s/%s", conf->tmp_dir, file_base);
+	  err = opkg_download(conf, url, tmp_file);
+	  if (err)
+	       return err;
+
+	  err = pkg_init_from_file(pkg, tmp_file);
+	  if (err)
+	       return err;
+	  pkg->local_filename = strdup(tmp_file);
+
+	  free(tmp_file);
+	  free(file_basec);
+
+     } else if (strcmp(&url[strlen(url) - 4], OPKG_PKG_EXTENSION) == 0
+		|| strcmp(&url[strlen(url) - 4], DPKG_PKG_EXTENSION) == 0) {
+
+	  err = pkg_init_from_file(pkg, url);
+	  if (err)
+	       return err;
+	  pkg->local_filename = strdup(url);
+	  opkg_message(conf, OPKG_DEBUG2, "Package %s provided by hand \(%s\).\n", pkg->name,pkg->local_filename);
+          pkg->provided_by_hand = 1;
+
+     } else {
+       pkg_deinit(pkg);
+       free(pkg);
+       return 0;
+     }
+
+     if (!pkg->architecture) {
+	  opkg_message(conf, OPKG_ERROR, "Package %s has no Architecture defined.\n", pkg->name);
+	  return -EINVAL;
+     }
+
+     pkg->dest = conf->default_dest;
+     pkg->state_want = SW_INSTALL;
+     pkg->state_flag |= SF_PREFER;
+     pkg = hash_insert_pkg(&conf->pkg_hash, pkg, 1,conf);  
+     if ( pkg == NULL ){
+        fprintf(stderr, "%s : This should never happen. Report this Bug in bugzilla please \n ",__FUNCTION__);
+        return 0;
+     }
+     if (namep) {
+	  *namep = strdup(pkg->name);
+     }
+     return 0;
+}

Copied: trunk/src/target/ipkg/opkg_download.h (from rev 3877, trunk/src/target/ipkg/ipkg_download.h)
===================================================================
--- trunk/src/target/ipkg/ipkg_download.h	2008-01-18 10:03:14 UTC (rev 3877)
+++ trunk/src/target/ipkg/opkg_download.h	2008-01-18 11:28:48 UTC (rev 3879)
@@ -0,0 +1,30 @@
+/* opkg_download.h - the itsy package management system
+
+   Carl D. Worth
+
+   Copyright (C) 2001 University of Southern California
+
+   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.
+*/
+
+#ifndef OPKG_DOWNLOAD_H
+#define OPKG_DOWNLOAD_H
+
+#include "opkg_conf.h"
+
+int opkg_download(opkg_conf_t *conf, const char *src, const char *dest_file_name);
+int opkg_download_pkg(opkg_conf_t *conf, pkg_t *pkg, const char *dir);
+/*
+ * Downloads file from url, installs in package database, return package name. 
+ */
+int opkg_prepare_url_for_install(opkg_conf_t *conf, const char *url, char **namep);
+
+#endif

Copied: trunk/src/target/ipkg/opkg_extract_test.c (from rev 3877, trunk/src/target/ipkg/ipkg_extract_test.c)
===================================================================
--- trunk/src/target/ipkg/ipkg_extract_test.c	2008-01-18 10:03:14 UTC (rev 3877)
+++ trunk/src/target/ipkg/opkg_extract_test.c	2008-01-18 11:28:48 UTC (rev 3879)
@@ -0,0 +1,46 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include "libbb/libbb.h"
+
+/*
+ * build thus: 
+
+ * gcc -o opkg_extract_test opkg_extract_test.c -I./busybox-0.60.2/libbb -L./busybox-0.60.2 -lbb
+ *
+ */
+const char * applet_name;
+
+int main(int argc, char * argv[])
+{
+  /*
+   * see libbb.h and let your imagination run wild
+   * or, set the last item below to extract_one_to_buffer, and you get the control file in 
+   * "returned"
+   * or, set the last one to extract_all_to_fs, and, well, guess what happens
+   */
+
+    /* enum extract_functions_e dowhat = extract_control_tar_gz | extract_unconditional | extract_one_to_buffer; */
+    enum extract_functions_e dowhat = extract_control_tar_gz | extract_all_to_fs | extract_preserve_date;
+  char * returned;
+  char * filename;
+  
+  if(argc < 2){
+    fprintf(stderr, "syntax: %s <opkg file> [<file_to_extract>]\n", argv[0]);
+    exit(0);
+  }
+  
+  if (argc < 3){
+    filename=NULL;
+  } else {
+    filename = argv[2];
+  }
+
+  returned = deb_extract(argv[1], stdout, dowhat, NULL, filename);
+  
+  if(returned)
+    fprintf(stderr, "returned %s\n", returned);
+  else
+    fprintf(stderr, "extract returned nuthin'\n");
+
+  return 0;
+}

Copied: trunk/src/target/ipkg/opkg_hash_test.c (from rev 3877, trunk/src/target/ipkg/ipkg_hash_test.c)
===================================================================
--- trunk/src/target/ipkg/ipkg_hash_test.c	2008-01-18 10:03:14 UTC (rev 3877)
+++ trunk/src/target/ipkg/opkg_hash_test.c	2008-01-18 11:28:48 UTC (rev 3879)
@@ -0,0 +1,79 @@
+/* opkg_hash_test.c - the itsy package management system
+
+   Carl D. Worth
+
+   Copyright (C) 2001 University of Southern California
+
+   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 "opkg.h"
+
+#include "hash_table.h"
+#include "opkg_utils.h"
+#include "pkg_hash.h"
+
+int main(int argc, char *argv[])
+{
+     opkg_conf_t conf;
+     hash_table_t *hash = &conf.pkg_hash;
+     pkg_vec_t * pkg_vec;
+
+    if (argc < 3) {
+	fprintf(stderr, "Usage: %s <pkgs_file1> <pkgs_file2> [pkg_name...]\n", argv[0]);
+	exit(1);
+    }
+    pkg_hash_init("test", hash, 1024);
+
+    pkg_hash_add_from_file(&conf, argv[1], NULL, NULL, 0);
+    pkg_hash_add_from_file(&conf, argv[2], NULL, NULL, 0);
+
+    if (argc < 4) {
+	pkg_print_info( pkg_hash_fetch_by_name_version(hash, "libc6", "2.2.3-2"), stdout);
+	/*	for(i = 0; i < pkg_vec->len; i++)
+		pkg_print(pkg_vec->pkgs[i], stdout);
+	*/
+    } else {
+	int i, j, k;
+	char **unresolved;
+
+	pkg_vec_t * dep_vec;
+	for (i = 3; i < argc; i++) {
+	    pkg_vec = pkg_vec_fetch_by_name(hash, argv[i]);
+	    if (pkg_vec == NULL) {
+		fprintf(stderr, "*** WARNING: Unknown package: %s\n\n", argv[i]);
+		continue;
+	    }
+
+	    for(j = 0; j < pkg_vec->len; j++){
+		pkg_print_info(pkg_vec->pkgs[j], stdout);
+		dep_vec = pkg_vec_alloc();
+		pkg_hash_fetch_unsatisfied_dependencies(&conf,
+							pkg_vec->pkgs[j],
+							dep_vec,
+							&unresolved);
+		if(dep_vec){
+		    fprintf(stderr, "and the unsatisfied dependencies are:\n");
+		    for(k = 0; k < dep_vec->len; k++){
+			fprintf(stderr, "%s version %s\n", dep_vec->pkgs[k]->name, dep_vec->pkgs[k]->version);
+		    }
+		}
+		
+		fputs("", stdout);
+		
+	    }
+ 	}
+    }
+
+    pkg_hash_deinit(hash);
+
+    return 0;
+}

Copied: trunk/src/target/ipkg/opkg_install.c (from rev 3877, trunk/src/target/ipkg/ipkg_install.c)
===================================================================
--- trunk/src/target/ipkg/ipkg_install.c	2008-01-18 10:03:14 UTC (rev 3877)
+++ trunk/src/target/ipkg/opkg_install.c	2008-01-18 11:28:48 UTC (rev 3879)
@@ -0,0 +1,1942 @@
+/* opkg_install.c - the itsy package management system
+
+   Carl D. Worth
+
+   Copyright (C) 2001 University of Southern California
+
+   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 "opkg.h"
+#include <errno.h>
+#include <dirent.h>
+#include <glob.h>
+#include <time.h>
+#include <signal.h>
+typedef void (*sighandler_t)(int);
+
+#include "pkg.h"
+#include "pkg_hash.h"
+#include "pkg_extract.h"
+
+#include "opkg_install.h"
+#include "opkg_configure.h"
+#include "opkg_download.h"
+#include "opkg_remove.h"
+
+#include "opkg_utils.h"
+#include "opkg_message.h"
+
+#include "sprintf_alloc.h"
+#include "file_util.h"
+#include "str_util.h"
+#include "xsystem.h"
+#include "user.h"
+
+int satisfy_dependencies_for(opkg_conf_t *conf, pkg_t *pkg);
+static int verify_pkg_installable(opkg_conf_t *conf, pkg_t *pkg);
+static int unpack_pkg_control_files(opkg_conf_t *conf, pkg_t *pkg);
+
+static int prerm_upgrade_old_pkg(opkg_conf_t *conf, pkg_t *pkg, pkg_t *old_pkg);
+static int prerm_upgrade_old_pkg_unwind(opkg_conf_t *conf, pkg_t *pkg, pkg_t *old_pkg);
+static int prerm_deconfigure_conflictors(opkg_conf_t *conf, pkg_t *pkg, pkg_vec_t *conflictors);
+static int prerm_deconfigure_conflictors_unwind(opkg_conf_t *conf, pkg_t *pkg, pkg_vec_t *conflictors);
+static int preinst_configure(opkg_conf_t *conf, pkg_t *pkg, pkg_t *old_pkg);
+static int preinst_configure_unwind(opkg_conf_t *conf, pkg_t *pkg, pkg_t *old_pkg);
+static int check_data_file_clashes(opkg_conf_t *conf, pkg_t *pkg, pkg_t *old_pkg);
+static int check_data_file_clashes_change(opkg_conf_t *conf, pkg_t *pkg, pkg_t *old_pkg);
+static int check_data_file_clashes_unwind(opkg_conf_t *conf, pkg_t *pkg, pkg_t *old_pkg);
+static int backup_modified_conffiles(opkg_conf_t *conf, pkg_t *pkg, pkg_t *old_pkg);
+static int backup_modified_conffiles_unwind(opkg_conf_t *conf, pkg_t *pkg, pkg_t *old_pkg);
+static int postrm_upgrade_old_pkg(opkg_conf_t *conf, pkg_t *pkg, pkg_t *old_pkg);
+static int postrm_upgrade_old_pkg_unwind(opkg_conf_t *conf, pkg_t *pkg, pkg_t *old_pkg);
+
+static int remove_obsolesced_files(opkg_conf_t *conf, pkg_t *pkg, pkg_t *old_pkg);
+static int install_maintainer_scripts(opkg_conf_t *conf, pkg_t *pkg, pkg_t *old_pkg);
+static int remove_disappeared(opkg_conf_t *conf, pkg_t *pkg);
+static int install_data_files(opkg_conf_t *conf, pkg_t *pkg);
+static int resolve_conffiles(opkg_conf_t *conf, pkg_t *pkg);
+
+static int cleanup_temporary_files(opkg_conf_t *conf, pkg_t *pkg);
+
+static int user_prefers_old_conffile(const char *file, const char *backup);
+
+static char *backup_filename_alloc(const char *file_name);
+static int backup_make_backup(opkg_conf_t *conf, const char *file_name);
+static int backup_exists_for(const char *file_name);
+static int backup_remove(const char *file_name);
+
+
+int opkg_install_from_file(opkg_conf_t *conf, const char *filename)
+{
+     int err, cmp;
+     pkg_t *pkg, *old;
+     char *old_version, *new_version;
+
+     pkg = pkg_new();
+     if (pkg == NULL) {
+	  return ENOMEM;
+     }
+
+     err = pkg_init_from_file(pkg, filename);
+     if (err) {
+	  return err;
+     }
+
+     if (!pkg->architecture) {
+	  opkg_message(conf, OPKG_ERROR, "Package %s has no Architecture defined.\n", pkg->name);
+	  return -EINVAL;
+     }
+
+     /* XXX: CLEANUP: hash_insert_pkg has a nasty side effect of possibly
+	freeing the pkg that we pass in. It might be nice to clean this up
+	if possible.  */
+     pkg = hash_insert_pkg(&conf->pkg_hash, pkg, 1,conf);
+     old = pkg_hash_fetch_installed_by_name(&conf->pkg_hash, pkg->name);
+
+     pkg->local_filename = strdup(filename);
+
+     if (old) {
+	  old_version = pkg_version_str_alloc(old);
+	  new_version = pkg_version_str_alloc(pkg);
+
+	  cmp = pkg_compare_versions(old, pkg);
+          if ( (conf->force_downgrade==1) && (cmp > 0) ){     /* We've been asked to allow downgrade  and version is precedent */
+             cmp = -1 ;                                       /* then we force opkg to downgrade */ 
+                                                              /* We need to use a value < 0 because in the 0 case we are asking to */
+                                                              /* reinstall, and some check could fail asking the "force-reinstall" option */
+          } 
+	  if (cmp > 0) {
+	         opkg_message(conf, OPKG_NOTICE,
+			      "Not downgrading package %s on %s from %s to %s.\n",
+			      old->name, old->dest->name, old_version, new_version);
+	         pkg->state_want = SW_DEINSTALL;
+	         pkg->state_flag |= SF_OBSOLETE;
+	         free(old_version);
+	         free(new_version);
+	         return 0;
+	  } else {
+	       free(old_version);
+	       free(new_version);
+	  }
+     }
+
+     opkg_message(conf, OPKG_DEBUG2,"Function: %s calling opkg_install_pkg \n",__FUNCTION__);
+     return opkg_install_pkg(conf, pkg,0);
+}
+
+opkg_error_t opkg_install_by_name(opkg_conf_t *conf, const char *pkg_name)
+{
+     int cmp;
+     pkg_t *old, *new;
+     char *old_version, *new_version;
+
+     opkg_message(conf, OPKG_DEBUG2, " Getting old  from pkg_hash_fetch \n" );
+     old = pkg_hash_fetch_installed_by_name(&conf->pkg_hash, pkg_name);
+     if ( old ) 
+        opkg_message(conf, OPKG_DEBUG2, " Old versions from pkg_hash_fetch %s \n",  old->version );
+    
+     opkg_message(conf, OPKG_DEBUG2, " Getting new  from pkg_hash_fetch \n" );
+     new = pkg_hash_fetch_best_installation_candidate_by_name(conf, pkg_name);
+     if ( new ) 
+        opkg_message(conf, OPKG_DEBUG2, " New versions from pkg_hash_fetch %s \n",  new->version );
+
+/* Pigi Basically here is broken the version stuff.
+   What's happening is that nothing provide the version to differents 
+   functions, so the returned struct is always the latest.
+   That's why the install by name don't work.
+*/
+     opkg_message(conf, OPKG_DEBUG2, " Versions from pkg_hash_fetch in %s ", __FUNCTION__ );
+
+     if ( old ) 
+        opkg_message(conf, OPKG_DEBUG2, " old %s ", old->version );
+     if ( new ) 
+        opkg_message(conf, OPKG_DEBUG2, " new %s ", new->version );
+     opkg_message(conf, OPKG_DEBUG2, " \n");
+
+     if (new == NULL) {
+	  return OPKG_PKG_HAS_NO_CANDIDATE;
+     }
+
+     new->state_flag |= SF_USER;
+     if (old) {
+	  old_version = pkg_version_str_alloc(old);
+	  new_version = pkg_version_str_alloc(new);
+
+	  cmp = pkg_compare_versions(old, new);
+          if ( (conf->force_downgrade==1) && (cmp > 0) ){     /* We've been asked to allow downgrade  and version is precedent */
+	     opkg_message(conf, OPKG_DEBUG, " Forcing downgrade \n");
+             cmp = -1 ;                                       /* then we force opkg to downgrade */ 
+                                                              /* We need to use a value < 0 because in the 0 case we are asking to */
+                                                              /* reinstall, and some check could fail asking the "force-reinstall" option */
+          } 
+	  opkg_message(conf, OPKG_DEBUG, 
+		       "Comparing visible versions of pkg %s:"
+		       "\n\t%s is installed "
+		       "\n\t%s is available "
+		       "\n\t%d was comparison result\n",
+		       pkg_name, old_version, new_version, cmp);
+	  if (cmp == 0 && !conf->force_reinstall) {
+	       opkg_message(conf, OPKG_NOTICE,
+			    "Package %s (%s) installed in %s is up to date.\n",
+			    old->name, old_version, old->dest->name);
+	       free(old_version);
+	       free(new_version);
+	       return 0;
+	  } else if (cmp > 0) {
+	       opkg_message(conf, OPKG_NOTICE,
+			    "Not downgrading package %s on %s from %s to %s.\n",
+			    old->name, old->dest->name, old_version, new_version);
+	       free(old_version);
+	       free(new_version);
+	       return 0;
+	  } else if (cmp < 0) {
+	       new->dest = old->dest;
+	       old->state_want = SW_DEINSTALL;    /* Here probably the problem for bug 1277 */
+	  }
+     }
+
+     /* XXX: CLEANUP: The error code of opkg_install_by_name is really
+	supposed to be an opkg_error_t, but opkg_install_pkg could
+	return any kind of integer, (might be errno from a syscall,
+	etc.). This is a real mess and will need to be cleaned up if
+	anyone ever wants to make a nice libopkg. */
+
+     opkg_message(conf, OPKG_DEBUG2,"Function: %s calling opkg_install_pkg \n",__FUNCTION__);
+     return opkg_install_pkg(conf, new,0);
+}
+
+opkg_error_t opkg_install_multi_by_name(opkg_conf_t *conf, const char *pkg_name)
+{
+     abstract_pkg_vec_t *providers = pkg_hash_fetch_all_installation_candidates (&conf->pkg_hash, pkg_name);
+     int i;
+     opkg_error_t err;
+     abstract_pkg_t *ppkg ;
+
+     if (providers == NULL)
+	  return OPKG_PKG_HAS_NO_CANDIDATE;
+
+     for (i = 0; i < providers->len; i++) {
+	  ppkg = abstract_pkg_vec_get(providers, i);
+          opkg_message(conf, OPKG_DEBUG2,"Function: %s calling opkg_install_by_name %d \n",__FUNCTION__, i);
+	  err = opkg_install_by_name(conf, ppkg->name);
+	  if (err)
+	       return err;
+/* XXX Maybe ppkg should be freed ? */
+     }
+     return 0;
+}
+
+/*
+ * Walk dependence graph starting with pkg, collect packages to be
+ * installed into pkgs_needed, in dependence order.
+ */
+int pkg_mark_dependencies_for_installation(opkg_conf_t *conf, pkg_t *pkg, pkg_vec_t *pkgs_needed)
+{
+     int i, err;
+     pkg_vec_t *depends = pkg_vec_alloc();
+     char **unresolved = NULL;
+     int ndepends;
+
+     ndepends = pkg_hash_fetch_unsatisfied_dependencies(conf, 
+							pkg, depends, 
+							&unresolved);
+
+     if (unresolved) {
+	  opkg_message(conf, OPKG_ERROR,
+		       "%s: Cannot satisfy the following dependencies for %s:\n\t",
+		       conf->force_depends ? "Warning" : "ERROR", pkg->name);
+	  while (*unresolved) {
+	       opkg_message(conf, OPKG_ERROR, " %s", *unresolved);
+	       unresolved++;
+	  }
+	  opkg_message(conf, OPKG_ERROR, "\n");
+	  if (! conf->force_depends) {
+	       opkg_message(conf, OPKG_INFO,
+			    "This could mean that your package list is out of date or that the packages\n"
+			    "mentioned above do not yet exist (try 'opkg update'). To proceed in spite\n"
+			    "of this problem try again with the '-force-depends' option.\n");
+	       pkg_vec_free(depends);
+	       return OPKG_PKG_DEPS_UNSATISFIED;
+	  }
+     }
+
+     if (ndepends <= 0) {
+	  pkg_vec_free(depends);
+	  return 0;
+     }
+
+     for (i = 0; i < depends->len; i++) {
+	  pkg_t *dep = depends->pkgs[i];
+	  /* The package was uninstalled when we started, but another
+	     dep earlier in this loop may have depended on it and pulled
+	     it in, so check first. */
+	  if ((dep->state_status != SS_INSTALLED)
+	      && (dep->state_status != SS_UNPACKED)
+	      && (dep->state_want != SW_INSTALL)) {
+
+	       /* Mark packages as to-be-installed */
+	       dep->state_want = SW_INSTALL;
+
+	       /* Dependencies should be installed the same place as pkg */
+	       if (dep->dest == NULL) {
+		    dep->dest = pkg->dest;
+	       }
+
+	       err = pkg_mark_dependencies_for_installation(conf, dep, pkgs_needed);
+	       if (err) {
+		    pkg_vec_free(depends);
+		    return err;
+	       }
+	  }
+     }
+     if (pkgs_needed)
+	  pkg_vec_insert(pkgs_needed, pkg);
+
+     pkg_vec_free(depends);
+
+     return 0;
+}
+
+int name_mark_dependencies_for_installation(opkg_conf_t *conf, const char *pkg_name, pkg_vec_t *pkgs_needed)
+{
+     int cmp;
+     pkg_t *old, *new;
+     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 OPKG_PKG_HAS_NO_CANDIDATE;
+     }
+     if (old) {
+	  old_version = pkg_version_str_alloc(old);
+	  new_version = pkg_version_str_alloc(new);
+
+	  cmp = pkg_compare_versions(old, new);
+          if ( (conf->force_downgrade==1) && (cmp > 0) ){     /* We've been asked to allow downgrade  and version is precedent */
+	    opkg_message(conf, OPKG_DEBUG, " Forcing downgrade ");
+             cmp = -1 ;                                       /* then we force opkg to downgrade */ 
+                                                              /* We need to use a value < 0 because in the 0 case we are asking to */
+                                                              /* reinstall, and some check could fail asking the "force-reinstall" option */
+          } 
+	  opkg_message(conf, OPKG_DEBUG, 
+		       "comparing visible versions of pkg %s:"
+		       "\n\t%s is installed "
+		       "\n\t%s is available "
+		       "\n\t%d was comparison result\n",
+		       pkg_name, old_version, new_version, cmp);
+	  if (cmp == 0 && !conf->force_reinstall) {
+	       opkg_message(conf, OPKG_NOTICE,
+			    "Package %s (%s) installed in %s is up to date.\n",
+			    old->name, old_version, old->dest->name);
+	       free(old_version);
+	       free(new_version);
+	       return 0;
+	  } else if (cmp > 0) {
+	       opkg_message(conf, OPKG_NOTICE,
+			    "Not downgrading package %s on %s from %s to %s.\n",
+			    old->name, old->dest->name, old_version, new_version);
+	       free(old_version);
+	       free(new_version);
+	       return 0;
+	  } else if (cmp < 0) {
+	       new->dest = old->dest;
+	       old->state_want = SW_DEINSTALL;
+	       old->state_flag |= SF_OBSOLETE;
+	  }
+     }
+     return pkg_mark_dependencies_for_installation(conf, new, pkgs_needed);
+}
+
+
+
+int satisfy_dependencies_for(opkg_conf_t *conf, pkg_t *pkg)
+{
+     int i, err;
+     pkg_vec_t *depends = pkg_vec_alloc();
+     pkg_t *dep;
+     char **unresolved = NULL;
+     int ndepends;
+
+     ndepends = pkg_hash_fetch_unsatisfied_dependencies(conf, 
+							pkg, depends, 
+							&unresolved);
+
+     if (unresolved) {
+	  opkg_message(conf, OPKG_ERROR,
+		       "%s: Cannot satisfy the following dependencies for %s:\n\t",
+		       conf->force_depends ? "Warning" : "ERROR", pkg->name);
+	  while (*unresolved) {
+	       opkg_message(conf, OPKG_ERROR, " %s", *unresolved);
+	       unresolved++;
+	  }
+	  opkg_message(conf, OPKG_ERROR, "\n");
+	  if (! conf->force_depends) {
+	       opkg_message(conf, OPKG_INFO,
+			    "This could mean that your package list is out of date or that the packages\n"
+			    "mentioned above do not yet exist (try 'opkg update'). To proceed in spite\n"
+			    "of this problem try again with the '-force-depends' option.\n");
+	       pkg_vec_free(depends);
+	       return OPKG_PKG_DEPS_UNSATISFIED;
+	  }
+     }
+
+     if (ndepends <= 0) {
+	  return 0;
+     }
+
+     /* Mark packages as to-be-installed */
+     for (i=0; i < depends->len; i++) {
+	  /* Dependencies should be installed the same place as pkg */
+	  if (depends->pkgs[i]->dest == NULL) {
+	       depends->pkgs[i]->dest = pkg->dest;
+	  }
+	  depends->pkgs[i]->state_want = SW_INSTALL;
+     }
+
+     for (i = 0; i < depends->len; i++) {
+	  dep = depends->pkgs[i];
+	  /* The package was uninstalled when we started, but another
+	     dep earlier in this loop may have depended on it and pulled
+	     it in, so check first. */
+	  if ((dep->state_status != SS_INSTALLED)
+	      && (dep->state_status != SS_UNPACKED)) {
+               opkg_message(conf, OPKG_DEBUG2,"Function: %s calling opkg_install_pkg \n",__FUNCTION__);
+	       err = opkg_install_pkg(conf, dep,0);
+	       if (err) {
+		    pkg_vec_free(depends);
+		    return err;
+	       }
+	  }
+     }
+
+     pkg_vec_free(depends);
+
+     return 0;
+}
+
+
+/* check all packages have their dependences satisfied, e.g., in case an upgraded package split */ 
+int opkg_satisfy_all_dependences(opkg_conf_t *conf)
+{
+     if (conf->nodeps == 0) {
+	  int i;
+	  pkg_vec_t *installed = pkg_vec_alloc();
+	  pkg_hash_fetch_all_installed(&conf->pkg_hash, installed);
+	  for (i = 0; i < installed->len; i++) {
+	       pkg_t *pkg = installed->pkgs[i];
+	       satisfy_dependencies_for(conf, pkg);
+	  }
+	  pkg_vec_free(installed);
+     }
+     return 0;
+}
+
+
+
+static int check_conflicts_for(opkg_conf_t *conf, pkg_t *pkg)
+{
+     int i;
+     pkg_vec_t *conflicts = NULL;
+     int level;
+     const char *prefix;
+     if (conf->force_depends) {
+	  level = OPKG_NOTICE;
+	  prefix = "Warning";
+     } else {
+	  level = OPKG_ERROR;
+	  prefix = "ERROR";
+     }
+
+     if (!conf->force_depends)
+	  conflicts = (pkg_vec_t *)pkg_hash_fetch_conflicts(&conf->pkg_hash, pkg);
+
+     if (conflicts) {
+	  opkg_message(conf, level,
+		       "%s: The following packages conflict with %s:\n\t", prefix, pkg->name);
+	  i = 0;
+	  while (i < conflicts->len)
+	       opkg_message(conf, level, " %s", conflicts->pkgs[i++]->name);
+	  opkg_message(conf, level, "\n");
+	  pkg_vec_free(conflicts);
+	  return OPKG_PKG_DEPS_UNSATISFIED;
+     }
+     return 0;
+}
+
+static int update_file_ownership(opkg_conf_t *conf, pkg_t *new_pkg, pkg_t *old_pkg)
+{
+     str_list_t *new_list = pkg_get_installed_files(new_pkg);
+     str_list_elt_t *iter;
+
+     for (iter = new_list->head; iter; iter = iter->next) {
+	  char *new_file = iter->data;
+	  pkg_t *owner = file_hash_get_file_owner(conf, new_file);
+	  if (!new_file)
+	       opkg_message(conf, OPKG_ERROR, "Null new_file for new_pkg=%s\n", new_pkg->name);
+	  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);
+	  for (iter = old_list->head; iter; iter = iter->next) {
+	       char *old_file = iter->data;
+	       pkg_t *owner = file_hash_get_file_owner(conf, old_file);
+	       if (owner == old_pkg) {
+		    /* obsolete */
+		    hash_table_insert(&conf->obs_file_hash, old_file, old_pkg);
+	       }
+	  }
+     }
+     return 0;
+}
+
+static int verify_pkg_installable(opkg_conf_t *conf, pkg_t *pkg)
+{
+    /* XXX: FEATURE: Anything else needed here? Maybe a check on free space? */
+
+    /* sma 6.20.02:  yup; here's the first bit */
+    /* 
+     * XXX: BUG easy for cworth
+     * 1) please point the call below to the correct current root destination
+     * 2) we need to resolve how to check the required space for a pending pkg, 
+     *    my diddling with the .ipk file size below isn't going to cut it.
+     * 3) return a proper error code instead of 1
+     */
+     int comp_size, blocks_available;
+    
+     if (!conf->force_space && pkg->installed_size != NULL) {
+	  blocks_available = get_available_blocks(conf->default_dest->root_dir);
+
+	  comp_size = strtoul(pkg->installed_size, NULL, 0);
+	  /* round up a blocks count without doing fancy-but-slow casting jazz */ 
+	  comp_size = (int)((comp_size + 1023) / 1024);
+
+	  if (comp_size >= blocks_available) {
+	       opkg_message(conf, OPKG_ERROR,
+			    "Only have %d available blocks on filesystem %s, pkg %s needs %d\n", 
+			    blocks_available, conf->default_dest->root_dir, pkg->name, comp_size);
+	       return ENOSPC;
+	  }
+     }
+     return 0;
+}
+
+static int unpack_pkg_control_files(opkg_conf_t *conf, pkg_t *pkg)
+{
+     int err;
+     char *conffiles_file_name;
+     char *root_dir;
+     FILE *conffiles_file;
+
+     sprintf_alloc(&pkg->tmp_unpack_dir, "%s/%s-XXXXXX", conf->tmp_dir, pkg->name);
+
+     pkg->tmp_unpack_dir = mkdtemp(pkg->tmp_unpack_dir);
+     if (pkg->tmp_unpack_dir == NULL) {
+	  opkg_message(conf, OPKG_ERROR,
+		       "%s: Failed to create temporary directory '%s': %s\n",
+		       __FUNCTION__, pkg->tmp_unpack_dir, strerror(errno));
+	  return errno;
+     }
+
+     err = pkg_extract_control_files_to_dir(pkg, pkg->tmp_unpack_dir);
+     if (err) {
+	  return err;
+     }
+
+     /* XXX: CLEANUP: There might be a cleaner place to read in the
+	conffiles. Seems like I should be able to get everything to go
+	through pkg_init_from_file. If so, maybe it would make sense to
+	move all of unpack_pkg_control_files to that function. */
+
+     /* Don't need to re-read conffiles if we already have it */
+     if (pkg->conffiles.head) {
+	  return 0;
+     }
+
+     sprintf_alloc(&conffiles_file_name, "%s/conffiles", pkg->tmp_unpack_dir);
+     if (! file_exists(conffiles_file_name)) {
+	  free(conffiles_file_name);
+	  return 0;
+     }
+    
+     conffiles_file = fopen(conffiles_file_name, "r");
+     if (conffiles_file == NULL) {
+	  fprintf(stderr, "%s: failed to open %s: %s\n",
+		  __FUNCTION__, conffiles_file_name, strerror(errno));
+	  free(conffiles_file_name);
+	  return errno;
+     }
+     free(conffiles_file_name);
+
+     while (1) {
+	  char *cf_name;
+	  char *cf_name_in_dest;
+
+	  cf_name = file_read_line_alloc(conffiles_file);
+	  if (cf_name == NULL) {
+	       break;
+	  }
+	  str_chomp(cf_name);
+	  if (cf_name[0] == '\0') {
+	       continue;
+	  }
+
+	  /* Prepend dest->root_dir to conffile name.
+	     Take pains to avoid multiple slashes. */
+	  root_dir = pkg->dest->root_dir;
+	  if (conf->offline_root)
+	       /* skip the offline_root prefix */
+	       root_dir = pkg->dest->root_dir + strlen(conf->offline_root);
+	  sprintf_alloc(&cf_name_in_dest, "%s%s", root_dir,
+			cf_name[0] == '/' ? (cf_name + 1) : cf_name);
+
+	  /* Can't get an md5sum now, (file isn't extracted yet).
+	     We'll wait until resolve_conffiles */
+	  conffile_list_append(&pkg->conffiles, cf_name_in_dest, NULL);
+
+	  free(cf_name);
+	  free(cf_name_in_dest);
+     }
+
+     fclose(conffiles_file);
+
+     return 0;
+}
+
+/* returns number of installed replacees */
+int pkg_get_installed_replacees(opkg_conf_t *conf, pkg_t *pkg, pkg_vec_t *installed_replacees)
+{
+     abstract_pkg_t **replaces = pkg->replaces;
+     int replaces_count = pkg->replaces_count;
+     int i, j;
+     for (i = 0; i < replaces_count; i++) {
+	  abstract_pkg_t *ab_pkg = replaces[i];
+	  pkg_vec_t *pkg_vec = ab_pkg->pkgs;
+	  if (pkg_vec) {
+	       for (j = 0; j < pkg_vec->len; j++) {
+		    pkg_t *replacee = pkg_vec->pkgs[j];
+		    if (!pkg_conflicts(pkg, replacee))
+			 continue;
+		    if (replacee->state_status == SS_INSTALLED) {
+			 pkg_vec_insert(installed_replacees, replacee);
+		    }
+	       }
+	  }
+     }
+     return installed_replacees->len;
+}
+
+int pkg_remove_installed_replacees(opkg_conf_t *conf, pkg_vec_t *replacees)
+{
+     int i;
+     int replaces_count = replacees->len;
+     for (i = 0; i < replaces_count; i++) {
+	  pkg_t *replacee = replacees->pkgs[i];
+	  int err;
+	  replacee->state_flag |= SF_REPLACE; /* flag it so remove won't complain */
+	  err = opkg_remove_pkg(conf, replacee,0);
+	  if (err)
+	       return err;
+     }
+     return 0;
+}
+
+/* to unwind the removal: make sure they are installed */
+int pkg_remove_installed_replacees_unwind(opkg_conf_t *conf, pkg_vec_t *replacees)
+{
+     int i, err;
+     int replaces_count = replacees->len;
+     for (i = 0; i < replaces_count; i++) {
+	  pkg_t *replacee = replacees->pkgs[i];
+	  if (replacee->state_status != SS_INSTALLED) {
+               opkg_message(conf, OPKG_DEBUG2,"Function: %s calling opkg_install_pkg \n",__FUNCTION__);
+	       err = opkg_install_pkg(conf, replacee,0);
+	       if (err)
+		    return err;
+	  }
+     }
+     return 0;
+}
+
+int caught_sigint = 0;
+static void opkg_install_pkg_sigint_handler(int sig)
+{
+     caught_sigint = sig;
+}
+
+/* compares versions of pkg and old_pkg, returns 0 if OK to proceed with installation of pkg, 1 otherwise */
+static int opkg_install_check_downgrade(opkg_conf_t *conf, pkg_t *pkg, pkg_t *old_pkg, int message)
+{	  
+     if (old_pkg) {
+          char message_out[15];
+	  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;
+
+          memset(message_out,'\x0',15);
+          strncpy (message_out,"Upgrading ",strlen("Upgrading ")); 
+          if ( (conf->force_downgrade==1) && (cmp > 0) ){     /* We've been asked to allow downgrade  and version is precedent */
+             cmp = -1 ;                                       /* then we force opkg to downgrade */ 
+             strncpy (message_out,"Downgrading ",strlen("Downgrading "));         /* We need to use a value < 0 because in the 0 case we are asking to */
+                                                              /* reinstall, and some check could fail asking the "force-reinstall" option */
+          } 
+
+	  if (cmp > 0) {
+	       opkg_message(conf, OPKG_NOTICE,
+			    "Not downgrading package %s on %s from %s to %s.\n",
+			    old_pkg->name, old_pkg->dest->name, old_version, new_version);
+	       rc = 1;
+	  } else if (cmp < 0) {
+	       opkg_message(conf, OPKG_NOTICE,
+			    "%s%s on %s from %s to %s...\n",
+			    message_out, pkg->name, old_pkg->dest->name, old_version, new_version);
+	       pkg->dest = old_pkg->dest;
+	       rc = 0;
+	  } else /* cmp == 0 */ {
+	       if (conf->force_reinstall) {
+		    opkg_message(conf, OPKG_NOTICE,
+				 "Reinstalling %s (%s) on %s...\n",
+				 pkg->name, new_version, old_pkg->dest->name);
+		    pkg->dest = old_pkg->dest;
+		    rc = 0;
+	       } else {
+		    opkg_message(conf, OPKG_NOTICE,
+				 "Not installing %s (%s) on %s -- already installed.\n",
+				 pkg->name, new_version, old_pkg->dest->name);
+		    rc = 1;
+	       }
+	  } 
+	  free(old_version);
+	  free(new_version);
+	  return rc;
+     } else {
+      char message_out[15] ;
+      memset(message_out,'\x0',15);
+      if ( message ) 
+          strncpy( message_out,"Upgrading ",strlen("Upgrading ") );
+      else
+          strncpy( message_out,"Installing ",strlen("Installing ") );
+	  char *version = pkg_version_str_alloc(pkg);
+      
+	  opkg_message(conf, OPKG_NOTICE,
+		       "%s%s (%s) to %s...\n", message_out,
+		       pkg->name, version, pkg->dest->name);
+	  free(version);
+	  return 0;
+     }
+}
+
+/* and now the meat... */
+int opkg_install_pkg(opkg_conf_t *conf, pkg_t *pkg, int from_upgrade)
+{
+     int err = 0;
+     int message = 0;
+     pkg_t *old_pkg = NULL;
+     pkg_vec_t *replacees;
+     abstract_pkg_t *ab_pkg = NULL;
+     int old_state_flag;
+     char* file_md5;
+
+    
+     if ( from_upgrade ) 
+        message = 1;            /* Coming from an upgrade, and should change the output message */
+
+     if (!pkg) {
+	  opkg_message(conf, OPKG_ERROR,
+		       "INTERNAL ERROR: null pkg passed to opkg_install_pkg\n");
+	  return -EINVAL;
+     }
+
+     opkg_message(conf, OPKG_DEBUG2, "Function: %s calling pkg_arch_supported %s \n", __FUNCTION__, __FUNCTION__);
+
+     if (!pkg_arch_supported(conf, pkg)) {
+	  opkg_message(conf, OPKG_ERROR, "INTERNAL ERROR: architecture %s for pkg %s is unsupported.\n",
+		       pkg->architecture, pkg->name);
+	  return -EINVAL;
+     }
+     if (pkg->state_status == SS_INSTALLED && conf->force_reinstall == 0 && conf->nodeps == 0) {
+	  err = satisfy_dependencies_for(conf, pkg);
+	  if (err) { return err; }
+
+	  opkg_message(conf, OPKG_NOTICE,
+		       "Package %s is already installed in %s.\n", 
+		       pkg->name, pkg->dest->name);
+	  return 0;
+     }
+
+     if (pkg->dest == NULL) {
+	  pkg->dest = conf->default_dest;
+     }
+
+     old_pkg = pkg_hash_fetch_installed_by_name(&conf->pkg_hash, pkg->name);
+
+     err = opkg_install_check_downgrade(conf, pkg, old_pkg, message);
+     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 */
+     }
+
+
+     /* Abhaya: conflicts check */
+     err = check_conflicts_for(conf, pkg);
+     if (err) { return err; }
+    
+     /* this setup is to remove the upgrade scenario in the end when
+	installing pkg A, A deps B & B deps on A. So both B and A are
+	installed. Then A's installation is started resulting in an
+	uncecessary upgrade */ 
+     if (pkg->state_status == SS_INSTALLED
+	 && conf->force_reinstall == 0) return 0;
+    
+     err = verify_pkg_installable(conf, pkg);
+     if (err) { return err; }
+
+     if (pkg->local_filename == NULL) {
+	  err = opkg_download_pkg(conf, pkg, conf->tmp_dir);
+	  if (err) {
+	       opkg_message(conf, OPKG_ERROR,
+			    "Failed to download %s. Perhaps you need to run 'opkg update'?\n",
+			    pkg->name);
+	       return err;
+	  }
+     }
+
+/* Check for md5 values */
+     if (pkg->md5sum)
+     {
+         file_md5 = file_md5sum_alloc(pkg->local_filename);
+         if (strcmp(file_md5, pkg->md5sum))
+         {
+              opkg_message(conf, OPKG_ERROR,
+                           "Package %s md5sum mismatch. Either the opkg or the package index are corrupt. Try 'opkg update'.\n",
+                           pkg->name);
+              free(file_md5);
+              return err;
+         }
+         free(file_md5);
+     }
+
+     if (pkg->tmp_unpack_dir == NULL) {
+	  unpack_pkg_control_files(conf, pkg);
+     }
+
+     /* We should update the filelist here, so that upgrades of packages that split will not fail. -Jamey 27-MAR-03 */
+/* Pigi: check if it will pass from here when replacing. It seems to fail */
+/* That's rather strange that files don't change owner. Investigate !!!!!!*/
+     err = update_file_ownership(conf, pkg, old_pkg);
+     if (err) { return err; }
+
+     if (conf->nodeps == 0) {
+	  err = satisfy_dependencies_for(conf, pkg);
+	  if (err) { return err; }
+     }
+
+     replacees = pkg_vec_alloc();
+     pkg_get_installed_replacees(conf, pkg, replacees);
+
+     /* this next section we do with SIGINT blocked to prevent inconsistency between opkg database and filesystem */
+     {
+	  sigset_t newset, oldset;
+	  sighandler_t old_handler = NULL;
+	  int use_signal = 0;
+	  caught_sigint = 0;
+	  if (use_signal) {
+	       old_handler = signal(SIGINT, opkg_install_pkg_sigint_handler);
+	  } else {
+	       sigemptyset(&newset);
+	       sigaddset(&newset, SIGINT);
+	       sigprocmask(SIG_BLOCK, &newset, &oldset);
+	  }
+
+	  opkg_state_changed++;
+	  pkg->state_flag |= SF_FILELIST_CHANGED;
+
+	  /* XXX: BUG: we really should treat replacement more like an upgrade
+	   *      Instead, we're going to remove the replacees 
+	   */
+	  err = pkg_remove_installed_replacees(conf, replacees);
+	  if (err) goto UNWIND_REMOVE_INSTALLED_REPLACEES;
+
+	  err = prerm_upgrade_old_pkg(conf, pkg, old_pkg);
+	  if (err) goto UNWIND_PRERM_UPGRADE_OLD_PKG;
+
+	  err = prerm_deconfigure_conflictors(conf, pkg, replacees);
+	  if (err) goto UNWIND_PRERM_DECONFIGURE_CONFLICTORS;
+
+	  err = preinst_configure(conf, pkg, old_pkg);
+	  if (err) goto UNWIND_PREINST_CONFIGURE;
+
+	  err = backup_modified_conffiles(conf, pkg, old_pkg);
+	  if (err) goto UNWIND_BACKUP_MODIFIED_CONFFILES;
+
+	  err = check_data_file_clashes(conf, pkg, old_pkg);
+	  if (err) goto UNWIND_CHECK_DATA_FILE_CLASHES;
+
+	  err = postrm_upgrade_old_pkg(conf, pkg, old_pkg);
+	  if (err) goto UNWIND_POSTRM_UPGRADE_OLD_PKG;
+
+	  if (conf->noaction) return 0;
+
+	  /* point of no return: no unwinding after this */
+	  if (old_pkg && !conf->force_reinstall) {
+	       old_pkg->state_want = SW_DEINSTALL;
+
+	       if (old_pkg->state_flag & SF_NOPRUNE) {
+		    opkg_message(conf, OPKG_INFO,
+				 "  not removing obsolesced files because package marked noprune\n");
+	       } else {
+		    opkg_message(conf, OPKG_INFO,
+				 "  removing obsolesced files\n");
+		    remove_obsolesced_files(conf, pkg, old_pkg);
+	       }
+               /* removing files from old package, to avoid ghost files */ 
+               remove_data_files_and_list(conf, old_pkg);
+/* Pigi : It should be better to remove also maintainer and postrem scripts here, just in case*/
+               remove_maintainer_scripts_except_postrm(conf, old_pkg);
+               remove_postrm(conf, old_pkg);
+/* Pigi */
+
+	  }
+
+
+	  opkg_message(conf, OPKG_INFO,
+		       "  installing maintainer scripts\n");
+	  install_maintainer_scripts(conf, pkg, old_pkg);
+
+	  /* the following just returns 0 */
+	  remove_disappeared(conf, pkg);
+
+	  opkg_message(conf, OPKG_INFO,
+		       "  installing data files\n");
+	  install_data_files(conf, pkg);
+
+/* read comments from function for detail but I will execute this here as all other tests are ok.*/
+	  err = check_data_file_clashes_change(conf, pkg, old_pkg);
+
+	  opkg_message(conf, OPKG_INFO,
+		       "  resolving conf files\n");
+	  resolve_conffiles(conf, pkg);
+
+	  pkg->state_status = SS_UNPACKED;
+	  old_state_flag = pkg->state_flag;
+	  pkg->state_flag &= ~SF_PREFER;
+	  opkg_message(conf, OPKG_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) {
+	       old_pkg->state_status = SS_NOT_INSTALLED;
+	  }
+
+	  time(&pkg->installed_time);
+
+	  opkg_message(conf, OPKG_INFO,
+		       "  cleanup temp files\n");
+	  cleanup_temporary_files(conf, pkg);
+
+	  ab_pkg = pkg->parent;
+	  if (ab_pkg)
+	       ab_pkg->state_status = pkg->state_status;
+
+	  opkg_message(conf, OPKG_INFO, "Done.\n");
+
+	  if (use_signal)
+	       signal(SIGINT, old_handler);
+	  else
+	       sigprocmask(SIG_UNBLOCK, &newset, &oldset);
+
+	  return 0;
+     
+
+     UNWIND_POSTRM_UPGRADE_OLD_PKG:
+	  postrm_upgrade_old_pkg_unwind(conf, pkg, old_pkg);
+     UNWIND_CHECK_DATA_FILE_CLASHES:
+	  check_data_file_clashes_unwind(conf, pkg, old_pkg);
+     UNWIND_BACKUP_MODIFIED_CONFFILES:
+	  backup_modified_conffiles_unwind(conf, pkg, old_pkg);
+     UNWIND_PREINST_CONFIGURE:
+	  preinst_configure_unwind(conf, pkg, old_pkg);
+     UNWIND_PRERM_DECONFIGURE_CONFLICTORS:
+	  prerm_deconfigure_conflictors_unwind(conf, pkg, replacees);
+     UNWIND_PRERM_UPGRADE_OLD_PKG:
+	  prerm_upgrade_old_pkg_unwind(conf, pkg, old_pkg);
+     UNWIND_REMOVE_INSTALLED_REPLACEES:
+	  pkg_remove_installed_replacees_unwind(conf, replacees);
+
+	  opkg_message(conf, OPKG_INFO,
+		       "  cleanup temp files\n");
+	  cleanup_temporary_files(conf, pkg);
+
+	  opkg_message(conf, OPKG_INFO,
+		       "Failed.\n");
+	  if (use_signal)
+	       signal(SIGINT, old_handler);
+	  else
+	       sigprocmask(SIG_UNBLOCK, &newset, &oldset);
+
+	  return err;
+     }
+}
+
+static int prerm_upgrade_old_pkg(opkg_conf_t *conf, pkg_t *pkg, pkg_t *old_pkg)
+{
+     /* DPKG_INCOMPATIBILITY:
+	dpkg does some things here that we don't do yet. Do we care?
+	
+	1. If a version of the package is already installed, call
+	   old-prerm upgrade new-version
+	2. If the script runs but exits with a non-zero exit status
+	   new-prerm failed-upgrade old-version
+	   Error unwind, for both the above cases:
+	   old-postinst abort-upgrade new-version
+     */
+     return 0;
+}
+
+static int prerm_upgrade_old_pkg_unwind(opkg_conf_t *conf, pkg_t *pkg, pkg_t *old_pkg)
+{
+     /* DPKG_INCOMPATIBILITY:
+	dpkg does some things here that we don't do yet. Do we care?
+	(See prerm_upgrade_old_package for details)
+     */
+     return 0;
+}
+
+static int prerm_deconfigure_conflictors(opkg_conf_t *conf, pkg_t *pkg, pkg_vec_t *conflictors)
+{
+     /* DPKG_INCOMPATIBILITY:
+	dpkg does some things here that we don't do yet. Do we care?
+	2. If a 'conflicting' package is being removed at the same time:
+		1. If any packages depended on that conflicting package and
+		   --auto-deconfigure is specified, call, for each such package:
+		   deconfigured's-prerm deconfigure \
+		   in-favour package-being-installed version \
+		   removing conflicting-package version
+		Error unwind:
+		   deconfigured's-postinst abort-deconfigure \
+		   in-favour package-being-installed-but-failed version \
+		   removing conflicting-package version
+
+		   The deconfigured packages are marked as requiring
+		   configuration, so that if --install is used they will be
+		   configured again if possible.
+		2. To prepare for removal of the conflicting package, call:
+		   conflictor's-prerm remove in-favour package new-version
+		Error unwind:
+		   conflictor's-postinst abort-remove in-favour package new-version
+     */
+     return 0;
+}
+
+static int prerm_deconfigure_conflictors_unwind(opkg_conf_t *conf, pkg_t *pkg, pkg_vec_t *conflictors)
+{
+     /* DPKG_INCOMPATIBILITY: dpkg does some things here that we don't
+	do yet. Do we care?  (See prerm_deconfigure_conflictors for
+	details) */
+     return 0;
+}
+
+static int preinst_configure(opkg_conf_t *conf, pkg_t *pkg, pkg_t *old_pkg)
+{
+     int err;
+     char *preinst_args;
+
+     if (old_pkg) {
+	  char *old_version = pkg_version_str_alloc(old_pkg);
+	  sprintf_alloc(&preinst_args, "upgrade %s", old_version);
+	  free(old_version);
+     } else if (pkg->state_status == SS_CONFIG_FILES) {
+	  char *pkg_version = pkg_version_str_alloc(pkg);
+	  sprintf_alloc(&preinst_args, "install %s", pkg_version);
+	  free(pkg_version);
+     } else {
+	  preinst_args = strdup("install");
+     }
+
+     err = pkg_run_script(conf, pkg, "preinst", preinst_args);
+     if (err) {
+	  opkg_message(conf, OPKG_ERROR,
+		       "Aborting installation of %s\n", pkg->name);
+	  return 1;
+     }
+
+     free(preinst_args);
+
+     return 0;
+}
+
+static int preinst_configure_unwind(opkg_conf_t *conf, pkg_t *pkg, pkg_t *old_pkg)
+{
+     /* DPKG_INCOMPATIBILITY:
+	dpkg does the following error unwind, should we?
+	pkg->postrm abort-upgrade old-version
+	OR pkg->postrm abort-install old-version
+	OR pkg->postrm abort-install
+     */
+     return 0;
+}
+
+static int backup_modified_conffiles(opkg_conf_t *conf, pkg_t *pkg, pkg_t *old_pkg)
+{
+     int err;
+     conffile_list_elt_t *iter;
+     conffile_t *cf;
+
+     if (conf->noaction) return 0;
+
+     /* Backup all modified conffiles */
+     if (old_pkg) {
+	  for (iter = old_pkg->conffiles.head; iter; iter = iter->next) {
+	       char *cf_name;
+	       
+	       cf = iter->data;
+	       cf_name = root_filename_alloc(conf, cf->name);
+
+	       /* Don't worry if the conffile is just plain gone */
+	       if (file_exists(cf_name) && conffile_has_been_modified(conf, cf)) {
+		    err = backup_make_backup(conf, cf_name);
+		    if (err) {
+			 return err;
+		    }
+	       }
+	       free(cf_name);
+	  }
+     }
+
+     /* Backup all conffiles that were not conffiles in old_pkg */
+     for (iter = pkg->conffiles.head; iter; iter = iter->next) {
+	  char *cf_name;
+	  cf = iter->data;
+	  cf_name = root_filename_alloc(conf, cf->name);
+	  /* Ignore if this was a conffile in old_pkg as well */
+	  if (pkg_get_conffile(old_pkg, cf->name)) {
+	       continue;
+	  }
+
+	  if (file_exists(cf_name) && (! backup_exists_for(cf_name))) {
+	       err = backup_make_backup(conf, cf_name);
+	       if (err) {
+		    return err;
+	       }
+	  }
+	  free(cf_name);
+     }
+
+     return 0;
+}
+
+static int backup_modified_conffiles_unwind(opkg_conf_t *conf, pkg_t *pkg, pkg_t *old_pkg)
+{
+     conffile_list_elt_t *iter;
+
+     if (old_pkg) {
+	  for (iter = old_pkg->conffiles.head; iter; iter = iter->next) {
+	       backup_remove(iter->data->name);
+	  }
+     }
+
+     for (iter = pkg->conffiles.head; iter; iter = iter->next) {
+	  backup_remove(iter->data->name);
+     }
+
+     return 0;
+}
+
+
+static int check_data_file_clashes(opkg_conf_t *conf, pkg_t *pkg, pkg_t *old_pkg)
+{
+     /* DPKG_INCOMPATIBILITY:
+	opkg takes a slightly different approach than dpkg at this
+	point.  dpkg installs each file in the new package while
+	creating a backup for any file that is replaced, (so that it
+	can unwind if necessary).  To avoid complexity and redundant
+	storage, opkg doesn't do any installation until later, (at the
+	point at which dpkg removes the backups.
+	
+	But, we do have to check for data file clashes, since after
+	installing a package with a file clash, removing either of the
+	packages involved in the clash has the potential to break the
+	other package.
+     */
+     str_list_t *files_list;
+     str_list_elt_t *iter;
+
+     int clashes = 0;
+
+     files_list = pkg_get_installed_files(pkg);
+     for (iter = files_list->head; iter; iter = iter->next) {
+	  char *root_filename;
+	  char *filename = iter->data;
+	  root_filename = root_filename_alloc(conf, filename);
+	  if (file_exists(root_filename) && (! file_is_dir(root_filename))) {
+	       pkg_t *owner;
+	       pkg_t *obs;
+	       /* Pre-existing conffiles are OK */
+	       /* @@@@ should have way to check that it is a conffile -Jamey */
+	       if (backup_exists_for(root_filename)) {
+		    continue;
+	       }
+
+	       /* Pre-existing files are OK if force-overwrite was asserted. */ 
+	       if (conf->force_overwrite) {
+		    /* but we need to change who owns this file */
+		    file_hash_set_file_owner(conf, filename, pkg);
+		    continue;
+	       }
+
+	       owner = file_hash_get_file_owner(conf, filename);
+
+	       /* Pre-existing files are OK if owned by the pkg being upgraded. */
+	       if (owner && old_pkg) {
+		    if (strcmp(owner->name, old_pkg->name) == 0) {
+			 continue;
+		    }
+	       }
+
+	       /* Pre-existing files are OK if owned by a package replaced by new pkg. */
+	       if (owner) {
+                    opkg_message(conf, OPKG_DEBUG2, "Checking for replaces for %s in package %s\n", filename, owner->name);
+		    if (pkg_replaces(pkg, owner)) {
+			 continue;
+		    }
+/* If the file that would be installed is owned by the same package, ( as per a reinstall or similar )
+   then it's ok to overwrite. */
+                    if (strcmp(owner->name,pkg->name)==0){
+			 opkg_message(conf, OPKG_INFO, "Replacing pre-existing file %s owned by package %s\n", filename, owner->name);
+			 continue;
+                    }
+	       }
+
+	       /* Pre-existing files are OK if they are obsolete */
+	       obs = hash_table_get(&conf->obs_file_hash, filename);
+	       if (obs) {
+		    opkg_message(conf, OPKG_INFO, "Pre-exiting file %s is obsolete.  obs_pkg=%s\n", filename, obs->name);
+		    continue;
+	       }
+
+	       /* We have found a clash. */
+	       opkg_message(conf, OPKG_ERROR,
+			    "Package %s wants to install file %s\n"
+			    "\tBut that file is already provided by package ",
+			    pkg->name, filename);
+	       if (owner) {
+		    opkg_message(conf, OPKG_ERROR,
+				 "%s\n", owner->name);
+	       } else {
+		    opkg_message(conf, OPKG_ERROR,
+				 "<no package>\nPlease move this file out of the way and try again.\n");
+	       }
+	       clashes++;
+	  }
+	  free(root_filename);
+     }
+     pkg_free_installed_files(pkg);
+
+     return clashes;
+}
+
+static int check_data_file_clashes_change(opkg_conf_t *conf, pkg_t *pkg, pkg_t *old_pkg)
+{
+    /* Basically that's the worst hack I could do to be able to change ownership of
+       file list, but, being that we have no way to unwind the mods, due to structure
+       of hash table, probably is the quickest hack too, whishing it would not slow-up thing too much.
+       What we do here is change the ownership of file in hash if a replace ( or similar events
+       happens )
+       Only the action that are needed to change name should be considered.
+       @@@ To change after 1.0 release.
+     */
+     str_list_t *files_list;
+     str_list_elt_t *iter;
+
+     int clashes = 0;
+
+     files_list = pkg_get_installed_files(pkg);
+     for (iter = files_list->head; iter; iter = iter->next) {
+	  char *root_filename;
+	  char *filename = iter->data;
+	  root_filename = root_filename_alloc(conf, filename);
+	  if (file_exists(root_filename) && (! file_is_dir(root_filename))) {
+	       pkg_t *owner;
+
+	       if (conf->force_overwrite) {
+		    /* but we need to change who owns this file */
+		    file_hash_set_file_owner(conf, filename, pkg);
+		    continue;
+	       }
+
+	       owner = file_hash_get_file_owner(conf, filename);
+
+	       /* Pre-existing files are OK if owned by a package replaced by new pkg. */
+	       if (owner) {
+		    if (pkg_replaces(pkg, owner)) {
+/* It's now time to change the owner of that file. 
+   It has been "replaced" from the new "Replaces", then I need to inform lists file about that.  */
+			 opkg_message(conf, OPKG_INFO, "Replacing pre-existing file %s owned by package %s\n", filename, owner->name);
+		         file_hash_set_file_owner(conf, filename, pkg);
+			 continue;
+		    }
+	       }
+
+	  }
+	  free(root_filename);
+     }
+     pkg_free_installed_files(pkg);
+
+     return clashes;
+}
+
+static int check_data_file_clashes_unwind(opkg_conf_t *conf, pkg_t *pkg, pkg_t *old_pkg)
+{
+     /* Nothing to do since check_data_file_clashes doesn't change state */
+     return 0;
+}
+
+static int postrm_upgrade_old_pkg(opkg_conf_t *conf, pkg_t *pkg, pkg_t *old_pkg)
+{
+     /* DPKG_INCOMPATIBILITY: dpkg does the following here, should we?
+	1. If the package is being upgraded, call
+	   old-postrm upgrade new-version
+	2. If this fails, attempt:
+	   new-postrm failed-upgrade old-version
+	Error unwind, for both cases:
+	   old-preinst abort-upgrade new-version    */
+     return 0;
+}
+
+static int postrm_upgrade_old_pkg_unwind(opkg_conf_t *conf, pkg_t *pkg, pkg_t *old_pkg)
+{
+     /* DPKG_INCOMPATIBILITY:
+	dpkg does some things here that we don't do yet. Do we care?
+	(See postrm_upgrade_old_pkg for details)
+     */
+    return 0;
+}
+
+static int remove_obsolesced_files(opkg_conf_t *conf, pkg_t *pkg, pkg_t *old_pkg)
+{
+     int err;
+     str_list_t *old_files;
+     str_list_elt_t *of;
+     str_list_t *new_files;
+     str_list_elt_t *nf;
+
+     if (old_pkg == NULL) {
+	  return 0;
+     }
+
+     old_files = pkg_get_installed_files(old_pkg);
+     new_files = pkg_get_installed_files(pkg);
+
+     for (of = old_files->head; of; of = of->next) {
+	  pkg_t *owner;
+	  char *old, *new;
+	  old = of->data;
+	  for (nf = new_files->head; nf; nf = nf->next) {
+	       new = nf->data;
+	       if (strcmp(old, new) == 0) {
+		    goto NOT_OBSOLETE;
+	       }
+	  }
+	  if (file_is_dir(old)) {
+	       continue;
+	  }
+	  owner = file_hash_get_file_owner(conf, old);
+	  if (owner != old_pkg) {
+	       /* in case obsolete file no longer belongs to old_pkg */
+	       continue;
+	  }
+ 
+	  /* old file is obsolete */
+	  opkg_message(conf, OPKG_INFO,
+		       "    removing obsolete file %s\n", old);
+	  if (!conf->noaction) {
+	       err = unlink(old);
+	       if (err) {
+		    opkg_message(conf, OPKG_ERROR, "    Warning: remove %s failed: %s\n", old,
+				 strerror(errno));
+	       }
+	  }
+
+     NOT_OBSOLETE:
+	  ;
+     }
+
+     pkg_free_installed_files(old_pkg);
+     pkg_free_installed_files(pkg);
+
+     return 0;
+}
+
+static int remove_obsolete_maintainer_scripts(opkg_conf_t *conf, pkg_t *pkg, pkg_t *old_pkg)
+{
+     int i;
+     int err = 0;
+     char *globpattern;
+     glob_t globbuf;
+     if (0) {
+	  if (!pkg->dest) {
+	       opkg_message(conf, OPKG_ERROR, "%s: no dest for package %s\n", __FUNCTION__, pkg->name);
+	       return -1;
+	  }
+	  sprintf_alloc(&globpattern, "%s/%s.*", pkg->dest->info_dir, pkg->name);
+	  err = glob(globpattern, 0, NULL, &globbuf);
+	  free(globpattern);
+	  if (err) {
+	       return err;
+	  }
+	  /* XXXX this should perhaps only remove the ones that are not overwritten in new package.  Jamey 11/11/2003 */
+	  for (i = 0; i < globbuf.gl_pathc; i++) {
+	       opkg_message(conf, OPKG_DEBUG, "Removing control file %s from old_pkg %s\n",
+			    globbuf.gl_pathv[i], old_pkg->name);
+	       if (!conf->noaction)
+		    unlink(globbuf.gl_pathv[i]);
+	  }
+	  globfree(&globbuf);
+     }
+     return err;
+}
+
+static int install_maintainer_scripts(opkg_conf_t *conf, pkg_t *pkg, pkg_t *old_pkg)
+{
+     int ret;
+     char *prefix;
+
+     if (old_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,
+							pkg->dest->info_dir,
+							prefix);
+     free(prefix);
+     return ret;
+}
+
+static int remove_disappeared(opkg_conf_t *conf, pkg_t *pkg)
+{
+     /* DPKG_INCOMPATIBILITY:
+	This is a fairly sophisticated dpkg operation. Shall we
+	skip it? */
+     
+     /* Any packages all of whose files have been overwritten during the
+	installation, and which aren't required for dependencies, are
+	considered to have been removed. For each such package
+	1. disappearer's-postrm disappear overwriter overwriter-version
+	2. The package's maintainer scripts are removed
+	3. It is noted in the status database as being in a sane state,
+           namely not installed (any conffiles it may have are ignored,
+	   rather than being removed by dpkg). Note that disappearing
+	   packages do not have their prerm called, because dpkg doesn't
+	   know in advance that the package is going to vanish.
+     */
+     return 0;
+}
+
+static int install_data_files(opkg_conf_t *conf, pkg_t *pkg)
+{
+     int err;
+
+     /* opkg takes a slightly different approach to data file backups
+	than dpkg. Rather than removing backups at this point, we
+	actually do the data file installation now. See comments in
+	check_data_file_clashes() for more details. */
+    
+     opkg_message(conf, OPKG_INFO,
+		  "    extracting data files to %s\n", pkg->dest->root_dir);
+     err = pkg_extract_data_files_to_dir(pkg, pkg->dest->root_dir);
+     if (err) {
+	  return err;
+     }
+
+     /* XXX: BUG or FEATURE : We are actually loosing the Essential flag,
+        so we can't save ourself from removing important packages
+        At this point we (should) have extracted the .control file, so it
+        would be a good idea to reload the data in it, and set the Essential 
+        state in *pkg. From now on the Essential is back in status file and
+        we can protect again.
+        We should operate this way:
+        fopen the file ( pkg->dest->root_dir/pkg->name.control )
+        check for "Essential" in it 
+        set the value in pkg->essential.
+        This new routine could be useful also for every other flag
+        Pigi: 16/03/2004 */
+     set_flags_from_control(conf, pkg) ;
+     
+     opkg_message(conf, OPKG_DEBUG, "    Calling pkg_write_filelist from %s\n", __FUNCTION__);
+     err = pkg_write_filelist(conf, pkg);
+     if (err)
+	  return err;
+
+     /* XXX: FEATURE: opkg should identify any files which existed
+	before installation and which were overwritten, (see
+	check_data_file_clashes()). What it must do is remove any such
+	files from the filelist of the old package which provided the
+	file. Otherwise, if the old package were removed at some point
+	it would break the new package. Removing the new package will
+	also break the old one, but this cannot be helped since the old
+	package's file has already been deleted. This is the importance
+	of check_data_file_clashes(), and only allowing opkg to install
+	a clashing package with a user force. */
+
+     return 0;
+}
+
+static int resolve_conffiles(opkg_conf_t *conf, pkg_t *pkg)
+{
+     conffile_list_elt_t *iter;
+     conffile_t *cf;
+     char *cf_backup;
+
+    char *md5sum;
+
+    
+     if (conf->noaction) return 0;
+
+     for (iter = pkg->conffiles.head; iter; iter = iter->next) {
+	  char *root_filename;
+	  cf = iter->data;
+	  root_filename = root_filename_alloc(conf, cf->name);
+
+	  /* Might need to initialize the md5sum for each conffile */
+	  if (cf->value == NULL) {
+	       cf->value = file_md5sum_alloc(root_filename);
+	  }
+
+	  if (!file_exists(root_filename)) {
+	       free(root_filename);
+	       continue;
+	  }
+
+	  cf_backup = backup_filename_alloc(root_filename);
+
+
+	  if (file_exists(cf_backup)) {
+ /* Let's compute md5 to test if files are changed */
+	      md5sum = file_md5sum_alloc(cf_backup);
+               if (strcmp( cf->value,md5sum) != 0 ) {
+	          if (conf->force_defaults
+		      || user_prefers_old_conffile(cf->name, cf_backup) ) {
+		       rename(cf_backup, root_filename);
+	          }
+	       }
+	       unlink(cf_backup);
+	       free(md5sum);
+	  }
+
+	  free(cf_backup);
+	  free(root_filename);
+     }
+
+     return 0;
+}
+
+static int user_prefers_old_conffile(const char *file_name, const char *backup)
+{
+     char *response;
+     const char *short_file_name;
+
+     short_file_name = strrchr(file_name, '/');
+     if (short_file_name) {
+	  short_file_name++;
+     } else {
+	  short_file_name = file_name;
+     }
+
+     while (1) {
+	  response = get_user_response("    Configuration file '%s'\n"
+				       "    ==> File on system created by you or by a script.\n"
+				       "    ==> File also in package provided by package maintainer.\n"
+				       "       What would you like to do about it ?  Your options are:\n"
+				       "        Y or I  : install the package maintainer's version\n"
+				       "        N or O  : keep your currently-installed version\n"
+				       "          D     : show the differences between the versions (if diff is installed)\n"
+				       "     The default action is to keep your current version.\n"
+				       "    *** %s (Y/I/N/O/D) [default=N] ? ", file_name, short_file_name);
+	  if (strcmp(response, "y") == 0
+	      || strcmp(response, "i") == 0
+	      || strcmp(response, "yes") == 0) {
+	       free(response);
+	       return 0;
+	  }
+
+	  if (strcmp(response, "d") == 0) {
+	       char *cmd;
+
+	       free(response);
+	       /* XXX: BUG rewrite to use exec or busybox's internal diff */
+	       sprintf_alloc(&cmd, "diff -u %s %s", backup, file_name);
+	       xsystem(cmd);
+	       free(cmd);
+	       printf("    [Press ENTER to continue]\n");
+	       response = file_read_line_alloc(stdin);
+	       free(response);
+	       continue;
+	  }
+
+	  free(response);
+	  return 1;
+     }
+}
+
+/* XXX: CLEANUP: I'd like to move all of the code for
+   creating/cleaning pkg->tmp_unpack_dir directly into pkg.c. (Then,
+   it would make sense to cleanup pkg->tmp_unpack_dir directly from
+   pkg_deinit for example). */
+static int cleanup_temporary_files(opkg_conf_t *conf, pkg_t *pkg)
+{
+     DIR *tmp_dir;
+     struct dirent *dirent;
+     char *tmp_file;
+
+#ifdef OPKG_DEBUG_NO_TMP_CLEANUP
+#error
+     opkg_message(conf, OPKG_DEBUG,
+		  "%s: Not cleaning up %s since opkg compiled with OPKG_DEBUG_NO_TMP_CLEANUP\n",
+		  __FUNCTION__, pkg->tmp_unpack_dir);
+     return 0;
+#endif
+
+     if (pkg->tmp_unpack_dir && file_is_dir(pkg->tmp_unpack_dir)) {
+	  tmp_dir = opendir(pkg->tmp_unpack_dir);
+	  if (tmp_dir) {
+	       while (1) {
+		    dirent = readdir(tmp_dir);
+		    if (dirent == NULL) {
+			 break;
+		    }
+		    sprintf_alloc(&tmp_file, "%s/%s",
+				  pkg->tmp_unpack_dir, dirent->d_name);
+		    if (! file_is_dir(tmp_file)) {
+			 unlink(tmp_file);
+		    }
+		    free(tmp_file);
+	       }
+	       closedir(tmp_dir);
+	       rmdir(pkg->tmp_unpack_dir);
+	       free(pkg->tmp_unpack_dir);
+	       pkg->tmp_unpack_dir = NULL;
+	  }
+     }
+
+     opkg_message(conf, OPKG_INFO, "cleanup_temporary_files: pkg=%s local_filename=%s tmp_dir=%s\n",
+		  pkg->name, pkg->local_filename, conf->tmp_dir);
+     if (pkg->local_filename && strncmp(pkg->local_filename, conf->tmp_dir, strlen(conf->tmp_dir)) == 0) {
+	  unlink(pkg->local_filename);
+	  free(pkg->local_filename);
+	  pkg->local_filename = NULL;
+     }
+
+     return 0;
+}
+
+static char *backup_filename_alloc(const char *file_name)
+{
+     char *backup;
+
+     sprintf_alloc(&backup, "%s%s", file_name, OPKG_BACKUP_SUFFIX);
+
+     return backup;
+}
+
+int backup_make_backup(opkg_conf_t *conf, const char *file_name)
+{
+     int err;
+     char *backup;
+    
+     backup = backup_filename_alloc(file_name);
+     err = file_copy(file_name, backup);
+     if (err) {
+	  opkg_message(conf, OPKG_ERROR,
+		       "%s: Failed to copy %s to %s\n",
+		       __FUNCTION__, file_name, backup);
+     }
+
+     free(backup);
+
+     return err;
+}
+
+static int backup_exists_for(const char *file_name)
+{
+     int ret;
+     char *backup;
+
+     backup = backup_filename_alloc(file_name);
+
+     ret = file_exists(backup);
+
+     free(backup);
+
+     return ret;
+}
+
+static int backup_remove(const char *file_name)
+{
+     char *backup;
+
+     backup = backup_filename_alloc(file_name);
+     unlink(backup);
+     free(backup);
+
+     return 0;
+}
+
+
+
+#ifdef CONFIG_OPKG_PROCESS_ACTIONS
+
+int opkg_remove_packages(opkg_conf_t *conf, pkg_vec_t *pkgs_to_remove) 
+{
+     /* first, remove the packages that need removing */
+     for (i = 0 ; i < pkgs_to_remove->len; i++ ) {
+	  pkg_t *pkg = pkgs_to_remove->pkgs[i];
+	  err = opkg_remove_pkg(conf, pkg,0);
+	  if (err) return err;
+     }
+     return 0;
+}
+
+int opkg_process_actions_sanity_check(opkg_conf_t *conf, pkg_vec_t *pkgs_to_remove, pkg_vec_t *pkgs_superseded, pkg_vec_t *pkgs_to_install)
+{
+     int i;
+     /* now one more pass checking on the ones that need to be installed */
+     for (i = 0 ; i < pkgs_to_install->len; i++ ) {
+	  pkg_t *pkg = pkgs_to_install->pkgs[i];
+	  if (pkg->dest == NULL)
+	       pkg->dest = conf->default_dest;
+
+	  pkg->state_want = SW_INSTALL;
+
+	  /* Abhaya: conflicts check */
+	  err = check_conflicts_for(conf, pkg);
+	  if (err) { return err; }
+     }
+     return 0;
+}
+
+int opkg_process_actions_unpack_packages(opkg_conf_t *conf, pkg_vec_t *pkgs_to_remove, pkg_vec_t *pkgs_to_install)
+{
+     int i;
+     /* now one more pass checking on the ones that need to be installed */
+     for (i = 0 ; i < pkgs_to_install->len; i++ ) {
+	  pkg_t *pkg = pkgs_to_install->pkgs[i];
+
+	  /* XXX: FEATURE: Need to really support Provides/Replaces: here at some point */
+	  pkg_vec_t *replacees = pkg_vec_alloc();
+	  pkg_get_installed_replacees(conf, pkg, replacees);
+
+	  /* XXX: BUG: we really should treat replacement more like an upgrade
+	   *      Instead, we're going to remove the replacees 
+	   */
+	  err = pkg_remove_installed_replacees(conf, replacees);
+	  if (err) return err;
+	  pkg->state_flag |= SF_REMOVED_REPLACEES;
+     }
+     return 0;
+}
+
+int opkg_process_actions_unpack_packages(opkg_conf_t *conf, pkg_vec_t *pkgs_to_remove, pkg_vec_t *pkgs_to_install)
+{
+     int i;
+     /* now one more pass checking on the ones that need to be installed */
+     for (i = 0 ; i < pkgs_to_install->len; i++ ) {
+	  pkg_t *pkg = pkgs_to_install->pkgs[i];
+	  if (pkg->local_filename == NULL) {
+	       err = opkg_download_pkg(conf, pkg, conf->tmp_dir);
+	       if (err) {
+		    opkg_message(conf, OPKG_ERROR,
+				 "Failed to download %s. Perhaps you need to run 'opkg update'?\n",
+				 pkg->name);
+		    return err;
+	       }
+	  }
+	  if (pkg->tmp_unpack_dir == NULL) {
+	       err = unpack_pkg_control_files(conf, pkg);
+	       if (err) return err;
+	  }
+     }
+     return 0;
+}
+
+int opkg_process_actions_prerm(opkg_conf_t *conf, pkg_vec_t *pkgs_to_install)
+{
+     int i;
+     /* now one more pass checking on the ones that need to be installed */
+     for (i = 0 ; i < pkgs_to_install->len; i++ ) {
+	  pkg_t *pkg = pkgs_to_install->pkgs[i];
+	  pkg_t *old_pkg = pkg->old_pkg;
+
+	  err = prerm_upgrade_old_pkg(conf, pkg, old_pkg);
+	  if (err) return err;
+
+	  err = prerm_deconfigure_conflictors(conf, pkg, replacees);
+	  if (err) return err;
+
+	  err = preinst_configure(conf, pkg, old_pkg);
+	  if (err) return err;
+
+	  err = backup_modified_conffiles(conf, pkg, old_pkg);
+	  if (err) return err;
+
+	  err = postrm_upgrade_old_pkg(conf, pkg, old_pkg);
+	  if (err) return err;
+     }
+     return 0;
+}
+
+int opkg_process_actions_install(opkg_conf_t *conf, pkg_vec_t *pkgs_to_install)
+{
+     int i;
+     /* now one more pass checking on the ones that need to be installed */
+     for (i = 0 ; i < pkgs_to_install->len; i++ ) {
+	  pkg_t *pkg = pkgs_to_install->pkgs[i];
+	  pkg_t *old_pkg = pkg->old_pkg;
+
+	  if (old_pkg) {
+	       old_pkg->state_want = SW_DEINSTALL;
+
+	       if (old_pkg->state_flag & SF_NOPRUNE) {
+		    opkg_message(conf, OPKG_INFO,
+				 "  not removing obsolesced files because package marked noprune\n");
+	       } else {
+		    opkg_message(conf, OPKG_INFO,
+				 "  removing obsolesced files\n");
+		    remove_obsolesced_files(conf, pkg, old_pkg);
+	       }
+	  }
+
+	  opkg_message(conf, OPKG_INFO,
+		       "  installing maintainer scripts\n");
+	  install_maintainer_scripts(conf, pkg, old_pkg);
+
+	  /* the following just returns 0 */
+	  remove_disappeared(conf, pkg);
+
+	  opkg_message(conf, OPKG_INFO,
+		       "  installing data files\n");
+	  install_data_files(conf, pkg);
+
+	  opkg_message(conf, OPKG_INFO,
+		       "  resolving conf files\n");
+	  resolve_conffiles(conf, pkg);
+
+	  pkg->state_status = SS_UNPACKED;
+
+	  if (old_pkg) {
+	       old_pkg->state_status = SS_NOT_INSTALLED;
+	  }
+
+	  time(&pkg->installed_time);
+
+	  opkg_message(conf, OPKG_INFO,
+		       "  cleanup temp files\n");
+	  cleanup_temporary_files(conf, pkg);
+
+	  if (pkg->parent)
+	       pkg->parent->state_status = pkg->state_status;
+     }
+     return 0;
+}
+
+int opkg_process_actions_unwind_prerm(opkg_conf_t *conf, pkg_vec_t *pkgs_to_install)
+{
+     int i;
+     /* now one more pass checking on the ones that need to be installed */
+     for (i = 0 ; i < pkgs_to_install->len; i++ ) {
+	  pkg_t *pkg = pkgs_to_install->pkgs[i];
+	  pkg_t *old_pkg = pkg->old_pkg;
+
+	  if (old_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)
+		    check_data_file_clashes_unwind(conf, pkg, old_pkg);
+	       if (old_pkg->state_flags & SF_BACKUP_MODIFIED_CONFFILES)
+		    backup_modified_conffiles_unwind(conf, pkg, old_pkg);
+	       if (old_pkg->state_flags & SF_PREINST_CONFIGURE)
+		    preinst_configure_unwind(conf, pkg, old_pkg);
+	       if (old_pkg->state_flags & SF_DECONFIGURE_CONFLICTORS)
+		    prerm_deconfigure_conflictors_unwind(conf, pkg, replacees);
+	       if (old_pkg->state_flags & SF_PRERM_UPGRADE)
+		    prerm_upgrade_old_pkg_unwind(conf, pkg, old_pkg);
+
+	       if (old_pkg->state_flags & SF_REMOVED_REPLACEES)
+		    remove_installed_replacees_unwind(conf, pkg, old_pkg);
+
+	  }
+     }
+     return 0;
+}
+
+/* 
+ * Perform all the actions.
+ *
+ * pkgs_to_remove are packages marked for removal.
+ * pkgs_superseded are the old packages being replaced by upgrades.
+ *
+ * Assumes pkgs_to_install includes all dependences, recursively, sorted in installable order.
+ */
+int opkg_process_actions(opkg_conf_t *conf, pkg_vec_t *pkgs_to_remove, pkg_vec_t *pkgs_superseded, pkg_vec_t *pkgs_to_install)
+{
+     int err;
+     int i;
+
+     err = opkg_remove_packages(conf, pkgs_to_remove);
+     if (err) return err;
+
+     err = opkg_process_actions_sanity_check(conf, pkgs_superseded, pkgs_to_install);
+     if (err) return err;
+
+     err = opkg_process_actions_remove_replacees(conf, pkgs_to_install);
+     if (err) goto UNWIND;
+
+     /* @@@@ look at opkg_install_pkg for handling replacements */
+     err = opkg_process_actions_unpack_packages(conf, pkgs_to_install);
+     if (err) goto UNWIND;
+
+     /* 
+      * Now that we have the packages unpacked, we can look for data
+      * file clashes.  First, we mark the files from the superseded
+      * packages as obsolete.  Then we scan the files in
+      * pkgs_to_install, and only complain about clashes with
+      * non-obsolete files.
+      */
+
+     err = opkg_process_actions_check_data_file_clashes(conf, pkgs_superseded, pkgs_to_install);
+     if (err) goto UNWIND;
+
+     /* this was before checking data file clashes */
+     err = opkg_process_actions_prerm(conf, pkgs_superseded, pkgs_to_install);
+     if (err) goto UNWIND;
+
+     /* point of no return: no unwinding after this */
+     err = opkg_process_actions_install(conf, pkgs_to_install);
+     if (err) return err;
+
+     opkg_message(conf, OPKG_INFO, "Done.\n");
+     return 0;
+
+ UNWIND:
+     opkg_process_actions_unwind(conf, pkgs_to_install);
+
+     opkg_message(conf, OPKG_INFO,
+		  "  cleanup temp files\n");
+     cleanup_temporary_files(conf, pkg);
+
+     opkg_message(conf, OPKG_INFO,
+		  "Failed.\n");
+     return err;
+}
+
+#endif

Copied: trunk/src/target/ipkg/opkg_install.h (from rev 3877, trunk/src/target/ipkg/ipkg_install.h)
===================================================================
--- trunk/src/target/ipkg/ipkg_install.h	2008-01-18 10:03:14 UTC (rev 3877)
+++ trunk/src/target/ipkg/opkg_install.h	2008-01-18 11:28:48 UTC (rev 3879)
@@ -0,0 +1,35 @@
+/* opkg_install.h - the itsy package management system
+
+   Carl D. Worth
+
+   Copyright (C) 2001 University of Southern California
+
+   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.
+*/
+
+#ifndef OPKG_INSTALL_H
+#define OPKG_INSTALL_H
+
+#include "pkg.h"
+#include "opkg_conf.h"
+
+opkg_error_t opkg_install_by_name(opkg_conf_t *conf, const char *pkg_name);
+opkg_error_t opkg_install_multi_by_name(opkg_conf_t *conf, const char *pkg_name);
+int opkg_install_from_file(opkg_conf_t *conf, const char *filename);
+int opkg_install_pkg(opkg_conf_t *conf, pkg_t *pkg,int from_upgrading);
+int satisfy_dependencies_for(opkg_conf_t *conf, pkg_t *pkg);
+
+int opkg_satisfy_all_dependences(opkg_conf_t *conf);
+
+int pkg_mark_dependencies_for_installation(opkg_conf_t *conf, pkg_t *pkg_name, pkg_vec_t *pkgs_needed);
+int name_mark_dependencies_for_installation(opkg_conf_t *conf, const char *pkg_name, pkg_vec_t *pkgs_needed);
+
+#endif

Copied: trunk/src/target/ipkg/opkg_message.c (from rev 3877, trunk/src/target/ipkg/ipkg_message.c)
===================================================================
--- trunk/src/target/ipkg/ipkg_message.c	2008-01-18 10:03:14 UTC (rev 3877)
+++ trunk/src/target/ipkg/opkg_message.c	2008-01-18 11:28:48 UTC (rev 3879)
@@ -0,0 +1,61 @@
+/* opkg_message.c - the itsy package management system
+
+   Copyright (C) 2003 Daniele Nicolodi <daniele at grinta.net>
+
+   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 "opkg.h"
+#include "opkg_conf.h"
+#include "opkg_message.h"
+
+#ifndef OPKG_LIB
+
+void
+opkg_message (opkg_conf_t * conf, message_level_t level, char *fmt, ...)
+{
+	va_list ap;
+
+	if (conf && (conf->verbosity < level))
+	{
+		return;
+	}
+	else
+	{
+
+		va_start (ap, fmt);
+		vprintf (fmt, ap);
+		va_end (ap);
+	}
+}
+
+#else
+
+#include "libopkg.h"
+
+//#define opkg_message(conf, level, fmt, arg...) opkg_cb_message(conf, level, fmt, ## arg)
+
+void
+opkg_message (opkg_conf_t * conf, message_level_t level, char *fmt, ...)
+{
+	va_list ap;
+	char ts[256];
+
+	if (opkg_cb_message)
+	{
+		va_start (ap, fmt);
+		vsnprintf (ts,256,fmt, ap);
+		va_end (ap);
+		opkg_cb_message(conf,level,ts);
+	}
+}
+#endif

Copied: trunk/src/target/ipkg/opkg_message.h (from rev 3877, trunk/src/target/ipkg/ipkg_message.h)
===================================================================
--- trunk/src/target/ipkg/ipkg_message.h	2008-01-18 10:03:14 UTC (rev 3877)
+++ trunk/src/target/ipkg/opkg_message.h	2008-01-18 11:28:48 UTC (rev 3879)
@@ -0,0 +1,32 @@
+/* opkg_message.h - the itsy package management system
+
+   Copyright (C) 2003 Daniele Nicolodi <daniele at grinta.net>
+
+   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.
+*/
+
+#ifndef _OPKG_MESSAGE_H_
+#define _OPKG_MESSAGE_H_
+
+#include "opkg.h"
+#include "opkg_conf.h"
+
+typedef enum {
+     OPKG_ERROR,	/* error conditions */
+     OPKG_NOTICE,	/* normal but significant condition */
+     OPKG_INFO,		/* informational message */
+     OPKG_DEBUG,	/* debug level message */
+     OPKG_DEBUG2,	/* more debug level message */
+} message_level_t;
+
+extern void opkg_message(opkg_conf_t *conf, message_level_t level, char *fmt, ...);
+
+#endif /* _OPKG_MESSAGE_H_ */

Copied: trunk/src/target/ipkg/opkg_remove.c (from rev 3877, trunk/src/target/ipkg/ipkg_remove.c)
===================================================================
--- trunk/src/target/ipkg/ipkg_remove.c	2008-01-18 10:03:14 UTC (rev 3877)
+++ trunk/src/target/ipkg/opkg_remove.c	2008-01-18 11:28:48 UTC (rev 3879)
@@ -0,0 +1,383 @@
+/* opkg_remove.c - the itsy package management system
+
+   Carl D. Worth
+
+   Copyright (C) 2001 University of Southern California
+
+   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 "opkg.h"
+#include "opkg_message.h"
+
+#include <glob.h>
+
+#include "opkg_remove.h"
+
+#include "file_util.h"
+#include "sprintf_alloc.h"
+#include "str_util.h"
+
+#include "opkg_cmd.h"
+
+/*
+ * Returns number of the number of packages depending on the packages provided by this package.
+ * Every package implicitly provides itself.
+ */
+int pkg_has_installed_dependents(opkg_conf_t *conf, abstract_pkg_t *parent_apkg, pkg_t *pkg, abstract_pkg_t *** pdependents)
+{
+     int nprovides = pkg->provides_count;
+     abstract_pkg_t **provides = pkg->provides;
+     int n_installed_dependents = 0;
+     int i;
+     for (i = 0; i <= nprovides; i++) {
+	  abstract_pkg_t *providee = provides[i];
+	  abstract_pkg_t **dependers = providee->depended_upon_by;
+	  abstract_pkg_t *dep_ab_pkg;
+	  if (dependers == NULL)
+	       continue;
+	  while ((dep_ab_pkg = *dependers++) != NULL) {
+	       if (dep_ab_pkg->state_status == SS_INSTALLED){
+		    n_installed_dependents++;
+               }
+	  }
+
+     }
+     /* if caller requested the set of installed dependents */
+     if (pdependents) {
+	  int p = 0;
+	  abstract_pkg_t **dependents = (abstract_pkg_t **)malloc((n_installed_dependents+1)*sizeof(abstract_pkg_t *));
+
+          if ( dependents == NULL ){
+              fprintf(stderr,"%s Unable to allocate memory. REPORT THIS BUG IN BUGZILLA PLEASE\n", __FUNCTION__);
+              return -1;  
+          }
+
+	  *pdependents = dependents;
+	  for (i = 0; i <= nprovides; i++) {
+	       abstract_pkg_t *providee = provides[i];
+	       abstract_pkg_t **dependers = providee->depended_upon_by;
+	       abstract_pkg_t *dep_ab_pkg;
+	       if (dependers == NULL)
+		    continue;
+	       while ((dep_ab_pkg = *dependers++) != NULL) {
+		    if (dep_ab_pkg->state_status == SS_INSTALLED && !(dep_ab_pkg->state_flag & SF_MARKED)) {
+			 dependents[p++] = dep_ab_pkg;
+			 dep_ab_pkg->state_flag |= SF_MARKED;
+		    }
+	       }
+	  }
+	  dependents[p] = NULL;
+	  /* now clear the marks */
+	  for (i = 0; i < p; i++) {
+	       abstract_pkg_t *dep_ab_pkg = dependents[i];
+	       dep_ab_pkg->state_flag &= ~SF_MARKED;
+	  }
+     }
+     return n_installed_dependents;
+}
+
+int opkg_remove_dependent_pkgs (opkg_conf_t *conf, pkg_t *pkg, abstract_pkg_t **dependents)
+{
+    int i;
+    int a;
+    int count;
+    pkg_vec_t *dependent_pkgs = pkg_vec_alloc();
+    abstract_pkg_t * ab_pkg;
+
+    if((ab_pkg = pkg->parent) == NULL){
+	fprintf(stderr, "%s: unable to get dependent pkgs. pkg %s isn't in hash table\n",
+		__FUNCTION__, pkg->name);
+	return 0;
+    }
+    
+    if (dependents == NULL)
+	    return 0;
+
+    // here i am using the dependencies_checked
+    if (ab_pkg->dependencies_checked == 2) // variable to make out whether this package
+	return 0;			   // has already been encountered in the process
+	                                   // of marking packages for removal - Karthik
+    ab_pkg->dependencies_checked = 2;
+
+    i = 0;
+    count = 1;
+    while (dependents [i] != NULL) {
+        abstract_pkg_t *dep_ab_pkg = dependents[i];
+	
+	if (dep_ab_pkg->dependencies_checked == 2){
+	    i++;
+	    continue;	
+        }
+        if (dep_ab_pkg->state_status == SS_INSTALLED) {
+            for (a = 0; a < dep_ab_pkg->pkgs->len; a++) {
+                pkg_t *dep_pkg = dep_ab_pkg->pkgs->pkgs[a];
+                if (dep_pkg->state_status == SS_INSTALLED) {
+                    pkg_vec_insert(dependent_pkgs, dep_pkg);
+                    count++;
+                }
+            }
+        }
+	i++;
+	/* 1 - to keep track of visited ab_pkgs when checking for possiblility of a broken removal of pkgs.
+	 * 2 - to keep track of pkgs whose deps have been checked alrdy  - Karthik */	
+    }
+    
+    if (count == 1)
+	    return 0;
+    
+    
+    for (i = 0; i < dependent_pkgs->len; i++) {
+        int err = opkg_remove_pkg(conf, dependent_pkgs->pkgs[i],0);
+        if (err)
+            return err;
+    }
+    return 0;
+}
+
+static int user_prefers_removing_dependents(opkg_conf_t *conf, abstract_pkg_t *abpkg, pkg_t *pkg, abstract_pkg_t **dependents)
+{
+    abstract_pkg_t *dep_ab_pkg;
+    opkg_message(conf, OPKG_ERROR, "Package %s is depended upon by packages:\n", pkg->name);
+    while ((dep_ab_pkg = *dependents++) != NULL) {
+	 if (dep_ab_pkg->state_status == SS_INSTALLED)
+	      opkg_message(conf, OPKG_ERROR, "\t%s\n", dep_ab_pkg->name);
+    }
+    opkg_message(conf, OPKG_ERROR, "These might cease to work if package %s is removed.\n\n", pkg->name);
+    opkg_message(conf, OPKG_ERROR, "");
+    opkg_message(conf, OPKG_ERROR, "You can force removal of this package with -force-depends.\n");
+    opkg_message(conf, OPKG_ERROR, "You can force removal of this package and its dependents\n");
+    opkg_message(conf, OPKG_ERROR, "with -force-removal-of-dependent-packages or -recursive\n");
+    opkg_message(conf, OPKG_ERROR, "or by setting option force_removal_of_dependent_packages\n");
+    opkg_message(conf, OPKG_ERROR, "in opkg.conf.\n");
+    return 0;
+}
+
+int opkg_remove_pkg(opkg_conf_t *conf, pkg_t *pkg,int message)
+{
+/* Actually, when "message == 1" I have been called from an upgrade, and not from a normal remove
+   thus I wan't check for essential, as I'm upgrading.
+   I hope it won't break anything :) 
+*/
+     int err;
+     abstract_pkg_t *parent_pkg = NULL;
+	
+     if (pkg->essential && !message) {
+	  if (conf->force_removal_of_essential_packages) {
+	       fprintf(stderr, "WARNING: Removing essential package %s under your coercion.\n"
+		       "\tIf your system breaks, you get to keep both pieces\n",
+		       pkg->name);
+	  } else {
+	       fprintf(stderr, "ERROR: Refusing to remove essential package %s.\n"
+		       "\tRemoving an essential package may lead to an unusable system, but if\n"
+		       "\tyou enjoy that kind of pain, you can force opkg to proceed against\n"
+		       "\tits will with the option: -force-removal-of-essential-packages\n",
+		       pkg->name);
+	       return OPKG_PKG_IS_ESSENTIAL;
+	  }
+     }
+
+     if ((parent_pkg = pkg->parent) == NULL)
+	  return 0;
+
+     /* only attempt to remove dependent installed packages if
+      * force_depends is not specified or the package is being
+      * replaced.
+      */
+     if (!conf->force_depends
+	 && !(pkg->state_flag & SF_REPLACE)) {
+	  abstract_pkg_t **dependents;
+	  int has_installed_dependents = 
+	       pkg_has_installed_dependents(conf, parent_pkg, pkg, &dependents);
+
+	  if (has_installed_dependents) {
+	       /*
+		* if this package is depended up by others, then either we should
+		* not remove it or we should remove it and all of its dependents 
+		*/
+
+	       if (!conf->force_removal_of_dependent_packages
+		   && !user_prefers_removing_dependents(conf, parent_pkg, pkg, dependents)) {
+		    return OPKG_PKG_HAS_DEPENDENTS;
+	       }
+
+	       /* remove packages depending on this package - Karthik */
+	       err = opkg_remove_dependent_pkgs (conf, pkg, dependents);
+	       free(dependents);
+	       if (err) return err;
+	  }
+     }
+
+     if ( message==0 ){
+         printf("Removing package %s from %s...\n", pkg->name, pkg->dest->name);
+         fflush(stdout);
+     }
+     pkg->state_flag |= SF_FILELIST_CHANGED;
+
+     pkg->state_want = SW_DEINSTALL;
+     opkg_state_changed++;
+
+     pkg_run_script(conf, pkg, "prerm", "remove");
+
+     /* DPKG_INCOMPATIBILITY: dpkg is slightly different here. It
+	maintains an empty filelist rather than deleting it. That seems
+	like a big pain, and I don't see that that should make a big
+	difference, but for anyone who wants tighter compatibility,
+	feel free to fix this. */
+     remove_data_files_and_list(conf, pkg);
+
+     pkg_run_script(conf, pkg, "postrm", "remove");
+
+     remove_maintainer_scripts_except_postrm(conf, pkg);
+
+     /* Aman Gupta - Since opkg is made for handheld devices with limited
+      * space, it doesn't make sense to leave extra configurations, files, 
+      * and maintainer scripts left around. So, we make remove like purge, 
+      * and take out all the crap :) */
+
+     remove_postrm(conf, pkg);
+     pkg->state_status = SS_NOT_INSTALLED;
+
+     if (parent_pkg) 
+	  parent_pkg->state_status = SS_NOT_INSTALLED;
+
+     return 0;
+}
+
+int opkg_purge_pkg(opkg_conf_t *conf, pkg_t *pkg)
+{
+    opkg_remove_pkg(conf, pkg,0);
+    return 0;
+}
+
+int remove_data_files_and_list(opkg_conf_t *conf, pkg_t *pkg)
+{
+     str_list_t installed_dirs;
+     str_list_t *installed_files;
+     str_list_elt_t *iter;
+     char *file_name;
+     conffile_t *conffile;
+     int removed_a_dir;
+     pkg_t *owner;
+
+     str_list_init(&installed_dirs);
+     installed_files = pkg_get_installed_files(pkg);
+
+     for (iter = installed_files->head; iter; iter = iter->next) {
+	  file_name = iter->data;
+
+	  if (file_is_dir(file_name)) {
+	       str_list_append(&installed_dirs, strdup(file_name));
+	       continue;
+	  }
+
+	  conffile = pkg_get_conffile(pkg, file_name);
+	  if (conffile) {
+	       /* XXX: QUESTION: Is this right? I figure we only need to
+		  save the conffile if it has been modified. Is that what
+		  dpkg does? Or does dpkg preserve all conffiles? If so,
+		  this seems like a better thing to do to conserve
+		  space. */
+	       if (conffile_has_been_modified(conf, conffile)) {
+		    printf("  not deleting modified conffile %s\n", file_name);
+		    fflush(stdout);
+		    continue;
+	       }
+	  }
+
+	  opkg_message(conf, OPKG_INFO, "  deleting %s (noaction=%d)\n", file_name, conf->noaction);
+	  if (!conf->noaction)
+	       unlink(file_name);
+     }
+
+     if (!conf->noaction) {
+	  do {
+	       removed_a_dir = 0;
+	       for (iter = installed_dirs.head; iter; iter = iter->next) {
+		    file_name = iter->data;
+	    
+		    if (rmdir(file_name) == 0) {
+			 opkg_message(conf, OPKG_INFO, "  deleting %s\n", file_name);
+			 removed_a_dir = 1;
+			 str_list_remove(&installed_dirs, &iter);
+		    }
+	       }
+	  } while (removed_a_dir);
+     }
+
+     pkg_free_installed_files(pkg);
+     /* We have to remove the file list now, so that
+	find_pkg_owning_file does not always just report this package */
+     pkg_remove_installed_files_list(conf, pkg);
+
+     /* Don't print warning for dirs that are provided by other packages */
+     for (iter = installed_dirs.head; iter; iter = iter->next) {
+	  file_name = iter->data;
+
+	  owner = file_hash_get_file_owner(conf, file_name);
+	  if (owner) {
+	       free(iter->data);
+	       iter->data = NULL;
+	       str_list_remove(&installed_dirs, &iter);
+	  }
+     }
+
+     /* cleanup */
+     for (iter = installed_dirs.head; iter; iter = iter->next) {
+	  free(iter->data);
+	  iter->data = NULL;
+     }
+     str_list_deinit(&installed_dirs);
+
+     return 0;
+}
+
+int remove_maintainer_scripts_except_postrm(opkg_conf_t *conf, pkg_t *pkg)
+{
+    int i, err;
+    char *globpattern;
+    glob_t globbuf;
+    
+    if (conf->noaction) return 0;
+
+    sprintf_alloc(&globpattern, "%s/%s.*",
+		  pkg->dest->info_dir, pkg->name);
+    err = glob(globpattern, 0, NULL, &globbuf);
+    free(globpattern);
+    if (err) {
+	return 0;
+    }
+
+    for (i = 0; i < globbuf.gl_pathc; i++) {
+	if (str_ends_with(globbuf.gl_pathv[i], ".postrm")) {
+	    continue;
+	}
+        opkg_message(conf, OPKG_INFO, "  deleting %s\n", globbuf.gl_pathv[i]);
+	unlink(globbuf.gl_pathv[i]);
+    }
+    globfree(&globbuf);
+
+    return 0;
+}
+
+int remove_postrm(opkg_conf_t *conf, pkg_t *pkg)
+{
+    char *postrm_file_name;
+
+    if (conf->noaction) return 0;
+
+    sprintf_alloc(&postrm_file_name, "%s/%s.postrm",
+		  pkg->dest->info_dir, pkg->name);
+    unlink(postrm_file_name);
+    free(postrm_file_name);
+
+    return 0;
+}

Copied: trunk/src/target/ipkg/opkg_remove.h (from rev 3877, trunk/src/target/ipkg/ipkg_remove.h)
===================================================================
--- trunk/src/target/ipkg/ipkg_remove.h	2008-01-18 10:03:14 UTC (rev 3877)
+++ trunk/src/target/ipkg/opkg_remove.h	2008-01-18 11:28:48 UTC (rev 3879)
@@ -0,0 +1,33 @@
+/* opkg_remove.h - the itsy package management system
+
+   Carl D. Worth
+
+   Copyright (C) 2001 University of Southern California
+
+   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.
+*/
+
+#ifndef OPKG_REMOVE_H
+#define OPKG_REMOVE_H
+
+#include "pkg.h"
+#include "opkg_conf.h"
+
+int opkg_remove_pkg(opkg_conf_t *conf, pkg_t *pkg,int message);
+int opkg_purge_pkg(opkg_conf_t *conf, pkg_t *pkg);
+int possible_broken_removal_of_packages (opkg_conf_t *conf, pkg_t *pkg);
+int pkg_has_installed_dependents(opkg_conf_t *conf, abstract_pkg_t *parent_apkg, pkg_t *pkg, abstract_pkg_t *** pdependents);
+int remove_data_files_and_list(opkg_conf_t *conf, pkg_t *pkg);
+int remove_maintainer_scripts_except_postrm (opkg_conf_t *conf, pkg_t *pkg);
+int remove_postrm (opkg_conf_t *conf, pkg_t *pkg);
+
+
+#endif

Copied: trunk/src/target/ipkg/opkg_upgrade.c (from rev 3877, trunk/src/target/ipkg/ipkg_upgrade.c)
===================================================================
--- trunk/src/target/ipkg/ipkg_upgrade.c	2008-01-18 10:03:14 UTC (rev 3877)
+++ trunk/src/target/ipkg/opkg_upgrade.c	2008-01-18 11:28:48 UTC (rev 3879)
@@ -0,0 +1,77 @@
+/* opkg_upgrade.c - the itsy package management system
+
+   Carl D. Worth
+   Copyright (C) 2001 University of Southern California
+
+   Copyright (C) 2003 Daniele Nicolodi <daniele at grinta.net>
+
+   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 "opkg.h"
+#include "opkg_install.h"
+#include "opkg_message.h"
+
+int opkg_upgrade_pkg(opkg_conf_t *conf, pkg_t *old)
+{
+     pkg_t *new;
+     int cmp;
+     char *old_version, *new_version;
+
+     if (old->state_flag & SF_HOLD) {
+          opkg_message(conf, OPKG_NOTICE,
+                       "Not upgrading package %s which is marked "
+                       "hold (flags=%#x)\n", old->name, old->state_flag);
+          return 0;
+     }
+
+     new = pkg_hash_fetch_best_installation_candidate_by_name(conf, old->name);
+     if (new == NULL) {
+          old_version = pkg_version_str_alloc(old);
+          opkg_message(conf, OPKG_NOTICE,
+                       "Assuming locally installed package %s (%s) "
+                       "is up to date.\n", old->name, old_version);
+          free(old_version);
+          return 0;
+     }
+          
+     old_version = pkg_version_str_alloc(old);
+     new_version = pkg_version_str_alloc(new);
+               
+     cmp = pkg_compare_versions(old, new);
+     opkg_message(conf, OPKG_DEBUG,
+                  "comparing visible versions of pkg %s:"
+                  "\n\t%s is installed "
+                  "\n\t%s is available "
+                  "\n\t%d was comparison result\n",
+                  old->name, old_version, new_version, cmp);
+     if (cmp == 0) {
+          opkg_message(conf, OPKG_INFO,
+                       "Package %s (%s) installed in %s is up to date.\n",
+                       old->name, old_version, old->dest->name);
+          free(old_version);
+          free(new_version);
+          return 0;
+     } else if (cmp > 0) {
+          opkg_message(conf, OPKG_NOTICE,
+                       "Not downgrading package %s on %s from %s to %s.\n",
+                       old->name, old->dest->name, old_version, new_version);
+          free(old_version);
+          free(new_version);
+          return 0;
+     } else if (cmp < 0) {
+          new->dest = old->dest;
+          old->state_want = SW_DEINSTALL;
+     }
+
+     new->state_flag |= SF_USER;
+     return opkg_install_pkg(conf, new,1);
+}

Copied: trunk/src/target/ipkg/opkg_upgrade.h (from rev 3877, trunk/src/target/ipkg/ipkg_upgrade.h)
===================================================================
--- trunk/src/target/ipkg/ipkg_upgrade.h	2008-01-18 10:03:14 UTC (rev 3877)
+++ trunk/src/target/ipkg/opkg_upgrade.h	2008-01-18 11:28:48 UTC (rev 3879)
@@ -0,0 +1,18 @@
+/* opkg_upgrade.c - the itsy package management system
+
+   Copyright (C) 2003 Daniele Nicolodi <daniele at grinta.net>
+
+   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 "opkg.h"
+
+int opkg_upgrade_pkg(opkg_conf_t *conf, pkg_t *old);

Copied: trunk/src/target/ipkg/opkg_utils.c (from rev 3877, trunk/src/target/ipkg/ipkg_utils.c)
===================================================================
--- trunk/src/target/ipkg/ipkg_utils.c	2008-01-18 10:03:14 UTC (rev 3877)
+++ trunk/src/target/ipkg/opkg_utils.c	2008-01-18 11:28:48 UTC (rev 3879)
@@ -0,0 +1,183 @@
+/* opkg_utils.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 "opkg.h"
+#include <errno.h>
+#include <ctype.h>
+#include <sys/vfs.h>
+
+#include "opkg_utils.h"
+#include "pkg.h"
+#include "pkg_hash.h"
+
+void print_pkg_status(pkg_t * pkg, FILE * file);
+
+int get_available_blocks(char * filesystem)
+{
+     struct statfs sfs;
+
+     if(statfs(filesystem, &sfs)){
+	  fprintf(stderr, "bad statfs\n");
+	  return 0;
+     }
+     /*    fprintf(stderr, "reported fs type %x\n", sfs.f_type); */
+     return ((sfs.f_bavail * sfs.f_bsize) / 1024);
+}
+
+char **read_raw_pkgs_from_file(const char *file_name)
+{
+     FILE *fp; 
+     char **ret;
+    
+     if(!(fp = fopen(file_name, "r"))){
+	  fprintf(stderr, "can't get %s open for read\n", file_name);
+	  return NULL;
+     }
+
+     ret = read_raw_pkgs_from_stream(fp);
+
+     fclose(fp);
+
+     return ret;
+}
+
+char **read_raw_pkgs_from_stream(FILE *fp)
+{    
+     char **raw = NULL, *buf, *scout;
+     int count = 0;
+     size_t size = 512;
+     
+     buf = malloc (size);
+
+     while (fgets(buf, size, fp)) {
+	  while (strlen (buf) == (size - 1)
+		 && buf[size-2] != '\n') {
+	       size_t o = size - 1;
+	       size *= 2;
+	       buf = realloc (buf, size);
+	       if (fgets (buf + o, size - o, fp) == NULL)
+		    break;
+	  }
+	  
+	  if(!(count % 50))
+	       raw = realloc(raw, (count + 50) * sizeof(char *));
+	
+	  if((scout = strchr(buf, '\n')))
+	       *scout = '\0';
+
+	  raw[count++] = strdup(buf);
+     }
+    
+     raw = realloc(raw, (count + 1) * sizeof(char *));
+     raw[count] = NULL;
+
+     free (buf);
+    
+     return raw;
+}
+
+/* something to remove whitespace, a hash pooper */
+char *trim_alloc(char *line)
+{
+     char *new; 
+     char *dest, *src, *end;
+    
+     new = malloc(strlen(line) + 1);
+     if ( new == NULL ){
+        fprintf(stderr,"%s: Unable to allocate memory\n",__FUNCTION__);
+        return NULL;
+     }
+     dest = new, src = line, end = line + (strlen(line) - 1);
+
+     /* remove it from the front */    
+     while(src && 
+	   isspace(*src) &&
+	   *src)
+	  src++;
+     /* and now from the back */
+     while((end > src) &&
+	   isspace(*end))
+	  end--;
+     end++;
+     *end = '\0';
+     strcpy(new, src);
+     /* this does from the first space
+      *  blasting away any versions stuff in depends
+      while(src && 
+      !isspace(*src) &&
+      *src)
+      *dest++ = *src++;
+      *dest = '\0';
+      */
+    
+     return new;
+}
+
+int line_is_blank(const char *line)
+{
+     const char *s;
+
+     for (s = line; *s; s++) {
+	  if (!isspace(*s))
+	       return 0;
+     }
+     return 1;
+}
+
+void push_error_list(struct errlist ** errors, char * msg){
+  struct errlist *err_lst_tmp;
+
+
+  err_lst_tmp = malloc ( sizeof (err_lst_tmp) );
+  err_lst_tmp->errmsg=strdup(msg) ;
+  err_lst_tmp->next = *errors;
+  *errors = err_lst_tmp;
+}
+
+
+void reverse_error_list(struct errlist **errors){
+   struct errlist *result=NULL;
+   struct errlist *current= *errors;
+   struct errlist *next;
+
+   while ( current != NULL ) {
+      next = current->next;
+      current->next=result;
+      result=current;
+      current=next;
+   }
+   *errors=result;
+
+}
+
+       
+void free_error_list(){
+struct errlist *err_tmp_lst;
+
+  err_tmp_lst = error_list;
+
+    while (err_tmp_lst != NULL) {
+      free(err_tmp_lst->errmsg);
+      err_tmp_lst = error_list->next;
+      free(error_list);
+      error_list = err_tmp_lst;
+    }
+
+
+}
+
+       

Copied: trunk/src/target/ipkg/opkg_utils.h (from rev 3877, trunk/src/target/ipkg/ipkg_utils.h)
===================================================================
--- trunk/src/target/ipkg/ipkg_utils.h	2008-01-18 10:03:14 UTC (rev 3877)
+++ trunk/src/target/ipkg/opkg_utils.h	2008-01-18 11:28:48 UTC (rev 3879)
@@ -0,0 +1,29 @@
+/* opkg_utils.h - 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.
+*/
+
+#ifndef OPKG_UTILS_H
+#define OPKG_UTILS_H
+
+#include "pkg.h"
+
+int get_available_blocks(char * filesystem);
+char **read_raw_pkgs_from_file(const char *file_name);
+char **read_raw_pkgs_from_stream(FILE *fp);
+char *trim_alloc(char * line);
+int line_is_blank(const char *line);
+
+#endif

Modified: trunk/src/target/ipkg/pkg.c
===================================================================
--- trunk/src/target/ipkg/pkg.c	2008-01-18 11:05:46 UTC (rev 3878)
+++ trunk/src/target/ipkg/pkg.c	2008-01-18 11:28:48 UTC (rev 3879)
@@ -15,7 +15,7 @@
    General Public License for more details.
 */
 
-#include "ipkg.h"
+#include "opkg.h"
 #include <ctype.h>
 #include <string.h>
 #include <errno.h>
@@ -24,14 +24,14 @@
 
 #include "pkg_parse.h"
 #include "pkg_extract.h"
-#include "ipkg_message.h"
-#include "ipkg_utils.h"
+#include "opkg_message.h"
+#include "opkg_utils.h"
 
 #include "sprintf_alloc.h"
 #include "file_util.h"
 #include "str_util.h"
 #include "xsystem.h"
-#include "ipkg_conf.h"
+#include "opkg_conf.h"
 
 typedef struct enum_map enum_map_t;
 struct enum_map
@@ -153,9 +153,9 @@
 	don't free */
      pkg->revision = NULL;
      pkg->familiar_revision = NULL;
-     /* owned by ipkg_conf_t */
+     /* owned by opkg_conf_t */
      pkg->dest = NULL;
-     /* owned by ipkg_conf_t */
+     /* owned by opkg_conf_t */
      pkg->src = NULL;
      free(pkg->architecture);
      pkg->architecture = NULL;
@@ -185,8 +185,8 @@
      free(pkg->local_filename);
      pkg->local_filename = NULL;
      /* CLEANUP: It'd be nice to pullin the cleanup function from
-	ipkg_install.c here. See comment in
-	ipkg_install.c:cleanup_temporary_files */
+	opkg_install.c here. See comment in
+	opkg_install.c:cleanup_temporary_files */
      free(pkg->tmp_unpack_dir);
      pkg->tmp_unpack_dir = NULL;
      free(pkg->md5sum);
@@ -393,27 +393,27 @@
      return 0;
 }
 
-void set_flags_from_control(ipkg_conf_t *conf, pkg_t *pkg){
+void set_flags_from_control(opkg_conf_t *conf, pkg_t *pkg){
      char * temp_str;
      char **raw =NULL;
      char **raw_start=NULL; 
 
      temp_str = (char *) malloc (strlen(pkg->dest->info_dir)+strlen(pkg->name)+12);
      if (temp_str == NULL ){
-        ipkg_message(conf, IPKG_INFO, "Out of memory in  %s\n", __FUNCTION__);
+        opkg_message(conf, OPKG_INFO, "Out of memory in  %s\n", __FUNCTION__);
         return;
      }
      sprintf( temp_str,"%s/%s.control",pkg->dest->info_dir,pkg->name);
    
      raw = raw_start = read_raw_pkgs_from_file(temp_str);
      if (raw == NULL ){
-        ipkg_message(conf, IPKG_ERROR, "Unable to open the control file in  %s\n", __FUNCTION__);
+        opkg_message(conf, OPKG_ERROR, "Unable to open the control file in  %s\n", __FUNCTION__);
         return;
      }
 
      while(*raw){
         if (!pkg_valorize_other_field(pkg, &raw ) == 0) {
-            ipkg_message(conf, IPKG_DEBUG, "unable to read control file for %s. May be empty\n", pkg->name);
+            opkg_message(conf, OPKG_DEBUG, "unable to read control file for %s. May be empty\n", pkg->name);
         }
      }
      raw = raw_start;
@@ -763,9 +763,9 @@
 	       int i;
 
 	       if (pkg->provides_count) {
-               /* Here we check if the ipkg_internal_use_only is used, and we discard it.*/
+               /* Here we check if the opkg_internal_use_only is used, and we discard it.*/
                   for ( i=0; i < pkg->provides_count; i++ ){
-	              if (strstr(pkg->provides_str[i],"ipkg_internal_use_only")!=NULL) {
+	              if (strstr(pkg->provides_str[i],"opkg_internal_use_only")!=NULL) {
                          memset (pkg->provides_str[i],'\x0',strlen(pkg->provides_str[i])); /* Pigi clear my trick flag, just in case */
                          flag_provide_false = 1;
                       }
@@ -1355,7 +1355,7 @@
      return 0;
 }
 
-int pkg_remove_installed_files_list(ipkg_conf_t *conf, pkg_t *pkg)
+int pkg_remove_installed_files_list(opkg_conf_t *conf, pkg_t *pkg)
 {
      int err;
      char *list_file_name;
@@ -1396,7 +1396,7 @@
      return NULL;
 }
 
-int pkg_run_script(ipkg_conf_t *conf, pkg_t *pkg,
+int pkg_run_script(opkg_conf_t *conf, pkg_t *pkg,
 		   const char *script, const char *args)
 {
      int err;
@@ -1424,7 +1424,7 @@
 	  sprintf_alloc(&path, "%s/%s", pkg->tmp_unpack_dir, script);
      }
 
-     ipkg_message(conf, IPKG_INFO, "Running script %s\n", path);
+     opkg_message(conf, OPKG_INFO, "Running script %s\n", path);
      if (conf->noaction) return 0;
 
      /* XXX: CLEANUP: There must be a better way to handle maintainer
@@ -1432,7 +1432,7 @@
 	than '/'. I've been playing around with some clever chroot
 	tricks and I might come up with something workable. */
      if (conf->offline_root) {
-	  setenv("IPKG_OFFLINE_ROOT", conf->offline_root, 1);
+	  setenv("OPKG_OFFLINE_ROOT", conf->offline_root, 1);
      }
 
      setenv("PKG_ROOT",
@@ -1584,7 +1584,7 @@
      return SS_NOT_INSTALLED;
 }
 
-int pkg_arch_supported(ipkg_conf_t *conf, pkg_t *pkg)
+int pkg_arch_supported(opkg_conf_t *conf, pkg_t *pkg)
 {
      nv_pair_list_elt_t *l;
 
@@ -1596,17 +1596,17 @@
      while (l) {
 	  nv_pair_t *nv = l->data;
 	  if (strcmp(nv->name, pkg->architecture) == 0) {
-	       ipkg_message(conf, IPKG_DEBUG, "arch %s (priority %s) supported for pkg %s\n", nv->name, nv->value, pkg->name);
+	       opkg_message(conf, OPKG_DEBUG, "arch %s (priority %s) supported for pkg %s\n", nv->name, nv->value, pkg->name);
 	       return 1;
 	  }
 	  l = l->next;
      }
 
-     ipkg_message(conf, IPKG_DEBUG, "arch %s unsupported for pkg %s\n", pkg->architecture, pkg->name);
+     opkg_message(conf, OPKG_DEBUG, "arch %s unsupported for pkg %s\n", pkg->architecture, pkg->name);
      return 0;
 }
 
-int pkg_get_arch_priority(ipkg_conf_t *conf, const char *archname)
+int pkg_get_arch_priority(opkg_conf_t *conf, const char *archname)
 {
      nv_pair_list_elt_t *l;
 
@@ -1623,14 +1623,14 @@
      return 0;
 }
 
-int pkg_info_preinstall_check(ipkg_conf_t *conf)
+int pkg_info_preinstall_check(opkg_conf_t *conf)
 {
      int i;
      hash_table_t *pkg_hash = &conf->pkg_hash;
      pkg_vec_t *available_pkgs = pkg_vec_alloc();
      pkg_vec_t *installed_pkgs = pkg_vec_alloc();
 
-     ipkg_message(conf, IPKG_INFO, "pkg_info_preinstall_check: updating arch priority for each package\n");
+     opkg_message(conf, OPKG_INFO, "pkg_info_preinstall_check: updating arch priority for each package\n");
      pkg_hash_fetch_available(pkg_hash, available_pkgs);
      /* update arch_priority for each package */
      for (i = 0; i < available_pkgs->len; i++) {
@@ -1638,12 +1638,12 @@
 	  int arch_priority = 1;
 	  if (!pkg)
 	       continue;
-	  // ipkg_message(conf, IPKG_DEBUG2, " package %s version=%s arch=%p:", pkg->name, pkg->version, pkg->architecture);
+	  // opkg_message(conf, OPKG_DEBUG2, " package %s version=%s arch=%p:", pkg->name, pkg->version, pkg->architecture);
 	  if (pkg->architecture) 
 	       arch_priority = pkg_get_arch_priority(conf, pkg->architecture);
 	  else 
-	       ipkg_message(conf, IPKG_ERROR, "pkg_info_preinstall_check: no architecture for package %s\n", pkg->name);
-	  // ipkg_message(conf, IPKG_DEBUG2, "%s arch_priority=%d\n", pkg->architecture, arch_priority);
+	       opkg_message(conf, OPKG_ERROR, "pkg_info_preinstall_check: no architecture for package %s\n", pkg->name);
+	  // opkg_message(conf, OPKG_DEBUG2, "%s arch_priority=%d\n", pkg->architecture, arch_priority);
 	  pkg->arch_priority = arch_priority;
      }
 
@@ -1651,7 +1651,7 @@
 	  pkg_t *pkg = available_pkgs->pkgs[i];
 	  if (!pkg->arch_priority && (pkg->state_flag || (pkg->state_want != SW_UNKNOWN))) {
 	       /* clear flags and want for any uninstallable package */
-	       ipkg_message(conf, IPKG_NOTICE, "Clearing state_want and state_flag for pkg=%s (arch_priority=%d flag=%d want=%d)\n", 
+	       opkg_message(conf, OPKG_NOTICE, "Clearing state_want and state_flag for pkg=%s (arch_priority=%d flag=%d want=%d)\n", 
 			    pkg->name, pkg->arch_priority, pkg->state_flag, pkg->state_want);
 	       pkg->state_want = SW_UNKNOWN;
 	       pkg->state_flag = 0;
@@ -1660,19 +1660,19 @@
      pkg_vec_free(available_pkgs);
 
      /* update the file owner data structure */
-     ipkg_message(conf, IPKG_INFO, "pkg_info_preinstall_check: update file owner list\n");
+     opkg_message(conf, OPKG_INFO, "pkg_info_preinstall_check: update file owner list\n");
      pkg_hash_fetch_all_installed(pkg_hash, installed_pkgs);
      for (i = 0; i < installed_pkgs->len; i++) {
 	  pkg_t *pkg = installed_pkgs->pkgs[i];
 	  str_list_t *installed_files = pkg_get_installed_files(pkg); /* this causes installed_files to be cached */
 	  str_list_elt_t *iter;
 	  if (installed_files == NULL) {
-	       ipkg_message(conf, IPKG_ERROR, "No installed files for pkg %s\n", pkg->name);
+	       opkg_message(conf, OPKG_ERROR, "No installed files for pkg %s\n", pkg->name);
 	       break;
 	  }
 	  for (iter = installed_files->head; iter; iter = iter->next) {
 	       char *installed_file = iter->data;
-	       // ipkg_message(conf, IPKG_DEBUG2, "pkg %s: file=%s\n", pkg->name, installed_file);
+	       // opkg_message(conf, OPKG_DEBUG2, "pkg %s: file=%s\n", pkg->name, installed_file);
 	       file_hash_set_file_owner(conf, installed_file, pkg);
 	  }
      }
@@ -1682,7 +1682,7 @@
 }
 
 struct pkg_write_filelist_data {
-     ipkg_conf_t *conf;
+     opkg_conf_t *conf;
      pkg_t *pkg;
      FILE *stream;
 };
@@ -1696,28 +1696,28 @@
      }
 }
 
-int pkg_write_filelist(ipkg_conf_t *conf, pkg_t *pkg)
+int pkg_write_filelist(opkg_conf_t *conf, pkg_t *pkg)
 {
      struct pkg_write_filelist_data data;
      char *list_file_name = NULL;
      int err = 0;
 
      if (!pkg) {
-	  ipkg_message(conf, IPKG_ERROR, "Null pkg\n");
+	  opkg_message(conf, OPKG_ERROR, "Null pkg\n");
 	  return -EINVAL;
      }
-     ipkg_message(conf, IPKG_INFO,
+     opkg_message(conf, OPKG_INFO,
 		  "    creating %s.list file\n", pkg->name);
      sprintf_alloc(&list_file_name, "%s/%s.list", pkg->dest->info_dir, pkg->name);
      if (!list_file_name) {
-	  ipkg_message(conf, IPKG_ERROR, "Failed to alloc list_file_name\n");
+	  opkg_message(conf, OPKG_ERROR, "Failed to alloc list_file_name\n");
 	  return -ENOMEM;
      }
-     ipkg_message(conf, IPKG_INFO,
+     opkg_message(conf, OPKG_INFO,
 		  "    creating %s file for pkg %s\n", list_file_name, pkg->name);
      data.stream = fopen(list_file_name, "w");
      if (!data.stream) {
-	  ipkg_message(conf, IPKG_ERROR, "Could not open %s for writing: %s\n",
+	  opkg_message(conf, OPKG_ERROR, "Could not open %s for writing: %s\n",
 		       list_file_name, strerror(errno));
 		       return errno;
      }
@@ -1730,7 +1730,7 @@
      return err;
 }
 
-int pkg_write_changed_filelists(ipkg_conf_t *conf)
+int pkg_write_changed_filelists(opkg_conf_t *conf)
 {
      pkg_vec_t *installed_pkgs = pkg_vec_alloc();
      hash_table_t *pkg_hash = &conf->pkg_hash;
@@ -1739,15 +1739,15 @@
      if (conf->noaction)
 	  return 0;
 
-     ipkg_message(conf, IPKG_INFO, "%s: saving changed filelists\n", __FUNCTION__);
+     opkg_message(conf, OPKG_INFO, "%s: saving changed filelists\n", __FUNCTION__);
      pkg_hash_fetch_all_installed(pkg_hash, installed_pkgs);
      for (i = 0; i < installed_pkgs->len; i++) {
 	  pkg_t *pkg = installed_pkgs->pkgs[i];
 	  if (pkg->state_flag & SF_FILELIST_CHANGED) {
-               ipkg_message(conf, IPKG_DEBUG, "Calling pkg_write_filelist for pkg=%s from %s\n", pkg->name, __FUNCTION__);
+               opkg_message(conf, OPKG_DEBUG, "Calling pkg_write_filelist for pkg=%s from %s\n", pkg->name, __FUNCTION__);
 	       err = pkg_write_filelist(conf, pkg);
 	       if (err)
-		    ipkg_message(conf, IPKG_NOTICE, "pkg_write_filelist pkg=%s returned %d\n", pkg->name, err);
+		    opkg_message(conf, OPKG_NOTICE, "pkg_write_filelist pkg=%s returned %d\n", pkg->name, err);
 	  }
      }
      return 0;

Modified: trunk/src/target/ipkg/pkg.h
===================================================================
--- trunk/src/target/ipkg/pkg.h	2008-01-18 11:05:46 UTC (rev 3878)
+++ trunk/src/target/ipkg/pkg.h	2008-01-18 11:28:48 UTC (rev 3879)
@@ -26,10 +26,10 @@
 #include "str_list.h"
 #include "pkg_src.h"
 #include "pkg_dest.h"
-#include "ipkg_conf.h"
+#include "opkg_conf.h"
 #include "conffile_list.h"
 
-struct ipkg_conf;
+struct opkg_conf;
 
 
 #define ARRAY_SIZE(array) sizeof(array) / sizeof((array)[0])
@@ -174,7 +174,7 @@
      int installed_files_ref_cnt;
      int essential;
      int arch_priority;
-/* Adding this flag, to "force" ipkg to choose a "provided_by_hand" package, if there are multiple choice */
+/* Adding this flag, to "force" opkg to choose a "provided_by_hand" package, if there are multiple choice */
      int provided_by_hand;
 };
 
@@ -200,16 +200,16 @@
 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 set_flags_from_control(opkg_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);
+int pkg_remove_installed_files_list(opkg_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,
+int pkg_run_script(struct opkg_conf *conf, pkg_t *pkg,
 		   const char *script, const char *args);
 
 /* enum mappings */
@@ -222,11 +222,11 @@
 
 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_arch_supported(opkg_conf_t *conf, pkg_t *pkg);
+int pkg_info_preinstall_check(opkg_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);
+int pkg_write_filelist(opkg_conf_t *conf, pkg_t *pkg);
+int pkg_write_changed_filelists(opkg_conf_t *conf);
 
 #endif

Modified: trunk/src/target/ipkg/pkg_depends.c
===================================================================
--- trunk/src/target/ipkg/pkg_depends.c	2008-01-18 11:05:46 UTC (rev 3878)
+++ trunk/src/target/ipkg/pkg_depends.c	2008-01-18 11:28:48 UTC (rev 3879)
@@ -15,14 +15,14 @@
    General Public License for more details.
 */
 
-#include "ipkg.h"
+#include "opkg.h"
 #include <errno.h>
 #include <ctype.h>
    
 #include "pkg.h"
-#include "ipkg_utils.h"
+#include "opkg_utils.h"
 #include "pkg_hash.h"
-#include "ipkg_message.h"
+#include "opkg_message.h"
 #include "pkg_parse.h"
 #include "hash_table.h"
 
@@ -64,7 +64,7 @@
 }
 
 /* returns ndependences or negative error value */ 
-int pkg_hash_fetch_unsatisfied_dependencies(ipkg_conf_t *conf, pkg_t * pkg, 
+int pkg_hash_fetch_unsatisfied_dependencies(opkg_conf_t *conf, pkg_t * pkg, 
 					    pkg_vec_t *unsatisfied, char *** unresolved)
 {
      pkg_t * satisfier_entry_pkg;
@@ -143,18 +143,18 @@
 					    pkg_t *p = tmp_vec->pkgs[i];
 					    if (p->state_want == SW_INSTALL)
 						continue;
-					    ipkg_message(conf, IPKG_DEBUG, "not installing %s due to requirement for %s\n", pkg_scout->name, p->name);
+					    opkg_message(conf, OPKG_DEBUG, "not installing %s due to requirement for %s\n", pkg_scout->name, p->name);
 					    ok = 0;
 					    break;
 					}
 					pkg_vec_free (tmp_vec);
 					if (ok) {
 					    /* mark this one for installation */
-					    ipkg_message(conf, IPKG_NOTICE, "Adding satisfier for greedy dependence: %s\n", pkg_scout->name);
+					    opkg_message(conf, OPKG_NOTICE, "Adding satisfier for greedy dependence: %s\n", pkg_scout->name);
 					    pkg_vec_insert(unsatisfied, pkg_scout);
 					}
 				   } else  {
-					ipkg_message(conf, IPKG_DEBUG, "not installing %s due to broken depends \n", pkg_scout->name);
+					opkg_message(conf, OPKG_DEBUG, "not installing %s due to broken depends \n", pkg_scout->name);
 					free (newstuff);
 				   }
 			      }
@@ -180,7 +180,7 @@
 	              satisfying_pkg = NULL;
                   }
                }
-	       ipkg_message(conf, IPKG_DEBUG, "%s:%d: satisfying_pkg=%p \n", __FILE__, __LINE__, satisfying_pkg);
+	       opkg_message(conf, OPKG_DEBUG, "%s:%d: satisfying_pkg=%p \n", __FILE__, __LINE__, satisfying_pkg);
 	       if (satisfying_pkg != NULL) {
 		    found = 1;
 		    break;
@@ -209,12 +209,12 @@
 		    if (satisfying_pkg != NULL
 			&& (compound_depend->type == RECOMMEND || compound_depend->type == SUGGEST)
 			&& (satisfying_pkg->state_want == SW_DEINSTALL || satisfying_pkg->state_want == SW_PURGE)) {
-			 ipkg_message (conf, IPKG_NOTICE, "%s: ignoring recommendation for %s at user request\n",
+			 opkg_message (conf, OPKG_NOTICE, "%s: ignoring recommendation for %s at user request\n",
 				       pkg->name, satisfying_pkg->name);
 			 continue;
 		    }
 
-		    ipkg_message(conf, IPKG_DEBUG, "%s:%d: satisfying_pkg=%p\n", __FILE__, __LINE__, satisfying_pkg);
+		    opkg_message(conf, OPKG_DEBUG, "%s:%d: satisfying_pkg=%p\n", __FILE__, __LINE__, satisfying_pkg);
 		    if (satisfying_pkg != NULL) {
 			 satisfier_entry_pkg = satisfying_pkg;
 			 break;
@@ -229,13 +229,13 @@
 		    if (compound_depend->type != RECOMMEND && compound_depend->type != SUGGEST)
 			 the_lost = add_unresolved_dep(pkg, the_lost, i);
 		    else
-			 ipkg_message (conf, IPKG_NOTICE, "%s: unsatisfied recommendation for %s\n",
+			 opkg_message (conf, OPKG_NOTICE, "%s: unsatisfied recommendation for %s\n",
 				       pkg->name, compound_depend->possibilities[0]->pkg->name);
 	       }
 	       else {
 		    if (compound_depend->type == SUGGEST) {
 			 /* just mention it politely */
-			 ipkg_message (conf, IPKG_NOTICE, "package %s suggests installing %s\n",
+			 opkg_message (conf, OPKG_NOTICE, "package %s suggests installing %s\n",
 				       pkg->name, satisfier_entry_pkg->name);
 		    } else {
 			 char ** newstuff = NULL;
@@ -276,7 +276,7 @@
 
     for (i = 0; i < replaces_count; i++) {
         if (strcmp(pkg_scout->name,pkg->replaces[i]->name)==0) {      // Found
-            ipkg_message(NULL, IPKG_DEBUG2, "Seems I've found a replace %s %s \n",pkg_scout->name,pkg->replaces[i]->name);
+            opkg_message(NULL, OPKG_DEBUG2, "Seems I've found a replace %s %s \n",pkg_scout->name,pkg->replaces[i]->name);
             return 1;
         }
     }
@@ -392,7 +392,7 @@
     return 0;
 }
 
-int pkg_dependence_satisfiable(ipkg_conf_t *conf, depend_t *depend)
+int pkg_dependence_satisfiable(opkg_conf_t *conf, depend_t *depend)
 {
      abstract_pkg_t *apkg = depend->pkg;
      abstract_pkg_vec_t *provider_apkgs = apkg->provided_by;
@@ -419,7 +419,7 @@
      return 0;
 }
 
-int pkg_dependence_satisfied(ipkg_conf_t *conf, depend_t *depend)
+int pkg_dependence_satisfied(opkg_conf_t *conf, depend_t *depend)
 {
      abstract_pkg_t *apkg = depend->pkg;
      abstract_pkg_vec_t *provider_apkgs = apkg->provided_by;
@@ -514,7 +514,7 @@
      for (i = 0; i < replaces_count; i++) {
 	  abstract_pkg_t *abstract_replacee = replaces[i];
 	  for (j = 0; j < replaces_count; j++) {
-   /*            ipkg_message(NULL, IPKG_DEBUG2, "Searching pkg-name %s repprovname %s absrepname %s \n",
+   /*            opkg_message(NULL, OPKG_DEBUG2, "Searching pkg-name %s repprovname %s absrepname %s \n",
                  pkg->name,replacee->provides[j]->name, abstract_replacee->name); */
 	       if (replacee->provides[j] == abstract_replacee)
 		    return 1;

Modified: trunk/src/target/ipkg/pkg_depends.h
===================================================================
--- trunk/src/target/ipkg/pkg_depends.h	2008-01-18 11:05:46 UTC (rev 3878)
+++ trunk/src/target/ipkg/pkg_depends.h	2008-01-18 11:28:48 UTC (rev 3879)
@@ -97,9 +97,9 @@
 void freeDepends(pkg_t *pkg);
 void printDepends(pkg_t * pkg);
 int version_constraints_satisfied(depend_t * depends, pkg_t * pkg);
-int pkg_hash_fetch_unsatisfied_dependencies(ipkg_conf_t *conf, pkg_t * pkg, pkg_vec_t *depends, char *** unresolved);
+int pkg_hash_fetch_unsatisfied_dependencies(opkg_conf_t *conf, pkg_t * pkg, pkg_vec_t *depends, char *** unresolved);
 pkg_vec_t * pkg_hash_fetch_conflicts(hash_table_t * hash, pkg_t * pkg);
-int pkg_dependence_satisfiable(ipkg_conf_t *conf, depend_t *depend);
-int pkg_dependence_satisfied(ipkg_conf_t *conf, depend_t *depend);
+int pkg_dependence_satisfiable(opkg_conf_t *conf, depend_t *depend);
+int pkg_dependence_satisfied(opkg_conf_t *conf, depend_t *depend);
 
 #endif

Modified: trunk/src/target/ipkg/pkg_dest.c
===================================================================
--- trunk/src/target/ipkg/pkg_dest.c	2008-01-18 11:05:46 UTC (rev 3878)
+++ trunk/src/target/ipkg/pkg_dest.c	2008-01-18 11:28:48 UTC (rev 3879)
@@ -15,7 +15,7 @@
    General Public License for more details.
 */
 
-#include "ipkg.h"
+#include "opkg.h"
 
 #include "pkg_dest.h"
 #include "file_util.h"
@@ -34,9 +34,9 @@
     }
     file_mkdir_hier(dest->root_dir, 0755);
 
-    sprintf_alloc(&dest->ipkg_dir, "%s%s",
-		  dest->root_dir, IPKG_STATE_DIR_PREFIX);
-    file_mkdir_hier(dest->ipkg_dir, 0755);
+    sprintf_alloc(&dest->opkg_dir, "%s%s",
+		  dest->root_dir, OPKG_STATE_DIR_PREFIX);
+    file_mkdir_hier(dest->opkg_dir, 0755);
 
     if (str_starts_with (lists_dir, "/")) 
         sprintf_alloc(&dest->lists_dir, "%s", lists_dir);
@@ -46,14 +46,14 @@
     file_mkdir_hier(dest->lists_dir, 0755);
 
     sprintf_alloc(&dest->info_dir, "%s/%s",
-		  dest->ipkg_dir, IPKG_INFO_DIR_SUFFIX);
+		  dest->opkg_dir, OPKG_INFO_DIR_SUFFIX);
     file_mkdir_hier(dest->info_dir, 0755);
 
     sprintf_alloc(&dest->status_file_name, "%s/%s",
-		  dest->ipkg_dir, IPKG_STATUS_FILE_SUFFIX);
+		  dest->opkg_dir, OPKG_STATUS_FILE_SUFFIX);
 
     sprintf_alloc(&dest->status_file_tmp_name, "%s/%s.tmp",
-		  dest->ipkg_dir, IPKG_STATUS_FILE_SUFFIX);
+		  dest->opkg_dir, OPKG_STATUS_FILE_SUFFIX);
 
     dest->status_file = NULL;
 
@@ -68,8 +68,8 @@
     free(dest->root_dir);
     dest->root_dir = NULL;
 
-    free(dest->ipkg_dir);
-    dest->ipkg_dir = NULL;
+    free(dest->opkg_dir);
+    dest->opkg_dir = NULL;
 
     free(dest->lists_dir);
     dest->lists_dir = NULL;

Modified: trunk/src/target/ipkg/pkg_dest.h
===================================================================
--- trunk/src/target/ipkg/pkg_dest.h	2008-01-18 11:05:46 UTC (rev 3878)
+++ trunk/src/target/ipkg/pkg_dest.h	2008-01-18 11:28:48 UTC (rev 3879)
@@ -23,7 +23,7 @@
 {
     char *name;
     char *root_dir;
-    char *ipkg_dir;
+    char *opkg_dir;
     char *lists_dir;
     char *info_dir;
     char *status_file_name;

Modified: trunk/src/target/ipkg/pkg_dest_list.c
===================================================================
--- trunk/src/target/ipkg/pkg_dest_list.c	2008-01-18 11:05:46 UTC (rev 3878)
+++ trunk/src/target/ipkg/pkg_dest_list.c	2008-01-18 11:28:48 UTC (rev 3879)
@@ -15,7 +15,7 @@
    General Public License for more details.
 */
 
-#include "ipkg.h"
+#include "opkg.h"
 
 #include "pkg_dest.h"
 #include "void_list.h"

Modified: trunk/src/target/ipkg/pkg_extract.c
===================================================================
--- trunk/src/target/ipkg/pkg_extract.c	2008-01-18 11:05:46 UTC (rev 3878)
+++ trunk/src/target/ipkg/pkg_extract.c	2008-01-18 11:28:48 UTC (rev 3879)
@@ -15,7 +15,7 @@
    General Public License for more details.
 */
 
-#include "ipkg.h"
+#include "opkg.h"
 #include <errno.h>
 
 #include "pkg_extract.h"
@@ -25,7 +25,7 @@
 #include "sprintf_alloc.h"
 
 /* assuage libb functions */
-const char *applet_name = "ipkg";
+const char *applet_name = "opkg";
 
 int pkg_extract_control_file_to_stream(pkg_t *pkg, FILE *stream)
 {
@@ -148,10 +148,10 @@
 {
     /* XXX: DPKG_INCOMPATIBILITY: deb_extract will extract all of the
        data file names with a '.' as the first character. I've taught
-       ipkg how to cope with the presence or absence of the '.', but
+       opkg how to cope with the presence or absence of the '.', but
        this may trip up dpkg.
 
-       For all I know, this could actually be a bug in ipkg-build. So,
+       For all I know, this could actually be a bug in opkg-build. So,
        I'll have to try installing some .debs and comparing the *.list
        files.
 

Modified: trunk/src/target/ipkg/pkg_hash.c
===================================================================
--- trunk/src/target/ipkg/pkg_hash.c	2008-01-18 11:05:46 UTC (rev 3878)
+++ trunk/src/target/ipkg/pkg_hash.c	2008-01-18 11:28:48 UTC (rev 3879)
@@ -1,4 +1,4 @@
-/* ipkg_hash.c - the itsy package management system
+/* opkg_hash.c - the itsy package management system
 
    Steven M. Ayer
    
@@ -15,7 +15,7 @@
    General Public License for more details.
 */
 
-#include "ipkg.h"
+#include "opkg.h"
 #include <errno.h>
 #include <ctype.h>
 #include <stdlib.h>
@@ -23,11 +23,11 @@
 
 #include "hash_table.h"
 #include "pkg.h"
-#include "ipkg_message.h"
+#include "opkg_message.h"
 #include "pkg_vec.h"
 #include "pkg_hash.h"
 #include "pkg_parse.h"
-#include "ipkg_utils.h"
+#include "opkg_utils.h"
 
 static abstract_pkg_t * add_new_abstract_pkg_by_name(hash_table_t * hash, const char * pkg_name);
 
@@ -60,7 +60,7 @@
 
 
 /* Find the default arch for a given package status file if none is given. */
-static char *pkg_get_default_arch(ipkg_conf_t *conf)
+static char *pkg_get_default_arch(opkg_conf_t *conf)
 {
      nv_pair_list_elt_t *l;
      char *def_arch = HOST_CPU_STR;		/* Default arch */
@@ -85,7 +85,7 @@
      return strdup(def_arch);
 }
 
-int pkg_hash_add_from_file(ipkg_conf_t *conf, const char *file_name,
+int pkg_hash_add_from_file(opkg_conf_t *conf, const char *file_name,
 			   pkg_src_t *src, pkg_dest_t *dest, int is_status_file)
 {
      hash_table_t *hash = &conf->pkg_hash;
@@ -106,7 +106,7 @@
 	       if (!pkg->architecture) {
 		    char *version_str = pkg_version_str_alloc(pkg);
 		    pkg->architecture = pkg_get_default_arch(conf);
-		    ipkg_message(conf, IPKG_ERROR, "Package %s version %s has no architecture specified, defaulting to %s.\n",
+		    opkg_message(conf, OPKG_ERROR, "Package %s version %s has no architecture specified, defaulting to %s.\n",
 				 pkg->name, version_str, pkg->architecture);
 		    free(version_str);
 	       }
@@ -140,7 +140,7 @@
 }
 
 
-pkg_t *pkg_hash_fetch_best_installation_candidate(ipkg_conf_t *conf, abstract_pkg_t *apkg, 
+pkg_t *pkg_hash_fetch_best_installation_candidate(opkg_conf_t *conf, abstract_pkg_t *apkg, 
 						  int (*constraint_fcn)(pkg_t *pkg, void *cdata), void *cdata, int quiet)
 {
      int i; 
@@ -160,18 +160,18 @@
          apkg == NULL || apkg->provided_by == NULL || (apkg->provided_by->len == 0))
 	  return NULL;
 
-     ipkg_message(conf, IPKG_DEBUG, "best installation candidate for %s\n", apkg->name);
+     opkg_message(conf, OPKG_DEBUG, "best installation candidate for %s\n", apkg->name);
 
      provided_apkg_vec = apkg->provided_by;
      nprovides = provided_apkg_vec->len;
      provided_apkgs = provided_apkg_vec->pkgs;
      if (nprovides > 1)
-	  ipkg_message(conf, IPKG_DEBUG, " apkg=%s nprovides=%d\n", apkg->name, nprovides);
+	  opkg_message(conf, OPKG_DEBUG, " apkg=%s nprovides=%d\n", apkg->name, nprovides);
 
      /* accumulate all the providers */
      for (i = 0; i < nprovides; i++) {
 	  abstract_pkg_t *provider_apkg = provided_apkgs[i];
-	  ipkg_message(conf, IPKG_DEBUG, " adding %s to providers\n", provider_apkg->name);
+	  opkg_message(conf, OPKG_DEBUG, " adding %s to providers\n", provider_apkg->name);
 	  abstract_pkg_vec_insert(providers, provider_apkg);
      }
      nprovides = providers->len;
@@ -184,13 +184,13 @@
 	  if (provider_apkg->replaced_by && provider_apkg->replaced_by->len) {
 	       replacement_apkg = provider_apkg->replaced_by->pkgs[0];
 	       if (provider_apkg->replaced_by->len > 1) {
-		    ipkg_message(conf, IPKG_NOTICE, "Multiple replacers for %s, using first one (%s)\n", 
+		    opkg_message(conf, OPKG_NOTICE, "Multiple replacers for %s, using first one (%s)\n", 
 				 provider_apkg->name, replacement_apkg->name);
 	       }
 	  }
 
 	  if (replacement_apkg)
-	       ipkg_message(conf, IPKG_DEBUG, "   replacement_apkg=%s for provider_apkg=%s\n", 
+	       opkg_message(conf, OPKG_DEBUG, "   replacement_apkg=%s for provider_apkg=%s\n", 
 			    replacement_apkg->name, provider_apkg->name);
 
 	  if (replacement_apkg && (replacement_apkg != provider_apkg)) {
@@ -201,7 +201,7 @@
 	  }
 
 	  if (!(vec = provider_apkg->pkgs)) {
-	       ipkg_message(conf, IPKG_DEBUG, "   no pkgs for provider_apkg %s\n", provider_apkg->name);
+	       opkg_message(conf, OPKG_DEBUG, "   no pkgs for provider_apkg %s\n", provider_apkg->name);
 	       continue;
 	  }
     
@@ -214,7 +214,7 @@
 	       /* count packages matching max arch priority and keep track of last one */
 	       for (i = 0; i < vec->len; i++) {
 		    pkg_t *maybe = vec->pkgs[i];
-		    ipkg_message(conf, IPKG_DEBUG, "  %s arch=%s arch_priority=%d version=%s  \n",
+		    opkg_message(conf, OPKG_DEBUG, "  %s arch=%s arch_priority=%d version=%s  \n",
 				 maybe->name, maybe->architecture, maybe->arch_priority, maybe->version);
 		    if (maybe->arch_priority > 0)  {
 			 max_count++;
@@ -243,7 +243,7 @@
      for (i = 0; i < matching_pkgs->len; i++) {
 	  pkg_t *matching = matching_pkgs->pkgs[i];
           if (constraint_fcn(matching, cdata)) {  /* We found it */
-             ipkg_message(conf, IPKG_DEBUG, " Found a valid candidate for the install: %s %s  \n", matching->name, matching->version) ;
+             opkg_message(conf, OPKG_DEBUG, " Found a valid candidate for the install: %s %s  \n", matching->name, matching->version) ;
              good_pkg_by_name = matching;
              if ( matching->provided_by_hand == 1 )    /* It has been provided by hand, so it is what user want */
                 break;                                 
@@ -258,28 +258,28 @@
 	       latest_installed_parent = matching;
 	  if (matching->state_flag & (SF_HOLD|SF_PREFER)) {
 	       if (held_pkg)
-		    ipkg_message(conf, IPKG_ERROR, "Multiple packages (%s and %s) providing same name marked HOLD or PREFER.  Using latest.\n",
+		    opkg_message(conf, OPKG_ERROR, "Multiple packages (%s and %s) providing same name marked HOLD or PREFER.  Using latest.\n",
 				 held_pkg->name, matching->name);
 	       held_pkg = matching;
 	  }
      }
 
      if (!good_pkg_by_name && !held_pkg && !latest_installed_parent && matching_apkgs->len > 1 && !quiet) {
-	  ipkg_message(conf, IPKG_ERROR, "Package=%s, %d matching providers\n",
+	  opkg_message(conf, OPKG_ERROR, "Package=%s, %d matching providers\n",
 		       apkg->name, matching_apkgs->len);
 	  for (i = 0; i < matching_apkgs->len; i++) {
               abstract_pkg_t *matching = matching_apkgs->pkgs[i];
-              ipkg_message(conf, IPKG_ERROR, "    %s\n", matching->name);
+              opkg_message(conf, OPKG_ERROR, "    %s\n", matching->name);
 	  }
-	  ipkg_message(conf, IPKG_ERROR, "Please select one with ipkg install or ipkg flag prefer\n");
+	  opkg_message(conf, OPKG_ERROR, "Please select one with opkg install or opkg flag prefer\n");
      }
 
      if (matching_apkgs->len > 1 && conf->verbosity > 1) {
-	  ipkg_message(conf, IPKG_NOTICE, "%s: for apkg=%s, %d matching pkgs\n",
+	  opkg_message(conf, OPKG_NOTICE, "%s: for apkg=%s, %d matching pkgs\n",
 		       __FUNCTION__, apkg->name, matching_pkgs->len);
 	  for (i = 0; i < matching_pkgs->len; i++) {
 	       pkg_t *matching = matching_pkgs->pkgs[i];
-	       ipkg_message(conf, IPKG_INFO, "    %s %s %s\n",
+	       opkg_message(conf, OPKG_INFO, "    %s %s %s\n",
 			    matching->name, matching->version, matching->architecture);
 	  }
      }
@@ -294,19 +294,19 @@
 	  return good_pkg_by_name;
      }
      if (held_pkg) {
-	  ipkg_message(conf, IPKG_INFO, "  using held package %s\n", held_pkg->name);
+	  opkg_message(conf, OPKG_INFO, "  using held package %s\n", held_pkg->name);
 	  return held_pkg;
      }
      if (latest_installed_parent) {
-	  ipkg_message(conf, IPKG_INFO, "  using latest version of installed package %s\n", latest_installed_parent->name);
+	  opkg_message(conf, OPKG_INFO, "  using latest version of installed package %s\n", latest_installed_parent->name);
 	  return latest_installed_parent;
      }
      if (nmatching > 1) {
-	  ipkg_message(conf, IPKG_INFO, "  no matching pkg out of matching_apkgs=%d\n", nmatching);
+	  opkg_message(conf, OPKG_INFO, "  no matching pkg out of matching_apkgs=%d\n", nmatching);
 	  return NULL;
      }
      if (latest_matching) {
-	  ipkg_message(conf, IPKG_INFO, "  using latest matching %s %s %s\n",
+	  opkg_message(conf, OPKG_INFO, "  using latest matching %s %s %s\n",
 		       latest_matching->name, latest_matching->version, latest_matching->architecture);
 	  return latest_matching;
      }
@@ -322,7 +322,7 @@
 	  return 0;   
 }
 
-pkg_t *pkg_hash_fetch_best_installation_candidate_by_name(ipkg_conf_t *conf, const char *name)
+pkg_t *pkg_hash_fetch_best_installation_candidate_by_name(opkg_conf_t *conf, const char *name)
 {
      hash_table_t *hash = &conf->pkg_hash;
      abstract_pkg_t *apkg = NULL;
@@ -476,7 +476,7 @@
   int i;
   pkg_t *pkg;
   abstract_pkg_t *ab_pkg = (abstract_pkg_t *)entry;
-  ipkg_conf_t *conf = (ipkg_conf_t *)data;
+  opkg_conf_t *conf = (opkg_conf_t *)data;
   abstract_pkg_t ** dependents = ab_pkg->depended_upon_by;
   fprintf(stdout, "%s\n", ab_pkg->name);
   i = 0;
@@ -513,7 +513,7 @@
   return ab_pkg;
 }
 
-pkg_t *hash_insert_pkg(hash_table_t *hash, pkg_t *pkg, int set_status,ipkg_conf_t *conf)
+pkg_t *hash_insert_pkg(hash_table_t *hash, pkg_t *pkg, int set_status,opkg_conf_t *conf)
 {
      abstract_pkg_t * ab_pkg;
      int arch_priority;
@@ -580,14 +580,14 @@
 }
 
 
-pkg_t *file_hash_get_file_owner(ipkg_conf_t *conf, const char *file_name)
+pkg_t *file_hash_get_file_owner(opkg_conf_t *conf, const char *file_name)
 {
      hash_table_t *file_hash = &conf->file_hash;
 
      return hash_table_get(file_hash, file_name); 
 }
 
-int file_hash_set_file_owner(ipkg_conf_t *conf, const char *file_name, pkg_t *owning_pkg)
+int file_hash_set_file_owner(opkg_conf_t *conf, const char *file_name, pkg_t *owning_pkg)
 {
      hash_table_t *file_hash = &conf->file_hash;
      pkg_t *old_owning_pkg = hash_table_get(file_hash, file_name);
@@ -603,7 +603,7 @@
 	  }
      }
 
-     // ipkg_message(conf, IPKG_DEBUG2, "owning_pkg=%s filename=%s\n", owning_pkg->name, file_name);
+     // opkg_message(conf, OPKG_DEBUG2, "owning_pkg=%s filename=%s\n", owning_pkg->name, file_name);
      hash_table_insert(file_hash, file_name, owning_pkg); 
      if (old_owning_pkg) {
 	  str_list_remove_elt(old_owning_pkg->installed_files, file_name);

Modified: trunk/src/target/ipkg/pkg_hash.h
===================================================================
--- trunk/src/target/ipkg/pkg_hash.h	2008-01-18 11:05:46 UTC (rev 3878)
+++ trunk/src/target/ipkg/pkg_hash.h	2008-01-18 11:28:48 UTC (rev 3879)
@@ -30,9 +30,9 @@
 void pkg_hash_dump(hash_table_t *hash, void *data);
 void pkg_hash_fetch_available(hash_table_t *hash, pkg_vec_t *available);
 
-int pkg_hash_add_from_file(ipkg_conf_t *conf, const char *file_name,
+int pkg_hash_add_from_file(opkg_conf_t *conf, const char *file_name,
 			   pkg_src_t *src, pkg_dest_t *dest, int is_status_file);
-pkg_t *hash_insert_pkg(hash_table_t *hash, pkg_t *pkg, int set_status,ipkg_conf_t *conf);
+pkg_t *hash_insert_pkg(hash_table_t *hash, pkg_t *pkg, int set_status,opkg_conf_t *conf);
 
 abstract_pkg_t * ensure_abstract_pkg_by_name(hash_table_t * hash, const char * pkg_name);
 abstract_pkg_t * abstract_pkg_fetch_by_name(hash_table_t * hash, const char * pkg_name);
@@ -42,17 +42,17 @@
 				       const char *pkg_name,
 				       const char * version);
 abstract_pkg_vec_t *pkg_hash_fetch_all_installation_candidates(hash_table_t *hash, const char *name);
-pkg_t *pkg_hash_fetch_best_installation_candidate(ipkg_conf_t *conf, abstract_pkg_t *apkg, 
+pkg_t *pkg_hash_fetch_best_installation_candidate(opkg_conf_t *conf, abstract_pkg_t *apkg, 
 						  int (*constraint_fcn)(pkg_t *pkg, void *data), void *cdata, int quiet);
-pkg_t *pkg_hash_fetch_best_installation_candidate_by_name(ipkg_conf_t *conf, const char *name);
+pkg_t *pkg_hash_fetch_best_installation_candidate_by_name(opkg_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);
 
-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);
+pkg_t *file_hash_get_file_owner(opkg_conf_t *conf, const char *file_name);
+int file_hash_set_file_owner(opkg_conf_t *conf, const char *file_name, pkg_t *pkg);
 
 /* XXX: shouldn't this go in pkg_vec.[ch]? */
 pkg_vec_t *pkg_vec_fetch_by_name(hash_table_t *hash, const char *pkg_name);

Modified: trunk/src/target/ipkg/pkg_parse.c
===================================================================
--- trunk/src/target/ipkg/pkg_parse.c	2008-01-18 11:05:46 UTC (rev 3878)
+++ trunk/src/target/ipkg/pkg_parse.c	2008-01-18 11:28:48 UTC (rev 3879)
@@ -15,12 +15,12 @@
    General Public License for more details.
 */
 
-#include "ipkg.h"
+#include "opkg.h"
 #include <errno.h>
 #include <ctype.h>
    
 #include "pkg.h"
-#include "ipkg_utils.h"
+#include "opkg_utils.h"
 #include "pkg_parse.h"
 
 int isGenericFieldType(char * type, char * line)
@@ -202,7 +202,7 @@
       raw++;
   }      
   
-  snprintf ( temp, 35, "Provides: ipkg_internal_use_only, ");           /* First part of the line */
+  snprintf ( temp, 35, "Provides: opkg_internal_use_only, ");           /* First part of the line */
   while (*raw) {
      strncat( temp, raw++, 1);
   }
@@ -251,7 +251,7 @@
 	    pkg->section = parseGenericFieldType("Section", *lines);
 	else if(isGenericFieldType("MD5sum:", *lines))
 	    pkg->md5sum = parseGenericFieldType("MD5sum", *lines);
-	/* The old ipkg wrote out status files with the wrong case for MD5sum,
+	/* The old opkg wrote out status files with the wrong case for MD5sum,
 	   let's parse it either way */
 	else if(isGenericFieldType("MD5Sum:", *lines))
 	    pkg->md5sum = parseGenericFieldType("MD5Sum", *lines);
@@ -292,7 +292,7 @@
 
 	else if(isGenericFieldType("Provides", *lines)){
 /* Here we add the internal_use to align the off by one problem between provides_str and provides */
-            provide = (char * ) malloc(strlen(*lines)+ 35 ); /* Preparing the space for the new ipkg_internal_use_only */
+            provide = (char * ) malloc(strlen(*lines)+ 35 ); /* Preparing the space for the new opkg_internal_use_only */
             if ( alterProvidesLine(*lines,provide) ){
                return EINVAL;
             }
@@ -337,7 +337,7 @@
     *raw = lines;
 /* If the ipk has not a Provides line, we insert our false line */ 
     if ( pkg_false_provides==1)
-       pkg->provides_str = parseDependsString ((char *)"Provides: ipkg_internal_use_only ", &pkg->provides_count);
+       pkg->provides_str = parseDependsString ((char *)"Provides: opkg_internal_use_only ", &pkg->provides_count);
 
     if (pkg->name) {
 	return 0;

Modified: trunk/src/target/ipkg/pkg_src.c
===================================================================
--- trunk/src/target/ipkg/pkg_src.c	2008-01-18 11:05:46 UTC (rev 3878)
+++ trunk/src/target/ipkg/pkg_src.c	2008-01-18 11:28:48 UTC (rev 3879)
@@ -15,7 +15,7 @@
    General Public License for more details.
 */
 
-#include "ipkg.h"
+#include "opkg.h"
 
 #include "pkg_src.h"
 #include "str_util.h"

Modified: trunk/src/target/ipkg/pkg_src_list.c
===================================================================
--- trunk/src/target/ipkg/pkg_src_list.c	2008-01-18 11:05:46 UTC (rev 3878)
+++ trunk/src/target/ipkg/pkg_src_list.c	2008-01-18 11:28:48 UTC (rev 3879)
@@ -15,7 +15,7 @@
    General Public License for more details.
 */
 
-#include "ipkg.h"
+#include "opkg.h"
 
 #include "pkg_src_list.h"
 #include "void_list.h"

Modified: trunk/src/target/ipkg/pkg_vec.c
===================================================================
--- trunk/src/target/ipkg/pkg_vec.c	2008-01-18 11:05:46 UTC (rev 3878)
+++ trunk/src/target/ipkg/pkg_vec.c	2008-01-18 11:28:48 UTC (rev 3879)
@@ -18,7 +18,7 @@
 #include <stdlib.h>
 #include <fnmatch.h>
 #include "xregex.h"
-#include "ipkg.h"
+#include "opkg.h"
 #include "pkg.h"
 
 pkg_vec_t * pkg_vec_alloc(void)
@@ -46,21 +46,21 @@
  *             so identical versions have identical version strings,
  *             implying identical packages; let's marry these
  */
-pkg_t *pkg_vec_insert_merge(pkg_vec_t *vec, pkg_t *pkg, int set_status,ipkg_conf_t *conf)
+pkg_t *pkg_vec_insert_merge(pkg_vec_t *vec, pkg_t *pkg, int set_status,opkg_conf_t *conf)
 {
      int i;
      int found = 0;
 
      /* look for a duplicate pkg by name, version, and architecture */
      for (i = 0; i < vec->len; i++){
-         ipkg_message(conf, IPKG_DEBUG2, "Function: %s. Found pkg=%s version=%s arch=%s cmp=%s version=%s arch=%s \n", 
+         opkg_message(conf, OPKG_DEBUG2, "Function: %s. Found pkg=%s version=%s arch=%s cmp=%s version=%s arch=%s \n", 
                       __FUNCTION__, pkg->name, pkg->version, pkg->architecture, 
                        vec->pkgs[i]->name, vec->pkgs[i]->version,vec->pkgs[i]->architecture );
 	  if ((strcmp(pkg->name, vec->pkgs[i]->name) == 0)
 	      && (pkg_compare_versions(pkg, vec->pkgs[i]) == 0)
 	      && (strcmp(pkg->architecture, vec->pkgs[i]->architecture) == 0)) {
 	       found  = 1;
-               ipkg_message(conf, IPKG_DEBUG2, "Function: %s. Found duplicate for pkg=%s version=%s arch=%s\n",
+               opkg_message(conf, OPKG_DEBUG2, "Function: %s. Found duplicate for pkg=%s version=%s arch=%s\n",
                              __FUNCTION__, pkg->name, pkg->version, pkg->architecture);
 	       break;
 	  }
@@ -68,7 +68,7 @@
 
      /* we didn't find one, add it */
      if (!found){   
-         ipkg_message(conf, IPKG_DEBUG2, "Function: %s. Adding new pkg=%s version=%s arch=%s\n",
+         opkg_message(conf, OPKG_DEBUG2, "Function: %s. Adding new pkg=%s version=%s arch=%s\n",
                       __FUNCTION__, pkg->name, pkg->version, pkg->architecture);
 
 	  vec->pkgs = (pkg_t **)realloc(vec->pkgs, (vec->len + 1) * sizeof(pkg_t *));
@@ -78,18 +78,18 @@
      }
      /* update the one that we have */
      else {
-          ipkg_message(conf, IPKG_DEBUG2, "Function: %s. calling pkg_merge for pkg=%s version=%s arch=%s",
+          opkg_message(conf, OPKG_DEBUG2, "Function: %s. calling pkg_merge for pkg=%s version=%s arch=%s",
                         __FUNCTION__, pkg->name, pkg->version, pkg->architecture);
 	  if (set_status) {
 	       /* this is from the status file, so need to merge with existing database */
-               ipkg_message(conf, IPKG_DEBUG2, " with set_status\n");
+               opkg_message(conf, OPKG_DEBUG2, " with set_status\n");
 	       pkg_merge(vec->pkgs[i], pkg, set_status);
 	       /* XXX: CLEANUP: It's not so polite to free something here
 		  that was passed in from above. */
 	       pkg_deinit(pkg);
 	       free(pkg);
 	  } else {
-               ipkg_message(conf, IPKG_DEBUG2, " WITHOUT set_status\n");
+               opkg_message(conf, OPKG_DEBUG2, " WITHOUT set_status\n");
 	       /* just overwrite the old one */
 	       pkg_deinit(vec->pkgs[i]);
 	       free(vec->pkgs[i]);

Modified: trunk/src/target/ipkg/pkg_vec.h
===================================================================
--- trunk/src/target/ipkg/pkg_vec.h	2008-01-18 11:05:46 UTC (rev 3878)
+++ trunk/src/target/ipkg/pkg_vec.h	2008-01-18 11:28:48 UTC (rev 3879)
@@ -43,7 +43,7 @@
 void pkg_vec_add(pkg_vec_t *vec, pkg_t *pkg);
 /* pkg_vec_insert_merge: might munge pkg.
 *  returns the pkg that is in the pkg graph */
-pkg_t *pkg_vec_insert_merge(pkg_vec_t *vec, pkg_t *pkg, int set_status, ipkg_conf_t *conf);
+pkg_t *pkg_vec_insert_merge(pkg_vec_t *vec, pkg_t *pkg, int set_status, opkg_conf_t *conf);
 /* this one never munges pkg */
 void pkg_vec_insert(pkg_vec_t *vec, const pkg_t *pkg);
 int pkg_vec_contains(pkg_vec_t *vec, pkg_t *apkg);

Modified: trunk/src/target/ipkg/sprintf_alloc.c
===================================================================
--- trunk/src/target/ipkg/sprintf_alloc.c	2008-01-18 11:05:46 UTC (rev 3878)
+++ trunk/src/target/ipkg/sprintf_alloc.c	2008-01-18 11:28:48 UTC (rev 3879)
@@ -15,7 +15,7 @@
    GNU General Public License for more details.
 */
 
-#include "ipkg.h"
+#include "opkg.h"
 #include <stdarg.h>
 
 #include "sprintf_alloc.h"

Modified: trunk/src/target/ipkg/str_list.c
===================================================================
--- trunk/src/target/ipkg/str_list.c	2008-01-18 11:05:46 UTC (rev 3878)
+++ trunk/src/target/ipkg/str_list.c	2008-01-18 11:28:48 UTC (rev 3879)
@@ -15,7 +15,7 @@
    General Public License for more details.
 */
 
-#include "ipkg.h"
+#include "opkg.h"
 
 #include "str_list.h"
 

Modified: trunk/src/target/ipkg/str_util.c
===================================================================
--- trunk/src/target/ipkg/str_util.c	2008-01-18 11:05:46 UTC (rev 3878)
+++ trunk/src/target/ipkg/str_util.c	2008-01-18 11:28:48 UTC (rev 3879)
@@ -15,7 +15,7 @@
    General Public License for more details.
 */
 
-#include "ipkg.h"
+#include "opkg.h"
 
 int str_starts_with(const char *str, const char *prefix)
 {

Modified: trunk/src/target/ipkg/update-alternatives
===================================================================
--- trunk/src/target/ipkg/update-alternatives	2008-01-18 11:05:46 UTC (rev 3878)
+++ trunk/src/target/ipkg/update-alternatives	2008-01-18 11:28:48 UTC (rev 3879)
@@ -21,7 +21,7 @@
 set -e
 
 # admin dir
-ad="$IPKG_OFFLINE_ROOT/usr/lib/ipkg/alternatives"
+ad="$OPKG_OFFLINE_ROOT/usr/lib/opkg/alternatives"
 
 usage() {
 	echo "update-alternatives: $*
@@ -93,7 +93,7 @@
 	[ $# -lt 1 ] && return 1
 	[ ! -f $ad/$name ] && return 0
 
-	link=$IPKG_OFFLINE_ROOT/`head -n 1 $ad/$name`
+	link=$OPKG_OFFLINE_ROOT/`head -n 1 $ad/$name`
 
 ##	path=`sed -ne "1!p" $ad/$name | sort -nr -k2 | head -1 | sed 's/ .*//'`
 ## busybox safe:
@@ -134,7 +134,7 @@
 	path=`echo $path | sed 's|/\+|/|g'`
 
 	# This is a bad hack, but I haven't thought of a cleaner solution yet...
-	[ -n "$IPKG_OFFLINE_ROOT" ] && path=`echo $path | sed "s|^$IPKG_OFFLINE_ROOT/*|/|"`
+	[ -n "$OPKG_OFFLINE_ROOT" ] && path=`echo $path | sed "s|^$OPKG_OFFLINE_ROOT/*|/|"`
 
 	register_alt $name $link
 	add_alt $name $path $priority
@@ -151,7 +151,7 @@
 	path=`echo $path | sed 's|/\+|/|g'`
 
 	# This is a bad hack, but I haven't thought of a cleaner solution yet...
-	[ -n "$IPKG_OFFLINE_ROOT" ] && path=`echo $path | sed "s|^$IPKG_OFFLINE_ROOT/*|/|"`
+	[ -n "$OPKG_OFFLINE_ROOT" ] && path=`echo $path | sed "s|^$OPKG_OFFLINE_ROOT/*|/|"`
 
 	remove_alt $name $path
 	find_best_alt $name

Modified: trunk/src/target/ipkg/user.c
===================================================================
--- trunk/src/target/ipkg/user.c	2008-01-18 11:05:46 UTC (rev 3878)
+++ trunk/src/target/ipkg/user.c	2008-01-18 11:28:48 UTC (rev 3879)
@@ -20,12 +20,12 @@
 #include <stdarg.h>
 #include "file_util.h"
 #include "str_util.h"
-#ifdef IPKG_LIB	
-#include "libipkg.h"
+#ifdef OPKG_LIB	
+#include "libopkg.h"
 #endif	
 
 
-#ifdef IPKG_LIB
+#ifdef OPKG_LIB
 static char *question = NULL;
 static int question_len = 255;
 #endif	
@@ -36,7 +36,7 @@
      char *response;
      va_start(ap, format);
 
-#ifndef IPKG_LIB
+#ifndef OPKG_LIB
      vprintf(format, ap);
      do {
 	  response = file_read_line_alloc(stdin);
@@ -49,7 +49,7 @@
 	  }
 	  len = vsnprintf(question,question_len,format,ap);
      } while (len > question_len);
-     response = strdup(ipkg_cb_response(question));
+     response = strdup(opkg_cb_response(question));
 #endif
      str_chomp(response);
      str_tolower(response);

Modified: trunk/src/target/ipkg/void_list.c
===================================================================
--- trunk/src/target/ipkg/void_list.c	2008-01-18 11:05:46 UTC (rev 3878)
+++ trunk/src/target/ipkg/void_list.c	2008-01-18 11:28:48 UTC (rev 3879)
@@ -15,7 +15,7 @@
    General Public License for more details.
 */
 
-#include "ipkg.h"
+#include "opkg.h"
 #include <errno.h>
 
 #include "void_list.h"

Modified: trunk/src/target/ipkg/xregex.c
===================================================================
--- trunk/src/target/ipkg/xregex.c	2008-01-18 11:05:46 UTC (rev 3878)
+++ trunk/src/target/ipkg/xregex.c	2008-01-18 11:28:48 UTC (rev 3879)
@@ -15,7 +15,7 @@
    GNU General Public License for more details.
 */
 
-#include "ipkg.h"
+#include "opkg.h"
 
 #include "xregex.h"
 

Modified: trunk/src/target/ipkg/xsystem.c
===================================================================
--- trunk/src/target/ipkg/xsystem.c	2008-01-18 11:05:46 UTC (rev 3878)
+++ trunk/src/target/ipkg/xsystem.c	2008-01-18 11:28:48 UTC (rev 3879)
@@ -15,7 +15,7 @@
    General Public License for more details.
 */
 
-#include "ipkg.h"
+#include "opkg.h"
 #include <sys/wait.h>
 
 #include "xsystem.h"





More information about the commitlog mailing list