pkgsrc/archivers/pax/files/cpio.1
minskim 3f8fb63c0c Update pax to 20051108. The previous version failed to handle the -X
option, which is used in print/teTeX3-texmf.  The only difference from
the pax in src is that tar does not support the --chroot option if
fchroot(2) is not available.


Major changes and bug fixes since 20040802:

PR/18759: FUKAUMI Naoki: pax/tar dot-dot handling broken
PR/18840: Frederick Bruckman:  Fix for PR/18663 incomplete pax symlink handling
This patch makes ``--insecure'' do something. Now if ``--insecure''
is not set (the default) we do a realpath(3) in all the pathnames
that we are trying to create and if either realpath fails, or the
path is outside our working directory, we print a warning and die.
This maybe too strict and might fail on valid archives that create
symlinks and directories in the wrong order.

PR/31923: Sergey Svishchev: pax-as-tar ignores -k, overwrites existing files
Fix from Onno van der Linden

PR/30132: Juan RP: tar --chroot refuses to extract files.
fchroot() changes the effective path, so we need to call updatepath().

Apply user supplied patterns first before applying actions for -A. This way pax
behavior WRT to patterns lines up with the example in the documentation
and how other implementations do it as well since -A is a non-standard
option/behavior. Fixes items noted in PR#23776

Add an option --chroot to tar.  Causes it to chroot(".") before doing
an extract.  With -h this will cause existing absolute symlinks to be treated
as relative to the current directory.
Helps sysinst handle existing symlinks in the target system.
Remove 'L' from the usage (got spilt into 'h' and 'H' many moons ago)
Add 'S' to usage, and put into correct place in options list.

PR/27213: Greg A. Woods: pax doesn't honour SIGPIPE when listing
But always exit, not just on SIGPIPE.

Properly handle "cpio" archives where the last hardlink includes the
data of a file. This fixes PR bin/26514.

PR/20228: Simon Burge: pax has problems reading a particular cpio archive
The problem here is that the archive is too short (< 512 bytes). The
buffer routines, try to read at least 512 bytes, even when we try to determine
what format file we have, which is wrong.

Don't leave arcn->org_name pointing to ftent->fts_path, if we being cpio
then ftent is freed just below.  Take a copy of the name and point org_name
at the copy.
Should fix PR/30627 (the fix in the PR will break pax and tar!)

PR/30167: J.T. Conklin: NetBSD tar does not support GNU tar --no-recursion flag

Fix from PR#29290. Properly terminate the cpio_longopts struct so an unknown
option doesn't run off the end and core dump

Fix broken cpio(1) option handling:
- "cpio -i -t" should list the contents of a file, not extract it.
- Don't extract a file when only option "-d" is given.
Patch supplied by Paul Ripke in PR bin/26513.

PR/27212: Greg A. Woods: Accept "-C <dirname>" inside filelists in addition
to "-C\n<dirname>".
But we are not making it the default output option as the patch suggests.

PR/19490: Julio Merino: Teach tar about --sparse, -S option.
Do it for cpio too.

PR/27208: Greg A. Woods: pax must call options() before using syswarn()
or tty_warn()

PR/20071: Perry Metzger: --extract handling is broken. This patch fixes
Perry's example.
2005-12-01 03:00:01 +00:00

302 lines
7.5 KiB
Groff

