Commit graph

45 commits

Author SHA1 Message Date
Warner Losh 1d386b48a5 Remove $FreeBSD$: one-line .c pattern
Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
2023-08-16 11:54:42 -06:00
Mark Johnston 41e6398f9b ar: Avoid overwriting the stdout file stream pointer
This doesn't work with musl, which defines stdout as FILE * const.
Instead, explicitly pass the desired output stream to ar_read_archive().

No functional change intended.

Reviewed by:	emaste
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D34064
2022-01-27 17:10:17 -05:00
Ed Maste 1a0a41b105 ar: accept but ignore 'T' option
In previous versions of BSD ar -T was an alias for -f -- use only the
first 15 characters of archive member names.  In GNU ar and LLVM ar -T
creates a thin archive.

The -f / old BSD ar -T functionality is not particularly useful, and
ignoring -T still results in a usable and compatible (but not thin)
archive.

An exp-run found a few ports invoking ar -T but they all expect thin
archives.  In addition, -T will be used to specify thin archives after
a migration to LLVM-ar.

PR:             260523 [exp-run]
Reviewed by:	markj
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D33553
2022-01-03 11:42:59 -05:00
Ed Maste edadbb4606 ar: deprecate -T option
Other ar implementations (GNU, LLVM) use -T to mean thin archive
rather than use only the first fifteen characters of the archive member
name.  We support both -T and -f for this, with -f documented as an
alias of -T.

An exp-run showed that the ports invoking `ar -T` expect thin archives,
not truncated names.  Switch -f to be the documented flag for this
behaviour, and emit a warning when -T is used.

The warning will be changed to an error in the future (in main), once
ports no longer use -T.

PR:		260523 [exp-run]
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2021-12-29 15:14:06 -05:00
Ed Maste 57aaefdcec ar: diff reduction against ELF Tool Chain
Remove ar_mode_* wrappers and call ar_read_archive / ar_write_archive
directly.

(This was originally committed in d20e9e02db but reverted due to a
regression, now fixed with an update from cy@.)

Obtained from:	ELF Tool Chain
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D31496
2021-08-13 11:17:46 -04:00
Ed Maste 086f090877 ar: diff reduction against ELF Tool Chain
Drop exit status from bsdar_errc.  ELF Tool Chain always returns
EXIT_FAILURE in bsdar_errc.

Recommit of one part of d20e9e02db / review D31496.

Obtained from:	ELF Tool Chain
Sponsored by:	The FreeBSD Foundation
2021-08-13 10:39:44 -04:00
Ed Maste c5bf58add0 Revert "ar: diff reduction against ELF Tool Chain"
This reverts commit d20e9e02db.
It caused port build failures.

Reported by:	cy
2021-08-12 14:26:37 -04:00
Ed Maste d20e9e02db ar: diff reduction against ELF Tool Chain
- Drop exit status from bsdar_errc.  ELF Tool Chain always returns
  EXIT_FAILURE in bsdar_errc.

- Remove ar_mode_* wrappers and call ar_read_archive / ar_write_archive
  directly.

Obtained from:	ELF Tool Chain
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D31496
2021-08-11 19:12:46 -04:00
Ed Maste 38911b3c2c ar: provide error exit status upon failure
Previously ar and ranlib returned with exit status 0 (success) in the
case of a missing file or other error.  Update to use error handling
similar to that added by ELF Tool Chain after that project forked
FreeBSD's ar.

PR:		PR257599 [exp-run]
Reported by:	Shawn Webb, gehmehgeh (on HardenedBSD IRC)
Reviewed by:	markj
Obtained from:	elftoolchain
MFC after:	2 months
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D31402
2021-08-10 17:08:10 -04:00
Ed Maste be72428e54 usr.bin/ar: use standard 2-Clause FreeBSD license
Many licenses on ar files contained small variations from the standard
FreeBSD license text. To avoid license proliferation switch to the usual
2-clause FreeBSD license after obtaining permission from all copyright
holders.

Approved by:	jkoshy, kaiw, kientzle
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D14561
2018-06-20 18:43:17 +00:00
Ed Maste 9befbe457c usr.bin/ar: remove incorrect SPDX tags
Three ar files have a non-standard variation of the BSD license, so
remove their SPDX tags.

Sponsored by:	The FreeBSD Foundation
2018-06-19 17:30:11 +00:00
Pedro F. Giffuni 8a16b7a18f General further adoption of SPDX licensing ID tags.
Mainly focus on files that use BSD 3-Clause license.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.

Special thanks to Wind River for providing access to "The Duke of
Highlander" tool: an older (2014) run over FreeBSD tree was useful as a
starting point.
2017-11-20 19:49:47 +00:00
Ed Maste 11c4d924e1 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
2016-06-16 21:22:26 +00:00
Ed Schouten c76f604ee9 Make code compile when basename() is POSIX compliant.
If basename() uses "char *", we shouldn't do the intermediate
assignment, as that field is of type "const char *". Simply call
basename() on the command line argument directly.

