Bug 46830 - Make pkg_add respect prefix for dependancies
Summary: Make pkg_add respect prefix for dependancies
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 4.6-STABLE
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-01-07 16:20 UTC by Dominic Marks
Modified: 2004-06-13 18:41 UTC (History)
0 users

See Also:


Attachments
file.diff (683 bytes, patch)
2003-01-07 16:20 UTC, Dominic Marks
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dominic Marks 2003-01-07 16:20:00 UTC
	I maintain my ports on a FreeBSD machine which I do not own and do not
	have root priveledges on. Sometimes I install dependancies for my
	ports as packages (much like the build cluster does), I have to
	install these under my home directory for reasons Ive already
	explained. Recently I tried to do the following:

	> pkg_add -p /home/cus/dom/tmp/prefix -rv popt

	This in turn pulls in a series of dependancies, ending at gettext.
	However the sub-processes don't respect the prefix I have specified
	and so pkg_add attempts to extract into /usr/local, fails, and the
	whole installation procedure falls on its face.

	Here is a log of the procedure if you'd like to look for yourself.

Script started on Tue Jan  7 16:14:27 2003
> pkg_add -p /home/cus/dom/tmp/prefix/ -rv popt
looking up ftp.freebsd.org
connecting to ftp.freebsd.org:21
setting passive mode
opening data connection
initiating transfer
Fetching ftp://ftp.freebsd.org/pub/FreeBSD/ports/i386/packages-4-stable/Latest/popt.tgz...+CONTENTS
+COMMENT
+DESC
+MTREE_DIRS
man/man3/popt.3.gz
include/popt.h
lib/libpopt.a
lib/libpopt.so
lib/libpopt.so.0
share/locale/cs/LC_MESSAGES/popt.mo
share/locale/da/LC_MESSAGES/popt.mo
share/locale/de/LC_MESSAGES/popt.mo
share/locale/es/LC_MESSAGES/popt.mo
share/locale/eu_ES/LC_MESSAGES/popt.mo
share/locale/fi/LC_MESSAGES/popt.mo
share/locale/fr/LC_MESSAGES/popt.mo
share/locale/gl/LC_MESSAGES/popt.mo
share/locale/hu/LC_MESSAGES/popt.mo
share/locale/id/LC_MESSAGES/popt.mo
share/locale/is/LC_MESSAGES/popt.mo
share/locale/it/LC_MESSAGES/popt.mo
share/locale/ja/LC_MESSAGES/popt.mo
share/locale/ko/LC_MESSAGES/popt.mo
share/locale/no/LC_MESSAGES/popt.mo
share/locale/pl/LC_MESSAGES/popt.mo
share/locale/pt/LC_MESSAGES/popt.mo
share/locale/pt_BR/LC_MESSAGES/popt.mo
share/locale/ro/LC_MESSAGES/popt.mo
share/locale/ru/LC_MESSAGES/popt.mo
share/locale/sk/LC_MESSAGES/popt.mo
share/locale/sl/LC_MESSAGES/popt.mo
share/locale/sr/LC_MESSAGES/popt.mo
share/locale/sv/LC_MESSAGES/popt.mo
share/locale/tr/LC_MESSAGES/popt.mo
share/locale/uk/LC_MESSAGES/popt.mo
share/locale/wa/LC_MESSAGES/popt.mo
share/locale/zh/LC_MESSAGES/popt.mo
share/locale/zh_CN.GB2312/LC_MESSAGES/popt.mo
tar command returns 0 status
 Done.
Package `popt-1.6.4' depends on `libiconv-1.8_2'.
setting passive mode
opening data connection
initiating transfer
Fetching ftp://ftp.freebsd.org/pub/FreeBSD/ports/i386/packages-4-stable/All/libiconv-1.8_2.tgz...+CONTENTS
+COMMENT
+DESC
+MTREE_DIRS
man/man1/iconv.1.gz
man/man3/iconv.3.gz
man/man3/iconv_open.3.gz
man/man3/iconv_close.3.gz
bin/iconv
include/iconv.h
include/libcharset.h
lib/libcharset.a
lib/libcharset.so
lib/libcharset.so.1
lib/libiconv.a
lib/libiconv.so
lib/libiconv.so.3
libdata/charset.alias
share/doc/libiconv/iconv.1.html
share/doc/libiconv/iconv.3.html
share/doc/libiconv/iconv_close.3.html
share/doc/libiconv/iconv_open.3.html
tar command returns 0 status
 Done.
