diff options
author | Michael Vogt <mvo@debian.org> | 2014-04-28 12:50:47 +0200 |
---|---|---|
committer | Michael Vogt <mvo@debian.org> | 2014-04-28 12:50:47 +0200 |
commit | 77efe478cc59fe205c35036bae8c0d5e0e6913d7 (patch) | |
tree | 292ddf183b3f38c299bd6614fbd48585aa6d00b2 | |
parent | 814e1b8d623cb1e6b03c79fcdab6b20754c57038 (diff) | |
parent | 038e721ad2557fd517eae4b102cd36080f4ee6e3 (diff) |
Merge branch 'debian/sid' into ubuntu/master
Conflicts:
po/vi.po
-rw-r--r-- | README.MultiArch | 63 | ||||
-rw-r--r-- | apt-pkg/cacheset.cc | 6 | ||||
-rw-r--r-- | apt-pkg/cdrom.cc | 66 | ||||
-rw-r--r-- | apt-pkg/cdrom.h | 1 | ||||
-rw-r--r-- | apt-pkg/contrib/fileutl.cc | 17 | ||||
-rw-r--r-- | cmdline/acqprogress.cc | 306 | ||||
-rw-r--r-- | cmdline/acqprogress.h | 39 | ||||
-rw-r--r-- | debian/apt.dirs | 1 | ||||
-rw-r--r-- | debian/apt.maintscript | 3 | ||||
-rwxr-xr-x | debian/rules | 4 | ||||
-rw-r--r-- | methods/http.cc | 88 | ||||
-rw-r--r-- | methods/https.cc | 10 | ||||
-rw-r--r-- | po/vi.po | 22 | ||||
-rw-r--r-- | share/bash-completions/apt | 95 | ||||
-rwxr-xr-x | test/integration/test-ubuntu-bug-365611-long-package-names | 6 | ||||
-rw-r--r-- | vendor/README | 66 | ||||
-rw-r--r-- | vendor/blankon/apt-vendor.ent | 8 | ||||
-rw-r--r-- | vendor/blankon/sources.list.in | 10 | ||||
-rw-r--r-- | vendor/ubuntu/apt.conf-01-vendor-ubuntu | 6 |
19 files changed, 295 insertions, 522 deletions
diff --git a/README.MultiArch b/README.MultiArch deleted file mode 100644 index 588419b8d..000000000 --- a/README.MultiArch +++ /dev/null @@ -1,63 +0,0 @@ -Before we start with this topic: Note that MultiArch is not yet ready for -prime time and/or for the casual user. The implementation is so far widely -untested and only useful for developers of packagemanagment tools which -use APT and his friends and maintainers of (upcoming) MultiArch packages. -This README is especially NOT written for the casual user and is NOT a -usage guide - you have been warned. It is assumed that the reader has -at least a bit of knowledge about APT internals, dependency relations -and the MultiArch spec [0]. - -Note also that the toolchain isn't ready yet, e.g. while you can simulate -the installation of MultiArch packages they will more sooner than later -cause enormous problems if really installed as dpkg can't handle MultiArch -yet (no, --force-{overwrite,architecture} aren't good options here). -Other parts of the big picture are missing and/or untested too. -You have been warned! - - -The implementation is focused on NOT breaking existing singleArch-only -applications and/or systems as this is the current status-quo for all -systems. Also, many systems don't need (or can't make use of) MultiArch, -so APT will proceed in thinking SingleArch as long as it is not explicitly -told to handle MultiArch: -To activate MultiArch handling you need to specify architectures you -want to be considered by APT with the config list APT::Architectures -(Insert architectures in order of preference). -APT will download Packages files for all these architectures in the -update step. Exception: In the sourcelist is the optionfield used: -deb [ arch=amd64,i386 ] http://example.org/ experimental main -(This optionfield is a NOP in previous apt versions) - -Internally in APT a package is represented as a PkgIterator - -before MultiArch this PkgIterator was architecture unaware, -only VerIterators include the architecture they came from. -This is/was a big problem as all versions in a package are -considered for dependency resolution, so pinning will not work in all cases. - -The problem is solved by a conceptional change: -A PkgIterator is now architecture aware, so the packages -of foobar for amd64 and for i386 are now for apt internal totally -different packages. That is a good thing for e.g. pinning, but -sometimes you need the information that such packages are belonging together: -All these foobar packages therefore form a Group accessible with GrpIterators. -Note that the GrpIterator has the same name as all the packages in this group, -so e.g. apt-cache pkgnames iterates over GrpIterator to get the package names: -This is compatible to SingleArch as a Group consists only of a single package -and also to MultiArch as a Group consists of possible many packages which -all have the same name and are therefore out of interest for pkgnames. - - -Given all these internal changes it is quite interesting that the actual -implementation of MultiArch is trivial: Some implicit dependencies and a few -more provides are all changes needed to get it working. Especially noteworthy -is that it wasn't needed to change the resolver in any way and other parts only -need to be told about using GrpIterator instead of PkgIterator, so chances are -good that libapt-applications will proceed to work without or at least only -require minor changes, but your mileage may vary… - - -Known Issues and/or noteworthy stuff: -* The implementation is mostly untested, so it is very likely that APT will - eat your kids if you aren't as lucky as the author of these patches. - -[0] https://wiki.ubuntu.com/MultiarchSpec diff --git a/apt-pkg/cacheset.cc b/apt-pkg/cacheset.cc index d453a2bfb..2ed6a96da 100644 --- a/apt-pkg/cacheset.cc +++ b/apt-pkg/cacheset.cc @@ -391,6 +391,8 @@ bool VersionContainerInterface::FromModifierCommandLine(unsigned short &modID, CacheSetHelper &helper) { Version select = NEWEST; std::string str = cmdline; + if (unlikely(str.empty() == true)) + return false; bool modifierPresent = false; unsigned short fallback = modID; for (std::list<Modifier>::const_iterator mod = mods.begin(); @@ -400,8 +402,8 @@ bool VersionContainerInterface::FromModifierCommandLine(unsigned short &modID, size_t const alength = strlen(mod->Alias); switch(mod->Pos) { case Modifier::POSTFIX: - if (str.compare(str.length() - alength, alength, - mod->Alias, 0, alength) != 0) + if (str.length() <= alength || + str.compare(str.length() - alength, alength, mod->Alias, 0, alength) != 0) continue; str.erase(str.length() - alength); modID = mod->ID; diff --git a/apt-pkg/cdrom.cc b/apt-pkg/cdrom.cc index 2635ede76..a5ad6a9ff 100644 --- a/apt-pkg/cdrom.cc +++ b/apt-pkg/cdrom.cc @@ -563,6 +563,15 @@ bool pkgCdrom::WriteSourceList(string Name,vector<string> &List,bool Source) return true; } /*}}}*/ +bool pkgCdrom::UnmountCDROM(std::string const &CDROM, pkgCdromStatus * const log)/*{{{*/ +{ + if (_config->FindB("APT::CDROM::NoMount",false) == true) + return true; + if (log != NULL) + log->Update(_("Unmounting CD-ROM...\n"), STEP_LAST); + return UnmountCdrom(CDROM); +} + /*}}}*/ bool pkgCdrom::MountAndIdentCDROM(Configuration &Database, std::string &CDROM, std::string &ident, pkgCdromStatus * const log, bool const interactive)/*{{{*/ { // Startup @@ -583,9 +592,7 @@ bool pkgCdrom::MountAndIdentCDROM(Configuration &Database, std::string &CDROM, s { if (interactive == true) { - if(log != NULL) - log->Update(_("Unmounting CD-ROM...\n"), STEP_LAST); - UnmountCdrom(CDROM); + UnmountCDROM(CDROM, log); if(log != NULL) { @@ -605,6 +612,9 @@ bool pkgCdrom::MountAndIdentCDROM(Configuration &Database, std::string &CDROM, s return _error->Error("Failed to mount the cdrom."); } + if (IsMounted(CDROM) == false) + return _error->Error("Failed to mount the cdrom."); + // Hash the CD to get an ID if (log != NULL) log->Update(_("Identifying... "), STEP_IDENT); @@ -614,6 +624,7 @@ bool pkgCdrom::MountAndIdentCDROM(Configuration &Database, std::string &CDROM, s ident = ""; if (log != NULL) log->Update("\n"); + UnmountCDROM(CDROM, NULL); return false; } @@ -629,8 +640,11 @@ bool pkgCdrom::MountAndIdentCDROM(Configuration &Database, std::string &CDROM, s if (FileExists(DFile) == true) { if (ReadConfigFile(Database,DFile) == false) + { + UnmountCDROM(CDROM, NULL); return _error->Error("Unable to read the cdrom database %s", DFile.c_str()); + } } return true; } @@ -651,13 +665,7 @@ bool pkgCdrom::Ident(string &ident, pkgCdromStatus *log) /*{{{*/ } // Unmount and finish - if (_config->FindB("APT::CDROM::NoMount",false) == false) - { - if (log != NULL) - log->Update(_("Unmounting CD-ROM...\n"), STEP_LAST); - UnmountCdrom(CDROM); - } - + UnmountCDROM(CDROM, log); return true; } /*}}}*/ @@ -682,11 +690,15 @@ bool pkgCdrom::Add(pkgCdromStatus *log) /*{{{*/ { if (log != NULL) log->Update("\n"); + UnmountCDROM(CDROM, NULL); return false; } if (chdir(StartDir.c_str()) != 0) + { + UnmountCDROM(CDROM, NULL); return _error->Errno("chdir","Unable to change to %s", StartDir.c_str()); + } if (_config->FindB("Debug::aptcdrom",false) == true) { @@ -728,8 +740,7 @@ bool pkgCdrom::Add(pkgCdromStatus *log) /*{{{*/ if (List.empty() == true && SourceList.empty() == true) { - if (_config->FindB("APT::CDROM::NoMount",false) == false) - UnmountCdrom(CDROM); + UnmountCDROM(CDROM, NULL); return _error->Error(_("Unable to locate any package files, perhaps this is not a Debian Disc or the wrong architecture?")); } @@ -769,14 +780,14 @@ bool pkgCdrom::Add(pkgCdromStatus *log) /*{{{*/ { if(log == NULL) { - if (_config->FindB("APT::CDROM::NoMount",false) == false) - UnmountCdrom(CDROM); + UnmountCDROM(CDROM, NULL); return _error->Error("No disc name found and no way to ask for it"); } while(true) { if(!log->AskCdromName(Name)) { // user canceld + UnmountCDROM(CDROM, NULL); return false; } cout << "Name: '" << Name << "'" << endl; @@ -813,7 +824,10 @@ bool pkgCdrom::Add(pkgCdromStatus *log) /*{{{*/ string const partialListDir = listDir + "partial/"; if (CreateAPTDirectoryIfNeeded(_config->FindDir("Dir::State"), partialListDir) == false && CreateAPTDirectoryIfNeeded(listDir, partialListDir) == false) + { + UnmountCDROM(CDROM, NULL); return _error->Errno("cdrom", _("List directory %spartial is missing."), listDir.c_str()); + } // take care of the signatures and copy them if they are ok // (we do this before PackageCopy as it modifies "List" and "SourceList") @@ -827,7 +841,10 @@ bool pkgCdrom::Add(pkgCdromStatus *log) /*{{{*/ if (Copy.CopyPackages(CDROM,Name,List, log) == false || SrcCopy.CopyPackages(CDROM,Name,SourceList, log) == false || TransCopy.CopyTranslations(CDROM,Name,TransList, log) == false) + { + UnmountCDROM(CDROM, NULL); return false; + } // reduce the List so that it takes less space in sources.list ReduceSourcelist(CDROM,List); @@ -837,13 +854,19 @@ bool pkgCdrom::Add(pkgCdromStatus *log) /*{{{*/ if (_config->FindB("APT::cdrom::NoAct",false) == false) { if (WriteDatabase(Database) == false) + { + UnmountCDROM(CDROM, NULL); return false; - + } + if(log != NULL) log->Update(_("Writing new source list\n"), STEP_WRITE); if (WriteSourceList(Name,List,false) == false || WriteSourceList(Name,SourceList,true) == false) + { + UnmountCDROM(CDROM, NULL); return false; + } } // Print the sourcelist entries @@ -855,8 +878,7 @@ bool pkgCdrom::Add(pkgCdromStatus *log) /*{{{*/ string::size_type Space = (*I).find(' '); if (Space == string::npos) { - if (_config->FindB("APT::CDROM::NoMount",false) == false) - UnmountCdrom(CDROM); + UnmountCDROM(CDROM, NULL); return _error->Error("Internal error"); } @@ -874,8 +896,7 @@ bool pkgCdrom::Add(pkgCdromStatus *log) /*{{{*/ string::size_type Space = (*I).find(' '); if (Space == string::npos) { - if (_config->FindB("APT::CDROM::NoMount",false) == false) - UnmountCdrom(CDROM); + UnmountCDROM(CDROM, NULL); return _error->Error("Internal error"); } @@ -888,12 +909,7 @@ bool pkgCdrom::Add(pkgCdromStatus *log) /*{{{*/ } // Unmount and finish - if (_config->FindB("APT::CDROM::NoMount",false) == false) { - if (log != NULL) - log->Update(_("Unmounting CD-ROM...\n"), STEP_LAST); - UnmountCdrom(CDROM); - } - + UnmountCDROM(CDROM, log); return true; } /*}}}*/ diff --git a/apt-pkg/cdrom.h b/apt-pkg/cdrom.h index 0f2c2cd02..bd0902176 100644 --- a/apt-pkg/cdrom.h +++ b/apt-pkg/cdrom.h @@ -77,6 +77,7 @@ class pkgCdrom /*{{{*/ private: APT_HIDDEN bool MountAndIdentCDROM(Configuration &Database, std::string &CDROM, std::string &ident, pkgCdromStatus * const log, bool const interactive); + APT_HIDDEN bool UnmountCDROM(std::string const &CDROM, pkgCdromStatus * const log); }; /*}}}*/ diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc index de73a7fd8..b77c7ff7f 100644 --- a/apt-pkg/contrib/fileutl.cc +++ b/apt-pkg/contrib/fileutl.cc @@ -58,13 +58,10 @@ #include <bzlib.h> #endif #ifdef HAVE_LZMA - #include <stdint.h> #include <lzma.h> #endif - -#ifdef WORDS_BIGENDIAN -#include <inttypes.h> -#endif +#include <endian.h> +#include <stdint.h> #include <apti18n.h> /*}}}*/ @@ -1880,19 +1877,13 @@ unsigned long long FileFd::Size() FileFdErrno("lseek","Unable to seek to end of gzipped file"); return 0; } - size = 0; + uint32_t size = 0; if (read(iFd, &size, 4) != 4) { FileFdErrno("read","Unable to read original size of gzipped file"); return 0; } - -#ifdef WORDS_BIGENDIAN - uint32_t tmp_size = size; - uint8_t const * const p = (uint8_t const * const) &tmp_size; - tmp_size = (p[3] << 24) | (p[2] << 16) | (p[1] << 8) | p[0]; - size = tmp_size; -#endif + size = le32toh(size); if (lseek(iFd, oldPos, SEEK_SET) < 0) { 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<config.h> - -#include <apt-pkg/acquire.h> -#include <apt-pkg/acquire-item.h> -#include <apt-pkg/acquire-worker.h> -#include <apt-pkg/configuration.h> -#include <apt-pkg/strutl.h> -#include <apt-pkg/error.h> - -#include <string.h> -#include <stdio.h> -#include <signal.h> -#include <iostream> -#include <unistd.h> - -#include "acqprogress.h" -#include <apti18n.h> - /*}}}*/ - -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 <apt-pkg/acquire.h> - -#include <string> - -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 diff --git a/debian/apt.dirs b/debian/apt.dirs index ecbcdbc0a..1e8b057eb 100644 --- a/debian/apt.dirs +++ b/debian/apt.dirs @@ -16,3 +16,4 @@ var/lib/apt/periodic var/log/apt usr/share/apt usr/share/bug/apt +usr/share/bash-completion/completions/ diff --git a/debian/apt.maintscript b/debian/apt.maintscript new file mode 100644 index 000000000..939769355 --- /dev/null +++ b/debian/apt.maintscript @@ -0,0 +1,3 @@ +rm_conffile /etc/apt/apt.conf.d/20changelog 1.0.3 -- "@" + + diff --git a/debian/rules b/debian/rules index 338890445..c013c3a55 100755 --- a/debian/rules +++ b/debian/rules @@ -191,6 +191,10 @@ apt: build-binary build-manpages debian/apt.install cp share/ubuntu-archive.gpg debian/$@/usr/share/$@ cp debian/apt.auto-removal.sh debian/$@/etc/kernel/postinst.d/apt-auto-removal chmod 755 debian/$@/etc/kernel/postinst.d/apt-auto-removal + # install bash completion + cp share/bash-completions/* debian/$@/usr/share/bash-completion/completions/ + # install vendor specific apt confs + find -L vendor/current -name 'apt.conf-*' | while read conf; do cp "$${conf}" "debian/$@/etc/apt/apt.conf.d/$${conf#*-}"; done # make rosetta happy and remove pot files in po/ (but leave stuff # in po/domains/* untouched) and cp *.po into each domain dir diff --git a/methods/http.cc b/methods/http.cc index ed6e3517d..c734d3799 100644 --- a/methods/http.cc +++ b/methods/http.cc @@ -45,6 +45,7 @@ #include <stdio.h> #include <errno.h> #include <iostream> +#include <sstream> #include "config.h" #include "connect.h" @@ -667,22 +668,13 @@ void HttpMethod::SendReq(FetchItem *Itm) URI Uri = Itm->Uri; // The HTTP server expects a hostname with a trailing :port - char Buf[1000]; + std::stringstream Req; string ProperHost; if (Uri.Host.find(':') != string::npos) ProperHost = '[' + Uri.Host + ']'; else ProperHost = Uri.Host; - if (Uri.Port != 0) - { - sprintf(Buf,":%u",Uri.Port); - ProperHost += Buf; - } - - // Just in case. - if (Itm->Uri.length() >= sizeof(Buf)) - abort(); /* RFC 2616 §5.1.2 requires absolute URIs for requests to proxies, but while its a must for all servers to accept absolute URIs, @@ -701,27 +693,20 @@ void HttpMethod::SendReq(FetchItem *Itm) in 1.1, can cause problems with proxies, and we are an HTTP/1.1 client anyway. C.f. https://tools.ietf.org/wg/httpbis/trac/ticket/158 */ - sprintf(Buf,"GET %s HTTP/1.1\r\nHost: %s\r\n", - requesturi.c_str(),ProperHost.c_str()); + Req << "GET " << requesturi << " HTTP/1.1\r\n"; + if (Uri.Port != 0) + Req << "Host: " << ProperHost << ":" << Uri.Port << "\r\n"; + else + Req << "Host: " << ProperHost << "\r\n"; // generate a cache control header (if needed) - if (_config->FindB("Acquire::http::No-Cache",false) == true) - { - strcat(Buf,"Cache-Control: no-cache\r\nPragma: no-cache\r\n"); - } - else - { - if (Itm->IndexFile == true) - { - sprintf(Buf+strlen(Buf),"Cache-Control: max-age=%u\r\n", - _config->FindI("Acquire::http::Max-Age",0)); - } - else - { - if (_config->FindB("Acquire::http::No-Store",false) == true) - strcat(Buf,"Cache-Control: no-store\r\n"); - } - } + if (_config->FindB("Acquire::http::No-Cache",false) == true) + Req << "Cache-Control: no-cache\r\n" + << "Pragma: no-cache\r\n"; + else if (Itm->IndexFile == true) + Req << "Cache-Control: max-age=" << _config->FindI("Acquire::http::Max-Age",0) << "\r\n"; + else if (_config->FindB("Acquire::http::No-Store",false) == true) + Req << "Cache-Control: no-store\r\n"; // If we ask for uncompressed files servers might respond with content- // negotiation which lets us end up with compressed files we do not support, @@ -733,46 +718,35 @@ void HttpMethod::SendReq(FetchItem *Itm) size_t const filepos = Itm->Uri.find_last_of('/'); string const file = Itm->Uri.substr(filepos + 1); if (flExtension(file) == file) - strcat(Buf,"Accept: text/*\r\n"); + Req << "Accept: text/*\r\n"; } - string Req = Buf; - - // Check for a partial file + // Check for a partial file and send if-queries accordingly struct stat SBuf; if (stat(Itm->DestFile.c_str(),&SBuf) >= 0 && SBuf.st_size > 0) - { - // In this case we send an if-range query with a range header - sprintf(Buf,"Range: bytes=%lli-\r\nIf-Range: %s\r\n",(long long)SBuf.st_size, - TimeRFC1123(SBuf.st_mtime).c_str()); - Req += Buf; - } - else - { - if (Itm->LastModified != 0) - { - sprintf(Buf,"If-Modified-Since: %s\r\n",TimeRFC1123(Itm->LastModified).c_str()); - Req += Buf; - } - } + Req << "Range: bytes=" << SBuf.st_size << "-\r\n" + << "If-Range: " << TimeRFC1123(SBuf.st_mtime) << "\r\n"; + else if (Itm->LastModified != 0) + Req << "If-Modified-Since: " << TimeRFC1123(Itm->LastModified).c_str() << "\r\n"; if (Server->Proxy.User.empty() == false || Server->Proxy.Password.empty() == false) - Req += string("Proxy-Authorization: Basic ") + - Base64Encode(Server->Proxy.User + ":" + Server->Proxy.Password) + "\r\n"; + Req << "Proxy-Authorization: Basic " + << Base64Encode(Server->Proxy.User + ":" + Server->Proxy.Password) << "\r\n"; maybe_add_auth (Uri, _config->FindFile("Dir::Etc::netrc")); if (Uri.User.empty() == false || Uri.Password.empty() == false) - { - Req += string("Authorization: Basic ") + - Base64Encode(Uri.User + ":" + Uri.Password) + "\r\n"; - } - Req += "User-Agent: " + _config->Find("Acquire::http::User-Agent", - "Debian APT-HTTP/1.3 (" PACKAGE_VERSION ")") + "\r\n\r\n"; - + Req << "Authorization: Basic " + << Base64Encode(Uri.User + ":" + Uri.Password) << "\r\n"; + + Req << "User-Agent: " << _config->Find("Acquire::http::User-Agent", + "Debian APT-HTTP/1.3 (" PACKAGE_VERSION ")") << "\r\n"; + + Req << "\r\n"; + if (Debug == true) cerr << Req << endl; - Server->WriteResponse(Req); + Server->WriteResponse(Req.str()); } /*}}}*/ // HttpMethod::Configuration - Handle a configuration message /*{{{*/ diff --git a/methods/https.cc b/methods/https.cc index c4aff8f38..e0348ab58 100644 --- a/methods/https.cc +++ b/methods/https.cc @@ -325,11 +325,11 @@ bool HttpsMethod::Fetch(FetchItem *Itm) // if we have the file send an if-range query with a range header if (stat(Itm->DestFile.c_str(),&SBuf) >= 0 && SBuf.st_size > 0) { - char Buf[1000]; - sprintf(Buf, "Range: bytes=%li-", (long) SBuf.st_size); - headers = curl_slist_append(headers, Buf); - sprintf(Buf, "If-Range: %s", TimeRFC1123(SBuf.st_mtime).c_str()); - headers = curl_slist_append(headers, Buf); + std::string Buf; + strprintf(Buf, "Range: bytes=%lli-", (long long) SBuf.st_size); + headers = curl_slist_append(headers, Buf.c_str()); + strprintf(Buf, "If-Range: %s", TimeRFC1123(SBuf.st_mtime).c_str()); + headers = curl_slist_append(headers, Buf.c_str()); } else if(Itm->LastModified > 0) { @@ -6,10 +6,10 @@ # msgid "" msgstr "" -"Project-Id-Version: apt 1.0.1\n" +"Project-Id-Version: apt 1.0.2\n" "Report-Msgid-Bugs-To: APT Development Team <deity@lists.debian.org>\n" -"POT-Creation-Date: 2014-04-25 13:52+0200\n" -"PO-Revision-Date: 2014-04-11 09:08+0700\n" +"POT-Creation-Date: 2014-04-25 13:17+0200\n" +"PO-Revision-Date: 2014-04-28 09:24+0700\n" "Last-Translator: Trần Ngọc Quân <vnwildman@gmail.com>\n" "Language-Team: Vietnamese <translation-team-vi@lists.sourceforge.net>\n" "Language: vi\n" @@ -162,7 +162,7 @@ msgid " Version table:" msgstr " Bảng phiên bản:" #: cmdline/apt-cache.cc:1742 cmdline/apt-cdrom.cc:207 cmdline/apt-config.cc:83 -#: cmdline/apt-get.cc:1581 cmdline/apt-helper.cc:58 cmdline/apt-mark.cc:388 +#: cmdline/apt-get.cc:1578 cmdline/apt-helper.cc:58 cmdline/apt-mark.cc:388 #: cmdline/apt.cc:42 cmdline/apt-extracttemplates.cc:217 #: ftparchive/apt-ftparchive.cc:600 cmdline/apt-internal-solver.cc:42 #: cmdline/apt-sortpkgs.cc:147 @@ -546,11 +546,11 @@ msgstr "Gặp lỗi khi xử lý các quan hệ phụ thuộc khi biên dịch" msgid "Changelog for %s (%s)" msgstr "Changelog cho %s (%s)" -#: cmdline/apt-get.cc:1586 +#: cmdline/apt-get.cc:1583 msgid "Supported modules:" msgstr "Hỗ trợ các mô-đun:" -#: cmdline/apt-get.cc:1627 +#: cmdline/apt-get.cc:1624 msgid "" "Usage: apt-get [options] command\n" " apt-get [options] install|remove pkg1 [pkg2 ...]\n" @@ -1503,11 +1503,11 @@ msgid "Listing" msgstr "Đang liệt kê" #: apt-private/private-list.cc:164 -#, fuzzy, c-format +#, c-format msgid "There is %i additional version. Please use the '-a' switch to see it" msgid_plural "" "There are %i additional versions. Please use the '-a' switch to see them." -msgstr[0] "Ở đây có %i bản ghi phụ thêm. Hãy dùng tùy chọn “-a” để xem" +msgstr[0] "Ở đây có %i phiên bản phụ thêm. Hãy dùng tùy chọn “-a” để xem." #: apt-private/private-main.cc:23 msgid "" @@ -1727,7 +1727,7 @@ msgstr "Xong" #. Only warn if there are no sources.list.d. #. Only warn if there is no sources.list file. #: methods/mirror.cc:95 apt-inst/extract.cc:471 apt-pkg/acquire.cc:491 -#: apt-pkg/clean.cc:40 apt-pkg/init.cc:103 apt-pkg/init.cc:111 +#: apt-pkg/clean.cc:40 apt-pkg/init.cc:102 apt-pkg/init.cc:110 #: apt-pkg/policy.cc:381 apt-pkg/sourcelist.cc:280 apt-pkg/sourcelist.cc:286 #: apt-pkg/contrib/cdromutl.cc:205 apt-pkg/contrib/fileutl.cc:371 #: apt-pkg/contrib/fileutl.cc:484 @@ -2808,12 +2808,12 @@ msgid "Invalid 'Date' entry in Release file %s" msgstr "" "Gặp mục tin “Date” (ngày tháng) không hợp lệ trong tập tin Phát hành %s" -#: apt-pkg/init.cc:146 +#: apt-pkg/init.cc:145 #, c-format msgid "Packaging system '%s' is not supported" msgstr "Không hỗ trợ hệ thống đóng gói “%s”" -#: apt-pkg/init.cc:162 +#: apt-pkg/init.cc:161 msgid "Unable to determine a suitable packaging system type" msgstr "Không thể quyết định kiểu hệ thống đóng gói thích hợp" diff --git a/share/bash-completions/apt b/share/bash-completions/apt new file mode 100644 index 000000000..9929bf755 --- /dev/null +++ b/share/bash-completions/apt @@ -0,0 +1,95 @@ +# Debian apt(8) completion -*- shell-script -*- + +_apt() +{ + local sourcesdir="/etc/apt/sources.list.d" + local cur prev words cword + _init_completion || return + + # see if the user selected a command already + local COMMANDS=("install" "remove" "purge" "show" "list" + "update" "upgrade" "full-upgrade" "dist-upgrade" + "edit-sources" "help") + + local command i + for (( i=0; i < ${#words[@]}-1; i++ )); do + if [[ ${COMMANDS[@]} =~ ${words[i]} ]]; then + command=${words[i]} + break + fi + done + + # supported options per command + if [[ "$cur" == -* ]]; then + case $command in + install|remove|purge|upgrade|full-upgrade) + COMPREPLY=( $( compgen -W '--show-progress + --fix-broken --purge --verbose-versions --auto-remove + --simulate --dry-run + --download + --fix-missing + --fix-policy + --ignore-hold + --force-yes + --trivial-only + --reinstall --solver' -- "$cur" ) ) + return 0 + ;; + update) + COMPREPLY=( $( compgen -W '--list-cleanup + ' -- "$cur" ) ) + return 0 + ;; + list) + COMPREPLY=( $( compgen -W '--installed --upgradable + --manual-installed + -v --verbose + -a --all-versions + ' -- "$cur" ) ) + return 0 + ;; + show) + COMPREPLY=( $( compgen -W '-a --all-versions + ' -- "$cur" ) ) + return 0 + ;; + esac + fi + + # specific command arguments + if [[ -n $command ]]; then + case $command in + remove|purge) + if [[ -f /etc/debian_version ]]; then + # Debian system + COMPREPLY=( $( \ + _xfunc dpkg _comp_dpkg_installed_packages $cur ) ) + else + # assume RPM based + _xfunc rpm _rpm_installed_packages + fi + return 0 + ;; + install|show|list) + COMPREPLY=( $( apt-cache --no-generate pkgnames "$cur" \ + 2> /dev/null ) ) + return 0 + ;; + edit-sources) + COMPREPLY=( $( compgen -W '$( command ls $sourcesdir )' \ + -- "$cur" ) ) + return 0 + ;; + esac + fi + + # no command yet, show what commands we have + if [ "$command" = "" ]; then + COMPREPLY=( $( compgen -W '${COMMANDS[@]}' -- "$cur" ) ) + fi + + return 0 +} && +complete -F _apt apt + +# ex: ts=4 sw=4 et filetype=sh diff --git a/test/integration/test-ubuntu-bug-365611-long-package-names b/test/integration/test-ubuntu-bug-365611-long-package-names index 894c8dc97..f22986e21 100755 --- a/test/integration/test-ubuntu-bug-365611-long-package-names +++ b/test/integration/test-ubuntu-bug-365611-long-package-names @@ -4,8 +4,12 @@ set -e TESTDIR=$(readlink -f $(dirname $0)) . $TESTDIR/framework setupenvironment -configarchitecture "i386" +configarchitecture 'i386' setupaptarchive aptget install $(for i in $(seq 0 1000); do echo -n 'a'; done) 2> longpackagename.log > /dev/null || true testfileequal 'longpackagename.log' "E: Unable to locate package $(for i in $(seq 0 1000); do echo -n 'a'; done)" + +# … and the opposite of long: +aptget install "" -s >longpackagename.log 2>&1 || true +testfileequal 'longpackagename.log' "$(aptget install -s)" diff --git a/vendor/README b/vendor/README new file mode 100644 index 000000000..c2fabbd4c --- /dev/null +++ b/vendor/README @@ -0,0 +1,66 @@ +The vendor system in APT is an experiment to help distributions ship a stock +apt release instead of applying documentation patches to it, increasing +maintenance burden for everyone and hiding 'interesting' patches in the mix. + +The provided information is used in the apt-key script and in documentation +like manpages and example configuration files. If you have patches modifying +additional bits and pieces currently not covered by this system please +contact us so we can change this! + + +== Adding a new vendor + +In the same directory you found this README in you should create a new +directory with the name of your distribution (as defined by dpkg-vendor, + e.g. via "dpkg-vendor --query Vendor"). The name is case-insensitive, +but ensure that the name is otherwise correct and the other fields in +your deb-origin(5) file are correct as well as our buildsystem relies on +this information. + +If no information is found for the current vendor at buildtime, the system +looks for a vendor the current vendor is a derivative of, falling back to +Debian if all else fails. + +The directory should include 2 files at the moment. It is best to look +at the files of other distributions to understand what values are to be +expected. Some additional notes about them can be found below. + +If we happen to include new fields/files in this system, we will opt for +using a sensible default rather than failing the build or similar, so +you are recommend to watch this space. +Ensure also that your information is up-to-date! + +Contributing a new vendor as well as updating a existing one is best done +by opening a bug in the Debian BTS against apt with a patch attached. + + +== apt-vendor.ent + +The format used is the one DocBook XML uses. The file is included as an +entity file in the manpages xml source, so the syntax has to be valid! + +The keyring-* settings are additionally used also in the creation of the +apt-key script and the keyring-package in particular as a dependency for apt. + +The field current-codename is optional and can be used in sources.list.in. + + +== sources.list.in + +An example for a sources.list which will be shipped in /usr/share/doc. +This file will NOT be installed in /etc or otherwise used by apt. + +You can use some placeholders in this file, namely: +* &debian-stable-codename; +* &debian-oldstable-codename; +* &debian-testing-codename; +* &ubuntu-codename; +with the value you would expect based on the name. + +The placeholder ¤t-codename; is yours and can be set in apt-vendor.ent + + +== apt.conf-* + +Files in your vendor directory following this naming scheme will be picked up +by the debian/rules file and installed in /etc/apt/apt.conf.d/ directory. diff --git a/vendor/blankon/apt-vendor.ent b/vendor/blankon/apt-vendor.ent new file mode 100644 index 000000000..2600eb715 --- /dev/null +++ b/vendor/blankon/apt-vendor.ent @@ -0,0 +1,8 @@ +<!-- details about the keys used by the distribution --> +<!ENTITY keyring-distro "BlankOn"> +<!ENTITY keyring-package "<package>blankon-keyring</package>"> +<!ENTITY keyring-filename "<filename>/usr/share/keyrings/blankon-archive-keyring.gpg</filename>"> +<!ENTITY keyring-removed-filename "<filename>/usr/share/keyrings/blankon-archive-removed-keys.gpg</filename>"> +<!ENTITY keyring-master-filename "/usr/share/keyrings/blankon-master-keyring.gpg"> +<!ENTITY keyring-uri "http://arsip.blankonlinux.or.id/blankon/project/blankon-archive-keyring.gpg"> +<!ENTITY current-codename "tambora"> diff --git a/vendor/blankon/sources.list.in b/vendor/blankon/sources.list.in new file mode 100644 index 000000000..2322e974d --- /dev/null +++ b/vendor/blankon/sources.list.in @@ -0,0 +1,10 @@ +# See sources.list(5) manpage for more information +# Remember that CD-ROMs, DVDs and such are managed through the apt-cdrom tool. +deb http://arsip.blankonlinux.or.id/blankon ¤t-codename; main restricted +deb-src http://arsip.blankonlinux.or.id/blankon ¤t-codename; main restricted + +deb http://arsip.blankonlinux.or.id/blankon ¤t-codename;-security main restricted +deb-src http://arsip.blankonlinux.or.id/blankon ¤t-codename;-security main restricted + +deb http://arsip.blankonlinux.or.id/blankon ¤t-codename;-updates main restricted +deb-src http://arsip.blankonlinux.or.id/blankon ¤t-codename;-updates main restricted diff --git a/vendor/ubuntu/apt.conf-01-vendor-ubuntu b/vendor/ubuntu/apt.conf-01-vendor-ubuntu new file mode 100644 index 000000000..c4092ff44 --- /dev/null +++ b/vendor/ubuntu/apt.conf-01-vendor-ubuntu @@ -0,0 +1,6 @@ +// Server information for apt-changelog +APT { + Changelogs { + Server "http://changelogs.ubuntu.com/changelogs"; + }; +}; |