diff -ur slapt-get-0.10.1.orig/ChangeLog slapt-get-0.10.1/ChangeLog
--- slapt-get-0.10.1.orig/ChangeLog	2008-12-14 20:28:32.000000000 +0100
+++ slapt-get-0.10.1/ChangeLog	2009-02-16 12:03:04.000000000 +0100
@@ -1,4 +1,70 @@
 
+0.10.2 Feb 16, 2009
+ * slapt-getrc now honours the following configuration variables in
+   SOURCES= lines:
+
+  --- snip ---
+
+       Example:
+
+        DISTRO: slackware 12.2; hostname: slakware, kernel: 2.6.24
+	DISTRO: slamd64 12.1; hostname: slamd; kernel 2.6.24-1
+	DISTRO: bluewhite64 12.2; hostname: bluewhite; kernel: 2.6.24-2
+	
+	VARIABLE NAME                     EXPANSION (slackware)  EXPANSION (slamd64)   EXPANSION (bluewhite64)
+	${ARCH}                           i686                   x86_64                x86_64
+	${UNAME_MACHINE}                  i686                   x86_64                x86_64
+	${HOSTNAME}                       slakware               slamd                 bluewhite
+	${UNAME_NODENAME}                 slakware               slamd                 bluewhite
+	${UNAME_RELEASE}                  2.6.24                 2.6.24-1              2.6.24-2
+	${KERNEL_VERSION}                 2.6.24                 2.6.24-1              2.6.24-2
+	${OS_TYPE}                        Linux                  Linux                 Linux
+	${UNAME_SYSNAME}                  Linux                  Linux                 Linux
+	${OS_TYPE_LC}                     linux                  linux                 linux
+	${UNAME_SYSNAME_LC}               linux                  linux                 linux
+	${DISTRO_TYPE}                    Slackware              Slamd64               Bluewhite64
+	${DISTRO_NAME}                    Slackware              Slamd64               Bluewhite64
+	${DISTRIBUTION}                   Slackware              Slamd64               Bluewhite64
+	${GENERIC_DISTRO_TYPE}            Slackware              Slackware             Slackware
+	${GENERIC_DISTRO_NAME}            Slackware              Slackware             Slackware
+	${GENERIC_DISTRO_TYPE_LC}         slackware              slackware             slackware
+	${GENERIC_DISTRO_NAME_LC}         slackware              slackware             slackware
+	${DISTRO_TYPE_LC}                 slackware              slamd64               bluewhite64
+	${DISTRO_NAME_LC}                 slackware              slamd64               bluewhite64
+	${DISTRIBUTION_LC}                slackware              slamd64               bluewhite64
+	${DISTRO_VERSION}                 12.2.0                 12.1.0                12.2.0
+	${DISTRIBUTION_VERSION}           12.2.0                 12.1.0                12.2.0
+	${DISTRO_VERSION_MAJOR}           12                     12                    12
+	${DISTRO_VERSION_MINOR}           2                      1                     2
+	${DISTRO_VERSION_BUILD}           0                      0                     0
+
+
+SOURCE=http://repo.example.org/dist/${ARCH}/${DISTRO_NAME_LC}-${DISTRO_VERSION}/:CUSTOM
+  expands to:
+       http://repo.example.org/dist/i686/slackware-12.2.0/:CUSTOM      (slackware)
+       http://repo.example.org/dist/x86_64/slamd64-12.1.0/:CUSTOM      (slamd64)
+       http://repo.example.org/dist/x86_64/bluewhite64-12.2.0/:CUSTOM  (bluewhite64)
+       
+SOURCE=http://repo.example.org/dist/noarch/${DISTRO_NAME_LC}-${DISTRO_VERSION}/:CUSTOM
+  expands to:
+       http://repo.example.org/dist/noarch/slackware-12.2.0/:CUSTOM      (slackware)
+       http://repo.example.org/dist/noarch/slamd64-12.1.0/:CUSTOM        (slamd64)
+       http://repo.example.org/dist/noarch/bluewhite64-12.2.0/:CUSTOM    (bluewhite64)
+
+SOURCE=http://repo.example.org/mirrors/${DISTRO_NAME_LC}-${DISTRO_VERSION_MAJOR}.${DISTRO_VERSION_MINOR}/:OFFICIAL
+  expands to:
+       http://repo.example.org/mirrors/slackware-12.2/:OFFICIAL      (slackware)
+       http://repo.example.org/mirrors/slamd64-12.1/:OFFICIAL        (slamd64)
+       http://repo.example.org/mirrors/bluewhite64-12.2/:OFFICIAL    (bluewhite64)
+
+  --- snip ---
+
+ * slapt-get targets can now be specified without -- command line prefix
+   slapt-get --install <pkgname>  -> slapt-get install <pkgname>
+
+ * added script generate-slapt-repository - Generates slapt repository
+   (a decent script)
+
 0.10.1 Dec 12, 2008
  * fixed an initialization errror in slapt_is_required_by() that
    caused a segfault when removing with --no-deps.