Finished loading libiconv-1.8_2 over FTP.
extract: Package name is libiconv-1.8_2
extract: CWD to /usr/local
extract: /usr/local/man/man1/iconv.1.gz
extract: /usr/local/man/man3/iconv.3.gz
extract: /usr/local/man/man3/iconv_open.3.gz
extract: /usr/local/man/man3/iconv_close.3.gz
extract: /usr/local/bin/iconv
extract: /usr/local/include/iconv.h
extract: /usr/local/include/libcharset.h
extract: /usr/local/lib/libcharset.a
extract: /usr/local/lib/libcharset.so
extract: /usr/local/lib/libcharset.so.1
extract: /usr/local/lib/libiconv.a
extract: /usr/local/lib/libiconv.so
extract: /usr/local/lib/libiconv.so.3
extract: /usr/local/libdata/charset.alias
extract: /usr/local/share/doc/libiconv/iconv.1.html
extract: /usr/local/share/doc/libiconv/iconv.3.html
extract: /usr/local/share/doc/libiconv/iconv_close.3.html
extract: /usr/local/share/doc/libiconv/iconv_open.3.html
tar: man/man1/iconv.1.gz: Cannot unlink: Permission denied
tar: man/man3/iconv.3.gz: Cannot unlink: Permission denied
tar: man/man3/iconv_open.3.gz: Cannot unlink: Permission denied
tar: man/man3/iconv_close.3.gz: Cannot unlink: Permission denied
tar: bin/iconv: Cannot unlink: Permission denied
tar: include/iconv.h: Cannot unlink: Permission denied
tar: include/libcharset.h: Cannot unlink: Permission denied
tar: lib/libcharset.a: Cannot unlink: Permission denied
tar: lib/libcharset.so: Cannot unlink: Permission denied
tar: lib/libcharset.so.1: Cannot unlink: Permission denied
tar: lib/libiconv.a: Cannot unlink: Permission denied
tar: lib/libiconv.so: Cannot unlink: Permission denied
tar: lib/libiconv.so.3: Cannot open: Permission denied
tar: libdata/charset.alias: Cannot unlink: Permission denied
tar: share/doc/libiconv/iconv.1.html: Cannot open: No such file or directory
tar: share/doc/libiconv/iconv.3.html: Cannot open: No such file or directory
tar: share/doc/libiconv/iconv_close.3.html: Cannot open: No such file or directory
tar: share/doc/libiconv/iconv_open.3.html: Cannot open: No such file or directory
tar: Error exit delayed from previous errors
pkg_add: extract_plist: can not invoke 481 byte tar pipeline: tar cf -  'man/man1/iconv.1.gz' 'man/man3/iconv.3.gz' 'man/man3/iconv_open.3.gz' 'man/man3/iconv_close.3.gz' 'bin/iconv' 'include/iconv.h' 'include/libcharset.h' 'lib/libcharset.a' 'lib/libcharset.so' 'lib/libcharset.so.1' 'lib/libiconv.a' 'lib/libiconv.so' 'lib/libiconv.so.3' 'libdata/charset.alias' 'share/doc/libiconv/iconv.1.html' 'share/doc/libiconv/iconv.3.html' 'share/doc/libiconv/iconv_close.3.html' 'share/doc/libiconv/iconv_open.3.html'|tar --unlink -xf - -C /usr/local
pkg_add: pkg_add of dependency `libiconv-1.8_2' failed!
Package `popt-1.6.4' depends on `expat-1.95.5'.
setting passive mode
opening data connection
initiating transfer
Fetching ftp://ftp.freebsd.org/pub/FreeBSD/ports/i386/packages-4-stable/All/expat-1.95.5.tgz...+CONTENTS
+COMMENT
+DESC
+MTREE_DIRS
man/man1/xmlwf.1.gz
bin/xmlwf
include/expat.h
lib/libexpat.a
lib/libexpat.so
lib/libexpat.so.4
tar command returns 0 status
 Done.
