Corinna Vinschen wrote:
On Dec 15 14:13, Eric Blake wrote:
On 12/15/2011 01:59 PM, Christopher Faylor wrote:
I think it's lame to have something like, e.g.,
/usr/src/openssh-5.6p1-2/openssh-5.6p1-2
/usr/src/binutils-2.22.51-1/binutils-2.22.51-1
sitting in my /usr/src. I find that nearly as objectionable as having
files littered in /usr/src.
I don't like /usr/src/binutils-2.22.51-1/binutils-2.22.51-1 either, but
it's much less objectionable than having /usr/src littered with the
content of package files.
Attached is a new patch which takes a different approach.
It handles both cases on the fly during installation.
/usr/src/binutils-2.22.51-1/* will be installed as before, but
/usr/src/blacklist.txt will be installed as
/usr/src/ca-certificates-1.78-1/blacklist.txt
This would break directory structure for packages which contain both, a
PACKAGE-VERSION subdir and toplevel files. Such packages might exist or
not. If yes, these should probably be fixed first.
Yes, I agree that this is a hack. But someone might agree that this is a
useful hack :-)
Christian
2011-12-16 Christian Franke <fra...@computer.org>
* install.cc (installOne): Ensure that src package
contents is installed below /usr/src/PACKAGE-VERSION.
diff --git a/install.cc b/install.cc
index 5e3331a..ad9e43d 100644
--- a/install.cc
+++ b/install.cc
@@ -401,6 +401,7 @@ Installer::installOne (packagemeta &pkgm, const packageversion &ver,
filename of each file that was unpacked. */
io_stream *lst = NULL;
+ std::string srcSubDir;
if (ver.Type () == package_binary)
{
std::string lstfn = "cygfile:///etc/setup/" + pkgm.name + ".lst.gz";
@@ -422,6 +423,17 @@ Installer::installOne (packagemeta &pkgm, const packageversion &ver,
}
}
}
+ else
+ {
+ /* Extract PACKAGE-VERSION from src archive name. */
+ const char *base = source.Base ();
+ int len = (base ? strlen (base) : 0);
+ if (len > 4 && ! strcmp (base + len - 4, "-src"))
+ {
+ srcSubDir.assign (base, len - 4);
+ srcSubDir += '/';
+ }
+ }
bool error_in_this_package = false;
bool ignoreInUseErrors = unattended_mode;
@@ -430,12 +442,22 @@ Installer::installOne (packagemeta &pkgm, const packageversion &ver,
package_bytes = source.size;
log (LOG_PLAIN) << "Extracting from " << source.Cached () << endLog;
+ std::string fullPrefixPath = prefixPath;
std::string fn;
while ((fn = tarstream->next_file_name ()).size ())
{
- std::string canonicalfn = prefixPath + fn;
+ if (! srcSubDir.empty ())
+ {
+ /* Ensure that src archive contents is installed below
+ /usr/src/PACKAGE-VERSION. */
+ fullPrefixPath = prefixPath;
+ if (strncmp (fn.c_str (), srcSubDir.c_str (), srcSubDir.size ()))
+ fullPrefixPath += srcSubDir;
+ }
+
+ std::string canonicalfn = fullPrefixPath + fn;
Progress.SetText3 (canonicalfn.c_str ());
- log (LOG_BABBLE) << "Installing file " << prefixURL << prefixPath
+ log (LOG_BABBLE) << "Installing file " << prefixURL << fullPrefixPath
<< fn << endLog;
if (lst)
{
@@ -447,7 +469,7 @@ Installer::installOne (packagemeta &pkgm, const packageversion &ver,
bool firstIteration = true;
int extract_error = 0;
- while ((extract_error = archive::extract_file (tarstream, prefixURL, prefixPath)) != 0)
+ while ((extract_error = archive::extract_file (tarstream, prefixURL, fullPrefixPath)) != 0)
{
switch (extract_error)
{
@@ -483,11 +505,11 @@ Installer::installOne (packagemeta &pkgm, const packageversion &ver,
++errors;
error_in_this_package = true;
log (LOG_PLAIN) << "Not replacing in-use file " << prefixURL
- << prefixPath << fn << endLog;
+ << fullPrefixPath << fn << endLog;
}
else
{
- error_in_this_package = extract_replace_on_reboot(tarstream, prefixURL, prefixPath, fn);
+ error_in_this_package = extract_replace_on_reboot(tarstream, prefixURL, fullPrefixPath, fn);
}
}
break;