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.
This commit is contained in:
David E. O'Brien 2001-02-13 09:49:14 +00:00
parent 60f958afb7
commit eb0dde377b
2 changed files with 36 additions and 10 deletions

View File

@ -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;

View File

@ -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