From: Erik van der Kouwe Date: Wed, 27 Jan 2010 07:47:29 +0000 (+0000) Subject: Add -p flag for install tool X-Git-Tag: v3.1.6~24 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/zlib_tech.html?a=commitdiff_plain;h=3e583f4c04b23ac29f445984aa326b7bd25fbb8f;p=minix.git Add -p flag for install tool --- diff --git a/commands/simple/install.c b/commands/simple/install.c index b167195e2..a6d638dd2 100644 --- a/commands/simple/install.c +++ b/commands/simple/install.c @@ -60,6 +60,7 @@ void deallocate(void *mem) int lflag= 0; /* Make a hard link if possible. */ int cflag= 0; /* Copy if you can't link, otherwise symlink. */ int dflag= 0; /* Create a directory. */ +int pflag= 0; /* Preserve timestamps. */ int strip= 0; /* Strip the copy. */ char **compress= nil; /* Compress utility to make a compressed executable. */ char *zcat= nil; /* Line one to decompress. */ @@ -169,6 +170,17 @@ void makedir(char *dir, int mode, int owner, int group) /* Set the mode again, chown may have wrecked it. */ (void) chmod(dir, mode); } + + if (pflag) { + struct utimbuf ubuf; + + ubuf.actime= st.st_atime; + ubuf.modtime= st.st_mtime; + + if (utime(dir, &ubuf) < 0 && errno != EPERM) { + report(dir); return; + } + } } } @@ -382,7 +394,7 @@ void copylink(char *source, char *dest, int mode, int owner, int group) /* Set the mode again, chown may have wrecked it. */ (void) chmod(dest, mode); } - if (!change) { + if (!change || pflag) { struct utimbuf ubuf; ubuf.actime= dst.st_atime; @@ -398,8 +410,8 @@ void usage(void) { fprintf(stderr, "\ Usage:\n\ - install [-lcsz#] [-o owner] [-g group] [-m mode] [-S stack] [file1] file2\n\ - install [-lcsz#] [-o owner] [-g group] [-m mode] [-S stack] file ... dir\n\ + install [-lcpsz#] [-o owner] [-g group] [-m mode] [-S stack] [file1] file2\n\ + install [-lcpsz#] [-o owner] [-g group] [-m mode] [-S stack] file ... dir\n\ install -d [-o owner] [-g group] [-m mode] directory\n"); exit(1); } @@ -447,6 +459,7 @@ void main(int argc, char **argv) case 'c': cflag= 1; break; case 's': strip= 1; break; case 'd': dflag= 1; break; + case 'p': pflag= 1; break; case 'z': if (compress == nil) { compress= COMPRESS; diff --git a/man/man1/install.1 b/man/man1/install.1 index 081dd6ac4..d76356f78 100644 --- a/man/man1/install.1 +++ b/man/man1/install.1 @@ -5,7 +5,7 @@ install \- install files .in +5 .ti -5 .B install -.RB [ \-lcsz\fIN\fP "] [" \-o +.RB [ \-lcpsz\fIN\fP "] [" \-o .IR owner ] .RB [ \-g .IR group ] @@ -18,7 +18,7 @@ install \- install files .br .ti -5 .B install -.RB [ \-lcsz\fIN\fP "] [" \-o +.RB [ \-lcpsz\fIN\fP "] [" \-o .IR owner ] .RB [ \-g .IR group ] @@ -80,6 +80,9 @@ is not given. With .BR \-l , the file is copied if the link fails. .TP +.B \-p +Preserve timestamp on source file or directory. +.TP .B \-s Strip the destination file of its symbol table, .I if