Only in slapt-get-0.10.1: contrib
diff -ur slapt-get-0.10.1.orig/example.slapt-getrc slapt-get-0.10.1/example.slapt-getrc
--- slapt-get-0.10.1.orig/example.slapt-getrc	2008-12-13 19:11:56.000000000 +0100
+++ slapt-get-0.10.1/example.slapt-getrc	2009-02-16 12:10:17.000000000 +0100
@@ -3,12 +3,76 @@
 
 
 # exclude package names and expressions
-EXCLUDE=^kernel-.*,^glibc.*,.*-[0-9]+dl$,^devs$,^udev$,aaa_elflibs,x86_64
+EXCLUDE=^kernel-.*,^glibc.*,.*-[0-9]+dl$,^devs$,^udev$,aaa_elflibs
 # * to exclude pre and beta packages, add this as an exclude: 
 # [0-9\_\.\-]{1}pre[0-9\-\.\-]{1}
 # To exclude architectures such as i686, use the following:
 # [\_\-]+i686
 
+####################################################################
+#                      VARIABLE EXPANSION                          #
+####################################################################
+#
+#
+# You can use varibles in 'SOURCE' definitions. Variables are in form
+# of ${VARIABLE_NAME} and they are expanded at runtime, therefore you
+# can use the same slapt-getrc file on your slackware, slamd64 and
+# bluewhite64 hosts, even you have completely separated slapt-get
+# repositories for them.
+#
+#       Example:
+#
+#        DISTRO: slackware 12.2; hostname: slakware, kernel: 2.6.24
+#        DISTRO: slamd64 12.1; hostname: slamd; kernel 2.6.24-1
+#        DISTRO: bluewhite64 12.2; hostname: bluewhite; kernel: 2.6.24-2
+#
+#        VARIABLE NAME                     EXPANSION (slackware)  EXPANSION (slamd64)   EXPANSION (bluewhite64)
+#        ${ARCH}                           i686                   x86_64                x86_64
+#        ${UNAME_MACHINE}                  i686                   x86_64                x86_64
+#        ${HOSTNAME}                       slakware               slamd                 bluewhite
+#        ${UNAME_NODENAME}                 slakware               slamd                 bluewhite
+#        ${UNAME_RELEASE}                  2.6.24                 2.6.24-1              2.6.24-2
+#        ${KERNEL_VERSION}                 2.6.24                 2.6.24-1              2.6.24-2
+#        ${OS_TYPE}                        Linux                  Linux                 Linux
+#        ${UNAME_SYSNAME}                  Linux                  Linux                 Linux
+#        ${OS_TYPE_LC}                     linux                  linux                 linux
+#        ${UNAME_SYSNAME_LC}               linux                  linux                 linux
+#        ${DISTRO_TYPE}                    Slackware              Slamd64               Bluewhite64
+#        ${DISTRO_NAME}                    Slackware              Slamd64               Bluewhite64
+#        ${DISTRIBUTION}                   Slackware              Slamd64               Bluewhite64
+#        ${GENERIC_DISTRO_TYPE}            Slackware              Slackware             Slackware
+#        ${GENERIC_DISTRO_NAME}            Slackware              Slackware             Slackware
+#        ${GENERIC_DISTRO_TYPE_LC}         slackware              slackware             slackware
+#        ${GENERIC_DISTRO_NAME_LC}         slackware              slackware             slackware
+#        ${DISTRO_TYPE_LC}                 slackware              slamd64               bluewhite64
+#        ${DISTRO_NAME_LC}                 slackware              slamd64               bluewhite64
+#        ${DISTRIBUTION_LC}                slackware              slamd64               bluewhite64
+#        ${DISTRO_VERSION}                 12.2.0                 12.1.0                12.2.0
+#        ${DISTRIBUTION_VERSION}           12.2.0                 12.1.0                12.2.0
+#        ${DISTRO_VERSION_MAJOR}           12                     12                    12
+#        ${DISTRO_VERSION_MINOR}           2                      1                     2
+#        ${DISTRO_VERSION_BUILD}           0                      0                     0
+#
+#
+#SOURCE=http://repo.example.org/dist/${ARCH}/${DISTRO_NAME_LC}-${DISTRO_VERSION}/:CUSTOM
+#  expands to:
+#       http://repo.example.org/dist/i686/slackware-12.2.0/:CUSTOM      (slackware)
+#       http://repo.example.org/dist/x86_64/slamd64-12.1.0/:CUSTOM      (slamd64)
+#       http://repo.example.org/dist/x86_64/bluewhite64-12.2.0/:CUSTOM  (bluewhite64)
+#
+#SOURCE=http://repo.example.org/dist/noarch/${DISTRO_NAME_LC}-${DISTRO_VERSION}/:CUSTOM
+#  expands to:
+#       http://repo.example.org/dist/noarch/slackware-12.2.0/:CUSTOM      (slackware)
+#       http://repo.example.org/dist/noarch/slamd64-12.1.0/:CUSTOM        (slamd64)
+#       http://repo.example.org/dist/noarch/bluewhite64-12.2.0/:CUSTOM    (bluewhite64)
+#
+#SOURCE=http://repo.example.org/mirrors/${DISTRO_NAME_LC}-${DISTRO_VERSION_MAJOR}.${DISTRO_VERSION_MINOR}/:OFFICIAL
+#  expands to:
+#       http://repo.example.org/mirrors/slackware-12.2/:OFFICIAL      (slackware)
+#       http://repo.example.org/mirrors/slamd64-12.1/:OFFICIAL        (slamd64)
+#       http://repo.example.org/mirrors/bluewhite64-12.2/:OFFICIAL    (bluewhite64)
+#
+#
 
 # base url to directory with a PACKAGES.TXT
 # can point to any release, ie: 9.0, 10.0, current, etc
