From d3a48cbb8c170c474c811961e6467bd18007fb01 Mon Sep 17 00:00:00 2001 From: obrien Date: Tue, 13 Feb 2001 09:49:14 +0000 Subject: In light of the dismal transfer times from ftp.FreeBSD.org, add a new `PACKAGEROOT' env var which you would set to a proper mirror of ftp.FreeBSD.org (say "export PACKAGEROOT=ftp://ftp3.FreeBSD.org"), to fetch from an alternate place. This is easier to use than `PACKAGESITE' for true mirrors, and can be used in your dot files across all versions of FreeBSD. --- usr.sbin/pkg_install/add/main.c | 32 ++++++++++++++++++++++---------- usr.sbin/pkg_install/add/pkg_add.1 | 14 ++++++++++++++ 2 files changed, 36 insertions(+), 10 deletions(-) (limited to 'usr.sbin') diff --git a/usr.sbin/pkg_install/add/main.c b/usr.sbin/pkg_install/add/main.c index 78c4c11..ad44f2d 100644 --- a/usr.sbin/pkg_install/add/main.c +++ b/usr.sbin/pkg_install/add/main.c @@ -62,7 +62,6 @@ main(int argc, char **argv) char *cp; char *remotepkg = NULL, *ptr; - static const char packageroot[MAXPATHLEN] = "ftp://ftp.FreeBSD.org/pub/FreeBSD/ports/"; static char temppackageroot[MAXPATHLEN]; start = argv; @@ -130,11 +129,7 @@ main(int argc, char **argv) /* Get all the remaining package names, if any */ for (ch = 0; *argv; ch++, argv++) { if (Remote) { - strcpy(temppackageroot, packageroot); - if (getenv("PACKAGESITE") == NULL) - strcat(temppackageroot, getpackagesite()); - else - strcpy(temppackageroot, (getenv("PACKAGESITE"))); + strcpy(temppackageroot, getpackagesite()); remotepkg = strcat(temppackageroot, *argv); if (!((ptr = strrchr(remotepkg, '.')) && ptr[1] == 't' && ptr[2] == 'g' && ptr[3] == 'z' && !ptr[4])) @@ -189,13 +184,30 @@ getpackagesite(void) static char sitepath[MAXPATHLEN]; struct utsname u; - reldate = getosreldate(); + if (getenv("PACKAGESITE")) { + strcpy(sitepath, getenv("PACKAGESITE")); + return sitepath; + } + + if (getenv("PACKAGEROOT")) + strcpy(sitepath, getenv("PACKAGEROOT")); + else + strcpy(sitepath, "ftp://ftp.FreeBSD.org"); + + strcat(sitepath, "/pub/FreeBSD/ports/"); uname(&u); - strcpy(sitepath, u.machine); + strcat(sitepath, u.machine); - if (reldate >= 500000) - strcat(sitepath, "/packages-current/Latest/"); + reldate = getosreldate(); + if (reldate == 500998) + strcat(sitepath, "/packages-5.0-release"); + else if (reldate >= 500999) + strcat(sitepath, "/packages-5-stable"); + else if (reldate >= 500000) + strcat(sitepath, "/packages-current"); + + strcat(sitepath, "/Latest/"); return sitepath; diff --git a/usr.sbin/pkg_install/add/pkg_add.1 b/usr.sbin/pkg_install/add/pkg_add.1 index 2aa618a..594fba0 100644 --- a/usr.sbin/pkg_install/add/pkg_add.1 +++ b/usr.sbin/pkg_install/add/pkg_add.1 @@ -407,6 +407,19 @@ or with sufficient space. .Pp The environment variable +.Ev PACKAGEROOT +specifies an alternate location for +.Nm +to fetch from. +The the fetch URL is built using this environment variable and the automatic +directory logic that +.Nm +uses when the +.Fl r +option is invoked. +An example setting would be "ftp://ftp3.FreeBSD.org". +.Pp +The environment variable .Ev PACKAGESITE specifies an alternate location for .Nm @@ -417,6 +430,7 @@ that uses when the .Fl r option is invoked. +Thus it should be a complete URL to the remote package file(s). .Sh FILES .Bl -tag -width /var/db/pkg -compact .It Pa /var/tmp -- cgit v1.1