// cmdline_download.cc // // Copyright 2004 Daniel Burrows #include "cmdline_download.h" #include "cmdline_common.h" #include "cmdline_progress.h" #include "cmdline_util.h" #include "terminal.h" #include "text_progress.h" #include #include #include #include #include #include #include #include #include #include #include #include #include using aptitude::controllers::acquire_download_progress; using aptitude::cmdline::create_cmdline_download_progress; using aptitude::cmdline::create_terminal; using aptitude::cmdline::make_text_progress; using aptitude::cmdline::terminal_io; using aptitude::cmdline::terminal_locale; using boost::shared_ptr; // Download stuff to the current directory int cmdline_download(int argc, char *argv[]) { shared_ptr term = create_terminal(); if(argc<=1) { printf(_("download: you must specify at least one package to download\n")); return -1; } _error->DumpErrors(); shared_ptr progress = make_text_progress(false, term, term, term); apt_init(progress.get(), false); if(_error->PendingError()) { _error->DumpErrors(); return -1; } pkgSourceList list; if(!list.ReadMainList()) { _error->Error(_("Couldn't read source list")); _error->DumpErrors(); return -1; } std::pair > progress_display = create_cmdline_download_progress(term, term, term, term); pkgAcquire fetcher; fetcher.Setup(progress_display.first); string filenames[(*apt_cache_file)->Head().PackageCount]; string default_release = aptcfg->Find("APT::Default-Release"); for(int i=1; iError(_("No downloadable files for %s version %s; perhaps it is a local or obsolete package?"), name.c_str(), ver.VerStr()); get_archive(&fetcher, &list, apt_package_records, ver, ".", filenames[pkg->ID]); } } if(fetcher.Run()!=pkgAcquire::Continue) // We failed or were cancelled { _error->DumpErrors(); return -1; } return 0; }