@@ -159,3 +223,5 @@
 #SOURCE=ftp://sunsite.pub.ro/pub/Linux/distributions/slackware/slackware-12.2/:OFFICIAL
 #SOURCE=http://slackware.itsoft.at/slackware/slackware-12.2/:OFFICIAL
 #SOURCE=ftp://slackware.itsoft.at/slackware/slackware-12.2/:OFFICIAL
+
+
diff -ur slapt-get-0.10.1.orig/Makefile slapt-get-0.10.1/Makefile
--- slapt-get-0.10.1.orig/Makefile	2008-12-14 20:25:57.000000000 +0100
+++ slapt-get-0.10.1/Makefile	2009-02-13 17:27:51.000000000 +0100
@@ -1,5 +1,5 @@
 PACKAGE=slapt-get
-VERSION=0.10.1
+VERSION=0.10.2
 ARCH=$(shell uname -m | sed -e "s/i[3456]86/i386/")
 LIBDIR=/usr/lib
 RELEASE=1
@@ -152,6 +152,7 @@
 	gzip pkg/usr/man/uk/man8/$(PACKAGE).8
 	mkdir -p pkg$(LIBDIR)
 	mkdir -p pkg/usr/include
+	cp contrib/generate-slapt-repository pkg/$(SBINDIR)
 	cp src/slapt.h pkg/usr/include/
 	cp src/libslapt.a src/libslapt.so.$(VERSION) pkg$(LIBDIR)/
 	strip pkg$(LIBDIR)/libslapt.so.$(VERSION)
