pkgsrc-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

bzip2 support from http for pkg_add on Linux



Hi all !

before a few month, i send to here problem about using pkg_add on linux
and tbz packages, which i want to install from http server.

here is the thread:
http://archive.netbsd.se/?ml=pkgsrc-users&a=2007-10&m=5428439

So, i wrote a little patch, which solve this problem :)

--- files/add/perform.c.orig    2008-02-02 10:24:23.000000000 +0100
+++ files/add/perform.c 2008-02-02 10:29:46.000000000 +0100
@@ -450,7 +450,7 @@
                if (!Home)
                        warnx("unable to make playpen for %ld bytes",
                              (long) (sb.st_size * 4));
-               result = unpack(pkg, &files);
+               result = unpack(pkg, &files, NULL);
                while ((lfp = TAILQ_FIRST(&files)) != NULL) {
                        TAILQ_REMOVE(&files, lfp, lf_link);
                        free(lfp);
@@ -488,7 +488,7 @@
                }
 
                /* Finally unpack the whole mess */
-               if (unpack(pkg, NULL)) {
+               if (unpack(pkg, NULL, NULL)) {
                        warnx("unable to extract `%s'!", pkg);
                        goto bomb;
                }
--- files/info/perform.c.orig   2008-02-02 10:25:04.000000000 +0100
+++ files/info/perform.c        2008-02-02 10:25:24.000000000 +0100
@@ -159,7 +159,7 @@
                                        goto bail;
                                }
                                Home = make_playpen(PlayPen,
PlayPenSize, sb.st_size / 2);
-                               result = unpack(fname, &files);
+                               result = unpack(fname, &files, NULL);
                                while ((lfp = TAILQ_FIRST(&files)) !=
NULL) { TAILQ_REMOVE(&files, lfp, lf_link);
                                        free(lfp);
--- files/lib/lib.h.orig        2008-02-02 10:19:31.000000000 +0100
+++ files/lib/lib.h     2008-02-02 10:19:57.000000000 +0100
@@ -367,7 +367,7 @@
 void    move_files(const char *, const char *, const char *);
 void    remove_files(const char *, const char *);
 int     delete_hierarchy(char *, Boolean, Boolean);
-int     unpack(const char *, const lfile_head_t *);
+int     unpack(const char *, const lfile_head_t *, const char *);
 void    format_cmd(char *, size_t, char *, char *, char *);
 
 /* ftpio.c: FTP handling */
--- files/lib/file.c.orig       2008-02-02 10:20:34.000000000 +0100
+++ files/lib/file.c    2008-02-02 10:23:28.000000000 +0100
@@ -638,7 +638,7 @@
  * Unpack a tar file
  */
 int
-unpack(const char *pkg, const lfile_head_t *filesp)
+unpack(const char *pkg, const lfile_head_t *filesp, const char *url)
 {
        const char *decompress_cmd = NULL;
        const char *suf;
@@ -654,18 +654,19 @@
                        count++;
        up_argc += count;
        up_argv = malloc((count + up_argc + 1) * sizeof(char *));
-       if (!IS_STDIN(pkg)) {
-               suf = suffix_of(pkg);
-               if (!strcmp(suf, "tbz") || !strcmp(suf, "bz2"))
-                       decompress_cmd = BZIP2_CMD;
-               else if (!strcmp(suf, "tgz") || !strcmp(suf, "gz"))
-                       decompress_cmd = GZIP_CMD;
-               else if (!strcmp(suf, "tar"))
-                       ; /* do nothing */
-               else
-                       errx(EXIT_FAILURE, "don't know how to
decompress %s, sorry", pkg);
-       } else
+       if (!IS_STDIN(pkg))
+            suf = suffix_of(pkg);
+        else
+            suf = suffix_of(url);
+
+       if (!strcmp(suf, "tbz") || !strcmp(suf, "bz2"))
+               decompress_cmd = BZIP2_CMD;
+       else if (!strcmp(suf, "tgz") || !strcmp(suf, "gz"))
                decompress_cmd = GZIP_CMD;
+       else if (!strcmp(suf, "tar"))
+               ; /* do nothing */
+       else
+               errx(EXIT_FAILURE, "don't know how to decompress %s,
sorry", pkg); 
        up_argv[i] = (char *)strrchr(TAR_CMD, '/');
        if (up_argv[i] == NULL)
--- files/lib/ftpio.c.orig      2008-02-02 10:20:27.000000000 +0100
+++ files/lib/ftpio.c   2008-02-02 10:23:59.000000000 +0100
@@ -1041,7 +1041,7 @@
                if ((path != NULL) && (chdir(path) < 0))
                        _exit(127);
 
-               if (unpack("-", NULL) != 0) {
+               if (unpack("-", NULL, url) != 0) {
                        warnx("unpack failed");
                        _exit(2);
                }

I test it, and it works fine, i try to install tbz from http, ftp,
and local disk :)



-- 
Ondrej Tuma

   Www: www.blackmouse.biz, mcbig.webjet.cz 
Jabber: mcbig%jabber.cz@localhost

Attachment: signature.asc
Description: PGP signature



Home | Main Index | Thread Index | Old Index