Date: Mon, 10 Mar 2008 04:08:12 +0800 From: "Denise H. G." <darcsis@gmail.com> To: FreeBSD-gnats-submit@FreeBSD.org Subject: bin/121542: [patch] teach `pkg_add' to accept PACKAGEROOT and PACKAGESITE via command line Message-ID: <47d443b4.2287460a.6dc6.ffff801e@mx.google.com> Resent-Message-ID: <200803092010.m29KA0pH009822@freefall.freebsd.org>
index | next in thread | raw e-mail
>Number: 121542 >Category: bin >Synopsis: [patch] teach `pkg_add' to accept PACKAGEROOT and PACKAGESITE via command line >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Sun Mar 09 20:10:00 UTC 2008 >Closed-Date: >Last-Modified: >Originator: Denise H. G. >Release: FreeBSD 7.0-STABLE amd64 >Organization: >Environment: System: FreeBSD pluton.xbsd.name 7.0-STABLE FreeBSD 7.0-STABLE #0: Fri Mar 7 14:53:14 CST 2008 dhg@pluton.xbsd.name:/opt/obj/usr/src/sys/mibsd-SMP-ULE amd64 >Description: a possible answer to the PR: http://www.freebsd.org/cgi/query-pr.cgi?pr=bin/113393 >How-To-Repeat: >Fix: --- patch.diff begins here --- diff -ruN pkg_install.orig/add/main.c pkg_install/add/main.c --- pkg_install.orig/add/main.c 2008-03-10 04:00:23.000000000 +0800 +++ pkg_install/add/main.c 2008-03-10 03:45:21.000000000 +0800 @@ -27,7 +27,7 @@ #include "lib.h" #include "add.h" -static char Options[] = "hvIRfFnrp:P:SMt:C:K"; +static char Options[] = "hvIRfFnrp:P:SMt:C:Kz:Z:"; char *Prefix = NULL; Boolean PrefixRecursive = FALSE; @@ -88,7 +88,7 @@ { 0, 0, NULL } }; -static char *getpackagesite(void); +static char *getpackagesite(const char *, const char *); int getosreldate(void); static void usage __P((void)); @@ -99,6 +99,7 @@ int ch, error; char **start; char *cp, *packagesite = NULL, *remotepkg = NULL, *ptr; + char *pkg_site = NULL, *pkg_root = NULL; static char temppackageroot[MAXPATHLEN]; static char pkgaddpath[MAXPATHLEN]; @@ -169,6 +170,14 @@ Chroot = optarg; break; + case 'z': + pkg_root = optarg; + break; + + case 'Z': + pkg_site = optarg; + break; + case 'h': case '?': default: @@ -187,7 +196,7 @@ for (ch = 0; *argv; ch++, argv++) { char temp[MAXPATHLEN]; if (Remote) { - if ((packagesite = getpackagesite()) == NULL) + if ((packagesite = getpackagesite(pkg_root, pkg_site)) == NULL) errx(1, "package name too long"); if (strlcpy(temppackageroot, packagesite, sizeof(temppackageroot)) >= sizeof(temppackageroot)) @@ -271,12 +280,15 @@ } static char * -getpackagesite(void) +getpackagesite(const char *pkg_root, const char *pkg_site) { int reldate, i; static char sitepath[MAXPATHLEN]; struct utsname u; + if (pkg_site) + return pkg_site; + if (getenv("PACKAGESITE")) { if (strlcpy(sitepath, getenv("PACKAGESITE"), sizeof(sitepath)) >= sizeof(sitepath)) @@ -284,7 +296,12 @@ return sitepath; } - if (getenv("PACKAGEROOT")) { + if (pkg_root) { + if (strlcpy(sitepath, pkg_root, sizeof(sitepath)) + >= sizeof(sitepath)) + return NULL; + } else { + if (getenv("PACKAGEROOT")) { if (strlcpy(sitepath, getenv("PACKAGEROOT"), sizeof(sitepath)) >= sizeof(sitepath)) return NULL; @@ -293,6 +310,7 @@ >= sizeof(sitepath)) return NULL; } + } if (strlcat(sitepath, "/pub/FreeBSD/ports/", sizeof(sitepath)) >= sizeof(sitepath)) @@ -324,6 +342,6 @@ { fprintf(stderr, "%s\n%s\n", "usage: pkg_add [-vInfFrRMSK] [-t template] [-p prefix] [-P prefix] [-C chrootdir]", - " pkg-name [pkg-name ...]"); + " [-z PACKAGEROOT] [-Z PACKAGESITE] pkg-name [pkg-name ...]"); exit(1); } diff -ruN pkg_install.orig/add/pkg_add.1 pkg_install/add/pkg_add.1 --- pkg_install.orig/add/pkg_add.1 2008-03-10 04:00:23.000000000 +0800 +++ pkg_install/add/pkg_add.1 2008-03-10 03:58:16.000000000 +0800 @@ -28,6 +28,8 @@ .Op Fl p Ar prefix .Op Fl P Ar prefix .Op Fl C Ar chrootdir +.Op Fl z Ar PACKAGEROOT +.Op Fl Z Ar PACKAGESITE .Ar pkg-name Op Ar pkg-name ... .Sh DESCRIPTION The @@ -245,6 +247,12 @@ may be run inside .Ar chrootdir as a side effect. +.It Fl z Ar PACKAGEROOT +Specify a URL to override the environmental variable PACKAGEROOT +via command line. +.It Fl Z Ar PACKAGESITE +Specify a complete URL (including path) to override the environmental +variable PACKAGESITE via command line. .El .Pp One or more --- patch.diff ends here --- >Release-Note: >Audit-Trail: >Unformatted:help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?47d443b4.2287460a.6dc6.ffff801e>