diff -ur slapt-get-0.10.1.orig/src/configuration.c slapt-get-0.10.1/src/configuration.c
--- slapt-get-0.10.1.orig/src/configuration.c	2008-12-14 20:28:32.000000000 +0100
+++ slapt-get-0.10.1/src/configuration.c	2009-02-16 11:53:47.000000000 +0100
@@ -20,6 +20,8 @@
 /* parse the exclude list */
 static struct slapt_exclude_list *parse_exclude(char *line);
 
+struct utsname uname_buf;
+struct distro_info *d_i;
 
 slapt_rc_config *slapt_init_config(void)
 {
@@ -62,7 +64,7 @@
   rc = slapt_open_file(file_name,"r");
 
   if ( rc == NULL )
-    exit(EXIT_FAILURE);
+	return NULL;
 
   while ( (g_size = getline(&getline_buffer,&gb_length,rc) ) != EOF ) {
     char *token_ptr = NULL;
@@ -76,7 +78,6 @@
 
     if ( (token_ptr = strstr(getline_buffer,SLAPT_SOURCE_TOKEN)) != NULL ) {
       /* SOURCE URL */
-
       if ( strlen(token_ptr) > strlen(SLAPT_SOURCE_TOKEN) ) {
         slapt_source_t *s = slapt_init_source(token_ptr + strlen(SLAPT_SOURCE_TOKEN));
         if (s != NULL) {
@@ -178,6 +179,8 @@
 
 void slapt_free_rc_config(slapt_rc_config *global_config)
 {
+  if (global_config == NULL) return;
+
   slapt_free_exclude_list(global_config->exclude_list);
   slapt_free_source_list(global_config->sources);
   free(global_config);
@@ -496,9 +499,247 @@
     free(attribute_string);
   }
 
+  /** look for special ${SOMETHING} variables in url and replace them */
+  /* printf("BEFORE src->url = '%s'\n", src->url); */
+  slapt_url_rewrite(src->url);
+  /* printf("AFTER src->url = '%s'\n", src->url); */
+
   return src;
 }
 
+void slapt_url_rewrite (char *s) {
+	char result[SLAPT_REWRITE_RESULT_BUFLEN];
+	char var_name[SLAPT_REWRITE_RESULT_BUFLEN];
+	char var_repl[SLAPT_REWRITE_RESULT_BUFLEN];
+	int len, i, j, k, i_r, in_var, repl_len;
+
+	len = strlen(s);
+
+	if (s == NULL || len < 1)
+		return;
+	/** destroy content */
+	memset(result, '\0', SLAPT_REWRITE_RESULT_BUFLEN);
+	
+	/** look scan source and look for ${VAR_NAME} substrings */
+	i = i_r = in_var = j = 0;
+	while (i < len) {
+		/* is this start of variable? */
+		if (s[i] == '$' && (((i + 1) < len) && s[i + 1] == '{')) {
+			memset(var_name, '\0', SLAPT_REWRITE_RESULT_BUFLEN);
+			j = 0;
+			/* get variable name */
+			for (k = (i + 2); k < len; k++) {
+				if (s[k] == '}') {
+					break;
+				} else {
+					var_name[j] = s[k];
+					j++;
+				}
+			}
+			/* printf("VAR_NAME: '%s'\n'", var_name); */
+			/* move source pointer forward */
+			i = k + 1;
+
+			/** get variable replacement */
+			slapt_url_rewrite_get_var(var_name, var_repl, SLAPT_REWRITE_RESULT_BUFLEN);
+			repl_len = strlen(var_repl);
+			/* printf("VAR_REPL: '%s', len = '%d'\n", var_repl, repl_len); */
+			/* fprintf(stderr, "replaced var '%s' with '%s'.\n", var_name, var_repl); */
+			strncat(result, var_repl, repl_len);
+			i_r += repl_len ;
+		} else {
+			result[i_r] = s[i];
+			i_r++;
+			i++;
+		}
+	}
+
+	/* printf("Result: '%s'\n", result); */
+	len = strlen(result);
+
+	/** copy result buffer back to original buffer and resize it... */
+	s = realloc(s, (len + 1));
+	if (s != NULL) {
+		memset(s, '\0', (len + 1));
+		strncpy(s, result, len);
+	} else {
+		fprintf(stderr, "Unable to resize destination string buffer: %s\n", strerror(errno));
+		exit(EXIT_FAILURE);
+	}
+}
+
+void slapt_url_rewrite_get_var (char *var_name, char *dst, size_t limit) {
+	struct utsname uname_buf;
+	char *str;
+	int i, len;
+
+	if (var_name == NULL || dst == NULL) return;
+
+	/* get info about running system */
+	uname(&uname_buf);
+
+	/** create var values if they don't exist */
+	if (d_i == NULL) {
+		d_i = (struct distro_info *) malloc(sizeof(struct distro_info));
+		if (d_i == NULL) {
+			fprintf(stderr, "Unable to allocate memory for struct distro_info: %s\n", strerror(errno));
+			exit(EXIT_FAILURE);
+		}
+
+		/** wipe out buffers */
+		memset(d_i->distro_name, '\0', SLAPT_DISTRO_INFO_BUFLEN);
+		memset(d_i->distro_version_major, '\0', SLAPT_DISTRO_INFO_BUFLEN);
+		memset(d_i->distro_version_minor, '\0', SLAPT_DISTRO_INFO_BUFLEN);
+		memset(d_i->distro_version_build, '\0', SLAPT_DISTRO_INFO_BUFLEN);
+
+		/** fill buffers */
+		slapt_distro_info(d_i);
+	}
+
+	/* destroy anything in dst */
+	memset(dst, '\0', limit);
+
+	str = NULL;
+
+	/** write var name */
+	if (strcasecmp(var_name, "ARCH") == 0 || strcasecmp(var_name, "UNAME_MACHINE") == 0)
+		str = uname_buf.machine;
+	else if (strcasecmp(var_name, "HOSTNAME") == 0 || strcasecmp(var_name, "UNAME_NODENAME") == 0)
+		str = uname_buf.nodename;
+	else if (strcasecmp(var_name, "UNAME_RELEASE") == 0 || strcasecmp(var_name, "KERNEL_VERSION") == 0)
+		str = uname_buf.release;
+	else if (strcasecmp(var_name, "OS_TYPE") == 0 || strcasecmp(var_name, "UNAME_SYSNAME") == 0)
+		str = uname_buf.sysname;
+	else if (strcasecmp(var_name, "OS_TYPE_LC") == 0 || strcasecmp(var_name, "UNAME_SYSNAME_LC") == 0) {
+		snprintf(dst, limit, "%s", uname_buf.sysname);
+		i = 0;
+		len = strlen(dst);
+		for (i = 0; i < len; i++)
+			dst[i] = tolower(dst[i]);
+	}
+	else if (strcasecmp(var_name, "DISTRO_TYPE") == 0 || strcasecmp(var_name, "DISTRO_NAME") == 0 || strcasecmp(var_name, "DISTRIBUTION") == 0)
+		str = d_i->distro_name;
+	else if (strcasecmp(var_name, "GENERIC_DISTRO_TYPE") == 0 || strcasecmp(var_name, "GENERIC_DISTRO_NAME") == 0)
+		str = SLAPT_DISTRO_GENERIC_NAME;
+	else if (strcasecmp(var_name, "GENERIC_DISTRO_TYPE_LC") == 0 || strcasecmp(var_name, "GENERIC_DISTRO_NAME_LC") == 0) {
+		snprintf(dst, limit, "%s", SLAPT_DISTRO_GENERIC_NAME);
+		i = 0;
+		len = strlen(dst);
+		for (i = 0; i < len; i++)
+			dst[i] = tolower(dst[i]);
+	}
+	else if (strcasecmp(var_name, "DISTRO_TYPE_LC") == 0 || strcasecmp(var_name, "DISTRO_NAME_LC") == 0 || strcasecmp(var_name, "DISTRIBUTION_LC") == 0) {
+		snprintf(dst, limit, "%s", d_i->distro_name);
+		i = 0;
+		len = strlen(dst);
+		for (i = 0; i < len; i++)
+			dst[i] = tolower(dst[i]);
+	}
+	else if (strcasecmp(var_name, "DISTRO_VERSION") == 0 || strcasecmp(var_name, "DISTRIBUTION_VERSION") == 0) {
+		snprintf(
+			dst,
+			limit,
+			"%s.%s.%s",
+			d_i->distro_version_major,
+			d_i->distro_version_minor,
+			d_i->distro_version_build
+		);
+	}
+	else if (strcasecmp(var_name, "DISTRO_VERSION_MAJOR") == 0)
+		str = d_i->distro_version_major;
+	else if (strcasecmp(var_name, "DISTRO_VERSION_MINOR") == 0)
+		str = d_i->distro_version_minor;
+	else if (strcasecmp(var_name, "DISTRO_VERSION_BUILD") == 0)
+		str = d_i->distro_version_build;
+	else
+		fprintf(stderr, "WARNING: Unsupported configuration variable name: ${%s}; replacing with empty string.\n", var_name);
+
+	if (str != NULL)
+		snprintf(dst, limit, "%s", str);
+}
+
+void slapt_distro_info(struct distro_info *d) {
+	FILE *fp;
+	char **f;
+	int i, len, j;
+	char buf[SLAPT_REWRITE_RESULT_BUFLEN];
+
+	/* file list */
+	char *distro_versions[] = {
+		"/etc/slackware-version",
+		"/etc/bluewhite64-version",
+		"/etc/slamd64-version"
+	};
+
+	/* try to open any file */
+	f = distro_versions;
+	while (f != NULL) {
+		if (f == NULL) break;
+		/* printf("Opening file: '%s'\n", *f); */
+		fp = fopen(*f, "r");
+		if (fp != NULL)	break;
+		f++;
+	}
+
+
+	/* none of listed files were opened? */
+	if (fp == NULL) return;
+
+
+	memset(buf, '\0', SLAPT_REWRITE_RESULT_BUFLEN);
+	fgets(buf, (SLAPT_REWRITE_RESULT_BUFLEN - 1), fp);
+	fclose(fp);
+
+	/* printf("PARSING: '%s'", buf); */
+
+
+	i = 0;
+	len = strlen(buf);
+
+	/** skip until last space */
+
+	/* extract distribution name: (example: Slackware) */
+	while (i < len && buf[i] != ' ') {
+		/* printf("NAME: %c\n", buf[i]); */
+		d->distro_name[i] = buf[i];
+		i++;
+	}
+
+	/* skip spaces */
+	while (i < len && isspace(buf[i])) i++;
+
+	/* extract version number: (example: 12.0.0.) */
+	j = 0;
+	while (i < len && isdigit(buf[i])) {
+		/* printf("MAJOR: %c\n", buf[i]); */
+		d->distro_version_major[j] = buf[i];
+		i++;
+		j++;
+	}
+
+	/* skip spaces && dots*/
+	while (i < len && (buf[i] == '.' || isspace(buf[i]))) i++;
+
+	j = 0;
+	while (i < len && isdigit(buf[i])) {
+		/* printf("MINOR: %c\n", buf[i]); */
+		d->distro_version_minor[j] = buf[i];
+		i++;
+		j++;
+	}
+
+	/* skip spaces && dots*/
+	while (i < len && (buf[i] == '.' || isspace(buf[i]))) i++;
+
+	j = 0;
+	while (i < len && isdigit(buf[i])) {
+		/* printf("BUILD: %c\n", buf[i]); */
+		d->distro_version_build[j] = buf[i];
+		i++;
+		j++;
+	}
+}
+
 void slapt_free_source(slapt_source_t *src)
 {
   free(src->url);
diff -ur slapt-get-0.10.1.orig/src/configuration.h slapt-get-0.10.1/src/configuration.h
--- slapt-get-0.10.1.orig/src/configuration.h	2008-12-14 20:28:32.000000000 +0100
+++ slapt-get-0.10.1/src/configuration.h	2009-02-16 11:33:44.000000000 +0100
@@ -5,6 +5,16 @@
 #define SLAPT_WORKINGDIR_TOKEN_LEN 256
 #define SLAPT_EXCLUDE_TOKEN "EXCLUDE="
 #define SLAPT_SOURCE_ATTRIBUTE_REGEX "(:[A-Z_,]+)$"
+#define SLAPT_REWRITE_RESULT_BUFLEN 1025
+#define SLAPT_DISTRO_INFO_BUFLEN 64
+#define SLAPT_DISTRO_GENERIC_NAME "Slackware"
+
+struct distro_info {
+	char distro_name[SLAPT_DISTRO_INFO_BUFLEN];
+	char distro_version_major[SLAPT_DISTRO_INFO_BUFLEN];
+	char distro_version_minor[SLAPT_DISTRO_INFO_BUFLEN];
+	char distro_version_build[SLAPT_DISTRO_INFO_BUFLEN];
+};
 
 struct slapt_exclude_list {
   char **excludes;
@@ -80,3 +90,8 @@
 SLAPT_BOOL_T slapt_is_interactive(const slapt_rc_config *);
 
 int slapt_write_rc_config(const slapt_rc_config *global_config, const char *location);
+
+void slapt_url_rewrite(char *s);
+void slapt_url_rewrite_get_var (char *var_name, char *dst, size_t limit);
+void slapt_distro_info(struct distro_info *d_i);
+
diff -ur slapt-get-0.10.1.orig/src/main.c slapt-get-0.10.1/src/main.c
--- slapt-get-0.10.1.orig/src/main.c	2008-11-23 21:31:33.000000000 +0100
+++ slapt-get-0.10.1/src/main.c	2009-02-13 17:23:51.000000000 +0100
@@ -29,7 +29,7 @@
   slapt_pkg_action_args_t *paa;
 
   int c = 0;
-  enum slapt_action do_action = 0;
+  enum slapt_action do_action = -1;
   int option_index = 0;
   static struct option long_options[] = {
     {"update", 0, 0, SLAPT_UPDATE_OPT},
@@ -93,7 +93,7 @@
   /* load up the configuration file */
   global_config = slapt_read_rc_config(RC_LOCATION);
   if ( global_config == NULL ) {
-    exit(EXIT_FAILURE);
+    /*/exit(EXIT_FAILURE); */
   }
   curl_global_init(CURL_GLOBAL_ALL);
 
@@ -161,7 +161,8 @@
         break;
       case SLAPT_HELP_OPT: /* help */
         usage();
-        slapt_free_rc_config(global_config);
+	if (global_config != NULL)
+          slapt_free_rc_config(global_config);
         curl_global_cleanup();
         exit(EXIT_FAILURE);
       case SLAPT_IGNORE_DEP_OPT: /* ignore-dep */
@@ -261,10 +262,88 @@
       break;
 
     default:
-      if (optind < argc)
-        do_action = USAGE;
+  	/** patch start */
+	if (argv[optind] == NULL)
+		break;
+
+	if (strcasecmp(argv[optind], "update") == 0 || strcasecmp(argv[optind], "u") == 0) {
+		do_action = UPDATE;
+		optind++;
+	}
+	else if (strcasecmp(argv[optind], "upgrade") == 0) {
+		do_action = UPGRADE;
+		optind++;
+	}
+	else if (strcasecmp(argv[optind], "dist-upgrade") == 0) {
+		global_config->dist_upgrade = SLAPT_TRUE;
+		do_action = UPGRADE;
+		optind++;
+	}
+	else if (strcasecmp(argv[optind], "install") == 0 || strcasecmp(argv[optind], "i") == 0) {
+		do_action = INSTALL;
+		optind++;
+	}
+	else if (strcasecmp(argv[optind], "install-set") == 0) {
+		do_action = INSTALL_DISK_SET;
+		optind++;
+	}
+	else if (strcasecmp(argv[optind], "remove") == 0) {
+		do_action = REMOVE;
+		optind++;
+	}
+	else if (strcasecmp(argv[optind], "show") == 0) {
+		do_action = SHOW;
+		global_config->simulate = SLAPT_TRUE; /* allow read access */
+		optind++;
+	}
+	else if (strcasecmp(argv[optind], "search") == 0) {
+		do_action = SEARCH;
+		global_config->simulate = SLAPT_TRUE; /* allow read access */
+		optind++;
+	}
+	else if (strcasecmp(argv[optind], "list") == 0) {
+		do_action = LIST;
+		global_config->simulate = SLAPT_TRUE; /* allow read access */
+		optind++;
+	}
+	else if (strcasecmp(argv[optind], "available") == 0) {
+		do_action = AVAILABLE;
+		global_config->simulate = SLAPT_TRUE; /* allow read access */
+		optind++;
+	}
+	else if (strcasecmp(argv[optind], "installed") == 0) {
+		do_action = INSTALLED;
+		global_config->simulate = SLAPT_TRUE; /* allow read access */
+		optind++;
+	}
+	else if (strcasecmp(argv[optind], "clean") == 0) {
+		do_action = CLEAN;
+		optind++;
+	}
+	else if (strcasecmp(argv[optind], "autoclean") == 0) {
+		do_action = AUTOCLEAN;
+		optind++;
+	}
+	#ifdef SLAPT_HAS_GPGME
+	else if (strcasecmp(argv[optind], "add-keys") == 0) {
+		do_action = ADD_KEYS;
+		optind++;
+	}
+	#endif
+	else if (strcasecmp(argv[optind], "help") == 0) {
+		do_action = USAGE;
+		optind++;
+	}
+	else if (strcasecmp(argv[optind], "version") == 0) {
+		do_action = SHOWVERSION;
+		optind++;
+	} else {
+		do_action = USAGE;
+	}
+
       break;
   }
+  /** patch end */
 
   if ( do_action == USAGE ) {
     usage();
diff -ur slapt-get-0.10.1.orig/src/main.h slapt-get-0.10.1/src/main.h
--- slapt-get-0.10.1.orig/src/main.h	2008-03-09 05:06:09.000000000 +0100
+++ slapt-get-0.10.1/src/main.h	2009-01-27 11:59:34.000000000 +0100
@@ -40,6 +40,7 @@
 #include <sys/mman.h>
 #include <zlib.h>
 #include <utime.h>
+#include <sys/utsname.h>
 
 #include "common.h"
 #include "configuration.h"
