From ed9665aedf77b3b8345bd4ed33de7885738e29f0 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 27 Feb 2014 16:46:05 +0100 Subject: initial version of apt-helper --- cmdline/apt-helper.cc | 127 ++++++++++++++++++++++++++++++++++++++++++++++++++ cmdline/makefile | 7 +++ 2 files changed, 134 insertions(+) create mode 100644 cmdline/apt-helper.cc (limited to 'cmdline') diff --git a/cmdline/apt-helper.cc b/cmdline/apt-helper.cc new file mode 100644 index 000000000..c1c8b2178 --- /dev/null +++ b/cmdline/apt-helper.cc @@ -0,0 +1,127 @@ +// -*- mode: cpp; mode: fold -*- +// Description /*{{{*/ +/* ##################################################################### + apt-helper - cmdline helpers + ##################################################################### */ + /*}}}*/ +// Include Files /*{{{*/ +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include +#include +#include +#include + + + +#include + /*}}}*/ +using namespace std; + +bool DoDownloadFile(CommandLine &CmdL) +{ + if (CmdL.FileSize() <= 2) + return _error->Error(_("Must specify at least one pair url/filename")); + + + pkgAcquire Fetcher; + AcqTextStatus Stat(ScreenWidth, _config->FindI("quiet",0)); + Fetcher.Setup(&Stat); + std::string download_uri = CmdL.FileList[1]; + std::string targetfile = CmdL.FileList[2]; + new pkgAcqFile(&Fetcher, download_uri, "", 0, "desc", "short-desc", + "dest-dir-ignored", targetfile); + Fetcher.Run(); + if (!FileExists(targetfile)) + { + _error->Error(_("Download Failed")); + return false; + } + return true; +} + +bool ShowHelp(CommandLine &CmdL) +{ + ioprintf(cout,_("%s %s for %s compiled on %s %s\n"),PACKAGE,PACKAGE_VERSION, + COMMON_ARCH,__DATE__,__TIME__); + + if (_config->FindB("version") == true) + return true; + + cout << + _("Usage: apt-helper [options] command\n" + " apt-helper [options] download-file uri target-path\n" + "\n" + "apt-helper is a internal helper for apt\n" + "\n" + "Commands:\n" + " download-file - download the given uri to the target-path\n" + "\n" + " This APT helper has Super Meep Powers.\n"); + return true; +} + + +int main(int argc,const char *argv[]) /*{{{*/ +{ + CommandLine::Dispatch Cmds[] = {{"help",&ShowHelp}, + {"download-file", &DoDownloadFile}, + {0,0}}; + + std::vector Args = getCommandArgs( + "apt-download", CommandLine::GetCommand(Cmds, argc, argv)); + + // Set up gettext support + setlocale(LC_ALL,""); + 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; + } + + InitOutput(); + + // Match the operation + CmdL.DispatchArg(Cmds); + + // Print any errors or warnings found during parsing + bool const Errors = _error->PendingError(); + if (_config->FindI("quiet",0) > 0) + _error->DumpErrors(); + else + _error->DumpErrors(GlobalError::DEBUG); + return Errors == true ? 100 : 0; +} + /*}}}*/ diff --git a/cmdline/makefile b/cmdline/makefile index f89192e10..c4a249cd6 100644 --- a/cmdline/makefile +++ b/cmdline/makefile @@ -47,6 +47,13 @@ LIB_MAKES = apt-pkg/makefile SOURCE = apt-mark.cc include $(PROGRAM_H) +# The apt-helper +PROGRAM=apt-helper +SLIBS = -lapt-pkg -lapt-private $(INTLLIBS) +LIB_MAKES = apt-pkg/makefile +SOURCE = apt-helper.cc +include $(PROGRAM_H) + # The apt-report-mirror-failure program #SOURCE=apt-report-mirror-failure #TO=$(BIN) -- cgit v1.2.3 From e43a426e5d402d36eb180935fbbf1430a4a86e3f Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 27 Feb 2014 16:46:05 +0100 Subject: initial version of apt-helper --- cmdline/apt-helper.cc | 127 ++++++++++++++++++++++++++++++++++++++++++++++++++ cmdline/makefile | 7 +++ 2 files changed, 134 insertions(+) create mode 100644 cmdline/apt-helper.cc (limited to 'cmdline') diff --git a/cmdline/apt-helper.cc b/cmdline/apt-helper.cc new file mode 100644 index 000000000..c1c8b2178 --- /dev/null +++ b/cmdline/apt-helper.cc @@ -0,0 +1,127 @@ +// -*- mode: cpp; mode: fold -*- +// Description /*{{{*/ +/* ##################################################################### + apt-helper - cmdline helpers + ##################################################################### */ + /*}}}*/ +// Include Files /*{{{*/ +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include +#include +#include +#include + + + +#include + /*}}}*/ +using namespace std; + +bool DoDownloadFile(CommandLine &CmdL) +{ + if (CmdL.FileSize() <= 2) + return _error->Error(_("Must specify at least one pair url/filename")); + + + pkgAcquire Fetcher; + AcqTextStatus Stat(ScreenWidth, _config->FindI("quiet",0)); + Fetcher.Setup(&Stat); + std::string download_uri = CmdL.FileList[1]; + std::string targetfile = CmdL.FileList[2]; + new pkgAcqFile(&Fetcher, download_uri, "", 0, "desc", "short-desc", + "dest-dir-ignored", targetfile); + Fetcher.Run(); + if (!FileExists(targetfile)) + { + _error->Error(_("Download Failed")); + return false; + } + return true; +} + +bool ShowHelp(CommandLine &CmdL) +{ + ioprintf(cout,_("%s %s for %s compiled on %s %s\n"),PACKAGE,PACKAGE_VERSION, + COMMON_ARCH,__DATE__,__TIME__); + + if (_config->FindB("version") == true) + return true; + + cout << + _("Usage: apt-helper [options] command\n" + " apt-helper [options] download-file uri target-path\n" + "\n" + "apt-helper is a internal helper for apt\n" + "\n" + "Commands:\n" + " download-file - download the given uri to the target-path\n" + "\n" + " This APT helper has Super Meep Powers.\n"); + return true; +} + + +int main(int argc,const char *argv[]) /*{{{*/ +{ + CommandLine::Dispatch Cmds[] = {{"help",&ShowHelp}, + {"download-file", &DoDownloadFile}, + {0,0}}; + + std::vector Args = getCommandArgs( + "apt-download", CommandLine::GetCommand(Cmds, argc, argv)); + + // Set up gettext support + setlocale(LC_ALL,""); + 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; + } + + InitOutput(); + + // Match the operation + CmdL.DispatchArg(Cmds); + + // Print any errors or warnings found during parsing + bool const Errors = _error->PendingError(); + if (_config->FindI("quiet",0) > 0) + _error->DumpErrors(); + else + _error->DumpErrors(GlobalError::DEBUG); + return Errors == true ? 100 : 0; +} + /*}}}*/ diff --git a/cmdline/makefile b/cmdline/makefile index f89192e10..c4a249cd6 100644 --- a/cmdline/makefile +++ b/cmdline/makefile @@ -47,6 +47,13 @@ LIB_MAKES = apt-pkg/makefile SOURCE = apt-mark.cc include $(PROGRAM_H) +# The apt-helper +PROGRAM=apt-helper +SLIBS = -lapt-pkg -lapt-private $(INTLLIBS) +LIB_MAKES = apt-pkg/makefile +SOURCE = apt-helper.cc +include $(PROGRAM_H) + # The apt-report-mirror-failure program #SOURCE=apt-report-mirror-failure #TO=$(BIN) -- cgit v1.2.3 From c1409d1be88557529c62883be3174793481233de Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 12 Mar 2014 20:33:05 +0100 Subject: add hashsum support in apt-file download and add more tests --- cmdline/apt-helper.cc | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'cmdline') diff --git a/cmdline/apt-helper.cc b/cmdline/apt-helper.cc index c1c8b2178..4a24b01d9 100644 --- a/cmdline/apt-helper.cc +++ b/cmdline/apt-helper.cc @@ -44,6 +44,9 @@ bool DoDownloadFile(CommandLine &CmdL) Fetcher.Setup(&Stat); std::string download_uri = CmdL.FileList[1]; std::string targetfile = CmdL.FileList[2]; + HashString hash; + if (CmdL.FileSize() > 3) + hash = HashString(CmdL.FileList[3]); new pkgAcqFile(&Fetcher, download_uri, "", 0, "desc", "short-desc", "dest-dir-ignored", targetfile); Fetcher.Run(); @@ -52,6 +55,14 @@ bool DoDownloadFile(CommandLine &CmdL) _error->Error(_("Download Failed")); return false; } + if(hash.empty() == false) + if(hash.VerifyFile(targetfile) == false) + { + _error->Error(_("HashSum Failed")); + Rename(targetfile, targetfile+".failed"); + return false; + } + return true; } -- cgit v1.2.3 From ce7f128c020e1347f91c6074238fc5da58c5df71 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Tue, 25 Feb 2014 14:26:18 +0100 Subject: support DEB_BUILD_PROFILES and -P for build profiles Inspired by the rest of the patch in 661537, but abstract the parsing of various ways of setting the build profiles more so it can potentially be reused and all apt parts have the same behaviour. Especially config options, cmdline options and environment will not be combined as proposed as this isn't APTs usual behaviour and dpkg doesn't do it either, so one overrides the other as it normally does. --- cmdline/apt-config.cc | 5 +++++ cmdline/apt-get.cc | 6 ++++++ 2 files changed, 11 insertions(+) (limited to 'cmdline') diff --git a/cmdline/apt-config.cc b/cmdline/apt-config.cc index 30c2a22d5..9f20b3c1b 100644 --- a/cmdline/apt-config.cc +++ b/cmdline/apt-config.cc @@ -155,6 +155,11 @@ int main(int argc,const char *argv[]) /*{{{*/ _config->Set(comp + "UncompressArg::", *a); } + std::vector const profiles = APT::Configuration::getBuildProfiles(); + _config->Clear("APT::Build-Profiles"); + for (std::vector::const_iterator p = profiles.begin(); p != profiles.end(); ++p) + _config->Set("APT::Build-Profiles::", *p); + // Match the operation CmdL.DispatchArg(Cmds); diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 12e385b69..f8de80a91 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -970,6 +970,12 @@ bool DoSource(CommandLine &CmdL) string buildopts = _config->Find("APT::Get::Host-Architecture"); if (buildopts.empty() == false) buildopts = "-a" + buildopts + " "; + + // get all active build profiles + std::string const profiles = APT::Configuration::getBuildProfilesString(); + if (profiles.empty() == false) + buildopts.append(" -P").append(profiles).append(" "); + buildopts.append(_config->Find("DPkg::Build-Options","-b -uc")); // Call dpkg-buildpackage -- cgit v1.2.3 From 67c3067f1a615fd6ff0b332c2a526d052442913d Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Tue, 25 Feb 2014 22:22:41 +0100 Subject: fix -Wmissing-field-initializers warnings Reported-By: gcc Git-Dch: Ignore --- cmdline/apt-cache.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cmdline') diff --git a/cmdline/apt-cache.cc b/cmdline/apt-cache.cc index b8892d23d..22778eb24 100644 --- a/cmdline/apt-cache.cc +++ b/cmdline/apt-cache.cc @@ -532,7 +532,7 @@ bool DumpAvail(CommandLine &Cmd) if ((File->Flags & pkgCache::Flag::NotSource) == pkgCache::Flag::NotSource) { pkgTagSection Tags; - TFRewriteData RW[] = {{"Status",0},{"Config-Version",0},{}}; + TFRewriteData RW[] = {{"Status", NULL, NULL},{"Config-Version", NULL, NULL},{NULL, NULL, NULL}}; const char *Zero = 0; if (Tags.Scan(Buffer+Jitter,VF.Size+1) == false || TFRewrite(stdout,Tags,&Zero,RW) == false) -- cgit v1.2.3 From d3e8fbb395f57954acd7a2095f02ce530a05ec6a Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 27 Feb 2014 01:20:53 +0100 Subject: =?UTF-8?q?warning:=20extra=20=E2=80=98;=E2=80=99=20[-Wpedantic]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Git-Dch: Ignore Reported-By: gcc -Wpedantic --- cmdline/apt-cdrom.cc | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'cmdline') diff --git a/cmdline/apt-cdrom.cc b/cmdline/apt-cdrom.cc index 20c6e8892..9aaebefd7 100644 --- a/cmdline/apt-cdrom.cc +++ b/cmdline/apt-cdrom.cc @@ -54,7 +54,7 @@ class pkgCdromTextStatus : public pkgCdromStatus /*{{{*/ { protected: OpTextProgress Progress; - void Prompt(const char *Text); + void Prompt(const char *Text); string PromptLine(const char *Text); bool AskCdromName(string &name); @@ -64,12 +64,12 @@ public: virtual OpProgress* GetOpProgress(); }; -void pkgCdromTextStatus::Prompt(const char *Text) +void pkgCdromTextStatus::Prompt(const char *Text) { char C; cout << Text << ' ' << flush; if (read(STDIN_FILENO,&C,1) < 0) - _error->Errno("pkgCdromTextStatus::Prompt", + _error->Errno("pkgCdromTextStatus::Prompt", "Failed to read from standard input (not a terminal?)"); if (C != '\n') cout << endl; @@ -78,37 +78,37 @@ void pkgCdromTextStatus::Prompt(const char *Text) string pkgCdromTextStatus::PromptLine(const char *Text) { cout << Text << ':' << endl; - + string Res; getline(cin,Res); return Res; } -bool pkgCdromTextStatus::AskCdromName(string &name) +bool pkgCdromTextStatus::AskCdromName(string &name) { cout << _("Please provide a name for this Disc, such as 'Debian 5.0.3 Disk 1'") << flush; name = PromptLine(""); - + return true; } - -void pkgCdromTextStatus::Update(string text, int current) + +void pkgCdromTextStatus::Update(string text, int current) { if(text.size() > 0) cout << text << flush; } -bool pkgCdromTextStatus::ChangeCdrom() +bool pkgCdromTextStatus::ChangeCdrom() { Prompt(_("Please insert a Disc in the drive and press enter")); return true; } -OpProgress* pkgCdromTextStatus::GetOpProgress() -{ - return &Progress; -}; +OpProgress* pkgCdromTextStatus::GetOpProgress() +{ + return &Progress; +} /*}}}*/ // SetupAutoDetect /*{{{*/ bool AutoDetectCdrom(pkgUdevCdromDevices &UdevCdroms, unsigned int &i, bool &automounted) -- cgit v1.2.3 From c3ccac9232c2684b15f75fa8622a9a290aeca123 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 27 Feb 2014 03:11:54 +0100 Subject: warning: no previous declaration for foobar() [-Wmissing-declarations] Git-Dch: Ignore Reported-By: gcc -Wmissing-declarations --- cmdline/apt-cache.cc | 48 ++++++++++++++++++++--------------------- cmdline/apt-cdrom.cc | 8 +++---- cmdline/apt-config.cc | 6 +++--- cmdline/apt-dump-solver.cc | 2 +- cmdline/apt-extracttemplates.cc | 8 +++---- cmdline/apt-get.cc | 36 +++++++++++++++---------------- cmdline/apt-helper.cc | 4 ++-- cmdline/apt-internal-solver.cc | 2 +- cmdline/apt-mark.cc | 12 +++++------ cmdline/apt-sortpkgs.cc | 4 ++-- cmdline/apt.cc | 2 +- 11 files changed, 66 insertions(+), 66 deletions(-) (limited to 'cmdline') diff --git a/cmdline/apt-cache.cc b/cmdline/apt-cache.cc index 22778eb24..7e569f2fc 100644 --- a/cmdline/apt-cache.cc +++ b/cmdline/apt-cache.cc @@ -58,7 +58,7 @@ using namespace std; // LocalitySort - Sort a version list by package file locality /*{{{*/ // --------------------------------------------------------------------- /* */ -int LocalityCompare(const void *a, const void *b) +static int LocalityCompare(const void *a, const void *b) { pkgCache::VerFile *A = *(pkgCache::VerFile **)a; pkgCache::VerFile *B = *(pkgCache::VerFile **)b; @@ -75,13 +75,13 @@ int LocalityCompare(const void *a, const void *b) return A->File - B->File; } -void LocalitySort(pkgCache::VerFile **begin, +static void LocalitySort(pkgCache::VerFile **begin, unsigned long Count,size_t Size) { qsort(begin,Count,Size,LocalityCompare); } -void LocalitySort(pkgCache::DescFile **begin, +static void LocalitySort(pkgCache::DescFile **begin, unsigned long Count,size_t Size) { qsort(begin,Count,Size,LocalityCompare); @@ -90,7 +90,7 @@ void LocalitySort(pkgCache::DescFile **begin, // UnMet - Show unmet dependencies /*{{{*/ // --------------------------------------------------------------------- /* */ -bool ShowUnMet(pkgCache::VerIterator const &V, bool const Important) +static bool ShowUnMet(pkgCache::VerIterator const &V, bool const Important) { bool Header = false; for (pkgCache::DepIterator D = V.DependsList(); D.end() == false;) @@ -163,7 +163,7 @@ bool ShowUnMet(pkgCache::VerIterator const &V, bool const Important) } return true; } -bool UnMet(CommandLine &CmdL) +static bool UnMet(CommandLine &CmdL) { bool const Important = _config->FindB("APT::Cache::Important",false); @@ -193,7 +193,7 @@ bool UnMet(CommandLine &CmdL) // DumpPackage - Show a dump of a package record /*{{{*/ // --------------------------------------------------------------------- /* */ -bool DumpPackage(CommandLine &CmdL) +static bool DumpPackage(CommandLine &CmdL) { pkgCacheFile CacheFile; APT::CacheSetHelper helper(true, GlobalError::NOTICE); @@ -258,7 +258,7 @@ bool DumpPackage(CommandLine &CmdL) // Stats - Dump some nice statistics /*{{{*/ // --------------------------------------------------------------------- /* */ -bool Stats(CommandLine &Cmd) +static bool Stats(CommandLine &Cmd) { pkgCacheFile CacheFile; pkgCache *Cache = CacheFile.GetPkgCache(); @@ -371,7 +371,7 @@ bool Stats(CommandLine &Cmd) // Dump - show everything /*{{{*/ // --------------------------------------------------------------------- /* This is worthless except fer debugging things */ -bool Dump(CommandLine &Cmd) +static bool Dump(CommandLine &Cmd) { pkgCacheFile CacheFile; pkgCache *Cache = CacheFile.GetPkgCache(); @@ -423,7 +423,7 @@ bool Dump(CommandLine &Cmd) // --------------------------------------------------------------------- /* This is needed to make dpkg --merge happy.. I spent a bit of time to make this run really fast, perhaps I went a little overboard.. */ -bool DumpAvail(CommandLine &Cmd) +static bool DumpAvail(CommandLine &Cmd) { pkgCacheFile CacheFile; pkgCache *Cache = CacheFile.GetPkgCache(); @@ -562,7 +562,7 @@ bool DumpAvail(CommandLine &Cmd) } /*}}}*/ // ShowDepends - Helper for printing out a dependency tree /*{{{*/ -bool ShowDepends(CommandLine &CmdL, bool const RevDepends) +static bool ShowDepends(CommandLine &CmdL, bool const RevDepends) { pkgCacheFile CacheFile; pkgCache *Cache = CacheFile.GetPkgCache(); @@ -676,7 +676,7 @@ bool ShowDepends(CommandLine &CmdL, bool const RevDepends) // Depends - Print out a dependency tree /*{{{*/ // --------------------------------------------------------------------- /* */ -bool Depends(CommandLine &CmdL) +static bool Depends(CommandLine &CmdL) { return ShowDepends(CmdL, false); } @@ -684,7 +684,7 @@ bool Depends(CommandLine &CmdL) // RDepends - Print out a reverse dependency tree /*{{{*/ // --------------------------------------------------------------------- /* */ -bool RDepends(CommandLine &CmdL) +static bool RDepends(CommandLine &CmdL) { return ShowDepends(CmdL, true); } @@ -693,7 +693,7 @@ bool RDepends(CommandLine &CmdL) // --------------------------------------------------------------------- // Code contributed from Junichi Uekawa on 20 June 2002. -bool XVcg(CommandLine &CmdL) +static bool XVcg(CommandLine &CmdL) { pkgCacheFile CacheFile; pkgCache *Cache = CacheFile.GetPkgCache(); @@ -905,7 +905,7 @@ bool XVcg(CommandLine &CmdL) /* Dotty is the graphvis program for generating graphs. It is a fairly simple queuing algorithm that just writes dependencies and nodes. http://www.research.att.com/sw/tools/graphviz/ */ -bool Dotty(CommandLine &CmdL) +static bool Dotty(CommandLine &CmdL) { pkgCacheFile CacheFile; pkgCache *Cache = CacheFile.GetPkgCache(); @@ -1126,7 +1126,7 @@ static unsigned char const* skipDescriptionFields(unsigned char const * DescP) ++DescP; return DescP; } -bool DisplayRecord(pkgCacheFile &CacheFile, pkgCache::VerIterator V) +static bool DisplayRecord(pkgCacheFile &CacheFile, pkgCache::VerIterator V) { pkgCache *Cache = CacheFile.GetPkgCache(); if (unlikely(Cache == NULL)) @@ -1228,7 +1228,7 @@ struct ExDescFile // Search - Perform a search /*{{{*/ // --------------------------------------------------------------------- /* This searches the package names and package descriptions for a pattern */ -bool Search(CommandLine &CmdL) +static bool Search(CommandLine &CmdL) { bool const ShowFull = _config->FindB("APT::Cache::ShowFull",false); bool const NamesOnly = _config->FindB("APT::Cache::NamesOnly",false); @@ -1388,7 +1388,7 @@ bool Search(CommandLine &CmdL) } /*}}}*/ /* ShowAuto - show automatically installed packages (sorted) {{{*/ -bool ShowAuto(CommandLine &CmdL) +static bool ShowAuto(CommandLine &CmdL) { pkgCacheFile CacheFile; pkgCache *Cache = CacheFile.GetPkgCache(); @@ -1415,7 +1415,7 @@ bool ShowAuto(CommandLine &CmdL) // ShowPackage - Dump the package record to the screen /*{{{*/ // --------------------------------------------------------------------- /* */ -bool ShowPackage(CommandLine &CmdL) +static bool ShowPackage(CommandLine &CmdL) { pkgCacheFile CacheFile; CacheSetHelperVirtuals helper(true, GlobalError::NOTICE); @@ -1439,7 +1439,7 @@ bool ShowPackage(CommandLine &CmdL) // ShowPkgNames - Show package names /*{{{*/ // --------------------------------------------------------------------- /* This does a prefix match on the first argument */ -bool ShowPkgNames(CommandLine &CmdL) +static bool ShowPkgNames(CommandLine &CmdL) { pkgCacheFile CacheFile; if (unlikely(CacheFile.BuildCaches(NULL, false) == false)) @@ -1478,7 +1478,7 @@ bool ShowPkgNames(CommandLine &CmdL) // ShowSrcPackage - Show source package records /*{{{*/ // --------------------------------------------------------------------- /* */ -bool ShowSrcPackage(CommandLine &CmdL) +static bool ShowSrcPackage(CommandLine &CmdL) { pkgCacheFile CacheFile; pkgSourceList *List = CacheFile.GetSourceList(); @@ -1515,7 +1515,7 @@ bool ShowSrcPackage(CommandLine &CmdL) // Policy - Show the results of the preferences file /*{{{*/ // --------------------------------------------------------------------- /* */ -bool Policy(CommandLine &CmdL) +static bool Policy(CommandLine &CmdL) { pkgCacheFile CacheFile; pkgCache *Cache = CacheFile.GetPkgCache(); @@ -1644,7 +1644,7 @@ bool Policy(CommandLine &CmdL) // Madison - Look a bit like katie's madison /*{{{*/ // --------------------------------------------------------------------- /* */ -bool Madison(CommandLine &CmdL) +static bool Madison(CommandLine &CmdL) { pkgCacheFile CacheFile; pkgSourceList *SrcList = CacheFile.GetSourceList(); @@ -1717,7 +1717,7 @@ bool Madison(CommandLine &CmdL) // GenCaches - Call the main cache generator /*{{{*/ // --------------------------------------------------------------------- /* */ -bool GenCaches(CommandLine &Cmd) +static bool GenCaches(CommandLine &Cmd) { OpTextProgress Progress(*_config); @@ -1728,7 +1728,7 @@ bool GenCaches(CommandLine &Cmd) // ShowHelp - Show a help screen /*{{{*/ // --------------------------------------------------------------------- /* */ -bool ShowHelp(CommandLine &Cmd) +static bool ShowHelp(CommandLine &Cmd) { ioprintf(cout,_("%s %s for %s compiled on %s %s\n"),PACKAGE,PACKAGE_VERSION, COMMON_ARCH,__DATE__,__TIME__); diff --git a/cmdline/apt-cdrom.cc b/cmdline/apt-cdrom.cc index 9aaebefd7..dc0e050c3 100644 --- a/cmdline/apt-cdrom.cc +++ b/cmdline/apt-cdrom.cc @@ -111,7 +111,7 @@ OpProgress* pkgCdromTextStatus::GetOpProgress() } /*}}}*/ // SetupAutoDetect /*{{{*/ -bool AutoDetectCdrom(pkgUdevCdromDevices &UdevCdroms, unsigned int &i, bool &automounted) +static bool AutoDetectCdrom(pkgUdevCdromDevices &UdevCdroms, unsigned int &i, bool &automounted) { bool Debug = _config->FindB("Debug::Acquire::cdrom", false); @@ -155,7 +155,7 @@ bool AutoDetectCdrom(pkgUdevCdromDevices &UdevCdroms, unsigned int &i, bool &aut sequence is to mount/umount the CD, Ident it then scan it for package files and reduce that list. Then we copy over the package files and verify them. Then rewrite the database files */ -bool DoAdd(CommandLine &) +static bool DoAdd(CommandLine &) { pkgUdevCdromDevices UdevCdroms; pkgCdromTextStatus log; @@ -201,7 +201,7 @@ bool DoAdd(CommandLine &) // DoIdent - Ident a CDROM /*{{{*/ // --------------------------------------------------------------------- /* */ -bool DoIdent(CommandLine &) +static bool DoIdent(CommandLine &) { pkgUdevCdromDevices UdevCdroms; string ident; @@ -247,7 +247,7 @@ bool DoIdent(CommandLine &) // ShowHelp - Show the help screen /*{{{*/ // --------------------------------------------------------------------- /* */ -bool ShowHelp(CommandLine &) +static bool ShowHelp(CommandLine &) { ioprintf(cout,_("%s %s for %s compiled on %s %s\n"),PACKAGE,PACKAGE_VERSION, COMMON_ARCH,__DATE__,__TIME__); diff --git a/cmdline/apt-config.cc b/cmdline/apt-config.cc index 9f20b3c1b..e83c4b64b 100644 --- a/cmdline/apt-config.cc +++ b/cmdline/apt-config.cc @@ -40,7 +40,7 @@ using namespace std; // DoShell - Handle the shell command /*{{{*/ // --------------------------------------------------------------------- /* */ -bool DoShell(CommandLine &CmdL) +static bool DoShell(CommandLine &CmdL) { for (const char **I = CmdL.FileList + 1; *I != 0; I += 2) { @@ -63,7 +63,7 @@ bool DoShell(CommandLine &CmdL) // DoDump - Dump the configuration space /*{{{*/ // --------------------------------------------------------------------- /* */ -bool DoDump(CommandLine &CmdL) +static bool DoDump(CommandLine &CmdL) { bool const empty = _config->FindB("APT::Config::Dump::EmptyValue", true); std::string const format = _config->Find("APT::Config::Dump::Format", "%f \"%v\";\n"); @@ -78,7 +78,7 @@ bool DoDump(CommandLine &CmdL) // ShowHelp - Show the help screen /*{{{*/ // --------------------------------------------------------------------- /* */ -bool ShowHelp(CommandLine &CmdL) +static bool ShowHelp(CommandLine &CmdL) { ioprintf(cout,_("%s %s for %s compiled on %s %s\n"),PACKAGE,PACKAGE_VERSION, COMMON_ARCH,__DATE__,__TIME__); diff --git a/cmdline/apt-dump-solver.cc b/cmdline/apt-dump-solver.cc index aa16b1271..c26cdc70a 100644 --- a/cmdline/apt-dump-solver.cc +++ b/cmdline/apt-dump-solver.cc @@ -18,7 +18,7 @@ // ShowHelp - Show a help screen /*{{{*/ // --------------------------------------------------------------------- /* */ -bool ShowHelp() { +static bool ShowHelp() { std::cout << PACKAGE " " PACKAGE_VERSION " for " COMMON_ARCH " compiled on " __DATE__ " " __TIME__ << std::endl << diff --git a/cmdline/apt-extracttemplates.cc b/cmdline/apt-extracttemplates.cc index 2408a7d9d..2b01968e3 100644 --- a/cmdline/apt-extracttemplates.cc +++ b/cmdline/apt-extracttemplates.cc @@ -212,7 +212,7 @@ bool DebFile::ParseInfo() // ShowHelp - show a short help text /*{{{*/ // --------------------------------------------------------------------- /* */ -int ShowHelp(void) +static int ShowHelp(void) { ioprintf(cout,_("%s %s for %s compiled on %s %s\n"),PACKAGE,PACKAGE_VERSION, COMMON_ARCH,__DATE__,__TIME__); @@ -237,7 +237,7 @@ int ShowHelp(void) // WriteFile - write the contents of the passed string to a file /*{{{*/ // --------------------------------------------------------------------- /* */ -string WriteFile(const char *package, const char *prefix, const char *data) +static string WriteFile(const char *package, const char *prefix, const char *data) { char fn[512]; static int i; @@ -265,7 +265,7 @@ string WriteFile(const char *package, const char *prefix, const char *data) // WriteConfig - write out the config data from a debian package file /*{{{*/ // --------------------------------------------------------------------- /* */ -void WriteConfig(const DebFile &file) +static void WriteConfig(const DebFile &file) { string templatefile = WriteFile(file.Package.c_str(), "template", file.Template); string configscript = WriteFile(file.Package.c_str(), "config", file.Config); @@ -279,7 +279,7 @@ void WriteConfig(const DebFile &file) // InitCache - initialize the package cache /*{{{*/ // --------------------------------------------------------------------- /* */ -bool Go(CommandLine &CmdL) +static bool Go(CommandLine &CmdL) { // Initialize the apt cache MMap *Map = 0; diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index f8de80a91..253b2f4a5 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -97,7 +97,7 @@ using namespace std; // --------------------------------------------------------------------- /* This used to be inlined in DoInstall, but with the advent of regex package name matching it was split out.. */ -bool TryToInstallBuildDep(pkgCache::PkgIterator Pkg,pkgCacheFile &Cache, +static bool TryToInstallBuildDep(pkgCache::PkgIterator Pkg,pkgCacheFile &Cache, pkgProblemResolver &Fix,bool Remove,bool BrokenFix, bool AllowFail = true) { @@ -138,7 +138,7 @@ bool TryToInstallBuildDep(pkgCache::PkgIterator Pkg,pkgCacheFile &Cache, // helper that can go wit hthe next ABI break #if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR < 13) -std::string MetaIndexFileNameOnDisk(metaIndex *metaindex) +static std::string MetaIndexFileNameOnDisk(metaIndex *metaindex) { // FIXME: this cast is the horror, the horror debReleaseIndex *r = (debReleaseIndex*)metaindex; @@ -159,7 +159,7 @@ std::string MetaIndexFileNameOnDisk(metaIndex *metaindex) // GetReleaseForSourceRecord - Return Suite for the given srcrecord /*{{{*/ // --------------------------------------------------------------------- /* */ -std::string GetReleaseForSourceRecord(pkgSourceList *SrcList, +static std::string GetReleaseForSourceRecord(pkgSourceList *SrcList, pkgSrcRecords::Parser *Parse) { // try to find release @@ -194,7 +194,7 @@ std::string GetReleaseForSourceRecord(pkgSourceList *SrcList, // FindSrc - Find a source record /*{{{*/ // --------------------------------------------------------------------- /* */ -pkgSrcRecords::Parser *FindSrc(const char *Name,pkgRecords &Recs, +static pkgSrcRecords::Parser *FindSrc(const char *Name,pkgRecords &Recs, pkgSrcRecords &SrcRecs,string &Src, CacheFile &CacheFile) { @@ -430,7 +430,7 @@ pkgSrcRecords::Parser *FindSrc(const char *Name,pkgRecords &Recs, } /*}}}*/ /* mark packages as automatically/manually installed. {{{*/ -bool DoMarkAuto(CommandLine &CmdL) +static bool DoMarkAuto(CommandLine &CmdL) { bool Action = true; int AutoMarkChanged = 0; @@ -475,7 +475,7 @@ bool DoMarkAuto(CommandLine &CmdL) // DoDSelectUpgrade - Do an upgrade by following dselects selections /*{{{*/ // --------------------------------------------------------------------- /* Follows dselect's selections */ -bool DoDSelectUpgrade(CommandLine &CmdL) +static bool DoDSelectUpgrade(CommandLine &CmdL) { CacheFile Cache; if (Cache.OpenForInstall() == false || Cache.CheckDeps() == false) @@ -551,7 +551,7 @@ bool DoDSelectUpgrade(CommandLine &CmdL) // DoClean - Remove download archives /*{{{*/ // --------------------------------------------------------------------- /* */ -bool DoClean(CommandLine &CmdL) +static bool DoClean(CommandLine &CmdL) { std::string const archivedir = _config->FindDir("Dir::Cache::archives"); std::string const pkgcache = _config->FindFile("Dir::cache::pkgcache"); @@ -599,7 +599,7 @@ class LogCleaner : public pkgArchiveCleaner }; }; -bool DoAutoClean(CommandLine &CmdL) +static bool DoAutoClean(CommandLine &CmdL) { // Lock the archive directory FileFd Lock; @@ -623,7 +623,7 @@ bool DoAutoClean(CommandLine &CmdL) /*}}}*/ // DoDownload - download a binary /*{{{*/ // --------------------------------------------------------------------- -bool DoDownload(CommandLine &CmdL) +static bool DoDownload(CommandLine &CmdL) { CacheFile Cache; if (Cache.ReadOnlyOpen() == false) @@ -696,7 +696,7 @@ bool DoDownload(CommandLine &CmdL) // --------------------------------------------------------------------- /* Opening automatically checks the system, this command is mostly used for debugging */ -bool DoCheck(CommandLine &CmdL) +static bool DoCheck(CommandLine &CmdL) { CacheFile Cache; Cache.Open(); @@ -715,7 +715,7 @@ struct DscFile string Dsc; }; -bool DoSource(CommandLine &CmdL) +static bool DoSource(CommandLine &CmdL) { CacheFile Cache; if (Cache.Open(false) == false) @@ -1016,7 +1016,7 @@ bool DoSource(CommandLine &CmdL) // --------------------------------------------------------------------- /* This function will look at the build depends list of the given source package and install the necessary packages to make it true, or fail. */ -bool DoBuildDep(CommandLine &CmdL) +static bool DoBuildDep(CommandLine &CmdL) { CacheFile Cache; @@ -1410,7 +1410,7 @@ bool DoBuildDep(CommandLine &CmdL) * pool/ next to the deb itself) * Example return: "pool/main/a/apt/apt_0.8.8ubuntu3" */ -string GetChangelogPath(CacheFile &Cache, +static string GetChangelogPath(CacheFile &Cache, pkgCache::PkgIterator Pkg, pkgCache::VerIterator Ver) { @@ -1437,7 +1437,7 @@ string GetChangelogPath(CacheFile &Cache, * apt-get changelog mplayer-doc: * http://packages.medibuntu.org/pool/non-free/m/mplayer/mplayer_1.0~rc4~try1.dsfg1-1ubuntu1+medibuntu1.changelog */ -bool GuessThirdPartyChangelogUri(CacheFile &Cache, +static bool GuessThirdPartyChangelogUri(CacheFile &Cache, pkgCache::PkgIterator Pkg, pkgCache::VerIterator Ver, string &out_uri) @@ -1462,7 +1462,7 @@ bool GuessThirdPartyChangelogUri(CacheFile &Cache, /*}}}*/ // DownloadChangelog - Download the changelog /*{{{*/ // --------------------------------------------------------------------- -bool DownloadChangelog(CacheFile &CacheFile, pkgAcquire &Fetcher, +static bool DownloadChangelog(CacheFile &CacheFile, pkgAcquire &Fetcher, pkgCache::VerIterator Ver, string targetfile) /* Download a changelog file for the given package version to * targetfile. This will first try the server from Apt::Changelogs::Server @@ -1517,7 +1517,7 @@ bool DownloadChangelog(CacheFile &CacheFile, pkgAcquire &Fetcher, /*}}}*/ // DoChangelog - Get changelog from the command line /*{{{*/ // --------------------------------------------------------------------- -bool DoChangelog(CommandLine &CmdL) +static bool DoChangelog(CommandLine &CmdL) { CacheFile Cache; if (Cache.ReadOnlyOpen() == false) @@ -1581,7 +1581,7 @@ bool DoChangelog(CommandLine &CmdL) // ShowHelp - Show a help screen /*{{{*/ // --------------------------------------------------------------------- /* */ -bool ShowHelp(CommandLine &CmdL) +static bool ShowHelp(CommandLine &CmdL) { ioprintf(cout,_("%s %s for %s compiled on %s %s\n"),PACKAGE,PACKAGE_VERSION, COMMON_ARCH,__DATE__,__TIME__); @@ -1677,7 +1677,7 @@ bool ShowHelp(CommandLine &CmdL) // SigWinch - Window size change signal handler /*{{{*/ // --------------------------------------------------------------------- /* */ -void SigWinch(int) +static void SigWinch(int) { // Riped from GNU ls #ifdef TIOCGWINSZ diff --git a/cmdline/apt-helper.cc b/cmdline/apt-helper.cc index c1c8b2178..d8ea0435a 100644 --- a/cmdline/apt-helper.cc +++ b/cmdline/apt-helper.cc @@ -33,7 +33,7 @@ /*}}}*/ using namespace std; -bool DoDownloadFile(CommandLine &CmdL) +static bool DoDownloadFile(CommandLine &CmdL) { if (CmdL.FileSize() <= 2) return _error->Error(_("Must specify at least one pair url/filename")); @@ -55,7 +55,7 @@ bool DoDownloadFile(CommandLine &CmdL) return true; } -bool ShowHelp(CommandLine &CmdL) +static bool ShowHelp(CommandLine &CmdL) { ioprintf(cout,_("%s %s for %s compiled on %s %s\n"),PACKAGE,PACKAGE_VERSION, COMMON_ARCH,__DATE__,__TIME__); diff --git a/cmdline/apt-internal-solver.cc b/cmdline/apt-internal-solver.cc index bf5b8c1fe..108e86b9a 100644 --- a/cmdline/apt-internal-solver.cc +++ b/cmdline/apt-internal-solver.cc @@ -30,7 +30,7 @@ // ShowHelp - Show a help screen /*{{{*/ // --------------------------------------------------------------------- /* */ -bool ShowHelp(CommandLine &CmdL) { +static bool ShowHelp(CommandLine &CmdL) { ioprintf(std::cout,_("%s %s for %s compiled on %s %s\n"),PACKAGE,PACKAGE_VERSION, COMMON_ARCH,__DATE__,__TIME__); diff --git a/cmdline/apt-mark.cc b/cmdline/apt-mark.cc index d3a3a780b..1af17cd7a 100644 --- a/cmdline/apt-mark.cc +++ b/cmdline/apt-mark.cc @@ -35,7 +35,7 @@ ostream c1out(0); ostream c2out(0); ofstream devnull("/dev/null"); /* DoAuto - mark packages as automatically/manually installed {{{*/ -bool DoAuto(CommandLine &CmdL) +static bool DoAuto(CommandLine &CmdL) { pkgCacheFile CacheFile; pkgCache *Cache = CacheFile.GetPkgCache(); @@ -82,7 +82,7 @@ bool DoAuto(CommandLine &CmdL) /* DoMarkAuto - mark packages as automatically/manually installed {{{*/ /* Does the same as DoAuto but tries to do it exactly the same why as the python implementation did it so it can be a drop-in replacement */ -bool DoMarkAuto(CommandLine &CmdL) +static bool DoMarkAuto(CommandLine &CmdL) { pkgCacheFile CacheFile; pkgCache *Cache = CacheFile.GetPkgCache(); @@ -119,7 +119,7 @@ bool DoMarkAuto(CommandLine &CmdL) } /*}}}*/ /* ShowAuto - show automatically installed packages (sorted) {{{*/ -bool ShowAuto(CommandLine &CmdL) +static bool ShowAuto(CommandLine &CmdL) { pkgCacheFile CacheFile; pkgCache *Cache = CacheFile.GetPkgCache(); @@ -159,7 +159,7 @@ bool ShowAuto(CommandLine &CmdL) } /*}}}*/ /* DoHold - mark packages as hold by dpkg {{{*/ -bool DoHold(CommandLine &CmdL) +static bool DoHold(CommandLine &CmdL) { pkgCacheFile CacheFile; pkgCache *Cache = CacheFile.GetPkgCache(); @@ -335,7 +335,7 @@ bool DoHold(CommandLine &CmdL) } /*}}}*/ /* ShowHold - show packages set on hold in dpkg status {{{*/ -bool ShowHold(CommandLine &CmdL) +static bool ShowHold(CommandLine &CmdL) { pkgCacheFile CacheFile; pkgCache *Cache = CacheFile.GetPkgCache(); @@ -372,7 +372,7 @@ bool ShowHold(CommandLine &CmdL) // ShowHelp - Show a help screen /*{{{*/ // --------------------------------------------------------------------- /* */ -bool ShowHelp(CommandLine &CmdL) +static bool ShowHelp(CommandLine &CmdL) { ioprintf(cout,_("%s %s for %s compiled on %s %s\n"),PACKAGE,PACKAGE_VERSION, COMMON_ARCH,__DATE__,__TIME__); diff --git a/cmdline/apt-sortpkgs.cc b/cmdline/apt-sortpkgs.cc index 46989044e..8d9cb23de 100644 --- a/cmdline/apt-sortpkgs.cc +++ b/cmdline/apt-sortpkgs.cc @@ -62,7 +62,7 @@ struct PkgName /*{{{*/ // DoIt - Sort a single file /*{{{*/ // --------------------------------------------------------------------- /* */ -bool DoIt(string InFile) +static bool DoIt(string InFile) { FileFd Fd(InFile,FileFd::ReadOnly); pkgTagFile Tags(&Fd); @@ -142,7 +142,7 @@ bool DoIt(string InFile) // ShowHelp - Show the help text /*{{{*/ // --------------------------------------------------------------------- /* */ -int ShowHelp() +static int ShowHelp() { ioprintf(cout,_("%s %s for %s compiled on %s %s\n"),PACKAGE,PACKAGE_VERSION, COMMON_ARCH,__DATE__,__TIME__); diff --git a/cmdline/apt.cc b/cmdline/apt.cc index 7ef9060aa..040ed6c25 100644 --- a/cmdline/apt.cc +++ b/cmdline/apt.cc @@ -61,7 +61,7 @@ -bool ShowHelp(CommandLine &CmdL) +static bool ShowHelp(CommandLine &CmdL) { ioprintf(c1out,_("%s %s for %s compiled on %s %s\n"),PACKAGE,PACKAGE_VERSION, COMMON_ARCH,__DATE__,__TIME__); -- cgit v1.2.3 From 655122418d714f342b5d9789f45f8035f3fe8b9a Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sat, 1 Mar 2014 15:11:42 +0100 Subject: =?UTF-8?q?warning:=20unused=20parameter=20=E2=80=98foo=E2=80=99?= =?UTF-8?q?=20[-Wunused-parameter]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reported-By: gcc -Wunused-parameter Git-Dch: Ignore --- cmdline/apt-cache.cc | 12 ++++++------ cmdline/apt-cdrom.cc | 2 +- cmdline/apt-config.cc | 2 +- cmdline/apt-extracttemplates.cc | 2 +- cmdline/apt-get.cc | 10 +++++----- cmdline/apt-helper.cc | 2 +- cmdline/apt-internal-solver.cc | 2 +- cmdline/apt-mark.cc | 2 +- cmdline/apt.cc | 2 +- 9 files changed, 18 insertions(+), 18 deletions(-) (limited to 'cmdline') diff --git a/cmdline/apt-cache.cc b/cmdline/apt-cache.cc index 7e569f2fc..d50e0c724 100644 --- a/cmdline/apt-cache.cc +++ b/cmdline/apt-cache.cc @@ -258,7 +258,7 @@ static bool DumpPackage(CommandLine &CmdL) // Stats - Dump some nice statistics /*{{{*/ // --------------------------------------------------------------------- /* */ -static bool Stats(CommandLine &Cmd) +static bool Stats(CommandLine &) { pkgCacheFile CacheFile; pkgCache *Cache = CacheFile.GetPkgCache(); @@ -371,7 +371,7 @@ static bool Stats(CommandLine &Cmd) // Dump - show everything /*{{{*/ // --------------------------------------------------------------------- /* This is worthless except fer debugging things */ -static bool Dump(CommandLine &Cmd) +static bool Dump(CommandLine &) { pkgCacheFile CacheFile; pkgCache *Cache = CacheFile.GetPkgCache(); @@ -423,7 +423,7 @@ static bool Dump(CommandLine &Cmd) // --------------------------------------------------------------------- /* This is needed to make dpkg --merge happy.. I spent a bit of time to make this run really fast, perhaps I went a little overboard.. */ -static bool DumpAvail(CommandLine &Cmd) +static bool DumpAvail(CommandLine &) { pkgCacheFile CacheFile; pkgCache *Cache = CacheFile.GetPkgCache(); @@ -1388,7 +1388,7 @@ static bool Search(CommandLine &CmdL) } /*}}}*/ /* ShowAuto - show automatically installed packages (sorted) {{{*/ -static bool ShowAuto(CommandLine &CmdL) +static bool ShowAuto(CommandLine &) { pkgCacheFile CacheFile; pkgCache *Cache = CacheFile.GetPkgCache(); @@ -1717,7 +1717,7 @@ static bool Madison(CommandLine &CmdL) // GenCaches - Call the main cache generator /*{{{*/ // --------------------------------------------------------------------- /* */ -static bool GenCaches(CommandLine &Cmd) +static bool GenCaches(CommandLine &) { OpTextProgress Progress(*_config); @@ -1728,7 +1728,7 @@ static bool GenCaches(CommandLine &Cmd) // ShowHelp - Show a help screen /*{{{*/ // --------------------------------------------------------------------- /* */ -static bool ShowHelp(CommandLine &Cmd) +static bool ShowHelp(CommandLine &) { ioprintf(cout,_("%s %s for %s compiled on %s %s\n"),PACKAGE,PACKAGE_VERSION, COMMON_ARCH,__DATE__,__TIME__); diff --git a/cmdline/apt-cdrom.cc b/cmdline/apt-cdrom.cc index dc0e050c3..8e1d27e52 100644 --- a/cmdline/apt-cdrom.cc +++ b/cmdline/apt-cdrom.cc @@ -93,7 +93,7 @@ bool pkgCdromTextStatus::AskCdromName(string &name) } -void pkgCdromTextStatus::Update(string text, int current) +void pkgCdromTextStatus::Update(string text, int /*current*/) { if(text.size() > 0) cout << text << flush; diff --git a/cmdline/apt-config.cc b/cmdline/apt-config.cc index e83c4b64b..26f0ea161 100644 --- a/cmdline/apt-config.cc +++ b/cmdline/apt-config.cc @@ -78,7 +78,7 @@ static bool DoDump(CommandLine &CmdL) // ShowHelp - Show the help screen /*{{{*/ // --------------------------------------------------------------------- /* */ -static bool ShowHelp(CommandLine &CmdL) +static bool ShowHelp(CommandLine &) { ioprintf(cout,_("%s %s for %s compiled on %s %s\n"),PACKAGE,PACKAGE_VERSION, COMMON_ARCH,__DATE__,__TIME__); diff --git a/cmdline/apt-extracttemplates.cc b/cmdline/apt-extracttemplates.cc index 2b01968e3..a27008233 100644 --- a/cmdline/apt-extracttemplates.cc +++ b/cmdline/apt-extracttemplates.cc @@ -137,7 +137,7 @@ bool DebFile::DoItem(Item &I, int &Fd) // DebFile::Process examine element in package and copy /*{{{*/ // --------------------------------------------------------------------- /* */ -bool DebFile::Process(Item &I, const unsigned char *data, +bool DebFile::Process(Item &/*I*/, const unsigned char *data, unsigned long size, unsigned long pos) { switch (Which) diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 253b2f4a5..9a4eb0881 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -475,7 +475,7 @@ static bool DoMarkAuto(CommandLine &CmdL) // DoDSelectUpgrade - Do an upgrade by following dselects selections /*{{{*/ // --------------------------------------------------------------------- /* Follows dselect's selections */ -static bool DoDSelectUpgrade(CommandLine &CmdL) +static bool DoDSelectUpgrade(CommandLine &) { CacheFile Cache; if (Cache.OpenForInstall() == false || Cache.CheckDeps() == false) @@ -551,7 +551,7 @@ static bool DoDSelectUpgrade(CommandLine &CmdL) // DoClean - Remove download archives /*{{{*/ // --------------------------------------------------------------------- /* */ -static bool DoClean(CommandLine &CmdL) +static bool DoClean(CommandLine &) { std::string const archivedir = _config->FindDir("Dir::Cache::archives"); std::string const pkgcache = _config->FindFile("Dir::cache::pkgcache"); @@ -599,7 +599,7 @@ class LogCleaner : public pkgArchiveCleaner }; }; -static bool DoAutoClean(CommandLine &CmdL) +static bool DoAutoClean(CommandLine &) { // Lock the archive directory FileFd Lock; @@ -696,7 +696,7 @@ static bool DoDownload(CommandLine &CmdL) // --------------------------------------------------------------------- /* Opening automatically checks the system, this command is mostly used for debugging */ -static bool DoCheck(CommandLine &CmdL) +static bool DoCheck(CommandLine &) { CacheFile Cache; Cache.Open(); @@ -1581,7 +1581,7 @@ static bool DoChangelog(CommandLine &CmdL) // ShowHelp - Show a help screen /*{{{*/ // --------------------------------------------------------------------- /* */ -static bool ShowHelp(CommandLine &CmdL) +static bool ShowHelp(CommandLine &) { ioprintf(cout,_("%s %s for %s compiled on %s %s\n"),PACKAGE,PACKAGE_VERSION, COMMON_ARCH,__DATE__,__TIME__); diff --git a/cmdline/apt-helper.cc b/cmdline/apt-helper.cc index d8ea0435a..8ff2fa037 100644 --- a/cmdline/apt-helper.cc +++ b/cmdline/apt-helper.cc @@ -55,7 +55,7 @@ static bool DoDownloadFile(CommandLine &CmdL) return true; } -static bool ShowHelp(CommandLine &CmdL) +static bool ShowHelp(CommandLine &) { ioprintf(cout,_("%s %s for %s compiled on %s %s\n"),PACKAGE,PACKAGE_VERSION, COMMON_ARCH,__DATE__,__TIME__); diff --git a/cmdline/apt-internal-solver.cc b/cmdline/apt-internal-solver.cc index 108e86b9a..0c2ff0f43 100644 --- a/cmdline/apt-internal-solver.cc +++ b/cmdline/apt-internal-solver.cc @@ -30,7 +30,7 @@ // ShowHelp - Show a help screen /*{{{*/ // --------------------------------------------------------------------- /* */ -static bool ShowHelp(CommandLine &CmdL) { +static bool ShowHelp(CommandLine &) { ioprintf(std::cout,_("%s %s for %s compiled on %s %s\n"),PACKAGE,PACKAGE_VERSION, COMMON_ARCH,__DATE__,__TIME__); diff --git a/cmdline/apt-mark.cc b/cmdline/apt-mark.cc index 1af17cd7a..53b5ec158 100644 --- a/cmdline/apt-mark.cc +++ b/cmdline/apt-mark.cc @@ -372,7 +372,7 @@ static bool ShowHold(CommandLine &CmdL) // ShowHelp - Show a help screen /*{{{*/ // --------------------------------------------------------------------- /* */ -static bool ShowHelp(CommandLine &CmdL) +static bool ShowHelp(CommandLine &) { ioprintf(cout,_("%s %s for %s compiled on %s %s\n"),PACKAGE,PACKAGE_VERSION, COMMON_ARCH,__DATE__,__TIME__); diff --git a/cmdline/apt.cc b/cmdline/apt.cc index 040ed6c25..1b7626948 100644 --- a/cmdline/apt.cc +++ b/cmdline/apt.cc @@ -61,7 +61,7 @@ -static bool ShowHelp(CommandLine &CmdL) +static bool ShowHelp(CommandLine &) { ioprintf(c1out,_("%s %s for %s compiled on %s %s\n"),PACKAGE,PACKAGE_VERSION, COMMON_ARCH,__DATE__,__TIME__); -- cgit v1.2.3 From 453b82a388013e522b3a1b9fcd6ed0810dab1f4f Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Wed, 5 Mar 2014 22:11:25 +0100 Subject: cleanup headers and especially #includes everywhere Beside being a bit cleaner it hopefully also resolves oddball problems I have with high levels of parallel jobs. Git-Dch: Ignore Reported-By: iwyu (include-what-you-use) --- cmdline/acqprogress.cc | 2 + cmdline/apt-cache.cc | 51 ++++++++++++++----------- cmdline/apt-cdrom.cc | 9 +---- cmdline/apt-config.cc | 2 +- cmdline/apt-dump-solver.cc | 6 ++- cmdline/apt-extracttemplates.cc | 9 ++--- cmdline/apt-extracttemplates.h | 3 +- cmdline/apt-get.cc | 83 +++++++++++++++++++++-------------------- cmdline/apt-helper.cc | 12 ++---- cmdline/apt-internal-solver.cc | 10 ++++- cmdline/apt-mark.cc | 29 +++++++++----- cmdline/apt-sortpkgs.cc | 6 +-- cmdline/apt.cc | 40 ++++---------------- 13 files changed, 130 insertions(+), 132 deletions(-) (limited to 'cmdline') diff --git a/cmdline/acqprogress.cc b/cmdline/acqprogress.cc index 3ac350aca..c362c1edf 100644 --- a/cmdline/acqprogress.cc +++ b/cmdline/acqprogress.cc @@ -10,12 +10,14 @@ // Include files /*{{{*/ #include +#include #include #include #include #include #include +#include #include #include #include diff --git a/cmdline/apt-cache.cc b/cmdline/apt-cache.cc index d50e0c724..0860ee7bf 100644 --- a/cmdline/apt-cache.cc +++ b/cmdline/apt-cache.cc @@ -15,40 +15,49 @@ // Include Files /*{{{*/ #include -#include +#include #include #include -#include -#include -#include #include -#include +#include #include +#include +#include +#include #include -#include -#include +#include #include -#include -#include +#include +#include #include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include -#include -#include -#include #include +#include -#include -#include -#include -#include -#include #include +#include #include -#include +#include +#include #include +#include +#include +#include +#include +#include +#include +#include +#include #include /*}}}*/ diff --git a/cmdline/apt-cdrom.cc b/cmdline/apt-cdrom.cc index 8e1d27e52..facb6002b 100644 --- a/cmdline/apt-cdrom.cc +++ b/cmdline/apt-cdrom.cc @@ -20,22 +20,15 @@ #include #include #include -#include -#include #include #include #include -#include #include -#include #include -#include +#include #include -#include -#include #include -#include #include diff --git a/cmdline/apt-config.cc b/cmdline/apt-config.cc index 26f0ea161..d95780c73 100644 --- a/cmdline/apt-config.cc +++ b/cmdline/apt-config.cc @@ -26,10 +26,10 @@ #include #include -#include #include #include #include +#include #include diff --git a/cmdline/apt-dump-solver.cc b/cmdline/apt-dump-solver.cc index c26cdc70a..04e13bde9 100644 --- a/cmdline/apt-dump-solver.cc +++ b/cmdline/apt-dump-solver.cc @@ -9,10 +9,12 @@ // Include Files /*{{{*/ #include -#include - +#include +#include #include #include + +#include /*}}}*/ // ShowHelp - Show a help screen /*{{{*/ diff --git a/cmdline/apt-extracttemplates.cc b/cmdline/apt-extracttemplates.cc index a27008233..a82623444 100644 --- a/cmdline/apt-extracttemplates.cc +++ b/cmdline/apt-extracttemplates.cc @@ -18,8 +18,8 @@ #include #include #include +#include #include -#include #include #include #include @@ -30,14 +30,13 @@ #include #include #include +#include +#include +#include #include #include -#include #include -#include - -#include #include "apt-extracttemplates.h" diff --git a/cmdline/apt-extracttemplates.h b/cmdline/apt-extracttemplates.h index 6d07a09c2..9cc3f5f25 100644 --- a/cmdline/apt-extracttemplates.h +++ b/cmdline/apt-extracttemplates.h @@ -11,11 +11,12 @@ #define _APTEXTRACTTEMPLATE_H_ #include -#include #include #include +class pkgCache; + class DebFile : public pkgDirStream { FileFd File; diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 9a4eb0881..a830c2387 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -27,66 +27,67 @@ // Include Files /*{{{*/ #include +#include +#include #include -#include +#include +#include +#include #include -#include +#include #include -#include -#include -#include -#include +#include #include -#include -#include -#include -#include -#include -#include +#include +#include +#include #include -#include -#include -#include +#include #include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include -#include -#include +#include +#include +#include +#include #include #include -#include +#include +#include #include -#include #include -#include -#include +#include #include -#include - -#include - -#include -#include -#include - -#include -#include -#include +#include +#include +#include +#include +#include +#include #include #include #include #include -#include -#include -#include -#include -#include #include - -#include -#include +#include +#include +#include +#include +#include +#include +#include #include /*}}}*/ diff --git a/cmdline/apt-helper.cc b/cmdline/apt-helper.cc index 8ff2fa037..d66b3ffae 100644 --- a/cmdline/apt-helper.cc +++ b/cmdline/apt-helper.cc @@ -7,6 +7,7 @@ // Include Files /*{{{*/ #include +#include #include #include #include @@ -20,14 +21,9 @@ #include #include -#include -#include -#include -#include -#include -#include - - +#include +#include +#include #include /*}}}*/ diff --git a/cmdline/apt-internal-solver.cc b/cmdline/apt-internal-solver.cc index 0c2ff0f43..b85c07c33 100644 --- a/cmdline/apt-internal-solver.cc +++ b/cmdline/apt-internal-solver.cc @@ -20,7 +20,15 @@ #include #include #include - +#include +#include +#include +#include + +#include +#include +#include +#include #include #include diff --git a/cmdline/apt-mark.cc b/cmdline/apt-mark.cc index 53b5ec158..ed348358a 100644 --- a/cmdline/apt-mark.cc +++ b/cmdline/apt-mark.cc @@ -11,20 +11,31 @@ #include #include #include +#include #include -#include #include -#include +#include +#include +#include +#include +#include +#include + +#include -#include #include -#include -#include -#include -#include #include - -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include /*}}}*/ diff --git a/cmdline/apt-sortpkgs.cc b/cmdline/apt-sortpkgs.cc index 8d9cb23de..c2b11890a 100644 --- a/cmdline/apt-sortpkgs.cc +++ b/cmdline/apt-sortpkgs.cc @@ -25,9 +25,9 @@ #include #include - -#include -#include +#include +#include +#include #include /*}}}*/ diff --git a/cmdline/apt.cc b/cmdline/apt.cc index 1b7626948..5dbf868d7 100644 --- a/cmdline/apt.cc +++ b/cmdline/apt.cc @@ -11,39 +11,12 @@ // Include Files /*{{{*/ #include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - +#include #include -#include -#include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include #include -#include -#include -#include - -#include +#include +#include #include #include @@ -55,11 +28,14 @@ #include #include #include -#include #include - /*}}}*/ +#include +#include +#include +#include + /*}}}*/ static bool ShowHelp(CommandLine &) { -- cgit v1.2.3 From a02db58fd50ef7fc2f0284852c6b3f98e458a232 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 6 Mar 2014 00:33:10 +0100 Subject: follow method attribute suggestions by gcc Git-Dch: Ignore Reported-By: gcc -Wsuggest-attribute={pure,const,noreturn} --- cmdline/apt-cache.cc | 2 +- cmdline/apt-cdrom.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'cmdline') diff --git a/cmdline/apt-cache.cc b/cmdline/apt-cache.cc index 0860ee7bf..84b775390 100644 --- a/cmdline/apt-cache.cc +++ b/cmdline/apt-cache.cc @@ -1118,7 +1118,7 @@ static bool Dotty(CommandLine &CmdL) /* This displays the package record from the proper package index file. It is not used by DumpAvail for performance reasons. */ -static unsigned char const* skipDescriptionFields(unsigned char const * DescP) +static APT_PURE unsigned char const* skipDescriptionFields(unsigned char const * DescP) { char const * const TagName = "\nDescription"; size_t const TagLen = strlen(TagName); diff --git a/cmdline/apt-cdrom.cc b/cmdline/apt-cdrom.cc index facb6002b..b7447463d 100644 --- a/cmdline/apt-cdrom.cc +++ b/cmdline/apt-cdrom.cc @@ -98,7 +98,7 @@ bool pkgCdromTextStatus::ChangeCdrom() return true; } -OpProgress* pkgCdromTextStatus::GetOpProgress() +APT_CONST OpProgress* pkgCdromTextStatus::GetOpProgress() { return &Progress; } -- cgit v1.2.3 From 500dc0700136092692d1cceba4e5c1639bcfc825 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 6 Mar 2014 01:31:55 +0100 Subject: use SPtrArray handling instead of explicit delete[] The warning message from gcc doesn't make that much sense in my reading as there is no loop which could overflow here, but it is better to use our SPtrArray wrapping anyway which fixes the warning as well. warning: cannot optimize loop, the loop counter may overflow [-Wunsafe-loop-optimizations] delete[] Dsc; Git-Dch: Ignore Reported-By: gcc -Wunsafe-loop-optimizations --- cmdline/apt-get.cc | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) (limited to 'cmdline') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index a830c2387..caf69da2a 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -741,7 +741,7 @@ static bool DoSource(CommandLine &CmdL) pkgAcquire Fetcher; Fetcher.SetLog(&Stat); - DscFile *Dsc = new DscFile[CmdL.FileSize()]; + SPtrArray Dsc = new DscFile[CmdL.FileSize()]; // insert all downloaded uris into this set to avoid downloading them // twice @@ -762,7 +762,6 @@ static bool DoSource(CommandLine &CmdL) pkgSrcRecords::Parser *Last = FindSrc(*I,Recs,SrcRecs,Src,Cache); if (Last == 0) { - delete[] Dsc; return _error->Error(_("Unable to find a source package for %s"),Src.c_str()); } @@ -796,7 +795,6 @@ static bool DoSource(CommandLine &CmdL) // Back track vector Lst; if (Last->Files(Lst) == false) { - delete[] Dsc; return false; } @@ -859,7 +857,6 @@ static bool DoSource(CommandLine &CmdL) struct statvfs Buf; string OutputDir = "."; if (statvfs(OutputDir.c_str(),&Buf) != 0) { - delete[] Dsc; if (errno == EOVERFLOW) return _error->WarningE("statvfs",_("Couldn't determine free space in %s"), OutputDir.c_str()); @@ -874,7 +871,6 @@ static bool DoSource(CommandLine &CmdL) || unsigned(Stat.f_type) != RAMFS_MAGIC #endif ) { - delete[] Dsc; return _error->Error(_("You don't have enough free space in %s"), OutputDir.c_str()); } @@ -896,7 +892,6 @@ static bool DoSource(CommandLine &CmdL) { for (unsigned I = 0; I != J; I++) ioprintf(cout,_("Fetch source %s\n"),Dsc[I].Package.c_str()); - delete[] Dsc; return true; } @@ -907,7 +902,6 @@ static bool DoSource(CommandLine &CmdL) for (; I != Fetcher.UriEnd(); ++I) cout << '\'' << I->URI << "' " << flNotDir(I->Owner->DestFile) << ' ' << I->Owner->FileSize << ' ' << I->Owner->HashSum() << endl; - delete[] Dsc; return true; } @@ -915,14 +909,12 @@ static bool DoSource(CommandLine &CmdL) bool Failed = false; if (AcquireRun(Fetcher, 0, &Failed, NULL) == false || Failed == true) { - delete[] Dsc; return _error->Error(_("Failed to fetch some archives.")); } if (_config->FindB("APT::Get::Download-only",false) == true) { c1out << _("Download complete and in download only mode") << endl; - delete[] Dsc; return true; } @@ -996,7 +988,6 @@ static bool DoSource(CommandLine &CmdL) _exit(0); } - delete[] Dsc; // Wait for the subprocess int Status = 0; -- cgit v1.2.3 From b5ee78aec0b13932bdeb710cbbea148b7041203a Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Mon, 10 Mar 2014 00:33:38 +0100 Subject: remove code duplication for Add & Ident in apt-cdrom The preparation code to deal with auto-detection and co is the same for both methods, so not sharing them would be bad. Deals also with the prevention of side effects triggered by the auto-detection like disabling mounting for the fallback. Git-Dch: Ignore --- cmdline/apt-cdrom.cc | 202 +++++++++++++++++++++------------------------------ 1 file changed, 81 insertions(+), 121 deletions(-) (limited to 'cmdline') diff --git a/cmdline/apt-cdrom.cc b/cmdline/apt-cdrom.cc index b7447463d..53efe65b8 100644 --- a/cmdline/apt-cdrom.cc +++ b/cmdline/apt-cdrom.cc @@ -34,12 +34,6 @@ #include /*}}}*/ -static const char *W_NO_CDROM_FOUND = \ - N_("No CD-ROM could be auto-detected or found using " - "the default mount point.\n" - "You may try the --cdrom option to set the CD-ROM mount point. " - "See 'man apt-cdrom' for more " - "information about the CD-ROM auto-detection and mount point."); using namespace std; @@ -103,143 +97,111 @@ APT_CONST OpProgress* pkgCdromTextStatus::GetOpProgress() return &Progress; } /*}}}*/ -// SetupAutoDetect /*{{{*/ -static bool AutoDetectCdrom(pkgUdevCdromDevices &UdevCdroms, unsigned int &i, bool &automounted) +// AddOrIdent - Add or Ident a CDROM /*{{{*/ +static bool AddOrIdent(bool const Add) { - bool Debug = _config->FindB("Debug::Acquire::cdrom", false); + pkgUdevCdromDevices UdevCdroms; + pkgCdromTextStatus log; + pkgCdrom cdrom; - automounted = false; + bool oneSuccessful = false; + bool AutoDetect = _config->FindB("Acquire::cdrom::AutoDetect", true); + if (AutoDetect == true && UdevCdroms.Dlopen() == true) + { + bool const Debug = _config->FindB("Debug::Acquire::cdrom", false); + std::string const CDMount = _config->Find("Acquire::cdrom::mount"); + bool const NoMount = _config->FindB("APT::CDROM::NoMount", false); + if (NoMount == false) + _config->Set("APT::CDROM::NoMount", true); + + vector const v = UdevCdroms.Scan(); + for (std::vector::const_iterator cd = v.begin(); cd != v.end(); ++cd) + { + if (Debug) + clog << "Looking at device:" + << "\tDeviveName: '" << cd->DeviceName << "'" + << "\tIsMounted: '" << cd->Mounted << "'" + << "\tMountPoint: '" << cd->MountPath << "'" + << endl; + + std::string AptMountPoint; + if (cd->Mounted) + _config->Set("Acquire::cdrom::mount", cd->MountPath); + else if (NoMount == true) + continue; + else + { + AptMountPoint = _config->FindDir("Dir::Media::MountPath"); + if (FileExists(AptMountPoint) == false) + mkdir(AptMountPoint.c_str(), 0750); + if(MountCdrom(AptMountPoint, cd->DeviceName) == false) + { + _error->Warning(_("Failed to mount '%s' to '%s'"), cd->DeviceName.c_str(), AptMountPoint.c_str()); + continue; + } + _config->Set("Acquire::cdrom::mount", AptMountPoint); + } - vector v = UdevCdroms.Scan(); - if (i >= v.size()) - return false; + _error->PushToStack(); + if (Add == true) + oneSuccessful = cdrom.Add(&log); + else + { + std::string id; + oneSuccessful = cdrom.Ident(id, &log); + } + _error->MergeWithStack(); - if (Debug) - clog << "Looking at devce " << i - << " DeviveName: " << v[i].DeviceName - << " IsMounted: '" << v[i].Mounted << "'" - << " MountPoint: '" << v[i].MountPath << "'" - << endl; + if (AptMountPoint.empty() == false) + UnmountCdrom(AptMountPoint); + } + if (NoMount == false) + _config->Set("APT::CDROM::NoMount", NoMount); + _config->Set("Acquire::cdrom::mount", CDMount); + } - if (v[i].Mounted) + // fallback if auto-detect didn't work + if (oneSuccessful == false) { - // set the right options - _config->Set("Acquire::cdrom::mount", v[i].MountPath); - _config->Set("APT::CDROM::NoMount", true); - } else { - string AptMountPoint = _config->FindDir("Dir::Media::MountPath"); - if (!FileExists(AptMountPoint)) - mkdir(AptMountPoint.c_str(), 0750); - if(MountCdrom(AptMountPoint, v[i].DeviceName) == false) - _error->Warning(_("Failed to mount '%s' to '%s'"), v[i].DeviceName.c_str(), AptMountPoint.c_str()); + _error->PushToStack(); + if (Add == true) + oneSuccessful = cdrom.Add(&log); else - automounted = true; - _config->Set("Acquire::cdrom::mount", AptMountPoint); - _config->Set("APT::CDROM::NoMount", true); + { + std::string id; + oneSuccessful = cdrom.Ident(id, &log); + } + _error->MergeWithStack(); } - i++; - return true; + if (oneSuccessful == false) + _error->Error("%s", _("No CD-ROM could be auto-detected or found using the default mount point.\n" + "You may try the --cdrom option to set the CD-ROM mount point.\n" + "See 'man apt-cdrom' for more information about the CD-ROM auto-detection and mount point.")); + else if (Add == true) + cout << _("Repeat this process for the rest of the CDs in your set.") << endl; + + return oneSuccessful; } /*}}}*/ // DoAdd - Add a new CDROM /*{{{*/ // --------------------------------------------------------------------- /* This does the main add bit.. We show some status and things. The - sequence is to mount/umount the CD, Ident it then scan it for package + sequence is to mount/umount the CD, Ident it then scan it for package files and reduce that list. Then we copy over the package files and verify them. Then rewrite the database files */ static bool DoAdd(CommandLine &) { - pkgUdevCdromDevices UdevCdroms; - pkgCdromTextStatus log; - pkgCdrom cdrom; - bool res = true; - - bool AutoDetect = _config->FindB("Acquire::cdrom::AutoDetect", true); - unsigned int count = 0; - string AptMountPoint = _config->FindDir("Dir::Media::MountPath"); - bool automounted = false; - if (AutoDetect && UdevCdroms.Dlopen()) - while (AutoDetectCdrom(UdevCdroms, count, automounted)) { - if (count == 1) { - // begin loop with res false to detect any success using OR - res = false; - } - - // dump any warnings/errors from autodetect - if (_error->empty() == false) - _error->DumpErrors(); - - res |= cdrom.Add(&log); - - if (automounted) - UnmountCdrom(AptMountPoint); - - // dump any warnings/errors from add/unmount - if (_error->empty() == false) - _error->DumpErrors(); - } - - if (count == 0) - res = cdrom.Add(&log); - - if (res == false) - _error->Error("%s", _(W_NO_CDROM_FOUND)); - else - cout << _("Repeat this process for the rest of the CDs in your set.") << endl; - - return res; + return AddOrIdent(true); } /*}}}*/ // DoIdent - Ident a CDROM /*{{{*/ -// --------------------------------------------------------------------- -/* */ static bool DoIdent(CommandLine &) { - pkgUdevCdromDevices UdevCdroms; - string ident; - pkgCdromTextStatus log; - pkgCdrom cdrom; - bool res = true; - - bool AutoDetect = _config->FindB("Acquire::cdrom::AutoDetect", true); - - unsigned int count = 0; - string AptMountPoint = _config->FindDir("Dir::Media::MountPath"); - bool automounted = false; - if (AutoDetect && UdevCdroms.Dlopen()) - while (AutoDetectCdrom(UdevCdroms, count, automounted)) { - if (count == 1) { - // begin loop with res false to detect any success using OR - res = false; - } - - // dump any warnings/errors from autodetect - if (_error->empty() == false) - _error->DumpErrors(); - - res |= cdrom.Ident(ident, &log); - - if (automounted) - UnmountCdrom(AptMountPoint); - - // dump any warnings/errors from add/unmount - if (_error->empty() == false) - _error->DumpErrors(); - } - - if (count == 0) - res = cdrom.Ident(ident, &log); - - if (res == false) - _error->Error("%s", _(W_NO_CDROM_FOUND)); - - return res; + return AddOrIdent(false); } /*}}}*/ // ShowHelp - Show the help screen /*{{{*/ -// --------------------------------------------------------------------- -/* */ static bool ShowHelp(CommandLine &) { ioprintf(cout,_("%s %s for %s compiled on %s %s\n"),PACKAGE,PACKAGE_VERSION, @@ -306,14 +268,12 @@ int main(int argc,const char *argv[]) /*{{{*/ _config->Set("quiet","1"); // Match the operation - CmdL.DispatchArg(Cmds); + bool returned = CmdL.DispatchArg(Cmds); - // Print any errors or warnings found during parsing - bool const Errors = _error->PendingError(); if (_config->FindI("quiet",0) > 0) _error->DumpErrors(); else _error->DumpErrors(GlobalError::DEBUG); - return Errors == true ? 100 : 0; + return returned == true ? 0 : 100; } /*}}}*/ -- cgit v1.2.3 From 0d58c26ad7b2308f08f4e6002cbf218605c1c7cf Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Mon, 10 Mar 2014 14:15:45 +0100 Subject: improve debug output in case downloadfile fails Git-Dch: Ignore --- cmdline/apt-helper.cc | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'cmdline') diff --git a/cmdline/apt-helper.cc b/cmdline/apt-helper.cc index d66b3ffae..37279ec28 100644 --- a/cmdline/apt-helper.cc +++ b/cmdline/apt-helper.cc @@ -19,6 +19,7 @@ #include #include +#include #include #include @@ -27,7 +28,6 @@ #include /*}}}*/ -using namespace std; static bool DoDownloadFile(CommandLine &CmdL) { @@ -43,23 +43,22 @@ static bool DoDownloadFile(CommandLine &CmdL) new pkgAcqFile(&Fetcher, download_uri, "", 0, "desc", "short-desc", "dest-dir-ignored", targetfile); Fetcher.Run(); - if (!FileExists(targetfile)) - { - _error->Error(_("Download Failed")); - return false; - } + bool Failed = false; + if (AcquireRun(Fetcher, 0, &Failed, NULL) == false || Failed == false || + FileExists(targetfile) == false) + return _error->Error(_("Download Failed")); return true; } static bool ShowHelp(CommandLine &) { - ioprintf(cout,_("%s %s for %s compiled on %s %s\n"),PACKAGE,PACKAGE_VERSION, + ioprintf(std::cout,_("%s %s for %s compiled on %s %s\n"),PACKAGE,PACKAGE_VERSION, COMMON_ARCH,__DATE__,__TIME__); if (_config->FindB("version") == true) return true; - cout << + std::cout << _("Usage: apt-helper [options] command\n" " apt-helper [options] download-file uri target-path\n" "\n" -- cgit v1.2.3 From 52922e2a6795aadcbb8dd11bba14db0f05da34c6 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Mon, 10 Mar 2014 15:12:11 +0100 Subject: cmdline parsing: apt-config is not apt-cdrom --- cmdline/apt-config.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cmdline') diff --git a/cmdline/apt-config.cc b/cmdline/apt-config.cc index d95780c73..40ba468eb 100644 --- a/cmdline/apt-config.cc +++ b/cmdline/apt-config.cc @@ -108,7 +108,7 @@ int main(int argc,const char *argv[]) /*{{{*/ {"help",&ShowHelp}, {0,0}}; - std::vector Args = getCommandArgs("apt-cdrom", CommandLine::GetCommand(Cmds, argc, argv)); + std::vector Args = getCommandArgs("apt-config", CommandLine::GetCommand(Cmds, argc, argv)); // Set up gettext support setlocale(LC_ALL,""); -- cgit v1.2.3 From 8d50b63f28f0d68ca72b6dc6e50e09cfec9842be Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 27 Mar 2014 10:14:30 +0100 Subject: Use mkstemp() in apt-extracttemplaes (closes: #741627) Use mkstemp() in apt-extractemplates and add a integrationtest for apt-extracttemplates too. Thanks to Steve Kemp for the report. --- cmdline/apt-extracttemplates.cc | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'cmdline') diff --git a/cmdline/apt-extracttemplates.cc b/cmdline/apt-extracttemplates.cc index a82623444..e4428e051 100644 --- a/cmdline/apt-extracttemplates.cc +++ b/cmdline/apt-extracttemplates.cc @@ -37,6 +37,7 @@ #include #include #include +#include #include "apt-extracttemplates.h" @@ -239,23 +240,25 @@ static int ShowHelp(void) static string WriteFile(const char *package, const char *prefix, const char *data) { char fn[512]; - static int i; std::string tempdir = GetTempDir(); - snprintf(fn, sizeof(fn), "%s/%s.%s.%u%d", + snprintf(fn, sizeof(fn), "%s/%s.%s.XXXXXX", _config->Find("APT::ExtractTemplates::TempDir", tempdir.c_str()).c_str(), - package, prefix, getpid(), i++); + package, prefix); FileFd f; if (data == NULL) data = ""; - - if (!f.Open(fn, FileFd::WriteTemp, 0600)) + int fd = mkstemp(fn); + if (fd < 0) { + _error->Errno("ofstream::ofstream",_("Unable to mkstemp %s"),fn); + return string(); + } + if (!f.OpenDescriptor(fd, FileFd::WriteOnly, FileFd::None, true)) { _error->Errno("ofstream::ofstream",_("Unable to write to %s"),fn); return string(); } - f.Write(data, strlen(data)); f.Close(); return fn; -- cgit v1.2.3 From 8bc31a93c391eaa31864534553348870901d2dd9 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Tue, 1 Apr 2014 12:21:34 +0200 Subject: enable DPkg::Progress-Fancy by default --- cmdline/apt.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cmdline') diff --git a/cmdline/apt.cc b/cmdline/apt.cc index 5dbf868d7..778ca5a80 100644 --- a/cmdline/apt.cc +++ b/cmdline/apt.cc @@ -109,7 +109,7 @@ int main(int argc, const char *argv[]) /*{{{*/ } // some different defaults - _config->CndSet("DPkgPM::Progress", "1"); + _config->CndSet("DPkg::Progress-Fancy", "1"); _config->CndSet("Apt::Color", "1"); _config->CndSet("APT::Get::Upgrade-Allow-New", true); -- cgit v1.2.3 From ec4371acb7bf586b4ed274b47813e5785da6b424 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 4 Apr 2014 12:16:22 +0200 Subject: Fix crash in "apt list" when a sources.list file is unreable Closes: 743413 --- cmdline/apt.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cmdline') diff --git a/cmdline/apt.cc b/cmdline/apt.cc index 778ca5a80..4813861a4 100644 --- a/cmdline/apt.cc +++ b/cmdline/apt.cc @@ -70,7 +70,7 @@ int main(int argc, const char *argv[]) /*{{{*/ { CommandLine::Dispatch Cmds[] = { // query - {"list",&List}, + {"list",&DoList}, {"search", &FullTextSearch}, {"show", &APT::Cmd::ShowPackage}, -- cgit v1.2.3 From 2a4af2a0558783b1889ffc552ff0be36aad03f55 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 24 Apr 2014 10:33:57 +0200 Subject: remove unused duplicated acqprogress.{cc,h} files Those files are in apt-private and used from there. Git-Dch: Ignore --- cmdline/acqprogress.cc | 306 ------------------------------------------------- cmdline/acqprogress.h | 39 ------- 2 files changed, 345 deletions(-) delete mode 100644 cmdline/acqprogress.cc delete mode 100644 cmdline/acqprogress.h (limited to 'cmdline') diff --git a/cmdline/acqprogress.cc b/cmdline/acqprogress.cc deleted file mode 100644 index c362c1edf..000000000 --- a/cmdline/acqprogress.cc +++ /dev/null @@ -1,306 +0,0 @@ -// -*- mode: cpp; mode: fold -*- -// Description /*{{{*/ -// $Id: acqprogress.cc,v 1.24 2003/04/27 01:56:48 doogie Exp $ -/* ###################################################################### - - Acquire Progress - Command line progress meter - - ##################################################################### */ - /*}}}*/ -// Include files /*{{{*/ -#include - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include "acqprogress.h" -#include - /*}}}*/ - -using namespace std; - -// AcqTextStatus::AcqTextStatus - Constructor /*{{{*/ -// --------------------------------------------------------------------- -/* */ -AcqTextStatus::AcqTextStatus(unsigned int &ScreenWidth,unsigned int Quiet) : - ScreenWidth(ScreenWidth), ID(0), Quiet(Quiet) -{ - BlankLine[0] = 0; -} - /*}}}*/ -// AcqTextStatus::Start - Downloading has started /*{{{*/ -// --------------------------------------------------------------------- -/* */ -void AcqTextStatus::Start() -{ - pkgAcquireStatus::Start(); - BlankLine[0] = 0; - ID = 1; -}; - /*}}}*/ -// AcqTextStatus::IMSHit - Called when an item got a HIT response /*{{{*/ -// --------------------------------------------------------------------- -/* */ -void AcqTextStatus::IMSHit(pkgAcquire::ItemDesc &Itm) -{ - if (Quiet > 1) - return; - - if (Quiet <= 0) - cout << '\r' << BlankLine << '\r'; - - cout << _("Hit ") << Itm.Description; - if (Itm.Owner->FileSize != 0) - cout << " [" << SizeToStr(Itm.Owner->FileSize) << "B]"; - cout << endl; - Update = true; -}; - /*}}}*/ -// AcqTextStatus::Fetch - An item has started to download /*{{{*/ -// --------------------------------------------------------------------- -/* This prints out the short description and the expected size */ -void AcqTextStatus::Fetch(pkgAcquire::ItemDesc &Itm) -{ - Update = true; - if (Itm.Owner->Complete == true) - return; - - Itm.Owner->ID = ID++; - - if (Quiet > 1) - return; - - if (Quiet <= 0) - cout << '\r' << BlankLine << '\r'; - - cout << _("Get:") << Itm.Owner->ID << ' ' << Itm.Description; - if (Itm.Owner->FileSize != 0) - cout << " [" << SizeToStr(Itm.Owner->FileSize) << "B]"; - cout << endl; -}; - /*}}}*/ -// AcqTextStatus::Done - Completed a download /*{{{*/ -// --------------------------------------------------------------------- -/* We don't display anything... */ -void AcqTextStatus::Done(pkgAcquire::ItemDesc &Itm) -{ - Update = true; -}; - /*}}}*/ -// AcqTextStatus::Fail - Called when an item fails to download /*{{{*/ -// --------------------------------------------------------------------- -/* We print out the error text */ -void AcqTextStatus::Fail(pkgAcquire::ItemDesc &Itm) -{ - if (Quiet > 1) - return; - - // Ignore certain kinds of transient failures (bad code) - if (Itm.Owner->Status == pkgAcquire::Item::StatIdle) - return; - - if (Quiet <= 0) - cout << '\r' << BlankLine << '\r'; - - if (Itm.Owner->Status == pkgAcquire::Item::StatDone) - { - cout << _("Ign ") << Itm.Description << endl; - } - else - { - cout << _("Err ") << Itm.Description << endl; - cout << " " << Itm.Owner->ErrorText << endl; - } - - Update = true; -}; - /*}}}*/ -// AcqTextStatus::Stop - Finished downloading /*{{{*/ -// --------------------------------------------------------------------- -/* This prints out the bytes downloaded and the overall average line - speed */ -void AcqTextStatus::Stop() -{ - pkgAcquireStatus::Stop(); - if (Quiet > 1) - return; - - if (Quiet <= 0) - cout << '\r' << BlankLine << '\r' << flush; - - if (FetchedBytes != 0 && _error->PendingError() == false) - ioprintf(cout,_("Fetched %sB in %s (%sB/s)\n"), - SizeToStr(FetchedBytes).c_str(), - TimeToStr(ElapsedTime).c_str(), - SizeToStr(CurrentCPS).c_str()); -} - /*}}}*/ -// AcqTextStatus::Pulse - Regular event pulse /*{{{*/ -// --------------------------------------------------------------------- -/* This draws the current progress. Each line has an overall percent - meter and a per active item status meter along with an overall - bandwidth and ETA indicator. */ -bool AcqTextStatus::Pulse(pkgAcquire *Owner) -{ - pkgAcquireStatus::Pulse(Owner); - - if (Quiet > 0) - return true; - - enum {Long = 0,Medium,Short} Mode = Medium; - - char Buffer[sizeof(BlankLine)]; - char *End = Buffer + sizeof(Buffer); - char *S = Buffer; - if (ScreenWidth >= sizeof(Buffer)) - ScreenWidth = sizeof(Buffer)-1; - - // Put in the percent done - sprintf(S,"%.0f%%",((CurrentBytes + CurrentItems)*100.0)/(TotalBytes+TotalItems)); - - bool Shown = false; - for (pkgAcquire::Worker *I = Owner->WorkersBegin(); I != 0; - I = Owner->WorkerStep(I)) - { - S += strlen(S); - - // There is no item running - if (I->CurrentItem == 0) - { - if (I->Status.empty() == false) - { - snprintf(S,End-S," [%s]",I->Status.c_str()); - Shown = true; - } - - continue; - } - - Shown = true; - - // Add in the short description - if (I->CurrentItem->Owner->ID != 0) - snprintf(S,End-S," [%lu %s",I->CurrentItem->Owner->ID, - I->CurrentItem->ShortDesc.c_str()); - else - snprintf(S,End-S," [%s",I->CurrentItem->ShortDesc.c_str()); - S += strlen(S); - - // Show the short mode string - if (I->CurrentItem->Owner->Mode != 0) - { - snprintf(S,End-S," %s",I->CurrentItem->Owner->Mode); - S += strlen(S); - } - - // Add the current progress - if (Mode == Long) - snprintf(S,End-S," %llu",I->CurrentSize); - else - { - if (Mode == Medium || I->TotalSize == 0) - snprintf(S,End-S," %sB",SizeToStr(I->CurrentSize).c_str()); - } - S += strlen(S); - - // Add the total size and percent - if (I->TotalSize > 0 && I->CurrentItem->Owner->Complete == false) - { - if (Mode == Short) - snprintf(S,End-S," %.0f%%", - (I->CurrentSize*100.0)/I->TotalSize); - else - snprintf(S,End-S,"/%sB %.0f%%",SizeToStr(I->TotalSize).c_str(), - (I->CurrentSize*100.0)/I->TotalSize); - } - S += strlen(S); - snprintf(S,End-S,"]"); - } - - // Show something.. - if (Shown == false) - snprintf(S,End-S,_(" [Working]")); - - /* Put in the ETA and cps meter, block off signals to prevent strangeness - during resizing */ - sigset_t Sigs,OldSigs; - sigemptyset(&Sigs); - sigaddset(&Sigs,SIGWINCH); - sigprocmask(SIG_BLOCK,&Sigs,&OldSigs); - - if (CurrentCPS != 0) - { - char Tmp[300]; - unsigned long long ETA = (TotalBytes - CurrentBytes)/CurrentCPS; - sprintf(Tmp," %sB/s %s",SizeToStr(CurrentCPS).c_str(),TimeToStr(ETA).c_str()); - unsigned int Len = strlen(Buffer); - unsigned int LenT = strlen(Tmp); - if (Len + LenT < ScreenWidth) - { - memset(Buffer + Len,' ',ScreenWidth - Len); - strcpy(Buffer + ScreenWidth - LenT,Tmp); - } - } - Buffer[ScreenWidth] = 0; - BlankLine[ScreenWidth] = 0; - sigprocmask(SIG_SETMASK,&OldSigs,0); - - // Draw the current status - if (strlen(Buffer) == strlen(BlankLine)) - cout << '\r' << Buffer << flush; - else - cout << '\r' << BlankLine << '\r' << Buffer << flush; - memset(BlankLine,' ',strlen(Buffer)); - BlankLine[strlen(Buffer)] = 0; - - Update = false; - - return true; -} - /*}}}*/ -// AcqTextStatus::MediaChange - Media need to be swapped /*{{{*/ -// --------------------------------------------------------------------- -/* Prompt for a media swap */ -bool AcqTextStatus::MediaChange(string Media,string Drive) -{ - // If we do not output on a terminal and one of the options to avoid user - // interaction is given, we assume that no user is present who could react - // on your media change request - if (isatty(STDOUT_FILENO) != 1 && Quiet >= 2 && - (_config->FindB("APT::Get::Assume-Yes",false) == true || - _config->FindB("APT::Get::Force-Yes",false) == true || - _config->FindB("APT::Get::Trivial-Only",false) == true)) - - return false; - - if (Quiet <= 0) - cout << '\r' << BlankLine << '\r'; - ioprintf(cout,_("Media change: please insert the disc labeled\n" - " '%s'\n" - "in the drive '%s' and press enter\n"), - Media.c_str(),Drive.c_str()); - - char C = 0; - bool bStatus = true; - while (C != '\n' && C != '\r') - { - int len = read(STDIN_FILENO,&C,1); - if(C == 'c' || len <= 0) - bStatus = false; - } - - if(bStatus) - Update = true; - return bStatus; -} - /*}}}*/ diff --git a/cmdline/acqprogress.h b/cmdline/acqprogress.h deleted file mode 100644 index 8f0903923..000000000 --- a/cmdline/acqprogress.h +++ /dev/null @@ -1,39 +0,0 @@ -// -*- mode: cpp; mode: fold -*- -// Description /*{{{*/ -// $Id: acqprogress.h,v 1.5 2003/02/02 22:24:11 jgg Exp $ -/* ###################################################################### - - Acquire Progress - Command line progress meter - - ##################################################################### */ - /*}}}*/ -#ifndef ACQPROGRESS_H -#define ACQPROGRESS_H - -#include - -#include - -class AcqTextStatus : public pkgAcquireStatus -{ - unsigned int &ScreenWidth; - char BlankLine[1024]; - unsigned long ID; - unsigned long Quiet; - - public: - - virtual bool MediaChange(std::string Media,std::string Drive); - virtual void IMSHit(pkgAcquire::ItemDesc &Itm); - virtual void Fetch(pkgAcquire::ItemDesc &Itm); - virtual void Done(pkgAcquire::ItemDesc &Itm); - virtual void Fail(pkgAcquire::ItemDesc &Itm); - virtual void Start(); - virtual void Stop(); - - bool Pulse(pkgAcquire *Owner); - - AcqTextStatus(unsigned int &ScreenWidth,unsigned int Quiet); -}; - -#endif -- cgit v1.2.3 From 3163087b04ca5c297a7c98c018ba5c30e850a11e Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Mon, 28 Apr 2014 13:41:33 +0200 Subject: Fix missing ScreenWidth check in apt.cc --- cmdline/apt-get.cc | 22 +++------------------- cmdline/apt.cc | 4 ++++ 2 files changed, 7 insertions(+), 19 deletions(-) (limited to 'cmdline') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index caf69da2a..566103f8c 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -1664,20 +1664,6 @@ static bool ShowHelp(CommandLine &) "pages for more information and options.\n" " This APT has Super Cow Powers.\n"); return true; -} - /*}}}*/ -// SigWinch - Window size change signal handler /*{{{*/ -// --------------------------------------------------------------------- -/* */ -static void SigWinch(int) -{ - // Riped from GNU ls -#ifdef TIOCGWINSZ - struct winsize ws; - - if (ioctl(1, TIOCGWINSZ, &ws) != -1 && ws.ws_col >= 5) - ScreenWidth = ws.ws_col - 1; -#endif } /*}}}*/ int main(int argc,const char *argv[]) /*{{{*/ @@ -1734,14 +1720,12 @@ int main(int argc,const char *argv[]) /*{{{*/ // see if we are in simulate mode CheckSimulateMode(CmdL); + // Init the signals + InitSignals(); + // Setup the output streams InitOutput(); - // Setup the signals - signal(SIGPIPE,SIG_IGN); - signal(SIGWINCH,SigWinch); - SigWinch(0); - // Match the operation CmdL.DispatchArg(Cmds); diff --git a/cmdline/apt.cc b/cmdline/apt.cc index 4813861a4..72086af14 100644 --- a/cmdline/apt.cc +++ b/cmdline/apt.cc @@ -96,6 +96,10 @@ int main(int argc, const char *argv[]) /*{{{*/ std::vector Args = getCommandArgs("apt", CommandLine::GetCommand(Cmds, argc, argv)); + // Init the signals + InitSignals(); + + // Init the output InitOutput(); // Set up gettext support -- cgit v1.2.3