.PHONY: default
default: startup all
-.PHONY: headers library clean veryclean all binary program doc test update-po
+.PHONY: fast headers library clean veryclean all binary program doc test update-po
all headers library clean veryclean binary program doc manpages docbook test update-po startup dirs:
$(MAKE) -C vendor $@
$(MAKE) -C apt-pkg $@
$(MAKE) -C po $@
$(MAKE) -C test $@
+fast:
+ $(MAKE) -C vendor all
+ $(MAKE) -C apt-pkg all
+ $(MAKE) -C apt-inst all
+ $(MAKE) -C apt-private all
+ $(MAKE) -C methods all
+ $(MAKE) -C cmdline all
+ $(MAKE) -C ftparchive all
+ $(MAKE) -C test all
+
all headers library clean veryclean binary program doc manpages docbook test update-po: startup dirs
dirs: startup
}
// Copy the scores to advoid additive looping
- SPtrArray<int> OldScores = new int[Size];
- memcpy(OldScores,Scores,sizeof(*Scores)*Size);
+ std::unique_ptr<int[]> OldScores(new int[Size]);
+ memcpy(OldScores.get(),Scores,sizeof(*Scores)*Size);
/* Now we cause 1 level of dependency inheritance, that is we add the
score of the packages that depend on the target Package. This
operates from highest score to lowest. This prevents problems when
high score packages cause the removal of lower score packages that
would cause the removal of even lower score packages. */
- SPtrArray<pkgCache::Package *> PList = new pkgCache::Package *[Size];
- pkgCache::Package **PEnd = PList;
+ std::unique_ptr<pkgCache::Package *[]> PList(new pkgCache::Package *[Size]);
+ pkgCache::Package **PEnd = PList.get();
for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; ++I)
*PEnd++ = I;
This = this;
- qsort(PList,PEnd - PList,sizeof(*PList),&ScoreSort);
+ qsort(PList.get(),PEnd - PList.get(),sizeof(PList[0]),&ScoreSort);
if (_config->FindB("Debug::pkgProblemResolver::ShowScores",false) == true)
{
clog << "Show Scores" << endl;
- for (pkgCache::Package **K = PList; K != PEnd; K++)
+ for (pkgCache::Package **K = PList.get(); K != PEnd; K++)
if (Scores[(*K)->ID] != 0)
{
pkgCache::PkgIterator Pkg(Cache,*K);
for (int Counter = 0; Counter != 10 && Change == true; Counter++)
{
Change = false;
- for (pkgCache::Package **K = PList; K != PEnd; K++)
+ for (pkgCache::Package **K = PList.get(); K != PEnd; K++)
{
pkgCache::PkgIterator I(Cache,*K);
/* Look across the version list. If there are no possible
targets then we keep the package and bail. This is necessary
if a package has a dep on another package that can't be found */
- SPtrArray<pkgCache::Version *> VList = Start.AllTargets();
- if (*VList == 0 && (Flags[I->ID] & Protected) != Protected &&
+ std::unique_ptr<pkgCache::Version *[]> VList(Start.AllTargets());
+ if (VList[0] == 0 && (Flags[I->ID] & Protected) != Protected &&
Start.IsNegative() == false &&
Cache[I].NowBroken() == false)
{
}
bool Done = false;
- for (pkgCache::Version **V = VList; *V != 0; V++)
+ for (pkgCache::Version **V = VList.get(); *V != 0; V++)
{
pkgCache::VerIterator Ver(Cache,*V);
pkgCache::PkgIterator Pkg = Ver.ParentPkg();
clog << "Package " << I.FullName(false) << " " << Start << endl;
// Look at all the possible provides on this package
- SPtrArray<pkgCache::Version *> VList = Start.AllTargets();
- for (pkgCache::Version **V = VList; *V != 0; V++)
+ std::unique_ptr<pkgCache::Version *[]> VList(Start.AllTargets());
+ for (pkgCache::Version **V = VList.get(); *V != 0; V++)
{
pkgCache::VerIterator Ver(Cache,*V);
pkgCache::PkgIterator Pkg = Ver.ParentPkg();
inline const char *Name() const { return Group().Name(); }
// Versions have sections - and packages can have different versions with different sections
// so this interface is broken by design. Run as fast as you can to Version.Section().
- APT_DEPRECATED inline const char *Section() const {
- APT_IGNORE_DEPRECATED_PUSH
- return S->Section == 0?0:Owner->StrP + S->Section;
- APT_IGNORE_DEPRECATED_POP
- }
+ APT_DEPRECATED inline const char *Section() const;
inline bool Purge() const {return S->CurrentState == pkgCache::State::Purge ||
(S->CurrentVer == 0 && S->CurrentState == pkgCache::State::NotInstalled);}
inline const char *Arch() const {return S->Arch == 0?0:Owner->StrP + S->Arch;}
{return VerFileIterator(*Owner,Owner->VerFileP + S->FileList);}
inline pkgCache::DescFileIterator pkgCache::DescIterator::FileList() const
{return DescFileIterator(*Owner,Owner->DescFileP + S->FileList);}
+APT_DEPRECATED inline const char * pkgCache::PkgIterator::Section() const
+ {return S->VersionList == 0 ? 0 : VersionList().Section();}
/*}}}*/
#endif
#include <set>
#include <algorithm>
+#include <memory>
#ifdef HAVE_ZLIB
#include <zlib.h>
return false;
// Buffered copy between fds
- SPtrArray<unsigned char> Buf = new unsigned char[64000];
+ std::unique_ptr<unsigned char[]> Buf(new unsigned char[64000]);
unsigned long long Size = From.Size();
while (Size != 0)
{
if (Size > 64000)
ToRead = 64000;
- if (From.Read(Buf,ToRead) == false ||
- To.Write(Buf,ToRead) == false)
+ if (From.Read(Buf.get(),ToRead) == false ||
+ To.Write(Buf.get(),ToRead) == false)
return false;
Size -= ToRead;
return _error->Error("No user %s, can not drop rights", toUser.c_str());
// Do not change the order here, it might break things
+ // Get rid of all our supplementary groups first
if (setgroups(1, &pw->pw_gid))
return _error->Errno("setgroups", "Failed to setgroups");
+ // Now change the group ids to the new user
+#ifdef HAVE_SETRESGID
+ if (setresgid(pw->pw_gid, pw->pw_gid, pw->pw_gid) != 0)
+ return _error->Errno("setresgid", "Failed to set new group ids");
+#else
if (setegid(pw->pw_gid) != 0)
return _error->Errno("setegid", "Failed to setegid");
if (setgid(pw->pw_gid) != 0)
return _error->Errno("setgid", "Failed to setgid");
+#endif
+ // Change the user ids to the new user
+#ifdef HAVE_SETRESUID
+ if (setresuid(pw->pw_uid, pw->pw_uid, pw->pw_uid) != 0)
+ return _error->Errno("setresuid", "Failed to set new user ids");
+#else
if (setuid(pw->pw_uid) != 0)
return _error->Errno("setuid", "Failed to setuid");
-
- // the seteuid() is probably uneeded (at least thats what the linux
- // man-page says about setuid(2)) but we cargo culted it anyway
if (seteuid(pw->pw_uid) != 0)
return _error->Errno("seteuid", "Failed to seteuid");
+#endif
// Verify that the user has only a single group, and the correct one
gid_t groups[1];
#define SMART_POINTER_H
template <class T>
-class SPtr
+class APT_DEPRECATED SPtr
{
public:
T *Ptr;
};
template <class T>
-class SPtrArray
+class APT_DEPRECATED SPtrArray
{
public:
T *Ptr;
Otherwise we remove the offender if needed */
else if (Start.IsNegative() == true && Start->Type != pkgCache::Dep::Obsoletes)
{
- SPtrArray<Version *> List = Start.AllTargets();
+ std::unique_ptr<Version *[]> List(Start.AllTargets());
pkgCache::PkgIterator TrgPkg = Start.TargetPkg();
- for (Version **I = List; *I != 0; I++)
+ for (Version **I = List.get(); *I != 0; I++)
{
VerIterator Ver(*this,*I);
PkgIterator Pkg = Ver.ParentPkg();
}
bool pkgDepCache::MarkAndSweep()
{
- std::auto_ptr<InRootSetFunc> f(GetRootSetFunc());
+ std::unique_ptr<InRootSetFunc> f(GetRootSetFunc());
if(f.get() != NULL)
return MarkAndSweep(*f.get());
else
inline bool Keep() const {return Mode == ModeKeep;};
inline bool Protect() const {return (iFlags & Protected) == Protected;};
inline bool Upgrade() const {return Status > 0 && Mode == ModeInstall;};
- inline bool Upgradable() const {return Status >= 1;};
+ inline bool Upgradable() const {return Status >= 1 && CandidateVer != NULL;};
inline bool Downgrade() const {return Status < 0 && Mode == ModeInstall;};
inline bool Held() const {return Status != 0 && Keep();};
inline bool NowBroken() const {return (DepState & DepNowMin) != DepNowMin;};
{
// Temp list
unsigned long Size = Cache.Head().PackageCount;
- SPtrArray<Package *> NList = new Package *[Size];
- SPtrArray<Package *> AfterList = new Package *[Size];
- AfterEnd = AfterList;
+ std::unique_ptr<Package *[]> NList(new Package *[Size]);
+ std::unique_ptr<Package *[]> AfterList(new Package *[Size]);
+ AfterEnd = AfterList.get();
Depth = 0;
WipeFlags(Added | AddPending | Loop | InList);
// Rebuild the main list into the temp list.
iterator OldEnd = End;
- End = NList;
+ End = NList.get();
for (iterator I = List; I != OldEnd; ++I)
if (VisitNode(PkgIterator(Cache,*I), "DoRun") == false)
{
}
// Copy the after list to the end of the main list
- for (Package **I = AfterList; I != AfterEnd; I++)
+ for (Package **I = AfterList.get(); I != AfterEnd; I++)
*End++ = *I;
// Swap the main list to the new list
delete [] List;
- List = NList.UnGuard();
+ List = NList.release();
return true;
}
/*}}}*/
against it! */
bool pkgOrderList::VisitProvides(DepIterator D,bool Critical)
{
- SPtrArray<Version *> List = D.AllTargets();
- for (Version **I = List; *I != 0; ++I)
+ std::unique_ptr<Version *[]> List(D.AllTargets());
+ for (Version **I = List.get(); *I != 0; ++I)
{
VerIterator Ver(Cache,*I);
PkgIterator Pkg = Ver.ParentPkg();
}
if (D.IsNegative() == false)
return true;
- for (Version **I = List; *I != 0; ++I)
+ for (Version **I = List.get(); *I != 0; ++I)
{
VerIterator Ver(Cache,*I);
PkgIterator Pkg = Ver.ParentPkg();
this fails to produce a suitable result. */
bool pkgOrderList::CheckDep(DepIterator D)
{
- SPtrArray<Version *> List = D.AllTargets();
+ std::unique_ptr<Version *[]> List(D.AllTargets());
bool Hit = false;
- for (Version **I = List; *I != 0; I++)
+ for (Version **I = List.get(); *I != 0; I++)
{
VerIterator Ver(Cache,*I);
PkgIterator Pkg = Ver.ParentPkg();
// to do anything at all
for (DepIterator Cur = Start; true; ++Cur)
{
- SPtrArray<Version *> VList = Cur.AllTargets();
+ std::unique_ptr<Version *> VList(Cur.AllTargets());
- for (Version **I = VList; *I != 0; ++I)
+ for (Version **I = VList.get(); *I != 0; ++I)
{
VerIterator Ver(Cache,*I);
PkgIterator DepPkg = Ver.ParentPkg();
// probably due to loops.
for (DepIterator Cur = Start; true; ++Cur)
{
- SPtrArray<Version *> VList = Cur.AllTargets();
+ std::unique_ptr<Version *> VList(Cur.AllTargets());
- for (Version **I = VList; *I != 0; ++I)
+ for (Version **I = VList.get(); *I != 0; ++I)
{
VerIterator Ver(Cache,*I);
PkgIterator DepPkg = Ver.ParentPkg();
// Search for dependencies which are unpacked but aren't configured yet (maybe loops)
for (DepIterator Cur = Start; true; ++Cur)
{
- SPtrArray<Version *> VList = Cur.AllTargets();
+ std::unique_ptr<Version *> VList(Cur.AllTargets());
- for (Version **I = VList; *I != 0; ++I)
+ for (Version **I = VList.get(); *I != 0; ++I)
{
VerIterator Ver(Cache,*I);
PkgIterator DepPkg = Ver.ParentPkg();
// Look for easy targets: packages that are already okay
for (DepIterator Cur = Start; Bad == true; ++Cur)
{
- SPtrArray<Version *> VList = Cur.AllTargets();
- for (Version **I = VList; *I != 0; ++I)
+ std::unique_ptr<Version *> VList(Cur.AllTargets());
+ for (Version **I = VList.get(); *I != 0; ++I)
{
VerIterator Ver(Cache,*I);
PkgIterator Pkg = Ver.ParentPkg();
// Look for something that could be configured.
for (DepIterator Cur = Start; Bad == true && Cur.end() == false; ++Cur)
{
- SPtrArray<Version *> VList = Cur.AllTargets();
- for (Version **I = VList; *I != 0; ++I)
+ std::unique_ptr<Version *[]> VList(Cur.AllTargets());
+ for (Version **I = VList.get(); *I != 0; ++I)
{
VerIterator Ver(Cache,*I);
PkgIterator DepPkg = Ver.ParentPkg();
End->Type == pkgCache::Dep::Obsoletes ||
End->Type == pkgCache::Dep::DpkgBreaks)
{
- SPtrArray<Version *> VList = End.AllTargets();
- for (Version **I = VList; *I != 0; ++I)
+ std::unique_ptr<Version *[]> VList(End.AllTargets());
+ for (Version **I = VList.get(); *I != 0; ++I)
{
VerIterator Ver(Cache,*I);
PkgIterator ConflictPkg = Ver.ParentPkg();
map_pointer_t VersionList; // Version
/** \brief index to the installed version */
map_pointer_t CurrentVer; // Version
- /** \brief indicates nothing (consistently)
- This field used to contain ONE section the package belongs to,
- if those differs between versions it is a RANDOM one.
- The Section() method tries to reproduce it, but the only sane
- thing to do is use the Section field from the version! */
- APT_DEPRECATED map_ptrloc Section; // StringItem
/** \brief index of the group this package belongs to */
map_pointer_t Group; // Group the Package belongs to
// Map it
FileFd CacheF(CacheFile,FileFd::ReadOnly);
- SPtr<MMap> Map = new MMap(CacheF,0);
- pkgCache Cache(Map);
+ std::unique_ptr<MMap> Map(new MMap(CacheF,0));
+ pkgCache Cache(Map.get());
if (_error->PendingError() == true || Map->Size() == 0)
{
if (Debug == true)
return false;
}
- SPtrArray<bool> RlsVisited = new bool[Cache.HeaderP->ReleaseFileCount];
- memset(RlsVisited,0,sizeof(*RlsVisited)*Cache.HeaderP->ReleaseFileCount);
+ std::unique_ptr<bool[]> RlsVisited(new bool[Cache.HeaderP->ReleaseFileCount]);
+ memset(RlsVisited.get(),0,sizeof(RlsVisited[0])*Cache.HeaderP->ReleaseFileCount);
std::vector<pkgIndexFile *> Files;
for (pkgSourceList::const_iterator i = List.begin(); i != List.end(); ++i)
{
/* Now we check every index file, see if it is in the cache,
verify the IMS data and check that it is on the disk too.. */
- SPtrArray<bool> Visited = new bool[Cache.HeaderP->PackageFileCount];
- memset(Visited,0,sizeof(*Visited)*Cache.HeaderP->PackageFileCount);
+ std::unique_ptr<bool[]> Visited(new bool[Cache.HeaderP->PackageFileCount]);
+ memset(Visited.get(),0,sizeof(Visited[0])*Cache.HeaderP->PackageFileCount);
for (std::vector<pkgIndexFile *>::const_reverse_iterator PkgFile = Files.rbegin(); PkgFile != Files.rend(); ++PkgFile)
{
if (Debug == true)
}
if (OutMap != 0)
- *OutMap = Map.UnGuard();
+ *OutMap = Map.release();
return true;
}
/*}}}*/
return true;
}
static bool loadBackMMapFromFile(std::unique_ptr<pkgCacheGenerator> &Gen,
- SPtr<DynamicMMap> &Map, OpProgress * const Progress, std::string const &FileName)
+ std::unique_ptr<DynamicMMap> &Map, OpProgress * const Progress, std::string const &FileName)
{
- Map = CreateDynamicMMap(NULL, 0);
+ Map.reset(CreateDynamicMMap(NULL, 0));
FileFd CacheF(FileName, FileFd::ReadOnly);
map_pointer_t const alloc = Map->RawAllocate(CacheF.Size());
if ((alloc == 0 && _error->PendingError())
|| CacheF.Read((unsigned char *)Map->Data() + alloc,
CacheF.Size()) == false)
return false;
- Gen.reset(new pkgCacheGenerator(Map.Get(),Progress));
+ Gen.reset(new pkgCacheGenerator(Map.get(),Progress));
return true;
}
APT_DEPRECATED bool pkgMakeStatusCache(pkgSourceList &List,OpProgress &Progress,
}
// At this point we know we need to construct something, so get storage ready
- SPtr<DynamicMMap> Map = CreateDynamicMMap(NULL, 0);
+ std::unique_ptr<DynamicMMap> Map(CreateDynamicMMap(NULL, 0));
if (Debug == true)
std::clog << "Open memory Map (not filebased)" << std::endl;
{
if (Debug == true)
std::clog << "srcpkgcache.bin is NOT valid - rebuild" << std::endl;
- Gen.reset(new pkgCacheGenerator(Map.Get(),Progress));
+ Gen.reset(new pkgCacheGenerator(Map.get(),Progress));
TotalSize += ComputeSize(&List, Files.begin(),Files.end());
if (BuildCache(*Gen, Progress, CurrentSize, TotalSize, &List,
return false;
if (Writeable == true && SrcCacheFile.empty() == false)
- if (writeBackMMapToFile(Gen.get(), Map.Get(), SrcCacheFile) == false)
+ if (writeBackMMapToFile(Gen.get(), Map.get(), SrcCacheFile) == false)
return false;
}
return false;
if (Writeable == true && CacheFile.empty() == false)
- if (writeBackMMapToFile(Gen.get(), Map.Get(), CacheFile) == false)
+ if (writeBackMMapToFile(Gen.get(), Map.get(), CacheFile) == false)
return false;
}
}
if (OutMap != nullptr)
- *OutMap = Map.UnGuard();
+ *OutMap = Map.release();
if (Debug == true)
std::clog << "Everything is ready for shipping" << std::endl;
if (_system->AddStatusFiles(Files) == false)
return false;
- SPtr<DynamicMMap> Map = CreateDynamicMMap(NULL, 0);
+ std::unique_ptr<DynamicMMap> Map(CreateDynamicMMap(NULL, 0));
map_filesize_t CurrentSize = 0;
map_filesize_t TotalSize = 0;
// Build the status cache
if (Progress != NULL)
Progress->OverallProgress(0,1,1,_("Reading package lists"));
- pkgCacheGenerator Gen(Map.Get(),Progress);
+ pkgCacheGenerator Gen(Map.get(),Progress);
if (_error->PendingError() == true)
return false;
if (BuildCache(Gen,Progress,CurrentSize,TotalSize, NULL,
if (_error->PendingError() == true)
return false;
- *OutMap = Map.UnGuard();
+ *OutMap = Map.release();
return true;
}
}
// Apply the defaults..
- SPtrArray<bool> Fixed = new bool[Cache->HeaderP->PackageFileCount];
- memset(Fixed,0,sizeof(*Fixed)*Cache->HeaderP->PackageFileCount);
+ std::unique_ptr<bool[]> Fixed(new bool[Cache->HeaderP->PackageFileCount]);
+ memset(Fixed.get(),0,sizeof(Fixed[0])*Cache->HeaderP->PackageFileCount);
StatusOverride = false;
for (vector<Pin>::const_iterator I = Defaults.begin(); I != Defaults.end(); ++I)
{
return Pins[Pkg->ID].Priority;
return 0;
}
-APT_PURE signed short pkgPolicy::GetPriority(pkgCache::VerIterator const &Ver)
+APT_PURE signed short pkgPolicy::GetPriority(pkgCache::VerIterator const &Ver, bool considerFiles)
{
if (VerPins[Ver->ID].Type != pkgVersionMatch::None)
return VerPins[Ver->ID].Priority;
-
+ if (!considerFiles)
+ return 0;
int priority = std::numeric_limits<int>::min();
for (pkgCache::VerFileIterator file = Ver.FileList(); file.end() == false; file++)
}
for (; Word != End && isspace(*Word) != 0; Word++);
- short int priority = Tags.FindI("Pin-Priority", 0);
+ int priority = Tags.FindI("Pin-Priority", 0);
+ if (priority < std::numeric_limits<short>::min() ||
+ priority > std::numeric_limits<short>::max() ||
+ _error->PendingError()) {
+ return _error->Error(_("%s: Value %s is outside the range of valid pin priorities (%d to %d)"),
+ File.c_str(), Tags.FindS("Pin-Priority").c_str(),
+ std::numeric_limits<short>::min(),
+ std::numeric_limits<short>::max());
+ }
if (priority == 0)
{
- _error->Warning(_("No priority (or zero) specified for pin"));
- continue;
+ return _error->Error(_("No priority (or zero) specified for pin"));
}
istringstream s(Name);
// Things for the cache interface.
virtual pkgCache::VerIterator GetCandidateVer(pkgCache::PkgIterator const &Pkg) APT_OVERRIDE;
virtual signed short GetPriority(pkgCache::PkgIterator const &Pkg) APT_OVERRIDE;
- virtual signed short GetPriority(pkgCache::VerIterator const &Pkg);
+ virtual signed short GetPriority(pkgCache::VerIterator const &Pkg, bool ConsiderFiles = true);
virtual signed short GetPriority(pkgCache::PkgFileIterator const &File) APT_OVERRIDE;
bool InitDefaults();
return Default;
strncpy(S,Start,Stop-Start);
S[Stop - Start] = 0;
-
+
+ errno = 0;
char *End;
signed long Result = strtol(S,&End,10);
+ if (errno == ERANGE)
+ _error->Errno("strtol", _("Cannot convert %s to integer"), S);
+ if (Result < std::numeric_limits<int>::min() || Result > std::numeric_limits<int>::max()) {
+ errno = ERANGE;
+ _error->Errno("", _("Cannot convert %s to integer"), S);
+ }
if (S == End)
return Default;
return Result;
if (CmdMatches("list"))
{
addArg(0,"installed","APT::Cmd::Installed",0);
+ addArg(0,"upgradeable","APT::Cmd::Upgradable",0);
addArg(0,"upgradable","APT::Cmd::Upgradable",0);
addArg(0,"manual-installed","APT::Cmd::Manual-Installed",0);
addArg('v', "verbose", "APT::Cmd::List-Include-Summary", 0);
pkgSourceList *List = Cache.GetSourceList();
// Create the package manager and prepare to download
- SPtr<pkgPackageManager> PM= _system->CreatePM(Cache);
+ std::unique_ptr<pkgPackageManager> PM(_system->CreatePM(Cache));
if (PM->GetArchives(&Fetcher,List,&Recs) == false ||
_error->PendingError() == true)
return false;
if (Cache->BrokenCount() != 0)
BrokenFix = true;
- SPtr<pkgProblemResolver> Fix;
+ std::unique_ptr<pkgProblemResolver> Fix(nullptr);
if (_config->FindB("APT::Get::CallResolver", true) == true)
- Fix = new pkgProblemResolver(Cache);
+ Fix.reset(new pkgProblemResolver(Cache));
unsigned short fallback = MOD_INSTALL;
if (strcasecmp(CmdL.FileList[0],"remove") == 0)
}
- TryToInstall InstallAction(Cache, Fix, BrokenFix);
- TryToRemove RemoveAction(Cache, Fix);
+ TryToInstall InstallAction(Cache, Fix.get(), BrokenFix);
+ TryToRemove RemoveAction(Cache, Fix.get());
// new scope for the ActionGroup
{
/* If there is no socklen_t, define this for the netdb shim */
#undef NEED_SOCKLEN_T_DEFINE
-/* We need the getresuid() function */
+/* Check for getresuid() function and similar ones */
#undef HAVE_GETRESUID
#undef HAVE_GETRESGID
+#undef HAVE_SETRESUID
+#undef HAVE_SETRESGID
/* Define to the size of the filesize containing structures */
#undef _FILE_OFFSET_BITS
}
// Display all solutions
- SPtrArray<pkgCache::Version *> List = D.AllTargets();
- pkgPrioSortList(*Cache,List);
- for (pkgCache::Version **I = List; *I != 0; I++)
+ std::unique_ptr<pkgCache::Version *[]> List(D.AllTargets());
+ pkgPrioSortList(*Cache,List.get());
+ for (pkgCache::Version **I = List.get(); *I != 0; I++)
{
pkgCache::VerIterator V(*Cache,*I);
if (V != Cache->VerP + V.ParentPkg()->VersionList ||
pkgCache::PkgIterator I = Cache->PkgBegin();
for (;I.end() != true; ++I)
{
- if (Plcy->GetPriority(I) == 0)
+ // Old code for debugging
+ if (_config->FindI("APT::Policy", 1) < 1) {
+ if (Plcy->GetPriority(I) == 0)
+ continue;
+
+ // Print the package name and the version we are forcing to
+ cout << " " << I.FullName(true) << " -> ";
+
+ pkgCache::VerIterator V = Plcy->GetMatch(I);
+ if (V.end() == true)
+ cout << _("(not found)") << endl;
+ else
+ cout << V.VerStr() << endl;
+
continue;
+ }
+ // New code
+ for (pkgCache::VerIterator V = I.VersionList(); !V.end(); V++) {
+ auto Prio = Plcy->GetPriority(V, false);
+ if (Prio == 0)
+ continue;
- // Print the package name and the version we are forcing to
- cout << " " << I.FullName(true) << " -> ";
-
- pkgCache::VerIterator V = Plcy->GetMatch(I);
- if (V.end() == true)
- cout << _("(not found)") << endl;
- else
- cout << V.VerStr() << endl;
- }
-
+ cout << " ";
+ // Print the package name and the version we are forcing to
+ ioprintf(cout, _("%s -> %s with priority %d\n"), I.FullName(true).c_str(), V.VerStr(), Prio);
+ }
+ }
return true;
}
cout << V.VerStr() << endl;
// Pinned version
- if (Plcy->GetPriority(Pkg) != 0)
+ if (_config->FindI("APT::Policy", 1) < 1 && Plcy->GetPriority(Pkg) != 0)
{
cout << _(" Package pin: ");
V = Plcy->GetMatch(Pkg);
cout << " *** " << V.VerStr();
else
cout << " " << V.VerStr();
- cout << " " << Plcy->GetPriority(V) << endl;
+ if (_config->FindI("APT::Policy", 1) < 1)
+ cout << " " << Plcy->GetPriority(Pkg) << endl;
+ else
+ cout << " " << Plcy->GetPriority(V) << endl;
for (pkgCache::VerFileIterator VF = V.FileList(); VF.end() == false; ++VF)
{
// Locate the associated index files so we can derive a description
AcqTextStatus Stat(std::cout, ScreenWidth,_config->FindI("quiet",0));
pkgAcquire Fetcher(&Stat);
- SPtrArray<DscFile> Dsc = new DscFile[CmdL.FileSize()];
+ std::unique_ptr<DscFile[]> Dsc(new DscFile[CmdL.FileSize()]);
// insert all downloaded uris into this set to avoid downloading them
// twice
{
string Src;
pkgSrcRecords::Parser *Last = 0;
- SPtr<pkgSrcRecords::Parser> LastOwner;
+ std::unique_ptr<pkgSrcRecords::Parser> LastOwner;
// an unpacked debian source tree
using APT::String::Startswith;
std::string TypeName = "Debian control file";
pkgIndexFile::Type *Type = pkgIndexFile::Type::GetType(TypeName.c_str());
if(Type != NULL)
- LastOwner = Last = Type->CreateSrcPkgParser(*I);
+ LastOwner.reset(Last = Type->CreateSrcPkgParser(*I));
}
// if its a local file (e.g. .dsc) use this
else if (FileExists(*I))
string TypeName = "Debian " + flExtension(*I) + " file";
pkgIndexFile::Type *Type = pkgIndexFile::Type::GetType(TypeName.c_str());
if(Type != NULL)
- LastOwner = Last = Type->CreateSrcPkgParser(*I);
+ LastOwner.reset(Last = Type->CreateSrcPkgParser(*I));
} else {
// normal case, search the cache for the source file
Last = FindSrc(*I,SrcRecs,Src,Cache);
dnl check for setuid checking function
-AC_CHECK_FUNCS(getresuid getresgid)
+AC_CHECK_FUNCS(getresuid getresgid setresuid setresgid)
AC_SUBST(HAVE_GETRESUID)
AC_SUBST(HAVE_GETRESGID)
+AC_SUBST(HAVE_SETRESUID)
+AC_SUBST(HAVE_SETRESGID)
dnl Check for doxygen
AC_PATH_PROG(DOXYGEN, doxygen)
display a list of packages. It supports shell pattern for matching
package names and the following options:
<option>--installed</option>,
- <option>--upgradable</option>,
+ <option>--upgradable</option>,
+ <option>--upgradeable</option>,
<option>--all-versions</option>
are supported.
</para></listitem>
<term>P < 0</term>
<listitem><simpara>prevents the version from being installed</simpara></listitem>
</varlistentry>
+<varlistentry>
+<term>P = 0</term>
+<listitem><simpara>has undefined behaviour, do not use it.</simpara></listitem>
+</varlistentry>
</variablelist>
</para>
-<para>If any specific-form records match an available package version then the
-first such record determines the priority of the package version.
-Failing that,
-if any general-form records match an available package version then the
-first such record determines the priority of the package version.</para>
+<para>
+The first specific-form record matching an available package version determines
+the priority of the package version.
+Failing that, the priority of the package is defined as the maximum of all
+priorities defined by generic-form records matching the version.
+Records defined using patterns in the Pin field other than "*" are treated like
+specific-form records.
+</para>
<para>For example, suppose the APT preferences file contains the three
records presented earlier:</para>
"<literal>list</literal> is used to display a list of packages. It supports "
"shell pattern for matching package names and the following options: "
"<option>--installed</option>, <option>--upgradable</option>, "
-"<option>--all-versions</option> are supported."
+"<option>--upgradeable</option>, <option>--all-versions</option> are "
+"supported."
msgstr ""
#. type: Content of: <refentry><refsect1><variablelist><varlistentry><listitem><para>
msgid ""
"<literal>list</literal> is used to display a list of packages. It supports "
"shell pattern for matching package names and the following options: "
-"<option>--installed</option>, <option>--upgradable</option>, <option>--all-"
+"<option>--installed</option>, <option>--upgradable</option>, <option>--upgradeable</option>, <option>--all-"
"versions</option> are supported."
msgstr ""
"<literal>list</literal> wird benutzt, um eine Paketliste anzuzeigen. Es "
"unterstützt Shell-Muster zur Beschränkung auf passende Paketnamen. Die "
"folgenden Optionen werden unterstützt: <option>--installed</option>, "
-"<option>--upgradable</option>, <option>--all-versions</option>."
+"<option>--upgradable</option>, <option>--upgradeable</option>, <option>--all-versions</option>."
#. type: Content of: <refentry><refsect1><variablelist><varlistentry><listitem><para>
#: apt.8.xml:54
msgid ""
"<literal>list</literal> is used to display a list of packages. It supports "
"shell pattern for matching package names and the following options: "
-"<option>--installed</option>, <option>--upgradable</option>, <option>--all-"
+"<option>--installed</option>, <option>--upgradable</option>, <option>--upgradeable</option>, <option>--all-"
"versions</option> are supported."
msgstr ""
msgid ""
"<literal>list</literal> is used to display a list of packages. It supports "
"shell pattern for matching package names and the following options: "
-"<option>--installed</option>, <option>--upgradable</option>, <option>--all-"
+"<option>--installed</option>, <option>--upgradable</option>, <option>--upgradeable</option>, <option>--all-"
"versions</option> are supported."
msgstr ""
"La commande <literal>list</literal> est utilisée pour afficher une liste de "
msgid ""
"<literal>list</literal> is used to display a list of packages. It supports "
"shell pattern for matching package names and the following options: "
-"<option>--installed</option>, <option>--upgradable</option>, <option>--all-"
+"<option>--installed</option>, <option>--upgradable</option>, <option>--upgradeable</option>, <option>--all-"
"versions</option> are supported."
msgstr ""
"<literal>list</literal> viene usato per visualizzare un elenco di pacchetti. "
"Permette l'uso dei modelli di shell per la corrispondenza con nomi di "
"pacchetto e sono gestite le seguenti opzioni: <option>--installed</option>, "
-"<option>--upgradable</option>, <option>--all-versions</option>."
+"<option>--upgradable</option>, <option>--upgradeable</option>, <option>--all-versions</option>."
#. type: Content of: <refentry><refsect1><variablelist><varlistentry><listitem><para>
#: apt.8.xml:54
msgid ""
"<literal>list</literal> is used to display a list of packages. It supports "
"shell pattern for matching package names and the following options: "
-"<option>--installed</option>, <option>--upgradable</option>, <option>--all-"
+"<option>--installed</option>, <option>--upgradable</option>, <option>--upgradeable</option>, <option>--all-"
"versions</option> are supported."
msgstr ""
"パッケージ一覧を表示するには <literal>list</literal> を使います。パッケージ名"
"のマッチングにシェルパターン、そしてオプション <option>--installed</"
-"option>、 <option>--upgradable</option>、 <option>--all-versions</option> を"
+"option>、 <option>--upgradable</option>, <option>--upgradeable</option>、 <option>--all-versions</option> を"
"サポートしています。"
#. type: Content of: <refentry><refsect1><variablelist><varlistentry><listitem><para>
msgid ""
"<literal>list</literal> is used to display a list of packages. It supports "
"shell pattern for matching package names and the following options: "
-"<option>--installed</option>, <option>--upgradable</option>, <option>--all-"
+"<option>--installed</option>, <option>--upgradable</option>, <option>--upgradeable</option>, <option>--all-"
"versions</option> are supported."
msgstr ""
msgid ""
"<literal>list</literal> is used to display a list of packages. It supports "
"shell pattern for matching package names and the following options: "
-"<option>--installed</option>, <option>--upgradable</option>, <option>--all-"
+"<option>--installed</option>, <option>--upgradable</option>, <option>--upgradeable</option>, <option>--all-"
"versions</option> are supported."
msgstr ""
"<literal>list</literal> é usado para mostrar uma lista de pacotes. Suporta "
msgid ""
"<literal>list</literal> is used to display a list of packages. It supports "
"shell pattern for matching package names and the following options: "
-"<option>--installed</option>, <option>--upgradable</option>, <option>--all-"
+"<option>--installed</option>, <option>--upgradable</option>, <option>--upgradeable</option>, <option>--all-"
"versions</option> are supported."
msgstr ""
Architecture = Arch;
else
Architecture = Tags.FindS("Architecture");
- auto_ptr<Override::Item> OverItem(Over.GetItem(Package,Architecture));
+ unique_ptr<Override::Item> OverItem(Over.GetItem(Package,Architecture));
if (Package.empty() == true)
return _error->Error(_("Archive had no package field"));
ioprintf(c1out, _(" %s has no override entry\n"), Package.c_str());
}
- OverItem = auto_ptr<Override::Item>(new Override::Item);
+ OverItem = unique_ptr<Override::Item>(new Override::Item);
OverItem->FieldOverride["Section"] = Tags.FindS("Section");
OverItem->Priority = Tags.FindS("Priority");
}
string BestPrio;
string Bins = Tags.FindS("Binary");
char Buffer[Bins.length() + 1];
- auto_ptr<Override::Item> OverItem(0);
+ unique_ptr<Override::Item> OverItem(nullptr);
if (Bins.empty() == false)
{
strcpy(Buffer,Bins.c_str());
unsigned char BestPrioV = pkgCache::State::Extra;
for (unsigned I = 0; BinList[I] != 0; I++)
{
- auto_ptr<Override::Item> Itm(BOver.GetItem(BinList[I]));
+ unique_ptr<Override::Item> Itm(BOver.GetItem(BinList[I]));
if (Itm.get() == 0)
continue;
}
if (OverItem.get() == 0)
- OverItem = Itm;
+ OverItem = std::move(Itm);
}
}
ioprintf(c1out, _(" %s has no override entry\n"), Tags.FindS("Source").c_str());
}
- OverItem = auto_ptr<Override::Item>(new Override::Item);
+ OverItem.reset(new Override::Item);
}
struct stat St;
if (stat(FileName.c_str(), &St) != 0)
return _error->Errno("fstat","Failed to stat %s",FileName.c_str());
- auto_ptr<Override::Item> SOverItem(SOver.GetItem(Tags.FindS("Source")));
- // const auto_ptr<Override::Item> autoSOverItem(SOverItem);
+ unique_ptr<Override::Item> SOverItem(SOver.GetItem(Tags.FindS("Source")));
+ // const unique_ptr<Override::Item> autoSOverItem(SOverItem);
if (SOverItem.get() == 0)
{
ioprintf(c1out, _(" %s has no source override entry\n"), Tags.FindS("Source").c_str());
- SOverItem = auto_ptr<Override::Item>(BOver.GetItem(Tags.FindS("Source")));
+ SOverItem = unique_ptr<Override::Item>(BOver.GetItem(Tags.FindS("Source")));
if (SOverItem.get() == 0)
{
ioprintf(c1out, _(" %s has no binary override entry either\n"), Tags.FindS("Source").c_str());
- SOverItem = auto_ptr<Override::Item>(new Override::Item);
+ SOverItem = unique_ptr<Override::Item>(new Override::Item);
*SOverItem = *OverItem;
}
}
#. careful with hard to type or special characters (like non-breaking spaces)
#: apt-private/private-install.cc:195
msgid "Yes, do as I say!"
-msgstr "Oui, faites ce que je vous dis !"
+msgstr "Oui, faites ce que je vous dis !"
#: apt-private/private-install.cc:197
#, c-format
testpinning() {
- local PKGPIN=''
local PKGPINPRIO=''
local REPPINPRIO=''
if [ "$1" != '*' ]; then
PKGPINPRIO=''
REPPINPRIO=' 500'
- PKGPIN='Package pin: 5.0.0
- '
fi
writepin "$1" '99'
testsuccessequal "base-files:
Installed: 5.0.0-1
Candidate: 5.0.0-1
- ${PKGPIN}Version table:
+ Version table:
*** 5.0.0-1 100
100 $STATUS
5.0.0 ${PKGPINPRIO:-99}
testsuccessequal "base-files:
Installed: 5.0.0-1
Candidate: 5.0.0-1
- ${PKGPIN}Version table:
+ Version table:
*** 5.0.0-1 100
100 $STATUS
5.0.0 ${PKGPINPRIO:-100}
testsuccessequal "base-files:
Installed: 5.0.0-1
Candidate: 5.0.0-1
- ${PKGPIN}Version table:
+ Version table:
*** 5.0.0-1 100
100 $STATUS
5.0.0 ${PKGPINPRIO:-999}
testsuccessequal "base-files:
Installed: 5.0.0-1
Candidate: 5.0.0
- ${PKGPIN}Version table:
+ Version table:
*** 5.0.0-1 100
100 $STATUS
5.0.0 ${PKGPINPRIO:-1000}
local AB="$3"
local AS="$4"
local PB="$5"
- local PINVERSION="$6"
- if [ -n "$PINVERSION" ]; then
- PINVERSION="Package pin: $PINVERSION
- "
- fi
local IS=""
local IB=""
local SB=""
testsuccessequal "coolstuff:
Installed: $INSTALLED
Candidate: $CANDIDATE
- ${PINVERSION}Version table:${BPO2ARCHIVE}
+ Version table:${BPO2ARCHIVE}
$IB 2.0~bpo1 $PB
${BPO1ARCHIVE}$SB
$IS 1.0 $AS