Procházet zdrojové kódy

* apt-pkg/pkgcachegen.cc:
- increase default mmap size
* tests/local-repo:
- added local repository testcase

Michael Vogt před 19 roky
rodič
revize
7f3142149d

+ 0 - 3
apt-pkg/acquire-item.cc

@@ -674,10 +674,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";

+ 2 - 2
apt-pkg/cdrom.cc

@@ -668,8 +668,8 @@ bool pkgCdrom::Add(pkgCdromStatus *log)
    DropRepeats(TransList,"");
    if(log) {
       msg.str("");
-      ioprintf(msg, _("Found %i package indexes, %i source indexes, "
-		      "%i translation indexes and %i signatures\n"), 
+      ioprintf(msg, _("Found %lu package indexes, %lu source indexes, "
+		      "%lu translation indexes and %lu signatures\n"), 
 	       List.size(), SourceList.size(), TransList.size(),
 	       SigList.size());
       log->Update(msg.str(), STEP_SCAN);

+ 4 - 7
apt-pkg/deb/dpkgpm.cc

@@ -44,7 +44,8 @@ using namespace std;
 // ---------------------------------------------------------------------
 /* */
 pkgDPkgPM::pkgDPkgPM(pkgDepCache *Cache) 
-   : pkgPackageManager(Cache), dpkgbuf_pos(0), PackagesTotal(0), PackagesDone(0)
+   : pkgPackageManager(Cache), dpkgbuf_pos(0), PackagesDone(0), 
+     PackagesTotal(0), term_out(NULL)
 {
 }
 									/*}}}*/
@@ -351,7 +352,7 @@ void pkgDPkgPM::DoStdin(int master)
 /*
  * read the terminal pty and write log
  */
-void pkgDPkgPM::DoTerminalPty(int master, FILE *term_out)
+void pkgDPkgPM::DoTerminalPty(int master)
 {
    char term_buf[1024] = {0,};
 
@@ -567,7 +568,6 @@ bool pkgDPkgPM::Go(int OutStatusFd)
       return _error->Error(_("Directory '%s' missing"), logdir.c_str());
    string logfile_name = flCombine(logdir,
 				   _config->Find("Dir::Log::Terminal"));
-   FILE *term_out = NULL;
    if (!logfile_name.empty())
    {
       term_out = fopen(logfile_name.c_str(),"a");
@@ -778,9 +778,6 @@ bool pkgDPkgPM::Go(int OutStatusFd)
       int _dpkgin = fd[0];
       close(fd[1]);                        // close the write end of the pipe
 
-      // the read buffers for the communication with dpkg
-      char buf[2] = {0,0};
-      
       // the result of the waitpid call
       int res;
       if(slave > 0)
@@ -820,7 +817,7 @@ bool pkgDPkgPM::Go(int OutStatusFd)
 	    continue;
 
 	 if(master >= 0 && FD_ISSET(master, &rfds))
-	    DoTerminalPty(master, term_out);
+	    DoTerminalPty(master);
 	 if(master >= 0 && FD_ISSET(0, &rfds))
 	    DoStdin(master);
 	 if(FD_ISSET(_dpkgin, &rfds))

+ 6 - 5
apt-pkg/deb/dpkgpm.h

@@ -26,7 +26,8 @@ class pkgDPkgPM : public pkgPackageManager
    // the buffer we use for the dpkg status-fd reading
    char dpkgbuf[1024];
    int dpkgbuf_pos;
-
+   FILE *term_out;
+   
    protected:
 
    // progress reporting
@@ -43,10 +44,10 @@ class pkgDPkgPM : public pkgPackageManager
    // the dpkg states that are already done; the string is the package
    // the int is the state that is already done (e.g. a package that is
    // going to be install is already in state "half-installed")
-   map<string,int> PackageOpsDone;
+   map<string,unsigned int> PackageOpsDone;
    // progress reporting
-   int PackagesDone;
-   int PackagesTotal;
+   unsigned int PackagesDone;
+   unsigned int PackagesTotal;
   
    struct Item
    {
@@ -67,7 +68,7 @@ class pkgDPkgPM : public pkgPackageManager
 
    // input processing
    void DoStdin(int master);
-   void DoTerminalPty(int master, FILE *out);
+   void DoTerminalPty(int master);
    void DoDpkgStatusFd(int statusfd, int OutStatusFd);
    void ProcessDpkgStatusLine(int OutStatusFd, char *line);
 

+ 2 - 2
apt-pkg/pkgcachegen.cc

@@ -781,7 +781,7 @@ static bool BuildCache(pkgCacheGenerator &Gen,
 bool pkgMakeStatusCache(pkgSourceList &List,OpProgress &Progress,
 			MMap **OutMap,bool AllowMem)
 {
-   unsigned long MapSize = _config->FindI("APT::Cache-Limit",16*1024*1024);
+   unsigned long MapSize = _config->FindI("APT::Cache-Limit",24*1024*1024);
    
    vector<pkgIndexFile *> Files;
    for (vector<metaIndex *>::const_iterator i = List.begin();
@@ -928,7 +928,7 @@ bool pkgMakeStatusCache(pkgSourceList &List,OpProgress &Progress,
 /* */
 bool pkgMakeOnlyStatusCache(OpProgress &Progress,DynamicMMap **OutMap)
 {
-   unsigned long MapSize = _config->FindI("APT::Cache-Limit",12*1024*1024);
+   unsigned long MapSize = _config->FindI("APT::Cache-Limit",20*1024*1024);
    vector<pkgIndexFile *> Files;
    unsigned long EndOfSource = Files.size();
    if (_system->AddStatusFiles(Files) == false)

+ 1 - 1
configure.in

@@ -18,7 +18,7 @@ AC_CONFIG_AUX_DIR(buildlib)
 AC_CONFIG_HEADER(include/config.h:buildlib/config.h.in include/apti18n.h:buildlib/apti18n.h.in)
 
 dnl -- SET THIS TO THE RELEASE VERSION --
-AC_DEFINE_UNQUOTED(VERSION,"0.7.6ubuntu1")
+AC_DEFINE_UNQUOTED(VERSION,"0.7.7")
 PACKAGE="apt"
 AC_DEFINE_UNQUOTED(PACKAGE,"$PACKAGE")
 AC_SUBST(PACKAGE)

+ 4 - 0
debian/changelog

@@ -17,6 +17,10 @@ apt (0.7.7) UNRELEASED; 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
   
   [ Program translations ]
     - French updated

+ 16 - 0
test/fake-status

@@ -0,0 +1,16 @@
+Package: libglib2.0-0
+Status: install ok installed
+Priority: optional
+Section: libs
+Installed-Size: 1376
+Maintainer: Ubuntu Desktop Team <ubuntu-desktop@lists.ubuntu.com>
+Architecture: amd64
+Source: glib2.0
+Version: 2.13.7-1ubuntu1
+Description: The GLib library of C routines
+ GLib is a library containing many useful C routines for things such
+ as trees, hashes, lists, and strings.  It is a useful general-purpose
+ C library used by projects such as GTK+, GIMP, and GNOME.
+ .
+ This package contains the shared libraries.
+Original-Maintainer: Loic Minier <lool@dooz.org>

+ 11 - 0
test/local-repo/Packages

@@ -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)
+

binární
test/local-repo/Packages.gz


binární
test/local-repo/Packages.gz.save


+ 13 - 0
test/local-repo/Release

@@ -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

+ 7 - 0
test/local-repo/Release.gpg

@@ -0,0 +1,7 @@
+-----BEGIN PGP SIGNATURE-----
+Version: GnuPG v1.4.6 (GNU/Linux)
+
+iD8DBQBGuui6liSD4VZixzQRApSlAJ9D6G1QXvtXH1jH1I4SStsb1VsImQCbBPfp
++1p0bDANcBVY+GckjJvFRkY=
+=a0AR
+-----END PGP SIGNATURE-----

binární
test/local-repo/gdebi-test4.deb


+ 148 - 0
test/pre-upload-check.py

@@ -0,0 +1,148 @@
+#!/usr/bin/python
+
+import sys
+import os
+import glob
+import os.path
+from subprocess import call, PIPE
+
+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"
+    pkg = "libglib2.0-data"
+    pkgver = "2.13.6-1ubuntu1"
+    pkgpath = "/var/cache/apt/archives/libglib2.0-data_2.13.6-1ubuntu1_all.deb"
+
+    def setUp(self):
+        for f in glob.glob("testkeys/*,key"):
+            call(["apt-key", "add", f], stdout=stdout, stderr=stderr)
+
+    def _cleanup(self):
+        " make sure we get new lists and no i-m-s "
+        call(["rm","-f", "/var/lib/apt/lists/*"])
+        if os.path.exists(self.pkgpath):
+            os.unlink(self.pkgpath)
+
+    def _expectedRes(self, resultstr):
+        if resultstr == 'ok':
+            return 0
+        elif resultstr == 'broken':
+            return 100
+        
+
+    def testPackages(self):
+        for f in glob.glob("testsources.list/sources.list*package*"):
+            self._cleanup()
+            (prefix, testtype, result) = f.split("-")
+            expected_res = self._expectedRes(result)
+            # update first
+            call([self.apt,"update",
+                  "-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+apt_args,
+                       stdout=stdout, stderr=stderr)
+            self.assert_(res == expected_res,
+                         "test '%s' failed (got %s expected %s" % (f,res,expected_res))
+            
+
+    def testGPG(self):
+        for f in glob.glob("testsources.list/sources.list*gpg*"):
+            self._cleanup()
+            (prefix, testtype, result) = f.split("-")
+            expected_res = self._expectedRes(result)
+            # update first
+            call([self.apt,"update",
+                  "-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+apt_args,
+                       stdout=stdout, stderr=stderr)
+            self.assert_(res == expected_res,
+                         "test '%s' failed (got %s expected %s" % (f,res,expected_res))
+
+    def testRelease(self):
+        for f in glob.glob("testsources.list/sources.list*release*"):
+            self._cleanup()
+            (prefix, testtype, result) = f.split("-")
+            expected_res = self._expectedRes(result)
+            cmd = ["update"]
+            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 testLocalRepositories(unittest.TestCase):
+    " test local repository regressions "
+
+    repo_dir = "local-repo"
+    apt = "apt-get"
+    pkg = "gdebi-test4"
+
+    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"
+    if len(sys.argv) > 1 and sys.argv[1] == "-v":
+        stdout = sys.stdout
+        stderr = sys.stderr
+    unittest.main()
+
+

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 1182 - 0
test/testkeys/mvo.key


+ 2 - 0
test/testsources.list/sources.list.all-gpg-broken

@@ -0,0 +1,2 @@
+deb http://people.ubuntu.com/~mvo/apt/auth-test-suit/gpg-package-broken/ /
+

+ 2 - 0
test/testsources.list/sources.list.all-gpg-ok

@@ -0,0 +1,2 @@
+deb http://people.ubuntu.com/~mvo/apt/auth-test-suit/gpg-package-ok/ /
+

+ 1 - 0
test/testsources.list/sources.list.all-release-broken

@@ -0,0 +1 @@
+deb http://people.ubuntu.com/~mvo/apt/auth-test-suit/all-release-broken/ /

+ 1 - 0
test/testsources.list/sources.list.all-release-ok

@@ -0,0 +1 @@
+deb http://people.ubuntu.com/~mvo/apt/auth-test-suit/all-release-ok/ /

+ 2 - 0
test/testsources.list/sources.list.md5-package-broken

@@ -0,0 +1,2 @@
+deb http://people.ubuntu.com/~mvo/apt/auth-test-suit/md5-package-broken/ /
+

+ 2 - 0
test/testsources.list/sources.list.md5-package-ok

@@ -0,0 +1,2 @@
+deb http://people.ubuntu.com/~mvo/apt/auth-test-suit/md5-package-ok/ /
+

+ 1 - 0
test/testsources.list/sources.list.md5-release-broken

@@ -0,0 +1 @@
+deb http://people.ubuntu.com/~mvo/apt/auth-test-suit/md5-release-broken/ /

+ 1 - 0
test/testsources.list/sources.list.md5-release-ok

@@ -0,0 +1 @@
+deb http://people.ubuntu.com/~mvo/apt/auth-test-suit/md5-release-ok/ /

+ 1 - 0
test/testsources.list/sources.list.sha1-release-broken

@@ -0,0 +1 @@
+deb http://people.ubuntu.com/~mvo/apt/auth-test-suit/sha1-release-broken/ /

+ 1 - 0
test/testsources.list/sources.list.sha1-release-ok

@@ -0,0 +1 @@
+deb http://people.ubuntu.com/~mvo/apt/auth-test-suit/sha1-release-ok/ /

+ 2 - 0
test/testsources.list/sources.list.sha256-package-broken

@@ -0,0 +1,2 @@
+deb http://people.ubuntu.com/~mvo/apt/auth-test-suit/sha256-package-broken/ /
+

+ 2 - 0
test/testsources.list/sources.list.sha256-package-ok

@@ -0,0 +1,2 @@
+deb http://people.ubuntu.com/~mvo/apt/auth-test-suit/sha256-package-ok/ /
+

+ 1 - 0
test/testsources.list/sources.list.sha256-release-broken

@@ -0,0 +1 @@
+deb http://people.ubuntu.com/~mvo/apt/auth-test-suit/sha256-release-broken/ /

+ 1 - 0
test/testsources.list/sources.list.sha256-release-ok

@@ -0,0 +1 @@
+deb http://people.ubuntu.com/~mvo/apt/auth-test-suit/sha256-release-ok/ /