Reviewed by:	emaste
Differential Revision:	https://reviews.freebsd.org/D6463
2016-05-19 20:03:01 +00:00
Ed Maste a84c4d189b ar: Deobfuscate a while loop 2015-08-31 18:07:17 +00:00
Ed Maste a64a36e280 ar: fix deterministic mode when running as ranlib
This was broken by r286024.

PR:		202741
Submitted by:	fk@fabiankeil.de
Obtained from:	ElectroBSD
2015-08-31 12:28:13 +00:00
Ed Maste a80ac30b2d ar: Fix deterministic mode default with options other than -q or -r
Reported by:	jhibbits
Reviewed by:	jhibbits
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D3237
2015-07-29 17:34:26 +00:00
Ed Maste fc964cbf4e ar: enable deterministic mode by default
Ar cannot handle UIDs with more than 6 digits, and storing the mtime,
uid, gid and mode provides little to negative value anyhow for ar's
uses. Turn on deterministic (-D) mode by default; it can be disabled by
the user with -U.

PR:		196929
Relnotes:	Yes
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D3190
2015-07-29 13:36:17 +00:00
Ed Maste 7072861cd0 ar: add -U (unique) option to disable -D (deterministic) mode
This is required in order for us to support deterministic mode by
default.  If multiple -D or -U options are specified on the command
line, the final one takes precedence.  GNU ar also uses -U for this.

An equivalent change will be applied to ELF Tool Chain's version of ar.

PR:		196929
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D3175
2015-07-24 17:46:43 +00:00
Martin Matuska 6c95142e79 Update libarchive to 3.0.3
Some of new features:
  - New readers: RAR, LHA/LZH, CAB reader, 7-Zip
  - New writers: ISO9660, XAR
  - Improvements to many formats, especially including ISO9660 and Zip
  - Stackable write filters to write, e.g., tar.gz.uu in a single pass
  - Exploit seekable input; new "seekable" Zip reader can exploit the Zip
    Central Directory when it's available; the old "streamable" Zip reader
    is still fully supported for cases where seeking is not possible.

Full release notes available at:
	https://github.com/libarchive/libarchive/wiki/ReleaseNotes
2012-02-25 10:58:02 +00:00
Benedict Reuschling 6bef5d2865 Correct typos in comments, no functional changes.
Found by:	codespell
Reviewed by:	kaiw
MFC after:	1 week
2011-05-20 11:29:09 +00:00
Kai Wang 773810fb45 Add option -D for ranlib(1). When -D is speicified, ranlib(1) will generate
a deterministic archive symbol table (i.e. timestamp for the symbol table
member header is set to 0).

Submitted by: 	 Erik Cederstrand
2010-11-28 18:53:57 +00:00
Tim Kientzle 0e479ac8f7 Add -D (deterministic) option to ar.
When set, it forces all timestamps and owners to zero and
modes to 0644.  Useful for producing libraries that are
bitwise identical across multiple build runs.

Submitted by:	Erik Cederstrand
Reviewed by:	Kai Wang
2010-10-09 05:31:08 +00:00
Kai Wang 5dfab45b42 Removed ar(1)'s support for compressed archives. This change removes
ar(1)'s dependencies on compressor libraries -lz, -lbz2 and -llzma and
fixes building HEAD on some versions of FreeBSD[78]. Option -j and -z
is now accepted but ignored.

Compressed ar(1) archives are not useful without a ld(1) that can read
them. Also, the current ar(1) compression scheme prevents random
access of archive members and needs to be redesigned anyway.

Submitted by:	kientzle (original patch)
Reviewed by:	delphij
Discussed on:	-current mailing list
2010-05-17 09:37:59 +00:00
Ed Schouten ef636796f6 ANSIfy various tools in usr.bin/.
Most of these tools properly build at WARNS=6, except for their K&R
function declarations. Fix this, so we can bump WARNS as well.
2010-01-02 10:09:20 +00:00
Tim Kientzle f05da0e980 Act like ranlib if our name ends in ranlib. In particular,
this works with some recent cross-building changes by Warner
that install ranlib as, e.g., "arm-freebsd7.1-ranlib".

Submitted by:	John Hein
2009-03-20 17:11:45 +00:00
Kai Wang 0c099281a3 Add support for option "-M", which is used to operate ar(1) in a
script mode like the MRI(Microtec Research Inc.) "librarian" program.

Originally this option is provided by Binutils ar(1) to ease the
transition for developers who are used to writing "librarian" scripts.

We added this option to BSD ar(1) because:

1. Further improve the compatibility with Binutils ar(1).
2. There are still a few software using this -M option. (at least one
in our ports collection)

