--- pax-20120216.orig/options.c +++ pax-20120216/options.c @@ -58,7 +58,7 @@ #include #endif -__RCSID("$MirOS: src/bin/pax/options.c,v 1.44 2012/02/16 17:27:31 tg Exp $"); +__RCSID("$MirOS: src/bin/pax/options.c,v 1.46 2012/02/27 22:31:01 tg Exp $"); #ifndef _PATH_DEFTAPE #define _PATH_DEFTAPE "/dev/rmt0" @@ -1178,6 +1178,7 @@ char *str; FSUB tmp; FILE *fp; + const char *optstr; kflag = 1; pids = 1; @@ -1186,234 +1187,243 @@ arcname = NULL; dflag = 1; nodirs = 1; - while ((c = getopt(argc, argv, - "6AaBbC:cdE:F:fH:I:iJjkLlM:mO:oprSstuVvZz")) != -1) + optstr = "iop"; + opterr = 0; + while ((c = getopt(argc, argv, optstr)) != -1) { switch (c) { - case 'a': - /* - * preserve access time on files read - */ - tflag = 1; - break; - case 'b': - /* - * swap bytes and half-words when reading data - */ - break; - case 'c': - /* - * ASCII cpio header - */ - frmt = &(fsub[F_ACPIO]); - break; - case 'd': - /* - * create directories as needed - */ - nodirs = 0; - break; - case 'f': - /* - * invert meaning of pattern list - */ - cflag = 1; - break; - case 'i': - /* - * restore an archive - */ - cpio_set_action(EXTRACT); - break; - case 'J': - /* - * use xz (non-standard option) - */ - compress_program = XZ_CMD; - break; - case 'j': - /* - * use bzip2 (non-standard option) - */ - compress_program = BZIP2_CMD; - break; - case 'k': - break; - case 'l': - /* - * use links instead of copies when possible - */ - lflag = 1; - break; - case 'm': - /* - * preserve modification time - */ - pmtime = 1; - break; - case 'o': - /* - * create an archive - */ - cpio_set_action(ARCHIVE); - frmt = &(fsub[F_CPIO]); - break; - case 'p': - /* - * copy-pass mode - */ - cpio_set_action(COPY); - break; - case 'r': - /* - * interactively rename files - */ - iflag = 1; - break; - case 's': - /* - * swap bytes after reading data - */ - break; - case 't': - /* - * list contents of archive - */ - cpio_set_action(LIST); - listf = stdout; - break; - case 'u': - /* - * replace newer files - */ - kflag = 0; - break; - case 'V': - /* - * print a dot for each file processed - */ - Vflag++; - break; - case 'v': - /* - * verbose operation mode - */ - vflag++; - break; - case 'z': - /* - * use gzip (non-standard option) - */ - compress_program = GZIP_CMD; - break; - case 'A': - /* - * append mode - */ - cpio_set_action(APPND); - break; - case 'B': - /* - * use 5120 byte block size - */ - wrblksz = 5120; - break; - case 'C': - /* - * set block size in bytes - */ - wrblksz = atoi(optarg); - break; - case 'E': - /* - * file with patterns to extract or list - */ - if ((fp = fopen(optarg, "r")) == NULL) { - paxwarn(1, "Unable to open file '%s' for read", optarg); - cpio_usage(); - } - while ((str = get_line(fp)) != NULL) { - pat_add(str, NULL); - } - fclose(fp); - if (get_line_error) { - paxwarn(1, "Problem with file '%s'", optarg); - cpio_usage(); - } - break; - case 'F': - case 'I': - case 'O': - /* - * filename where the archive is stored - */ - if ((optarg[0] == '-') && (optarg[1]== '\0')) { - /* - * treat a - as stdin - */ - arcname = NULL; - break; - } - arcname = optarg; - break; - case 'H': - /* - * specify an archive format on write - */ - if (!strcmp(optarg, "bin")) { - tmp.name = "bcpio"; - } else if (!strcmp(optarg, "crc")) { - tmp.name = "sv4crc"; - } else if (!strcmp(optarg, "newc")) { - tmp.name = "sv4cpio"; - } else if (!strcmp(optarg, "odc")) { - tmp.name = "cpio"; - } else { - tmp.name = optarg; - } - if ((frmt = (FSUB *)bsearch((void *)&tmp, (void *)fsub, - sizeof(fsub)/sizeof(FSUB), sizeof(FSUB), c_frmt)) != NULL) - break; - paxwarn(1, "Unknown -H format: %s", optarg); - (void)fputs("cpio: Known -H formats are:", stderr); - for (i = 0; i < (sizeof(fsub)/sizeof(FSUB)); ++i) - (void)fprintf(stderr, " %s", fsub[i].name); - (void)fputs("\n\n", stderr); + case 'a': + /* + * preserve access time on files read + */ + tflag = 1; + break; + case 'b': + /* + * swap bytes and half-words when reading data + */ + break; + case 'c': + /* + * ASCII cpio header + */ + frmt = &(fsub[F_ACPIO]); + break; + case 'd': + /* + * create directories as needed + */ + nodirs = 0; + break; + case 'f': + /* + * invert meaning of pattern list + */ + cflag = 1; + break; + case 'i': + /* + * restore an archive + */ + cpio_set_action(EXTRACT); + break; + case 'J': + /* + * use xz (non-standard option) + */ + compress_program = XZ_CMD; + break; + case 'j': + /* + * use bzip2 (non-standard option) + */ + compress_program = BZIP2_CMD; + break; + case 'k': + break; + case 'l': + /* + * use links instead of copies when possible + */ + lflag = 1; + break; + case 'm': + /* + * preserve modification time + */ + pmtime = 1; + break; + case 'o': + /* + * create an archive + */ + cpio_set_action(ARCHIVE); + frmt = &(fsub[F_CPIO]); + break; + case 'p': + /* + * copy-pass mode + */ + cpio_set_action(COPY); + break; + case 'r': + /* + * interactively rename files + */ + iflag = 1; + break; + case 's': + /* + * swap bytes after reading data + */ + break; + case 't': + /* + * list contents of archive + */ + cpio_set_action(LIST); + listf = stdout; + break; + case 'u': + /* + * replace newer files + */ + kflag = 0; + break; + case 'V': + /* + * print a dot for each file processed + */ + Vflag++; + break; + case 'v': + /* + * verbose operation mode + */ + vflag++; + break; + case 'z': + /* + * use gzip (non-standard option) + */ + compress_program = GZIP_CMD; + break; + case 'A': + /* + * append mode + */ + cpio_set_action(APPND); + break; + case 'B': + /* + * use 5120 byte block size + */ + wrblksz = 5120; + break; + case 'C': + /* + * set block size in bytes + */ + wrblksz = atoi(optarg); + break; + case 'E': + /* + * file with patterns to extract or list + */ + if ((fp = fopen(optarg, "r")) == NULL) { + paxwarn(1, "Unable to open file '%s' for read", optarg); cpio_usage(); - break; - case 'L': - /* - * follow symbolic links - */ - Lflag = 1; - break; - case 'M': - /* - * MirOS extension: archive normaliser - */ - process_M(optarg, cpio_usage); - break; - case 'S': - /* - * swap halfwords after reading data - */ - break; - case 'Z': - /* - * use compress (non-standard option) - */ - compress_program = COMPRESS_CMD; - break; - case '6': + } + while ((str = get_line(fp)) != NULL) { + pat_add(str, NULL); + } + fclose(fp); + if (get_line_error) { + paxwarn(1, "Problem with file '%s'", optarg); + cpio_usage(); + } + break; + case 'F': + case 'I': + case 'O': + /* + * filename where the archive is stored + */ + if ((optarg[0] == '-') && (optarg[1]== '\0')) { /* - * process Version 6 cpio format + * treat a - as stdin */ - frmt = &(fsub[F_OCPIO]); + arcname = NULL; break; - case '?': - default: - cpio_usage(); + } + arcname = optarg; + break; + case 'H': + /* + * specify an archive format on write + */ + if (!strcmp(optarg, "bin")) { + tmp.name = "bcpio"; + } else if (!strcmp(optarg, "crc")) { + tmp.name = "sv4crc"; + } else if (!strcmp(optarg, "newc")) { + tmp.name = "sv4cpio"; + } else if (!strcmp(optarg, "odc")) { + tmp.name = "cpio"; + } else { + tmp.name = optarg; + } + if ((frmt = (FSUB *)bsearch((void *)&tmp, (void *)fsub, + sizeof(fsub)/sizeof(FSUB), sizeof(FSUB), c_frmt)) != NULL) break; + paxwarn(1, "Unknown -H format: %s", optarg); + (void)fputs("cpio: Known -H formats are:", stderr); + for (i = 0; i < (sizeof(fsub)/sizeof(FSUB)); ++i) + (void)fprintf(stderr, " %s", fsub[i].name); + (void)fputs("\n\n", stderr); + cpio_usage(); + break; + case 'L': + /* + * follow symbolic links + */ + Lflag = 1; + break; + case 'M': + /* + * MirOS extension: archive normaliser + */ + process_M(optarg, cpio_usage); + break; + case 'S': + /* + * swap halfwords after reading data + */ + break; + case 'Z': + /* + * use compress (non-standard option) + */ + compress_program = COMPRESS_CMD; + break; + case '6': + /* + * process Version 6 cpio format + */ + frmt = &(fsub[F_OCPIO]); + break; + case '?': + default: + if (opterr == 0) { + paxwarn(1, "need -i or -o or -p option first"); + } + cpio_usage(); + break; + } + if (opterr == 0) { + optstr = "6AaBbC:cdE:F:fH:I:iJjkLlM:mO:oprSstuVvZz"; + opterr = 1; } + } argc -= optind; argv += optind; @@ -1421,42 +1431,42 @@ * process the args as they are interpreted by the operation mode */ switch (act) { - case LIST: - case EXTRACT: - while (*argv != NULL) - if (pat_add(*argv++, NULL) < 0) - cpio_usage(); - break; - case COPY: - if (*argv == NULL) { - paxwarn(0, "Destination directory was not supplied"); - cpio_usage(); - } - dirptr = *argv; - if (mkpath(dirptr) < 0) - cpio_usage(); - --argc; - ++argv; - /* FALLTHROUGH */ - case ARCHIVE: - case APPND: - if (*argv != NULL) - cpio_usage(); - /* - * no read errors allowed on updates/append operation! - */ - maxflt = 0; - while ((str = get_line(stdin)) != NULL) { - ftree_add(str, 0); - } - if (get_line_error) { - paxwarn(1, "Problem while reading stdin"); + case LIST: + case EXTRACT: + while (*argv != NULL) + if (pat_add(*argv++, NULL) < 0) cpio_usage(); - } - break; - default: + break; + case COPY: + if (*argv == NULL) { + paxwarn(0, "Destination directory was not supplied"); cpio_usage(); - break; + } + dirptr = *argv; + if (mkpath(dirptr) < 0) + cpio_usage(); + --argc; + ++argv; + /* FALLTHROUGH */ + case ARCHIVE: + case APPND: + if (*argv != NULL) + cpio_usage(); + /* + * no read errors allowed on updates/append operation! + */ + maxflt = 0; + while ((str = get_line(stdin)) != NULL) { + ftree_add(str, 0); + } + if (get_line_error) { + paxwarn(1, "Problem while reading stdin"); + cpio_usage(); + } + break; + default: + cpio_usage(); + break; } } @@ -1665,17 +1675,17 @@ } switch (*expr) { - case '\0': - break; - case '*': - case 'x': - t = num; - num *= str_offt(expr + 1); - if (t > num) - return (0); - break; - default: + case '\0': + break; + case '*': + case 'x': + t = num; + num *= str_offt(expr + 1); + if (t > num) return (0); + break; + default: + return (0); } return ((off_t)num); } --- pax-20120216.orig/debian/compat +++ pax-20120216/debian/compat @@ -0,0 +1 @@ +5 --- pax-20120216.orig/debian/changelog +++ pax-20120216/debian/changelog @@ -0,0 +1,57 @@ +pax (1:20120216-2) unstable; urgency=low + + * Update options.c to version from CVS to ensure the order of + command line arguments in the cpio front-end more tightly, + to prevent creating archives in the wrong format accidentally + * Link with --as-needed (not enough to workaround #650145 though ☹) + * Policy 3.9.3 (no changes) + * Mention non-support of ACLs/EAs in the long description + + -- Thorsten Glaser Mon, 27 Feb 2012 22:37:12 +0000 + +pax (1:20120216-1) unstable; urgency=low + + * Debian GNU/kFreeBSD uses 64-bit off_t line FreeBSD®, unlike GNU + * Implement GNU cpio ‘-V’ option + + -- Thorsten Glaser Thu, 16 Feb 2012 18:01:39 +0000 + +pax (1:20120212-1) unstable; urgency=low + + * Brown paper bag: pasto in one of the manpages, and work around a + GNU groff deficiency in another + + -- Thorsten Glaser Sun, 12 Feb 2012 03:03:15 +0000 + +pax (1:20120211-1) unstable; urgency=low + + * Take over maintainership of the pax package in Debian from + Bdale Garbee (thanks) and replace it with the MirBSD variant + also providing paxcpio/paxtar (Closes: #42158) (Closes: #539353) + * debian/rules: cleanup (remove dh_installdirs, add back dh_clean) + * debian/rules: modernise; use fully hardened dpkg-buildflags + * debian/control: rework package description + + -- Thorsten Glaser Sun, 12 Feb 2012 02:10:40 +0000 + +mircpio (20110817-0wtf2) wtf; urgency=low + + * New upstream release, many new features + - build from formal release, not CVS export + * Update packaging to current standards, still works with etch + * Link against libbsd (backport) instead of duplicating code + * Move to Policy 3.9.2 (no relevant changes) + * Add RCS IDs, VCS-* headers, misc:Depends + * Patch manpages to honour the binary præfix (pax→mirpax, etc.) + * Enhance package description, mention distinguishing features + * paxmirabilis can do Multi-Arch: foreign as requested by vorlon + * Add Origin and Bugs headers + + -- Thorsten Glaser Wed, 17 Aug 2011 10:55:08 +0000 + +mircpio (20080906-1) experimental; urgency=low + + * Initial release + * Adjust manpages to cope with GNU groff’s inferiorities + + -- Thorsten Glaser Sun, 07 Sep 2008 01:00:10 +0000 --- pax-20120216.orig/debian/watch +++ pax-20120216/debian/watch @@ -0,0 +1,4 @@ +# $MirOS: contrib/hosted/tg/deb/mircpio/debian/watch,v 1.2 2011/08/16 14:37:46 tg Exp $ + +version=3 +http://www.mirbsd.org/MirOS/dist/mir/cpio/ paxmirabilis-(.*)\.cpio\.gz --- pax-20120216.orig/debian/source.lintian-overrides +++ pax-20120216/debian/source.lintian-overrides @@ -0,0 +1,5 @@ +# $MirOS: contrib/hosted/tg/deb/mircpio/debian/source.lintian-overrides,v 1.1 2012/02/27 22:41:59 tg Exp $ + +# desired method of keeping changes is CVS +# as long as etch backports are required +pax source: direct-changes-in-diff-but-no-patch-system * --- pax-20120216.orig/debian/install +++ pax-20120216/debian/install @@ -0,0 +1,3 @@ +# $MirOS: contrib/hosted/tg/deb/mircpio/debian/install,v 1.3 2012/02/12 02:23:51 tg Exp $ +#- +pax bin --- pax-20120216.orig/debian/control +++ pax-20120216/debian/control @@ -0,0 +1,35 @@ +# $MirOS: contrib/hosted/tg/deb/mircpio/debian/control,v 1.14 2012/02/27 22:52:04 tg Exp $ +# +Source: pax +Section: utils +Priority: optional +Maintainer: Thorsten Glaser +Build-Depends: debhelper (>= 5), libbsd-dev (>= 0.1.1) +Standards-Version: 3.9.3 +# First word is the $CVSROOT (-d arg) string, second word the module. +Vcs-CVS: :ext:_anoncvs@anoncvs.mirbsd.org:/cvs contrib/hosted/tg/deb/mircpio +Vcs-Browser: http://cvs.mirbsd.de/contrib/hosted/tg/deb/mircpio/ + +Package: pax +Architecture: any +Multi-Arch: foreign +Depends: ${shlibs:Depends}, ${misc:Depends} +Description: Portable Archive Interchange (cpio, pax, tar) + paxtar is an implementation of an archiving utility that reads + and writes several formats - traditional ones, the extended + formats specified in IEEE 1003.1, and the ar(5) format used + by deb(5) packages (MirBSD specific paxtar extension). The + pax interface was designed by IEEE 1003.2 as a compromise in + the chronic controversy over which of tar or cpio is best, but + this implementation offers paxcpio and paxtar for easy calling. + . + This is the MirBSD paxtar implementation supporting the formats + ar, bcpio, cpio, SVR4 cpio with and without CRC, old tar, and + ustar, but not the format known as pax yet. It has extensions + for removing non-numerical user and group IDs from the archive, + storing hardlinked files only once, setting ownership to the + superuser, anonymising inode and device information, changing + the mtime to zero, and producing GNU tar compatible trailing + slashes on ustar directory nodes. Its "ar" format is suitable + for operating on *.deb files, unlike that of GNU binutils. + Note that ACLs and Extended Attributes are not supported. --- pax-20120216.orig/debian/copyright +++ pax-20120216/debian/copyright @@ -0,0 +1,48 @@ +This package was debianised by Thorsten Glaser on +Sat, 06 Sep 2008 21:25:34 +0000. + +$MirOS: contrib/hosted/tg/deb/mircpio/debian/copyright,v 1.5 2012/02/16 18:02:24 tg Exp $ + +It was downloaded from: +https://www.mirbsd.org/MirOS/dist/mir/cpio/paxmirabilis-20120216.cpio.gz + +Licence: + + * Copyright (c) 2005, 2006, 2007, 2008, 2009, 2011, 2012 + * Thorsten Glaser + * Copyright (c) 1996, 1997 SigmaSoft, Th. Lockert + * Copyright (c) 1992 Keith Muller. + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * Some Debian patches Copyright (c) 2011 + * Svante Signell + * Guillem Jover + * Bdale Garbee + * + * This code is derived from software contributed to Berkeley by + * Keith Muller of the University of California, San Diego. + * + * 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. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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. --- pax-20120216.orig/debian/rules +++ pax-20120216/debian/rules @@ -0,0 +1,77 @@ +#!/usr/bin/make -f +# $MirOS: contrib/hosted/tg/deb/mircpio/debian/rules,v 1.14 2012/02/27 22:54:38 tg Exp $ + +DEB_HOST_ARCH_OS=$(shell dpkg-architecture -qDEB_HOST_ARCH_OS) + +CC?= gcc +EXTRA_CFLAGS= -Wall -Wextra -Wformat -fno-strict-aliasing +EXTRA_CPPFLAGS= -DUSE_LIBBSD +EXTRA_LDFLAGS= -Wl,--as-needed + +ifneq (kfreebsd,${DEB_HOST_ARCH_OS}) +EXTRA_CPPFLAGS+= -DLONG_OFF_T +endif + +ifneq (,$(wildcard /usr/share/dpkg/buildflags.mk)) +# dpkg-dev (>= 1.16.1~) +DEB_CFLAGS_MAINT_APPEND=${EXTRA_CFLAGS} +DEB_CPPFLAGS_MAINT_APPEND=${EXTRA_CPPFLAGS} +DEB_LDFLAGS_MAINT_APPEND=${EXTRA_LDFLAGS} +DEB_BUILD_MAINT_OPTIONS=hardening=+all +include /usr/share/dpkg/buildflags.mk +else +# old-fashioned way to determine build flags +CFLAGS= -O$(if $(findstring noopt,${DEB_BUILD_OPTIONS}),0,2) -g +CFLAGS+= ${EXTRA_CFLAGS} +CPPFLAGS+= ${EXTRA_CPPFLAGS} +LDFLAGS+= ${EXTRA_LDFLAGS} +endif + +LDADD+= -lbsd + +build build-arch: debian/.build_stamp +build-indep: + +debian/.build_stamp: + dh_testdir + -rm -f debian/.*_stamp debian/*.1 pax + +for opts in '-flto=jobserver' '-fwhole-program --combine' ''; do \ + set -x; \ + ${CC} ${CPPFLAGS} ${CFLAGS} $$opts ${LDFLAGS} -o pax ar.c \ + ar_io.c ar_subs.c buf_subs.c cache.c cpio.c file_subs.c \ + ftree.c gen_subs.c getoldopt.c options.c pat_rep.c pax.c \ + sel_subs.c tables.c tar.c tty_subs.c ${LDADD}; \ + test -x pax && exit 0; \ + done; echo >&2 Compiling failed.; exit 1 + echo .nr g 2 | cat - cpio.1 >debian/paxcpio.1 + echo .nr g 2 | cat - pax.1 >debian/pax.1 + echo .nr g 2 | cat - tar.1 >debian/paxtar.1 + @:>$@ + +clean: + dh_testdir + -rm -f debian/.*_stamp debian/*.1 pax + dh_clean + +binary-indep: build-indep + +binary-arch: build-arch + dh_testdir + dh_testroot + if test -x "$$(which dh_prep)"; then dh_prep; else dh_clean -k; fi + dh_installchangelogs + dh_installdocs + dh_install + dh_installman + dh_link + dh_strip + dh_compress + dh_fixperms + dh_installdeb + dh_shlibdeps + dh_gencontrol + dh_md5sums + dh_builddeb + +binary: binary-indep binary-arch +.PHONY: binary binary-arch binary-indep build build-arch build-indep clean --- pax-20120216.orig/debian/manpages +++ pax-20120216/debian/manpages @@ -0,0 +1,5 @@ +# $MirOS: contrib/hosted/tg/deb/mircpio/debian/manpages,v 1.3 2012/02/12 02:23:51 tg Exp $ +#- +debian/pax.1 +debian/paxcpio.1 +debian/paxtar.1 --- pax-20120216.orig/debian/links +++ pax-20120216/debian/links @@ -0,0 +1,4 @@ +# $MirOS: contrib/hosted/tg/deb/mircpio/debian/links,v 1.2 2012/02/12 02:23:51 tg Exp $ +#- +bin/pax bin/paxcpio +bin/pax bin/paxtar --- pax-20120216.orig/debian/source/format +++ pax-20120216/debian/source/format @@ -0,0 +1 @@ +1.0