ar: enable reproducible output by default when invoked as 'ar -s'

ar output is already deterministic by default for ar -q and ar -r, and
when invoked as ranlib. Make ar -s equivalent to ranlib and enable
deterministic output by default in that case too.

PR:		210330
Reviewed by:	bdrewery
Approved by:	re (gjb)
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D6871
This commit is contained in:
emaste 2016-06-16 21:22:26 +00:00
parent 0178fb72fc
commit 71cb38c340
2 changed files with 9 additions and 3 deletions

View File

@ -23,7 +23,7 @@
.\"
.\" $FreeBSD$
.\"
.Dd July 24, 2015
.Dd June 16, 2016
.Dt AR 1
.Os
.Sh NAME
@ -205,7 +205,12 @@ When used in combination with the
.Fl r
or
.Fl q
option, insert 0's instead of the real mtime, uid and gid values
option,
with the
.Fl s
option without other options, or when invoked as
.Nm ranlib ,
insert 0's instead of the real mtime, uid and gid values
and 0644 instead of file mode from the members named by arguments
.Ar .
This ensures that checksums on the resulting archives are reproducible

View File

@ -283,7 +283,8 @@ main(int argc, char **argv)
}
/* Set determinstic mode for -D, and by default without -U. */
if (Dflag || (Uflag == 0 && (bsdar->mode == 'q' || bsdar->mode == 'r')))
if (Dflag || (Uflag == 0 && (bsdar->mode == 'q' || bsdar->mode == 'r' ||
(bsdar->mode == '\0' && bsdar->options & AR_S))))
bsdar->options |= AR_D;
if (bsdar->options & AR_A)