aboutsummaryrefslogtreecommitdiff
path: root/usr.bin/xinstall
Commit message (Collapse)AuthorAgeFilesLines
* install: Expect EINTR while copyingDag-Erling Smørgrav2026-02-112-22/+60
| | | | | | | | | | | | | | | Both copy_file_range() and read() / write() in our fallback loop can be interrupted before copying anything at all, in which case it returns -1 and sets errno to EINTR. If that happens, we should retry, not fail. While here, drop the size argument from copy() (we always want to copy the entire file anyway) and add test cases which exercise the metalog and digest functionality. PR: 293028 MFC after: 1 week Reviewed by: kevans Differential Revision: https://reviews.freebsd.org/D55168
* xinstall: Don't use UF_SETTABLE to infer whether st_flags is presentJessica Clarke2025-05-061-1/+1
| | | | | | | | | A future commit will add definitions of these for use in bootstrap tools on Linux, but struct stat will still be the host's that lacks st_flags. Switch this to just check for Linux instead, matching nbtool_config.h. Reviewed by: emaste, markj, imp Differential Revision: https://reviews.freebsd.org/D50079
* install: Fix METALOG ouptut for numeric -o and -g argsEd Maste2025-01-211-4/+16
| | | | | | | | | | | | | | | | | | | install's -o and -g flags both accept a name or a numeric argument. In -U -M (non-root METALOG) mode it always emitted uname= and gname= in the METALOG, but these are not appropriate for numeric IDs. If the -o and/or -u arguments parse as an ID, emit uid= and/or gid= respectively. Note that if an argument is valid as both a name and numeric ID we will prefer the name in normal (non -U -M) mode and the ID in -U -M mode. We don't want to require a passwd db in non-root mode, and entirely-numeric user or group names are a terrible idea so just accept this discrepancy. PR: 284119 Reviewed by: jlduran Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D48504
* install: print directory name instead of file name if mkstemp failsAhmad Khalifa2024-11-292-1/+11
| | | | | | | | | | | Printing the file name doesn't make sense since mkstemp failing means that the file wasn't created. Also add a test case for this. Co-authored-by: Jose Luis Duran <jlduran@gmail.com> Reviewed by: imp,jhb Pull Request: https://github.com/freebsd/freebsd-src/pull/1383
* Remove residual blank line at start of MakefileWarner Losh2024-07-152-2/+0
| | | | | | | This is a residual of the $FreeBSD$ removal. MFC After: 3 days (though I'll just run the command on the branches) Sponsored by: Netflix
* install: Fix a compiler warning when bootstrappingMark Johnston2024-04-191-0/+2
| | | | | | Fixes: 4336161cc9c6 ("install: Don't skip syncing in the common case.") Reviewed by: imp, des Differential Revision: https://reviews.freebsd.org/D44866
* install: Assorted nitpickery.Dag-Erling Smørgrav2024-04-171-23/+17
| | | | | | | | | | | | | | | | * Use `errc()` instead of manually setting `errno` before calling `err()`. * Change one warning into a fatal error. * Drop some unnecessary casts. * `strlcat()` bounds checks were off-by-one. This does not matter in practice because the subsequent code renders an overrun harmless. * We were passing `SSIZE_MAX` to `copy_file_range()` instead of the requested size. This only matters if we're asked to install a file which is still being written to while we are copying it. MFC after: 1 week Sponsored by: Klara, Inc. Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D44810
* install: Remove the mmap(2) option.Dag-Erling Smørgrav2024-04-172-148/+67
| | | | | | | | | | | We already removed it from cp(1) over a year ago but never followed up here. Do so now, for the same reasons: significant complexity for little to no benefit. MFC after: 1 week Sponsored by: Klara, Inc. Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D44809
* install: Don't skip syncing in the common case.Dag-Erling Smørgrav2024-04-121-7/+5
| | | | | | | | | | | | | | In `copy()`, if no digest was requested (which is the common case), we use `copy_file_range()` to avoid needlessly copying the contents of the file into user space and back. When `copy_file_range()` returns successfully (which, again, is the common case), we simply return, and therefore never get to the point where we call `fsync()` if the `-S` option was specified. Fix this. MFC after: 1 week Sponsored by: Klara, Inc. Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D44756
* install: Simplify path construction.Dag-Erling Smørgrav2024-04-122-13/+29
| | | | | | | | | | | | | | | There's no need to copy the path twice to split it into base and dir. We simply call `basename()` first, then handle the two trivial cases in which it isn't safe to call `dirname()`. While here, add an early check that the destination is not an empty string. This would always fail eventually, so it may as well fail right away. Also add a test case for this shortcut. MFC after: 1 week Sponsored by: Klara, Inc. Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D44743
* install: Always use a temporary file.Dag-Erling Smørgrav2024-04-122-124/+33
| | | | | | | | | | | | | | | | | | | | | | Previously, we would only use a temporary file if explicitly asked to with the `-S` option, and even then, only if the target file already existed. This meant that an outside observer looking for the target file might see a partial file, and might see the file disappear and then reappear. With this patch, we always use a temporary file, ensuring atomicity. The downside is slightly increased disk usage. The upside is never having to worry about, for instance, cron jobs randomly failing if they happen to run simultaneously with `make installworld`. The `-S` option is retained, partly for compatibility, and partly to control the use of `fsync(2)`, which has a non-negligible cost (approximately 10% increase in wall time for `make installworld`). MFC after: 1 week Sponsored by: Klara, Inc. Reviewed by: 0mp, brooks, imp, markj Differential Revision: https://reviews.freebsd.org/D44742
* install: Prefer strsnvis() to strsvis().Dag-Erling Smørgrav2024-03-271-8/+11
| | | | | | | MFC after: 1 week Sponsored by: Klara, Inc. Reviewed by: allanjude Differential Revision: https://reviews.freebsd.org/D44514
* install(1): Fix typo in usr.bin/xinstall/xinstall.cLO WEN-CHIEN2024-02-131-1/+1
| | | | | Event: Advanced UNIX Programming Course (Fall’23) at NTHU Pull Request: https://github.com/freebsd/freebsd-src/pull/1012
* Remove copyright strings ifdef'd outWarner Losh2023-11-271-10/+0
| | | | | | | | | | | We've ifdef'd out the copyright strings for some time now. Go ahead and remove the ifdefs. Plus whatever other detritis was left over from other recent removals. These copyright strings are present in the comments and are largely from CSRG's attempt at adding their copyright to every binary file (which modern interpretations of the license doesn't require). Sponsored by: Netflix
* usr.bin: Remove ancient SCCS tags.Warner Losh2023-11-273-6/+0
| | | | | | | | Remove ancient SCCS tags from the tree, automated scripting, with two minor fixup to keep things compiling. All the common forms in the tree were removed with a perl script. Sponsored by: Netflix
* install: handle -m +X more accuratelyKyle Evans2023-10-192-2/+26
| | | | | | | | | | | | | | As described by chmod(1), +X in the mode may be used to optionally set the +x bit if the file is a directory if any of the execute/search bits are set in the original mode. The latter is not applicable because we assume -m is a fresh mask, but a functional +X could be useful in the former case if we're passing along a common INSTALL_MODE that's designed to install either 0644 or 0755 depending simply on whether it's a directory or not. Reviewed by: des Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D42273
* Remove $FreeBSD$: one-line nroff patternWarner Losh2023-08-161-1/+0
| | | | Remove /^\.\\"\s*\$FreeBSD\$$\n/
* Remove $FreeBSD$: one-line sh patternWarner Losh2023-08-165-5/+0
| | | | Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/
* Remove $FreeBSD$: one-line .c patternWarner Losh2023-08-161-2/+0
| | | | Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
* xinstall: do not use copy_file_range(2) when BOOTSTRAPPINGMartin Matuska2023-07-082-0/+9
| | | | Reported by: arichardson
* xinstall: use copy_file_range(2) with fallback to previous behaviorMartin Matuska2023-07-081-0/+21
| | | | | | | | | | | This allows to use special filesystem features like server-side copying on NFS 4.2 or block cloning on OpenZFS 2.2. Note: copy_file_range(2) is not used when a digest calculation is requested as this would require to read the input file twice. Reviewed by: asomers, imp, rmacklem Differential revision: https://reviews.freebsd.org/D40898
* Update/fix Makefile.depend for userlandSimon J. Gerraty2023-04-191-1/+0
|
* xinstall: alphabetize: upper case precedes lower.Dag-Erling Smørgrav2022-08-041-7/+7
| | | | Sponsored by: Klara, Inc.
* xinstall: use dynamic bufsize as in cat(1) / cp(1).Dag-Erling Smørgrav2022-08-031-5/+53
| | | | Sponsored by: Klara, Inc.
* xinstall: make md5 and ripemd160 conditionalDag-Erling Smørgrav2022-08-032-1/+34
| | | | Sponsored by: Klara, Inc.
* xinstall: fix dounpriv logic, add testsDag-Erling Smørgrav2022-08-032-8/+87
| | | | | Sponsored by: Klara, Inc. MFC after: 1 week
* pkgbase: Put more binaries/lib in runtimeEmmanuel Vadot2021-12-211-0/+2
| | | | | | | | | Move some needed binaries/libs from FreeBSD-utilities to FreeBSD_runtime. This is everything needed to boot to multiuser with FreeBSD-rc installed. MFC after: 2 weeks Sponsored by: Beckhoff Automation GmbH & Co. KG Differential Revision: https://reviews.freebsd.org/D33435
* xinstall: fix invocation of llvm-stripMitchell Horne2021-08-301-5/+15
| | | | | | | | | | | | | | | | | When executing strip(1), '--' is passed as an argument to explicitly terminate the getopt(3) loop. The option parsing in llvm-strip doesn't support this however, so setting XSTRIPBIN=llvm-strip results in an unsupported argument error. llvm-strip(1) is otherwise commandline-compatible with FreeBSD's strip(1), so just use the documented argument format that is common to both. Special care needs to be taken for filenames beginning with a '-'. Reviewed by: arichardson, eugen (earlier version, both) Discussed with: jilles Sponsored by: NetApp, Inc. Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D30614
* install(1): Avoid unncessary fstatfs() calls and use mmap() based on sizeAlex Richardson2020-10-141-23/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | According to git blame the trymmap() function was added in 1996 to skip mmap() calls for NFS file systems. However, nowadays mmap() should be perfectly safe even on NFS. Importantly, onl ufs and cd9660 file systems were whitelisted so we don't use mmap() on ZFS. It also prevents the use of mmap() when bootstrapping from macOS/Linux since on those systems the trymmap() function was always returning zero due to the missing MFSNAMELEN define. This change keeps the trymmap() function but changes it to check whether using mmap() can reduce the number of system calls that are required. Using mmap() only reduces the number of system calls if we need multiple read() syscalls, i.e. if the file size is > MAXBSIZE. However, mmap() is more expensive than read() so this sets the threshold at 4 fewer syscalls. Additionally, for larger file size mmap() can significantly increase the number of page faults, so avoid it in that case. It's unclear whether using mmap() is ever faster than a read with an appropriate buffer size, but this change at least removes two unnecessary system calls for every file that is installed. Reviewed By: markj Differential Revision: https://reviews.freebsd.org/D26041 Notes: svn path=/head/; revision=366697
* Allow install(1)'s create_tempfile() to work on Linux hostsAlex Richardson2020-07-152-5/+5
| | | | | | | | | | | GLibc expects six 'X' characters in the mkstemp template argument and will return EINVAL otherwise. Reviewed By: emaste, imp, mjg Differential Revision: https://reviews.freebsd.org/D25662 Notes: svn path=/head/; revision=363230
* install(1): another correction after r363064Eugene Grosbein2020-07-121-9/+16
| | | | | | | | | | | | Make sure we call fsync(2) on strip result in case of "safecopy" and "strip -o tempcopy -- src" before renaming tempcopy to destination. MFC after: 3 weeks X-MFC-With: r363064 Notes: svn path=/head/; revision=363136
* Fix the tests for install(1): add support for STRIPBIN's -o option.Eugene Grosbein2020-07-101-2/+6
| | | | | | | | Reported by: lwhsu MFC after: 1 week Notes: svn path=/head/; revision=363088
* install(1): addition to r363067Eugene Grosbein2020-07-101-1/+1
| | | | | | | | | | | | Also, make it not break if STRIPBIN points to strip version without -o support and destination does not exist before installing. Reported by: lwhsu MFC after: 1 month X-MFC-With: 363064 Notes: svn path=/head/; revision=363081
* install(1): correction after r363064Eugene Grosbein2020-07-101-1/+1
| | | | | | | | | | | Make it not break if STRIPBIN points to strip version without -o support. In that case, perform extra copy just like before r363064. MFC after: 1 month X-MFC-With: 363064 Notes: svn path=/head/; revision=363067
* Optimize install(1) a bit.Eugene Grosbein2020-07-101-23/+50
| | | | | | | | | | | | | | | | | | | | | | Currently, "install -s -S" behaviour is inefficient for upgrade. First it finds that destination file already exists and copies source file to temporary file. Then it calls strip(1) with name of temporary file as single agrument and our strip(1) creates another temporary file in the /tmp (or TMPDIR) making another copy that is finally copied to DESTDIR third time. Meantime, strip(1) has an option "-o dst" to specify destination so install(1) is allowed to skip initial copying from obj to DESTDIR. This change makes it do so. Take a look at https://reviews.freebsd.org/D25551 for details and efficiency numbers (in short: upto 32% gained for installword). MFC after: 1 month Differential Revision: https://reviews.freebsd.org/D25551 Notes: svn path=/head/; revision=363064
* Allow boostrapping xinstall on LinuxAlex Richardson2019-11-202-1/+11
| | | | | | | | | | Linux does not have st_flags so we have to avoid using it there. Reviewed By: emaste, imp Differential Revision: https://reviews.freebsd.org/D22446 Notes: svn path=/head/; revision=354901
* install.1: Add missing arguments to option descriptionsMateusz Piotrowski2019-08-121-13/+9
| | | | | | | | | | | | | While here: - Remove deprecated Tn macros. - Do not use macros with the -width option. Reviewed by: bcr Approved by: doc (bcr) Differential Revision: https://reviews.freebsd.org/D21173 Notes: svn path=/head/; revision=350895
* install(1): Fix relative path calculation with partial common dest/srcKyle Evans2019-01-312-2/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | | For example, from the referenced PR [1]: $ mkdir /tmp/lib/ /tmp/libexec $ touch /tmp/lib/foo.so $ install -lrs /tmp/lib/foo.so /tmp/libexec/ The common path identification bits terminate src at /tmp/lib/ and the destination at /tmp/libe. The subsequent backtracking is then incorrect, as it traverses the destination and backtraces exactly one level while eating the 'libexec' because it was previously (falsely) identified as common with 'lib'. The obvious fix would be to make sure we've actually terminated just after directory separators and rewind a character if we haven't. In the above example, we would end up rewinding to /tmp/ and subsequently doing the right thing. Test case added. PR: 235330 [1] MFC after: 1 week Notes: svn path=/head/; revision=343601
* When doing a -S "safe copy", the install command should do anKirk McKusick2018-08-271-0/+6
| | | | | | | | | | | | fsync(2) system call after copying the installed file to ensure that it is on stable storage. PR: 230851 Reviewed by: kib Approved by: re (marius) Notes: svn path=/head/; revision=338340
* Allow xinstall and makefs to be crossbuilt on Linux and MacAlex Richardson2018-01-162-1/+23
| | | | | | | | | | | | | | I need these tools in order to install the crossbuilt FreeBSD and create a disk image. Linux does not have a st_flags in struct stat so unfortunately I need a bunch of ugly ifdefs. The resulting binaries allow me to sucessfully install a MIPS64 world and create a disk-image that boots. Reviewed By: brooks, bdrewery, emaste Approved By: jhb (mentor) Differential Revision: https://reviews.freebsd.org/D13307 Notes: svn path=/head/; revision=328064
* General further adoption of SPDX licensing ID tags.Pedro F. Giffuni2017-11-201-1/+3
| | | | | | | | | | | | | | | | | 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. Notes: svn path=/head/; revision=326025
* DIRDEPS_BUILD: Update dependencies.Bryan Drewery2017-10-311-1/+0
| | | | | | | Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=325188
* xinstall: plug an infinite loop in directory creationMateusz Guzik2017-10-121-2/+4
| | | | | | | | | | | | If stat continues to fail with ENOENT and mkdir with EEXIST the code wont finish. In particular this can show up when the target path follows through a symlink to a non-existent directory. Reported by: ae MFC after: 1 week Notes: svn path=/head/; revision=324547
* Add HAS_TESTS to all Makefiles that are currently using theEnji Cooper2017-08-021-0/+1
| | | | | | | | | `SUBDIR.${MK_TESTS}+= tests` idiom. This is a follow up to r321912. Notes: svn path=/projects/make-check-sandbox/; revision=321914
* Convert traditional ${MK_TESTS} conditional idiom for including testEnji Cooper2017-08-021-3/+1
| | | | | | | | | | | | | | directories to SUBDIR.${MK_TESTS} idiom This is being done to pave the way for future work (and homogenity) in ^/projects/make-check-sandbox . No functional change intended. MFC after: 1 weeks Notes: svn path=/head/; revision=321912
* Adopt SRCTOP in usr.binWarner Losh2017-03-121-3/+3
| | | | | | | | | | | | Prefer ${SRCTOP}/foo over ${.CURDIR}/../../foo and ${SRCTOP}/usr.bin/foo over ${.CURDIR}/../foo for paths in Makefiles. Differential Revision: https://reviews.freebsd.org/D9932 Sponsored by: Netflix Silence on: arch@ (twice) Notes: svn path=/head/; revision=315170
* Restore some of the error message text accidentally removed in r315098Enji Cooper2017-03-121-2/+2
| | | | | | | | | | | | "unexpected symlink contents" is more pedantically correct than "unexpected symlink". MFC after: 1 week X-MFC with: r315098 Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=315108
* Add 3 more testcases demonstrating how install -l sr worksEnji Cooper2017-03-121-0/+66
| | | | | | | | | | | | | | | The additional testcases use absolute paths for sources and targets, as the other testcase which tested `-l sr` used flat relative paths in the same directory. Please note that these testcases do not test `-l a` -- that's already addressed in the battery of tests. MFC after: 1 week Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=315106
* Clarify src vs dest path mismatch in :symbolic_link_{absolute,relative}_bodyEnji Cooper2017-03-121-2/+10
| | | | | | | | | | | | | | Unfortunately kyua does not omit the path mismatch on failure, so it must be coded into the error message. Cache the values, run the test(1) call, then print out the values in an atf_fail call to emit the required diagnostics to debug why things are failing. MFC after: 1 week Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=315098
* DIRDEPS_BUILD: Add some missing dirctories to the build.Bryan Drewery2016-08-311-0/+11
| | | | | | | Sponsored by: EMC / Isilon Storage Division Notes: svn path=/head/; revision=305148