Просмотр исходного кода

Fix regression when copy: is used for a relative path

When we do a ReverifyAfterIMS() we use the copy: method to
verify the hashes again. If the user uses -o Dir=./something/relative
this fails because we use the URI class in copy.cc that strips
away the leading relative part. By not using URI this is fixed.

Closes: #762160
Michael Vogt лет назад: 11
Родитель
Сommit
9da539c5af
2 измененных файлов с 8 добавлено и 6 удалено
  1. 2 2
      methods/copy.cc
  2. 6 4
      test/integration/test-bug-762160-relpath

+ 2 - 2
methods/copy.cc

@@ -55,8 +55,8 @@ void CopyMethod::CalculateHashes(FetchResult &Res)
 /* */
 bool CopyMethod::Fetch(FetchItem *Itm)
 {
-   URI Get = Itm->Uri;
-   std::string File = Get.Path;
+   // this ensures that relative paths work in copy
+   std::string File = Itm->Uri.substr(Itm->Uri.find(':')+1);
 
    // Stat the file and send a start message
    struct stat Buf;

+ 6 - 4
test/integration/test-bug-762160-relpath

@@ -1,9 +1,9 @@
 #!/bin/sh
+# regresion test for bug #762160 where apt-get update fails when a 
+# relative directory is given
+#
 set -e
 
-# dpkg implements versioned provides in commit 5bb02fe80e9f40dcad9703a72f67cf615ff217b5
-# but previous versions seem to allow parsing, working and ignoring it.
-
 TESTDIR=$(readlink -f $(dirname $0))
 . $TESTDIR/framework
 setupenvironment
@@ -11,5 +11,7 @@ configarchitecture 'amd64'
 
 insertpackage 'unstable' 'foo' 'all' '1'
 setupaptarchive
+changetowebserver
 
-aptget update -o Dir=./apt
+testsuccess aptget update -o Dir=./rootdir
+testsuccess aptget update -o Dir=./rootdir