diff --git a/dpkg.c b/dpkg.c
new file mode 100644
index 0000000..9519eeb
--- /dev/null
+++ b/dpkg.c
@@ -0,0 +1,905 @@
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <search.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <utime.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include "busybox.h"
+
+//#define PACKAGE "udpkg"
+//#define VERSION "0.1"
+
+/*
+ * Should we do full dependency checking?
+ */
+#define DODEPENDS 1
+
+/*
+ * Should we do debugging?
+ */
+#define DODEBUG 0
+
+#ifdef DODEBUG
+#include <assert.h>
+#define ASSERT(x) assert(x)
+#define SYSTEM(x) do_system(x)
+#define DPRINTF(fmt,args...) fprintf(stderr, fmt, ##args)
+#else
+#define ASSERT(x) /* nothing */
+#define SYSTEM(x) system(x)
+#define DPRINTF(fmt,args...) /* nothing */
+#endif
+
+#define BUFSIZE		4096
+#define ADMINDIR "/var/lib/dpkg"
+#define STATUSFILE	ADMINDIR ## "/status"
+#define DPKGCIDIR	ADMINDIR ## "/tmp.ci/"
+#define INFODIR		ADMINDIR ## "/info/"
+#define UDPKG_QUIET	"UDPKG_QUIET"
+#define DEPENDSMAX	64	/* maximum number of depends we can handle */
+
+#define STATUS_WANTSTART		(0)
+#define STATUS_WANTUNKNOWN		(1 << 0)
+#define STATUS_WANTINSTALL		(1 << 1)
+#define STATUS_WANTHOLD			(1 << 2)
+#define STATUS_WANTDEINSTALL		(1 << 3)
+#define STATUS_WANTPURGE		(1 << 4)
+#define STATUS_WANTMASK			~(STATUS_WANTUNKNOWN | STATUS_WANTINSTALL | STATUS_WANTHOLD | STATUS_WANTDEINSTALL | STATUS_WANTPURGE)
+
+#define STATUS_FLAGSTART		(5)
+#define STATUS_FLAGOK			(1 << 5)
+#define STATUS_FLAGREINSTREQ		(1 << 6)
+#define STATUS_FLAGHOLD			(1 << 7)
+#define STATUS_FLAGHOLDREINSTREQ	(1 << 8)
+#define STATUS_FLAGMASK			~(STATUS_FLAGOK | STATUS_FLAGREINSTREQ | STATUS_FLAGHOLD | STATUS_FLAGHOLDREINSTREQ)
+
+#define STATUS_STATUSSTART		(9)
+#define STATUS_STATUSNOTINSTALLED	(1 << 9)
+#define STATUS_STATUSUNPACKED		(1 << 10)
+#define STATUS_STATUSHALFCONFIGURED	(1 << 11)
+#define STATUS_STATUSINSTALLED		(1 << 12)
+#define STATUS_STATUSHALFINSTALLED	(1 << 13)
+#define STATUS_STATUSCONFIGFILES	(1 << 14)
+#define STATUS_STATUSPOSTINSTFAILED	(1 << 15)
+#define STATUS_STATUSREMOVALFAILED	(1 << 16)
+#define STATUS_STATUSMASK		~(STATUS_STATUSNOTINSTALLED | STATUS_STATUSUNPACKED | STATUS_STATUSHALFCONFIGURED | STATUS_STATUSCONFIGFILES | STATUS_STATUSPOSTINSTFAILED | STATUS_STATUSREMOVALFAILED | STATUS_STATUSHALFINSTALLED)
+
+#define COLOR_WHITE			0
+#define COLOR_GRAY			1
+#define COLOR_BLACK			2
+
+/* data structures */
+struct package_t {
+	char *file;
+	char *package;
+	char *version;
+	char *depends;
+	char *provides;
+	char *description;
+	int installer_menu_item;
+	unsigned long status;
+	char color; /* for topo-sort */
+	struct package_t *requiredfor[DEPENDSMAX]; 
+	unsigned short requiredcount;
+	struct package_t *next;
+};
+
+/* function prototypes */
+void *status_read(void);
+void control_read(FILE *f, struct package_t *p);
+int status_merge(void *status, struct package_t *pkgs);
+int package_compare(const void *p1, const void *p2);
+struct package_t *depends_resolve(struct package_t *pkgs, void *status);
+
+#ifdef DODEPENDS
+#include <ctype.h>
+
+static char **depends_split(const char *dependsstr)
+{
+	static char *dependsvec[DEPENDSMAX];
+	char *p;
+	int i = 0;
+
+	dependsvec[0] = 0;
+
+	if (dependsstr != 0)
+	{
+		p = strdup(dependsstr);
+		while (*p != 0 && *p != '\n')
+		{
+			if (*p != ' ')
+			{
+				if (*p == ',')
+				{
+					*p = 0;
+					dependsvec[++i] = 0;
+				}
+				else if (dependsvec[i] == 0)
+					dependsvec[i] = p;
+			}
+			else
+				*p = 0; /* eat the space... */
+			p++;
+		}
+		*p = 0;
+	}
+	dependsvec[i+1] = 0;
+	return dependsvec;
+}
+
+static void depends_sort_visit(struct package_t **ordered, 
+	struct package_t *pkgs, struct package_t *pkg)
+{
+	/* Topological sort algorithm:
+	 * ordered is the output list, pkgs is the dependency graph, pkg is 
+	 * the current node
+	 *
+	 * recursively add all the adjacent nodes to the ordered list, marking
+	 * each one as visited along the way
+	 *
+	 * yes, this algorithm looks a bit odd when all the params have the
+	 * same type :-)
+	 */
+	unsigned short i;
+
+	/* mark node as processing */
+	pkg->color = COLOR_GRAY;
+
+	/* visit each not-yet-visited node */
+	for (i = 0; i < pkg->requiredcount; i++)
+		if (pkg->requiredfor[i]->color == COLOR_WHITE)
+			depends_sort_visit(ordered, pkgs, pkg->requiredfor[i]);
+
+#if 0
+	/* add it to the list */
+	newnode = (struct package_t *)malloc(sizeof(struct package_t));
+	/* make a shallow copy */
+	*newnode = *pkg;
+	newnode->next = *ordered;
+	*ordered = newnode;
+#endif
+	pkg->next = *ordered;
+	*ordered = pkg;
+
+	/* mark node as done */
+	pkg->color = COLOR_BLACK;
+}
+
+static struct package_t *depends_sort(struct package_t *pkgs)
+{
+	/* TODO: it needs to break cycles in the to-be-installed package 
+	 * graph... */
+	struct package_t *ordered = NULL;
+	struct package_t *pkg;
+
+	for (pkg = pkgs; pkg != 0; pkg = pkg->next)
+		pkg->color = COLOR_WHITE;
+
+	for (pkg = pkgs; pkg != 0; pkg = pkg->next)
+		if (pkg->color == COLOR_WHITE)
+			depends_sort_visit(&ordered, pkgs, pkg);
+
+	/* Leaks the old list... return the new one... */
+	return ordered;
+}
+
+
+/* resolve package dependencies -- 
+ * for each package in the list of packages to be installed, we parse its 
+ * dependency info to determine if the dependent packages are either 
+ * already installed, or are scheduled to be installed. If both tests fail
+ * than bail.
+ *
+ * The algorithm here is O(n^2*m) where n = number of packages to be 
+ * installed and m is the # of dependencies per package. Not a terribly
+ * efficient algorithm, but given that at any one time you are unlikely
+ * to install a very large number of packages it doesn't really matter
+ */
+struct package_t *depends_resolve(struct package_t *pkgs, void *status)
+{
+	struct package_t *pkg, *chk;
+	struct package_t dependpkg;
+	char **dependsvec;
+	int i;
+	void *found;
+
+	for (pkg = pkgs; pkg != 0; pkg = pkg->next)
+	{
+		dependsvec = depends_split(pkg->depends);
+		i = 0;
+		while (dependsvec[i] != 0)
+		{
+			/* Check for dependencies; first look for installed packages */
+			dependpkg.package = dependsvec[i];
+			if ((found = tfind(&dependpkg, &status, package_compare)) == 0 ||
+			    ((chk = *(struct package_t **)found) &&
+			     (chk->status & (STATUS_FLAGOK | STATUS_STATUSINSTALLED)) != 
+			      (STATUS_FLAGOK | STATUS_STATUSINSTALLED)))
+			{
+				/* if it fails, we look through the list of packages we are going to 
+				 * install */
+				for (chk = pkgs; chk != 0; chk = chk->next)
+				{
+					if (strcmp(chk->package, dependsvec[i]) == 0 ||
+					    (chk->provides && 
+					     strncmp(chk->provides, dependsvec[i], strlen(dependsvec[i])) == 0))
+					{
+						if (chk->requiredcount >= DEPENDSMAX)
+						{
+							fprintf(stderr, "Too many dependencies for %s\n", 
+								chk->package);
+							return 0;
+						}
+						if (chk != pkg)
+							chk->requiredfor[chk->requiredcount++] = pkg;
+						break;
+					}
+				}
+				if (chk == 0)
+				{
+					fprintf(stderr, "%s depends on %s, but it is not going to be installed\n", pkg->package, dependsvec[i]);
+					return 0;
+				}
+			}
+			i++;
+		}
+	}
+
+	return depends_sort(pkgs);
+}
+#endif
+
+/* Status file handling routines
+ * 
+ * This is a fairly minimalistic implementation. there are two main functions 
+ * that are supported:
+ * 
+ * 1) reading the entire status file:
+ *    the status file is read into memory as a binary-tree, with just the 
+ *    package and status info preserved
+ *
+ * 2) merging the status file
+ *    control info from (new) packages is merged into the status file, 
+ *    replacing any pre-existing entries. when a merge happens, status info 
+ *    read using the status_read function is written back to the status file
+ */
+
+static const char *statuswords[][10] = {
+	{ (char *)STATUS_WANTSTART, "unknown", "install", "hold", 
+		"deinstall", "purge", 0 },
+	{ (char *)STATUS_FLAGSTART, "ok", "reinstreq", "hold", 
+		"hold-reinstreq", 0 },
+	{ (char *)STATUS_STATUSSTART, "not-installed", "unpacked", "half-configured",
+		"installed", "half-installed",
+		"config-files", "post-inst-failed", 
+		"removal-failed", 0 }
+};
+
+int package_compare(const void *p1, const void *p2)
+{
+	return strcmp(((struct package_t *)p1)->package, 
+		((struct package_t *)p2)->package);
+}
+
+static unsigned long status_parse(const char *line)
+{
+	char *p;
+	int i, j;
+	unsigned long l = 0;
+	for (i = 0; i < 3; i++)
+	{
+		p = strchr(line, ' ');
+		if (p) *p = 0; 
+		j = 1;
+		while (statuswords[i][j] != 0) 
+		{
+			if (strcmp(line, statuswords[i][j]) == 0) 
+			{
+				l |= (1 << ((int)statuswords[i][0] + j - 1));
+				break;
+			}
+			j++;
+		}
+		if (statuswords[i][j] == 0) return 0; /* parse error */
+		line = p+1;
+	}
+	return l;
+}
+
+static const char *status_print(unsigned long flags)
+{
+	/* this function returns a static buffer... */
+	static char buf[256];
+	int i, j;
+
+	buf[0] = 0;
+	for (i = 0; i < 3; i++)
+	{
+		j = 1;
+		while (statuswords[i][j] != 0)
+		{
+			if ((flags & (1 << ((int)statuswords[i][0] + j - 1))) != 0)
+			{
+				strcat(buf, statuswords[i][j]);
+				if (i < 2) strcat(buf, " ");
+				break;
+			}
+			j++;
+		}
+		if (statuswords[i][j] == 0)
+		{
+			fprintf(stderr, "corrupted status flag!!\n");
+			return NULL;
+		}
+	}
+	return buf;
+}
+
+/*
+ * Read a control file (or a stanza of a status file) and parse it,
+ * filling parsed fields into the package structure
+ */
+void control_read(FILE *f, struct package_t *p)
+{
+	char buf[BUFSIZE];
+	while (fgets(buf, BUFSIZE, f) && !feof(f))
+	{
+		buf[strlen(buf)-1] = 0;
+		if (*buf == 0)
+			return;
+		else if (strstr(buf, "Package: ") == buf)
+		{
+			p->package = strdup(buf+9);
+		}
+		else if (strstr(buf, "Status: ") == buf)
+		{
+			p->status = status_parse(buf+8);
+		}
+		else if (strstr(buf, "Depends: ") == buf)
+		{
+			p->depends = strdup(buf+9);
+		}
+		else if (strstr(buf, "Provides: ") == buf)
+		{
+			p->provides = strdup(buf+10);
+		}
+		/* This is specific to the Debian Installer. Ifdef? */
+		else if (strstr(buf, "installer-menu-item: ") == buf) 
+		{
+			p->installer_menu_item = atoi(buf+21);
+		}
+		else if (strstr(buf, "Description: ") == buf)
+		{
+			p->description = strdup(buf+13);
+		}
+		/* TODO: localized descriptions */
+	}
+}
+
+void *status_read(void)
+{
+	FILE *f;
+	void *status = 0;
+	struct package_t *m = 0, *p = 0, *t = 0;
+
+	if ((f = fopen(STATUSFILE, "r")) == NULL)
+	{
+		perror(STATUSFILE);
+		return 0;
+	}
+	if (getenv(UDPKG_QUIET) == NULL)
+		printf("(Reading database...)\n");
+	while (!feof(f))
+	{
+		m = (struct package_t *)malloc(sizeof(struct package_t));
+		memset(m, 0, sizeof(struct package_t));
+		control_read(f, m);
+		if (m->package)
+		{
+			/*
+			 * If there is an item in the tree by this name,
+			 * it must be a virtual package; insert real
+			 * package in preference.
+			 */
+			tdelete(m, &status, package_compare);
+			tsearch(m, &status, package_compare);
+			if (m->provides)
+			{
+				/* 
+				 * A "Provides" triggers the insertion
+				 * of a pseudo package into the status
+				 * binary-tree.
+				 */
+				p = (struct package_t *)malloc(sizeof(struct package_t));
+				memset(p, 0, sizeof(struct package_t));
+				p->package = strdup(m->provides);
+
+				t = *(struct package_t **)tsearch(p, &status, package_compare);
+				if (!(t == p))
+				{
+					free(p->package);
+					free(p);
+				}
+				else {
+					/*
+					 * Pseudo package status is the
+					 * same as the status of the
+					 * package providing it 
+					 * FIXME: (not quite right, if 2
+					 * packages of different statuses
+					 * provide it).
+					 */
+					t->status = m->status;
+				}
+			}
+		}
+		else
+		{
+			free(m);
+		}
+	}
+	fclose(f);
+	return status;
+}
+
+int status_merge(void *status, struct package_t *pkgs)
+{
+	FILE *fin, *fout;
+	char buf[BUFSIZE];
+	struct package_t *pkg = 0, *statpkg = 0;
+	struct package_t locpkg;
+	int r = 0;
+
+	if ((fin = fopen(STATUSFILE, "r")) == NULL)
+	{
+		perror(STATUSFILE);
+		return 0;
+	}
+	if ((fout = fopen(STATUSFILE ".new", "w")) == NULL)
+	{
+		perror(STATUSFILE ".new");
+		return 0;
+	}
+	if (getenv(UDPKG_QUIET) == NULL)
+		printf("(Updating database...)\n");
+	while (fgets(buf, BUFSIZE, fin) && !feof(fin))
+	{
+		buf[strlen(buf)-1] = 0; /* trim newline */
+		/* If we see a package header, find out if it's a package
+		 * that we have processed. if so, we skip that block for
+		 * now (write it at the end).
+		 *
+		 * we also look at packages in the status cache and update
+		 * their status fields
+		 */
+		if (strstr(buf, "Package: ") == buf)
+		{
+			for (pkg = pkgs; pkg != 0 && strncmp(buf+9,
+					pkg->package, strlen(pkg->package))!=0;
+			     pkg = pkg->next) ;
+
+			locpkg.package = buf+9;
+			statpkg = tfind(&locpkg, &status, package_compare);
+			
+			/* note: statpkg should be non-zero, unless the status
+			 * file was changed while we are processing (no locking
+			 * is currently done...
+			 */
+			if (statpkg != 0) statpkg = *(struct package_t **)statpkg;
+		}
+		if (pkg != 0) continue;
+
+		if (strstr(buf, "Status: ") == buf && statpkg != 0)
+		{
+			  snprintf(buf, sizeof(buf), "Status: %s",
+				 status_print(statpkg->status));
+		}
+		fputs(buf, fout);
+		fputc('\n', fout);
+	}
+
+	// Print out packages we processed.
+	for (pkg = pkgs; pkg != 0; pkg = pkg->next) {
+		fprintf(fout, "Package: %s\nStatus: %s\n", 
+			pkg->package, status_print(pkg->status));
+		if (pkg->depends)
+			fprintf(fout, "Depends: %s\n", pkg->depends);
+		if (pkg->provides)
+			fprintf(fout, "Provides: %s\n", pkg->provides);
+		if (pkg->installer_menu_item)
+			fprintf(fout, "installer-menu-item: %i\n", pkg->installer_menu_item);
+		if (pkg->description)
+			fprintf(fout, "Description: %s\n", pkg->description);
+		fputc('\n', fout);
+	}
+	
+	fclose(fin);
+	fclose(fout);
+
+	r = rename(STATUSFILE, STATUSFILE ".bak");
+	if (r == 0) r = rename(STATUSFILE ".new", STATUSFILE);
+	return 0;
+}
+
+#include <errno.h>
+#include <fcntl.h>
+#include <search.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <utime.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+
+/* 
+ * Main udpkg implementation routines
+ */
+
+#ifdef DODEBUG
+static int do_system(const char *cmd)
+{
+	DPRINTF("cmd is %s\n", cmd);
+	return system(cmd);
+}
+#else
+#define do_system(cmd) system(cmd)
+#endif
+
+static int is_file(const char *fn)
+{
+	struct stat statbuf;
+
+	if (stat(fn, &statbuf) < 0) return 0;
+	return S_ISREG(statbuf.st_mode);
+}
+
+static int dpkg_copyfile(const char *src, const char *dest)
+{
+	/* copy a (regular) file if it exists, preserving the mode, mtime 
+	 * and atime */
+	char buf[8192];
+	int infd, outfd;
+	int r;
+	struct stat srcStat;
+	struct utimbuf times;
+
+	if (stat(src, &srcStat) < 0) 
+	{
+		if (errno == 2) return 0; else return -1;
+	}
+	if ((infd = open(src, O_RDONLY)) < 0) 
+		return -1;
+	if ((outfd = open(dest, O_WRONLY|O_CREAT|O_TRUNC, srcStat.st_mode)) < 0)
+		return -1;
+	while ((r = read(infd, buf, sizeof(buf))) > 0)
+	{
+		if (write(outfd, buf, r) < 0)
+			return -1;
+	}
+	close(outfd);
+	close(infd);
+	if (r < 0) return -1;
+	times.actime = srcStat.st_atime;
+	times.modtime = srcStat.st_mtime;
+	if (utime(dest, &times) < 0) return -1;
+	return 1;
+}
+
+static int dpkg_doconfigure(struct package_t *pkg)
+{
+	int r;
+	char postinst[1024];
+	char buf[1024];
+	DPRINTF("Configuring %s\n", pkg->package);
+	pkg->status &= STATUS_STATUSMASK;
+	snprintf(postinst, sizeof(postinst), "%s%s.postinst", INFODIR, pkg->package);
+	if (is_file(postinst))
+	{
+		snprintf(buf, sizeof(buf), "%s configure", postinst);
+		if ((r = do_system(buf)) != 0)
+		{
+			fprintf(stderr, "postinst exited with status %d\n", r);
+			pkg->status |= STATUS_STATUSHALFCONFIGURED;
+			return 1;
+		}
+	}
+
+	pkg->status |= STATUS_STATUSINSTALLED;
+	
+	return 0;
+}
+
+static int dpkg_dounpack(struct package_t *pkg)
+{
+	int r = 0;
+	char *cwd, *p;
+	FILE *infp, *outfp;
+	char buf[1024], buf2[1024];
+	int i;
+	char *adminscripts[] = { "prerm", "postrm", "preinst", "postinst",
+	                         "conffiles", "md5sums", "shlibs", 
+				 "templates" };
+
+	DPRINTF("Unpacking %s\n", pkg->package);
+
+	cwd = getcwd(0, 0);
+	chdir("/");
+	snprintf(buf, sizeof(buf), "ar -p %s data.tar.gz|zcat|tar -xf -", pkg->file);
+	if (SYSTEM(buf) == 0)
+	{
+		/* Installs the package scripts into the info directory */
+		for (i = 0; i < sizeof(adminscripts) / sizeof(adminscripts[0]);
+		     i++)
+		{
+			snprintf(buf, sizeof(buf), "%s%s/%s",
+				DPKGCIDIR, pkg->package, adminscripts[i]);
+			snprintf(buf2, sizeof(buf), "%s%s.%s", 
+				INFODIR, pkg->package, adminscripts[i]);
+			if (dpkg_copyfile(buf, buf2) < 0)
+			{
+				fprintf(stderr, "Cannot copy %s to %s: %s\n", 
+					buf, buf2, strerror(errno));
+				r = 1;
+				break;
+			}
+			else
+			{
+				/* ugly hack to create the list file; should
+				 * probably do something more elegant
+				 *
+				 * why oh why does dpkg create the list file
+				 * so oddly...
+				 */
+				snprintf(buf, sizeof(buf), 
+					"ar -p %s data.tar.gz|zcat|tar -tf -", 
+					pkg->file);
+				snprintf(buf2, sizeof(buf2),
+					"%s%s.list", INFODIR, pkg->package);
+				if ((infp = popen(buf, "r")) == NULL ||
+				    (outfp = fopen(buf2, "w")) == NULL)
+				{
+					fprintf(stderr, "Cannot create %s\n",
+						buf2);
+					r = 1;
+					break;
+				}
+				while (fgets(buf, sizeof(buf), infp) &&
+				       !feof(infp))
+				{
+					p = buf;
+					if (*p == '.') p++;
+					if (*p == '/' && *(p+1) == '\n')
+					{
+						*(p+1) = '.';
+						*(p+2) = '\n';
+						*(p+3) = 0;
+					}
+					if (p[strlen(p)-2] == '/')
+					{
+						p[strlen(p)-2] = '\n';
+						p[strlen(p)-1] = 0;
+					}
+					fputs(p, outfp);
+				}
+				fclose(infp);
+				fclose(outfp);
+			}
+		}
+		pkg->status &= STATUS_WANTMASK;
+		pkg->status |= STATUS_WANTINSTALL;
+		pkg->status &= STATUS_FLAGMASK;
+		pkg->status |= STATUS_FLAGOK;
+		pkg->status &= STATUS_STATUSMASK;
+		if (r == 0)
+			pkg->status |= STATUS_STATUSUNPACKED;
+		else
+			pkg->status |= STATUS_STATUSHALFINSTALLED;
+	}
+	chdir(cwd);
+	return r;
+}
+
+static int dpkg_doinstall(struct package_t *pkg)
+{
+	DPRINTF("Installing %s\n", pkg->package);
+	return (dpkg_dounpack(pkg) || dpkg_doconfigure(pkg));
+}
+
+static int dpkg_unpackcontrol(struct package_t *pkg)
+{
+	int r = 1;
+	char *cwd = 0;
+	char *p;
+	char buf[1024];
+	FILE *f;
+
+	p = strrchr(pkg->file, '/');
+	if (p) p++; else p = pkg->file;
+	p = pkg->package = strdup(p);
+	while (*p != 0 && *p != '_' && *p != '.') p++;
+	*p = 0;
+
+	cwd = getcwd(0, 0);
+	snprintf(buf, sizeof(buf), "%s%s", DPKGCIDIR, pkg->package);
+	DPRINTF("dir = %s\n", buf);
+	if (mkdir(buf, S_IRWXU) == 0 && chdir(buf) == 0)
+	{
+		snprintf(buf, sizeof(buf), "ar -p %s control.tar.gz|zcat|tar -xf -",
+			pkg->file);
+		if (SYSTEM(buf) == 0)
+		{
+			if ((f = fopen("control", "r")) != NULL) {
+				control_read(f, pkg);
+				r = 0;
+			}
+		}
+	}
+
+	chdir(cwd);
+	free(cwd);
+	return r;
+}
+
+static int dpkg_unpack(struct package_t *pkgs)
+{
+	int r = 0;
+	struct package_t *pkg;
+	void *status = status_read();
+
+	if (SYSTEM("rm -rf -- " DPKGCIDIR) != 0 ||
+	    mkdir(DPKGCIDIR, S_IRWXU) != 0)
+	{
+		perror("mkdir");
+		return 1;
+	}
+	
+	for (pkg = pkgs; pkg != 0; pkg = pkg->next)
+	{
+		dpkg_unpackcontrol(pkg);
+		r = dpkg_dounpack(pkg);
+		if (r != 0) break;
+	}
+	status_merge(status, pkgs);
+	SYSTEM("rm -rf -- " DPKGCIDIR);
+	return r;
+}
+
+static int dpkg_configure(struct package_t *pkgs)
+{
+	int r = 0;
+	void *found;
+	struct package_t *pkg;
+	void *status = status_read();
+	for (pkg = pkgs; pkg != 0 && r == 0; pkg = pkg->next)
+	{
+		found = tfind(pkg, &status, package_compare);
+		if (found == 0)
+		{
+			fprintf(stderr, "Trying to configure %s, but it is not installed\n", pkg->package);
+			r = 1;
+		}
+		else
+		{
+			/* configure the package listed in the status file;
+			 * not pkg, as we have info only for the latter */
+			r = dpkg_doconfigure(*(struct package_t **)found);
+		}
+	}
+	status_merge(status, 0);
+	return r;
+}
+
+static int dpkg_install(struct package_t *pkgs)
+{
+	struct package_t *p, *ordered = 0;
+	void *status = status_read();
+	if (SYSTEM("rm -rf -- " DPKGCIDIR) != 0 ||
+	    mkdir(DPKGCIDIR, S_IRWXU) != 0)
+	{
+		perror("mkdir");
+		return 1;
+	}
+	
+	/* Stage 1: parse all the control information */
+	for (p = pkgs; p != 0; p = p->next)
+		if (dpkg_unpackcontrol(p) != 0)
+		{
+			perror(p->file);
+			/* force loop break, and prevents further ops */
+			pkgs = 0;
+		}
+	
+	/* Stage 2: resolve dependencies */
+#ifdef DODEPENDS
+	ordered = depends_resolve(pkgs, status);
+#else
+	ordered = pkgs;
+#endif
+	
+	/* Stage 3: install */
+	for (p = ordered; p != 0; p = p->next)
+	{
+		p->status &= STATUS_WANTMASK;
+		p->status |= STATUS_WANTINSTALL;
+
+		/* for now the flag is always set to ok... this is probably
+		 * not what we want
+		 */
+		p->status &= STATUS_FLAGMASK;
+		p->status |= STATUS_FLAGOK;
+
+		if (dpkg_doinstall(p) != 0)
+		{
+			perror(p->file);
+		}
+	}
+	
+	if (ordered != 0)
+		status_merge(status, pkgs);
+	SYSTEM("rm -rf -- " DPKGCIDIR);
+	return 0;
+}
+
+static int dpkg_remove(struct package_t *pkgs)
+{
+	struct package_t *p;
+	void *status = status_read();
+	for (p = pkgs; p != 0; p = p->next)
+	{
+	}
+	status_merge(status, 0);
+	return 0;
+}
+
+int dpkg_main(int argc, char **argv)
+{
+	char opt = 0;
+	char *s;
+	struct package_t *p, *packages = NULL;
+	char *cwd = getcwd(0, 0);
+	while (*++argv)
+	{
+		if (**argv == '-') {
+			/* Nasty little hack to "parse" long options. */
+			s = *argv;
+			while (*s == '-')
+				s++;
+			opt=s[0];
+		}
+		else
+		{
+			p = (struct package_t *)malloc(sizeof(struct package_t));
+			memset(p, 0, sizeof(struct package_t));
+			if (**argv == '/')
+				p->file = *argv;
+			else if (opt != 'c')
+			{
+				p->file = malloc(strlen(cwd) + strlen(*argv) + 2);
+				sprintf(p->file, "%s/%s", cwd, *argv);
+			}
+			else {
+				p->package = strdup(*argv);
+			}
+			p->next = packages;
+			packages = p;
+		}
+			
+	}
+	switch (opt)
+	{
+		case 'i': return dpkg_install(packages); break;
+		case 'r': return dpkg_remove(packages); break;
+		case 'u': return dpkg_unpack(packages); break;
+		case 'c': return dpkg_configure(packages); break;
+	}
+
+	/* if it falls through to here, some of the command line options were
+	   wrong */
+	usage(dpkg_usage);
+	return 0;
+}
\ No newline at end of file
