--- xpenguins-2.2.orig/debian/patches/01_HOMEsegfault.patch
+++ xpenguins-2.2/debian/patches/01_HOMEsegfault.patch
@@ -0,0 +1,117 @@
+--- bla/src/xpenguins_theme.orig	Tue Oct  2 00:36:12 2001
++++ bla/src/xpenguins_theme.c	Sat Nov 30 19:30:49 2002
+@@ -153,28 +153,32 @@
+   char *home_root = XPENGUINS_USER_DIRECTORY;
+   char *themes = XPENGUINS_THEME_DIRECTORY;
+   char *config = XPENGUINS_CONFIG;
+-  char *config_path, *tmp_path;
++  char *config_path=NULL, *tmp_path;
+   char *list = NULL;
+   char **list_array = NULL;
+   int list_len = 0;
+   int i, string_length = 0;
+   glob_t globbuf;
++  int sys_glob_mode=0;
+   int n = 0;
+-
+-  /* First add themes from the users home directory */
+-  string_length = strlen(home) + strlen(home_root)
+-    + strlen(themes) + 2 + strlen(config) + 1;
+-  config_path = malloc(string_length);
+-  if (!config_path) {
+-    xpenguins_out_of_memory();
+-    return NULL;
+-  }
+-  snprintf(config_path, string_length, "%s%s%s/*%s",
+-	   home, home_root, themes, config);
+-  if (glob(config_path, 0, NULL, &globbuf) == GLOB_NOSPACE) {
+-    free(config_path);
+-    xpenguins_out_of_memory();
+-    return NULL;
++ 
++  if (home != NULL) {
++    /* First add themes from the users home directory */
++    string_length = strlen(home) + strlen(home_root)
++      + strlen(themes) + 2 + strlen(config) + 1;
++    config_path = malloc(string_length);
++    if (!config_path) {
++      xpenguins_out_of_memory();
++      return NULL;
++    }
++    snprintf(config_path, string_length, "%s%s%s/*%s",
++	     home, home_root, themes, config);
++    if (glob(config_path, 0, NULL, &globbuf) == GLOB_NOSPACE) {
++      free(config_path);
++      xpenguins_out_of_memory();
++      return NULL;
++    }
++    sys_glob_mode=GLOB_APPEND;
+   }
+ 
+   /* Then add system themes */
+@@ -192,7 +196,7 @@
+   }
+   snprintf(config_path, string_length, "%s%s/*%s",
+ 	   xpenguins_directory, themes, config);
+-  if (glob(config_path, GLOB_APPEND, NULL, &globbuf) == GLOB_NOSPACE) {
++  if (glob(config_path, sys_glob_mode, NULL, &globbuf) == GLOB_NOSPACE) {
+     free(config_path);
+     xpenguins_out_of_memory();
+     return NULL;
+@@ -338,30 +342,33 @@
+   int string_length = 0, root_length;
+   struct stat stat_buf;
+ 
+-  /* First look in $HOME/.xpenguins/themes for config */
+-  root_length = strlen(home) + strlen(home_root) + strlen(themes) + 1;
+-  string_length = root_length + strlen(name) + strlen(config) + 1;
+-  config_path = malloc(string_length);
+-  if (!config_path) {
+-    xpenguins_out_of_memory();
+-    return NULL;
+-  }
+-  snprintf(config_path, string_length, "%s%s%s/%s%s",
+-	   home, home_root, themes, name, config);
+-  /* Convert spaces to underscores */
+-  ch = config_path + root_length;
+-  while (*ch != '/') {
+-    if (*ch == ' ') {
+-      *ch = '_';
+-    }
+-    ++ch;
+-  }
+-  /* See if theme exists */
+-  if (stat(config_path, &stat_buf) == 0) {
+-    config_path[string_length-strlen(config)-1] = '\0';
+-    return config_path;
++  if(home!=NULL) {
++    /* First look in $HOME/.xpenguins/themes for config */
++    root_length = strlen(home) + strlen(home_root) + strlen(themes) + 1;
++    string_length = root_length + strlen(name) + strlen(config) + 1;
++    config_path = malloc(string_length);
++    if (!config_path) {
++      xpenguins_out_of_memory();
++      return NULL;
++    }
++    snprintf(config_path, string_length, "%s%s%s/%s%s",
++	     home, home_root, themes, name, config);
++    /* Convert spaces to underscores */
++    ch = config_path + root_length;
++    while (*ch != '/') {
++      if (*ch == ' ') {
++	*ch = '_';
++      }
++      ++ch;
++    }
++    /* See if theme exists */
++    if (stat(config_path, &stat_buf) == 0) {
++      config_path[string_length-strlen(config)-1] = '\0';
++      return config_path;
++    }
++    /* Theme not found in users theme directory... */
+   }
+-  /* Theme not found in users theme directory... */
++
+   /* Now look in [xpenguins_directory]/themes for config */
+   root_length = strlen(xpenguins_directory) + strlen(themes) + 1;
+   string_length = root_length + strlen(name) + strlen(config) + 1;
--- xpenguins-2.2.orig/debian/patches/02_randomtheme.patch
+++ xpenguins-2.2/debian/patches/02_randomtheme.patch
@@ -0,0 +1,73 @@
+--- bla/src/main.c.orig	Tue Oct  2 08:34:17 2001
++++ bla/src/main.c	Fri Oct 26 16:24:08 2001
+@@ -92,6 +92,7 @@
+   char rectangular_windows = 0;
+   char load_message = 0;
+   char all_themes = 0;
++  char random_theme = 0;
+ 
+   theme_names = malloc(2 * sizeof(char *));
+   theme_names[0] = DEFAULT_THEME;
+@@ -206,6 +207,9 @@
+     else if (LongArgumentIs("-all")) {
+       all_themes = 1;
+     }
++    else if (LongArgumentIs("-random-theme")) {
++      random_theme = 1;
++    }
+     else if (LongArgumentIs("-id")) {
+       if (argc > ++n) {
+ 	Window id;
+@@ -276,6 +280,32 @@
+   else if (describe_theme) {
+     DescribeThemes(theme_names);
+   }
++  else if (random_theme) {
++    char **tmp_list = xpenguins_list_themes(NULL);
++    if (tmp_list) {
++      srand(getpid() ^ time(NULL));
++
++      /* we need to count how many themes there are */
++      for(nthemes = 0; tmp_list[nthemes] != NULL; nthemes++) {
++      }
++      
++      free(theme_names);
++
++      theme_names = malloc(2 * sizeof(char *));
++      nthemes = rand() % nthemes;
++      theme_names[0] = strdup(tmp_list[nthemes]);
++      theme_names[1] = NULL;
++
++      /* we probably should free tmp_list and its contents */
++      /* not sure why but we get a segfault if we free the contents */
++      free(tmp_list);
++
++      if (xpenguins_verbose) {
++	fprintf(stderr, _("Selected random theme - '%s'\n"),
++	        theme_names[0]);
++      }
++    }
++  }
+ 
+   if (ignore_popups) {
+     xpenguins_ignorepopups(1);
+@@ -412,6 +442,7 @@
+ 	    "  -a, --no-angels                   Do not show any cherubim\n"
+ 	    "  -s, --squish                      kill penguins with mouse\n"
+ 	    "      --all                         Run all available themes simultaneously\n"
++	    "      --random-theme                Choose a random theme\n"
+ 	    "      --id             <window id>  Send penguins to window with this ID\n"
+ 	    "      --nice           <ld1> <ld2>  Start killing penguins when load reaches\n"
+ 	    "                                       <ld1>, kill all if load reches <ld2>\n"
+--- bla/xpenguins.1.orig	2001-10-02 01:07:03.000000000 +0200
++++ bla/xpenguins.1	2004-02-11 17:22:58.000000000 +0100
+@@ -50,6 +50,9 @@
+ .B "\-t"
+ option to select the theme to describe.
+ .TP 8
++.B "\-\-random\-theme"
++Start with a random theme.
++.TP 8
+ .B "\-l, \-\-list\-themes"
+ List the available themes, one on each line, and exit.
+ .TP 8
--- xpenguins-2.2.orig/debian/menu
+++ xpenguins-2.2/debian/menu
@@ -0,0 +1,4 @@
+?package(xpenguins):needs="x11" section="Games/Toys" \
+	title="xpenguins - start" command="xpenguins"
+?package(xpenguins):needs="x11" section="Games/Toys" \
+        title="xpenguins - stop" command="kill -TERM `pidof xpenguins`"
--- xpenguins-2.2.orig/debian/changelog
+++ xpenguins-2.2/debian/changelog
@@ -0,0 +1,56 @@
+xpenguins (2.2-2) unstable; urgency=low
+
+  * Fixed segfault when $HOME is not set (closes: #171289)
+    (thanks to Sebastian Waschik for the patch)
+  * Added option to select a random theme on start (closes: #117139)
+    (thanks to Jason Thomas for the patch)
+
+ -- Bas Zoetekouw <bas@debian.org>  Wed, 11 Feb 2004 17:19:59 +0100
+
+xpenguins (2.2-1) unstable; urgency=low
+
+  * New upstream release (closes: #110067)
+  * Added an rm of config.status in the clean target
+
+ -- Bas Zoetekouw <bas@debian.org>  Sat, 13 Oct 2001 18:38:45 +0200
+
+xpenguins (2.1-2) unstable; urgency=low
+
+  * Removed Build-depends on libc6-dev 
+
+ -- Bas Zoetekouw <bas@debian.org>  Mon,  9 Jul 2001 11:32:45 +0200
+
+xpenguins (2.1-1) unstable; urgency=low
+
+  * New upstream release (closes: #100556)
+
+ -- Bas Zoetekouw <bas@debian.org>  Thu, 28 Jun 2001 10:04:37 +0200
+
+xpenguins (1.2-4) unstable; urgency=low
+
+  * Added a menu item to stop xpenguins (closes: #86815) 
+
+ -- Bas Zoetekouw <bas@debian.org>  Sun, 22 Apr 2001 21:39:16 +0200
+
+xpenguins (1.2-3) unstable; urgency=low
+
+  * Added a Build-Depends on debhelper. 
+  * This package does now comply to Standards-Version 3.2.1
+
+ -- Bas Zoetekouw <bas@debian.org>  Mon,  8 Jan 2001 19:42:20 +0100
+
+xpenguins (1.2-2) unstable; urgency=low
+
+  * Fixed the short description (closes: #80430) 
+
+ -- Bas Zoetekouw <bas@debian.org>  Wed, 27 Dec 2000 13:19:40 +0100
+
+xpenguins (1.2-1) unstable; urgency=low
+
+  * Initial Release.
+
+ -- Bas Zoetekouw <bas@debian.org>  Sun,  6 Aug 2000 11:19:56 +0200
+
+Local variables:
+mode: debian-changelog
+End:
--- xpenguins-2.2.orig/debian/rules
+++ xpenguins-2.2/debian/rules
@@ -0,0 +1,101 @@
+#!/usr/bin/make -f
+# Sample debian/rules that uses debhelper.
+# GNU copyright 1997 to 1999 by Joey Hess.
+
+# Uncomment this to turn on verbose mode.
+#export DH_VERBOSE=1
+
+# This is the debhelper compatability version to use.
+export DH_COMPAT=1
+
+DESTDIR = `pwd`/debian/tmp
+
+build: build-stamp
+build-stamp: patch
+	dh_testdir
+
+	
+	# Add here commands to compile the package.
+	./configure --prefix=/usr --mandir=/usr/share/man
+	$(MAKE)
+
+	touch build-stamp
+
+clean: unpatch
+	dh_testdir
+	dh_testroot
+
+	-$(MAKE) clean
+	-rm -f {.,src,themes,themes/*}/Makefile config.{h,log} xpenguins.spec stamp-h
+
+	rm -f build-stamp config.cache config.status
+	dh_clean
+
+patch:
+	for p in debian/patches/*.patch; do \
+		if [ ! -e $${p}-stamp ]; then \
+			echo Applying patch $${p}; \
+			patch -s -p1 < $${p}; \
+			touch blabli  $${p}-stamp; \
+		else \
+			echo Skipping patch $$p: already applied; \
+		fi \
+	done;
+
+unpatch:
+	for p in debian/patches/*.patch; do \
+		if [ -e $${p}-stamp ]; then \
+			echo "Unapplying patch $${p}"; \
+			patch -s -p1 -R < $${p}; \
+			rm $${p}-stamp; \
+		else \
+			echo "Skipping patch $$p: wasn't applied"; \
+		fi \
+	done;
+
+install: build
+	dh_testdir
+	dh_testroot
+	dh_clean -k
+	dh_installdirs
+
+	# Add here commands to install the package into debian/tmp.
+	$(MAKE) install DESTDIR=`pwd`/debian/tmp
+
+
+# Build architecture-independent files here.
+binary-indep: build install
+# We have nothing to do by default.
+
+# Build architecture-dependent files here.
+binary-arch: build install
+#	dh_testversion
+	dh_testdir
+	dh_testroot
+#	dh_installdebconf	
+	dh_installdocs
+	dh_installexamples
+	dh_installmenu
+#	dh_installemacsen
+#	dh_installpam
+#	dh_installinit
+	dh_installcron
+	dh_installmanpages
+	dh_installinfo
+#	dh_undocumented
+	dh_installchangelogs ChangeLog
+	dh_link
+	dh_strip
+	dh_compress
+	dh_fixperms
+#	dh_suidregister
+#	dh_makeshlibs
+	dh_installdeb
+#	dh_perl
+	dh_shlibdeps
+	dh_gencontrol
+	dh_md5sums
+	dh_builddeb
+
+binary: binary-indep binary-arch
+.PHONY: build clean binary-indep binary-arch binary install patch unpatch
--- xpenguins-2.2.orig/debian/copyright
+++ xpenguins-2.2/debian/copyright
@@ -0,0 +1,12 @@
+This package was debianized by Bas Zoetekouw <bas@debian.org> on
+Sun,  6 Aug 2000 11:19:56 +0200.
+
+It was downloaded from http://xpenguins.seul.org
+
+Upstream Author: Robin Hogan <r.j.hogan@reading.ac.uk>
+
+You are free to distribute this software under the terms of the GNU
+General Public License, version 2.0.  
+On Debian systems, the complete text of the GNU General Public License
+can be found in /usr/share/common-licenses/GPL file.
+
--- xpenguins-2.2.orig/debian/control
+++ xpenguins-2.2/debian/control
@@ -0,0 +1,15 @@
+Source: xpenguins
+Section: games
+Priority: optional
+Maintainer: Bas Zoetekouw <bas@debian.org>
+Standards-Version: 3.2.1
+Build-Depends: xlibs-dev, debhelper, patch
+
+Package: xpenguins
+Architecture: any
+Depends: ${shlibs:Depends}
+Description: little penguins walk on your windows
+ Ever wanted cute little penguins walking along the tops of your
+ windows? Ever wanted to send an army of cute little penguins to invade
+ the screen of someone else on your network? Probably not, but why not
+ try this program out anyway, it's cool!
--- xpenguins-2.2.orig/debian/watch
+++ xpenguins-2.2/debian/watch
@@ -0,0 +1,2 @@
+# Site		Directory		Pattern			Version	Script
+http://xpenguins.seul.org/	/	xpenguins-(.*)\.tar\.gz	debian
--- xpenguins-2.2.orig/debian/dirs
+++ xpenguins-2.2/debian/dirs
@@ -0,0 +1,2 @@
+usr/bin
+usr/share/man/man1
--- xpenguins-2.2.orig/debian/docs
+++ xpenguins-2.2/debian/docs
@@ -0,0 +1 @@
+README
