tech-pkg archive

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

PKG_PATH with trailing /



Hello,

It appears that at the moment pkg_add(1) requires the PKG_PATH variable
to not end in a /.  However, it seems to me like a common user "mistake"
to include the trailing slash.  The resulting error message is not
entirely unreasonable:

# setenv PKG_PATH 
ftp://ftp.netbsd.org/pub/pkgsrc/packages/NetBSD/amd64/5.1_2011Q4/All/
# pkg_add bc

ftp: The `CWD ' command (without a directory), which is required by
     RFC3986 to support the empty directory in the URL pathname (`//'),
     conflicts with the server's conformance to RFC0959.
     Try the same URL without the `//' in the URL pathname.

but a new user might still wonder what this is all about.  More
specifically, the user might wonder why the tool does not simply either
bail out right away or strip off the trailing / if it knows this to be
an error condition.

So, I was wondering if the following would make sense:

--- files/lib/parse-config.c    16 Jun 2010 23:02:49 -0000      1.15
+++ files/lib/parse-config.c    27 Feb 2012 14:17:54 -0000
@@ -206,8 +206,13 @@
        if (do_license_check == NULL)
                do_license_check = "no";

-       if ((value = getenv("PKG_PATH")) != NULL)
+       if ((value = getenv("PKG_PATH")) != NULL) {
+               int len = strlen(value);
+               if (value[len] == '/') {
+                       value[len] == '\0';
+               }
                config_pkg_path = value;
+       }

        if (strcasecmp(cache_index, "yes") == 0)
                do_cache_index = 1;


Or should that perhaps be handled in files/lib/pkg_io.c:process_pkg_path
?

-Jan

Attachment: pgppQdVaWGrSW.pgp
Description: PGP signature



Home | Main Index | Thread Index | Old Index