arnesen@aftp.UUCP (Geir Arnesen) (07/17/89)
Does anyone now if it is possible to extract tar files from tape - to another directory/file than it was archived as? Regards Geir Arnesen /* * Geir Arnesen - Aftenposten * adress: Akersgt.51, P.b. 1178, Sentrum, 0107 Oslo 1, Norway * UUCP: ...mcvax!ndosl!aftp!arnesen * Internet: arnesen@aftenp.uu.no * Phone: +47-2-863232 Priv: +47-2-809133 FAX: +47-2-426325 TLX: 71230 aftp N */
ked@garnet.berkeley.edu (Earl H. Kinmonth) (07/19/89)
In article <499@aftp.UUCP> arnesen@aftp.UUCP (Geir Arnesen) writes: >Does anyone now if it is possible to extract tar files from tape - to >another directory/file than it was archived as? My version of pdtar has a -Pnn option that permits removing the first nn parts of path names. Earl H. Kinmonth History Department University of California, Davis 916-752-1636 (voice, fax [2300-0800 PDT]) 916-752-0776 secretary (bitnet) ehkinmonth@ucdavis.edu (uucp) ucbvax!ucdavis!ucdked!cck (telnet or 916-752-7920) cc-dnet.ucdavis.edu [128.120.2.251] request ucdked, login as guest, no password
rbj@dsys.ncsl.nist.gov (Root Boy Jim) (08/09/89)
? From: Geir Arnesen <arnesen@aftp.uucp> ? Does anyone now if it is possible to extract tar files from tape - to ? another directory/file than it was archived as? Uh oh. You sound like you have a tape made with something like tar c /usr By now, you should be figuring out that you should *never* make tar tapes with absolute pathnames on them. Use relative names: cd /; tar c usr This is such an annoying problem that newer versions of tar (unfortunately, most vendors have yet to ship them) include an option to remove the initial `/', making tapes created with the above two methods effectively the same. One such version is GNU tar, available at an archive site near you. If you have emacs, you can edit the tar file directly. Find the header for each file, and change a file name of the form `/usr/bin' to `usr//bin'. That will keep the checksum the same. If you don't have emacs, you'll have to write a program. Supposedly, the -i option exists to ignore bogus checksums, but I can get it to work on our system, SunOS 3.5. Good luck. ? Regards ? Geir Arnesen ? /* ? * Geir Arnesen - Aftenposten ? * adress: Akersgt.51, P.b. 1178, Sentrum, 0107 Oslo 1, Norway ? * UUCP: ...mcvax!ndosl!aftp!arnesen ? * Internet: arnesen@aftenp.uu.no ? * Phone: +47-2-863232 Priv: +47-2-809133 FAX: +47-2-426325 TLX: 71230 aftp N ? */ Root Boy Jim Have GNU, Will Travel.
hjespersen@trillium.waterloo.edu (Hans Jespersen) (08/10/89)
In article <20552@adm.BRL.MIL> rbj@dsys.ncsl.nist.gov (Root Boy Jim) writes: >? From: Geir Arnesen <arnesen@aftp.uucp> >? Does anyone now if it is possible to extract tar files from tape - to >? another directory/file than it was archived as? > >If you have emacs, you can edit the tar file directly. Find the >header for each file, and change a file name of the form >`/usr/bin' to `usr//bin'. That will keep the checksum the same. >If you don't have emacs, you'll have to write a program. You could always use 'chroot' to move the effective root directory and read the files in to an alternate directory structure. This saves having to edit all the file names. Of course you may need to make a duplicate of /bin/sh, /bin/tar, and mknod the tape device in the new "root" directory ( alternatively a couple of well chosen symlinks would be even better, if you have them). Writting a program seems to be a bit exessive. -- Hans Jespersen hjespersen@trillium.waterloo.edu uunet!watmath!trillium!hjespersen
ruud@targon.UUCP (Ruud Harmsen) (08/16/89)
In article <20552@adm.BRL.MIL> rbj@dsys.ncsl.nist.gov (Root Boy Jim) writes: > From: Geir Arnesen <arnesen@aftp.uucp> > > Does anyone now if it is possible to extract tar files from tape - to > another directory/file than it was archived as? I wrote a program to do this. See included manpage for details. No makefile, just "make" should do the job. #! /bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh <file", e.g.. If this archive is complete, you # will see the following message at the end: # "End of shell archive." # Contents: tarabs.1 tarabs.c # Wrapped by ruud@swpvia on Tue Aug 15 19:36:13 1989 PATH=/bin:/usr/bin:/usr/ucb ; export PATH if test -f tarabs.1 -a "${1}" != "-c" ; then echo shar: Will not over-write existing file \"tarabs.1\" else echo shar: Extracting \"tarabs.1\" \(1260 characters\) sed "s/^X//" >tarabs.1 <<'END_OF_tarabs.1' X.TH TARABS 23 Vianen Local\ additions X.SH NAME Xtarabs \- read tarfiles with absolute pathnames X.SH ORIGIN XNixdorf, SWP-Vianen X.SH SYNOPSIS X.B tarabs searcharg X.SH DESCRIPTION X.I Tarabs Xmay be useful if someone sends you a tape written with absolute Xpathnames, i.e. pathnames that start with a slash ('/'). XTar should not be used that way, because you must have the same Xdirectory structure as the sender, and if you have you will overwrite Xany files that are already present there with the same name. X X.I Tarabs Xmakes it possible to read such files with relative pathnames. XIt converts the pathnames in the tar archive, such that the initial Xslash and the character directly behind it are interchanged. This Xturns the names into relative paths, and the "directory checksums" Xthat X.I tar Xmaintains, are still valid. X X.I Tarabs Xtakes one argument, which is a string to be searched for in the names. X. X.SH EXAMPLE XSuppose someone sends you a tar tape with files like: X.nf X/usr/bin/nroff X/usr/bin/lex X.fi X XYou can read this file by: X X.nf Xcd <where-ever you wish> Xcat /dev/rmt0 > file1 Xtarabs /usr/ < file1 > file2 Xtar xof file X.fi X XThe files will now be extracted as: X X.nf Xu/sr/bin/nroff Xu/sr/bin/lex X.fi X Xrelative to the current directory. X. X.SH SEE ALSO Xtar(1) END_OF_tarabs.1 if test 1260 -ne `wc -c <tarabs.1`; then echo shar: \"tarabs.1\" unpacked with wrong size! fi # end of overwriting check fi if test -f tarabs.c -a "${1}" != "-c" ; then echo shar: Will not over-write existing file \"tarabs.c\" else echo shar: Extracting \"tarabs.c\" \(1047 characters\) sed "s/^X//" >tarabs.c <<'END_OF_tarabs.c' X#include <stdio.h> X#include <string.h> X X#define BUFLEN 512 X Xmain (argc, argv) int argc; char ** argv; X{ X char buf[BUFLEN]; X char *bufp; X int len, red; X X if (argc != 2) X { X fprintf (stderr, "Usage %s string\n", argv[0]); X fprintf (stderr, X "%s converts tar-files with absolute pathnames\n", argv[0]); X fprintf (stderr, "string if converted in pathnames, by\n"); X fprintf (stderr, "string if converted in pathnames, by\n"); X fprintf (stderr, X "interchanging the slash and the next character\n"); X } X X len = strlen (argv[1]); X X while (fread (buf, 1, BUFLEN, stdin) > 0) X { X if (strncmp (argv[1], buf, len) == 0) X { X *buf = *(buf + 1); X *(buf + 1) = '/'; X /* Look for link names */ X for (bufp = buf; *bufp != '\0' && bufp < buf + BUFLEN; bufp++) X ; X for (/*go on */; *bufp != '/' && bufp < buf + BUFLEN; bufp++) X ; X if (bufp + len < buf + BUFLEN X && strncmp (argv[1], bufp, len) == 0) X { X *bufp = *(bufp + 1); X *(bufp + 1) = '/'; X } X } X fwrite (buf, 1, BUFLEN, stdout); X } X} END_OF_tarabs.c if test 1047 -ne `wc -c <tarabs.c`; then echo shar: \"tarabs.c\" unpacked with wrong size! fi # end of overwriting check fi echo shar: End of shell archive. exit 0