diff --git a/usr.bin/xinstall/install.1 b/usr.bin/xinstall/install.1 index 1806559b0568..0cf89bab99e5 100644 --- a/usr.bin/xinstall/install.1 +++ b/usr.bin/xinstall/install.1 @@ -1,4 +1,4 @@ -.\" $NetBSD: install.1,v 1.33 2002/12/19 09:17:01 wiz Exp $ +.\" $NetBSD: install.1,v 1.34 2002/12/22 10:15:17 lukem Exp $ .\" .\" Copyright (c) 1987, 1990, 1993 .\" The Regents of the University of California. All rights reserved. @@ -33,7 +33,7 @@ .\" .\" @(#)install.1 8.1 (Berkeley) 6/6/93 .\" -.Dd December 19, 2002 +.Dd December 21, 2002 .Dt INSTALL 1 .Os .Sh NAME @@ -46,6 +46,9 @@ .Op Fl B Ar suffix .Ek .Bk -words +.Op Fl D Ar destdir +.Ek +.Bk -words .Op Fl f Ar flags .Ek .Bk -words @@ -82,6 +85,9 @@ .Op Fl B Ar suffix .Ek .Bk -words +.Op Fl D Ar destdir +.Ek +.Bk -words .Op Fl f Ar flags .Ek .Bk -words @@ -117,6 +123,9 @@ .Fl d .Op Fl Up .Bk -words +.Op Fl D Ar destdir +.Ek +.Bk -words .Op Fl M Ar metalog .Ek .Bk -words @@ -206,6 +215,17 @@ where it deletes the original file after creating the target. .It Fl d Create directories. Missing parent directories are created as required. +.It Fl D Ar destdir +Specify the +.Ev DESTDIR +(top of the file hierarchy) that the items are installed in to. +If +.Fl M Ar metalog +is in use, a leading string of +.Dq Ar destdir +will removed from the file names logged to the +.Ar metalog . +This option does not affect where the actual files are installed. .It Fl f Ar flags Specify the target's file flags. (See diff --git a/usr.bin/xinstall/xinstall.c b/usr.bin/xinstall/xinstall.c index 7750b08f9dcd..609cb0ed2031 100644 --- a/usr.bin/xinstall/xinstall.c +++ b/usr.bin/xinstall/xinstall.c @@ -1,4 +1,4 @@ -/* $NetBSD: xinstall.c,v 1.74 2002/12/19 08:30:39 lukem Exp $ */ +/* $NetBSD: xinstall.c,v 1.75 2002/12/22 10:15:17 lukem Exp $ */ /* * Copyright (c) 1987, 1993 @@ -50,7 +50,7 @@ __COPYRIGHT("@(#) Copyright (c) 1987, 1993\n\ #if 0 static char sccsid[] = "@(#)xinstall.c 8.1 (Berkeley) 7/21/93"; #else -__RCSID("$NetBSD: xinstall.c,v 1.74 2002/12/19 08:30:39 lukem Exp $"); +__RCSID("$NetBSD: xinstall.c,v 1.75 2002/12/22 10:15:17 lukem Exp $"); #endif #endif /* not lint */ @@ -93,6 +93,7 @@ u_long fileflags; char *stripArgs; char *afterinstallcmd; char *suffix = BACKUP_SUFFIX; +char *destdir; #define LN_ABSOLUTE 0x01 #define LN_RELATIVE 0x02 @@ -133,7 +134,8 @@ main(int argc, char *argv[]) setprogname(argv[0]); iflags = 0; - while ((ch = getopt(argc, argv, "a:cbB:df:g:l:m:M:N:o:prsS:T:U")) != -1) + while ((ch = getopt(argc, argv, "a:cbB:dD:f:g:l:m:M:N:o:prsS:T:U")) + != -1) switch((char)ch) { case 'a': afterinstallcmd = strdup(optarg); @@ -167,6 +169,9 @@ main(int argc, char *argv[]) case 'd': dodir = 1; break; + case 'D': + destdir = optarg; + break; #if !HAVE_CONFIG_H case 'f': fflags = optarg; @@ -920,7 +925,8 @@ metadata_log(const char *path, const char *type, struct timeval *tv, const char *link) { static const char extra[] = { ' ', '\t', '\n', '\\', '#', '\0' }; - char *buf; + char *buf, *p; + size_t destlen; struct flock metalog_lock; if (!metafp) @@ -941,8 +947,16 @@ metadata_log(const char *path, const char *type, struct timeval *tv, } strsvis(buf, path, VIS_CSTYLE, extra); /* encode name */ - fprintf(metafp, ".%s%s type=%s mode=%#o", /* print details */ - buf[0] == '/' ? "" : "/", buf, type, mode); + p = buf; /* remove destdir */ + if (destdir) { + destlen = strlen(destdir); + if (strncmp(p, destdir, destlen) == 0 && p[destlen] == '/') + p += destlen; + } + while (*p && *p == '/') /* remove leading /s */ + p++; + /* print details */ + fprintf(metafp, "./%s type=%s mode=%#o", p, type, mode); if (link) fprintf(metafp, " link=%s", link); if (owner) @@ -1005,13 +1019,13 @@ usage(void) prog = getprogname(); (void)fprintf(stderr, -"usage: %s [-Ubcprs] [-M log] [-T tags] [-B suffix] [-a afterinstallcmd]\n" -" [-f flags] [-m mode] [-N dbdir] [-o owner] [-g group] [-l linkflags]\n" -" [-S stripflags] file1 file2\n" -" %s [-Ubcprs] [-M log] [-T tags] [-B suffix] [-a afterinstallcmd]\n" -" [-f flags] [-m mode] [-N dbdir] [-o owner] [-g group] [-l linkflags]\n" -" [-S stripflags] file1 ... fileN directory\n" -" %s -d [-Up] [-M log] [-T tags] [-a afterinstallcmd] [-m mode]\n" +"usage: %s [-Ubcprs] [-M log] [-D dest] [-T tags] [-B suffix]\n" +" [-a aftercmd] [-f flags] [-m mode] [-N dbdir] [-o owner] [-g group] \n" +" [-l linkflags] [-S stripflags] file1 file2\n" +" %s [-Ubcprs] [-M log] [-D dest] [-T tags] [-B suffix]\n" +" [-a aftercmd] [-f flags] [-m mode] [-N dbdir] [-o owner] [-g group]\n" +" [-l linkflags] [-S stripflags] file1 ... fileN directory\n" +" %s -d [-Up] [-M log] [-D dest] [-T tags] [-a aftercmd] [-m mode]\n" " [-N dbdir] [-o owner] [-g group] directory ...\n", prog, prog, prog); exit(1);