]> git.saurik.com Git - apt.git/commitdiff
* apt-pkg/acquire-item.cc:
authorMichael Vogt <michael.vogt@ubuntu.com>
Thu, 9 Aug 2007 10:34:46 +0000 (12:34 +0200)
committerMichael Vogt <michael.vogt@ubuntu.com>
Thu, 9 Aug 2007 10:34:46 +0000 (12:34 +0200)
  - fix file removal on local repo i-m-s hit (LP: #131166)
* tests/local-repo:
  - added regression test for this bug
* apt-pkg/pkgcachegen.cc:
  - increase default mmap size
* tests/local-repo:
  - added local repository testcase

apt-pkg/acquire-item.cc
debian/changelog
test/local-repo/Packages [new file with mode: 0644]
test/local-repo/Packages.gz [new file with mode: 0644]
test/local-repo/Packages.gz.save [new file with mode: 0644]
test/local-repo/Release [new file with mode: 0644]
test/local-repo/Release.gpg [new file with mode: 0644]
test/local-repo/gdebi-test4.deb [new file with mode: 0644]
test/pre-upload-check.py

index 3e6262c96f72313680e8c52105bd27b3870671fd..b5c2149cc6096f3bca4d1d42904738a465ea102b 100644 (file)
@@ -724,10 +724,7 @@ void pkgAcqIndex::Done(string Message,unsigned long Size,string Hash,
    {
       // The files timestamp matches
       if (StringToBool(LookupTag(Message,"Alt-IMS-Hit"),false) == true)
-      {
-        unlink(FileName.c_str());
         return;
-      }
       Decompression = true;
       Local = true;
       DestFile += ".decomp";
index 710472d67e4fe7998cf9882d57ba8a6bb6ddf26e..7b71c36087496d1e22747457b2fe47780b56a6a8 100644 (file)
@@ -1,3 +1,12 @@
+apt (0.7.6ubuntu5) UNRELEASED; urgency=low
+
+  * apt-pkg/acquire-item.cc:
+    - fix file removal on local repo i-m-s hit (LP: #131166)
+  * tests/local-repo:
+    - added regression test for this bug
+
+ -- Michael Vogt <michael.vogt@ubuntu.com>  Thu, 09 Aug 2007 12:34:07 +0200
+
 apt (0.7.6ubuntu4) gutsy; urgency=low
 
   * cmdline/apt-get.cc:
@@ -49,6 +58,10 @@ apt (0.7.6ubuntu1) gutsy; urgency=low
   * merged apt--sha256 branch to fully support the new
     sha256 checksums in the Packages and Release files
     (ABI break)
+  * apt-pkg/pkgcachegen.cc:
+    - increase default mmap size
+  * tests/local-repo:
+    - added local repository testcase
 
  -- Michael Vogt <michael.vogt@ubuntu.com>  Thu, 02 Aug 2007 11:55:54 +0200
 
diff --git a/test/local-repo/Packages b/test/local-repo/Packages
new file mode 100644 (file)
index 0000000..fe62fc0
--- /dev/null
@@ -0,0 +1,11 @@
+Package: gdebi-test4
+Architecture: all
+Version: 1.0
+Conflicts: apt (<= 0.1)
+Filename: ./gdebi-test4.deb
+Size: 2306
+MD5sum: 0952a2b4a566215e0794c7603f3fcfcc
+SHA1: 318688ea2d53352a1bdb669ebd2cd4847f6c4e7c
+SHA256: 35f600b57253cef807a1da7c5deb06e7821de9223842a310a77b4da87cf51e2c
+Description: testpackage for gdebi - Conflicts: apt (<= 0.1)
+
diff --git a/test/local-repo/Packages.gz b/test/local-repo/Packages.gz
new file mode 100644 (file)
index 0000000..b5d5284
Binary files /dev/null and b/test/local-repo/Packages.gz differ
diff --git a/test/local-repo/Packages.gz.save b/test/local-repo/Packages.gz.save
new file mode 100644 (file)
index 0000000..c73f563
Binary files /dev/null and b/test/local-repo/Packages.gz.save differ
diff --git a/test/local-repo/Release b/test/local-repo/Release
new file mode 100644 (file)
index 0000000..7f206ef
--- /dev/null
@@ -0,0 +1,13 @@
+Date: Thu, 09 Aug 2007 10:13:06 UTC
+MD5Sum:
+ 29f79161fafe1f0c393e7fc6ddcb99b5              338 Packages
+ 2f885b2ebdb77d3354ba63d8b5aad614              269 Packages.gz
+ d41d8cd98f00b204e9800998ecf8427e                0 Release
+SHA1:
+ d8860d409a8b0db443fbf254e2d6afbfc9bc04a8              338 Packages
+ 8b668a7b730ceb4d702737a13a723959c20b67df              269 Packages.gz
+ da39a3ee5e6b4b0d3255bfef95601890afd80709                0 Release
+SHA256:
+ 39aa9fc59d868a71030d24aeaa4b574d7a11a10ea79491a0881f8d755b36a06d              338 Packages
+ 62898623498ebf8304647db1ba2d33e4d8ec0e3e45250c2b66907c812b099297              269 Packages.gz
+ e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855                0 Release
diff --git a/test/local-repo/Release.gpg b/test/local-repo/Release.gpg
new file mode 100644 (file)
index 0000000..e1c3095
--- /dev/null
@@ -0,0 +1,7 @@
+-----BEGIN PGP SIGNATURE-----
+Version: GnuPG v1.4.6 (GNU/Linux)
+
+iD8DBQBGuui6liSD4VZixzQRApSlAJ9D6G1QXvtXH1jH1I4SStsb1VsImQCbBPfp
++1p0bDANcBVY+GckjJvFRkY=
+=a0AR
+-----END PGP SIGNATURE-----
diff --git a/test/local-repo/gdebi-test4.deb b/test/local-repo/gdebi-test4.deb
new file mode 100644 (file)
index 0000000..9eb92d1
Binary files /dev/null and b/test/local-repo/gdebi-test4.deb differ
index 837a25023552c380249fbf3749f296c549bc3228..8131d891e38c84600abf34bf60fc3e1547c922ec 100755 (executable)
@@ -11,11 +11,13 @@ import unittest
 stdout = os.open("/dev/null",0) #sys.stdout
 stderr = os.open("/dev/null",0) # sys.stderr
 
+apt_args = []  # ["-o","Debug::pkgAcquire::Auth=true"]
+
+
 class testAuthentication(unittest.TestCase):
 
     # some class wide data
     apt = "apt-get"
-    args = []  # ["-q", "-q", "-o","Debug::pkgAcquire::Auth=true"]
     pkg = "libglib2.0-data"
     pkgver = "2.13.6-1ubuntu1"
     pkgpath = "/var/cache/apt/archives/libglib2.0-data_2.13.6-1ubuntu1_all.deb"
@@ -44,13 +46,13 @@ class testAuthentication(unittest.TestCase):
             expected_res = self._expectedRes(result)
             # update first
             call([self.apt,"update",
-                  "-o","Dir::Etc::sourcelist=./%s" % f]+self.args,
+                  "-o","Dir::Etc::sourcelist=./%s" % f]+apt_args,
                  stdout=stdout, stderr=stderr)
             # then get the pkg
             cmd = ["install", "-y", "-d", "--reinstall",
                    "%s=%s" % (self.pkg, self.pkgver),
                    "-o","Dir::state::Status=./fake-status"]
-            res = call([self.apt, "-o","Dir::Etc::sourcelist=./%s" % f]+cmd+self.args,
+            res = call([self.apt, "-o","Dir::Etc::sourcelist=./%s" % f]+cmd+apt_args,
                        stdout=stdout, stderr=stderr)
             self.assert_(res == expected_res,
                          "test '%s' failed (got %s expected %s" % (f,res,expected_res))
@@ -63,14 +65,14 @@ class testAuthentication(unittest.TestCase):
             expected_res = self._expectedRes(result)
             # update first
             call([self.apt,"update",
-                  "-o","Dir::Etc::sourcelist=./%s" % f]+self.args,
+                  "-o","Dir::Etc::sourcelist=./%s" % f]+apt_args,
                  stdout=stdout, stderr=stderr)
             # then get the pkg
             cmd = ["install", "-y", "-d", "--reinstall",
                    "%s=%s" % (self.pkg, self.pkgver),
                    "-o","Dir::state::Status=./fake-status"]
             res = call([self.apt, "-o","Dir::Etc::sourcelist=./%s" % f]+
-                       cmd+self.args,
+                       cmd+apt_args,
                        stdout=stdout, stderr=stderr)
             self.assert_(res == expected_res,
                          "test '%s' failed (got %s expected %s" % (f,res,expected_res))
@@ -81,33 +83,60 @@ class testAuthentication(unittest.TestCase):
             (prefix, testtype, result) = f.split("-")
             expected_res = self._expectedRes(result)
             cmd = ["update"]
-            res = call([self.apt,"-o","Dir::Etc::sourcelist=./%s" % f]+cmd+self.args,
+            res = call([self.apt,"-o","Dir::Etc::sourcelist=./%s" % f]+cmd+apt_args,
                        stdout=stdout, stderr=stderr)
             self.assert_(res == expected_res,
                          "test '%s' failed (got %s expected %s" % (f,res,expected_res))
 
 
-class testPythonApt(unittest.TestCase):
-    " test if python-apt is still working and if we not accidently broke the ABI "
-    
-    def testPythonApt(self):
-        import apt
-        cache = apt.Cache()
-        cache.update()
-        pkg = cache["apt"]
-        self.assert_(pkg.name == 'apt')
 
-class testAptInstall(unittest.TestCase):
-    " test if installing still works "
+class testLocalRepositories(unittest.TestCase):
+    " test local repository regressions "
 
+    repo_dir = "local-repo"
     apt = "apt-get"
-    pkg = "coreutils"
+    pkg = "gdebi-test4"
 
-    def testInstall(self):
-        res = call([self.apt,"-y","install","--reinstall",self.pkg],
+    def setUp(self):
+        self.repo = os.path.abspath(os.path.join(os.getcwd(), self.repo_dir))
+        self.sources = os.path.join(self.repo, "sources.list")
+        s = open(self.sources,"w")
+        s.write("deb file://%s/ /\n" % self.repo)
+        s.close()
+
+    def testLocalRepoAuth(self):
+        # two times to get at least one i-m-s hit
+        for i in range(2):
+            self.assert_(os.path.exists(self.sources))
+            cmd = [self.apt,"update","-o", "Dir::Etc::sourcelist=%s" % self.sources]+apt_args
+            res = call(cmd, stdout=stdout, stderr=stderr)
+            self.assertEqual(res, 0, "local repo test failed")
+            self.assert_(os.path.exists(os.path.join(self.repo,"Packages.gz")),
+                         "Packages.gz vanished from local repo")
+
+    def testInstallFromLocalRepo(self):
+        apt = [self.apt,"-o", "Dir::Etc::sourcelist=%s"% self.sources]+apt_args
+        cmd = apt+["update"]
+        res = call(cmd, stdout=stdout, stderr=stderr)
+        self.assertEqual(res, 0)
+        res = call(apt+["-y","install","--reinstall",self.pkg],
                    stdout=stdout, stderr=stderr)
         self.assert_(res == 0,
                      "installing %s failed (got %s)" % (self.pkg, res))
+        res = call(apt+["-y","remove",self.pkg],
+                   stdout=stdout, stderr=stderr)
+        self.assert_(res == 0,
+                     "removing %s failed (got %s)" % (self.pkg, res))
+
+    def testPythonAptInLocalRepo(self):
+        import apt, apt_pkg
+        apt_pkg.Config.Set("Dir::Etc::sourcelist",self.sources)
+        cache = apt.Cache()
+        cache.update()
+        pkg = cache["apt"]
+        self.assert_(pkg.name == 'apt')
+        
+
 
 if __name__ == "__main__":
     print "Runing simple testsuit on current apt-get and libapt"