Finished loading expat-1.95.5 over FTP.
extract: Package name is expat-1.95.5
extract: CWD to /usr/local
extract: /usr/local/man/man1/xmlwf.1.gz
extract: /usr/local/bin/xmlwf
extract: /usr/local/include/expat.h
extract: /usr/local/lib/libexpat.a
extract: /usr/local/lib/libexpat.so
extract: /usr/local/lib/libexpat.so.4
tar: man/man1/xmlwf.1.gz: Cannot open: Permission denied
tar: bin/xmlwf: Cannot open: Permission denied
tar: include/expat.h: Cannot open: Permission denied
tar: lib/libexpat.a: Cannot open: Permission denied
tar: lib/libexpat.so: Cannot create symlink to `libexpat.so.4': Permission denied
tar: lib/libexpat.so.4: Cannot open: Permission denied
tar: Error exit delayed from previous errors
pkg_add: extract_plist: can not invoke 149 byte tar pipeline: tar cf -  'man/man1/xmlwf.1.gz' 'bin/xmlwf' 'include/expat.h' 'lib/libexpat.a' 'lib/libexpat.so' 'lib/libexpat.so.4'|tar --unlink -xf - -C /usr/local
pkg_add: pkg_add of dependency `expat-1.95.5' failed!
Package `popt-1.6.4' depends on `gettext-0.11.5_1'.
setting passive mode
opening data connection
initiating transfer
Fetching ftp://ftp.freebsd.org/pub/FreeBSD/ports/i386/packages-4-stable/All/gettext-0.11.5_1.tgz...+CONTENTS
+COMMENT
+DESC
+MTREE_DIRS
man/man1/autopoint.1.gz
man/man1/gettext.1.gz
man/man1/gettextize.1.gz
man/man1/msgattrib.1.gz
man/man1/msgcat.1.gz
man/man1/msgcmp.1.gz
man/man1/msgcomm.1.gz
man/man1/msgconv.1.gz
man/man1/msgen.1.gz
man/man1/msgexec.1.gz
man/man1/msgfilter.1.gz
man/man1/msgfmt.1.gz
man/man1/msggrep.1.gz
man/man1/msginit.1.gz
man/man1/msgmerge.1.gz
man/man1/msgunfmt.1.gz
man/man1/msguniq.1.gz
man/man1/ngettext.1.gz
man/man1/xgettext.1.gz
man/man3/bind_textdomain_codeset.3.gz
man/man3/bindtextdomain.3.gz
man/man3/dcgettext.3.gz
man/man3/dcngettext.3.gz
man/man3/dgettext.3.gz
man/man3/dngettext.3.gz
man/man3/gettext.3.gz
man/man3/ngettext.3.gz
man/man3/textdomain.3.gz
bin/autopoint
bin/gettext
bin/gettextize
bin/msgattrib
bin/msgcat
bin/msgcmp
bin/msgcomm
bin/msgconv
bin/msgen
bin/msgexec
bin/msgfilter
bin/msgfmt
bin/msggrep
bin/msginit
bin/msgmerge
bin/msgunfmt
bin/msguniq
bin/ngettext
bin/xgettext
include/libintl.h
info/gettext.info
lib/libgettextlib-0.11.5.so
lib/libgettextlib.so
lib/libgettextsrc-0.11.5.so
lib/libgettextsrc.so
lib/libintl.a
lib/libintl.so
lib/libintl.so.4
libdata/gettext/hostname
libdata/gettext/project-id
libdata/gettext/urlget
libdata/gettext/user-email
share/aclocal/codeset.m4
share/aclocal/gettext.m4
share/aclocal/glibc21.m4
share/aclocal/iconv.m4
share/aclocal/intdiv0.m4
share/aclocal/inttypes-pri.m4
share/aclocal/inttypes.m4
share/aclocal/inttypes_h.m4
share/aclocal/isc-posix.m4
share/aclocal/lcmessage.m4
share/aclocal/lib-ld.m4
share/aclocal/lib-link.m4
share/aclocal/lib-prefix.m4
share/aclocal/progtest.m4
share/aclocal/stdint_h.m4
share/aclocal/uintmax_t.m4
share/aclocal/ulonglong.m4
share/doc/gettext/autopoint.1.html
share/doc/gettext/bind_textdomain_codeset.3.html
share/doc/gettext/bindtextdomain.3.html
share/doc/gettext/gettext.1.html
share/doc/gettext/gettext.3.html
share/doc/gettext/gettext_1.html
share/doc/gettext/gettext_10.html
share/doc/gettext/gettext_11.html
share/doc/gettext/gettext_12.html
share/doc/gettext/gettext_13.html
share/doc/gettext/gettext_14.html
share/doc/gettext/gettext_15.html
share/doc/gettext/gettext_16.html
share/doc/gettext/gettext_17.html
share/doc/gettext/gettext_18.html
share/doc/gettext/gettext_19.html
share/doc/gettext/gettext_2.html
share/doc/gettext/gettext_20.html
share/doc/gettext/gettext_21.html
share/doc/gettext/gettext_22.html
share/doc/gettext/gettext_3.html
share/doc/gettext/gettext_4.html
share/doc/gettext/gettext_5.html
share/doc/gettext/gettext_6.html
share/doc/gettext/gettext_7.html
share/doc/gettext/gettext_8.html
share/doc/gettext/gettext_9.html
share/doc/gettext/gettext_foot.html
share/doc/gettext/gettext_toc.html
share/doc/gettext/gettextize.1.html
share/doc/gettext/msgattrib.1.html
share/doc/gettext/msgcat.1.html
share/doc/gettext/msgcmp.1.html
share/doc/gettext/msgcomm.1.html
share/doc/gettext/msgconv.1.html
share/doc/gettext/msgen.1.html
share/doc/gettext/msgexec.1.html
share/doc/gettext/msgfilter.1.html
share/doc/gettext/msgfmt.1.html
share/doc/gettext/msggrep.1.html
share/doc/gettext/msginit.1.html
share/doc/gettext/msgmerge.1.html
share/doc/gettext/msgunfmt.1.html
share/doc/gettext/msguniq.1.html
share/doc/gettext/ngettext.1.html
share/doc/gettext/ngettext.3.html
share/doc/gettext/textdomain.3.html
share/doc/gettext/xgettext.1.html
share/emacs/site-lisp/po-compat.el
share/emacs/site-lisp/po-mode.el
share/gettext/ABOUT-NLS
share/gettext/archive.tar.gz
share/gettext/config.rpath
share/gettext/gettext.h
share/gettext/intl/COPYING.LIB-2.0
share/gettext/intl/COPYING.LIB-2.1
share/gettext/intl/ChangeLog
share/gettext/intl/Makefile.in
share/gettext/intl/VERSION
share/gettext/intl/bindtextdom.c
share/gettext/intl/config.charset
share/gettext/intl/dcgettext.c
share/gettext/intl/dcigettext.c
share/gettext/intl/dcngettext.c
share/gettext/intl/dgettext.c
share/gettext/intl/dngettext.c
share/gettext/intl/eval-plural.h
share/gettext/intl/explodename.c
share/gettext/intl/finddomain.c
share/gettext/intl/gettext.c
share/gettext/intl/gettextP.h
share/gettext/intl/gmo.h
share/gettext/intl/hash-string.h
share/gettext/intl/intl-compat.c
share/gettext/intl/l10nflist.c
share/gettext/intl/libgnuintl.h
share/gettext/intl/loadinfo.h
share/gettext/intl/loadmsgcat.c
share/gettext/intl/localcharset.c
share/gettext/intl/locale.alias
share/gettext/intl/localealias.c
share/gettext/intl/localename.c
share/gettext/intl/ngettext.c
share/gettext/intl/os2compat.c
share/gettext/intl/os2compat.h
share/gettext/intl/osdep.c
share/gettext/intl/plural-exp.c
share/gettext/intl/plural-exp.h
share/gettext/intl/plural.c
share/gettext/intl/plural.y
share/gettext/intl/ref-add.sin
share/gettext/intl/ref-del.sin
share/gettext/intl/textdomain.c
share/gettext/mkinstalldirs
share/gettext/msgunfmt.tcl
share/gettext/po/Makefile.in.in
share/gettext/po/Makevars
share/gettext/po/Rules-quot
share/gettext/po/boldquot.sed
share/gettext/po/en@boldquot.header
share/gettext/po/en@quot.header
share/gettext/po/insert-header.sin
share/gettext/po/quot.sed
share/gettext/po/remove-potcdate.sin
share/gettext/projects/GNOME/team-address
share/gettext/projects/GNOME/teams.html
share/gettext/projects/GNOME/teams.url
share/gettext/projects/GNOME/trigger
share/gettext/projects/KDE/team-address
share/gettext/projects/KDE/teams.html
share/gettext/projects/KDE/teams.url
share/gettext/projects/KDE/trigger
share/gettext/projects/TP/team-address
share/gettext/projects/TP/teams.html
share/gettext/projects/TP/teams.url
share/gettext/projects/TP/trigger
share/gettext/projects/index
share/gettext/projects/team-address
share/locale/be/LC_MESSAGES/gettext.mo
share/locale/ca/LC_MESSAGES/gettext.mo
share/locale/cs/LC_MESSAGES/gettext.mo
share/locale/da/LC_MESSAGES/gettext.mo
share/locale/de/LC_MESSAGES/gettext.mo
share/locale/el/LC_MESSAGES/gettext.mo
share/locale/en@boldquot/LC_MESSAGES/gettext.mo
share/locale/en@quot/LC_MESSAGES/gettext.mo
share/locale/es/LC_MESSAGES/gettext.mo
share/locale/et/LC_MESSAGES/gettext.mo
share/locale/fi/LC_MESSAGES/gettext.mo
share/locale/fr/LC_MESSAGES/gettext.mo
share/locale/gl/LC_MESSAGES/gettext.mo
share/locale/id/LC_MESSAGES/gettext.mo
share/locale/it/LC_MESSAGES/gettext.mo
share/locale/ja/LC_MESSAGES/gettext.mo
share/locale/ko/LC_MESSAGES/gettext.mo
share/locale/locale.alias
share/locale/nl/LC_MESSAGES/gettext.mo
share/locale/nn/LC_MESSAGES/gettext.mo
share/locale/no/LC_MESSAGES/gettext.mo
share/locale/pl/LC_MESSAGES/gettext.mo
share/locale/pt/LC_MESSAGES/gettext.mo
share/locale/pt_BR/LC_MESSAGES/gettext.mo
share/locale/ru/LC_MESSAGES/gettext.mo
share/locale/sk/LC_MESSAGES/gettext.mo
share/locale/sl/LC_MESSAGES/gettext.mo
share/locale/sv/LC_MESSAGES/gettext.mo
share/locale/tr/LC_MESSAGES/gettext.mo
share/locale/zh_TW/LC_MESSAGES/gettext.mo
tar command returns 0 status
 Done.
