Tk Library Source Code

View Ticket
Login
Ticket UUID: 2840147
Title: Add prefix to name of file added to tarball
Type: Patch Version: None
Submitter: lars_h Created on: 2009-08-19 09:03:45
Subsystem: tar Assigned To: andreas_kupries
Priority: 5 Medium Severity:
Status: Closed Last Modified: 2009-12-04 03:27:56
Resolution: Accepted Closed By: andreas_kupries
    Closed on: 2009-12-03 20:06:47
Description:
The git-archive utility has an option --prefix described as:

  --prefix=<prefix>/
      Prepend <prefix>/ to each filename in the archive.

I found this useful in the case that the the parent directory of what I'm wrapping up as a tarball isn't named the way I'd like root directory within the tarball to be named. However, I also needed to add a few files to the tarball, and my command-line tar didn't have a corresponding option. Therefore I turned to adding a -prefix option to the tcllib [tar::add] command.

The main change needed to implement this was to split [tar::createHeader] into two commands [tar::statFile] and [tar::formatHeader], as [tar::createHeader] hardwired the in-archive name of a file to be the same as the name in the normal file system. I think this is a good change, as it also opens up for adding items to a tarball that don't first have to exist within the normal filesystem (a kind of [tar::put], if you will).

Another change required was that [tar::writefile] takes another argument: the name to use in the archive. [tar::add] and [tar::create] have been modified accordingly.

While testing this, I also discovered a bug in the current [tar::add]: one cannot in general assume that the end of an archive occurs 1024 bytes before the end of the file. The catch is that tarballs are written with a specific "blocksize" (often 20 records, i.e., 10Kb), and are supposed to consist of an integral number of complete blocks. Therefore there may be extra padding after the 1024 end-of-archive nulls, and it is then impossible to tell if an all-null record at the end of a tarball is nulls at the end of a file, end-of-archive nulls, or padding until the end of a block. The only safe way to find the end is to read the tarball from the beginning.

I added a third option -quick to [tar::add] which selects the old seek-from-end method of finding where to put the header for the first new file, but made the default be to read the tarball from start.

Being a tcllib developer, I can probably check this into CVS myself, but I think you should have a chance to look at it first.
User Comments: andreas_kupries added on 2009-12-04 03:27:56:
This type of putting up an RC and freezing CVS before actually doing the release is mainly there to flush out all the people who have such last-minute stuff and sort of forgot that we are working on making a release. A last wakeup call. I definitely expected for stuff like this come out of the woodwork with my declaration.

andreas_kupries added on 2009-12-04 03:25:43:
The declaration also said 'If changes are needed before 1.12 is released coordinate with me.'.

Which Aaron did, pinging me on the chat. I reviewed and decided to apply, i.e. decided hat I want to have this in 1.12. It was not Aaron going over my declaration.

lars_h added on 2009-12-04 03:16:13:

allow_comments - 0

This got added /after/ today's declaration of a CVS being frozen? Still, it's good that it got in; I've been thinking about this the last couple of weeks, but also been too busy to get around to it.

andreas_kupries added on 2009-12-04 03:06:47:

allow_comments - 1

andreas_kupries added on 2009-12-04 03:06:46:
Committed to head. Updated the tar.pcx.

lars_h added on 2009-08-19 16:03:45:

File Added - 339706: tar.patch

Attachments: