#include <string.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
-#include <sys/wait.h>
#include <unistd.h>
#include <pwd.h>
#include <grp.h>
if (verset.empty() == true)
return false;
- AcqTextStatus Stat(std::cout, ScreenWidth,_config->FindI("quiet",0));
- pkgAcquire Fetcher(&Stat);
-
pkgRecords Recs(Cache);
pkgSourceList *SrcList = Cache.GetSourceList();
// reuse the usual acquire methods for deb files, but don't drop them into
// the usual directories - keep everything in the current directory
+ aptAcquireWithTextStatus Fetcher;
std::vector<std::string> storefile(verset.size());
std::string const cwd = SafeGetCWD();
_config->Set("Dir::Cache::Archives", cwd);
return true;
}
- // Disable drop-privs if "_apt" can not write to the target dir
- CheckDropPrivsMustBeDisabled(Fetcher);
-
if (_error->PendingError() == true || CheckAuth(Fetcher, false) == false)
return false;
if (_error->PendingError() == true)
return false;
- // Create the download object
- AcqTextStatus Stat(std::cout, ScreenWidth,_config->FindI("quiet",0));
- pkgAcquire Fetcher(&Stat);
-
std::unique_ptr<DscFile[]> Dsc(new DscFile[CmdL.FileSize()]);
// insert all downloaded uris into this set to avoid downloading them
bool const dscOnly = _config->FindB("APT::Get::Dsc-Only", false);
// Load the requestd sources into the fetcher
+ aptAcquireWithTextStatus Fetcher;
unsigned J = 0;
std::vector<std::string> UntrustedList;
for (const char **I = CmdL.FileList + 1; *I != 0; I++, J++)
}
pos += vcs.length()+2;
string::size_type epos = srec.find("\n", pos);
- string uri = srec.substr(pos,epos-pos).c_str();
+ string const uri = srec.substr(pos,epos-pos);
ioprintf(c1out, _("NOTICE: '%s' packaging is maintained in "
"the '%s' version control system at:\n"
"%s\n"),
Src.c_str(), vcs.c_str(), uri.c_str());
- if(vcs == "Bzr")
- ioprintf(c1out,_("Please use:\n"
- "bzr branch %s\n"
- "to retrieve the latest (possibly unreleased) "
- "updates to the package.\n"),
- uri.c_str());
+ std::string vcscmd;
+ if (vcs == "Bzr")
+ vcscmd = "bzr branch " + uri;
+ else if (vcs == "Git")
+ vcscmd = "git clone " + uri;
+
+ if (vcscmd.empty() == false)
+ ioprintf(c1out,_("Please use:\n%s\n"
+ "to retrieve the latest (possibly unreleased) "
+ "updates to the package.\n"),
+ vcscmd.c_str());
break;
}
return true;
}
- // Disable drop-privs if "_apt" can not write to the target dir
- CheckDropPrivsMustBeDisabled(Fetcher);
-
// check authentication status of the source as well
if (UntrustedList.empty() == false && AuthPrompt(UntrustedList, false) == false)
return false;
_exit(0);
}
- // Wait for the subprocess
- int Status = 0;
- while (waitpid(Process,&Status,0) != Process)
- {
- if (errno == EINTR)
- continue;
- return _error->Errno("waitpid","Couldn't wait for subprocess");
- }
-
- if (WIFEXITED(Status) == 0 || WEXITSTATUS(Status) != 0)
- return _error->Error(_("Child process failed"));
-
- return true;
+ return ExecWait(Process, "dpkg-source");
}
/*}}}*/
// DoBuildDep - Install/removes packages to satisfy build dependencies /*{{{*/
CmdL.FileList + 1, APT::CacheSetHelper::CANDIDATE, helper);
if (verset.empty() == true)
return false;
- pkgAcquire Fetcher;
- AcqTextStatus Stat(std::cout, ScreenWidth,_config->FindI("quiet",0));
- Fetcher.SetLog(&Stat);
bool const downOnly = _config->FindB("APT::Get::Download-Only", false);
bool const printOnly = _config->FindB("APT::Get::Print-URIs", false);
+ aptAcquireWithTextStatus Fetcher;
for (APT::VersionList::const_iterator Ver = verset.begin();
Ver != verset.end();
++Ver)
if (printOnly == false)
{
- // Disable drop-privs if "_apt" can not write to the target dir
- CheckDropPrivsMustBeDisabled(Fetcher);
- if (_error->PendingError() == true)
- return false;
-
bool Failed = false;
if (AcquireRun(Fetcher, 0, &Failed, NULL) == false || Failed == true)
return false;
<< "Description: " << T->Description << "\n"
<< "URI: " << T->URI << "\n"
<< "Filename: " << filename << "\n"
- << "Optional: " << (T->IsOptional ? "yes" : "no") << "\n";
+ << "Optional: " << (T->IsOptional ? "yes" : "no") << "\n"
+ << "KeepCompressed: " << (T->KeepCompressed ? "yes" : "no") << "\n";
for (std::map<std::string,std::string>::const_iterator O = AddOptions.begin(); O != AddOptions.end(); ++O)
stanza << format_key(O->first) << ": " << O->second << "\n";
for (std::map<std::string,std::string>::const_iterator O = T->Options.begin(); O != T->Options.end(); ++O)
- stanza << format_key(O->first) << ": " << O->second << "\n";
+ {
+ if (O->first == "PDIFFS")
+ stanza << "PDiffs: " << O->second << "\n";
+ else if (O->first == "COMPRESSIONTYPES")
+ stanza << "CompressionTypes: " << O->second << "\n";
+ else if (O->first == "DEFAULTENABLED")
+ stanza << "DefaultEnabled: " << O->second << "\n";
+ else
+ stanza << format_key(O->first) << ": " << O->second << "\n";
+ }
stanza << "\n";
if (Filtered)
// ShowHelp - Show a help screen /*{{{*/
// ---------------------------------------------------------------------
/* */
-static bool ShowHelp(CommandLine &)
+static bool ShowHelp(CommandLine &, CommandLine::DispatchWithHelp const * Cmds)
{
ioprintf(cout, "%s %s (%s)\n", PACKAGE, PACKAGE_VERSION, COMMON_ARCH);
return true;
}
-
- cout <<
+
+ std::cout <<
_("Usage: apt-get [options] command\n"
" apt-get [options] install|remove pkg1 [pkg2 ...]\n"
" apt-get [options] source pkg1 [pkg2 ...]\n"
"\n"
"apt-get is a simple command line interface for downloading and\n"
"installing packages. The most frequently used commands are update\n"
- "and install.\n"
- "\n"
- "Commands:\n"
- " update - Retrieve new lists of packages\n"
- " upgrade - Perform an upgrade\n"
- " install - Install new packages (pkg is libc6 not libc6.deb)\n"
- " remove - Remove packages\n"
- " autoremove - Remove automatically all unused packages\n"
- " purge - Remove packages and config files\n"
- " source - Download source archives\n"
- " build-dep - Configure build-dependencies for source packages\n"
- " dist-upgrade - Distribution upgrade, see apt-get(8)\n"
- " dselect-upgrade - Follow dselect selections\n"
- " clean - Erase downloaded archive files\n"
- " autoclean - Erase old downloaded archive files\n"
- " check - Verify that there are no broken dependencies\n"
- " changelog - Download and display the changelog for the given package\n"
- " download - Download the binary package into the current directory\n"
- "\n"
- "Options:\n"
+ "and install.\n")
+ << std::endl
+ << _("Commands:") << std::endl;
+ for (; Cmds->Handler != nullptr; ++Cmds)
+ {
+ if (Cmds->Help == nullptr)
+ continue;
+ std::cout << " " << Cmds->Match << " - " << Cmds->Help << std::endl;
+ }
+
+ std::cout << std::endl <<
+ _("Options:\n"
" -h This help text.\n"
" -q Loggable output - no progress indicator\n"
" -qq No output except for errors\n"
/*}}}*/
int main(int argc,const char *argv[]) /*{{{*/
{
- CommandLine::Dispatch Cmds[] = {{"update",&DoUpdate},
- {"upgrade",&DoUpgrade},
- {"install",&DoInstall},
- {"remove",&DoInstall},
- {"purge",&DoInstall},
- {"autoremove",&DoInstall},
- {"auto-remove",&DoInstall},
- {"markauto",&DoMarkAuto},
- {"unmarkauto",&DoMarkAuto},
- {"dist-upgrade",&DoDistUpgrade},
- {"full-upgrade",&DoDistUpgrade},
- {"dselect-upgrade",&DoDSelectUpgrade},
- {"build-dep",&DoBuildDep},
- {"clean",&DoClean},
- {"autoclean",&DoAutoClean},
- {"auto-clean",&DoAutoClean},
- {"check",&DoCheck},
- {"source",&DoSource},
- {"download",&DoDownload},
- {"changelog",&DoChangelog},
- {"indextargets",&DoIndexTargets},
- {"moo",&DoMoo},
- {"help",&ShowHelp},
- {0,0}};
-
- std::vector<CommandLine::Args> Args = getCommandArgs("apt-get", CommandLine::GetCommand(Cmds, argc, argv));
-
- // Set up gettext support
- setlocale(LC_ALL,"");
- textdomain(PACKAGE);
+ InitLocale();
+
+ CommandLine::DispatchWithHelp Cmds[] = {
+ {"update", &DoUpdate, _("Retrieve new lists of packages")},
+ {"upgrade", &DoUpgrade, _("Perform an upgrade")},
+ {"install", &DoInstall, _("Install new packages (pkg is libc6 not libc6.deb)")},
+ {"remove", &DoInstall, _("Remove packages")},
+ {"purge", &DoInstall, _("Remove packages and config files")},
+ {"autoremove", &DoInstall, _("Remove automatically all unused packages")},
+ {"auto-remove", &DoInstall, nullptr},
+ {"markauto", &DoMarkAuto, nullptr},
+ {"unmarkauto", &DoMarkAuto, nullptr},
+ {"dist-upgrade", &DoDistUpgrade, _("Distribution upgrade, see apt-get(8)")},
+ {"full-upgrade", &DoDistUpgrade, nullptr},
+ {"dselect-upgrade", &DoDSelectUpgrade, _("Follow dselect selections")},
+ {"build-dep", &DoBuildDep, _("Configure build-dependencies for source packages")},
+ {"clean", &DoClean, _("Erase downloaded archive files")},
+ {"autoclean", &DoAutoClean, _("Erase old downloaded archive files")},
+ {"auto-clean", &DoAutoClean, nullptr},
+ {"check", &DoCheck, _("Verify that there are no broken dependencies")},
+ {"source", &DoSource, _("Download source archives")},
+ {"download", &DoDownload, _("Download the binary package into the current directory")},
+ {"changelog", &DoChangelog, _("Download and display the changelog for the given package")},
+ {"indextargets", &DoIndexTargets, nullptr},
+ {"moo", &DoMoo, nullptr},
+ {nullptr, nullptr, nullptr}
+ };
// Parse the command line and initialize the package library
CommandLine CmdL;
- ParseCommandLine(CmdL, Cmds, Args.data(), &_config, &_system, argc, argv, ShowHelp);
+ ParseCommandLine(CmdL, Cmds, "apt-get", &_config, &_system, argc, argv, ShowHelp);
- // see if we are in simulate mode
- CheckSimulateMode(CmdL);
-
- // Init the signals
InitSignals();
-
- // Setup the output streams
InitOutput();
- // Match the operation
- CmdL.DispatchArg(Cmds);
+ CheckIfSimulateMode(CmdL);
- // 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 DispatchCommandLine(CmdL, Cmds);
}
/*}}}*/