.\" $NetBSD: cpio.1,v 1.3 2005/12/01 03:00:01 minskim Exp $
.\"
.\" Copyright (c) 1997 SigmaSoft, Th. Lockert
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
.\" OpenBSD: cpio.1,v 1.14 2000/11/10 17:52:02 aaron Exp
.\"
.Dd February 13, 2004
.Dt CPIO 1
.Os
.Sh NAME
.Nm cpio
.Nd copy file archives in and out
.Sh SYNOPSIS
.Nm cpio
.Fl o
.Op Fl aABcLvzZ
.Op Fl C Ar bytes
.Op Fl F Ar archive
.Op Fl H Ar format
.Op Fl O Ar archive
.Ar "\*[Lt] name-list"
.Op Ar "\*[Gt] archive"
.Nm cpio
.Fl i
.Op Fl bBcdfmrsStuvzZ6
.Op Fl C Ar bytes
.Op Fl E Ar file
.Op Fl F Ar archive
.Op Fl H Ar format
.Op Fl I Ar archive
.Op Ar "pattern ..."
.Op Ar "\*[Lt] archive"
.Nm cpio
.Fl p
.Op Fl adlLmuv
.Ar destination-directory
.Ar "\*[Lt] name-list"
.Sh DESCRIPTION
The
.Nm
command copies files to and from a
.Nm
archive.
If the archive is of the form:
.Ar [[user@]host:]file
then the archive will be processed using
.Xr rmt 8 .
.Pp
The options are as follows:
.Bl -tag -width Ds
.It Fl o , -create
Create an archive.
Reads the list of files to store in the
archive from standard input, and writes the archive on standard
output.
.Bl -tag -width Ds
.It Fl a , -reset-access-time
Reset the access times on files that have been copied to the
archive.
.It Fl A , -append
Append to the specified archive.
.It Fl B
Set block size of output to 5120 bytes.
.It Fl c
Use ASCII format for
.Nm
header for portability.
.It Fl C Ar bytes
Set the block size of output to
.Ar bytes .
.It Fl F Ar archive
.It Fl O Ar archive
Use the specified file name as the archive to write to.
.It Fl H Ar format
Write the archive in the specified format.
Recognized formats are:
.Pp
.Bl -tag -width sv4cpio -compact
.It Ar bcpio
Old binary
.Nm
format.
.It Ar cpio
Old octal character
.Nm
format.
.It Ar sv4cpio
SVR4 hex
.Nm
format.
.It Ar tar
Old tar format.
.It Ar ustar
POSIX ustar format.
.El
.It Fl L
Follow symbolic links.
.It Fl v
Be verbose about operations.
List filenames as they are written to the archive.
.It Fl z
Compress archive using
.Xr gzip 1
format.
.It Fl Z
Compress archive using
.Xr compress 1
format.
.El
.It Fl i , -extract
Restore files from an archive.
Reads the archive file from
standard input and extracts files matching the
.Ar patterns
that were specified on the command line.
.Bl -tag -width Ds
.It Fl b
Do byte and word swapping after reading in data from the
archive, for restoring archives created on systems with
a different byte order.
.It Fl B
Set the block size of the archive being read to 5120 bytes.
.It Fl c
Expect the archive headers to be in ASCII format.
.It Fl C Ar bytes
Read archive written with a block size of
.Ar bytes .
.It Fl d , -make-directories
Create any intermediate directories as needed during
restore.
.It Fl E Ar file , Fl -pattern-file Ar file
Read list of file name patterns to extract or list from
.Ar file .
.It Fl f , -nonmatching
Restore all files except those matching the
.Ar patterns
given on the command line.
.It Fl F Ar archive , Fl -file Ar archive
.It Fl I Ar archive
Use the specified file as the input for the archive.
.It Fl H Ar format , Fl -format Ar format
Read an archive of the specified format.
Recognized formats are:
.Pp
.Bl -tag -width sv4cpio -compact
.It Ar bcpio
Old binary
.Nm
format.
.It Ar cpio
Old octal character
.Nm
format.
.It Ar sv4cpio
SVR4 hex
.Nm
format.
.It Ar tar
Old tar format.
.It Ar ustar
POSIX ustar format.
.El
.It Fl m
Restore modification times on files.
.It Fl r , -rename
Rename restored files interactively.
.It Fl s
Swap bytes after reading data from the archive.
.It Fl S , -swap-halfwords
Swap words after reading data from the archive.
.It Fl t , -list
Only list the contents of the archive, no files or
directories will be created.
.It Fl u , -unconditional
Overwrite files even when the file in the archive is
older than the one that will be overwritten.
.It Fl v , -verbose
Be verbose about operations.
List filenames as they are copied in from the archive.
.It Fl z
Uncompress archive using
.Xr gzip 1
format.
.It Fl Z
Uncompress archive using
.Xr compress 1
format.
.It Fl 6
Process old-style
.Nm
format archives.
.El
.It Fl p , -pass-through
Copy files from one location to another in a single pass.
The list of files to copy are read from standard input and
written out to a directory relative to the specified
.Ar directory
argument.
.Bl -tag -width Ds
.It Fl a
Reset the access times on files that have been copied.
.It Fl d
Create any intermediate directories as needed to write
the files at the new location.
.It Fl l , -link
When possible, link files rather than creating an
extra copy.
.It Fl L , -dereference
Follow symbolic links.
.It Fl m , -preserve-modification-time
Restore modification times on files.
.It Fl u , -unconditional
Overwrite files even when the original file being copied is
older than the one that will be overwritten.
.It Fl v , -verbose
Be verbose about operations.
List filenames as they are copied.
.It Fl -force-local
Do not interpret filenames that contain a
.Sq \&:
as remote files.
.It Fl -insecure
Normally
.Nm
ignores filenames that contain
.Sq ..
as a path component. With this option,
files that contain
.Sq ..
can be processed.
.El
.El
.Sh EXIT STATUS
.Nm
will exit with one of the following values:
.Bl -tag -width 2n
.It 0
All files were processed successfully.
.It 1
An error occurred.
.El
.Pp
Whenever
.Nm
cannot create a file or a link when extracting an archive or cannot
find a file while writing an archive, or cannot preserve the user
ID, group ID, file mode, or access and modification times when the
.Fl p
option is specified, a diagnostic message is written to standard
error and a non-zero exit value will be returned, but processing
will continue.
In the case where
.Nm
cannot create a link to a file,
.Nm
will not create a second copy of the file.
.Pp
If the extraction of a file from an archive is prematurely terminated
by a signal or error,
.Nm
may have only partially extracted the file the user wanted.
Additionally, the file modes of extracted files and directories may
have incorrect file bits, and the modification and access times may
be wrong.
.Pp
If the creation of an archive is prematurely terminated by a signal
or error,
.Nm
may have only partially created the archive which may violate the
specific archive format specification.
.Sh SEE ALSO
.Xr pax 1 ,
.Xr tar 1
.Sh AUTHORS
Keith Muller at the University of California, San Diego.
.Sh BUGS
The
.Fl s
and
.Fl S
options are currently not implemented.