X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/9055d5e68bd09f31df00e45bd14cb599ba3735e5..0a7370ca91289db3d23d72aeac397edfe3dfb75b:/apt-private/private-download.cc diff --git a/apt-private/private-download.cc b/apt-private/private-download.cc index 4894c72bf..c85a49727 100644 --- a/apt-private/private-download.cc +++ b/apt-private/private-download.cc @@ -27,6 +27,7 @@ #include #include #include +#include #include #include @@ -65,8 +66,7 @@ bool AuthPrompt(std::vector const &UntrustedList, bool const Prompt if (_config->FindI("quiet",0) < 2 && _config->FindB("APT::Get::Assume-Yes",false) == false) { - c2out << _("Install these packages without verification?") << std::flush; - if (!YnPrompt(false)) + if (!YnPrompt(_("Install these packages without verification?"), false)) return _error->Error(_("Some packages could not be authenticated")); return true; @@ -108,7 +108,7 @@ bool AcquireRun(pkgAcquire &Fetcher, int const PulseInterval, bool * const Failu uri.User.clear(); uri.Password.clear(); std::string descUri = std::string(uri); - _error->Error(_("Failed to fetch %s %s\n"), descUri.c_str(), + _error->Error(_("Failed to fetch %s %s"), descUri.c_str(), (*I)->ErrorText.c_str()); if (Failure != NULL) @@ -143,7 +143,7 @@ bool CheckFreeSpaceBeforeDownload(std::string const &Dir, unsigned long long Fet { struct statfs Stat; if (statfs(Dir.c_str(),&Stat) != 0 -#if HAVE_STRUCT_STATFS_F_TYPE +#ifdef HAVE_STRUCT_STATFS_F_TYPE || Stat.f_type != RAMFS_MAGIC #endif ) @@ -224,6 +224,7 @@ bool DoDownload(CommandLine &CmdL) std::ifstream src((*I)->DestFile.c_str(), std::ios::binary); std::ofstream dst(filename.c_str(), std::ios::binary); dst << src.rdbuf(); + chmod(filename.c_str(), 0644); } } return Failed == false; @@ -244,6 +245,8 @@ bool DoChangelog(CommandLine &CmdL) bool const downOnly = _config->FindB("APT::Get::Download-Only", false); bool const printOnly = _config->FindB("APT::Get::Print-URIs", false); + if (printOnly) + _config->CndSet("Acquire::Changelogs::AlwaysOnline", true); aptAcquireWithTextStatus Fetcher; for (APT::VersionList::const_iterator Ver = verset.begin(); @@ -307,12 +310,18 @@ bool DoClean(CommandLine &) } pkgAcquire Fetcher; - Fetcher.GetLock(archivedir); - Fetcher.Clean(archivedir); - Fetcher.Clean(archivedir + "partial/"); + if (archivedir.empty() == false && FileExists(archivedir) == true && + Fetcher.GetLock(archivedir) == true) + { + Fetcher.Clean(archivedir); + Fetcher.Clean(archivedir + "partial/"); + } - Fetcher.GetLock(listsdir); - Fetcher.Clean(listsdir + "partial/"); + if (listsdir.empty() == false && FileExists(listsdir) == true && + Fetcher.GetLock(listsdir) == true) + { + Fetcher.Clean(listsdir + "partial/"); + } pkgCacheFile::RemoveCaches(); @@ -331,16 +340,20 @@ bool DoClean(CommandLine &) c1out << "Del " << Pkg << " " << Ver << " [" << SizeToStr(St.st_size) << "B]" << std::endl; if (_config->FindB("APT::Get::Simulate") == false) - unlink(File); + RemoveFile("Cleaner::Erase", File); }; }; bool DoAutoClean(CommandLine &) { + std::string const archivedir = _config->FindDir("Dir::Cache::Archives"); + if (FileExists(archivedir) == false) + return true; + // Lock the archive directory FileFd Lock; if (_config->FindB("Debug::NoLocking",false) == false) { - int lock_fd = GetLock(_config->FindDir("Dir::Cache::Archives") + "lock"); + int lock_fd = GetLock(flCombine(archivedir, "lock")); if (lock_fd < 0) return _error->Error(_("Unable to lock the download directory")); Lock.Fd(lock_fd); @@ -352,7 +365,7 @@ bool DoAutoClean(CommandLine &) LogCleaner Cleaner; - return Cleaner.Go(_config->FindDir("Dir::Cache::archives"),*Cache) && - Cleaner.Go(_config->FindDir("Dir::Cache::archives") + "partial/",*Cache); + return Cleaner.Go(archivedir, *Cache) && + Cleaner.Go(flCombine(archivedir, "partial/"), *Cache); } /*}}}*/