Finished loading gettext-0.11.5_1 over FTP.
Package `gettext-0.11.5_1' depends on `libiconv-1.8_2'.
pkg_add: could not find package libiconv-1.8_2 !
Package `gettext-0.11.5_1' depends on `expat-1.95.5'.
pkg_add: could not find package expat-1.95.5 !
pkg_add: 1 package addition(s) failed
pkg_add: pkg_add of dependency `gettext-0.11.5_1' failed!
pkg_add: 1 package addition(s) failed
> exit
exit

Script done on Tue Jan  7 16:15:03 2003

How-To-Repeat: 
	As a non-root user, try and install into a prefix using pkg_add's -p
	parameter.
Comment 1 Dominic Marks 2003-04-12 21:41:19 UTC
Hey,

Here is a better patch than the original one.

Index: perform.c
===================================================================
RCS file: /home/ncvs/src/usr.sbin/pkg_install/add/perform.c,v
retrieving revision 1.73
diff -u -r1.73 perform.c
--- perform.c	2002/09/03 06:59:33	1.73
+++ perform.c	2003/04/12 20:37:01
@@ -19,7 +19,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/usr.sbin/pkg_install/add/perform.c,v 1.73 2002/09/03 06:59:33 sobomax Exp $");
+__FBSDID("$FreeBSD: src/usr.sbin/pkg_install/add/perform.c,v 1.57.2.15 2002/09/25 23:22:13 bmah Exp $");
 
 #include <err.h>
 #include <paths.h>
@@ -68,7 +68,7 @@
     char extract_contents[FILENAME_MAX];
     char *where_to, *extract;
     FILE *cfile;
-    int code;
+    int code, rv;
     PackingList p;
     struct stat sb;
     int inPlace;
@@ -271,7 +271,7 @@
 
 		    ext = strrchr(pkg_fullname, '.');
 		    if (ext == NULL)
-			ext = ".tbz";
+			ext = ".tgz";
 		    snprintf(path, FILENAME_MAX, "%s/%s%s", getenv("_TOP"), p->name, ext);
 		    if (fexists(path))
 			cp = path;
@@ -280,12 +280,19 @@
 		    if (cp) {
 			if (Verbose)
 			    printf("Loading it from %s.\n", cp);
-			if (vsystem("pkg_add %s'%s'", Verbose ? "-v " : "", cp)) {
-			    warnx("autoload of dependency '%s' failed%s",
-				cp, Force ? " (proceeding anyway)" : "!");
-			    if (!Force)
-				++code;
-			}
+				if (Prefix == NULL) {
+				rv = vsystem("pkg_add %s'%s'",
+					Verbose ? "-v " : "", cp);
+				} else {
+				rv = vsystem("pkg_add %s -p '%s' '%s'",
+					Verbose ? "-v" : "", Prefix, cp);
+				}
+				if (rv) {
+			    	warnx("autoload of dependency '%s' failed%s",
+					cp, Force ? " (proceeding anyway)" : "!");
+			    	if (!Force)
+					++code;
+				}
 		    }
 		    else {
 			warnx("could not find package %s %s",

-- 
Dominic
 <dom at cus.org.uk> <d.marks at student.umist.ac.uk>
Comment 2 Dominic Marks 2003-04-12 22:01:33 UTC
Hey,

I didn't quite get the diff right last time, forgetting that there are
now differences between pkg_add in 4 and 5. Also GNATS seems to have
completely lost my first attempt at a followup. Here is a better diff:

I'm hoping it will apply cleanly to pkg_add in 4 and 5.

Index: perform.c
===================================================================
RCS file: /home/ncvs/src/usr.sbin/pkg_install/add/perform.c,v
retrieving revision 1.57.2.15
diff -u -3 -p -u -r1.57.2.15 perform.c
--- perform.c	25 Sep 2002 23:22:13 -0000	1.57.2.15
+++ perform.c	12 Apr 2003 20:57:03 -0000
@@ -68,7 +68,7 @@ pkg_do(char *pkg)
     char extract_contents[FILENAME_MAX];
     char *where_to, *extract;
     FILE *cfile;
-    int code;
+    int code, rv;
     PackingList p;
     struct stat sb;
     int inPlace;
@@ -280,12 +280,19 @@ pkg_do(char *pkg)
 		    if (cp) {
 			if (Verbose)
 			    printf("Loading it from %s.\n", cp);
-			if (vsystem("pkg_add %s'%s'", Verbose ? "-v " : "", cp)) {
-			    warnx("autoload of dependency '%s' failed%s",
-				cp, Force ? " (proceeding anyway)" : "!");
-			    if (!Force)
-				++code;
-			}
+				if (Prefix == NULL) {
+				rv = vsystem("pkg_add %s'%s'",
+					Verbose ? "-v " : "", cp);
+				} else {
+				rv = vsystem("pkg_add %s -p '%s' '%s'",
+					Verbose ? "-v" : "", Prefix, cp);
+				}
+				if (rv) {
+			    	warnx("autoload of dependency '%s' failed%s",
+					cp, Force ? " (proceeding anyway)" : "!");
+			    	if (!Force)
+					++code;
+				}
 		    }
 		    else {
 			warnx("could not find package %s %s",


Thanks,
-- 
Dominic
 <dom at cus.org.uk> <d.marks at student.umist.ac.uk>
Comment 3 Dominic Marks 2004-06-12 23:28:46 UTC
This PR can be closed.

The sysutils/pkg_install port contains a patch for this.

Thanks,
Dominic
Comment 4 Simon L. B. Nielsen freebsd_committer freebsd_triage 2004-06-13 18:40:46 UTC
State Changed
From-To: open->closed

Submitter reports that the PR can be closed.  Thanks for letting us 
know.