Index: trunk/debbuild
===================================================================
--- trunk/debbuild	(revision 196)
+++ trunk/debbuild	(revision 198)
@@ -363,4 +363,5 @@
 if ($cmdopts{type} eq 't') {
   # Need to unpack the tarball to find the spec file.  Sort of the inverse of -b above.
+  # Note that rpmbuild doesn't seem to support this operation from a .zip file, so neither will we.
   # zcat $tarball |tar -t |grep .spec
   # collect some info about the tarball
@@ -913,5 +914,8 @@
 #   Looks to be "expand -a into $aftersource and expand -b into $beforesource inside the while()"
 #   instead of treating them as flags like the other arguments.
+# Known differences
 # - -q appears to be somewhat positional
+# - rpmbuild requires -n on all %setup macros, but carries the first down to %install etc,
+#   debbuild sets the global on the first call, and keeps using it for further %setup calls
 
         $prepscript .= "cd '$topdir/BUILD'\n";
@@ -922,11 +926,18 @@
         if ($deftarball) {
           $prepscript .= "cd '$tarballdir'\n" if $changedir;
-          $prepscript .=
+          if ($pkgdata{main}{source} =~ /\.zip$/) {
+            # .zip files are not really tarballs
+            $prepscript .= "/usr/bin/unzip".
+		( $quietunpack ? ' -qq ' : ' ' ).
+		"'$topdir/SOURCES/$pkgdata{main}{source}'";
+          } else {
+            $prepscript .=
 		( $pkgdata{main}{source} =~ /\.tar\.gz$/  ? "/bin/gzip"   : "" ).
 		( $pkgdata{main}{source} =~ /\.tar\.bz2$/ ? "/bin/bzip2"  : "" ).
 		( $pkgdata{main}{source} =~ /\.tar\.xz$/  ? "/usr/bin/xz" : "" ).
 		" -dc '$topdir/SOURCES/$pkgdata{main}{source}' | /bin/tar -x".
-		( $quietunpack ? '' : 'vv' )."f -\n".
-		qq(STATUS=\$?\nif [ \$STATUS -ne 0 ]; then\n  exit \$STATUS\nfi\n);
+		( $quietunpack ? '' : 'vv' )."f - ";
+          }
+          $prepscript .= qq(\nSTATUS=\$?\nif [ \$STATUS -ne 0 ]; then\n  exit \$STATUS\nfi\n);
         }
 
@@ -934,21 +945,35 @@
           if ($altsource == 1) { # -a
             $prepscript .= "cd '$tarballdir'\n";
-            $prepscript .=
+            if ($pkgdata{sources}{$snum} =~ /\.zip$/) {
+              # .zip files are not really tarballs
+              $prepscript .= "/usr/bin/unzip".
+		( $quietunpack ? ' -qq ' : ' ' ).
+		"'$topdir/SOURCES/$pkgdata{sources}{$snum}'";
+            } else {
+              $prepscript .=
 		( $pkgdata{sources}{$snum} =~ /\.tar\.gz$/  ? "/bin/gzip"   : "" ).
 		( $pkgdata{sources}{$snum} =~ /\.tar\.bz2$/ ? "/bin/bzip2"  : "" ).
 		( $pkgdata{sources}{$snum} =~ /\.tar\.xz$/  ? "/usr/bin/xz" : "" ).
 		" -dc '$topdir/SOURCES/$pkgdata{sources}{$snum}' | /bin/tar -x".
-		( $quietunpack ? '' : 'vv' )."f -\n".
-		qq(STATUS=\$?\nif [ \$STATUS -ne 0 ]; then\n  exit \$STATUS\nfi\n);
+		( $quietunpack ? '' : 'vv' )."f -";
+            }
+            $prepscript .= qq(\nSTATUS=\$?\nif [ \$STATUS -ne 0 ]; then\n  exit \$STATUS\nfi\n);
           } # $altsource == 1
 
           if ($altsource == 2) { # -b
-            $prepscript .=
+            if ($pkgdata{sources}{$snum} =~ /\.zip$/) {
+              # .zip files are not really tarballs
+              $prepscript .= "/usr/bin/unzip".
+		( $quietunpack ? ' -qq ' : ' ' ).
+		"'$topdir/SOURCES/$pkgdata{main}{source}'";
+            } else {
+              $prepscript .=
 		( $pkgdata{sources}{$snum} =~ /\.tar\.gz$/  ? "/bin/gzip"   : "" ).
 		( $pkgdata{sources}{$snum} =~ /\.tar\.bz2$/ ? "/bin/bzip2"  : "" ).
 		( $pkgdata{sources}{$snum} =~ /\.tar\.xz$/  ? "/usr/bin/xz" : "" ).
 		" -dc '$topdir/SOURCES/$pkgdata{sources}{$snum}' | /bin/tar -x".
-		( $quietunpack ? '' : 'vv' )."f -\n".
-		qq(STATUS=\$?\nif [ \$STATUS -ne 0 ]; then\n  exit \$STATUS\nfi\n);
+		( $quietunpack ? '' : 'vv' )."f -";
+            }
+            $prepscript .= qq(\nSTATUS=\$?\nif [ \$STATUS -ne 0 ]; then\n  exit \$STATUS\nfi\n);
             $prepscript .= "cd '$tarballdir'\n";
           } # $altsource == 2
@@ -1146,6 +1171,6 @@
         $pkgdata{main}{source} =~ s|^.+/([^/]+)$|$1|;
         $pkgdata{sources}{0} = $pkgdata{main}{source};
-	# .tar, .tar.gz, .tar.bz2, .tgz, .xz
-        die "Unknown Source: header format $sval\n" if $sval !~ /\.(?:tar(?:\.(?:gz|bz2|xz))?|tgz)$/;
+	# .tar, .tar.gz, .tar.bz2, .tgz, .xz, .zip
+        die "Unknown Source: header format $sval\n" if $sval !~ /\.(?:tar(?:\.(?:gz|bz2|xz))?|tgz|zip)$/;
       } elsif (my ($srcnum, $src) = (/^source([0-9]+):\s*(.+)/i)) {
         $src =~ s/\s*$//;
