diff --git a/usr.bin/install/COPYING b/usr.bin/install/COPYING index 7dfefce..01ae15c 100644 --- a/usr.bin/install/COPYING +++ b/usr.bin/install/COPYING @@ -1,4 +1,4 @@ -Copyright 1996-1997 Devin Reade . +Copyright 1996-1998 Devin Reade . All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/usr.bin/install/Makefile b/usr.bin/install/Makefile index 38a6f6e..7eae950 100644 --- a/usr.bin/install/Makefile +++ b/usr.bin/install/Makefile @@ -1,5 +1,5 @@ # -# $Id: Makefile,v 1.2 1998/03/08 18:18:57 gdr-ftp Exp $ +# $Id: Makefile,v 1.3 1998/04/24 00:53:59 gdr-ftp Exp $ # # Don't name this "install"; we change the name later. @@ -7,8 +7,8 @@ PROG = inst BINDIR = /usr/bin CUSTOM_RELEASE = true LDADD = -lcontrib -OPTIMIZE = 78 -STACK = 1024 +OPTIMIZE = -1 +STACK = 1024 # largest observed is 707 bytes .INCLUDE: /src/gno/prog.mk diff --git a/usr.bin/install/README b/usr.bin/install/README index b9a7e1f..367af09 100644 --- a/usr.bin/install/README +++ b/usr.bin/install/README @@ -1,13 +1,15 @@ -$Id: README,v 1.2 1997/10/30 04:14:21 gdr Exp $ +$Id: README,v 1.3 1998/04/24 00:54:00 gdr-ftp Exp $ As the describe file says, install(1) is a utility similar to cp(1), except that it does a few more things and is intended for use in makefiles and scripts. -To install install, type "dmake doinstall". By default, it places the +To install install, type "dmake install". By default, it places the binary in /usr/bin and the man page in /usr/man/man1. If you don't like these locations, either modify the makefile or copy the two files -by hand. There are no support files. +by hand. There are no support files. [Note: As of v1.1, the +assumption is that you're building these files from within the GNO +base source hierarchy.] As usual, please email me or post to comp.sys.apple2.gno if you encounter problems or bugs. @@ -19,6 +21,11 @@ March 1996 CHANGE LOG ========== +v1.2 April 1998 + - Added sessions to (hopefully) speed things up. + - Increased to use optimization level -1. It seems to work. + - Added the -V (verbose) flag. + v1.1 August 1997 - Incorporated install(1) into base GNO v2.0.6 distribution - Use the GNO v2.0.6 libcontrib library @@ -27,4 +34,4 @@ v1.1 August 1997 usual UNIX usage. v1.0 March 1996 - Initial Version + - Initial Version diff --git a/usr.bin/install/inst.1 b/usr.bin/install/inst.1 index 98b1344..c5fe7df 100644 --- a/usr.bin/install/inst.1 +++ b/usr.bin/install/inst.1 @@ -1,8 +1,8 @@ -.\" Copyright 1996-1997 Devin Reade +.\" Copyright 1996-1997 Devin Reade . .\" -.\" $Id: inst.1,v 1.2 1997/10/30 04:14:21 gdr Exp $ +.\" $Id: inst.1,v 1.3 1998/04/24 00:54:02 gdr-ftp Exp $ .\" -.TH INSTALL 1 "16 October 1997" GNO "Commands and Applications" +.TH INSTALL 1 "23 April 1998" GNO "Commands and Applications" .SH NAME install \- copy files and set their attributes .SH SYNOPSIS @@ -99,14 +99,27 @@ may also be numeric user ID. Strip the symbol tables from the installed programs. .sp \fBThis is currently ignored under GNO.\fR +.IP \fB-V\fR +Verbose output; +.BR install +will print out the name of each file or directory as it is created. .IP \fB-v\fR Show version number. +.SH BUGS +When installing multiple files into a directory and the +.BR -V +flag is given, the respective file names are printed +.I after +the file has been copied, rather than before. This was done since the +final file name is known only after the copying subroutine has returned. +While the name could be determined prior to the copy, this extra work +was left out for efficiency reasons. .SH VERSION This manual page documents .BR install -version 1.1. +version 1.2. .SH AUTHOR -Devin Reade +Devin Reade . .SH "SEE ALSO" .BR cp (1) .BR chmod (2). diff --git a/usr.bin/install/inst.c b/usr.bin/install/inst.c index a22e045..b69a8fe 100644 --- a/usr.bin/install/inst.c +++ b/usr.bin/install/inst.c @@ -1,13 +1,16 @@ /* - * Copyright 1996-1997 Devin Reade . + * Copyright 1996-1997 Devin Reade . * All rights reserved. * * For copying and distribution information, see the file "COPYING" * accompanying this file. * - * $Id: inst.c,v 1.4 1998/03/08 18:18:58 gdr-ftp Exp $ + * $Id: inst.c,v 1.5 1998/04/24 00:54:03 gdr-ftp Exp $ */ +#define VERSION "1.2" +#define EMAIL "" + #define __USE_DYNAMIC_GSSTRING__ #include @@ -40,23 +43,8 @@ #define S_WRITE 0222 #define S_EXECUTE 0111 -#define VERSION "1.1" -#define EMAIL "" - char *versionMsg = "Version %s by Devin Reade %s\n"; -int dFlag; - -#ifdef __STACK_CHECK__ -/* - * printStack - * - * prints stack usage (debugging only) - */ -static void -printStack (void) { - fprintf(stderr, "stack usage: %d bytes\n", _endStackCheck()); -} -#endif +int dFlag, verbose; /* * usage @@ -67,7 +55,7 @@ printStack (void) { void usage(void) { - fputs("Usage: install [-cdhsv] [-o owner] [-g group] [-m mode] ", stderr); + fputs("Usage: install [-cdhsvV] [-o owner] [-g group] [-m mode] ", stderr); fputs("source [...] dest\n\n", stderr); fputs("Options:\n", stderr); fputs("\t-c Ignored. (Backwards Unix compatibility)\n", stderr); @@ -77,6 +65,8 @@ usage(void) fputs("\t-m mode Specify (Unix) access mode\n", stderr); fputs("\t-o owner Specify owner id (not implemented)\n", stderr); fputs("\t-s Strip binary (not implemented)\n", stderr); + fputs("\t-V Print each file as it is created (verbose).\n", + stderr); fputs("\t-v Show version number\n\n", stderr); fprintf(stderr, versionMsg, VERSION, EMAIL); exit(1); @@ -252,10 +242,15 @@ mkdirs(int argc, char **argv) } /* go ahead and create the directory */ - if (makeit && mkdir(path)) { - warn("couldn't create directory %s", path); - abortpath = 1; - result = 1; + if (makeit) { + if (verbose) { + fprintf(stderr, "%s\n", path); + } + if (mkdir(path)) { + warn("couldn't create directory %s", path); + abortpath = 1; + result = 1; + } } /* reinstate the ':' that we "nulled-out" */ if (p != path + pathlen) { @@ -288,8 +283,11 @@ copyfiles(int argc, char **argv, int action, mode_t mode) { static FileInfoRecGS inforec; GSStringPtr src, dest, newname; - int total, i, result; + int total, i, result, printWhen; unsigned short flags; +#define PRINT_NEVER 0 /* used for printWhen (verbose mode) */ +#define PRINT_BEFORE 1 +#define PRINT_AFTER 2 static const char *nodup = "couldn't duplicate %s file name \"%s\""; @@ -301,8 +299,8 @@ copyfiles(int argc, char **argv, int action, mode_t mode) flags = LC_COPY_DATA | LC_COPY_REZ | LC_COPY_KEEPBUF; /* duplicate the destination name */ - if ((dest = __C2GSMALLOC(argv[argc - 1])) == NULL) { - err(1, nodup, "destination", argv[argc - 1]); + if ((dest = __C2GSMALLOC(argv[total])) == NULL) { + err(1, nodup, "destination", argv[total]); /*NOTREACHED*/ } @@ -327,7 +325,15 @@ copyfiles(int argc, char **argv, int action, mode_t mode) } /* copy each file */ + if (verbose) { + printWhen = (argc == 2) ? PRINT_BEFORE : PRINT_AFTER; + } else { + printWhen = PRINT_NEVER; + } for (i=0; itext); + } if (action & ACTION_CHANGE_MODE) { if (chmod(newname->text, mode) < 0) { result = errno; @@ -363,11 +372,8 @@ main(int argc, char **argv) int c, nfiles; int action = 0; -#ifdef __STACK_CHECK__ - _beginStackCheck(); - atexit(printStack); -#endif - + __REPORT_STACK(); + if (needsgno() == 0) { errx(1, "requires GNO"); } @@ -377,7 +383,7 @@ main(int argc, char **argv) newmode = 0L; /* parse command line */ - while ((c = getopt(argc, argv, "cdg:hm:o:sv")) != EOF) { + while ((c = getopt(argc, argv, "cdg:hm:o:svV")) != EOF) { switch (c) { case 'v': errx(1, versionMsg, VERSION, EMAIL); @@ -391,6 +397,10 @@ main(int argc, char **argv) } break; + case 'V': + verbose=1; + break; + case 'd': dFlag++; case 'c': /* not implemented */ case 'g': /* not implemented */ @@ -404,6 +414,30 @@ main(int argc, char **argv) } nfiles = argc - optind; +#if 1 + if (nfiles < (dFlag ? 1 : 2)) { + usage(); + } + + c = 0; /* using c as a temp variable */ + BeginSessionGS(&c); + if (_toolErr) { + errno = _mapErr(_toolErr); + err(EXIT_FAILURE, "BeginSessionGS failed (0x%x)", _toolErr); + } + if (dFlag) { + c = mkdirs(nfiles, &argv[optind]); + } else { + /* ignore new user and group for now */ + c = copyfiles(nfiles, &argv[optind], action, newmode); + } + action = 0; /* using action as a temp variable */ + EndSessionGS(&action); + if (_toolErr) { + errno = _mapErr(_toolErr); + err(EXIT_FAILURE, "EndSessionGS failed (0x%x)", _toolErr); + } +#else if (dFlag) { if (nfiles < 1) { @@ -417,7 +451,7 @@ main(int argc, char **argv) /* ignore new user and group for now */ c = copyfiles(nfiles, &argv[optind], action, newmode); } - +#endif return c; } diff --git a/usr.bin/install/inst.desc b/usr.bin/install/inst.desc index b0d1df2..c75168c 100644 --- a/usr.bin/install/inst.desc +++ b/usr.bin/install/inst.desc @@ -1,10 +1,10 @@ Name: install -Version: 1.1 (16 Oct 97) +Version: 1.2 (23 Apr 98) Shell: GNO Author: Devin Reade -Contact: gdr@eddore.myrias.com +Contact: gdr@trenco.gno.org Where: /usr/bin -FTP: apple2.caltech.edu, ground.isca.uiowa.edu, trenco.myrias.com +FTP: ftp.gno.org Install is similar to cp(1) in that it copies files. It will also create directory hierarchies, modify certain access bits, and convert TXT or SRC diff --git a/usr.bin/install/inst.rez b/usr.bin/install/inst.rez index 4ede365..dc7e2ae 100644 --- a/usr.bin/install/inst.rez +++ b/usr.bin/install/inst.rez @@ -1,11 +1,11 @@ /* - * Copyright 1996-1997 Devin Reade . + * Copyright 1996-1997 Devin Reade . * All rights reserved. * * For copying and distribution information, see the file "COPYING" * accompanying this file. * - * $Id: inst.rez,v 1.3 1998/03/08 18:19:00 gdr-ftp Exp $ + * $Id: inst.rez,v 1.4 1998/04/24 00:54:06 gdr-ftp Exp $ */ #include "Types.Rez" @@ -13,7 +13,7 @@ resource rVersion (0x1, purgeable3, nocrossbank) { - { 1, 1, 0, /* version 1.1.0 */ + { 1, 2, 0, /* version; also in inst.c and inst.desc */ release, /* development|alpha|beta|final|release */ 0 /* non-final release number */ },