dir listing not starting with . and ..
John W. Eaton
jwe at octave.org
Wed Feb 4 11:31:15 CST 2009
On 4-Feb-2009, Søren Hauberg wrote:
| ons, 04 02 2009 kl. 11:20 -0500, skrev John W. Eaton:
| > Shouldn't a package named foo-1.0.0.tar.gz unpack into a directory
| > called foo-1.0.0? If that's not already part of the definition of a
| > package, then maybe it should be? If we have this requirement, then
| > I think it simplifies things a bit.
|
| I think (not sure) that the packages in octave-forge unpacks in a
| directory called 'foo' and not 'foo-1.0.0', and I think both of these
| makes sense. The current code essentially does
|
| tmp_dir = create_tmp_dir ();
| untar (package_file, tmp_dir);
| source_dir = readdir (tmp_dir) {3}; # the first two are "." and ".."
|
| The main reason for creating a temporary directory in the first place is
| to make it easy to delete the files that was unpacked. And once we know
| that all files/directories in 'tmp_dir' belongs to the package, I think
| it's quite simple to just pick the first one that is listed.
I would still recommend creating the temporary directory to work in,
but instead of taking the third element of the directory listing, I
would look for the expected package directory.
Picking the third element of readdir seems fragile to me, so using a
name derived from the package file name might be more robust. If
someone renames a package file and tries to install it, then you could
just issue a message saying that the package appears corrupted because
it did not extract into the expected directory structure.
I know that people are not supposed to unpack the package files by
hand to install them, but some people might want to unpack them
anyway, without installing, just to see what they contain. So I think
the packages should unpack into directories with names that include
the version number. I really dislike unpacking a tar file and having
it go into some directory that isn't the same as the name of the tar
file minus the ".tar.gz" extension. With the version number included,
I can easily unpack two or more versions of the same package in a
single directory and compare them, for example. If the version
information is stripped, then that becomes more of a hassle. Is there
some good reason not to keep the version info? Does it create some
difficult problem for the pkg functions?
jwe
More information about the Bug-octave
mailing list