
Package: zlib-bin
Version: 1:1.1.3-16
Severity: normal
Tags: patch

The r-base package used zip and unzip to manage example and help files. As
Debian has only minizip / miniunzip in main, the different feature set
between the "mini" and full version of unzip creates a problem -- in
particular the "-d extractdir" option of unzip.

Attached is a small patch to contrib/miniunz.c which provides this
features (as well as correcting a typo in the URL that is displayed). The
contributed Debian manual page is updated accordingly (and corrected: there
is no option of specifying several files; everything past the first file is
discarded). 

Regards, Dirk

[Rediffed against minizip 1.0 
 --broonie]


--- zlib-1.2.1/contrib/minizip/miniunz.c.orig	2003-09-10 09:00:16.000000000 +0100
+++ zlib-1.2.1/contrib/minizip/miniunz.c	2003-11-17 22:52:30.000000000 +0000
@@ -27,7 +27,7 @@
   mini unzip, demo of unzip package
 
   usage :
-  Usage : miniunz [-exvlo] file.zip [file_to_extract]
+  Usage : miniunz [-exvlo] file.zip [file_to_extract] [-d extractdir]
 
   list the file in the zipfile, and print the content of FILE_ID.ZIP or README.TXT
     if it exists
@@ -146,11 +146,12 @@
 
 void do_help()
 {
-    printf("Usage : miniunz [-e] [-x] [-v] [-l] [-o] [-p password] file.zip [file_to_extr.]\n\n" \
+    printf("Usage : miniunz [-e] [-x] [-v] [-l] [-o] [-p password] file.zip [file_to_extr.] [-d extractdir]\n\n" \
            "  -e  Extract without pathname (junk paths)\n" \
            "  -x  Extract with pathname\n" \
            "  -v  list files\n" \
            "  -l  list files\n" \
+	   "  -d  directory to extract into\n" \
            "  -o  overwrite files without prompting\n" \
            "  -p  extract crypted file using password\n\n");
 }
@@ -459,6 +460,8 @@
     int opt_do_extract=1;
     int opt_do_extract_withoutpath=0;
     int opt_overwrite=0;
+    int opt_extractdir=0;
+    const char *dirname=NULL;
     unzFile uf=NULL;
 
     do_banner();
@@ -488,6 +491,10 @@
                         opt_do_extract = opt_do_extract_withoutpath = 1;
                     if ((c=='o') || (c=='O'))
                         opt_overwrite=1;
+		    if ((c=='d') || (c=='D')) {
+			opt_extractdir=1;
+			dirname=argv[i+1];
+		    }
                     if (((c=='p') || (c=='P')) && (i+1<argc))
                     {
                         password=argv[i+1];
@@ -499,7 +506,7 @@
             {
                 if (zipfilename == NULL)
                     zipfilename = argv[i];
-                else if (filename_to_extract==NULL)
+                else if (filename_to_extract==NULL && !opt_extractdir)
                         filename_to_extract = argv[i] ;
             }
         }
@@ -544,6 +551,10 @@
         return do_list(uf);
     else if (opt_do_extract==1)
     {
+      if (opt_extractdir && chdir(dirname)) {
+	fprintf(stderr, "Error changing into %s, aborting\n", dirname);
+	exit(-1);
+      }
         if (filename_to_extract == NULL)
             return do_extract(uf,opt_do_extract_withoutpath,opt_overwrite,password);
         else