Suggested by:	rink & erwin
2008-09-20 22:10:10 +00:00
Kai Wang cb0dad38e4 GNU ar did NOT implment option -q as a synonym of -r as the manual
page stated, thus BSD ar(1) option -q, which was implemented based on
the GNU ar manual page, turns out to be incompatible with GNU ar -q.

This change will make BSD ar(1) -q a *REAL* GNU ar -q:

1. It will update symbol table. (same as unfixed version)
2. It will NOT compare new members spcified in the command line args
   with existing members, instead, append them directly.

Reported by:	  Johannes 5 Joemann <joemann@beefree.free.de>
Reported by:	  Timothy Bourke <timbob@bigpond.com>
Tested by:	  Johannes 5 Joemann <joemann@beefree.free.de>
Reviewed by:	  jkoshy
Approved by:	  jkoshy (mentor)
2008-03-11 18:35:51 +00:00
Kai Wang a711c209bc Since the program is installed as 'bsdranlib', we need to
check if it is invoked as 'bsdranlib'.

Reported by:	Michael Plass <mfp49_freebsd [AT] plass-family [DOT] net>
Reviewed by:	Michael Plass <mfp49_freebsd [AT] plass-family [DOT] net>
Reviewed by:	jkoshy
Approved by:	jkoshy (mentor)
2008-02-24 18:07:46 +00:00
Kai Wang d192f3d3c3 Import ar(1) front-end. (aka 'BSD' ar)
Reviewed by: 		jkoshy
Approved by:		jkoshy (mentor)
Tested by:		erwin (ports build test on pointyhat)
Sponsored by:		Google Summer of Code 2007
Reviewed by (earlier version): Jaakko Heinonen <jh[AT]saunalahti.fi>
Tested by (earlier version): Steve Kargl <sgk[AT]troutmask.apl.washington.edu>
Tested by (earlier version): Martin Voros <martin_voros[AT]yahoo.com>
Tested by (earlier version): swell.k[AT]gmail.com
Tested by (earlier version): joel
Tested by (earlier version): Alexey Shuvaev <shuvaev[AT]physik.uni-wuerzburg.de>
Tested by (earlier version): Arjan van Leeuwen <avleeuwen[AT]gmail.com>

Thanks to gabor@ for building ports for it.
Thanks to erwin@ and kris@ for scheduling the ports build test on pointyhat.
And thanks to many others for their feedback.
2008-02-21 10:52:31 +00:00
David E. O'Brien f6d8a17fe8 Finish the deorbital burn of the i386-only a.out toolchain. 2003-06-27 03:59:46 +00:00
Alfred Perlstein da8de1e204 WARNS=4 2002-07-14 18:23:22 +00:00
Warner Losh f1bb2cd2aa remove __P 2002-03-22 01:22:50 +00:00
David Malone 9f5b04e925 Style improvements recommended by Bruce as a follow up to some
of the recent WARNS commits. The idea is:

1) FreeBSD id tags should follow vendor tags.
2) Vendor tags should not be compiled (though copyrights probably should).
3) There should be no blank line between including cdefs and __FBSDIF.
2001-12-10 21:13:08 +00:00
Mark Murray 01823518f5 Use __FBSDID(). 2001-12-02 20:45:24 +00:00
Mark Murray 865eb33a74 WARNS=2 fixup. 2001-12-02 12:36:35 +00:00
David E. O'Brien 9ebd5897b2 Replace the local rname' with the cannonical basename'. 2001-07-24 14:04:20 +00:00
Peter Wemm c3aac50f28 $Id$ -> $FreeBSD$ 1999-08-28 01:08:13 +00:00
Archie Cobbs 5d2b41cb4e Eliminate compiler warnings from -Wall 1998-12-06 07:36:44 +00:00
Philippe Charnier 911091e7fc Convert man page to mdoc format. Cosmetic in usage string. 1997-06-23 06:41:30 +00:00
Warner Losh 1c8af87873 compare return value from getopt against -1 rather than EOF, per the final
posix standard on the topic.
1997-03-29 04:34:07 +00:00
Jean-Marc Zucconi d508ff27b1 The -q option does not require a list of elements: the command 'ar q foo.a'
is perfectly valid and eventually creates an empty archive.
This is consistent with OSF1 V3.x, SunOS 4.x, ULTRIX 4.x and probably others.
1996-10-17 22:13:36 +00:00
Andrey A. Chernov 6e9804553e Add setlocale LC_TIME 1995-10-24 05:37:15 +00:00
Rodney W. Grimes 7799f52a32 Remove trailing whitespace. 1995-05-30 06:41:30 +00:00
Rodney W. Grimes 9b50d90275 BSD 4.4 Lite Usr.bin Sources 1994-05-27 12:33:43 +00:00