]> git.saurik.com Git - apt.git/blobdiff - cmdline/apt-get.cc
add a simple unit test for acquire progress
[apt.git] / cmdline / apt-get.cc
index eca4a723b28f35e3d806a4ef0677c58a3c03a5fc..1a4f4c5a847d94791146ba09e2c9f36a7aefecae 100644 (file)
@@ -558,30 +558,12 @@ static bool DoClean(CommandLine &)
       return true;
    }
 
-   bool const NoLocking = _config->FindB("Debug::NoLocking",false);
-   // Lock the archive directory
-   FileFd Lock;
-   if (NoLocking == false)
-   {
-      int lock_fd = GetLock(archivedir + "lock");
-      if (lock_fd < 0)
-        return _error->Error(_("Unable to lock directory %s"), archivedir.c_str());
-      Lock.Fd(lock_fd);
-   }
-
    pkgAcquire Fetcher;
+   Fetcher.GetLock(archivedir);
    Fetcher.Clean(archivedir);
    Fetcher.Clean(archivedir + "partial/");
 
-   if (NoLocking == false)
-   {
-      Lock.Close();
-      int lock_fd = GetLock(listsdir + "lock");
-      if (lock_fd < 0)
-        return _error->Error(_("Unable to lock directory %s"), listsdir.c_str());
-      Lock.Fd(lock_fd);
-   }
-
+   Fetcher.GetLock(listsdir);
    Fetcher.Clean(listsdir + "partial/");
 
    pkgCacheFile::RemoveCaches();
@@ -642,7 +624,7 @@ static bool DoDownload(CommandLine &CmdL)
    if (verset.empty() == true)
       return false;
 
-   AcqTextStatus Stat(ScreenWidth, _config->FindI("quiet", 0));
+   AcqTextStatus Stat(std::cout, ScreenWidth,_config->FindI("quiet",0));
    pkgAcquire Fetcher(&Stat);
 
    pkgRecords Recs(Cache);
@@ -747,7 +729,7 @@ static bool DoSource(CommandLine &CmdL)
       return false;
 
    // Create the download object
-   AcqTextStatus Stat(ScreenWidth,_config->FindI("quiet",0));
+   AcqTextStatus Stat(std::cout, ScreenWidth,_config->FindI("quiet",0));
    pkgAcquire Fetcher(&Stat);
 
    SPtrArray<DscFile> Dsc = new DscFile[CmdL.FileSize()];
@@ -809,13 +791,13 @@ static bool DoSource(CommandLine &CmdL)
       }
 
       // Back track
-      vector<pkgSrcRecords::File> Lst;
-      if (Last->Files(Lst) == false) {
+      vector<pkgSrcRecords::File2> Lst;
+      if (Last->Files2(Lst) == false) {
         return false;
       }
 
       // Load them into the fetcher
-      for (vector<pkgSrcRecords::File>::const_iterator I = Lst.begin();
+      for (vector<pkgSrcRecords::File2>::const_iterator I = Lst.begin();
           I != Lst.end(); ++I)
       {
         // Try to guess what sort of file it is we are getting.
@@ -862,7 +844,7 @@ static bool DoSource(CommandLine &CmdL)
         }
 
         new pkgAcqFile(&Fetcher,Last->Index().ArchiveURI(I->Path),
-                       I->Hashes, I->Size, Last->Index().SourceInfo(*Last,*I), Src);
+                       I->Hashes, I->FileSize, Last->Index().SourceInfo(*Last,*I), Src);
       }
    }
 
@@ -1568,7 +1550,7 @@ static bool DoChangelog(CommandLine &CmdL)
       return Success;
    }
 
-   AcqTextStatus Stat(ScreenWidth, _config->FindI("quiet",0));
+   AcqTextStatus Stat(std::cout, ScreenWidth,_config->FindI("quiet",0));
    Fetcher.SetLog(&Stat);
 
    bool const downOnly = _config->FindB("APT::Get::Download-Only", false);
@@ -1625,13 +1607,12 @@ static bool DoChangelog(CommandLine &CmdL)
 /* */
 static bool ShowHelp(CommandLine &)
 {
-   ioprintf(cout,_("%s %s for %s compiled on %s %s\n"),PACKAGE,PACKAGE_VERSION,
-           COMMON_ARCH,__DATE__,__TIME__);
-           
+   ioprintf(cout, "%s %s (%s)\n", PACKAGE, PACKAGE_VERSION, COMMON_ARCH);
+
    if (_config->FindB("version") == true)
    {
       cout << _("Supported modules:") << endl;
-      
+
       for (unsigned I = 0; I != pkgVersioningSystem::GlobalListLen; I++)
       {
         pkgVersioningSystem *VS = pkgVersioningSystem::GlobalList[I];
@@ -1640,7 +1621,7 @@ static bool ShowHelp(CommandLine &)
         else
            cout << ' ';
         cout << "Ver: " << VS->Label << endl;
-        
+
         /* Print out all the packaging systems that will work with 
            this VS */
         for (unsigned J = 0; J != pkgSystem::GlobalListLen; J++)
@@ -1746,26 +1727,8 @@ int main(int argc,const char *argv[])                                    /*{{{*/
    textdomain(PACKAGE);
 
    // Parse the command line and initialize the package library
-   CommandLine CmdL(Args.data(),_config);
-   if (pkgInitConfig(*_config) == false ||
-       CmdL.Parse(argc,argv) == false ||
-       pkgInitSystem(*_config,_system) == false)
-   {
-      if (_config->FindB("version") == true)
-        ShowHelp(CmdL);
-        
-      _error->DumpErrors();
-      return 100;
-   }
-
-   // See if the help should be shown
-   if (_config->FindB("help") == true ||
-       _config->FindB("version") == true ||
-       CmdL.FileSize() == 0)
-   {
-      ShowHelp(CmdL);
-      return 0;
-   }
+   CommandLine CmdL;
+   ParseCommandLine(CmdL, Cmds, Args.data(), &_config, &_system, argc, argv, ShowHelp);
 
    // see if we are in simulate mode
    CheckSimulateMode(CmdL);