* [devel] [PATCH for apt 01/38] Replace post-increments with pre-increments
2019-12-10 15:23 [devel] [PATCH for apt 00/38] Various fixes for Apt and basic integration test suite Aleksei Nikiforov
@ 2019-12-10 15:23 ` Aleksei Nikiforov
2019-12-10 18:21 ` Alexey Tourbin
2019-12-10 15:23 ` [devel] [PATCH for apt 02/38] Use correct types and type specifiers Aleksei Nikiforov
` (36 subsequent siblings)
37 siblings, 1 reply; 84+ messages in thread
From: Aleksei Nikiforov @ 2019-12-10 15:23 UTC (permalink / raw)
To: devel; +Cc: Aleksei Nikiforov
Found via cppcheck
---
apt/apt-pkg/acquire-item.cc | 4 ++--
apt/apt-pkg/contrib/configuration.cc | 2 +-
apt/apt-pkg/orderlist.cc | 8 ++++----
apt/apt-pkg/packagemanager.cc | 12 ++++++------
apt/apt-pkg/pkgcachegen.cc | 8 ++++----
apt/apt-pkg/policy.cc | 6 +++---
apt/apt-pkg/rpm/rpmindexfile.cc | 2 +-
apt/apt-pkg/rpm/rpmpackagedata.cc | 8 ++++----
apt/apt-pkg/rpm/rpmpm.cc | 6 +++---
apt/apt-pkg/sourcelist.cc | 22 +++++++++++-----------
apt/apt-pkg/srcrecords.cc | 4 ++--
apt/apt-pkg/versionmatch.cc | 2 +-
apt/cmdline/apt-cdrom.cc | 20 ++++++++++----------
apt/cmdline/apt-get.cc | 20 +++++++++-----------
apt/cmdline/apt-shell.cc | 6 +++---
apt/cmdline/indexcopy.cc | 4 ++--
apt/cmdline/rpmindexcopy.cc | 4 ++--
apt/methods/ftp.cc | 2 +-
apt/methods/http.cc | 10 +++++-----
19 files changed, 74 insertions(+), 76 deletions(-)
diff --git a/apt/apt-pkg/acquire-item.cc b/apt/apt-pkg/acquire-item.cc
index 9325c53..61592c8 100644
--- a/apt/apt-pkg/acquire-item.cc
+++ b/apt/apt-pkg/acquire-item.cc
@@ -486,7 +486,7 @@ void pkgAcqIndexRel::Done(const string &Message,unsigned long long Size,const st
bool found = false;
for (vector<string>::const_iterator I = Repository->FingerPrint.begin();
- I != Repository->FingerPrint.end(); I++)
+ I != Repository->FingerPrint.end(); ++I)
{
// Match fingerprint of Release file
if ((*I) == FingerPrint)
@@ -501,7 +501,7 @@ void pkgAcqIndexRel::Done(const string &Message,unsigned long long Size,const st
Status = StatError;
ErrorText = _("Signature fingerprint of Release file does not match (expected ");
for (vector<string>::const_iterator I = Repository->FingerPrint.begin();
- I != Repository->FingerPrint.end(); I++)
+ I != Repository->FingerPrint.end(); ++I)
ErrorText += "\n"+(*I);
ErrorText += _(", got ")+FingerPrint+")";
return;
diff --git a/apt/apt-pkg/contrib/configuration.cc b/apt/apt-pkg/contrib/configuration.cc
index 59ee122..214babc 100644
--- a/apt/apt-pkg/contrib/configuration.cc
+++ b/apt/apt-pkg/contrib/configuration.cc
@@ -809,7 +809,7 @@ bool ReadConfigDir(Configuration &Conf,const string &Dir,bool AsSectional,
sort(List.begin(),List.end());
// Read the files
- for (vector<string>::const_iterator I = List.begin(); I != List.end(); I++)
+ for (vector<string>::const_iterator I = List.begin(); I != List.end(); ++I)
if (ReadConfigFile(Conf,*I,AsSectional,Depth) == false)
return false;
return true;
diff --git a/apt/apt-pkg/orderlist.cc b/apt/apt-pkg/orderlist.cc
index f6081b3..d96a263 100644
--- a/apt/apt-pkg/orderlist.cc
+++ b/apt/apt-pkg/orderlist.cc
@@ -148,13 +148,13 @@ bool pkgOrderList::DoRun()
Depth = 0;
WipeFlags(Added | AddPending | Loop | InList);
- for (iterator I = List; I != End; I++)
+ for (iterator I = List; I != End; ++I)
Flag(*I,InList);
// Rebuild the main list into the temp list.
iterator OldEnd = End;
End = NList;
- for (iterator I = List; I != OldEnd; I++)
+ for (iterator I = List; I != OldEnd; ++I)
if (VisitNode(PkgIterator(Cache,*I)) == false)
{
End = OldEnd;
@@ -212,7 +212,7 @@ bool pkgOrderList::OrderUnpack(string *FileList)
WipeFlags(After);
// Set the inlist flag
- for (iterator I = List; I != End; I++)
+ for (iterator I = List; I != End; ++I)
{
PkgIterator P(Cache,*I);
if (IsMissing(P) == true && IsNow(P) == true)
@@ -260,7 +260,7 @@ bool pkgOrderList::OrderUnpack(string *FileList)
{
clog << "** Unpack ordering done" << endl;
- for (iterator I = List; I != End; I++)
+ for (iterator I = List; I != End; ++I)
{
PkgIterator P(Cache,*I);
if (IsNow(P) == true)
diff --git a/apt/apt-pkg/packagemanager.cc b/apt/apt-pkg/packagemanager.cc
index c269d0c..0bcd902 100644
--- a/apt/apt-pkg/packagemanager.cc
+++ b/apt/apt-pkg/packagemanager.cc
@@ -65,7 +65,7 @@ bool pkgPackageManager::GetArchives(pkgAcquire *Owner,pkgSourceList *Sources,
if (List->OrderUnpack() == false)
return _error->Error("Internal ordering error");
- for (pkgOrderList::iterator I = List->begin(); I != List->end(); I++)
+ for (pkgOrderList::iterator I = List->begin(); I != List->end(); ++I)
{
PkgIterator Pkg(Cache,*I);
FileNames[Pkg->ID] = string();
@@ -236,7 +236,7 @@ bool pkgPackageManager::ConfigureAll()
pkgOrderList OList(&Cache);
// Populate the order list
- for (pkgOrderList::iterator I = List->begin(); I != List->end(); I++)
+ for (pkgOrderList::iterator I = List->begin(); I != List->end(); ++I)
if (List->IsFlag(pkgCache::PkgIterator(Cache,*I),
pkgOrderList::UnPacked) == true)
OList.push_back(*I);
@@ -245,7 +245,7 @@ bool pkgPackageManager::ConfigureAll()
return false;
// Perform the configuring
- for (pkgOrderList::iterator I = OList.begin(); I != OList.end(); I++)
+ for (pkgOrderList::iterator I = OList.begin(); I != OList.end(); ++I)
{
PkgIterator Pkg(Cache,*I);
@@ -273,7 +273,7 @@ bool pkgPackageManager::SmartConfigure(PkgIterator Pkg)
return false;
// Perform the configuring
- for (pkgOrderList::iterator I = OList.begin(); I != OList.end(); I++)
+ for (pkgOrderList::iterator I = OList.begin(); I != OList.end(); ++I)
{
PkgIterator Pkg(Cache,*I);
@@ -593,7 +593,7 @@ pkgPackageManager::OrderResult pkgPackageManager::OrderInstall()
clog << "Done ordering" << endl;
bool DoneSomething = false;
- for (pkgOrderList::iterator I = List->begin(); I != List->end(); I++)
+ for (pkgOrderList::iterator I = List->begin(); I != List->end(); ++I)
{
PkgIterator Pkg(Cache,*I);
@@ -648,7 +648,7 @@ pkgPackageManager::OrderResult pkgPackageManager::OrderInstall()
return Failed;
// Sanity check
- for (pkgOrderList::iterator I = List->begin(); I != List->end(); I++)
+ for (pkgOrderList::iterator I = List->begin(); I != List->end(); ++I)
{
if (List->IsFlag(*I,pkgOrderList::Configured) == false)
{
diff --git a/apt/apt-pkg/pkgcachegen.cc b/apt/apt-pkg/pkgcachegen.cc
index 56716b5..654c81c 100644
--- a/apt/apt-pkg/pkgcachegen.cc
+++ b/apt/apt-pkg/pkgcachegen.cc
@@ -802,7 +802,7 @@ static bool CheckValidity(const string &CacheFile, FileIterator Start,
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);
- for (; Start != End; Start++)
+ for (; Start != End; ++Start)
{
if ((*Start)->HasPackages() == false)
continue;
@@ -845,7 +845,7 @@ static bool CheckValidity(const string &CacheFile, FileIterator Start,
static unsigned long long ComputeSize(FileIterator Start,FileIterator End)
{
unsigned long long TotalSize = 0;
- for (; Start != End; Start++)
+ for (; Start != End; ++Start)
{
if ((*Start)->HasPackages() == false)
continue;
@@ -863,7 +863,7 @@ static bool BuildCache(pkgCacheGenerator &Gen,
FileIterator Start, FileIterator End)
{
FileIterator I;
- for (I = Start; I != End; I++)
+ for (I = Start; I != End; ++I)
{
if ((*I)->HasPackages() == false)
continue;
@@ -913,7 +913,7 @@ static bool CollectFileProvides(pkgCacheGenerator &Gen,
unsigned long long &CurrentSize,unsigned long long TotalSize,
FileIterator Start, FileIterator End)
{
- for (FileIterator I = Start; I != End; I++)
+ for (FileIterator I = Start; I != End; ++I)
{
if ((*I)->HasPackages() == false || (*I)->Exists() == false)
continue;
diff --git a/apt/apt-pkg/policy.cc b/apt/apt-pkg/policy.cc
index 80722ae..ed0938a 100644
--- a/apt/apt-pkg/policy.cc
+++ b/apt/apt-pkg/policy.cc
@@ -86,7 +86,7 @@ bool pkgPolicy::InitDefaults()
signed Cur = 989;
StatusOverride = false;
for (vector<Pin>::const_iterator I = Defaults.begin(); I != Defaults.end();
- I++, Cur--)
+ ++I, --Cur)
{
pkgVersionMatch Match(I->Data,I->Type);
for (pkgCache::PkgFileIterator F = Cache->FileBegin(); F != Cache->FileEnd(); F++)
@@ -197,7 +197,7 @@ void pkgPolicy::CreatePin(pkgVersionMatch::MatchType Type, const string &Name,
{
// Check the unmatched table
for (vector<PkgPin>::iterator I = Unmatched.begin();
- I != Unmatched.end() && P == 0; I++)
+ I != Unmatched.end() && P == 0; ++I)
if (I->Pkg == Name)
P = &*I;
@@ -343,7 +343,7 @@ bool ReadPinDir(pkgPolicy &Plcy,string Dir)
sort(List.begin(),List.end());
// Read the files
- for (vector<string>::const_iterator I = List.begin(); I != List.end(); I++)
+ for (vector<string>::const_iterator I = List.begin(); I != List.end(); ++I)
if (ReadPinFile(Plcy, *I) == false)
return false;
return true;
diff --git a/apt/apt-pkg/rpm/rpmindexfile.cc b/apt/apt-pkg/rpm/rpmindexfile.cc
index 5ccd5fe..b4523b9 100644
--- a/apt/apt-pkg/rpm/rpmindexfile.cc
+++ b/apt/apt-pkg/rpm/rpmindexfile.cc
@@ -648,7 +648,7 @@ class rpmSLTypeGen : public pkgSourceList::Type
const pkgSourceList::Vendor *Vendor) const
{
for (vector<pkgRepository *>::const_iterator iter = RepList.begin();
- iter != RepList.end(); iter++)
+ iter != RepList.end(); ++iter)
{
if ((*iter)->URI == URI && (*iter)->Dist == Dist)
{
diff --git a/apt/apt-pkg/rpm/rpmpackagedata.cc b/apt/apt-pkg/rpm/rpmpackagedata.cc
index 98eb5e3..186a146 100644
--- a/apt/apt-pkg/rpm/rpmpackagedata.cc
+++ b/apt/apt-pkg/rpm/rpmpackagedata.cc
@@ -222,7 +222,7 @@ RPMPackageData::RPMPackageData()
bool RPMPackageData::HoldPackage(const char *name)
{
for (vector<regex_t*>::iterator I = HoldPackages.begin();
- I != HoldPackages.end(); I++)
+ I != HoldPackages.end(); ++I)
if (regexec(*I,name,0,0,0) == 0)
return true;
return false;
@@ -237,7 +237,7 @@ bool RPMPackageData::IgnoreDep(pkgVersioningSystem &VS,
if (VerList == NULL)
return true;
for (vector<string>::iterator I = VerList->begin();
- I != VerList->end(); I++)
+ I != VerList->end(); ++I)
{
if (VS.CheckDep(I->c_str(),Dep->CompareOp,Dep.TargetVer()) == true)
return true;
@@ -276,7 +276,7 @@ void RPMPackageData::GenericTranslate(vector<Translate*> &TList,
map<string,string> &Dict)
{
const char *fulluri = FullURI.c_str();
- for (vector<Translate*>::iterator I = TList.begin(); I != TList.end(); I++)
+ for (vector<Translate*>::iterator I = TList.begin(); I != TList.end(); ++I)
{
if (regexec(&(*I)->Pattern,fulluri,0,0,0) == 0)
{
@@ -323,7 +323,7 @@ bool RPMPackageData::IsDupPackage(const string &Name)
return true;
const char *name = Name.c_str();
for (vector<regex_t*>::iterator I = DuplicatedPatterns.begin();
- I != DuplicatedPatterns.end(); I++) {
+ I != DuplicatedPatterns.end(); ++I) {
if (regexec(*I,name,0,0,0) == 0) {
SetDupPackage(Name);
return true;
diff --git a/apt/apt-pkg/rpm/rpmpm.cc b/apt/apt-pkg/rpm/rpmpm.cc
index e00630f..eb14363 100644
--- a/apt/apt-pkg/rpm/rpmpm.cc
+++ b/apt/apt-pkg/rpm/rpmpm.cc
@@ -241,7 +241,7 @@ bool pkgRPMPM::RunScriptsWithPkgs(const char *Cnf)
FileFd Fd(Pipes[1]);
// Feed it the filenames.
- for (vector<Item>::iterator I = List.begin(); I != List.end(); I++)
+ for (vector<Item>::iterator I = List.begin(); I != List.end(); ++I)
{
// Only deal with packages to be installed from .rpm
if (I->Op != Item::Install)
@@ -298,7 +298,7 @@ bool pkgRPMPM::Go()
vector<char*> unalloc;
- for (vector<Item>::iterator I = List.begin(); I != List.end(); I++)
+ for (vector<Item>::iterator I = List.begin(); I != List.end(); ++I)
{
string Name = I->Pkg.Name();
string::size_type loc;
@@ -391,7 +391,7 @@ bool pkgRPMPM::Go()
Ret = RunScripts("RPM::Post-Invoke");
exit:
- for (vector<char *>::iterator I = unalloc.begin(); I != unalloc.end(); I++)
+ for (vector<char *>::iterator I = unalloc.begin(); I != unalloc.end(); ++I)
free(*I);
return Ret;
diff --git a/apt/apt-pkg/sourcelist.cc b/apt/apt-pkg/sourcelist.cc
index 7e2eb36..f2fbe21 100644
--- a/apt/apt-pkg/sourcelist.cc
+++ b/apt/apt-pkg/sourcelist.cc
@@ -149,10 +149,10 @@ pkgSourceList::pkgSourceList(const string &File)
/* */
pkgSourceList::~pkgSourceList()
{
- for (const_iterator I = SrcList.begin(); I != SrcList.end(); I++)
+ for (const_iterator I = SrcList.begin(); I != SrcList.end(); ++I)
delete *I;
for (vector<Vendor *>::iterator I = VendorList.begin();
- I != VendorList.end(); I++)
+ I != VendorList.end(); ++I)
delete *I;
}
/*}}}*/
@@ -176,7 +176,7 @@ bool pkgSourceList::ReadVendors()
return false;
for (vector<Vendor *>::iterator I = VendorList.begin();
- I != VendorList.end(); I++)
+ I != VendorList.end(); ++I)
delete *I;
VendorList.erase(VendorList.begin(),VendorList.end());
@@ -190,7 +190,7 @@ bool pkgSourceList::ReadVendors()
bool New = true;
for (vector<pkgSourceList::Vendor *>::iterator I = VendorList.begin();
- I != VendorList.end(); I++)
+ I != VendorList.end(); ++I)
{
if ((*I)->VendorID == Group)
{
@@ -213,7 +213,7 @@ bool pkgSourceList::ReadVendors()
char *buffer = new char[FingerPrint.length()+1];
char *p = buffer;;
for (string::const_iterator I = FingerPrint.begin();
- I != FingerPrint.end(); I++)
+ I != FingerPrint.end(); ++I)
{
if (*I != ' ' && *I != '\t')
*p++ = *I;
@@ -292,7 +292,7 @@ bool pkgSourceList::ReadMainList()
/* */
void pkgSourceList::Reset()
{
- for (const_iterator I = SrcList.begin(); I != SrcList.end(); I++)
+ for (const_iterator I = SrcList.begin(); I != SrcList.end(); ++I)
delete *I;
SrcList.erase(SrcList.begin(),SrcList.end());
// CNC:2003-11-21
@@ -374,7 +374,7 @@ bool pkgSourceList::ReadAppend(const string &File)
VendorID = string(VendorID,1,VendorID.size()-2);
for (vector<Vendor *>::iterator iter = VendorList.begin();
- iter != VendorList.end(); iter++)
+ iter != VendorList.end(); ++iter)
{
if ((*iter)->VendorID == VendorID)
{
@@ -400,7 +400,7 @@ bool pkgSourceList::ReadAppend(const string &File)
bool pkgSourceList::FindIndex(pkgCache::PkgFileIterator File,
pkgIndexFile *&Found) const
{
- for (const_iterator I = SrcList.begin(); I != SrcList.end(); I++)
+ for (const_iterator I = SrcList.begin(); I != SrcList.end(); ++I)
{
if ((*I)->FindInCache(*File.Cache()) == File)
{
@@ -417,7 +417,7 @@ bool pkgSourceList::FindIndex(pkgCache::PkgFileIterator File,
/* */
bool pkgSourceList::GetIndexes(pkgAcquire *Owner) const
{
- for (const_iterator I = SrcList.begin(); I != SrcList.end(); I++)
+ for (const_iterator I = SrcList.begin(); I != SrcList.end(); ++I)
if ((*I)->GetIndexes(Owner) == false)
return false;
return true;
@@ -429,7 +429,7 @@ bool pkgSourceList::GetIndexes(pkgAcquire *Owner) const
/* */
bool pkgSourceList::GetReleases(pkgAcquire *Owner) const
{
- for (const_iterator I = SrcList.begin(); I != SrcList.end(); I++)
+ for (const_iterator I = SrcList.begin(); I != SrcList.end(); ++I)
if ((*I)->GetReleases(Owner) == false)
return false;
return true;
@@ -479,7 +479,7 @@ bool pkgSourceList::ReadSourceDir(const string &Dir)
sort(List.begin(),List.end());
// Read the files
- for (vector<string>::const_iterator I = List.begin(); I != List.end(); I++)
+ for (vector<string>::const_iterator I = List.begin(); I != List.end(); ++I)
if (ReadAppend(*I) == false)
return false;
return true;
diff --git a/apt/apt-pkg/srcrecords.cc b/apt/apt-pkg/srcrecords.cc
index 0a5483a..00e4f3c 100644
--- a/apt/apt-pkg/srcrecords.cc
+++ b/apt/apt-pkg/srcrecords.cc
@@ -34,7 +34,7 @@ pkgSrcRecords::pkgSrcRecords(pkgSourceList &List) : Files(0), Current(0)
unsigned int Count = 0;
pkgSourceList::const_iterator I = List.begin();
- for (; I != List.end(); I++)
+ for (; I != List.end(); ++I)
{
Files[Count] = (*I)->CreateSrcParser();
if (_error->PendingError() == true)
@@ -119,7 +119,7 @@ pkgSrcRecords::Parser *pkgSrcRecords::Find(const char *Package,bool SrcOnly)
vector<pkgSrcRecords::File> Files;
if ((*Current)->Files(Files) == true) {
vector<pkgSrcRecords::File>::const_iterator I = Files.begin();
- for (; I != Files.end(); I++) {
+ for (; I != Files.end(); ++I) {
if (flNotDir(I->Path) == flNotDir(Package))
return *Current;
}
diff --git a/apt/apt-pkg/versionmatch.cc b/apt/apt-pkg/versionmatch.cc
index 6a6f4f6..360e0f3 100644
--- a/apt/apt-pkg/versionmatch.cc
+++ b/apt/apt-pkg/versionmatch.cc
@@ -63,7 +63,7 @@ pkgVersionMatch::pkgVersionMatch(const string &Data,MatchType Type,int Op) : Ver
// Are we a simple specification?
string::const_iterator I = Data.begin();
- for (; I != Data.end() && *I != '='; I++);
+ for (; I != Data.end() && *I != '='; ++I);
if (I == Data.end())
{
// Temporary
diff --git a/apt/cmdline/apt-cdrom.cc b/apt/cmdline/apt-cdrom.cc
index 8ba9174..eded525 100644
--- a/apt/cmdline/apt-cdrom.cc
+++ b/apt/cmdline/apt-cdrom.cc
@@ -317,7 +317,7 @@ void ReduceSourcelist(const string &CD,vector<string> &List)
sort(List.begin(),List.end());
// Collect similar entries
- for (vector<string>::iterator I = List.begin(); I != List.end(); I++)
+ for (vector<string>::iterator I = List.begin(); I != List.end(); ++I)
{
// Find a space..
string::size_type Space = (*I).find(' ');
@@ -329,7 +329,7 @@ void ReduceSourcelist(const string &CD,vector<string> &List)
string Word1 = string(*I,Space,SSpace-Space);
string Prefix = string(*I,0,Space);
- for (vector<string>::iterator J = List.begin(); J != I; J++)
+ for (vector<string>::iterator J = List.begin(); J != I; ++J)
{
// Find a space..
string::size_type Space2 = (*J).find(' ');
@@ -467,7 +467,7 @@ bool WriteSourceList(const string &Name,vector<string> &List,bool Source)
if (First == true)
{
- for (vector<string>::iterator I = List.begin(); I != List.end(); I++)
+ for (vector<string>::iterator I = List.begin(); I != List.end(); ++I)
{
string::size_type Space = (*I).find(' ');
if (Space == string::npos)
@@ -501,7 +501,7 @@ bool WriteSourceList(const string &Name,vector<string> &List,bool Source)
// Just in case the file was empty
if (First == true)
{
- for (vector<string>::iterator I = List.begin(); I != List.end(); I++)
+ for (vector<string>::iterator I = List.begin(); I != List.end(); ++I)
{
string::size_type Space = (*I).find(' ');
if (Space == string::npos)
@@ -641,10 +641,10 @@ bool DoAdd(CommandLine &)
if (_config->FindB("Debug::aptcdrom",false) == true)
{
cout << _("I found (binary):") << endl;
- for (vector<string>::iterator I = List.begin(); I != List.end(); I++)
+ for (vector<string>::iterator I = List.begin(); I != List.end(); ++I)
cout << *I << endl;
cout << _("I found (source):") << endl;
- for (vector<string>::iterator I = sList.begin(); I != sList.end(); I++)
+ for (vector<string>::iterator I = sList.begin(); I != sList.end(); ++I)
cout << *I << endl;
}
@@ -686,7 +686,7 @@ bool DoAdd(CommandLine &)
{
// Escape special characters
string::iterator J = Name.begin();
- for (; J != Name.end(); J++)
+ for (; J != Name.end(); ++J)
if (*J == '"' || *J == ']' || *J == '[')
*J = '_';
@@ -717,7 +717,7 @@ bool DoAdd(CommandLine &)
// Escape special characters
string::iterator J = Name.begin();
- for (; J != Name.end(); J++)
+ for (; J != Name.end(); ++J)
if (*J == '"' || *J == ']' || *J == '[')
*J = '_';
@@ -756,7 +756,7 @@ bool DoAdd(CommandLine &)
// Print the sourcelist entries
cout << _("Source List entries for this Media are:") << endl;
- for (vector<string>::iterator I = List.begin(); I != List.end(); I++)
+ for (vector<string>::iterator I = List.begin(); I != List.end(); ++I)
{
string::size_type Space = (*I).find(' ');
if (Space == string::npos)
@@ -772,7 +772,7 @@ bool DoAdd(CommandLine &)
#endif
}
- for (vector<string>::iterator I = sList.begin(); I != sList.end(); I++)
+ for (vector<string>::iterator I = sList.begin(); I != sList.end(); ++I)
{
string::size_type Space = (*I).find(' ');
if (Space == string::npos)
diff --git a/apt/cmdline/apt-get.cc b/apt/cmdline/apt-get.cc
index a26c93c..3858752 100644
--- a/apt/cmdline/apt-get.cc
+++ b/apt/cmdline/apt-get.cc
@@ -541,8 +541,7 @@ bool DownloadPackages(vector<string> &URLLst)
pkgAcquire Fetcher(&Stat);
// Load the requestd sources into the fetcher
- vector<string>::const_iterator I = URLLst.begin();
- for (; I != URLLst.end(); I++)
+ for (auto I = URLLst.begin(); I != URLLst.end(); ++I)
new pkgAcqFile(&Fetcher,*I,"",0,*I,flNotDir(*I));
// Run it
@@ -551,7 +550,7 @@ bool DownloadPackages(vector<string> &URLLst)
// Print error messages
bool Failed = false;
- for (pkgAcquire::ItemIterator I = Fetcher.ItemsBegin(); I != Fetcher.ItemsEnd(); I++)
+ for (auto I = Fetcher.ItemsBegin(); I != Fetcher.ItemsEnd(); ++I)
{
if ((*I)->Status == pkgAcquire::Item::StatDone &&
(*I)->Complete == true)
@@ -1407,7 +1406,7 @@ bool DoInstall(CommandLine &CmdL)
// Run over the matches
bool Hit = false;
for (vector<string>::const_iterator I = VS.begin();
- I != VS.end(); I++) {
+ I != VS.end(); ++I) {
Pkg = Cache->FindPkg(*I);
if (Pkg.end() == true)
@@ -1721,8 +1720,7 @@ bool DoDSelectUpgrade(CommandLine &CmdL)
return false;
// Install everything with the install flag set
- pkgCache::PkgIterator I = Cache->PkgBegin();
- for (;I.end() != true; I++)
+ for (auto I = Cache->PkgBegin(); not I.end(); ++I)
{
/* Install the package only if it is a new install, the autoupgrader
will deal with the rest */
@@ -1732,7 +1730,7 @@ bool DoDSelectUpgrade(CommandLine &CmdL)
/* Now install their deps too, if we do this above then order of
the status file is significant for | groups */
- for (I = Cache->PkgBegin();I.end() != true; I++)
+ for (auto I = Cache->PkgBegin(); not I.end(); ++I)
{
/* Install the package only if it is a new install, the autoupgrader
will deal with the rest */
@@ -1741,7 +1739,7 @@ bool DoDSelectUpgrade(CommandLine &CmdL)
}
// Apply erasures now, they override everything else.
- for (I = Cache->PkgBegin();I.end() != true; I++)
+ for (auto I = Cache->PkgBegin(); not I.end(); ++I)
{
// Remove packages
if (I->SelectedState == pkgCache::State::DeInstall ||
@@ -1758,7 +1756,7 @@ bool DoDSelectUpgrade(CommandLine &CmdL)
// Hold back held packages.
if (_config->FindB("APT::Ignore-Hold",false) == false)
{
- for (pkgCache::PkgIterator I = Cache->PkgBegin(); I.end() == false; I++)
+ for (auto I = Cache->PkgBegin(); not I.end(); ++I)
{
if (I->SelectedState == pkgCache::State::Hold)
{
@@ -1949,7 +1947,7 @@ bool DoSource(CommandLine &CmdL)
// Load them into the fetcher
for (vector<pkgSrcRecords::File>::const_iterator I = Lst.begin();
- I != Lst.end(); I++)
+ I != Lst.end(); ++I)
{
// Try to guess what sort of file it is we are getting.
// CNC:2002-07-06
@@ -2225,7 +2223,7 @@ bool DoBuildDep(CommandLine &CmdL)
vector <pkgSrcRecords::Parser::BuildDepRec>::iterator D;
pkgProblemResolver Fix(Cache);
bool skipAlternatives = false; // skip remaining alternatives in an or group
- for (D = BuildDeps.begin(); D != BuildDeps.end(); D++)
+ for (D = BuildDeps.begin(); D != BuildDeps.end(); ++D)
{
bool hasAlternatives = (((*D).Op & pkgCache::Dep::Or) == pkgCache::Dep::Or);
diff --git a/apt/cmdline/apt-shell.cc b/apt/cmdline/apt-shell.cc
index 9582291..0aa5da5 100644
--- a/apt/cmdline/apt-shell.cc
+++ b/apt/cmdline/apt-shell.cc
@@ -1318,7 +1318,7 @@ bool DoInstall(CommandLine &CmdL)
// Run over the matches
bool Hit = false;
for (vector<string>::const_iterator I = VS.begin();
- I != VS.end(); I++) {
+ I != VS.end(); ++I) {
Pkg = Cache->FindPkg(*I);
if (Pkg.end() == true)
@@ -1776,7 +1776,7 @@ bool DoBuildDep(CommandLine &CmdL)
vector <pkgSrcRecords::Parser::BuildDepRec>::iterator D;
pkgProblemResolver Fix(Cache);
bool skipAlternatives = false; // skip remaining alternatives in an or group
- for (D = BuildDeps.begin(); D != BuildDeps.end(); D++)
+ for (D = BuildDeps.begin(); D != BuildDeps.end(); ++D)
{
bool hasAlternatives = (((*D).Op & pkgCache::Dep::Or) == pkgCache::Dep::Or);
@@ -3034,7 +3034,7 @@ bool DoList(CommandLine &CmdL)
string status = "available";
if (Pkg->CurrentVer != 0) status = "installed";
if (Pkg->CurrentVer != 0)
- for (pkgCache::DepIterator D = Pkg.RevDependsList(); D.end() == false; D++)
+ for (pkgCache::DepIterator D = Pkg.RevDependsList(); not D.end(); ++D)
{
pkgCache::PkgIterator P = D.ParentPkg();
if ((P->Flags & pkgCache::Flag::Essential) != pkgCache::Flag::Essential &&
diff --git a/apt/cmdline/indexcopy.cc b/apt/cmdline/indexcopy.cc
index fb2c7ef..64a9c1d 100644
--- a/apt/cmdline/indexcopy.cc
+++ b/apt/cmdline/indexcopy.cc
@@ -43,7 +43,7 @@ bool IndexCopy::CopyPackages(const string &CDROM,const string &Name,vector<strin
// Prepare the progress indicator
unsigned long long TotalSize = 0;
- for (vector<string>::iterator I = List.begin(); I != List.end(); I++)
+ for (vector<string>::iterator I = List.begin(); I != List.end(); ++I)
{
struct stat Buf;
if (stat(string(*I + GetFileName()).c_str(),&Buf) != 0 &&
@@ -57,7 +57,7 @@ bool IndexCopy::CopyPackages(const string &CDROM,const string &Name,vector<strin
unsigned int NotFound = 0;
unsigned int WrongSize = 0;
unsigned int Packages = 0;
- for (vector<string>::iterator I = List.begin(); I != List.end(); I++)
+ for (vector<string>::iterator I = List.begin(); I != List.end(); ++I)
{
string OrigPath = string(*I,CDROM.length());
unsigned long FileSize = 0;
diff --git a/apt/cmdline/rpmindexcopy.cc b/apt/cmdline/rpmindexcopy.cc
index 744af1f..9604d4b 100644
--- a/apt/cmdline/rpmindexcopy.cc
+++ b/apt/cmdline/rpmindexcopy.cc
@@ -53,7 +53,7 @@ bool RPMIndexCopy::CopyPackages(const string &CDROM,const string &Name,vector<st
// Prepare the progress indicator
unsigned long long TotalSize = 0;
- for (vector<string>::iterator I = List.begin(); I != List.end(); I++)
+ for (vector<string>::iterator I = List.begin(); I != List.end(); ++I)
{
struct stat Buf;
if (stat((*I).c_str(),&Buf) != 0)
@@ -67,7 +67,7 @@ bool RPMIndexCopy::CopyPackages(const string &CDROM,const string &Name,vector<st
// Keep track of global release processing
map<string,bool> GlobalReleases;
- for (vector<string>::iterator I = List.begin(); I != List.end(); I++)
+ for (vector<string>::iterator I = List.begin(); I != List.end(); ++I)
{
string OrigPath = string(*I,CDROM.length());
unsigned long long FileSize = 0;
diff --git a/apt/methods/ftp.cc b/apt/methods/ftp.cc
index 97d81d5..953febf 100644
--- a/apt/methods/ftp.cc
+++ b/apt/methods/ftp.cc
@@ -560,7 +560,7 @@ bool FTPConn::ExtGoPasv()
string::const_iterator List[4];
unsigned Count = 0;
Pos++;
- for (string::const_iterator I = Msg.begin() + Pos; I < Msg.end(); I++)
+ for (string::const_iterator I = Msg.begin() + Pos; I < Msg.end(); ++I)
{
if (*I != Msg[Pos])
continue;
diff --git a/apt/methods/http.cc b/apt/methods/http.cc
index dcdd651..da3e646 100644
--- a/apt/methods/http.cc
+++ b/apt/methods/http.cc
@@ -383,10 +383,10 @@ int ServerState::RunHeaders()
if (Debug == true)
clog << Data;
- for (string::const_iterator I = Data.begin(); I < Data.end(); I++)
+ for (string::const_iterator I = Data.begin(); I != Data.end(); ++I)
{
string::const_iterator J = I;
- for (; J != Data.end() && *J != '\n' && *J != '\r';J++);
+ for (; J != Data.end() && *J != '\n' && *J != '\r';++J);
if (HeaderLine(string(I,J)) == false)
return 2;
I = J;
@@ -937,7 +937,7 @@ int HttpMethod::DealWithHeaders(FetchResult &Res,ServerState *Srv)
if (ParsedURI.User.empty())
{
for (CurrentAuth = AuthList.begin(); CurrentAuth != AuthList.end();
- CurrentAuth++)
+ ++CurrentAuth)
if (CurrentAuth->Host == Srv->ServerName.Host)
{
AuthUser = CurrentAuth->User;
@@ -968,7 +968,7 @@ int HttpMethod::DealWithHeaders(FetchResult &Res,ServerState *Srv)
NewAuthInfo.Password = AuthPass;
for (CurrentAuth = AuthList.begin(); CurrentAuth != AuthList.end();
- CurrentAuth++)
+ ++CurrentAuth)
if (CurrentAuth->Host == Srv->ServerName.Host)
{
*CurrentAuth = NewAuthInfo;
@@ -1345,7 +1345,7 @@ int HttpMethod::Loop()
StopRedirects = true;
else
{
- for (StringVectorIterator I = R.begin(); I != R.end(); I++)
+ for (StringVectorIterator I = R.begin(); I != R.end(); ++I)
if (Queue->Uri == *I)
{
R[0] = "STOP";
--
2.24.0
^ permalink raw reply [flat|nested] 84+ messages in thread
* Re: [devel] [PATCH for apt 01/38] Replace post-increments with pre-increments
2019-12-10 15:23 ` [devel] [PATCH for apt 01/38] Replace post-increments with pre-increments Aleksei Nikiforov
@ 2019-12-10 18:21 ` Alexey Tourbin
2019-12-11 7:51 ` Aleksei Nikiforov
0 siblings, 1 reply; 84+ messages in thread
From: Alexey Tourbin @ 2019-12-10 18:21 UTC (permalink / raw)
To: ALT Linux Team development discussions
On Tue, Dec 10, 2019 at 6:25 PM Aleksei Nikiforov
<darktemplar@altlinux.org> wrote:
> +++ b/apt/apt-pkg/acquire-item.cc
> @@ -486,7 +486,7 @@ void pkgAcqIndexRel::Done(const string &Message,unsigned long long Size,const st
>
> bool found = false;
> for (vector<string>::const_iterator I = Repository->FingerPrint.begin();
> - I != Repository->FingerPrint.end(); I++)
> + I != Repository->FingerPrint.end(); ++I)
> {
> // Match fingerprint of Release file
> if ((*I) == FingerPrint)
How does that fix anything? It doesn't! Avoid unnecessary changes,
only make those beaming with thought. As Pouchkine wrote, "strashisya
uchasti bessmyslennykh pevtsov".
^ permalink raw reply [flat|nested] 84+ messages in thread
* Re: [devel] [PATCH for apt 01/38] Replace post-increments with pre-increments
2019-12-10 18:21 ` Alexey Tourbin
@ 2019-12-11 7:51 ` Aleksei Nikiforov
2019-12-11 8:11 ` Aleksei Nikiforov
0 siblings, 1 reply; 84+ messages in thread
From: Aleksei Nikiforov @ 2019-12-11 7:51 UTC (permalink / raw)
To: devel
10.12.2019 21:21, Alexey Tourbin пишет:
> On Tue, Dec 10, 2019 at 6:25 PM Aleksei Nikiforov
> <darktemplar@altlinux.org> wrote:
>> +++ b/apt/apt-pkg/acquire-item.cc
>> @@ -486,7 +486,7 @@ void pkgAcqIndexRel::Done(const string &Message,unsigned long long Size,const st
>>
>> bool found = false;
>> for (vector<string>::const_iterator I = Repository->FingerPrint.begin();
>> - I != Repository->FingerPrint.end(); I++)
>> + I != Repository->FingerPrint.end(); ++I)
>> {
>> // Match fingerprint of Release file
>> if ((*I) == FingerPrint)
>
> How does that fix anything? It doesn't! Avoid unnecessary changes,
> only make those beaming with thought. As Pouchkine wrote, "strashisya
> uchasti bessmyslennykh pevtsov".
You're right, but not the way you think you are :)
In order for this fix to matter, signature of operator++ should be fixed
as well. Currently it's not a standard, and returns not an object copy
or reference to object, but returns void. I'll fix it too and this
change would matter :)
> _______________________________________________
> Devel mailing list
> Devel@lists.altlinux.org
> https://lists.altlinux.org/mailman/listinfo/devel
>
^ permalink raw reply [flat|nested] 84+ messages in thread
* Re: [devel] [PATCH for apt 01/38] Replace post-increments with pre-increments
2019-12-11 7:51 ` Aleksei Nikiforov
@ 2019-12-11 8:11 ` Aleksei Nikiforov
0 siblings, 0 replies; 84+ messages in thread
From: Aleksei Nikiforov @ 2019-12-11 8:11 UTC (permalink / raw)
To: devel
11.12.2019 10:51, Aleksei Nikiforov пишет:
> 10.12.2019 21:21, Alexey Tourbin пишет:
>> On Tue, Dec 10, 2019 at 6:25 PM Aleksei Nikiforov
>> <darktemplar@altlinux.org> wrote:
>>> +++ b/apt/apt-pkg/acquire-item.cc
>>> @@ -486,7 +486,7 @@ void pkgAcqIndexRel::Done(const string
>>> &Message,unsigned long long Size,const st
>>>
>>> bool found = false;
>>> for (vector<string>::const_iterator I =
>>> Repository->FingerPrint.begin();
>>> - I != Repository->FingerPrint.end(); I++)
>>> + I != Repository->FingerPrint.end(); ++I)
>>> {
>>> // Match fingerprint of Release file
>>> if ((*I) == FingerPrint)
>>
>> How does that fix anything? It doesn't! Avoid unnecessary changes,
>> only make those beaming with thought. As Pouchkine wrote, "strashisya
>> uchasti bessmyslennykh pevtsov".
>
> You're right, but not the way you think you are :)
>
> In order for this fix to matter, signature of operator++ should be fixed
> as well. Currently it's not a standard, and returns not an object copy
> or reference to object, but returns void. I'll fix it too and this
> change would matter :)
>
I've re-read contents of this patch, and it includes only operator
changes for standard iterators, so everything is fine with this patch.
Although, unstandard operators from Apt code may be improved as I wrote
in my last message.
As for your original question, switching post-increments to
pre-increments for non-fundamental types (i.e. objects like iterators)
either improves compile-time performance or improves run-time performance.
>> _______________________________________________
>> Devel mailing list
>> Devel@lists.altlinux.org
>> https://lists.altlinux.org/mailman/listinfo/devel
>>
> _______________________________________________
> Devel mailing list
> Devel@lists.altlinux.org
> https://lists.altlinux.org/mailman/listinfo/devel
^ permalink raw reply [flat|nested] 84+ messages in thread
* [devel] [PATCH for apt 02/38] Use correct types and type specifiers
2019-12-10 15:23 [devel] [PATCH for apt 00/38] Various fixes for Apt and basic integration test suite Aleksei Nikiforov
2019-12-10 15:23 ` [devel] [PATCH for apt 01/38] Replace post-increments with pre-increments Aleksei Nikiforov
@ 2019-12-10 15:23 ` Aleksei Nikiforov
2019-12-10 22:45 ` Dmitry V. Levin
2019-12-10 15:23 ` [devel] [PATCH for apt 03/38] Fix potential memory corruption in pkgCache::DepIterator::AllTargets() Aleksei Nikiforov
` (35 subsequent siblings)
37 siblings, 1 reply; 84+ messages in thread
From: Aleksei Nikiforov @ 2019-12-10 15:23 UTC (permalink / raw)
To: devel; +Cc: Aleksei Nikiforov
Found via cppcheck
---
apt/apt-pkg/contrib/cdromutl.cc | 4 ++--
apt/apt-pkg/contrib/strutl.cc | 8 ++++----
apt/cmdline/acqprogress.cc | 4 ++--
apt/methods/connect.cc | 4 ++--
apt/methods/http.cc | 9 +++------
apt/methods/http.h | 2 +-
6 files changed, 14 insertions(+), 17 deletions(-)
diff --git a/apt/apt-pkg/contrib/cdromutl.cc b/apt/apt-pkg/contrib/cdromutl.cc
index 6101145..139be84 100644
--- a/apt/apt-pkg/contrib/cdromutl.cc
+++ b/apt/apt-pkg/contrib/cdromutl.cc
@@ -232,8 +232,8 @@ bool IdentCdrom(const string &CD,string &Res,unsigned int Version)
return _error->Errno("statfs",_("Failed to stat the cdrom"));
// We use a kilobyte block size to advoid overflow
- sprintf(S,"%llu %llu",(long long)(Buf.f_blocks*(Buf.f_bsize/1024)),
- (long long)(Buf.f_bfree*(Buf.f_bsize/1024)));
+ sprintf(S,"%llu %llu",(unsigned long long)(Buf.f_blocks*(Buf.f_bsize/1024)),
+ (unsigned long long)(Buf.f_bfree*(Buf.f_bsize/1024)));
Hash.Add(S);
sprintf(S,"-%u",Version);
}
diff --git a/apt/apt-pkg/contrib/strutl.cc b/apt/apt-pkg/contrib/strutl.cc
index 6131d47..bde4ef5 100644
--- a/apt/apt-pkg/contrib/strutl.cc
+++ b/apt/apt-pkg/contrib/strutl.cc
@@ -292,23 +292,23 @@ string TimeToStr(unsigned long Sec)
{
if (Sec > 60*60*24)
{
- sprintf(S,"%lid %lih%lim%lis",Sec/60/60/24,(Sec/60/60) % 24,(Sec/60) % 60,Sec % 60);
+ sprintf(S,"%lud %luh%lum%lus",Sec/60/60/24,(Sec/60/60) % 24,(Sec/60) % 60,Sec % 60);
break;
}
if (Sec > 60*60)
{
- sprintf(S,"%lih%lim%lis",Sec/60/60,(Sec/60) % 60,Sec % 60);
+ sprintf(S,"%luh%lum%lus",Sec/60/60,(Sec/60) % 60,Sec % 60);
break;
}
if (Sec > 60)
{
- sprintf(S,"%lim%lis",Sec/60,Sec % 60);
+ sprintf(S,"%lum%lus",Sec/60,Sec % 60);
break;
}
- sprintf(S,"%lis",Sec);
+ sprintf(S,"%lus",Sec);
break;
}
diff --git a/apt/cmdline/acqprogress.cc b/apt/cmdline/acqprogress.cc
index 8fa9420..ecf9c2e 100644
--- a/apt/cmdline/acqprogress.cc
+++ b/apt/cmdline/acqprogress.cc
@@ -215,10 +215,10 @@ bool AcqTextStatus::Pulse(pkgAcquire *Owner)
{
if (Mode == Short)
snprintf(S,End-S," %lu%%",
- long(double(I->CurrentSize*100.0)/double(I->TotalSize)));
+ (unsigned long) (double(I->CurrentSize*100.0)/double(I->TotalSize)));
else
snprintf(S,End-S,"/%sB %lu%%",SizeToStr(I->TotalSize).c_str(),
- long(double(I->CurrentSize*100.0)/double(I->TotalSize)));
+ (unsigned long) (double(I->CurrentSize*100.0)/double(I->TotalSize)));
}
S += strlen(S);
snprintf(S,End-S,"]");
diff --git a/apt/methods/connect.cc b/apt/methods/connect.cc
index f086a7e..a25d6b4 100644
--- a/apt/methods/connect.cc
+++ b/apt/methods/connect.cc
@@ -162,7 +162,7 @@ bool Connect(const string &Host,int Port,const char *Service,int DefPort,std::un
// Convert the port name/number
char ServStr[300];
if (Port != 0)
- snprintf(ServStr,sizeof(ServStr),"%u",Port);
+ snprintf(ServStr,sizeof(ServStr),"%u",(unsigned) Port);
else
snprintf(ServStr,sizeof(ServStr),"%s",Service);
@@ -198,7 +198,7 @@ bool Connect(const string &Host,int Port,const char *Service,int DefPort,std::un
{
if (DefPort != 0)
{
- snprintf(ServStr,sizeof(ServStr),"%u",DefPort);
+ snprintf(ServStr,sizeof(ServStr),"%u",(unsigned) DefPort);
DefPort = 0;
continue;
}
diff --git a/apt/methods/http.cc b/apt/methods/http.cc
index da3e646..6d9a642 100644
--- a/apt/methods/http.cc
+++ b/apt/methods/http.cc
@@ -588,7 +588,7 @@ bool ServerState::HeaderLine(const string &Line)
if (sscanf(Val.c_str(),"bytes %llu-%*u/%llu",&StartPos,&Size) != 2)
return _error->Error(_("The http server sent an invalid Content-Range header"));
- if ((unsigned long long)StartPos > Size)
+ if (StartPos > Size)
return _error->Error(_("This http server has broken range support"));
return true;
}
@@ -1016,11 +1016,8 @@ int HttpMethod::DealWithHeaders(FetchResult &Res,ServerState *Srv)
FailTime = Srv->Date;
// Set the expected size
- if (Srv->StartPos >= 0)
- {
- Res.ResumePoint = Srv->StartPos;
- ftruncate(File->Fd(),Srv->StartPos);
- }
+ Res.ResumePoint = Srv->StartPos;
+ ftruncate(File->Fd(),Srv->StartPos);
// Set the start point
lseek(File->Fd(),0,SEEK_END);
diff --git a/apt/methods/http.h b/apt/methods/http.h
index b5c2d68..3b50e73 100644
--- a/apt/methods/http.h
+++ b/apt/methods/http.h
@@ -87,7 +87,7 @@ struct ServerState
// These are some statistics from the last parsed header lines
unsigned long long Size;
- signed long long StartPos;
+ unsigned long long StartPos;
time_t Date;
bool HaveContent;
enum {Chunked,Stream,Closes} Encoding;
--
2.24.0
^ permalink raw reply [flat|nested] 84+ messages in thread
* Re: [devel] [PATCH for apt 02/38] Use correct types and type specifiers
2019-12-10 15:23 ` [devel] [PATCH for apt 02/38] Use correct types and type specifiers Aleksei Nikiforov
@ 2019-12-10 22:45 ` Dmitry V. Levin
2019-12-11 7:56 ` Aleksei Nikiforov
0 siblings, 1 reply; 84+ messages in thread
From: Dmitry V. Levin @ 2019-12-10 22:45 UTC (permalink / raw)
To: ALT Devel discussion list
[-- Attachment #1: Type: text/plain, Size: 613 bytes --]
On Tue, Dec 10, 2019 at 06:23:07PM +0300, Aleksei Nikiforov wrote:
> Found via cppcheck
> ---
> apt/apt-pkg/contrib/cdromutl.cc | 4 ++--
> apt/apt-pkg/contrib/strutl.cc | 8 ++++----
> apt/cmdline/acqprogress.cc | 4 ++--
> apt/methods/connect.cc | 4 ++--
> apt/methods/http.cc | 9 +++------
> apt/methods/http.h | 2 +-
> 6 files changed, 14 insertions(+), 17 deletions(-)
It would be great if you included the cppcheck diagnostics as well,
you can use the following commit as an example:
https://gitlab.com/strace/strace/commit/2b64854e
--
ldv
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 801 bytes --]
^ permalink raw reply [flat|nested] 84+ messages in thread
* Re: [devel] [PATCH for apt 02/38] Use correct types and type specifiers
2019-12-10 22:45 ` Dmitry V. Levin
@ 2019-12-11 7:56 ` Aleksei Nikiforov
2019-12-11 23:48 ` Dmitry V. Levin
0 siblings, 1 reply; 84+ messages in thread
From: Aleksei Nikiforov @ 2019-12-11 7:56 UTC (permalink / raw)
To: devel
11.12.2019 1:45, Dmitry V. Levin пишет:
> On Tue, Dec 10, 2019 at 06:23:07PM +0300, Aleksei Nikiforov wrote:
>> Found via cppcheck
>> ---
>> apt/apt-pkg/contrib/cdromutl.cc | 4 ++--
>> apt/apt-pkg/contrib/strutl.cc | 8 ++++----
>> apt/cmdline/acqprogress.cc | 4 ++--
>> apt/methods/connect.cc | 4 ++--
>> apt/methods/http.cc | 9 +++------
>> apt/methods/http.h | 2 +-
>> 6 files changed, 14 insertions(+), 17 deletions(-)
>
> It would be great if you included the cppcheck diagnostics as well,
> you can use the following commit as an example:
> https://gitlab.com/strace/strace/commit/2b64854e
>
>
So, should such blankets of text be added for each fixed line? Commit
messages would become much bigger than commits themselves in that case
for a lot of commits considering multiline messages and one-line fixes.
Is it really needed considering fixes are already grouped in commits by
type?
>
> _______________________________________________
> Devel mailing list
> Devel@lists.altlinux.org
> https://lists.altlinux.org/mailman/listinfo/devel
>
^ permalink raw reply [flat|nested] 84+ messages in thread
* Re: [devel] [PATCH for apt 02/38] Use correct types and type specifiers
2019-12-11 7:56 ` Aleksei Nikiforov
@ 2019-12-11 23:48 ` Dmitry V. Levin
2019-12-12 9:57 ` [devel] [PATCH for apt v2 00/21] Various fixes for Apt and basic integration test suite Aleksei Nikiforov
0 siblings, 1 reply; 84+ messages in thread
From: Dmitry V. Levin @ 2019-12-11 23:48 UTC (permalink / raw)
To: ALT Devel discussion list
On Wed, Dec 11, 2019 at 10:56:36AM +0300, Aleksei Nikiforov wrote:
> 11.12.2019 1:45, Dmitry V. Levin пишет:
> > On Tue, Dec 10, 2019 at 06:23:07PM +0300, Aleksei Nikiforov wrote:
> >> Found via cppcheck
> >> ---
> >> apt/apt-pkg/contrib/cdromutl.cc | 4 ++--
> >> apt/apt-pkg/contrib/strutl.cc | 8 ++++----
> >> apt/cmdline/acqprogress.cc | 4 ++--
> >> apt/methods/connect.cc | 4 ++--
> >> apt/methods/http.cc | 9 +++------
> >> apt/methods/http.h | 2 +-
> >> 6 files changed, 14 insertions(+), 17 deletions(-)
> >
> > It would be great if you included the cppcheck diagnostics as well,
> > you can use the following commit as an example:
> > https://gitlab.com/strace/strace/commit/2b64854e
>
> So, should such blankets of text be added for each fixed line? Commit
> messages would become much bigger than commits themselves in that case
> for a lot of commits considering multiline messages and one-line fixes.
> Is it really needed considering fixes are already grouped in commits by
> type?
Let's use common sense. If both the bug and the fix are obvious, there is
no need to add anything. Otherwise, group all fixes by the kind of bug
being fixed and include a single diagnostic message, e.g. the first
diagnostic message of the series.
--
ldv
^ permalink raw reply [flat|nested] 84+ messages in thread
* [devel] [PATCH for apt v2 00/21] Various fixes for Apt and basic integration test suite
2019-12-11 23:48 ` Dmitry V. Levin
@ 2019-12-12 9:57 ` Aleksei Nikiforov
2019-12-12 9:57 ` [devel] [PATCH for apt v2 01/21] Replace post-increments with pre-increments Aleksei Nikiforov
` (20 more replies)
0 siblings, 21 replies; 84+ messages in thread
From: Aleksei Nikiforov @ 2019-12-12 9:57 UTC (permalink / raw)
To: devel; +Cc: Aleksei Nikiforov
This patch series updates patches 1-21 from 38 patches,
mostly by updating commit messages.
Remaining 17 patches are still relevant,
I'm just skipping resending them since they're unchanged.
Aleksei Nikiforov (21):
Replace post-increments with pre-increments
Use correct types and type specifiers
Fix potential memory corruption in pkgCache::DepIterator::AllTargets()
Get rid of nullptr dereference
Fix memory access outside of allocated buffer ranges
Get rid of hardcoded array size
Use signed types to detect IO errors
Use 'explicit' keyword for constructors with one argument
Rework identical conditions
Improve member variable initialization
Remove useless variable shadowing
Fortify against buffer overflows
Cacheiterators: sanitize increment operators and end() function
Fix memory leaks
Fix incorrect delete operator
Don't access uninitialized data
Fix access after free error
Apt-pipe: ensure mainloop function doesn't return uninitialized or
garbage value
Don't use uninitialized value
Get rid of dangling invalid pointer
Fix invalid check of Queue against zero
apt/apt-pkg/acquire-item.cc | 4 +-
apt/apt-pkg/acquire-method.cc | 4 +-
apt/apt-pkg/algorithms.cc | 5 ++-
apt/apt-pkg/cacheiterators.h | 22 +++++------
apt/apt-pkg/contrib/cdromutl.cc | 4 +-
apt/apt-pkg/contrib/configuration.cc | 4 +-
apt/apt-pkg/contrib/strutl.cc | 10 ++---
apt/apt-pkg/init.cc | 2 +-
apt/apt-pkg/orderlist.cc | 8 ++--
apt/apt-pkg/packagemanager.cc | 12 +++---
apt/apt-pkg/pkgcache.cc | 48 ++++++++++++++++--------
apt/apt-pkg/pkgcachegen.cc | 8 ++--
apt/apt-pkg/policy.cc | 6 +--
apt/apt-pkg/rpm/rpmindexfile.cc | 2 +-
apt/apt-pkg/rpm/rpmpackagedata.cc | 16 ++++----
apt/apt-pkg/rpm/rpmpm.cc | 8 ++--
apt/apt-pkg/sourcelist.cc | 22 +++++------
apt/apt-pkg/srcrecords.cc | 6 +--
apt/apt-pkg/versionmatch.cc | 2 +-
apt/cmdline/acqprogress.cc | 4 +-
apt/cmdline/apt-cache.cc | 20 ++++++----
apt/cmdline/apt-cdrom.cc | 24 ++++++------
apt/cmdline/apt-get.cc | 44 +++++++++++++---------
apt/cmdline/apt-pipe.c | 7 +++-
apt/cmdline/apt-shell.cc | 56 ++++++++++++++++++----------
apt/cmdline/indexcopy.cc | 4 +-
apt/cmdline/rpmindexcopy.cc | 8 ++--
apt/methods/connect.cc | 4 +-
apt/methods/ftp.cc | 2 +-
apt/methods/ftp.h | 2 +-
apt/methods/gzip.cc | 2 +-
apt/methods/http.cc | 51 +++++++++++++------------
apt/methods/http.h | 9 +++--
apt/methods/rsh.h | 2 +-
apt/methods/rsync-method.h | 5 ++-
apt/methods/rsync.cc | 35 +++++++----------
apt/tools/genpkglist.cc | 12 +++---
apt/tools/gensrclist.cc | 13 +++----
38 files changed, 277 insertions(+), 220 deletions(-)
--
2.24.1
^ permalink raw reply [flat|nested] 84+ messages in thread
* [devel] [PATCH for apt v2 01/21] Replace post-increments with pre-increments
2019-12-12 9:57 ` [devel] [PATCH for apt v2 00/21] Various fixes for Apt and basic integration test suite Aleksei Nikiforov
@ 2019-12-12 9:57 ` Aleksei Nikiforov
2019-12-12 21:32 ` Andrey Savchenko
2019-12-12 9:57 ` [devel] [PATCH for apt v2 02/21] Use correct types and type specifiers Aleksei Nikiforov
` (19 subsequent siblings)
20 siblings, 1 reply; 84+ messages in thread
From: Aleksei Nikiforov @ 2019-12-12 9:57 UTC (permalink / raw)
To: devel; +Cc: Aleksei Nikiforov
Found via cppcheck:
(performance) Prefer prefix ++/-- operators for non-primitive types.
---
apt/apt-pkg/acquire-item.cc | 4 ++--
apt/apt-pkg/contrib/configuration.cc | 2 +-
apt/apt-pkg/orderlist.cc | 8 ++++----
apt/apt-pkg/packagemanager.cc | 12 ++++++------
apt/apt-pkg/pkgcachegen.cc | 8 ++++----
apt/apt-pkg/policy.cc | 6 +++---
apt/apt-pkg/rpm/rpmindexfile.cc | 2 +-
apt/apt-pkg/rpm/rpmpackagedata.cc | 8 ++++----
apt/apt-pkg/rpm/rpmpm.cc | 6 +++---
apt/apt-pkg/sourcelist.cc | 22 +++++++++++-----------
apt/apt-pkg/srcrecords.cc | 4 ++--
apt/apt-pkg/versionmatch.cc | 2 +-
apt/cmdline/apt-cdrom.cc | 20 ++++++++++----------
apt/cmdline/apt-get.cc | 20 +++++++++-----------
apt/cmdline/apt-shell.cc | 6 +++---
apt/cmdline/indexcopy.cc | 4 ++--
apt/cmdline/rpmindexcopy.cc | 4 ++--
apt/methods/ftp.cc | 2 +-
apt/methods/http.cc | 10 +++++-----
19 files changed, 74 insertions(+), 76 deletions(-)
diff --git a/apt/apt-pkg/acquire-item.cc b/apt/apt-pkg/acquire-item.cc
index 9325c53..61592c8 100644
--- a/apt/apt-pkg/acquire-item.cc
+++ b/apt/apt-pkg/acquire-item.cc
@@ -486,7 +486,7 @@ void pkgAcqIndexRel::Done(const string &Message,unsigned long long Size,const st
bool found = false;
for (vector<string>::const_iterator I = Repository->FingerPrint.begin();
- I != Repository->FingerPrint.end(); I++)
+ I != Repository->FingerPrint.end(); ++I)
{
// Match fingerprint of Release file
if ((*I) == FingerPrint)
@@ -501,7 +501,7 @@ void pkgAcqIndexRel::Done(const string &Message,unsigned long long Size,const st
Status = StatError;
ErrorText = _("Signature fingerprint of Release file does not match (expected ");
for (vector<string>::const_iterator I = Repository->FingerPrint.begin();
- I != Repository->FingerPrint.end(); I++)
+ I != Repository->FingerPrint.end(); ++I)
ErrorText += "\n"+(*I);
ErrorText += _(", got ")+FingerPrint+")";
return;
diff --git a/apt/apt-pkg/contrib/configuration.cc b/apt/apt-pkg/contrib/configuration.cc
index 59ee122..214babc 100644
--- a/apt/apt-pkg/contrib/configuration.cc
+++ b/apt/apt-pkg/contrib/configuration.cc
@@ -809,7 +809,7 @@ bool ReadConfigDir(Configuration &Conf,const string &Dir,bool AsSectional,
sort(List.begin(),List.end());
// Read the files
- for (vector<string>::const_iterator I = List.begin(); I != List.end(); I++)
+ for (vector<string>::const_iterator I = List.begin(); I != List.end(); ++I)
if (ReadConfigFile(Conf,*I,AsSectional,Depth) == false)
return false;
return true;
diff --git a/apt/apt-pkg/orderlist.cc b/apt/apt-pkg/orderlist.cc
index f6081b3..d96a263 100644
--- a/apt/apt-pkg/orderlist.cc
+++ b/apt/apt-pkg/orderlist.cc
@@ -148,13 +148,13 @@ bool pkgOrderList::DoRun()
Depth = 0;
WipeFlags(Added | AddPending | Loop | InList);
- for (iterator I = List; I != End; I++)
+ for (iterator I = List; I != End; ++I)
Flag(*I,InList);
// Rebuild the main list into the temp list.
iterator OldEnd = End;
End = NList;
- for (iterator I = List; I != OldEnd; I++)
+ for (iterator I = List; I != OldEnd; ++I)
if (VisitNode(PkgIterator(Cache,*I)) == false)
{
End = OldEnd;
@@ -212,7 +212,7 @@ bool pkgOrderList::OrderUnpack(string *FileList)
WipeFlags(After);
// Set the inlist flag
- for (iterator I = List; I != End; I++)
+ for (iterator I = List; I != End; ++I)
{
PkgIterator P(Cache,*I);
if (IsMissing(P) == true && IsNow(P) == true)
@@ -260,7 +260,7 @@ bool pkgOrderList::OrderUnpack(string *FileList)
{
clog << "** Unpack ordering done" << endl;
- for (iterator I = List; I != End; I++)
+ for (iterator I = List; I != End; ++I)
{
PkgIterator P(Cache,*I);
if (IsNow(P) == true)
diff --git a/apt/apt-pkg/packagemanager.cc b/apt/apt-pkg/packagemanager.cc
index c269d0c..0bcd902 100644
--- a/apt/apt-pkg/packagemanager.cc
+++ b/apt/apt-pkg/packagemanager.cc
@@ -65,7 +65,7 @@ bool pkgPackageManager::GetArchives(pkgAcquire *Owner,pkgSourceList *Sources,
if (List->OrderUnpack() == false)
return _error->Error("Internal ordering error");
- for (pkgOrderList::iterator I = List->begin(); I != List->end(); I++)
+ for (pkgOrderList::iterator I = List->begin(); I != List->end(); ++I)
{
PkgIterator Pkg(Cache,*I);
FileNames[Pkg->ID] = string();
@@ -236,7 +236,7 @@ bool pkgPackageManager::ConfigureAll()
pkgOrderList OList(&Cache);
// Populate the order list
- for (pkgOrderList::iterator I = List->begin(); I != List->end(); I++)
+ for (pkgOrderList::iterator I = List->begin(); I != List->end(); ++I)
if (List->IsFlag(pkgCache::PkgIterator(Cache,*I),
pkgOrderList::UnPacked) == true)
OList.push_back(*I);
@@ -245,7 +245,7 @@ bool pkgPackageManager::ConfigureAll()
return false;
// Perform the configuring
- for (pkgOrderList::iterator I = OList.begin(); I != OList.end(); I++)
+ for (pkgOrderList::iterator I = OList.begin(); I != OList.end(); ++I)
{
PkgIterator Pkg(Cache,*I);
@@ -273,7 +273,7 @@ bool pkgPackageManager::SmartConfigure(PkgIterator Pkg)
return false;
// Perform the configuring
- for (pkgOrderList::iterator I = OList.begin(); I != OList.end(); I++)
+ for (pkgOrderList::iterator I = OList.begin(); I != OList.end(); ++I)
{
PkgIterator Pkg(Cache,*I);
@@ -593,7 +593,7 @@ pkgPackageManager::OrderResult pkgPackageManager::OrderInstall()
clog << "Done ordering" << endl;
bool DoneSomething = false;
- for (pkgOrderList::iterator I = List->begin(); I != List->end(); I++)
+ for (pkgOrderList::iterator I = List->begin(); I != List->end(); ++I)
{
PkgIterator Pkg(Cache,*I);
@@ -648,7 +648,7 @@ pkgPackageManager::OrderResult pkgPackageManager::OrderInstall()
return Failed;
// Sanity check
- for (pkgOrderList::iterator I = List->begin(); I != List->end(); I++)
+ for (pkgOrderList::iterator I = List->begin(); I != List->end(); ++I)
{
if (List->IsFlag(*I,pkgOrderList::Configured) == false)
{
diff --git a/apt/apt-pkg/pkgcachegen.cc b/apt/apt-pkg/pkgcachegen.cc
index 56716b5..654c81c 100644
--- a/apt/apt-pkg/pkgcachegen.cc
+++ b/apt/apt-pkg/pkgcachegen.cc
@@ -802,7 +802,7 @@ static bool CheckValidity(const string &CacheFile, FileIterator Start,
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);
- for (; Start != End; Start++)
+ for (; Start != End; ++Start)
{
if ((*Start)->HasPackages() == false)
continue;
@@ -845,7 +845,7 @@ static bool CheckValidity(const string &CacheFile, FileIterator Start,
static unsigned long long ComputeSize(FileIterator Start,FileIterator End)
{
unsigned long long TotalSize = 0;
- for (; Start != End; Start++)
+ for (; Start != End; ++Start)
{
if ((*Start)->HasPackages() == false)
continue;
@@ -863,7 +863,7 @@ static bool BuildCache(pkgCacheGenerator &Gen,
FileIterator Start, FileIterator End)
{
FileIterator I;
- for (I = Start; I != End; I++)
+ for (I = Start; I != End; ++I)
{
if ((*I)->HasPackages() == false)
continue;
@@ -913,7 +913,7 @@ static bool CollectFileProvides(pkgCacheGenerator &Gen,
unsigned long long &CurrentSize,unsigned long long TotalSize,
FileIterator Start, FileIterator End)
{
- for (FileIterator I = Start; I != End; I++)
+ for (FileIterator I = Start; I != End; ++I)
{
if ((*I)->HasPackages() == false || (*I)->Exists() == false)
continue;
diff --git a/apt/apt-pkg/policy.cc b/apt/apt-pkg/policy.cc
index 80722ae..ed0938a 100644
--- a/apt/apt-pkg/policy.cc
+++ b/apt/apt-pkg/policy.cc
@@ -86,7 +86,7 @@ bool pkgPolicy::InitDefaults()
signed Cur = 989;
StatusOverride = false;
for (vector<Pin>::const_iterator I = Defaults.begin(); I != Defaults.end();
- I++, Cur--)
+ ++I, --Cur)
{
pkgVersionMatch Match(I->Data,I->Type);
for (pkgCache::PkgFileIterator F = Cache->FileBegin(); F != Cache->FileEnd(); F++)
@@ -197,7 +197,7 @@ void pkgPolicy::CreatePin(pkgVersionMatch::MatchType Type, const string &Name,
{
// Check the unmatched table
for (vector<PkgPin>::iterator I = Unmatched.begin();
- I != Unmatched.end() && P == 0; I++)
+ I != Unmatched.end() && P == 0; ++I)
if (I->Pkg == Name)
P = &*I;
@@ -343,7 +343,7 @@ bool ReadPinDir(pkgPolicy &Plcy,string Dir)
sort(List.begin(),List.end());
// Read the files
- for (vector<string>::const_iterator I = List.begin(); I != List.end(); I++)
+ for (vector<string>::const_iterator I = List.begin(); I != List.end(); ++I)
if (ReadPinFile(Plcy, *I) == false)
return false;
return true;
diff --git a/apt/apt-pkg/rpm/rpmindexfile.cc b/apt/apt-pkg/rpm/rpmindexfile.cc
index 5ccd5fe..b4523b9 100644
--- a/apt/apt-pkg/rpm/rpmindexfile.cc
+++ b/apt/apt-pkg/rpm/rpmindexfile.cc
@@ -648,7 +648,7 @@ class rpmSLTypeGen : public pkgSourceList::Type
const pkgSourceList::Vendor *Vendor) const
{
for (vector<pkgRepository *>::const_iterator iter = RepList.begin();
- iter != RepList.end(); iter++)
+ iter != RepList.end(); ++iter)
{
if ((*iter)->URI == URI && (*iter)->Dist == Dist)
{
diff --git a/apt/apt-pkg/rpm/rpmpackagedata.cc b/apt/apt-pkg/rpm/rpmpackagedata.cc
index 98eb5e3..186a146 100644
--- a/apt/apt-pkg/rpm/rpmpackagedata.cc
+++ b/apt/apt-pkg/rpm/rpmpackagedata.cc
@@ -222,7 +222,7 @@ RPMPackageData::RPMPackageData()
bool RPMPackageData::HoldPackage(const char *name)
{
for (vector<regex_t*>::iterator I = HoldPackages.begin();
- I != HoldPackages.end(); I++)
+ I != HoldPackages.end(); ++I)
if (regexec(*I,name,0,0,0) == 0)
return true;
return false;
@@ -237,7 +237,7 @@ bool RPMPackageData::IgnoreDep(pkgVersioningSystem &VS,
if (VerList == NULL)
return true;
for (vector<string>::iterator I = VerList->begin();
- I != VerList->end(); I++)
+ I != VerList->end(); ++I)
{
if (VS.CheckDep(I->c_str(),Dep->CompareOp,Dep.TargetVer()) == true)
return true;
@@ -276,7 +276,7 @@ void RPMPackageData::GenericTranslate(vector<Translate*> &TList,
map<string,string> &Dict)
{
const char *fulluri = FullURI.c_str();
- for (vector<Translate*>::iterator I = TList.begin(); I != TList.end(); I++)
+ for (vector<Translate*>::iterator I = TList.begin(); I != TList.end(); ++I)
{
if (regexec(&(*I)->Pattern,fulluri,0,0,0) == 0)
{
@@ -323,7 +323,7 @@ bool RPMPackageData::IsDupPackage(const string &Name)
return true;
const char *name = Name.c_str();
for (vector<regex_t*>::iterator I = DuplicatedPatterns.begin();
- I != DuplicatedPatterns.end(); I++) {
+ I != DuplicatedPatterns.end(); ++I) {
if (regexec(*I,name,0,0,0) == 0) {
SetDupPackage(Name);
return true;
diff --git a/apt/apt-pkg/rpm/rpmpm.cc b/apt/apt-pkg/rpm/rpmpm.cc
index e00630f..eb14363 100644
--- a/apt/apt-pkg/rpm/rpmpm.cc
+++ b/apt/apt-pkg/rpm/rpmpm.cc
@@ -241,7 +241,7 @@ bool pkgRPMPM::RunScriptsWithPkgs(const char *Cnf)
FileFd Fd(Pipes[1]);
// Feed it the filenames.
- for (vector<Item>::iterator I = List.begin(); I != List.end(); I++)
+ for (vector<Item>::iterator I = List.begin(); I != List.end(); ++I)
{
// Only deal with packages to be installed from .rpm
if (I->Op != Item::Install)
@@ -298,7 +298,7 @@ bool pkgRPMPM::Go()
vector<char*> unalloc;
- for (vector<Item>::iterator I = List.begin(); I != List.end(); I++)
+ for (vector<Item>::iterator I = List.begin(); I != List.end(); ++I)
{
string Name = I->Pkg.Name();
string::size_type loc;
@@ -391,7 +391,7 @@ bool pkgRPMPM::Go()
Ret = RunScripts("RPM::Post-Invoke");
exit:
- for (vector<char *>::iterator I = unalloc.begin(); I != unalloc.end(); I++)
+ for (vector<char *>::iterator I = unalloc.begin(); I != unalloc.end(); ++I)
free(*I);
return Ret;
diff --git a/apt/apt-pkg/sourcelist.cc b/apt/apt-pkg/sourcelist.cc
index 7e2eb36..f2fbe21 100644
--- a/apt/apt-pkg/sourcelist.cc
+++ b/apt/apt-pkg/sourcelist.cc
@@ -149,10 +149,10 @@ pkgSourceList::pkgSourceList(const string &File)
/* */
pkgSourceList::~pkgSourceList()
{
- for (const_iterator I = SrcList.begin(); I != SrcList.end(); I++)
+ for (const_iterator I = SrcList.begin(); I != SrcList.end(); ++I)
delete *I;
for (vector<Vendor *>::iterator I = VendorList.begin();
- I != VendorList.end(); I++)
+ I != VendorList.end(); ++I)
delete *I;
}
/*}}}*/
@@ -176,7 +176,7 @@ bool pkgSourceList::ReadVendors()
return false;
for (vector<Vendor *>::iterator I = VendorList.begin();
- I != VendorList.end(); I++)
+ I != VendorList.end(); ++I)
delete *I;
VendorList.erase(VendorList.begin(),VendorList.end());
@@ -190,7 +190,7 @@ bool pkgSourceList::ReadVendors()
bool New = true;
for (vector<pkgSourceList::Vendor *>::iterator I = VendorList.begin();
- I != VendorList.end(); I++)
+ I != VendorList.end(); ++I)
{
if ((*I)->VendorID == Group)
{
@@ -213,7 +213,7 @@ bool pkgSourceList::ReadVendors()
char *buffer = new char[FingerPrint.length()+1];
char *p = buffer;;
for (string::const_iterator I = FingerPrint.begin();
- I != FingerPrint.end(); I++)
+ I != FingerPrint.end(); ++I)
{
if (*I != ' ' && *I != '\t')
*p++ = *I;
@@ -292,7 +292,7 @@ bool pkgSourceList::ReadMainList()
/* */
void pkgSourceList::Reset()
{
- for (const_iterator I = SrcList.begin(); I != SrcList.end(); I++)
+ for (const_iterator I = SrcList.begin(); I != SrcList.end(); ++I)
delete *I;
SrcList.erase(SrcList.begin(),SrcList.end());
// CNC:2003-11-21
@@ -374,7 +374,7 @@ bool pkgSourceList::ReadAppend(const string &File)
VendorID = string(VendorID,1,VendorID.size()-2);
for (vector<Vendor *>::iterator iter = VendorList.begin();
- iter != VendorList.end(); iter++)
+ iter != VendorList.end(); ++iter)
{
if ((*iter)->VendorID == VendorID)
{
@@ -400,7 +400,7 @@ bool pkgSourceList::ReadAppend(const string &File)
bool pkgSourceList::FindIndex(pkgCache::PkgFileIterator File,
pkgIndexFile *&Found) const
{
- for (const_iterator I = SrcList.begin(); I != SrcList.end(); I++)
+ for (const_iterator I = SrcList.begin(); I != SrcList.end(); ++I)
{
if ((*I)->FindInCache(*File.Cache()) == File)
{
@@ -417,7 +417,7 @@ bool pkgSourceList::FindIndex(pkgCache::PkgFileIterator File,
/* */
bool pkgSourceList::GetIndexes(pkgAcquire *Owner) const
{
- for (const_iterator I = SrcList.begin(); I != SrcList.end(); I++)
+ for (const_iterator I = SrcList.begin(); I != SrcList.end(); ++I)
if ((*I)->GetIndexes(Owner) == false)
return false;
return true;
@@ -429,7 +429,7 @@ bool pkgSourceList::GetIndexes(pkgAcquire *Owner) const
/* */
bool pkgSourceList::GetReleases(pkgAcquire *Owner) const
{
- for (const_iterator I = SrcList.begin(); I != SrcList.end(); I++)
+ for (const_iterator I = SrcList.begin(); I != SrcList.end(); ++I)
if ((*I)->GetReleases(Owner) == false)
return false;
return true;
@@ -479,7 +479,7 @@ bool pkgSourceList::ReadSourceDir(const string &Dir)
sort(List.begin(),List.end());
// Read the files
- for (vector<string>::const_iterator I = List.begin(); I != List.end(); I++)
+ for (vector<string>::const_iterator I = List.begin(); I != List.end(); ++I)
if (ReadAppend(*I) == false)
return false;
return true;
diff --git a/apt/apt-pkg/srcrecords.cc b/apt/apt-pkg/srcrecords.cc
index 0a5483a..00e4f3c 100644
--- a/apt/apt-pkg/srcrecords.cc
+++ b/apt/apt-pkg/srcrecords.cc
@@ -34,7 +34,7 @@ pkgSrcRecords::pkgSrcRecords(pkgSourceList &List) : Files(0), Current(0)
unsigned int Count = 0;
pkgSourceList::const_iterator I = List.begin();
- for (; I != List.end(); I++)
+ for (; I != List.end(); ++I)
{
Files[Count] = (*I)->CreateSrcParser();
if (_error->PendingError() == true)
@@ -119,7 +119,7 @@ pkgSrcRecords::Parser *pkgSrcRecords::Find(const char *Package,bool SrcOnly)
vector<pkgSrcRecords::File> Files;
if ((*Current)->Files(Files) == true) {
vector<pkgSrcRecords::File>::const_iterator I = Files.begin();
- for (; I != Files.end(); I++) {
+ for (; I != Files.end(); ++I) {
if (flNotDir(I->Path) == flNotDir(Package))
return *Current;
}
diff --git a/apt/apt-pkg/versionmatch.cc b/apt/apt-pkg/versionmatch.cc
index 6a6f4f6..360e0f3 100644
--- a/apt/apt-pkg/versionmatch.cc
+++ b/apt/apt-pkg/versionmatch.cc
@@ -63,7 +63,7 @@ pkgVersionMatch::pkgVersionMatch(const string &Data,MatchType Type,int Op) : Ver
// Are we a simple specification?
string::const_iterator I = Data.begin();
- for (; I != Data.end() && *I != '='; I++);
+ for (; I != Data.end() && *I != '='; ++I);
if (I == Data.end())
{
// Temporary
diff --git a/apt/cmdline/apt-cdrom.cc b/apt/cmdline/apt-cdrom.cc
index 8ba9174..eded525 100644
--- a/apt/cmdline/apt-cdrom.cc
+++ b/apt/cmdline/apt-cdrom.cc
@@ -317,7 +317,7 @@ void ReduceSourcelist(const string &CD,vector<string> &List)
sort(List.begin(),List.end());
// Collect similar entries
- for (vector<string>::iterator I = List.begin(); I != List.end(); I++)
+ for (vector<string>::iterator I = List.begin(); I != List.end(); ++I)
{
// Find a space..
string::size_type Space = (*I).find(' ');
@@ -329,7 +329,7 @@ void ReduceSourcelist(const string &CD,vector<string> &List)
string Word1 = string(*I,Space,SSpace-Space);
string Prefix = string(*I,0,Space);
- for (vector<string>::iterator J = List.begin(); J != I; J++)
+ for (vector<string>::iterator J = List.begin(); J != I; ++J)
{
// Find a space..
string::size_type Space2 = (*J).find(' ');
@@ -467,7 +467,7 @@ bool WriteSourceList(const string &Name,vector<string> &List,bool Source)
if (First == true)
{
- for (vector<string>::iterator I = List.begin(); I != List.end(); I++)
+ for (vector<string>::iterator I = List.begin(); I != List.end(); ++I)
{
string::size_type Space = (*I).find(' ');
if (Space == string::npos)
@@ -501,7 +501,7 @@ bool WriteSourceList(const string &Name,vector<string> &List,bool Source)
// Just in case the file was empty
if (First == true)
{
- for (vector<string>::iterator I = List.begin(); I != List.end(); I++)
+ for (vector<string>::iterator I = List.begin(); I != List.end(); ++I)
{
string::size_type Space = (*I).find(' ');
if (Space == string::npos)
@@ -641,10 +641,10 @@ bool DoAdd(CommandLine &)
if (_config->FindB("Debug::aptcdrom",false) == true)
{
cout << _("I found (binary):") << endl;
- for (vector<string>::iterator I = List.begin(); I != List.end(); I++)
+ for (vector<string>::iterator I = List.begin(); I != List.end(); ++I)
cout << *I << endl;
cout << _("I found (source):") << endl;
- for (vector<string>::iterator I = sList.begin(); I != sList.end(); I++)
+ for (vector<string>::iterator I = sList.begin(); I != sList.end(); ++I)
cout << *I << endl;
}
@@ -686,7 +686,7 @@ bool DoAdd(CommandLine &)
{
// Escape special characters
string::iterator J = Name.begin();
- for (; J != Name.end(); J++)
+ for (; J != Name.end(); ++J)
if (*J == '"' || *J == ']' || *J == '[')
*J = '_';
@@ -717,7 +717,7 @@ bool DoAdd(CommandLine &)
// Escape special characters
string::iterator J = Name.begin();
- for (; J != Name.end(); J++)
+ for (; J != Name.end(); ++J)
if (*J == '"' || *J == ']' || *J == '[')
*J = '_';
@@ -756,7 +756,7 @@ bool DoAdd(CommandLine &)
// Print the sourcelist entries
cout << _("Source List entries for this Media are:") << endl;
- for (vector<string>::iterator I = List.begin(); I != List.end(); I++)
+ for (vector<string>::iterator I = List.begin(); I != List.end(); ++I)
{
string::size_type Space = (*I).find(' ');
if (Space == string::npos)
@@ -772,7 +772,7 @@ bool DoAdd(CommandLine &)
#endif
}
- for (vector<string>::iterator I = sList.begin(); I != sList.end(); I++)
+ for (vector<string>::iterator I = sList.begin(); I != sList.end(); ++I)
{
string::size_type Space = (*I).find(' ');
if (Space == string::npos)
diff --git a/apt/cmdline/apt-get.cc b/apt/cmdline/apt-get.cc
index a26c93c..3858752 100644
--- a/apt/cmdline/apt-get.cc
+++ b/apt/cmdline/apt-get.cc
@@ -541,8 +541,7 @@ bool DownloadPackages(vector<string> &URLLst)
pkgAcquire Fetcher(&Stat);
// Load the requestd sources into the fetcher
- vector<string>::const_iterator I = URLLst.begin();
- for (; I != URLLst.end(); I++)
+ for (auto I = URLLst.begin(); I != URLLst.end(); ++I)
new pkgAcqFile(&Fetcher,*I,"",0,*I,flNotDir(*I));
// Run it
@@ -551,7 +550,7 @@ bool DownloadPackages(vector<string> &URLLst)
// Print error messages
bool Failed = false;
- for (pkgAcquire::ItemIterator I = Fetcher.ItemsBegin(); I != Fetcher.ItemsEnd(); I++)
+ for (auto I = Fetcher.ItemsBegin(); I != Fetcher.ItemsEnd(); ++I)
{
if ((*I)->Status == pkgAcquire::Item::StatDone &&
(*I)->Complete == true)
@@ -1407,7 +1406,7 @@ bool DoInstall(CommandLine &CmdL)
// Run over the matches
bool Hit = false;
for (vector<string>::const_iterator I = VS.begin();
- I != VS.end(); I++) {
+ I != VS.end(); ++I) {
Pkg = Cache->FindPkg(*I);
if (Pkg.end() == true)
@@ -1721,8 +1720,7 @@ bool DoDSelectUpgrade(CommandLine &CmdL)
return false;
// Install everything with the install flag set
- pkgCache::PkgIterator I = Cache->PkgBegin();
- for (;I.end() != true; I++)
+ for (auto I = Cache->PkgBegin(); not I.end(); ++I)
{
/* Install the package only if it is a new install, the autoupgrader
will deal with the rest */
@@ -1732,7 +1730,7 @@ bool DoDSelectUpgrade(CommandLine &CmdL)
/* Now install their deps too, if we do this above then order of
the status file is significant for | groups */
- for (I = Cache->PkgBegin();I.end() != true; I++)
+ for (auto I = Cache->PkgBegin(); not I.end(); ++I)
{
/* Install the package only if it is a new install, the autoupgrader
will deal with the rest */
@@ -1741,7 +1739,7 @@ bool DoDSelectUpgrade(CommandLine &CmdL)
}
// Apply erasures now, they override everything else.
- for (I = Cache->PkgBegin();I.end() != true; I++)
+ for (auto I = Cache->PkgBegin(); not I.end(); ++I)
{
// Remove packages
if (I->SelectedState == pkgCache::State::DeInstall ||
@@ -1758,7 +1756,7 @@ bool DoDSelectUpgrade(CommandLine &CmdL)
// Hold back held packages.
if (_config->FindB("APT::Ignore-Hold",false) == false)
{
- for (pkgCache::PkgIterator I = Cache->PkgBegin(); I.end() == false; I++)
+ for (auto I = Cache->PkgBegin(); not I.end(); ++I)
{
if (I->SelectedState == pkgCache::State::Hold)
{
@@ -1949,7 +1947,7 @@ bool DoSource(CommandLine &CmdL)
// Load them into the fetcher
for (vector<pkgSrcRecords::File>::const_iterator I = Lst.begin();
- I != Lst.end(); I++)
+ I != Lst.end(); ++I)
{
// Try to guess what sort of file it is we are getting.
// CNC:2002-07-06
@@ -2225,7 +2223,7 @@ bool DoBuildDep(CommandLine &CmdL)
vector <pkgSrcRecords::Parser::BuildDepRec>::iterator D;
pkgProblemResolver Fix(Cache);
bool skipAlternatives = false; // skip remaining alternatives in an or group
- for (D = BuildDeps.begin(); D != BuildDeps.end(); D++)
+ for (D = BuildDeps.begin(); D != BuildDeps.end(); ++D)
{
bool hasAlternatives = (((*D).Op & pkgCache::Dep::Or) == pkgCache::Dep::Or);
diff --git a/apt/cmdline/apt-shell.cc b/apt/cmdline/apt-shell.cc
index 9582291..0aa5da5 100644
--- a/apt/cmdline/apt-shell.cc
+++ b/apt/cmdline/apt-shell.cc
@@ -1318,7 +1318,7 @@ bool DoInstall(CommandLine &CmdL)
// Run over the matches
bool Hit = false;
for (vector<string>::const_iterator I = VS.begin();
- I != VS.end(); I++) {
+ I != VS.end(); ++I) {
Pkg = Cache->FindPkg(*I);
if (Pkg.end() == true)
@@ -1776,7 +1776,7 @@ bool DoBuildDep(CommandLine &CmdL)
vector <pkgSrcRecords::Parser::BuildDepRec>::iterator D;
pkgProblemResolver Fix(Cache);
bool skipAlternatives = false; // skip remaining alternatives in an or group
- for (D = BuildDeps.begin(); D != BuildDeps.end(); D++)
+ for (D = BuildDeps.begin(); D != BuildDeps.end(); ++D)
{
bool hasAlternatives = (((*D).Op & pkgCache::Dep::Or) == pkgCache::Dep::Or);
@@ -3034,7 +3034,7 @@ bool DoList(CommandLine &CmdL)
string status = "available";
if (Pkg->CurrentVer != 0) status = "installed";
if (Pkg->CurrentVer != 0)
- for (pkgCache::DepIterator D = Pkg.RevDependsList(); D.end() == false; D++)
+ for (pkgCache::DepIterator D = Pkg.RevDependsList(); not D.end(); ++D)
{
pkgCache::PkgIterator P = D.ParentPkg();
if ((P->Flags & pkgCache::Flag::Essential) != pkgCache::Flag::Essential &&
diff --git a/apt/cmdline/indexcopy.cc b/apt/cmdline/indexcopy.cc
index fb2c7ef..64a9c1d 100644
--- a/apt/cmdline/indexcopy.cc
+++ b/apt/cmdline/indexcopy.cc
@@ -43,7 +43,7 @@ bool IndexCopy::CopyPackages(const string &CDROM,const string &Name,vector<strin
// Prepare the progress indicator
unsigned long long TotalSize = 0;
- for (vector<string>::iterator I = List.begin(); I != List.end(); I++)
+ for (vector<string>::iterator I = List.begin(); I != List.end(); ++I)
{
struct stat Buf;
if (stat(string(*I + GetFileName()).c_str(),&Buf) != 0 &&
@@ -57,7 +57,7 @@ bool IndexCopy::CopyPackages(const string &CDROM,const string &Name,vector<strin
unsigned int NotFound = 0;
unsigned int WrongSize = 0;
unsigned int Packages = 0;
- for (vector<string>::iterator I = List.begin(); I != List.end(); I++)
+ for (vector<string>::iterator I = List.begin(); I != List.end(); ++I)
{
string OrigPath = string(*I,CDROM.length());
unsigned long FileSize = 0;
diff --git a/apt/cmdline/rpmindexcopy.cc b/apt/cmdline/rpmindexcopy.cc
index 744af1f..9604d4b 100644
--- a/apt/cmdline/rpmindexcopy.cc
+++ b/apt/cmdline/rpmindexcopy.cc
@@ -53,7 +53,7 @@ bool RPMIndexCopy::CopyPackages(const string &CDROM,const string &Name,vector<st
// Prepare the progress indicator
unsigned long long TotalSize = 0;
- for (vector<string>::iterator I = List.begin(); I != List.end(); I++)
+ for (vector<string>::iterator I = List.begin(); I != List.end(); ++I)
{
struct stat Buf;
if (stat((*I).c_str(),&Buf) != 0)
@@ -67,7 +67,7 @@ bool RPMIndexCopy::CopyPackages(const string &CDROM,const string &Name,vector<st
// Keep track of global release processing
map<string,bool> GlobalReleases;
- for (vector<string>::iterator I = List.begin(); I != List.end(); I++)
+ for (vector<string>::iterator I = List.begin(); I != List.end(); ++I)
{
string OrigPath = string(*I,CDROM.length());
unsigned long long FileSize = 0;
diff --git a/apt/methods/ftp.cc b/apt/methods/ftp.cc
index 97d81d5..953febf 100644
--- a/apt/methods/ftp.cc
+++ b/apt/methods/ftp.cc
@@ -560,7 +560,7 @@ bool FTPConn::ExtGoPasv()
string::const_iterator List[4];
unsigned Count = 0;
Pos++;
- for (string::const_iterator I = Msg.begin() + Pos; I < Msg.end(); I++)
+ for (string::const_iterator I = Msg.begin() + Pos; I < Msg.end(); ++I)
{
if (*I != Msg[Pos])
continue;
diff --git a/apt/methods/http.cc b/apt/methods/http.cc
index dcdd651..da3e646 100644
--- a/apt/methods/http.cc
+++ b/apt/methods/http.cc
@@ -383,10 +383,10 @@ int ServerState::RunHeaders()
if (Debug == true)
clog << Data;
- for (string::const_iterator I = Data.begin(); I < Data.end(); I++)
+ for (string::const_iterator I = Data.begin(); I != Data.end(); ++I)
{
string::const_iterator J = I;
- for (; J != Data.end() && *J != '\n' && *J != '\r';J++);
+ for (; J != Data.end() && *J != '\n' && *J != '\r';++J);
if (HeaderLine(string(I,J)) == false)
return 2;
I = J;
@@ -937,7 +937,7 @@ int HttpMethod::DealWithHeaders(FetchResult &Res,ServerState *Srv)
if (ParsedURI.User.empty())
{
for (CurrentAuth = AuthList.begin(); CurrentAuth != AuthList.end();
- CurrentAuth++)
+ ++CurrentAuth)
if (CurrentAuth->Host == Srv->ServerName.Host)
{
AuthUser = CurrentAuth->User;
@@ -968,7 +968,7 @@ int HttpMethod::DealWithHeaders(FetchResult &Res,ServerState *Srv)
NewAuthInfo.Password = AuthPass;
for (CurrentAuth = AuthList.begin(); CurrentAuth != AuthList.end();
- CurrentAuth++)
+ ++CurrentAuth)
if (CurrentAuth->Host == Srv->ServerName.Host)
{
*CurrentAuth = NewAuthInfo;
@@ -1345,7 +1345,7 @@ int HttpMethod::Loop()
StopRedirects = true;
else
{
- for (StringVectorIterator I = R.begin(); I != R.end(); I++)
+ for (StringVectorIterator I = R.begin(); I != R.end(); ++I)
if (Queue->Uri == *I)
{
R[0] = "STOP";
--
2.24.1
^ permalink raw reply [flat|nested] 84+ messages in thread
* Re: [devel] [PATCH for apt v2 01/21] Replace post-increments with pre-increments
2019-12-12 9:57 ` [devel] [PATCH for apt v2 01/21] Replace post-increments with pre-increments Aleksei Nikiforov
@ 2019-12-12 21:32 ` Andrey Savchenko
2019-12-13 8:29 ` Aleksei Nikiforov
` (3 more replies)
0 siblings, 4 replies; 84+ messages in thread
From: Andrey Savchenko @ 2019-12-12 21:32 UTC (permalink / raw)
To: ALT Linux Team development discussions
[-- Attachment #1: Type: text/plain, Size: 3905 bytes --]
On Thu, 12 Dec 2019 12:57:10 +0300 Aleksei Nikiforov wrote:
> Found via cppcheck:
> (performance) Prefer prefix ++/-- operators for non-primitive types.
[...]
> diff --git a/apt/cmdline/apt-get.cc b/apt/cmdline/apt-get.cc
> index a26c93c..3858752 100644
> --- a/apt/cmdline/apt-get.cc
> +++ b/apt/cmdline/apt-get.cc
> @@ -541,8 +541,7 @@ bool DownloadPackages(vector<string> &URLLst)
> pkgAcquire Fetcher(&Stat);
>
> // Load the requestd sources into the fetcher
> - vector<string>::const_iterator I = URLLst.begin();
> - for (; I != URLLst.end(); I++)
> + for (auto I = URLLst.begin(); I != URLLst.end(); ++I)
> new pkgAcqFile(&Fetcher,*I,"",0,*I,flNotDir(*I));
This one contains the unrelated change for the iterator
initialization. If you really need this cosmetics, submit it as a
separate patch.
> @@ -551,7 +550,7 @@ bool DownloadPackages(vector<string> &URLLst)
>
> // Print error messages
> bool Failed = false;
> - for (pkgAcquire::ItemIterator I = Fetcher.ItemsBegin(); I != Fetcher.ItemsEnd(); I++)
> + for (auto I = Fetcher.ItemsBegin(); I != Fetcher.ItemsEnd(); ++I)
Same here.
> @@ -1721,8 +1720,7 @@ bool DoDSelectUpgrade(CommandLine &CmdL)
> return false;
>
> // Install everything with the install flag set
> - pkgCache::PkgIterator I = Cache->PkgBegin();
> - for (;I.end() != true; I++)
> + for (auto I = Cache->PkgBegin(); not I.end(); ++I)
And here.
> @@ -1732,7 +1730,7 @@ bool DoDSelectUpgrade(CommandLine &CmdL)
>
> /* Now install their deps too, if we do this above then order of
> the status file is significant for | groups */
> - for (I = Cache->PkgBegin();I.end() != true; I++)
> + for (auto I = Cache->PkgBegin(); not I.end(); ++I)
And here.
> {
> /* Install the package only if it is a new install, the autoupgrader
> will deal with the rest */
> @@ -1741,7 +1739,7 @@ bool DoDSelectUpgrade(CommandLine &CmdL)
> }
>
> // Apply erasures now, they override everything else.
> - for (I = Cache->PkgBegin();I.end() != true; I++)
> + for (auto I = Cache->PkgBegin(); not I.end(); ++I)
And here.
> @@ -1758,7 +1756,7 @@ bool DoDSelectUpgrade(CommandLine &CmdL)
> // Hold back held packages.
> if (_config->FindB("APT::Ignore-Hold",false) == false)
> {
> - for (pkgCache::PkgIterator I = Cache->PkgBegin(); I.end() == false; I++)
> + for (auto I = Cache->PkgBegin(); not I.end(); ++I)
And here.
> diff --git a/apt/cmdline/apt-shell.cc b/apt/cmdline/apt-shell.cc
> index 9582291..0aa5da5 100644
> --- a/apt/cmdline/apt-shell.cc
> +++ b/apt/cmdline/apt-shell.cc
> @@ -3034,7 +3034,7 @@ bool DoList(CommandLine &CmdL)
> string status = "available";
> if (Pkg->CurrentVer != 0) status = "installed";
> if (Pkg->CurrentVer != 0)
> - for (pkgCache::DepIterator D = Pkg.RevDependsList(); D.end() == false; D++)
> + for (pkgCache::DepIterator D = Pkg.RevDependsList(); not D.end(); ++D)
Same here. Though this D.end() related change looks as an absolutely
useless cosmetics.
> diff --git a/apt/methods/http.cc b/apt/methods/http.cc
> index dcdd651..da3e646 100644
> --- a/apt/methods/http.cc
> +++ b/apt/methods/http.cc
> @@ -383,10 +383,10 @@ int ServerState::RunHeaders()
> if (Debug == true)
> clog << Data;
>
> - for (string::const_iterator I = Data.begin(); I < Data.end(); I++)
> + for (string::const_iterator I = Data.begin(); I != Data.end(); ++I)
This is the correct change. But yet again it is unrelated to the
patch description, please submit Data.end() fix as a separate patch.
Other changes LGTM. They may improve performance (and may not
depending on how smart a compiler is), but are harmless otherwise.
Best regards,
Andrew Savchenko
[-- Attachment #2: Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 84+ messages in thread
* Re: [devel] [PATCH for apt v2 01/21] Replace post-increments with pre-increments
2019-12-12 21:32 ` Andrey Savchenko
@ 2019-12-13 8:29 ` Aleksei Nikiforov
2019-12-13 9:11 ` [devel] [PATCH for apt v3 " Aleksei Nikiforov
` (2 subsequent siblings)
3 siblings, 0 replies; 84+ messages in thread
From: Aleksei Nikiforov @ 2019-12-13 8:29 UTC (permalink / raw)
To: devel
13.12.2019 0:32, Andrey Savchenko пишет:
> On Thu, 12 Dec 2019 12:57:10 +0300 Aleksei Nikiforov wrote:
>> Found via cppcheck:
>> (performance) Prefer prefix ++/-- operators for non-primitive types.
> [...]
>> diff --git a/apt/cmdline/apt-get.cc b/apt/cmdline/apt-get.cc
>> index a26c93c..3858752 100644
>> --- a/apt/cmdline/apt-get.cc
>> +++ b/apt/cmdline/apt-get.cc
>> @@ -541,8 +541,7 @@ bool DownloadPackages(vector<string> &URLLst)
>> pkgAcquire Fetcher(&Stat);
>>
>> // Load the requestd sources into the fetcher
>> - vector<string>::const_iterator I = URLLst.begin();
>> - for (; I != URLLst.end(); I++)
>> + for (auto I = URLLst.begin(); I != URLLst.end(); ++I)
>> new pkgAcqFile(&Fetcher,*I,"",0,*I,flNotDir(*I));
>
> This one contains the unrelated change for the iterator
> initialization. If you really need this cosmetics, submit it as a
> separate patch.
>
>> @@ -551,7 +550,7 @@ bool DownloadPackages(vector<string> &URLLst)
>>
>> // Print error messages
>> bool Failed = false;
>> - for (pkgAcquire::ItemIterator I = Fetcher.ItemsBegin(); I != Fetcher.ItemsEnd(); I++)
>> + for (auto I = Fetcher.ItemsBegin(); I != Fetcher.ItemsEnd(); ++I)
>
> Same here.
>
>> @@ -1721,8 +1720,7 @@ bool DoDSelectUpgrade(CommandLine &CmdL)
>> return false;
>>
>> // Install everything with the install flag set
>> - pkgCache::PkgIterator I = Cache->PkgBegin();
>> - for (;I.end() != true; I++)
>> + for (auto I = Cache->PkgBegin(); not I.end(); ++I)
>
> And here.
>
>> @@ -1732,7 +1730,7 @@ bool DoDSelectUpgrade(CommandLine &CmdL)
>>
>> /* Now install their deps too, if we do this above then order of
>> the status file is significant for | groups */
>> - for (I = Cache->PkgBegin();I.end() != true; I++)
>> + for (auto I = Cache->PkgBegin(); not I.end(); ++I)
>
> And here.
>
>> {
>> /* Install the package only if it is a new install, the autoupgrader
>> will deal with the rest */
>> @@ -1741,7 +1739,7 @@ bool DoDSelectUpgrade(CommandLine &CmdL)
>> }
>>
>> // Apply erasures now, they override everything else.
>> - for (I = Cache->PkgBegin();I.end() != true; I++)
>> + for (auto I = Cache->PkgBegin(); not I.end(); ++I)
>
> And here.
>
>> @@ -1758,7 +1756,7 @@ bool DoDSelectUpgrade(CommandLine &CmdL)
>> // Hold back held packages.
>> if (_config->FindB("APT::Ignore-Hold",false) == false)
>> {
>> - for (pkgCache::PkgIterator I = Cache->PkgBegin(); I.end() == false; I++)
>> + for (auto I = Cache->PkgBegin(); not I.end(); ++I)
>
> And here.
>
>> diff --git a/apt/cmdline/apt-shell.cc b/apt/cmdline/apt-shell.cc
>> index 9582291..0aa5da5 100644
>> --- a/apt/cmdline/apt-shell.cc
>> +++ b/apt/cmdline/apt-shell.cc
>> @@ -3034,7 +3034,7 @@ bool DoList(CommandLine &CmdL)
>> string status = "available";
>> if (Pkg->CurrentVer != 0) status = "installed";
>> if (Pkg->CurrentVer != 0)
>> - for (pkgCache::DepIterator D = Pkg.RevDependsList(); D.end() == false; D++)
>> + for (pkgCache::DepIterator D = Pkg.RevDependsList(); not D.end(); ++D)
>
> Same here. Though this D.end() related change looks as an absolutely
> useless cosmetics.
>
>> diff --git a/apt/methods/http.cc b/apt/methods/http.cc
>> index dcdd651..da3e646 100644
>> --- a/apt/methods/http.cc
>> +++ b/apt/methods/http.cc
>> @@ -383,10 +383,10 @@ int ServerState::RunHeaders()
>> if (Debug == true)
>> clog << Data;
>>
>> - for (string::const_iterator I = Data.begin(); I < Data.end(); I++)
>> + for (string::const_iterator I = Data.begin(); I != Data.end(); ++I)
>
> This is the correct change. But yet again it is unrelated to the
> patch description, please submit Data.end() fix as a separate patch.
>
> Other changes LGTM. They may improve performance (and may not
> depending on how smart a compiler is), but are harmless otherwise.
>
Thanks, I'll review this patch once more.
A note: if compiler is smart, it takes time to do these heuristics, and
thus this change would improve compile time in that case. Otherwise,
this change may improve runtime performance.
> Best regards,
> Andrew Savchenko
>
>
> _______________________________________________
> Devel mailing list
> Devel@lists.altlinux.org
> https://lists.altlinux.org/mailman/listinfo/devel
>
^ permalink raw reply [flat|nested] 84+ messages in thread
* [devel] [PATCH for apt v3 01/21] Replace post-increments with pre-increments
2019-12-12 21:32 ` Andrey Savchenko
2019-12-13 8:29 ` Aleksei Nikiforov
@ 2019-12-13 9:11 ` Aleksei Nikiforov
2019-12-13 9:12 ` [devel] [PATCH for apt v4 09/21] Rework identical conditions Aleksei Nikiforov
2019-12-13 9:18 ` [devel] [PATCH for apt v4] Additional loops improvements and beautification Aleksei Nikiforov
3 siblings, 0 replies; 84+ messages in thread
From: Aleksei Nikiforov @ 2019-12-13 9:11 UTC (permalink / raw)
To: devel; +Cc: Aleksei Nikiforov
Found via cppcheck:
(performance) Prefer prefix ++/-- operators for non-primitive types.
---
apt/apt-pkg/acquire-item.cc | 4 ++--
apt/apt-pkg/contrib/configuration.cc | 2 +-
apt/apt-pkg/orderlist.cc | 8 ++++----
apt/apt-pkg/packagemanager.cc | 12 ++++++------
apt/apt-pkg/pkgcachegen.cc | 8 ++++----
apt/apt-pkg/policy.cc | 6 +++---
apt/apt-pkg/rpm/rpmindexfile.cc | 2 +-
apt/apt-pkg/rpm/rpmpackagedata.cc | 8 ++++----
apt/apt-pkg/rpm/rpmpm.cc | 6 +++---
apt/apt-pkg/sourcelist.cc | 22 +++++++++++-----------
apt/apt-pkg/srcrecords.cc | 4 ++--
apt/apt-pkg/versionmatch.cc | 2 +-
apt/cmdline/apt-cdrom.cc | 20 ++++++++++----------
apt/cmdline/apt-get.cc | 10 +++++-----
apt/cmdline/apt-shell.cc | 4 ++--
apt/cmdline/indexcopy.cc | 4 ++--
apt/cmdline/rpmindexcopy.cc | 4 ++--
apt/methods/ftp.cc | 2 +-
apt/methods/http.cc | 10 +++++-----
19 files changed, 69 insertions(+), 69 deletions(-)
diff --git a/apt/apt-pkg/acquire-item.cc b/apt/apt-pkg/acquire-item.cc
index 9325c53..61592c8 100644
--- a/apt/apt-pkg/acquire-item.cc
+++ b/apt/apt-pkg/acquire-item.cc
@@ -486,7 +486,7 @@ void pkgAcqIndexRel::Done(const string &Message,unsigned long long Size,const st
bool found = false;
for (vector<string>::const_iterator I = Repository->FingerPrint.begin();
- I != Repository->FingerPrint.end(); I++)
+ I != Repository->FingerPrint.end(); ++I)
{
// Match fingerprint of Release file
if ((*I) == FingerPrint)
@@ -501,7 +501,7 @@ void pkgAcqIndexRel::Done(const string &Message,unsigned long long Size,const st
Status = StatError;
ErrorText = _("Signature fingerprint of Release file does not match (expected ");
for (vector<string>::const_iterator I = Repository->FingerPrint.begin();
- I != Repository->FingerPrint.end(); I++)
+ I != Repository->FingerPrint.end(); ++I)
ErrorText += "\n"+(*I);
ErrorText += _(", got ")+FingerPrint+")";
return;
diff --git a/apt/apt-pkg/contrib/configuration.cc b/apt/apt-pkg/contrib/configuration.cc
index 59ee122..214babc 100644
--- a/apt/apt-pkg/contrib/configuration.cc
+++ b/apt/apt-pkg/contrib/configuration.cc
@@ -809,7 +809,7 @@ bool ReadConfigDir(Configuration &Conf,const string &Dir,bool AsSectional,
sort(List.begin(),List.end());
// Read the files
- for (vector<string>::const_iterator I = List.begin(); I != List.end(); I++)
+ for (vector<string>::const_iterator I = List.begin(); I != List.end(); ++I)
if (ReadConfigFile(Conf,*I,AsSectional,Depth) == false)
return false;
return true;
diff --git a/apt/apt-pkg/orderlist.cc b/apt/apt-pkg/orderlist.cc
index f6081b3..d96a263 100644
--- a/apt/apt-pkg/orderlist.cc
+++ b/apt/apt-pkg/orderlist.cc
@@ -148,13 +148,13 @@ bool pkgOrderList::DoRun()
Depth = 0;
WipeFlags(Added | AddPending | Loop | InList);
- for (iterator I = List; I != End; I++)
+ for (iterator I = List; I != End; ++I)
Flag(*I,InList);
// Rebuild the main list into the temp list.
iterator OldEnd = End;
End = NList;
- for (iterator I = List; I != OldEnd; I++)
+ for (iterator I = List; I != OldEnd; ++I)
if (VisitNode(PkgIterator(Cache,*I)) == false)
{
End = OldEnd;
@@ -212,7 +212,7 @@ bool pkgOrderList::OrderUnpack(string *FileList)
WipeFlags(After);
// Set the inlist flag
- for (iterator I = List; I != End; I++)
+ for (iterator I = List; I != End; ++I)
{
PkgIterator P(Cache,*I);
if (IsMissing(P) == true && IsNow(P) == true)
@@ -260,7 +260,7 @@ bool pkgOrderList::OrderUnpack(string *FileList)
{
clog << "** Unpack ordering done" << endl;
- for (iterator I = List; I != End; I++)
+ for (iterator I = List; I != End; ++I)
{
PkgIterator P(Cache,*I);
if (IsNow(P) == true)
diff --git a/apt/apt-pkg/packagemanager.cc b/apt/apt-pkg/packagemanager.cc
index c269d0c..0bcd902 100644
--- a/apt/apt-pkg/packagemanager.cc
+++ b/apt/apt-pkg/packagemanager.cc
@@ -65,7 +65,7 @@ bool pkgPackageManager::GetArchives(pkgAcquire *Owner,pkgSourceList *Sources,
if (List->OrderUnpack() == false)
return _error->Error("Internal ordering error");
- for (pkgOrderList::iterator I = List->begin(); I != List->end(); I++)
+ for (pkgOrderList::iterator I = List->begin(); I != List->end(); ++I)
{
PkgIterator Pkg(Cache,*I);
FileNames[Pkg->ID] = string();
@@ -236,7 +236,7 @@ bool pkgPackageManager::ConfigureAll()
pkgOrderList OList(&Cache);
// Populate the order list
- for (pkgOrderList::iterator I = List->begin(); I != List->end(); I++)
+ for (pkgOrderList::iterator I = List->begin(); I != List->end(); ++I)
if (List->IsFlag(pkgCache::PkgIterator(Cache,*I),
pkgOrderList::UnPacked) == true)
OList.push_back(*I);
@@ -245,7 +245,7 @@ bool pkgPackageManager::ConfigureAll()
return false;
// Perform the configuring
- for (pkgOrderList::iterator I = OList.begin(); I != OList.end(); I++)
+ for (pkgOrderList::iterator I = OList.begin(); I != OList.end(); ++I)
{
PkgIterator Pkg(Cache,*I);
@@ -273,7 +273,7 @@ bool pkgPackageManager::SmartConfigure(PkgIterator Pkg)
return false;
// Perform the configuring
- for (pkgOrderList::iterator I = OList.begin(); I != OList.end(); I++)
+ for (pkgOrderList::iterator I = OList.begin(); I != OList.end(); ++I)
{
PkgIterator Pkg(Cache,*I);
@@ -593,7 +593,7 @@ pkgPackageManager::OrderResult pkgPackageManager::OrderInstall()
clog << "Done ordering" << endl;
bool DoneSomething = false;
- for (pkgOrderList::iterator I = List->begin(); I != List->end(); I++)
+ for (pkgOrderList::iterator I = List->begin(); I != List->end(); ++I)
{
PkgIterator Pkg(Cache,*I);
@@ -648,7 +648,7 @@ pkgPackageManager::OrderResult pkgPackageManager::OrderInstall()
return Failed;
// Sanity check
- for (pkgOrderList::iterator I = List->begin(); I != List->end(); I++)
+ for (pkgOrderList::iterator I = List->begin(); I != List->end(); ++I)
{
if (List->IsFlag(*I,pkgOrderList::Configured) == false)
{
diff --git a/apt/apt-pkg/pkgcachegen.cc b/apt/apt-pkg/pkgcachegen.cc
index 56716b5..654c81c 100644
--- a/apt/apt-pkg/pkgcachegen.cc
+++ b/apt/apt-pkg/pkgcachegen.cc
@@ -802,7 +802,7 @@ static bool CheckValidity(const string &CacheFile, FileIterator Start,
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);
- for (; Start != End; Start++)
+ for (; Start != End; ++Start)
{
if ((*Start)->HasPackages() == false)
continue;
@@ -845,7 +845,7 @@ static bool CheckValidity(const string &CacheFile, FileIterator Start,
static unsigned long long ComputeSize(FileIterator Start,FileIterator End)
{
unsigned long long TotalSize = 0;
- for (; Start != End; Start++)
+ for (; Start != End; ++Start)
{
if ((*Start)->HasPackages() == false)
continue;
@@ -863,7 +863,7 @@ static bool BuildCache(pkgCacheGenerator &Gen,
FileIterator Start, FileIterator End)
{
FileIterator I;
- for (I = Start; I != End; I++)
+ for (I = Start; I != End; ++I)
{
if ((*I)->HasPackages() == false)
continue;
@@ -913,7 +913,7 @@ static bool CollectFileProvides(pkgCacheGenerator &Gen,
unsigned long long &CurrentSize,unsigned long long TotalSize,
FileIterator Start, FileIterator End)
{
- for (FileIterator I = Start; I != End; I++)
+ for (FileIterator I = Start; I != End; ++I)
{
if ((*I)->HasPackages() == false || (*I)->Exists() == false)
continue;
diff --git a/apt/apt-pkg/policy.cc b/apt/apt-pkg/policy.cc
index 80722ae..ed0938a 100644
--- a/apt/apt-pkg/policy.cc
+++ b/apt/apt-pkg/policy.cc
@@ -86,7 +86,7 @@ bool pkgPolicy::InitDefaults()
signed Cur = 989;
StatusOverride = false;
for (vector<Pin>::const_iterator I = Defaults.begin(); I != Defaults.end();
- I++, Cur--)
+ ++I, --Cur)
{
pkgVersionMatch Match(I->Data,I->Type);
for (pkgCache::PkgFileIterator F = Cache->FileBegin(); F != Cache->FileEnd(); F++)
@@ -197,7 +197,7 @@ void pkgPolicy::CreatePin(pkgVersionMatch::MatchType Type, const string &Name,
{
// Check the unmatched table
for (vector<PkgPin>::iterator I = Unmatched.begin();
- I != Unmatched.end() && P == 0; I++)
+ I != Unmatched.end() && P == 0; ++I)
if (I->Pkg == Name)
P = &*I;
@@ -343,7 +343,7 @@ bool ReadPinDir(pkgPolicy &Plcy,string Dir)
sort(List.begin(),List.end());
// Read the files
- for (vector<string>::const_iterator I = List.begin(); I != List.end(); I++)
+ for (vector<string>::const_iterator I = List.begin(); I != List.end(); ++I)
if (ReadPinFile(Plcy, *I) == false)
return false;
return true;
diff --git a/apt/apt-pkg/rpm/rpmindexfile.cc b/apt/apt-pkg/rpm/rpmindexfile.cc
index 5ccd5fe..b4523b9 100644
--- a/apt/apt-pkg/rpm/rpmindexfile.cc
+++ b/apt/apt-pkg/rpm/rpmindexfile.cc
@@ -648,7 +648,7 @@ class rpmSLTypeGen : public pkgSourceList::Type
const pkgSourceList::Vendor *Vendor) const
{
for (vector<pkgRepository *>::const_iterator iter = RepList.begin();
- iter != RepList.end(); iter++)
+ iter != RepList.end(); ++iter)
{
if ((*iter)->URI == URI && (*iter)->Dist == Dist)
{
diff --git a/apt/apt-pkg/rpm/rpmpackagedata.cc b/apt/apt-pkg/rpm/rpmpackagedata.cc
index 98eb5e3..186a146 100644
--- a/apt/apt-pkg/rpm/rpmpackagedata.cc
+++ b/apt/apt-pkg/rpm/rpmpackagedata.cc
@@ -222,7 +222,7 @@ RPMPackageData::RPMPackageData()
bool RPMPackageData::HoldPackage(const char *name)
{
for (vector<regex_t*>::iterator I = HoldPackages.begin();
- I != HoldPackages.end(); I++)
+ I != HoldPackages.end(); ++I)
if (regexec(*I,name,0,0,0) == 0)
return true;
return false;
@@ -237,7 +237,7 @@ bool RPMPackageData::IgnoreDep(pkgVersioningSystem &VS,
if (VerList == NULL)
return true;
for (vector<string>::iterator I = VerList->begin();
- I != VerList->end(); I++)
+ I != VerList->end(); ++I)
{
if (VS.CheckDep(I->c_str(),Dep->CompareOp,Dep.TargetVer()) == true)
return true;
@@ -276,7 +276,7 @@ void RPMPackageData::GenericTranslate(vector<Translate*> &TList,
map<string,string> &Dict)
{
const char *fulluri = FullURI.c_str();
- for (vector<Translate*>::iterator I = TList.begin(); I != TList.end(); I++)
+ for (vector<Translate*>::iterator I = TList.begin(); I != TList.end(); ++I)
{
if (regexec(&(*I)->Pattern,fulluri,0,0,0) == 0)
{
@@ -323,7 +323,7 @@ bool RPMPackageData::IsDupPackage(const string &Name)
return true;
const char *name = Name.c_str();
for (vector<regex_t*>::iterator I = DuplicatedPatterns.begin();
- I != DuplicatedPatterns.end(); I++) {
+ I != DuplicatedPatterns.end(); ++I) {
if (regexec(*I,name,0,0,0) == 0) {
SetDupPackage(Name);
return true;
diff --git a/apt/apt-pkg/rpm/rpmpm.cc b/apt/apt-pkg/rpm/rpmpm.cc
index e00630f..eb14363 100644
--- a/apt/apt-pkg/rpm/rpmpm.cc
+++ b/apt/apt-pkg/rpm/rpmpm.cc
@@ -241,7 +241,7 @@ bool pkgRPMPM::RunScriptsWithPkgs(const char *Cnf)
FileFd Fd(Pipes[1]);
// Feed it the filenames.
- for (vector<Item>::iterator I = List.begin(); I != List.end(); I++)
+ for (vector<Item>::iterator I = List.begin(); I != List.end(); ++I)
{
// Only deal with packages to be installed from .rpm
if (I->Op != Item::Install)
@@ -298,7 +298,7 @@ bool pkgRPMPM::Go()
vector<char*> unalloc;
- for (vector<Item>::iterator I = List.begin(); I != List.end(); I++)
+ for (vector<Item>::iterator I = List.begin(); I != List.end(); ++I)
{
string Name = I->Pkg.Name();
string::size_type loc;
@@ -391,7 +391,7 @@ bool pkgRPMPM::Go()
Ret = RunScripts("RPM::Post-Invoke");
exit:
- for (vector<char *>::iterator I = unalloc.begin(); I != unalloc.end(); I++)
+ for (vector<char *>::iterator I = unalloc.begin(); I != unalloc.end(); ++I)
free(*I);
return Ret;
diff --git a/apt/apt-pkg/sourcelist.cc b/apt/apt-pkg/sourcelist.cc
index 7e2eb36..f2fbe21 100644
--- a/apt/apt-pkg/sourcelist.cc
+++ b/apt/apt-pkg/sourcelist.cc
@@ -149,10 +149,10 @@ pkgSourceList::pkgSourceList(const string &File)
/* */
pkgSourceList::~pkgSourceList()
{
- for (const_iterator I = SrcList.begin(); I != SrcList.end(); I++)
+ for (const_iterator I = SrcList.begin(); I != SrcList.end(); ++I)
delete *I;
for (vector<Vendor *>::iterator I = VendorList.begin();
- I != VendorList.end(); I++)
+ I != VendorList.end(); ++I)
delete *I;
}
/*}}}*/
@@ -176,7 +176,7 @@ bool pkgSourceList::ReadVendors()
return false;
for (vector<Vendor *>::iterator I = VendorList.begin();
- I != VendorList.end(); I++)
+ I != VendorList.end(); ++I)
delete *I;
VendorList.erase(VendorList.begin(),VendorList.end());
@@ -190,7 +190,7 @@ bool pkgSourceList::ReadVendors()
bool New = true;
for (vector<pkgSourceList::Vendor *>::iterator I = VendorList.begin();
- I != VendorList.end(); I++)
+ I != VendorList.end(); ++I)
{
if ((*I)->VendorID == Group)
{
@@ -213,7 +213,7 @@ bool pkgSourceList::ReadVendors()
char *buffer = new char[FingerPrint.length()+1];
char *p = buffer;;
for (string::const_iterator I = FingerPrint.begin();
- I != FingerPrint.end(); I++)
+ I != FingerPrint.end(); ++I)
{
if (*I != ' ' && *I != '\t')
*p++ = *I;
@@ -292,7 +292,7 @@ bool pkgSourceList::ReadMainList()
/* */
void pkgSourceList::Reset()
{
- for (const_iterator I = SrcList.begin(); I != SrcList.end(); I++)
+ for (const_iterator I = SrcList.begin(); I != SrcList.end(); ++I)
delete *I;
SrcList.erase(SrcList.begin(),SrcList.end());
// CNC:2003-11-21
@@ -374,7 +374,7 @@ bool pkgSourceList::ReadAppend(const string &File)
VendorID = string(VendorID,1,VendorID.size()-2);
for (vector<Vendor *>::iterator iter = VendorList.begin();
- iter != VendorList.end(); iter++)
+ iter != VendorList.end(); ++iter)
{
if ((*iter)->VendorID == VendorID)
{
@@ -400,7 +400,7 @@ bool pkgSourceList::ReadAppend(const string &File)
bool pkgSourceList::FindIndex(pkgCache::PkgFileIterator File,
pkgIndexFile *&Found) const
{
- for (const_iterator I = SrcList.begin(); I != SrcList.end(); I++)
+ for (const_iterator I = SrcList.begin(); I != SrcList.end(); ++I)
{
if ((*I)->FindInCache(*File.Cache()) == File)
{
@@ -417,7 +417,7 @@ bool pkgSourceList::FindIndex(pkgCache::PkgFileIterator File,
/* */
bool pkgSourceList::GetIndexes(pkgAcquire *Owner) const
{
- for (const_iterator I = SrcList.begin(); I != SrcList.end(); I++)
+ for (const_iterator I = SrcList.begin(); I != SrcList.end(); ++I)
if ((*I)->GetIndexes(Owner) == false)
return false;
return true;
@@ -429,7 +429,7 @@ bool pkgSourceList::GetIndexes(pkgAcquire *Owner) const
/* */
bool pkgSourceList::GetReleases(pkgAcquire *Owner) const
{
- for (const_iterator I = SrcList.begin(); I != SrcList.end(); I++)
+ for (const_iterator I = SrcList.begin(); I != SrcList.end(); ++I)
if ((*I)->GetReleases(Owner) == false)
return false;
return true;
@@ -479,7 +479,7 @@ bool pkgSourceList::ReadSourceDir(const string &Dir)
sort(List.begin(),List.end());
// Read the files
- for (vector<string>::const_iterator I = List.begin(); I != List.end(); I++)
+ for (vector<string>::const_iterator I = List.begin(); I != List.end(); ++I)
if (ReadAppend(*I) == false)
return false;
return true;
diff --git a/apt/apt-pkg/srcrecords.cc b/apt/apt-pkg/srcrecords.cc
index 0a5483a..00e4f3c 100644
--- a/apt/apt-pkg/srcrecords.cc
+++ b/apt/apt-pkg/srcrecords.cc
@@ -34,7 +34,7 @@ pkgSrcRecords::pkgSrcRecords(pkgSourceList &List) : Files(0), Current(0)
unsigned int Count = 0;
pkgSourceList::const_iterator I = List.begin();
- for (; I != List.end(); I++)
+ for (; I != List.end(); ++I)
{
Files[Count] = (*I)->CreateSrcParser();
if (_error->PendingError() == true)
@@ -119,7 +119,7 @@ pkgSrcRecords::Parser *pkgSrcRecords::Find(const char *Package,bool SrcOnly)
vector<pkgSrcRecords::File> Files;
if ((*Current)->Files(Files) == true) {
vector<pkgSrcRecords::File>::const_iterator I = Files.begin();
- for (; I != Files.end(); I++) {
+ for (; I != Files.end(); ++I) {
if (flNotDir(I->Path) == flNotDir(Package))
return *Current;
}
diff --git a/apt/apt-pkg/versionmatch.cc b/apt/apt-pkg/versionmatch.cc
index 6a6f4f6..360e0f3 100644
--- a/apt/apt-pkg/versionmatch.cc
+++ b/apt/apt-pkg/versionmatch.cc
@@ -63,7 +63,7 @@ pkgVersionMatch::pkgVersionMatch(const string &Data,MatchType Type,int Op) : Ver
// Are we a simple specification?
string::const_iterator I = Data.begin();
- for (; I != Data.end() && *I != '='; I++);
+ for (; I != Data.end() && *I != '='; ++I);
if (I == Data.end())
{
// Temporary
diff --git a/apt/cmdline/apt-cdrom.cc b/apt/cmdline/apt-cdrom.cc
index 8ba9174..eded525 100644
--- a/apt/cmdline/apt-cdrom.cc
+++ b/apt/cmdline/apt-cdrom.cc
@@ -317,7 +317,7 @@ void ReduceSourcelist(const string &CD,vector<string> &List)
sort(List.begin(),List.end());
// Collect similar entries
- for (vector<string>::iterator I = List.begin(); I != List.end(); I++)
+ for (vector<string>::iterator I = List.begin(); I != List.end(); ++I)
{
// Find a space..
string::size_type Space = (*I).find(' ');
@@ -329,7 +329,7 @@ void ReduceSourcelist(const string &CD,vector<string> &List)
string Word1 = string(*I,Space,SSpace-Space);
string Prefix = string(*I,0,Space);
- for (vector<string>::iterator J = List.begin(); J != I; J++)
+ for (vector<string>::iterator J = List.begin(); J != I; ++J)
{
// Find a space..
string::size_type Space2 = (*J).find(' ');
@@ -467,7 +467,7 @@ bool WriteSourceList(const string &Name,vector<string> &List,bool Source)
if (First == true)
{
- for (vector<string>::iterator I = List.begin(); I != List.end(); I++)
+ for (vector<string>::iterator I = List.begin(); I != List.end(); ++I)
{
string::size_type Space = (*I).find(' ');
if (Space == string::npos)
@@ -501,7 +501,7 @@ bool WriteSourceList(const string &Name,vector<string> &List,bool Source)
// Just in case the file was empty
if (First == true)
{
- for (vector<string>::iterator I = List.begin(); I != List.end(); I++)
+ for (vector<string>::iterator I = List.begin(); I != List.end(); ++I)
{
string::size_type Space = (*I).find(' ');
if (Space == string::npos)
@@ -641,10 +641,10 @@ bool DoAdd(CommandLine &)
if (_config->FindB("Debug::aptcdrom",false) == true)
{
cout << _("I found (binary):") << endl;
- for (vector<string>::iterator I = List.begin(); I != List.end(); I++)
+ for (vector<string>::iterator I = List.begin(); I != List.end(); ++I)
cout << *I << endl;
cout << _("I found (source):") << endl;
- for (vector<string>::iterator I = sList.begin(); I != sList.end(); I++)
+ for (vector<string>::iterator I = sList.begin(); I != sList.end(); ++I)
cout << *I << endl;
}
@@ -686,7 +686,7 @@ bool DoAdd(CommandLine &)
{
// Escape special characters
string::iterator J = Name.begin();
- for (; J != Name.end(); J++)
+ for (; J != Name.end(); ++J)
if (*J == '"' || *J == ']' || *J == '[')
*J = '_';
@@ -717,7 +717,7 @@ bool DoAdd(CommandLine &)
// Escape special characters
string::iterator J = Name.begin();
- for (; J != Name.end(); J++)
+ for (; J != Name.end(); ++J)
if (*J == '"' || *J == ']' || *J == '[')
*J = '_';
@@ -756,7 +756,7 @@ bool DoAdd(CommandLine &)
// Print the sourcelist entries
cout << _("Source List entries for this Media are:") << endl;
- for (vector<string>::iterator I = List.begin(); I != List.end(); I++)
+ for (vector<string>::iterator I = List.begin(); I != List.end(); ++I)
{
string::size_type Space = (*I).find(' ');
if (Space == string::npos)
@@ -772,7 +772,7 @@ bool DoAdd(CommandLine &)
#endif
}
- for (vector<string>::iterator I = sList.begin(); I != sList.end(); I++)
+ for (vector<string>::iterator I = sList.begin(); I != sList.end(); ++I)
{
string::size_type Space = (*I).find(' ');
if (Space == string::npos)
diff --git a/apt/cmdline/apt-get.cc b/apt/cmdline/apt-get.cc
index a26c93c..dfcce7f 100644
--- a/apt/cmdline/apt-get.cc
+++ b/apt/cmdline/apt-get.cc
@@ -542,7 +542,7 @@ bool DownloadPackages(vector<string> &URLLst)
// Load the requestd sources into the fetcher
vector<string>::const_iterator I = URLLst.begin();
- for (; I != URLLst.end(); I++)
+ for (; I != URLLst.end(); ++I)
new pkgAcqFile(&Fetcher,*I,"",0,*I,flNotDir(*I));
// Run it
@@ -551,7 +551,7 @@ bool DownloadPackages(vector<string> &URLLst)
// Print error messages
bool Failed = false;
- for (pkgAcquire::ItemIterator I = Fetcher.ItemsBegin(); I != Fetcher.ItemsEnd(); I++)
+ for (pkgAcquire::ItemIterator I = Fetcher.ItemsBegin(); I != Fetcher.ItemsEnd(); ++I)
{
if ((*I)->Status == pkgAcquire::Item::StatDone &&
(*I)->Complete == true)
@@ -1407,7 +1407,7 @@ bool DoInstall(CommandLine &CmdL)
// Run over the matches
bool Hit = false;
for (vector<string>::const_iterator I = VS.begin();
- I != VS.end(); I++) {
+ I != VS.end(); ++I) {
Pkg = Cache->FindPkg(*I);
if (Pkg.end() == true)
@@ -1949,7 +1949,7 @@ bool DoSource(CommandLine &CmdL)
// Load them into the fetcher
for (vector<pkgSrcRecords::File>::const_iterator I = Lst.begin();
- I != Lst.end(); I++)
+ I != Lst.end(); ++I)
{
// Try to guess what sort of file it is we are getting.
// CNC:2002-07-06
@@ -2225,7 +2225,7 @@ bool DoBuildDep(CommandLine &CmdL)
vector <pkgSrcRecords::Parser::BuildDepRec>::iterator D;
pkgProblemResolver Fix(Cache);
bool skipAlternatives = false; // skip remaining alternatives in an or group
- for (D = BuildDeps.begin(); D != BuildDeps.end(); D++)
+ for (D = BuildDeps.begin(); D != BuildDeps.end(); ++D)
{
bool hasAlternatives = (((*D).Op & pkgCache::Dep::Or) == pkgCache::Dep::Or);
diff --git a/apt/cmdline/apt-shell.cc b/apt/cmdline/apt-shell.cc
index 9582291..0163314 100644
--- a/apt/cmdline/apt-shell.cc
+++ b/apt/cmdline/apt-shell.cc
@@ -1318,7 +1318,7 @@ bool DoInstall(CommandLine &CmdL)
// Run over the matches
bool Hit = false;
for (vector<string>::const_iterator I = VS.begin();
- I != VS.end(); I++) {
+ I != VS.end(); ++I) {
Pkg = Cache->FindPkg(*I);
if (Pkg.end() == true)
@@ -1776,7 +1776,7 @@ bool DoBuildDep(CommandLine &CmdL)
vector <pkgSrcRecords::Parser::BuildDepRec>::iterator D;
pkgProblemResolver Fix(Cache);
bool skipAlternatives = false; // skip remaining alternatives in an or group
- for (D = BuildDeps.begin(); D != BuildDeps.end(); D++)
+ for (D = BuildDeps.begin(); D != BuildDeps.end(); ++D)
{
bool hasAlternatives = (((*D).Op & pkgCache::Dep::Or) == pkgCache::Dep::Or);
diff --git a/apt/cmdline/indexcopy.cc b/apt/cmdline/indexcopy.cc
index fb2c7ef..64a9c1d 100644
--- a/apt/cmdline/indexcopy.cc
+++ b/apt/cmdline/indexcopy.cc
@@ -43,7 +43,7 @@ bool IndexCopy::CopyPackages(const string &CDROM,const string &Name,vector<strin
// Prepare the progress indicator
unsigned long long TotalSize = 0;
- for (vector<string>::iterator I = List.begin(); I != List.end(); I++)
+ for (vector<string>::iterator I = List.begin(); I != List.end(); ++I)
{
struct stat Buf;
if (stat(string(*I + GetFileName()).c_str(),&Buf) != 0 &&
@@ -57,7 +57,7 @@ bool IndexCopy::CopyPackages(const string &CDROM,const string &Name,vector<strin
unsigned int NotFound = 0;
unsigned int WrongSize = 0;
unsigned int Packages = 0;
- for (vector<string>::iterator I = List.begin(); I != List.end(); I++)
+ for (vector<string>::iterator I = List.begin(); I != List.end(); ++I)
{
string OrigPath = string(*I,CDROM.length());
unsigned long FileSize = 0;
diff --git a/apt/cmdline/rpmindexcopy.cc b/apt/cmdline/rpmindexcopy.cc
index 744af1f..9604d4b 100644
--- a/apt/cmdline/rpmindexcopy.cc
+++ b/apt/cmdline/rpmindexcopy.cc
@@ -53,7 +53,7 @@ bool RPMIndexCopy::CopyPackages(const string &CDROM,const string &Name,vector<st
// Prepare the progress indicator
unsigned long long TotalSize = 0;
- for (vector<string>::iterator I = List.begin(); I != List.end(); I++)
+ for (vector<string>::iterator I = List.begin(); I != List.end(); ++I)
{
struct stat Buf;
if (stat((*I).c_str(),&Buf) != 0)
@@ -67,7 +67,7 @@ bool RPMIndexCopy::CopyPackages(const string &CDROM,const string &Name,vector<st
// Keep track of global release processing
map<string,bool> GlobalReleases;
- for (vector<string>::iterator I = List.begin(); I != List.end(); I++)
+ for (vector<string>::iterator I = List.begin(); I != List.end(); ++I)
{
string OrigPath = string(*I,CDROM.length());
unsigned long long FileSize = 0;
diff --git a/apt/methods/ftp.cc b/apt/methods/ftp.cc
index 97d81d5..953febf 100644
--- a/apt/methods/ftp.cc
+++ b/apt/methods/ftp.cc
@@ -560,7 +560,7 @@ bool FTPConn::ExtGoPasv()
string::const_iterator List[4];
unsigned Count = 0;
Pos++;
- for (string::const_iterator I = Msg.begin() + Pos; I < Msg.end(); I++)
+ for (string::const_iterator I = Msg.begin() + Pos; I < Msg.end(); ++I)
{
if (*I != Msg[Pos])
continue;
diff --git a/apt/methods/http.cc b/apt/methods/http.cc
index dcdd651..c366798 100644
--- a/apt/methods/http.cc
+++ b/apt/methods/http.cc
@@ -383,10 +383,10 @@ int ServerState::RunHeaders()
if (Debug == true)
clog << Data;
- for (string::const_iterator I = Data.begin(); I < Data.end(); I++)
+ for (string::const_iterator I = Data.begin(); I < Data.end(); ++I)
{
string::const_iterator J = I;
- for (; J != Data.end() && *J != '\n' && *J != '\r';J++);
+ for (; J != Data.end() && *J != '\n' && *J != '\r';++J);
if (HeaderLine(string(I,J)) == false)
return 2;
I = J;
@@ -937,7 +937,7 @@ int HttpMethod::DealWithHeaders(FetchResult &Res,ServerState *Srv)
if (ParsedURI.User.empty())
{
for (CurrentAuth = AuthList.begin(); CurrentAuth != AuthList.end();
- CurrentAuth++)
+ ++CurrentAuth)
if (CurrentAuth->Host == Srv->ServerName.Host)
{
AuthUser = CurrentAuth->User;
@@ -968,7 +968,7 @@ int HttpMethod::DealWithHeaders(FetchResult &Res,ServerState *Srv)
NewAuthInfo.Password = AuthPass;
for (CurrentAuth = AuthList.begin(); CurrentAuth != AuthList.end();
- CurrentAuth++)
+ ++CurrentAuth)
if (CurrentAuth->Host == Srv->ServerName.Host)
{
*CurrentAuth = NewAuthInfo;
@@ -1345,7 +1345,7 @@ int HttpMethod::Loop()
StopRedirects = true;
else
{
- for (StringVectorIterator I = R.begin(); I != R.end(); I++)
+ for (StringVectorIterator I = R.begin(); I != R.end(); ++I)
if (Queue->Uri == *I)
{
R[0] = "STOP";
--
2.24.1
^ permalink raw reply [flat|nested] 84+ messages in thread
* [devel] [PATCH for apt v4 09/21] Rework identical conditions
2019-12-12 21:32 ` Andrey Savchenko
2019-12-13 8:29 ` Aleksei Nikiforov
2019-12-13 9:11 ` [devel] [PATCH for apt v3 " Aleksei Nikiforov
@ 2019-12-13 9:12 ` Aleksei Nikiforov
2019-12-13 9:18 ` [devel] [PATCH for apt v4] Additional loops improvements and beautification Aleksei Nikiforov
3 siblings, 0 replies; 84+ messages in thread
From: Aleksei Nikiforov @ 2019-12-13 9:12 UTC (permalink / raw)
To: devel; +Cc: Aleksei Nikiforov
Found via cppcheck:
[apt/methods/rsync.cc:371] -> [apt/methods/rsync.cc:373]:
(style) The if condition is the same as the previous if condition
---
apt/cmdline/apt-shell.cc | 6 ++++--
apt/methods/rsync.cc | 3 ++-
2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/apt/cmdline/apt-shell.cc b/apt/cmdline/apt-shell.cc
index fb8cd71..4ea9e2b 100644
--- a/apt/cmdline/apt-shell.cc
+++ b/apt/cmdline/apt-shell.cc
@@ -3044,8 +3044,9 @@ bool DoList(CommandLine &CmdL)
PkgSection = Pkg.Section();
StrLen = strlen(Str);
string status = "available";
- if (Pkg->CurrentVer != 0) status = "installed";
- if (Pkg->CurrentVer != 0)
+ if (Pkg->CurrentVer != 0)
+ {
+ status = "installed";
for (pkgCache::DepIterator D = Pkg.RevDependsList(); D.end() == false; D++)
{
pkgCache::PkgIterator P = D.ParentPkg();
@@ -3054,6 +3055,7 @@ bool DoList(CommandLine &CmdL)
continue;
status = "locked";
}
+ }
if (Pkg->CurrentVer != 0 && Cache[Pkg].Upgradable() == true) status = "upgradable";
if (Cache[Pkg].NewInstall()) status = "be-installed";
if (Cache[Pkg].Delete()) status = "be-removed";
diff --git a/apt/methods/rsync.cc b/apt/methods/rsync.cc
index bae22eb..64c9231 100644
--- a/apt/methods/rsync.cc
+++ b/apt/methods/rsync.cc
@@ -369,9 +369,10 @@ bool RsyncMethod::RsyncConnExec::Get(pkgAcqMethod *Owner, FetchResult &FRes, con
return false;
}
if ( RsyncMethod::Debug )
+ {
cerr << "RSYNC: Created pipe [" << p[0] << ',' << p[1] << ']' << endl;
- if ( RsyncMethod::Debug )
cerr << "RSYNC: Starting: " << string(argv) << endl;
+ }
switch ( ChildPid = fork() ) {
case -1:
--
2.24.1
^ permalink raw reply [flat|nested] 84+ messages in thread
* [devel] [PATCH for apt v4] Additional loops improvements and beautification
2019-12-12 21:32 ` Andrey Savchenko
` (2 preceding siblings ...)
2019-12-13 9:12 ` [devel] [PATCH for apt v4 09/21] Rework identical conditions Aleksei Nikiforov
@ 2019-12-13 9:18 ` Aleksei Nikiforov
2019-12-13 9:20 ` Aleksei Nikiforov
3 siblings, 1 reply; 84+ messages in thread
From: Aleksei Nikiforov @ 2019-12-13 9:18 UTC (permalink / raw)
To: devel; +Cc: Aleksei Nikiforov
Reduce iterators scope.
Update loop conditions and iteration expressions.
---
apt/cmdline/apt-get.cc | 12 +++++-------
apt/cmdline/apt-shell.cc | 2 +-
apt/methods/http.cc | 2 +-
3 files changed, 7 insertions(+), 9 deletions(-)
diff --git a/apt/cmdline/apt-get.cc b/apt/cmdline/apt-get.cc
index 74993e6..535df0a 100644
--- a/apt/cmdline/apt-get.cc
+++ b/apt/cmdline/apt-get.cc
@@ -542,8 +542,7 @@ bool DownloadPackages(vector<string> &URLLst)
pkgAcquire Fetcher(&Stat);
// Load the requestd sources into the fetcher
- vector<string>::const_iterator I = URLLst.begin();
- for (; I != URLLst.end(); ++I)
+ for (auto I = URLLst.begin(); I != URLLst.end(); ++I)
new pkgAcqFile(&Fetcher,*I,"",0,*I,flNotDir(*I));
// Run it
@@ -1722,8 +1721,7 @@ bool DoDSelectUpgrade(CommandLine &CmdL)
return false;
// Install everything with the install flag set
- pkgCache::PkgIterator I = Cache->PkgBegin();
- for (;I.end() != true; I++)
+ for (auto I = Cache->PkgBegin(); not I.end(); ++I)
{
/* Install the package only if it is a new install, the autoupgrader
will deal with the rest */
@@ -1733,7 +1731,7 @@ bool DoDSelectUpgrade(CommandLine &CmdL)
/* Now install their deps too, if we do this above then order of
the status file is significant for | groups */
- for (I = Cache->PkgBegin();I.end() != true; I++)
+ for (auto I = Cache->PkgBegin(); not I.end(); ++I)
{
/* Install the package only if it is a new install, the autoupgrader
will deal with the rest */
@@ -1742,7 +1740,7 @@ bool DoDSelectUpgrade(CommandLine &CmdL)
}
// Apply erasures now, they override everything else.
- for (I = Cache->PkgBegin();I.end() != true; I++)
+ for (auto I = Cache->PkgBegin(); not I.end(); ++I)
{
// Remove packages
if (I->SelectedState == pkgCache::State::DeInstall ||
@@ -1759,7 +1757,7 @@ bool DoDSelectUpgrade(CommandLine &CmdL)
// Hold back held packages.
if (_config->FindB("APT::Ignore-Hold",false) == false)
{
- for (pkgCache::PkgIterator I = Cache->PkgBegin(); I.end() == false; I++)
+ for (auto I = Cache->PkgBegin(); not I.end(); ++I)
{
if (I->SelectedState == pkgCache::State::Hold)
{
diff --git a/apt/cmdline/apt-shell.cc b/apt/cmdline/apt-shell.cc
index b9ae00d..3a6748b 100644
--- a/apt/cmdline/apt-shell.cc
+++ b/apt/cmdline/apt-shell.cc
@@ -3050,7 +3050,7 @@ bool DoList(CommandLine &CmdL)
if (Pkg->CurrentVer != 0)
{
status = "installed";
- for (pkgCache::DepIterator D = Pkg.RevDependsList(); D.end() == false; D++)
+ for (pkgCache::DepIterator D = Pkg.RevDependsList(); not D.end(); ++D)
{
pkgCache::PkgIterator P = D.ParentPkg();
if ((P->Flags & pkgCache::Flag::Essential) != pkgCache::Flag::Essential &&
diff --git a/apt/methods/http.cc b/apt/methods/http.cc
index 75b6873..c9a37de 100644
--- a/apt/methods/http.cc
+++ b/apt/methods/http.cc
@@ -386,7 +386,7 @@ int ServerState::RunHeaders()
if (Debug == true)
clog << Data;
- for (string::const_iterator I = Data.begin(); I < Data.end(); ++I)
+ for (string::const_iterator I = Data.begin(); I != Data.end(); ++I)
{
string::const_iterator J = I;
for (; J != Data.end() && *J != '\n' && *J != '\r';++J);
--
2.24.1
^ permalink raw reply [flat|nested] 84+ messages in thread
* Re: [devel] [PATCH for apt v4] Additional loops improvements and beautification
2019-12-13 9:18 ` [devel] [PATCH for apt v4] Additional loops improvements and beautification Aleksei Nikiforov
@ 2019-12-13 9:20 ` Aleksei Nikiforov
0 siblings, 0 replies; 84+ messages in thread
From: Aleksei Nikiforov @ 2019-12-13 9:20 UTC (permalink / raw)
To: devel
This patch should be positioned after 'Fix iterators comparison' one.
13.12.2019 12:18, Aleksei Nikiforov пишет:
> Reduce iterators scope.
> Update loop conditions and iteration expressions.
> ---
> apt/cmdline/apt-get.cc | 12 +++++-------
> apt/cmdline/apt-shell.cc | 2 +-
> apt/methods/http.cc | 2 +-
> 3 files changed, 7 insertions(+), 9 deletions(-)
>
> diff --git a/apt/cmdline/apt-get.cc b/apt/cmdline/apt-get.cc
> index 74993e6..535df0a 100644
> --- a/apt/cmdline/apt-get.cc
> +++ b/apt/cmdline/apt-get.cc
> @@ -542,8 +542,7 @@ bool DownloadPackages(vector<string> &URLLst)
> pkgAcquire Fetcher(&Stat);
>
> // Load the requestd sources into the fetcher
> - vector<string>::const_iterator I = URLLst.begin();
> - for (; I != URLLst.end(); ++I)
> + for (auto I = URLLst.begin(); I != URLLst.end(); ++I)
> new pkgAcqFile(&Fetcher,*I,"",0,*I,flNotDir(*I));
>
> // Run it
> @@ -1722,8 +1721,7 @@ bool DoDSelectUpgrade(CommandLine &CmdL)
> return false;
>
> // Install everything with the install flag set
> - pkgCache::PkgIterator I = Cache->PkgBegin();
> - for (;I.end() != true; I++)
> + for (auto I = Cache->PkgBegin(); not I.end(); ++I)
> {
> /* Install the package only if it is a new install, the autoupgrader
> will deal with the rest */
> @@ -1733,7 +1731,7 @@ bool DoDSelectUpgrade(CommandLine &CmdL)
>
> /* Now install their deps too, if we do this above then order of
> the status file is significant for | groups */
> - for (I = Cache->PkgBegin();I.end() != true; I++)
> + for (auto I = Cache->PkgBegin(); not I.end(); ++I)
> {
> /* Install the package only if it is a new install, the autoupgrader
> will deal with the rest */
> @@ -1742,7 +1740,7 @@ bool DoDSelectUpgrade(CommandLine &CmdL)
> }
>
> // Apply erasures now, they override everything else.
> - for (I = Cache->PkgBegin();I.end() != true; I++)
> + for (auto I = Cache->PkgBegin(); not I.end(); ++I)
> {
> // Remove packages
> if (I->SelectedState == pkgCache::State::DeInstall ||
> @@ -1759,7 +1757,7 @@ bool DoDSelectUpgrade(CommandLine &CmdL)
> // Hold back held packages.
> if (_config->FindB("APT::Ignore-Hold",false) == false)
> {
> - for (pkgCache::PkgIterator I = Cache->PkgBegin(); I.end() == false; I++)
> + for (auto I = Cache->PkgBegin(); not I.end(); ++I)
> {
> if (I->SelectedState == pkgCache::State::Hold)
> {
> diff --git a/apt/cmdline/apt-shell.cc b/apt/cmdline/apt-shell.cc
> index b9ae00d..3a6748b 100644
> --- a/apt/cmdline/apt-shell.cc
> +++ b/apt/cmdline/apt-shell.cc
> @@ -3050,7 +3050,7 @@ bool DoList(CommandLine &CmdL)
> if (Pkg->CurrentVer != 0)
> {
> status = "installed";
> - for (pkgCache::DepIterator D = Pkg.RevDependsList(); D.end() == false; D++)
> + for (pkgCache::DepIterator D = Pkg.RevDependsList(); not D.end(); ++D)
> {
> pkgCache::PkgIterator P = D.ParentPkg();
> if ((P->Flags & pkgCache::Flag::Essential) != pkgCache::Flag::Essential &&
> diff --git a/apt/methods/http.cc b/apt/methods/http.cc
> index 75b6873..c9a37de 100644
> --- a/apt/methods/http.cc
> +++ b/apt/methods/http.cc
> @@ -386,7 +386,7 @@ int ServerState::RunHeaders()
> if (Debug == true)
> clog << Data;
>
> - for (string::const_iterator I = Data.begin(); I < Data.end(); ++I)
> + for (string::const_iterator I = Data.begin(); I != Data.end(); ++I)
> {
> string::const_iterator J = I;
> for (; J != Data.end() && *J != '\n' && *J != '\r';++J);
>
^ permalink raw reply [flat|nested] 84+ messages in thread
* [devel] [PATCH for apt v2 02/21] Use correct types and type specifiers
2019-12-12 9:57 ` [devel] [PATCH for apt v2 00/21] Various fixes for Apt and basic integration test suite Aleksei Nikiforov
2019-12-12 9:57 ` [devel] [PATCH for apt v2 01/21] Replace post-increments with pre-increments Aleksei Nikiforov
@ 2019-12-12 9:57 ` Aleksei Nikiforov
2019-12-12 9:57 ` [devel] [PATCH for apt v2 03/21] Fix potential memory corruption in pkgCache::DepIterator::AllTargets() Aleksei Nikiforov
` (18 subsequent siblings)
20 siblings, 0 replies; 84+ messages in thread
From: Aleksei Nikiforov @ 2019-12-12 9:57 UTC (permalink / raw)
To: devel; +Cc: Aleksei Nikiforov
Found via cppcheck:
(warning) %li in format string (no. 1) requires 'long'
but the argument type is 'unsigned long'.
(warning) %llu in format string (no. 1) requires 'unsigned long long'
but the argument type is 'signed long long'.
And other similar warnings
---
apt/apt-pkg/contrib/cdromutl.cc | 4 ++--
apt/apt-pkg/contrib/strutl.cc | 8 ++++----
apt/cmdline/acqprogress.cc | 4 ++--
apt/methods/connect.cc | 4 ++--
apt/methods/http.cc | 9 +++------
apt/methods/http.h | 2 +-
6 files changed, 14 insertions(+), 17 deletions(-)
diff --git a/apt/apt-pkg/contrib/cdromutl.cc b/apt/apt-pkg/contrib/cdromutl.cc
index 6101145..139be84 100644
--- a/apt/apt-pkg/contrib/cdromutl.cc
+++ b/apt/apt-pkg/contrib/cdromutl.cc
@@ -232,8 +232,8 @@ bool IdentCdrom(const string &CD,string &Res,unsigned int Version)
return _error->Errno("statfs",_("Failed to stat the cdrom"));
// We use a kilobyte block size to advoid overflow
- sprintf(S,"%llu %llu",(long long)(Buf.f_blocks*(Buf.f_bsize/1024)),
- (long long)(Buf.f_bfree*(Buf.f_bsize/1024)));
+ sprintf(S,"%llu %llu",(unsigned long long)(Buf.f_blocks*(Buf.f_bsize/1024)),
+ (unsigned long long)(Buf.f_bfree*(Buf.f_bsize/1024)));
Hash.Add(S);
sprintf(S,"-%u",Version);
}
diff --git a/apt/apt-pkg/contrib/strutl.cc b/apt/apt-pkg/contrib/strutl.cc
index 6131d47..bde4ef5 100644
--- a/apt/apt-pkg/contrib/strutl.cc
+++ b/apt/apt-pkg/contrib/strutl.cc
@@ -292,23 +292,23 @@ string TimeToStr(unsigned long Sec)
{
if (Sec > 60*60*24)
{
- sprintf(S,"%lid %lih%lim%lis",Sec/60/60/24,(Sec/60/60) % 24,(Sec/60) % 60,Sec % 60);
+ sprintf(S,"%lud %luh%lum%lus",Sec/60/60/24,(Sec/60/60) % 24,(Sec/60) % 60,Sec % 60);
break;
}
if (Sec > 60*60)
{
- sprintf(S,"%lih%lim%lis",Sec/60/60,(Sec/60) % 60,Sec % 60);
+ sprintf(S,"%luh%lum%lus",Sec/60/60,(Sec/60) % 60,Sec % 60);
break;
}
if (Sec > 60)
{
- sprintf(S,"%lim%lis",Sec/60,Sec % 60);
+ sprintf(S,"%lum%lus",Sec/60,Sec % 60);
break;
}
- sprintf(S,"%lis",Sec);
+ sprintf(S,"%lus",Sec);
break;
}
diff --git a/apt/cmdline/acqprogress.cc b/apt/cmdline/acqprogress.cc
index 8fa9420..ecf9c2e 100644
--- a/apt/cmdline/acqprogress.cc
+++ b/apt/cmdline/acqprogress.cc
@@ -215,10 +215,10 @@ bool AcqTextStatus::Pulse(pkgAcquire *Owner)
{
if (Mode == Short)
snprintf(S,End-S," %lu%%",
- long(double(I->CurrentSize*100.0)/double(I->TotalSize)));
+ (unsigned long) (double(I->CurrentSize*100.0)/double(I->TotalSize)));
else
snprintf(S,End-S,"/%sB %lu%%",SizeToStr(I->TotalSize).c_str(),
- long(double(I->CurrentSize*100.0)/double(I->TotalSize)));
+ (unsigned long) (double(I->CurrentSize*100.0)/double(I->TotalSize)));
}
S += strlen(S);
snprintf(S,End-S,"]");
diff --git a/apt/methods/connect.cc b/apt/methods/connect.cc
index f086a7e..a25d6b4 100644
--- a/apt/methods/connect.cc
+++ b/apt/methods/connect.cc
@@ -162,7 +162,7 @@ bool Connect(const string &Host,int Port,const char *Service,int DefPort,std::un
// Convert the port name/number
char ServStr[300];
if (Port != 0)
- snprintf(ServStr,sizeof(ServStr),"%u",Port);
+ snprintf(ServStr,sizeof(ServStr),"%u",(unsigned) Port);
else
snprintf(ServStr,sizeof(ServStr),"%s",Service);
@@ -198,7 +198,7 @@ bool Connect(const string &Host,int Port,const char *Service,int DefPort,std::un
{
if (DefPort != 0)
{
- snprintf(ServStr,sizeof(ServStr),"%u",DefPort);
+ snprintf(ServStr,sizeof(ServStr),"%u",(unsigned) DefPort);
DefPort = 0;
continue;
}
diff --git a/apt/methods/http.cc b/apt/methods/http.cc
index da3e646..6d9a642 100644
--- a/apt/methods/http.cc
+++ b/apt/methods/http.cc
@@ -588,7 +588,7 @@ bool ServerState::HeaderLine(const string &Line)
if (sscanf(Val.c_str(),"bytes %llu-%*u/%llu",&StartPos,&Size) != 2)
return _error->Error(_("The http server sent an invalid Content-Range header"));
- if ((unsigned long long)StartPos > Size)
+ if (StartPos > Size)
return _error->Error(_("This http server has broken range support"));
return true;
}
@@ -1016,11 +1016,8 @@ int HttpMethod::DealWithHeaders(FetchResult &Res,ServerState *Srv)
FailTime = Srv->Date;
// Set the expected size
- if (Srv->StartPos >= 0)
- {
- Res.ResumePoint = Srv->StartPos;
- ftruncate(File->Fd(),Srv->StartPos);
- }
+ Res.ResumePoint = Srv->StartPos;
+ ftruncate(File->Fd(),Srv->StartPos);
// Set the start point
lseek(File->Fd(),0,SEEK_END);
diff --git a/apt/methods/http.h b/apt/methods/http.h
index b5c2d68..3b50e73 100644
--- a/apt/methods/http.h
+++ b/apt/methods/http.h
@@ -87,7 +87,7 @@ struct ServerState
// These are some statistics from the last parsed header lines
unsigned long long Size;
- signed long long StartPos;
+ unsigned long long StartPos;
time_t Date;
bool HaveContent;
enum {Chunked,Stream,Closes} Encoding;
--
2.24.1
^ permalink raw reply [flat|nested] 84+ messages in thread
* [devel] [PATCH for apt v2 03/21] Fix potential memory corruption in pkgCache::DepIterator::AllTargets()
2019-12-12 9:57 ` [devel] [PATCH for apt v2 00/21] Various fixes for Apt and basic integration test suite Aleksei Nikiforov
2019-12-12 9:57 ` [devel] [PATCH for apt v2 01/21] Replace post-increments with pre-increments Aleksei Nikiforov
2019-12-12 9:57 ` [devel] [PATCH for apt v2 02/21] Use correct types and type specifiers Aleksei Nikiforov
@ 2019-12-12 9:57 ` Aleksei Nikiforov
2019-12-12 9:57 ` [devel] [PATCH for apt v2 04/21] Get rid of nullptr dereference Aleksei Nikiforov
` (17 subsequent siblings)
20 siblings, 0 replies; 84+ messages in thread
From: Aleksei Nikiforov @ 2019-12-12 9:57 UTC (permalink / raw)
To: devel; +Cc: Aleksei Nikiforov
Use dynamic memory allocation instead of predefined buffer.
Found via cppcheck during investigation of:
(style) Condition 'Res!=0' is always true
---
apt/apt-pkg/pkgcache.cc | 45 ++++++++++++++++++++++++++---------------
1 file changed, 29 insertions(+), 16 deletions(-)
diff --git a/apt/apt-pkg/pkgcache.cc b/apt/apt-pkg/pkgcache.cc
index dfdba6b..afefe3b 100644
--- a/apt/apt-pkg/pkgcache.cc
+++ b/apt/apt-pkg/pkgcache.cc
@@ -388,8 +388,10 @@ bool pkgCache::DepIterator::SmartTargetPkg(PkgIterator &Result)
must be delete [] 'd */
pkgCache::Version **pkgCache::DepIterator::AllTargets()
{
- Version *Res[1024];
- unsigned int Size = 0;
+ Version **Res = nullptr;
+ size_t Size = 0;
+
+ while (true)
{
PkgIterator DPkg = TargetPkg();
@@ -405,9 +407,9 @@ pkgCache::Version **pkgCache::DepIterator::AllTargets()
continue;
Version *v = I;
- if (Res != 0 && Size > 0) {
+ if (Res != nullptr && Size > 0) {
bool seen = false;
- for (unsigned int j = 0; j < Size; ++j) {
+ for (size_t j = 0; j < Size; ++j) {
Version *vj = Res[j];
if (v == vj) {
seen = true;
@@ -418,8 +420,10 @@ pkgCache::Version **pkgCache::DepIterator::AllTargets()
continue;
}
- assert(Size < sizeof(Res)/sizeof(*Res));
- Res[Size++] = v;
+ if (Res != nullptr) {
+ Res[Size] = v;
+ }
+ Size++;
}
// Follow all provides
@@ -434,9 +438,9 @@ pkgCache::Version **pkgCache::DepIterator::AllTargets()
continue;
Version *v = I.OwnerVer();
- if (Res != 0 && Size > 0) {
+ if (Res != nullptr && Size > 0) {
bool seen = false;
- for (unsigned int j = 0; j < Size; ++j) {
+ for (size_t j = 0; j < Size; ++j) {
Version *vj = Res[j];
if (v == vj) {
seen = true;
@@ -447,16 +451,25 @@ pkgCache::Version **pkgCache::DepIterator::AllTargets()
continue;
}
- assert(Size < sizeof(Res)/sizeof(*Res));
- Res[Size++] = v;
+ if (Res != nullptr) {
+ Res[Size] = v;
+ }
+ Size++;
+ }
+
+ if (Res == 0)
+ {
+ Res = new Version *[Size+1];
+ Size = 0;
+ }
+ else
+ {
+ Res[Size] = nullptr;
+ break;
}
}
-
- Version **Ret = new Version *[Size+1];
- if (Size)
- memcpy(Ret, Res, Size*sizeof(*Res));
- Ret[Size] = 0;
- return Ret;
+
+ return Res;
}
/*}}}*/
// DepIterator::GlobOr - Compute an OR group /*{{{*/
--
2.24.1
^ permalink raw reply [flat|nested] 84+ messages in thread
* [devel] [PATCH for apt v2 04/21] Get rid of nullptr dereference
2019-12-12 9:57 ` [devel] [PATCH for apt v2 00/21] Various fixes for Apt and basic integration test suite Aleksei Nikiforov
` (2 preceding siblings ...)
2019-12-12 9:57 ` [devel] [PATCH for apt v2 03/21] Fix potential memory corruption in pkgCache::DepIterator::AllTargets() Aleksei Nikiforov
@ 2019-12-12 9:57 ` Aleksei Nikiforov
2019-12-12 9:57 ` [devel] [PATCH for apt v2 05/21] Fix memory access outside of allocated buffer ranges Aleksei Nikiforov
` (16 subsequent siblings)
20 siblings, 0 replies; 84+ messages in thread
From: Aleksei Nikiforov @ 2019-12-12 9:57 UTC (permalink / raw)
To: devel; +Cc: Aleksei Nikiforov
Found via cppcheck:
(warning) Possible null pointer dereference: CmdL
---
apt/cmdline/apt-get.cc | 22 +++++++++++++++++-----
apt/cmdline/apt-shell.cc | 34 +++++++++++++++++++++++-----------
2 files changed, 40 insertions(+), 16 deletions(-)
diff --git a/apt/cmdline/apt-get.cc b/apt/cmdline/apt-get.cc
index 3858752..1eff3eb 100644
--- a/apt/cmdline/apt-get.cc
+++ b/apt/cmdline/apt-get.cc
@@ -190,6 +190,8 @@ bool CheckOnly(CacheFile &Cache)
// CNC:2002-07-06
bool DoClean(CommandLine &CmdL);
bool DoAutoClean(CommandLine &CmdL);
+static bool DoCleanImpl();
+static bool DoAutoCleanImpl();
// InstallPackages - Actually download and install the packages /*{{{*/
// ---------------------------------------------------------------------
@@ -508,11 +510,10 @@ bool InstallPackages(CacheFile &Cache,bool ShwKept,bool Ask = true,
// CNC:2002-07-06
if (Res == pkgPackageManager::Completed)
{
- CommandLine *CmdL = NULL; // Watch out! If used will blow up!
if (_config->FindB("APT::Post-Install::Clean",false) == true)
- Ret &= DoClean(*CmdL);
+ Ret &= DoCleanImpl();
else if (_config->FindB("APT::Post-Install::AutoClean",false) == true)
- Ret &= DoAutoClean(*CmdL);
+ Ret &= DoAutoCleanImpl();
return Ret;
}
@@ -1790,7 +1791,7 @@ bool DoDSelectUpgrade(CommandLine &CmdL)
// DoClean - Remove download archives /*{{{*/
// ---------------------------------------------------------------------
/* */
-bool DoClean(CommandLine &CmdL)
+static bool DoCleanImpl()
{
if (_config->FindB("APT::Get::Simulate") == true)
{
@@ -1813,6 +1814,12 @@ bool DoClean(CommandLine &CmdL)
Fetcher.Clean(_config->FindDir("Dir::Cache::archives") + "partial/");
return true;
}
+
+bool DoClean(CommandLine &CmdL)
+{
+ return DoCleanImpl();
+}
+
/*}}}*/
// DoAutoClean - Smartly remove downloaded archives /*{{{*/
// ---------------------------------------------------------------------
@@ -1830,7 +1837,7 @@ class LogCleaner : public pkgArchiveCleaner
};
};
-bool DoAutoClean(CommandLine &CmdL)
+static bool DoAutoCleanImpl()
{
// Lock the archive directory
FileFd Lock;
@@ -1850,6 +1857,11 @@ bool DoAutoClean(CommandLine &CmdL)
return Cleaner.Go(_config->FindDir("Dir::Cache::archives"),*Cache) &&
Cleaner.Go(_config->FindDir("Dir::Cache::archives") + "partial/",*Cache);
}
+
+bool DoAutoClean(CommandLine &CmdL)
+{
+ return DoAutoCleanImpl();
+}
/*}}}*/
// DoCheck - Perform the check operation /*{{{*/
// ---------------------------------------------------------------------
diff --git a/apt/cmdline/apt-shell.cc b/apt/cmdline/apt-shell.cc
index 0aa5da5..d192783 100644
--- a/apt/cmdline/apt-shell.cc
+++ b/apt/cmdline/apt-shell.cc
@@ -261,6 +261,8 @@ bool ConfirmChanges(CacheFile &Cache, AutoRestore &StateGuard)
// CNC:2002-07-06
bool DoClean(CommandLine &CmdL);
bool DoAutoClean(CommandLine &CmdL);
+static bool DoCleanImpl();
+static bool DoAutoCleanImpl();
// InstallPackages - Actually download and install the packages /*{{{*/
// ---------------------------------------------------------------------
@@ -565,11 +567,10 @@ bool InstallPackages(CacheFile &Cache,bool ShwKept,bool Ask = true,
// CNC:2002-07-06
if (Res == pkgPackageManager::Completed)
{
- CommandLine *CmdL = NULL; // Watch out! If used will blow up!
if (_config->FindB("APT::Post-Install::Clean",false) == true)
- Ret &= DoClean(*CmdL);
+ Ret &= DoCleanImpl();
else if (_config->FindB("APT::Post-Install::AutoClean",false) == true)
- Ret &= DoAutoClean(*CmdL);
+ Ret &= DoAutoCleanImpl();
if (Ret)
{
@@ -1611,11 +1612,8 @@ bool DoDSelectUpgrade(CommandLine &CmdL)
// DoClean - Remove download archives /*{{{*/
// ---------------------------------------------------------------------
/* */
-bool DoClean(CommandLine &CmdL)
+static bool DoCleanImpl()
{
- if (CheckHelp(CmdL,0) == true)
- return true;
-
if (_config->FindB("APT::Get::Simulate") == true)
{
cout << "Del " << _config->FindDir("Dir::Cache::archives") << "* " <<
@@ -1637,6 +1635,14 @@ bool DoClean(CommandLine &CmdL)
Fetcher.Clean(_config->FindDir("Dir::Cache::archives") + "partial/");
return true;
}
+
+bool DoClean(CommandLine &CmdL)
+{
+ if (CheckHelp(CmdL,0) == true)
+ return true;
+
+ return DoCleanImpl();
+}
/*}}}*/
// DoAutoClean - Smartly remove downloaded archives /*{{{*/
// ---------------------------------------------------------------------
@@ -1654,11 +1660,8 @@ class LogCleaner : public pkgArchiveCleaner
};
};
-bool DoAutoClean(CommandLine &CmdL)
+static bool DoAutoCleanImpl()
{
- if (CheckHelp(CmdL,0) == true)
- return true;
-
// Lock the archive directory
FileFd Lock;
if (_config->FindB("Debug::NoLocking",false) == false)
@@ -1679,6 +1682,15 @@ bool DoAutoClean(CommandLine &CmdL)
return Cleaner.Go(_config->FindDir("Dir::Cache::archives"),*Cache) &&
Cleaner.Go(_config->FindDir("Dir::Cache::archives") + "partial/",*Cache);
}
+
+bool DoAutoClean(CommandLine &CmdL)
+{
+ if (CheckHelp(CmdL,0) == true)
+ return true;
+
+ return DoAutoCleanImpl();
+}
+
/*}}}*/
// DoCheck - Perform the check operation /*{{{*/
// ---------------------------------------------------------------------
--
2.24.1
^ permalink raw reply [flat|nested] 84+ messages in thread
* [devel] [PATCH for apt v2 05/21] Fix memory access outside of allocated buffer ranges
2019-12-12 9:57 ` [devel] [PATCH for apt v2 00/21] Various fixes for Apt and basic integration test suite Aleksei Nikiforov
` (3 preceding siblings ...)
2019-12-12 9:57 ` [devel] [PATCH for apt v2 04/21] Get rid of nullptr dereference Aleksei Nikiforov
@ 2019-12-12 9:57 ` Aleksei Nikiforov
2019-12-12 9:57 ` [devel] [PATCH for apt v2 06/21] Get rid of hardcoded array size Aleksei Nikiforov
` (15 subsequent siblings)
20 siblings, 0 replies; 84+ messages in thread
From: @ 2019-12-12 9:57 UTC (permalink / raw)
^ permalink raw reply [flat|nested] 84+ messages in thread
* [devel] [PATCH for apt v2 06/21] Get rid of hardcoded array size
2019-12-12 9:57 ` [devel] [PATCH for apt v2 00/21] Various fixes for Apt and basic integration test suite Aleksei Nikiforov
` (4 preceding siblings ...)
2019-12-12 9:57 ` [devel] [PATCH for apt v2 05/21] Fix memory access outside of allocated buffer ranges Aleksei Nikiforov
@ 2019-12-12 9:57 ` Aleksei Nikiforov
2019-12-12 9:57 ` [devel] [PATCH for apt v2 07/21] Use signed types to detect IO errors Aleksei Nikiforov
` (14 subsequent siblings)
20 siblings, 0 replies; 84+ messages in thread
From: @ 2019-12-12 9:57 UTC (permalink / raw)
^ permalink raw reply [flat|nested] 84+ messages in thread
* [devel] [PATCH for apt v2 07/21] Use signed types to detect IO errors
2019-12-12 9:57 ` [devel] [PATCH for apt v2 00/21] Various fixes for Apt and basic integration test suite Aleksei Nikiforov
` (5 preceding siblings ...)
2019-12-12 9:57 ` [devel] [PATCH for apt v2 06/21] Get rid of hardcoded array size Aleksei Nikiforov
@ 2019-12-12 9:57 ` Aleksei Nikiforov
2019-12-12 9:57 ` [devel] [PATCH for apt v2 08/21] Use 'explicit' keyword for constructors with one argument Aleksei Nikiforov
` (13 subsequent siblings)
20 siblings, 0 replies; 84+ messages in thread
From: @ 2019-12-12 9:57 UTC (permalink / raw)
^ permalink raw reply [flat|nested] 84+ messages in thread
* [devel] [PATCH for apt v2 08/21] Use 'explicit' keyword for constructors with one argument
2019-12-12 9:57 ` [devel] [PATCH for apt v2 00/21] Various fixes for Apt and basic integration test suite Aleksei Nikiforov
` (6 preceding siblings ...)
2019-12-12 9:57 ` [devel] [PATCH for apt v2 07/21] Use signed types to detect IO errors Aleksei Nikiforov
@ 2019-12-12 9:57 ` Aleksei Nikiforov
2019-12-12 9:57 ` [devel] [PATCH for apt v2 09/21] Rework identical conditions Aleksei Nikiforov
` (12 subsequent siblings)
20 siblings, 0 replies; 84+ messages in thread
From: @ 2019-12-12 9:57 UTC (permalink / raw)
^ permalink raw reply [flat|nested] 84+ messages in thread
* [devel] [PATCH for apt v2 09/21] Rework identical conditions
2019-12-12 9:57 ` [devel] [PATCH for apt v2 00/21] Various fixes for Apt and basic integration test suite Aleksei Nikiforov
` (7 preceding siblings ...)
2019-12-12 9:57 ` [devel] [PATCH for apt v2 08/21] Use 'explicit' keyword for constructors with one argument Aleksei Nikiforov
@ 2019-12-12 9:57 ` Aleksei Nikiforov
2019-12-12 19:55 ` Andrey Savchenko
2019-12-12 9:57 ` [devel] [PATCH for apt v2 10/21] Improve member variable initialization Aleksei Nikiforov
` (11 subsequent siblings)
20 siblings, 1 reply; 84+ messages in thread
From: @ 2019-12-12 9:57 UTC (permalink / raw)
^ permalink raw reply [flat|nested] 84+ messages in thread
* [devel] [PATCH for apt v2 10/21] Improve member variable initialization
2019-12-12 9:57 ` [devel] [PATCH for apt v2 00/21] Various fixes for Apt and basic integration test suite Aleksei Nikiforov
` (8 preceding siblings ...)
2019-12-12 9:57 ` [devel] [PATCH for apt v2 09/21] Rework identical conditions Aleksei Nikiforov
@ 2019-12-12 9:57 ` Aleksei Nikiforov
2019-12-12 9:57 ` [devel] [PATCH for apt v2 11/21] Remove useless variable shadowing Aleksei Nikiforov
` (10 subsequent siblings)
20 siblings, 0 replies; 84+ messages in thread
From: @ 2019-12-12 9:57 UTC (permalink / raw)
^ permalink raw reply [flat|nested] 84+ messages in thread
* [devel] [PATCH for apt v2 11/21] Remove useless variable shadowing
2019-12-12 9:57 ` [devel] [PATCH for apt v2 00/21] Various fixes for Apt and basic integration test suite Aleksei Nikiforov
` (9 preceding siblings ...)
2019-12-12 9:57 ` [devel] [PATCH for apt v2 10/21] Improve member variable initialization Aleksei Nikiforov
@ 2019-12-12 9:57 ` Aleksei Nikiforov
2019-12-12 21:19 ` Andrey Savchenko
2019-12-12 9:57 ` [devel] [PATCH for apt v2 12/21] Fortify against buffer overflows Aleksei Nikiforov
` (9 subsequent siblings)
20 siblings, 1 reply; 84+ messages in thread
From: @ 2019-12-12 9:57 UTC (permalink / raw)
^ permalink raw reply [flat|nested] 84+ messages in thread
* [devel] [PATCH for apt v2 12/21] Fortify against buffer overflows
2019-12-12 9:57 ` [devel] [PATCH for apt v2 00/21] Various fixes for Apt and basic integration test suite Aleksei Nikiforov
` (10 preceding siblings ...)
2019-12-12 9:57 ` [devel] [PATCH for apt v2 11/21] Remove useless variable shadowing Aleksei Nikiforov
@ 2019-12-12 9:57 ` Aleksei Nikiforov
2019-12-12 9:57 ` [devel] [PATCH for apt v2 13/21] Cacheiterators: sanitize increment operators and end() function Aleksei Nikiforov
` (8 subsequent siblings)
20 siblings, 0 replies; 84+ messages in thread
From: @ 2019-12-12 9:57 UTC (permalink / raw)
^ permalink raw reply [flat|nested] 84+ messages in thread
* [devel] [PATCH for apt v2 13/21] Cacheiterators: sanitize increment operators and end() function
2019-12-12 9:57 ` [devel] [PATCH for apt v2 00/21] Various fixes for Apt and basic integration test suite Aleksei Nikiforov
` (11 preceding siblings ...)
2019-12-12 9:57 ` [devel] [PATCH for apt v2 12/21] Fortify against buffer overflows Aleksei Nikiforov
@ 2019-12-12 9:57 ` Aleksei Nikiforov
2019-12-12 9:57 ` [devel] [PATCH for apt v2 14/21] Fix memory leaks Aleksei Nikiforov
` (7 subsequent siblings)
20 siblings, 0 replies; 84+ messages in thread
From: @ 2019-12-12 9:57 UTC (permalink / raw)
^ permalink raw reply [flat|nested] 84+ messages in thread
* [devel] [PATCH for apt v2 14/21] Fix memory leaks
2019-12-12 9:57 ` [devel] [PATCH for apt v2 00/21] Various fixes for Apt and basic integration test suite Aleksei Nikiforov
` (12 preceding siblings ...)
2019-12-12 9:57 ` [devel] [PATCH for apt v2 13/21] Cacheiterators: sanitize increment operators and end() function Aleksei Nikiforov
@ 2019-12-12 9:57 ` Aleksei Nikiforov
2019-12-12 9:57 ` [devel] [PATCH for apt v2 15/21] Fix incorrect delete operator Aleksei Nikiforov
` (6 subsequent siblings)
20 siblings, 0 replies; 84+ messages in thread
From: @ 2019-12-12 9:57 UTC (permalink / raw)
^ permalink raw reply [flat|nested] 84+ messages in thread
* [devel] [PATCH for apt v2 15/21] Fix incorrect delete operator
2019-12-12 9:57 ` [devel] [PATCH for apt v2 00/21] Various fixes for Apt and basic integration test suite Aleksei Nikiforov
` (13 preceding siblings ...)
2019-12-12 9:57 ` [devel] [PATCH for apt v2 14/21] Fix memory leaks Aleksei Nikiforov
@ 2019-12-12 9:57 ` Aleksei Nikiforov
2019-12-12 9:57 ` [devel] [PATCH for apt v2 16/21] Don't access uninitialized data Aleksei Nikiforov
` (5 subsequent siblings)
20 siblings, 0 replies; 84+ messages in thread
From: @ 2019-12-12 9:57 UTC (permalink / raw)
^ permalink raw reply [flat|nested] 84+ messages in thread
* [devel] [PATCH for apt v2 16/21] Don't access uninitialized data
2019-12-12 9:57 ` [devel] [PATCH for apt v2 00/21] Various fixes for Apt and basic integration test suite Aleksei Nikiforov
` (14 preceding siblings ...)
2019-12-12 9:57 ` [devel] [PATCH for apt v2 15/21] Fix incorrect delete operator Aleksei Nikiforov
@ 2019-12-12 9:57 ` Aleksei Nikiforov
2019-12-12 9:57 ` [devel] [PATCH for apt v2 17/21] Fix access after free error Aleksei Nikiforov
` (4 subsequent siblings)
20 siblings, 0 replies; 84+ messages in thread
From: @ 2019-12-12 9:57 UTC (permalink / raw)
^ permalink raw reply [flat|nested] 84+ messages in thread
* [devel] [PATCH for apt v2 17/21] Fix access after free error
2019-12-12 9:57 ` [devel] [PATCH for apt v2 00/21] Various fixes for Apt and basic integration test suite Aleksei Nikiforov
` (15 preceding siblings ...)
2019-12-12 9:57 ` [devel] [PATCH for apt v2 16/21] Don't access uninitialized data Aleksei Nikiforov
@ 2019-12-12 9:57 ` Aleksei Nikiforov
2019-12-12 9:57 ` [devel] [PATCH for apt v2 18/21] Apt-pipe: ensure mainloop function doesn't return uninitialized or garbage value Aleksei Nikiforov
` (3 subsequent siblings)
20 siblings, 0 replies; 84+ messages in thread
From: @ 2019-12-12 9:57 UTC (permalink / raw)
^ permalink raw reply [flat|nested] 84+ messages in thread
* [devel] [PATCH for apt v2 18/21] Apt-pipe: ensure mainloop function doesn't return uninitialized or garbage value
2019-12-12 9:57 ` [devel] [PATCH for apt v2 00/21] Various fixes for Apt and basic integration test suite Aleksei Nikiforov
` (16 preceding siblings ...)
2019-12-12 9:57 ` [devel] [PATCH for apt v2 17/21] Fix access after free error Aleksei Nikiforov
@ 2019-12-12 9:57 ` Aleksei Nikiforov
2019-12-12 9:57 ` [devel] [PATCH for apt v2 19/21] Don't use uninitialized value Aleksei Nikiforov
` (2 subsequent siblings)
20 siblings, 0 replies; 84+ messages in thread
From: @ 2019-12-12 9:57 UTC (permalink / raw)
^ permalink raw reply [flat|nested] 84+ messages in thread
* [devel] [PATCH for apt v2 19/21] Don't use uninitialized value
2019-12-12 9:57 ` [devel] [PATCH for apt v2 00/21] Various fixes for Apt and basic integration test suite Aleksei Nikiforov
` (17 preceding siblings ...)
2019-12-12 9:57 ` [devel] [PATCH for apt v2 18/21] Apt-pipe: ensure mainloop function doesn't return uninitialized or garbage value Aleksei Nikiforov
@ 2019-12-12 9:57 ` Aleksei Nikiforov
2019-12-12 9:57 ` [devel] [PATCH for apt v2 20/21] Get rid of dangling invalid pointer Aleksei Nikiforov
2019-12-12 9:57 ` [devel] [PATCH for apt v2 21/21] Fix invalid check of Queue against zero Aleksei Nikiforov
20 siblings, 0 replies; 84+ messages in thread
From: @ 2019-12-12 9:57 UTC (permalink / raw)
^ permalink raw reply [flat|nested] 84+ messages in thread
* [devel] [PATCH for apt v2 20/21] Get rid of dangling invalid pointer
2019-12-12 9:57 ` [devel] [PATCH for apt v2 00/21] Various fixes for Apt and basic integration test suite Aleksei Nikiforov
` (18 preceding siblings ...)
2019-12-12 9:57 ` [devel] [PATCH for apt v2 19/21] Don't use uninitialized value Aleksei Nikiforov
@ 2019-12-12 9:57 ` Aleksei Nikiforov
2019-12-12 9:57 ` [devel] [PATCH for apt v2 21/21] Fix invalid check of Queue against zero Aleksei Nikiforov
20 siblings, 0 replies; 84+ messages in thread
From: @ 2019-12-12 9:57 UTC (permalink / raw)
^ permalink raw reply [flat|nested] 84+ messages in thread
* [devel] [PATCH for apt v2 21/21] Fix invalid check of Queue against zero
2019-12-12 9:57 ` [devel] [PATCH for apt v2 00/21] Various fixes for Apt and basic integration test suite Aleksei Nikiforov
` (19 preceding siblings ...)
2019-12-12 9:57 ` [devel] [PATCH for apt v2 20/21] Get rid of dangling invalid pointer Aleksei Nikiforov
@ 2019-12-12 9:57 ` Aleksei Nikiforov
2019-12-12 19:08 ` Andrey Savchenko
20 siblings, 1 reply; 84+ messages in thread
From: @ 2019-12-12 9:57 UTC (permalink / raw)
^ permalink raw reply [flat|nested] 84+ messages in thread
* [devel] [PATCH for apt 03/38] Fix potential memory corruption in pkgCache::DepIterator::AllTargets()
2019-12-10 15:23 [devel] [PATCH for apt 00/38] Various fixes for Apt and basic integration test suite Aleksei Nikiforov
2019-12-10 15:23 ` [devel] [PATCH for apt 01/38] Replace post-increments with pre-increments Aleksei Nikiforov
2019-12-10 15:23 ` [devel] [PATCH for apt 02/38] Use correct types and type specifiers Aleksei Nikiforov
@ 2019-12-10 15:23 ` Aleksei Nikiforov
2019-12-10 15:23 ` [devel] [PATCH for apt 04/38] Get rid of nullptr dereference Aleksei Nikiforov
` (34 subsequent siblings)
37 siblings, 0 replies; 84+ messages in thread
From: @ 2019-12-10 15:23 UTC (permalink / raw)
^ permalink raw reply [flat|nested] 84+ messages in thread
* [devel] [PATCH for apt 04/38] Get rid of nullptr dereference
2019-12-10 15:23 [devel] [PATCH for apt 00/38] Various fixes for Apt and basic integration test suite Aleksei Nikiforov
` (2 preceding siblings ...)
2019-12-10 15:23 ` [devel] [PATCH for apt 03/38] Fix potential memory corruption in pkgCache::DepIterator::AllTargets() Aleksei Nikiforov
@ 2019-12-10 15:23 ` Aleksei Nikiforov
2019-12-10 15:23 ` [devel] [PATCH for apt 05/38] Fix memory access outside of allocated buffer ranges Aleksei Nikiforov
` (33 subsequent siblings)
37 siblings, 0 replies; 84+ messages in thread
From: @ 2019-12-10 15:23 UTC (permalink / raw)
^ permalink raw reply [flat|nested] 84+ messages in thread
* [devel] [PATCH for apt 05/38] Fix memory access outside of allocated buffer ranges
2019-12-10 15:23 [devel] [PATCH for apt 00/38] Various fixes for Apt and basic integration test suite Aleksei Nikiforov
` (3 preceding siblings ...)
2019-12-10 15:23 ` [devel] [PATCH for apt 04/38] Get rid of nullptr dereference Aleksei Nikiforov
@ 2019-12-10 15:23 ` Aleksei Nikiforov
2019-12-10 15:23 ` [devel] [PATCH for apt 06/38] Get rid of hardcoded array size Aleksei Nikiforov
` (32 subsequent siblings)
37 siblings, 0 replies; 84+ messages in thread
From: @ 2019-12-10 15:23 UTC (permalink / raw)
^ permalink raw reply [flat|nested] 84+ messages in thread
* [devel] [PATCH for apt 06/38] Get rid of hardcoded array size
2019-12-10 15:23 [devel] [PATCH for apt 00/38] Various fixes for Apt and basic integration test suite Aleksei Nikiforov
` (4 preceding siblings ...)
2019-12-10 15:23 ` [devel] [PATCH for apt 05/38] Fix memory access outside of allocated buffer ranges Aleksei Nikiforov
@ 2019-12-10 15:23 ` Aleksei Nikiforov
2019-12-10 15:23 ` [devel] [PATCH for apt 07/38] Use signed types to detect IO errors Aleksei Nikiforov
` (31 subsequent siblings)
37 siblings, 0 replies; 84+ messages in thread
From: @ 2019-12-10 15:23 UTC (permalink / raw)
^ permalink raw reply [flat|nested] 84+ messages in thread
* [devel] [PATCH for apt 07/38] Use signed types to detect IO errors
2019-12-10 15:23 [devel] [PATCH for apt 00/38] Various fixes for Apt and basic integration test suite Aleksei Nikiforov
` (5 preceding siblings ...)
2019-12-10 15:23 ` [devel] [PATCH for apt 06/38] Get rid of hardcoded array size Aleksei Nikiforov
@ 2019-12-10 15:23 ` Aleksei Nikiforov
2019-12-10 15:23 ` [devel] [PATCH for apt 08/38] Use 'explicit' keyword for constructors with one argument Aleksei Nikiforov
` (30 subsequent siblings)
37 siblings, 0 replies; 84+ messages in thread
From: @ 2019-12-10 15:23 UTC (permalink / raw)
^ permalink raw reply [flat|nested] 84+ messages in thread
* [devel] [PATCH for apt 08/38] Use 'explicit' keyword for constructors with one argument
2019-12-10 15:23 [devel] [PATCH for apt 00/38] Various fixes for Apt and basic integration test suite Aleksei Nikiforov
` (6 preceding siblings ...)
2019-12-10 15:23 ` [devel] [PATCH for apt 07/38] Use signed types to detect IO errors Aleksei Nikiforov
@ 2019-12-10 15:23 ` Aleksei Nikiforov
2019-12-10 15:23 ` [devel] [PATCH for apt 09/38] Rework identical conditions Aleksei Nikiforov
` (29 subsequent siblings)
37 siblings, 0 replies; 84+ messages in thread
From: @ 2019-12-10 15:23 UTC (permalink / raw)
^ permalink raw reply [flat|nested] 84+ messages in thread
* [devel] [PATCH for apt 09/38] Rework identical conditions
2019-12-10 15:23 [devel] [PATCH for apt 00/38] Various fixes for Apt and basic integration test suite Aleksei Nikiforov
` (7 preceding siblings ...)
2019-12-10 15:23 ` [devel] [PATCH for apt 08/38] Use 'explicit' keyword for constructors with one argument Aleksei Nikiforov
@ 2019-12-10 15:23 ` Aleksei Nikiforov
2019-12-10 15:23 ` [devel] [PATCH for apt 10/38] Improve member variable initialization Aleksei Nikiforov
` (28 subsequent siblings)
37 siblings, 0 replies; 84+ messages in thread
From: @ 2019-12-10 15:23 UTC (permalink / raw)
^ permalink raw reply [flat|nested] 84+ messages in thread
* [devel] [PATCH for apt 10/38] Improve member variable initialization
2019-12-10 15:23 [devel] [PATCH for apt 00/38] Various fixes for Apt and basic integration test suite Aleksei Nikiforov
` (8 preceding siblings ...)
2019-12-10 15:23 ` [devel] [PATCH for apt 09/38] Rework identical conditions Aleksei Nikiforov
@ 2019-12-10 15:23 ` Aleksei Nikiforov
2019-12-10 15:23 ` [devel] [PATCH for apt 11/38] Remove useless variable shadowing Aleksei Nikiforov
` (27 subsequent siblings)
37 siblings, 0 replies; 84+ messages in thread
From: @ 2019-12-10 15:23 UTC (permalink / raw)
^ permalink raw reply [flat|nested] 84+ messages in thread
* [devel] [PATCH for apt 11/38] Remove useless variable shadowing
2019-12-10 15:23 [devel] [PATCH for apt 00/38] Various fixes for Apt and basic integration test suite Aleksei Nikiforov
` (9 preceding siblings ...)
2019-12-10 15:23 ` [devel] [PATCH for apt 10/38] Improve member variable initialization Aleksei Nikiforov
@ 2019-12-10 15:23 ` Aleksei Nikiforov
2019-12-10 15:23 ` [devel] [PATCH for apt 12/38] Fortify against buffer overflows Aleksei Nikiforov
` (26 subsequent siblings)
37 siblings, 0 replies; 84+ messages in thread
From: @ 2019-12-10 15:23 UTC (permalink / raw)
^ permalink raw reply [flat|nested] 84+ messages in thread
* [devel] [PATCH for apt 12/38] Fortify against buffer overflows
2019-12-10 15:23 [devel] [PATCH for apt 00/38] Various fixes for Apt and basic integration test suite Aleksei Nikiforov
` (10 preceding siblings ...)
2019-12-10 15:23 ` [devel] [PATCH for apt 11/38] Remove useless variable shadowing Aleksei Nikiforov
@ 2019-12-10 15:23 ` Aleksei Nikiforov
2019-12-10 15:23 ` [devel] [PATCH for apt 13/38] Cacheiterators: sanitize increment operators and end() function Aleksei Nikiforov
` (25 subsequent siblings)
37 siblings, 0 replies; 84+ messages in thread
From: @ 2019-12-10 15:23 UTC (permalink / raw)
^ permalink raw reply [flat|nested] 84+ messages in thread
* [devel] [PATCH for apt 13/38] Cacheiterators: sanitize increment operators and end() function
2019-12-10 15:23 [devel] [PATCH for apt 00/38] Various fixes for Apt and basic integration test suite Aleksei Nikiforov
` (11 preceding siblings ...)
2019-12-10 15:23 ` [devel] [PATCH for apt 12/38] Fortify against buffer overflows Aleksei Nikiforov
@ 2019-12-10 15:23 ` Aleksei Nikiforov
2019-12-10 15:23 ` [devel] [PATCH for apt 14/38] Fix memory leaks Aleksei Nikiforov
` (24 subsequent siblings)
37 siblings, 0 replies; 84+ messages in thread
From: @ 2019-12-10 15:23 UTC (permalink / raw)
^ permalink raw reply [flat|nested] 84+ messages in thread
* [devel] [PATCH for apt 14/38] Fix memory leaks
2019-12-10 15:23 [devel] [PATCH for apt 00/38] Various fixes for Apt and basic integration test suite Aleksei Nikiforov
` (12 preceding siblings ...)
2019-12-10 15:23 ` [devel] [PATCH for apt 13/38] Cacheiterators: sanitize increment operators and end() function Aleksei Nikiforov
@ 2019-12-10 15:23 ` Aleksei Nikiforov
2019-12-10 15:23 ` [devel] [PATCH for apt 15/38] Fix incorrect delete operator Aleksei Nikiforov
` (23 subsequent siblings)
37 siblings, 0 replies; 84+ messages in thread
From: @ 2019-12-10 15:23 UTC (permalink / raw)
^ permalink raw reply [flat|nested] 84+ messages in thread
* [devel] [PATCH for apt 15/38] Fix incorrect delete operator
2019-12-10 15:23 [devel] [PATCH for apt 00/38] Various fixes for Apt and basic integration test suite Aleksei Nikiforov
` (13 preceding siblings ...)
2019-12-10 15:23 ` [devel] [PATCH for apt 14/38] Fix memory leaks Aleksei Nikiforov
@ 2019-12-10 15:23 ` Aleksei Nikiforov
2019-12-10 15:23 ` [devel] [PATCH for apt 16/38] Don't access uninitialized data Aleksei Nikiforov
` (22 subsequent siblings)
37 siblings, 0 replies; 84+ messages in thread
From: @ 2019-12-10 15:23 UTC (permalink / raw)
^ permalink raw reply [flat|nested] 84+ messages in thread
* [devel] [PATCH for apt 16/38] Don't access uninitialized data
2019-12-10 15:23 [devel] [PATCH for apt 00/38] Various fixes for Apt and basic integration test suite Aleksei Nikiforov
` (14 preceding siblings ...)
2019-12-10 15:23 ` [devel] [PATCH for apt 15/38] Fix incorrect delete operator Aleksei Nikiforov
@ 2019-12-10 15:23 ` Aleksei Nikiforov
2019-12-10 15:23 ` [devel] [PATCH for apt 17/38] Fix access after free error Aleksei Nikiforov
` (21 subsequent siblings)
37 siblings, 0 replies; 84+ messages in thread
From: @ 2019-12-10 15:23 UTC (permalink / raw)
^ permalink raw reply [flat|nested] 84+ messages in thread
* [devel] [PATCH for apt 17/38] Fix access after free error
2019-12-10 15:23 [devel] [PATCH for apt 00/38] Various fixes for Apt and basic integration test suite Aleksei Nikiforov
` (15 preceding siblings ...)
2019-12-10 15:23 ` [devel] [PATCH for apt 16/38] Don't access uninitialized data Aleksei Nikiforov
@ 2019-12-10 15:23 ` Aleksei Nikiforov
2019-12-10 15:23 ` [devel] [PATCH for apt 18/38] Apt-pipe: ensure mainloop function doesn't return uninitialized or garbage value Aleksei Nikiforov
` (20 subsequent siblings)
37 siblings, 0 replies; 84+ messages in thread
From: @ 2019-12-10 15:23 UTC (permalink / raw)
^ permalink raw reply [flat|nested] 84+ messages in thread
* [devel] [PATCH for apt 18/38] Apt-pipe: ensure mainloop function doesn't return uninitialized or garbage value
2019-12-10 15:23 [devel] [PATCH for apt 00/38] Various fixes for Apt and basic integration test suite Aleksei Nikiforov
` (16 preceding siblings ...)
2019-12-10 15:23 ` [devel] [PATCH for apt 17/38] Fix access after free error Aleksei Nikiforov
@ 2019-12-10 15:23 ` Aleksei Nikiforov
2019-12-10 15:23 ` [devel] [PATCH for apt 19/38] Don't use uninitialized value Aleksei Nikiforov
` (19 subsequent siblings)
37 siblings, 0 replies; 84+ messages in thread
From: @ 2019-12-10 15:23 UTC (permalink / raw)
^ permalink raw reply [flat|nested] 84+ messages in thread
* [devel] [PATCH for apt 19/38] Don't use uninitialized value
2019-12-10 15:23 [devel] [PATCH for apt 00/38] Various fixes for Apt and basic integration test suite Aleksei Nikiforov
` (17 preceding siblings ...)
2019-12-10 15:23 ` [devel] [PATCH for apt 18/38] Apt-pipe: ensure mainloop function doesn't return uninitialized or garbage value Aleksei Nikiforov
@ 2019-12-10 15:23 ` Aleksei Nikiforov
2019-12-10 15:23 ` [devel] [PATCH for apt 20/38] Get rid of dangling invalid pointer Aleksei Nikiforov
` (18 subsequent siblings)
37 siblings, 0 replies; 84+ messages in thread
From: @ 2019-12-10 15:23 UTC (permalink / raw)
^ permalink raw reply [flat|nested] 84+ messages in thread
* [devel] [PATCH for apt 20/38] Get rid of dangling invalid pointer
2019-12-10 15:23 [devel] [PATCH for apt 00/38] Various fixes for Apt and basic integration test suite Aleksei Nikiforov
` (18 preceding siblings ...)
2019-12-10 15:23 ` [devel] [PATCH for apt 19/38] Don't use uninitialized value Aleksei Nikiforov
@ 2019-12-10 15:23 ` Aleksei Nikiforov
2019-12-10 15:23 ` [devel] [PATCH for apt 21/38] Fix invalid check of Queue against zero Aleksei Nikiforov
` (17 subsequent siblings)
37 siblings, 0 replies; 84+ messages in thread
From: @ 2019-12-10 15:23 UTC (permalink / raw)
^ permalink raw reply [flat|nested] 84+ messages in thread
* [devel] [PATCH for apt 21/38] Fix invalid check of Queue against zero
2019-12-10 15:23 [devel] [PATCH for apt 00/38] Various fixes for Apt and basic integration test suite Aleksei Nikiforov
` (19 preceding siblings ...)
2019-12-10 15:23 ` [devel] [PATCH for apt 20/38] Get rid of dangling invalid pointer Aleksei Nikiforov
@ 2019-12-10 15:23 ` Aleksei Nikiforov
2019-12-10 15:23 ` [devel] [PATCH for apt 22/38] Fix iterators comparison Aleksei Nikiforov
` (16 subsequent siblings)
37 siblings, 0 replies; 84+ messages in thread
From: @ 2019-12-10 15:23 UTC (permalink / raw)
^ permalink raw reply [flat|nested] 84+ messages in thread
* [devel] [PATCH for apt 22/38] Fix iterators comparison
2019-12-10 15:23 [devel] [PATCH for apt 00/38] Various fixes for Apt and basic integration test suite Aleksei Nikiforov
` (20 preceding siblings ...)
2019-12-10 15:23 ` [devel] [PATCH for apt 21/38] Fix invalid check of Queue against zero Aleksei Nikiforov
@ 2019-12-10 15:23 ` Aleksei Nikiforov
2019-12-10 15:23 ` [devel] [PATCH for apt 23/38] Fortify ParseQuoteWord function Aleksei Nikiforov
` (15 subsequent siblings)
37 siblings, 0 replies; 84+ messages in thread
From: @ 2019-12-10 15:23 UTC (permalink / raw)
^ permalink raw reply [flat|nested] 84+ messages in thread
* [devel] [PATCH for apt 23/38] Fortify ParseQuoteWord function
2019-12-10 15:23 [devel] [PATCH for apt 00/38] Various fixes for Apt and basic integration test suite Aleksei Nikiforov
` (21 preceding siblings ...)
2019-12-10 15:23 ` [devel] [PATCH for apt 22/38] Fix iterators comparison Aleksei Nikiforov
@ 2019-12-10 15:23 ` Aleksei Nikiforov
2019-12-10 15:23 ` [devel] [PATCH for apt 24/38] Improve ipv6 address handling Aleksei Nikiforov
` (14 subsequent siblings)
37 siblings, 0 replies; 84+ messages in thread
From: @ 2019-12-10 15:23 UTC (permalink / raw)
^ permalink raw reply [flat|nested] 84+ messages in thread
* [devel] [PATCH for apt 24/38] Improve ipv6 address handling
2019-12-10 15:23 [devel] [PATCH for apt 00/38] Various fixes for Apt and basic integration test suite Aleksei Nikiforov
` (22 preceding siblings ...)
2019-12-10 15:23 ` [devel] [PATCH for apt 23/38] Fortify ParseQuoteWord function Aleksei Nikiforov
@ 2019-12-10 15:23 ` Aleksei Nikiforov
2019-12-10 15:23 ` [devel] [PATCH for apt 25/38] Check subsecond modification time for cached files Aleksei Nikiforov
` (13 subsequent siblings)
37 siblings, 0 replies; 84+ messages in thread
From: @ 2019-12-10 15:23 UTC (permalink / raw)
^ permalink raw reply [flat|nested] 84+ messages in thread
* [devel] [PATCH for apt 25/38] Check subsecond modification time for cached files
2019-12-10 15:23 [devel] [PATCH for apt 00/38] Various fixes for Apt and basic integration test suite Aleksei Nikiforov
` (23 preceding siblings ...)
2019-12-10 15:23 ` [devel] [PATCH for apt 24/38] Improve ipv6 address handling Aleksei Nikiforov
@ 2019-12-10 15:23 ` Aleksei Nikiforov
2019-12-10 15:23 ` [devel] [PATCH for apt 26/38] Fix warning about truncation of value of pkgCache::Header::HeaderSz Aleksei Nikiforov
` (12 subsequent siblings)
37 siblings, 0 replies; 84+ messages in thread
From: @ 2019-12-10 15:23 UTC (permalink / raw)
^ permalink raw reply [flat|nested] 84+ messages in thread
* [devel] [PATCH for apt 26/38] Fix warning about truncation of value of pkgCache::Header::HeaderSz
2019-12-10 15:23 [devel] [PATCH for apt 00/38] Various fixes for Apt and basic integration test suite Aleksei Nikiforov
` (24 preceding siblings ...)
2019-12-10 15:23 ` [devel] [PATCH for apt 25/38] Check subsecond modification time for cached files Aleksei Nikiforov
@ 2019-12-10 15:23 ` Aleksei Nikiforov
2019-12-10 22:57 ` Dmitry V. Levin
2019-12-10 15:23 ` [devel] [PATCH for apt 27/38] FileFd: all files are closed automatically Aleksei Nikiforov
` (11 subsequent siblings)
37 siblings, 1 reply; 84+ messages in thread
From: @ 2019-12-10 15:23 UTC (permalink / raw)
^ permalink raw reply [flat|nested] 84+ messages in thread
* Re: [devel] [PATCH for apt 26/38] Fix warning about truncation of value of pkgCache::Header::HeaderSz
2019-12-10 15:23 ` [devel] [PATCH for apt 26/38] Fix warning about truncation of value of pkgCache::Header::HeaderSz Aleksei Nikiforov
@ 2019-12-10 22:57 ` Dmitry V. Levin
2019-12-11 7:51 ` Aleksei Nikiforov
0 siblings, 1 reply; 84+ messages in thread
From: @ 2019-12-10 22:57 UTC (permalink / raw)
^ permalink raw reply [flat|nested] 84+ messages in thread
* Re: [devel] [PATCH for apt 26/38] Fix warning about truncation of value of pkgCache::Header::HeaderSz
2019-12-10 22:57 ` Dmitry V. Levin
@ 2019-12-11 7:51 ` Aleksei Nikiforov
2019-12-11 23:41 ` Dmitry V. Levin
0 siblings, 1 reply; 84+ messages in thread
From: @ 2019-12-11 7:51 UTC (permalink / raw)
^ permalink raw reply [flat|nested] 84+ messages in thread
* Re: [devel] [PATCH for apt 26/38] Fix warning about truncation of value of pkgCache::Header::HeaderSz
2019-12-11 7:51 ` Aleksei Nikiforov
@ 2019-12-11 23:41 ` Dmitry V. Levin
2019-12-12 7:38 ` Aleksei Nikiforov
0 siblings, 1 reply; 84+ messages in thread
From: Dmitry V. Levin @ 2019-12-11 23:41 UTC (permalink / raw)
To: ALT Devel discussion list
On Wed, Dec 11, 2019 at 10:51:28AM +0300, Aleksei Nikiforov wrote:
> 11.12.2019 1:58, Dmitry V. Levin пишет:
> > On Tue, Dec 10, 2019 at 06:23:31PM +0300, Aleksei Nikiforov wrote:
> >> Update types of other variables as well.
> >
> > What's the rationale for changing types of *all* these fields,
> > and for choosing architecture-dependent "unsigned long"
> > as the new type instead of "unsigned short"?
>
> Value of HeaderSz is truncated. IIRC, assigned value was around 270k.
> Types of other variables were changed for uniformity and possible
> mitigation of same overflow issues in future, but may be reverted for
> now. Since type wasn't architecture-independent, similar
> architecture-dependent type of bigger size was used. All of this may be
> changed as needed, with only exception of keeping size of HeaderSz
> increased.
How many objects containing struct pkgCache::Header are created?
If there are just a few of them, then we don't have to worry about
the memory footprint and can make them all unsigned long (== size_t)
as you did in your patch.
> >> apt/apt-pkg/pkgcache.h | 14 +++++++-------
> >> 1 file changed, 7 insertions(+), 7 deletions(-)
> >>
> >> diff --git a/apt/apt-pkg/pkgcache.h b/apt/apt-pkg/pkgcache.h
> >> index 05a63bc..6b44522 100644
> >> --- a/apt/apt-pkg/pkgcache.h
> >> +++ b/apt/apt-pkg/pkgcache.h
> >> @@ -175,13 +175,13 @@ struct pkgCache::Header
> >> unsigned long OptionsHash;
> >>
> >> // Size of structure values
> >> - unsigned short HeaderSz;
> >> - unsigned short PackageSz;
> >> - unsigned short PackageFileSz;
> >> - unsigned short VersionSz;
> >> - unsigned short DependencySz;
> >> - unsigned short ProvidesSz;
> >> - unsigned short VerFileSz;
> >> + unsigned long HeaderSz;
> >> + unsigned long PackageSz;
> >> + unsigned long PackageFileSz;
> >> + unsigned long VersionSz;
> >> + unsigned long DependencySz;
> >> + unsigned long ProvidesSz;
> >> + unsigned long VerFileSz;
> >>
> >> // Structure counts
> >> unsigned long PackageCount;
--
ldv
^ permalink raw reply [flat|nested] 84+ messages in thread
* Re: [devel] [PATCH for apt 26/38] Fix warning about truncation of value of pkgCache::Header::HeaderSz
2019-12-11 23:41 ` Dmitry V. Levin
@ 2019-12-12 7:38 ` Aleksei Nikiforov
0 siblings, 0 replies; 84+ messages in thread
From: Aleksei Nikiforov @ 2019-12-12 7:38 UTC (permalink / raw)
To: devel
12.12.2019 2:41, Dmitry V. Levin пишет:
> On Wed, Dec 11, 2019 at 10:51:28AM +0300, Aleksei Nikiforov wrote:
>> 11.12.2019 1:58, Dmitry V. Levin пишет:
>>> On Tue, Dec 10, 2019 at 06:23:31PM +0300, Aleksei Nikiforov wrote:
>>>> Update types of other variables as well.
>>>
>>> What's the rationale for changing types of *all* these fields,
>>> and for choosing architecture-dependent "unsigned long"
>>> as the new type instead of "unsigned short"?
>>
>> Value of HeaderSz is truncated. IIRC, assigned value was around 270k.
>> Types of other variables were changed for uniformity and possible
>> mitigation of same overflow issues in future, but may be reverted for
>> now. Since type wasn't architecture-independent, similar
>> architecture-dependent type of bigger size was used. All of this may be
>> changed as needed, with only exception of keeping size of HeaderSz
>> increased.
>
> How many objects containing struct pkgCache::Header are created?
> If there are just a few of them, then we don't have to worry about
> the memory footprint and can make them all unsigned long (== size_t)
> as you did in your patch.
>
One object created per pkgCacheGenerator instance AFAIK, so it
translates to one per memory map, i.e. usually one per application instance.
>>>> apt/apt-pkg/pkgcache.h | 14 +++++++-------
>>>> 1 file changed, 7 insertions(+), 7 deletions(-)
>>>>
>>>> diff --git a/apt/apt-pkg/pkgcache.h b/apt/apt-pkg/pkgcache.h
>>>> index 05a63bc..6b44522 100644
>>>> --- a/apt/apt-pkg/pkgcache.h
>>>> +++ b/apt/apt-pkg/pkgcache.h
>>>> @@ -175,13 +175,13 @@ struct pkgCache::Header
>>>> unsigned long OptionsHash;
>>>>
>>>> // Size of structure values
>>>> - unsigned short HeaderSz;
>>>> - unsigned short PackageSz;
>>>> - unsigned short PackageFileSz;
>>>> - unsigned short VersionSz;
>>>> - unsigned short DependencySz;
>>>> - unsigned short ProvidesSz;
>>>> - unsigned short VerFileSz;
>>>> + unsigned long HeaderSz;
>>>> + unsigned long PackageSz;
>>>> + unsigned long PackageFileSz;
>>>> + unsigned long VersionSz;
>>>> + unsigned long DependencySz;
>>>> + unsigned long ProvidesSz;
>>>> + unsigned long VerFileSz;
>>>>
>>>> // Structure counts
>>>> unsigned long PackageCount;
>
^ permalink raw reply [flat|nested] 84+ messages in thread
* [devel] [PATCH for apt 27/38] FileFd: all files are closed automatically
2019-12-10 15:23 [devel] [PATCH for apt 00/38] Various fixes for Apt and basic integration test suite Aleksei Nikiforov
` (25 preceding siblings ...)
2019-12-10 15:23 ` [devel] [PATCH for apt 26/38] Fix warning about truncation of value of pkgCache::Header::HeaderSz Aleksei Nikiforov
@ 2019-12-10 15:23 ` Aleksei Nikiforov
2019-12-10 15:23 ` [devel] [PATCH for apt 28/38] Fix resource leaks in pkgCacheFile class Aleksei Nikiforov
` (10 subsequent siblings)
37 siblings, 0 replies; 84+ messages in thread
From: Aleksei Nikiforov @ 2019-12-10 15:23 UTC (permalink / raw)
To: devel; +Cc: Aleksei Nikiforov
Remove unused API
---
apt/apt-pkg/contrib/fileutl.cc | 4 +---
apt/apt-pkg/contrib/fileutl.h | 8 +++++---
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/apt/apt-pkg/contrib/fileutl.cc b/apt/apt-pkg/contrib/fileutl.cc
index abcf363..38a28ec 100644
--- a/apt/apt-pkg/contrib/fileutl.cc
+++ b/apt/apt-pkg/contrib/fileutl.cc
@@ -682,7 +682,6 @@ bool ExecWait(int Pid,const char *Name,bool Reap)
bool FileFd::Open(const string &FileName,OpenMode Mode, unsigned long Perms)
{
Close();
- Flags = AutoClose;
switch (Mode)
{
case ReadOnly:
@@ -872,8 +871,7 @@ unsigned long long FileFd::Size()
bool FileFd::Close()
{
bool Res = true;
- if ((Flags & AutoClose) == AutoClose)
- if (iFd >= 0 && close(iFd) != 0)
+ if (iFd >= 0 && close(iFd) != 0)
Res &= _error->Errno("close",_("Problem closing the file"));
iFd = -1;
diff --git a/apt/apt-pkg/contrib/fileutl.h b/apt/apt-pkg/contrib/fileutl.h
index 770d3bb..04229c8 100644
--- a/apt/apt-pkg/contrib/fileutl.h
+++ b/apt/apt-pkg/contrib/fileutl.h
@@ -34,7 +34,7 @@ class FileFd
protected:
int iFd;
- enum LocalFlags {AutoClose = (1<<0),Fail = (1<<1),DelOnFail = (1<<2),
+ enum LocalFlags {Fail = (1<<1),DelOnFail = (1<<2),
HitEof = (1<<3)};
unsigned long Flags;
string FileName;
@@ -75,9 +75,11 @@ class FileFd
{
Open(FileName,Mode,Perms);
};
- FileFd(int Fd = -1) : iFd(Fd), Flags(AutoClose) {};
- FileFd(int Fd,bool) : iFd(Fd), Flags(0) {};
+ FileFd(int Fd = -1) : iFd(Fd), Flags(0) {};
virtual ~FileFd();
+
+ FileFd(const FileFd &other) = delete;
+ FileFd& operator=(const FileFd &other) = delete;
};
bool CopyFile(FileFd &From,FileFd &To);
--
2.24.0
^ permalink raw reply [flat|nested] 84+ messages in thread
* [devel] [PATCH for apt 28/38] Fix resource leaks in pkgCacheFile class
2019-12-10 15:23 [devel] [PATCH for apt 00/38] Various fixes for Apt and basic integration test suite Aleksei Nikiforov
` (26 preceding siblings ...)
2019-12-10 15:23 ` [devel] [PATCH for apt 27/38] FileFd: all files are closed automatically Aleksei Nikiforov
@ 2019-12-10 15:23 ` Aleksei Nikiforov
2019-12-10 15:23 ` [devel] [PATCH for apt 29/38] Fix off by one error in dynamic mmap leading to resource leak Aleksei Nikiforov
` (9 subsequent siblings)
37 siblings, 0 replies; 84+ messages in thread
From: Aleksei Nikiforov @ 2019-12-10 15:23 UTC (permalink / raw)
To: devel; +Cc: Aleksei Nikiforov
---
apt/apt-pkg/cachefile.cc | 12 ++++++++++++
apt/apt-pkg/pkgcachegen.cc | 12 ++++++++++++
2 files changed, 24 insertions(+)
diff --git a/apt/apt-pkg/cachefile.cc b/apt/apt-pkg/cachefile.cc
index 1a5fa64..0ac882b 100644
--- a/apt/apt-pkg/cachefile.cc
+++ b/apt/apt-pkg/cachefile.cc
@@ -81,6 +81,12 @@ bool pkgCacheFile::BuildCaches(OpProgress &Progress,bool WithLock)
return false;
// Read the caches
+ if (Map != nullptr)
+ {
+ delete Map;
+ Map = nullptr;
+ }
+
bool Res = pkgMakeStatusCache(*SrcList,Progress,&Map,!WithLock);
Progress.Done();
if (Res == false)
@@ -90,6 +96,12 @@ bool pkgCacheFile::BuildCaches(OpProgress &Progress,bool WithLock)
if (_error->empty() == false)
_error->Warning(_("You may want to run apt-get update to correct these problems"));
+ if (Cache != nullptr)
+ {
+ delete Cache;
+ Cache = nullptr;
+ }
+
Cache = new pkgCache(Map);
if (_error->PendingError() == true)
return false;
diff --git a/apt/apt-pkg/pkgcachegen.cc b/apt/apt-pkg/pkgcachegen.cc
index 654c81c..42f2d42 100644
--- a/apt/apt-pkg/pkgcachegen.cc
+++ b/apt/apt-pkg/pkgcachegen.cc
@@ -834,7 +834,14 @@ static bool CheckValidity(const string &CacheFile, FileIterator Start,
}
if (OutMap != 0)
+ {
+ if (*OutMap != nullptr)
+ {
+ delete *OutMap;
+ }
+
*OutMap = Map.UnGuard();
+ }
return true;
}
/*}}}*/
@@ -1130,6 +1137,11 @@ bool pkgMakeStatusCache(pkgSourceList &List,OpProgress &Progress,
return false;
if (OutMap != 0)
{
+ if (*OutMap != nullptr)
+ {
+ delete *OutMap;
+ }
+
if (CacheF != 0)
{
delete Map.UnGuard();
--
2.24.0
^ permalink raw reply [flat|nested] 84+ messages in thread
* [devel] [PATCH for apt 29/38] Fix off by one error in dynamic mmap leading to resource leak
2019-12-10 15:23 [devel] [PATCH for apt 00/38] Various fixes for Apt and basic integration test suite Aleksei Nikiforov
` (27 preceding siblings ...)
2019-12-10 15:23 ` [devel] [PATCH for apt 28/38] Fix resource leaks in pkgCacheFile class Aleksei Nikiforov
@ 2019-12-10 15:23 ` Aleksei Nikiforov
2019-12-10 15:23 ` [devel] [PATCH for apt 30/38] pkgCacheFile: call Close() function in destructor Aleksei Nikiforov
` (8 subsequent siblings)
37 siblings, 0 replies; 84+ messages in thread
From: Aleksei Nikiforov @ 2019-12-10 15:23 UTC (permalink / raw)
To: devel; +Cc: Aleksei Nikiforov
---
apt/apt-pkg/contrib/mmap.cc | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/apt/apt-pkg/contrib/mmap.cc b/apt/apt-pkg/contrib/mmap.cc
index a3b06cc..83bf402 100644
--- a/apt/apt-pkg/contrib/mmap.cc
+++ b/apt/apt-pkg/contrib/mmap.cc
@@ -166,7 +166,7 @@ DynamicMMap::DynamicMMap(FileFd &F,unsigned long Flags,unsigned long long WorkSp
WorkSpace = EndOfFile;
else
{
- Fd->Seek(WorkSpace);
+ Fd->Seek(WorkSpace - 1);
char C = 0;
Fd->Write(&C,sizeof(C));
}
--
2.24.0
^ permalink raw reply [flat|nested] 84+ messages in thread
* [devel] [PATCH for apt 30/38] pkgCacheFile: call Close() function in destructor
2019-12-10 15:23 [devel] [PATCH for apt 00/38] Various fixes for Apt and basic integration test suite Aleksei Nikiforov
` (28 preceding siblings ...)
2019-12-10 15:23 ` [devel] [PATCH for apt 29/38] Fix off by one error in dynamic mmap leading to resource leak Aleksei Nikiforov
@ 2019-12-10 15:23 ` Aleksei Nikiforov
2019-12-10 15:23 ` [devel] [PATCH for apt 31/38] pkgCacheFile: don't regenerate cache if it was already built Aleksei Nikiforov
` (7 subsequent siblings)
37 siblings, 0 replies; 84+ messages in thread
From: Aleksei Nikiforov @ 2019-12-10 15:23 UTC (permalink / raw)
To: devel; +Cc: Aleksei Nikiforov
---
apt/apt-pkg/cachefile.cc | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/apt/apt-pkg/cachefile.cc b/apt/apt-pkg/cachefile.cc
index 0ac882b..8b17345 100644
--- a/apt/apt-pkg/cachefile.cc
+++ b/apt/apt-pkg/cachefile.cc
@@ -50,11 +50,7 @@ pkgCacheFile::pkgCacheFile() : Map(0), Cache(0), DCache(0), SrcList(0), Policy(0
/* */
pkgCacheFile::~pkgCacheFile()
{
- delete DCache;
- delete Policy;
- delete Cache;
- delete Map;
- _system->UnLock(true);
+ Close();
}
/*}}}*/
// CacheFile::BuildCaches - Open and build the cache files /*{{{*/
--
2.24.0
^ permalink raw reply [flat|nested] 84+ messages in thread
* [devel] [PATCH for apt 31/38] pkgCacheFile: don't regenerate cache if it was already built
2019-12-10 15:23 [devel] [PATCH for apt 00/38] Various fixes for Apt and basic integration test suite Aleksei Nikiforov
` (29 preceding siblings ...)
2019-12-10 15:23 ` [devel] [PATCH for apt 30/38] pkgCacheFile: call Close() function in destructor Aleksei Nikiforov
@ 2019-12-10 15:23 ` Aleksei Nikiforov
2019-12-10 15:23 ` [devel] [PATCH for apt 32/38] Add support for rpm's dbpath configuration Aleksei Nikiforov
` (6 subsequent siblings)
37 siblings, 0 replies; 84+ messages in thread
From: Aleksei Nikiforov @ 2019-12-10 15:23 UTC (permalink / raw)
To: devel; +Cc: Aleksei Nikiforov
---
apt/apt-pkg/cachefile.cc | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/apt/apt-pkg/cachefile.cc b/apt/apt-pkg/cachefile.cc
index 8b17345..41ca057 100644
--- a/apt/apt-pkg/cachefile.cc
+++ b/apt/apt-pkg/cachefile.cc
@@ -58,6 +58,10 @@ pkgCacheFile::~pkgCacheFile()
/* */
bool pkgCacheFile::BuildCaches(OpProgress &Progress,bool WithLock)
{
+ // Reuse cache if possible
+ if (this->Cache != NULL)
+ return true;
+
if (WithLock == true)
if (_system->Lock() == false)
return false;
--
2.24.0
^ permalink raw reply [flat|nested] 84+ messages in thread
* [devel] [PATCH for apt 32/38] Add support for rpm's dbpath configuration
2019-12-10 15:23 [devel] [PATCH for apt 00/38] Various fixes for Apt and basic integration test suite Aleksei Nikiforov
` (30 preceding siblings ...)
2019-12-10 15:23 ` [devel] [PATCH for apt 31/38] pkgCacheFile: don't regenerate cache if it was already built Aleksei Nikiforov
@ 2019-12-10 15:23 ` Aleksei Nikiforov
2019-12-10 15:23 ` [devel] [PATCH for apt 33/38] Import integration tests framework from Debian Aleksei Nikiforov
` (5 subsequent siblings)
37 siblings, 0 replies; 84+ messages in thread
From: Aleksei Nikiforov @ 2019-12-10 15:23 UTC (permalink / raw)
To: devel; +Cc: Aleksei Nikiforov
---
apt/apt-pkg/rpm/rpmhandler.cc | 23 +++++++++++++++++++---
apt/apt-pkg/rpm/rpmpm.cc | 37 +++++++++++++++++++++++++++++++++++
apt/apt-pkg/rpm/rpmsystem.cc | 14 +++++++++++++
3 files changed, 71 insertions(+), 3 deletions(-)
diff --git a/apt/apt-pkg/rpm/rpmhandler.cc b/apt/apt-pkg/rpm/rpmhandler.cc
index 0bc6b4e..ed23cbe 100644
--- a/apt/apt-pkg/rpm/rpmhandler.cc
+++ b/apt/apt-pkg/rpm/rpmhandler.cc
@@ -384,6 +384,7 @@ RPMDBHandler::RPMDBHandler(bool WriteLock)
RpmIter = NULL;
#endif
string Dir = _config->Find("RPM::RootDir");
+ string DBDir = _config->Find("RPM::DBPath");
rpmReadConfigFiles(NULL, NULL);
ID = DataPath(false);
@@ -403,6 +404,17 @@ RPMDBHandler::RPMDBHandler(bool WriteLock)
Handler = rpmtsCreate();
rpmtsSetVSFlags(Handler, (rpmVSFlags_e)-1);
rpmtsSetRootDir(Handler, Dir.c_str());
+
+ if (!DBDir.empty())
+ {
+ std::string dbpath_macro = std::string("_dbpath ") + DBDir;
+ if (rpmDefineMacro(NULL, dbpath_macro.c_str(), 0) != 0)
+ {
+ _error->Error(_("Failed to set rpm dbpath"));
+ return;
+ }
+ }
+
if (rpmtsOpenDB(Handler, O_RDONLY) != 0)
{
_error->Error(_("could not open RPM database"));
@@ -412,6 +424,8 @@ RPMDBHandler::RPMDBHandler(bool WriteLock)
const char *RootDir = NULL;
if (!Dir.empty())
RootDir = Dir.c_str();
+ if (!DBDir.empty())
+ addMacro(NULL, "_dbpath", NULL, DBDir.c_str(), 0);
if (rpmdbOpen(RootDir, &Handler, O_RDONLY, 0644) != 0)
{
_error->Error(_("could not open RPM database"));
@@ -480,9 +494,12 @@ RPMDBHandler::~RPMDBHandler()
string RPMDBHandler::DataPath(bool DirectoryOnly)
{
string File = "Packages";
- char *tmp = (char *) rpmExpand("%{_dbpath}", NULL);
- string DBPath(_config->Find("RPM::RootDir")+tmp);
- free(tmp);
+ string DBPath = _config->Find("RPM::DBPath");
+ if (DBPath.empty()) {
+ char *tmp = (char *) rpmExpand("%{_dbpath}", NULL);
+ DBPath = _config->Find("RPM::RootDir") + tmp;
+ free(tmp);
+ }
if (DirectoryOnly == true)
return DBPath;
diff --git a/apt/apt-pkg/rpm/rpmpm.cc b/apt/apt-pkg/rpm/rpmpm.cc
index a6a3837..d2d3120 100644
--- a/apt/apt-pkg/rpm/rpmpm.cc
+++ b/apt/apt-pkg/rpm/rpmpm.cc
@@ -478,6 +478,14 @@ bool pkgRPMExtPM::ExecRPM(Item::RPMOps op, const std::vector<apt_item> &files)
Args[n++] = rootdir.c_str();
}
+ string DBDir = _config->Find("RPM::DBPath");
+ string DBDirArg;
+ if (!DBDir.empty())
+ {
+ DBDirArg = std::string("--dbpath=") + DBDir;
+ Args[n++] = DBDirArg.c_str();
+ }
+
Configuration::Item const *Opts;
if (op == Item::RPMErase)
{
@@ -835,6 +843,7 @@ bool pkgRPMLibPM::Process(const std::vector<apt_item> &install,
bool Success = false;
bool Interactive = _config->FindB("RPM::Interactive",true);
string Dir = _config->Find("RPM::RootDir");
+ string DBDir = _config->Find("RPM::DBPath");
int quiet = _config->FindI("quiet",0);
rpmReadConfigFiles(NULL, NULL);
@@ -855,6 +864,17 @@ bool pkgRPMLibPM::Process(const std::vector<apt_item> &install,
// 4.1 needs this always set even if NULL,
// otherwise all scriptlets fail
rpmtsSetRootDir(TS, Dir.c_str());
+
+ if (!DBDir.empty())
+ {
+ std::string dbpath_macro = std::string("_dbpath ") + DBDir;
+ if (rpmDefineMacro(NULL, dbpath_macro.c_str(), 0) != 0)
+ {
+ _error->Error(_("Failed to set rpm dbpath"));
+ goto exit;
+ }
+ }
+
if (rpmtsOpenDB(TS, O_RDWR) != 0)
{
_error->Error(_("Could not open RPM database"));
@@ -865,6 +885,8 @@ bool pkgRPMLibPM::Process(const std::vector<apt_item> &install,
const char *RootDir = NULL;
if (!Dir.empty())
RootDir = Dir.c_str();
+ if (!DBDir.empty())
+ addMacro(NULL, "_dbpath", NULL, DBDir.c_str(), 0);
if (rpmdbOpen(RootDir, &DB, O_RDWR|O_CREAT, 0644) != 0)
{
_error->Error(_("Could not open RPM database"));
@@ -1129,6 +1151,7 @@ bool pkgRPMLibPM::UpdateMarks()
}
std::string Dir = _config->Find("RPM::RootDir");
+ string DBDir = _config->Find("RPM::DBPath");
if (rpmReadConfigFiles(NULL, NULL) != 0)
{
@@ -1144,6 +1167,17 @@ bool pkgRPMLibPM::UpdateMarks()
// 4.1 needs this always set even if NULL,
// otherwise all scriptlets fail
rpmtsSetRootDir(TS, Dir.c_str());
+
+ if (!DBDir.empty())
+ {
+ std::string dbpath_macro = std::string("_dbpath ") + DBDir;
+ if (rpmDefineMacro(NULL, dbpath_macro.c_str(), 0) != 0)
+ {
+ _error->Error(_("Failed to set rpm dbpath"));
+ return false;
+ }
+ }
+
if (rpmtsOpenDB(TS, O_RDWR) != 0)
{
_error->Error(_("Could not open RPM database"));
@@ -1156,6 +1190,9 @@ bool pkgRPMLibPM::UpdateMarks()
RootDir = Dir.c_str();
}
+ if (!DBDir.empty())
+ addMacro(NULL, "_dbpath", NULL, DBDir.c_str(), 0);
+
if (rpmdbOpen(RootDir, &DB, O_RDWR|O_CREAT, 0644) != 0)
{
_error->Error(_("Could not open RPM database"));
diff --git a/apt/apt-pkg/rpm/rpmsystem.cc b/apt/apt-pkg/rpm/rpmsystem.cc
index e48267c..aba3297 100644
--- a/apt/apt-pkg/rpm/rpmsystem.cc
+++ b/apt/apt-pkg/rpm/rpmsystem.cc
@@ -275,6 +275,8 @@ string rpmSystem::DistroVer(Configuration const &Cnf)
string DistroVerPkg = _config->Find("Apt::DistroVerPkg");
string DistroVersion;
+ string DBDir = _config->Find("RPM::DBPath");
+
if (DistroVerPkg.empty())
return DistroVersion;
@@ -283,12 +285,24 @@ string rpmSystem::DistroVer(Configuration const &Cnf)
ts = rpmtsCreate();
rpmtsSetVSFlags(ts, (rpmVSFlags_e)-1);
rpmtsSetRootDir(ts, NULL);
+
+ if (!DBDir.empty())
+ {
+ std::string dbpath_macro = std::string("_dbpath ") + DBDir;
+ if (rpmDefineMacro(NULL, dbpath_macro.c_str(), 0) != 0)
+ {
+ return DistroVersion;
+ }
+ }
+
if (rpmtsOpenDB(ts, O_RDONLY))
return DistroVersion;
#else
rpmdb DB;
string RootDir = _config->Find("RPM::RootDir");
const char *RootDirStr = RootDir.empty() ? NULL : RootDir.c_str();
+ if (!DBDir.empty())
+ addMacro(NULL, "_dbpath", NULL, DBDir.c_str(), 0);
if (rpmdbOpen(RootDirStr, &DB, O_RDONLY, 0644))
return DistroVersion;
#endif
--
2.24.0
^ permalink raw reply [flat|nested] 84+ messages in thread
* [devel] [PATCH for apt 33/38] Import integration tests framework from Debian
2019-12-10 15:23 [devel] [PATCH for apt 00/38] Various fixes for Apt and basic integration test suite Aleksei Nikiforov
` (31 preceding siblings ...)
2019-12-10 15:23 ` [devel] [PATCH for apt 32/38] Add support for rpm's dbpath configuration Aleksei Nikiforov
@ 2019-12-10 15:23 ` Aleksei Nikiforov
2019-12-10 15:23 ` [devel] [PATCH for apt 34/38] Add initial integration tests Aleksei Nikiforov
` (4 subsequent siblings)
37 siblings, 0 replies; 84+ messages in thread
From: Aleksei Nikiforov @ 2019-12-10 15:23 UTC (permalink / raw)
To: devel; +Cc: Aleksei Nikiforov
---
apt/test/integration/framework | 1275 ++++++++++++++++++++++++++++++++
apt/test/integration/run-tests | 66 ++
2 files changed, 1341 insertions(+)
create mode 100644 apt/test/integration/framework
create mode 100755 apt/test/integration/run-tests
diff --git a/apt/test/integration/framework b/apt/test/integration/framework
new file mode 100644
index 0000000..bccbb71
--- /dev/null
+++ b/apt/test/integration/framework
@@ -0,0 +1,1275 @@
+#!/bin/sh -- # no runable script, just for vi
+
+EXIT_CODE=0
+
+# we all like colorful messages
+if [ "$MSGCOLOR" != 'NO' ]; then
+ if [ ! -t 1 ]; then # but check that we output to a terminal
+ export MSGCOLOR='NO'
+ fi
+fi
+
+
+if [ "$MSGCOLOR" != 'NO' ]; then
+ CERROR="\033[1;31m" # red
+ CWARNING="\033[1;33m" # yellow
+ CMSG="\033[1;32m" # green
+ CINFO="\033[1;96m" # light blue
+ CDEBUG="\033[1;94m" # blue
+ CNORMAL="\033[0;39m" # default system console color
+ CDONE="\033[1;32m" # green
+ CPASS="\033[1;32m" # green
+ CFAIL="\033[1;31m" # red
+ CCMD="\033[1;35m" # pink
+fi
+
+msgdie() { printf "${CERROR}E: $1${CNORMAL}\n" >&2; exit 1; }
+msgwarn() { printf "${CWARNING}W: $1${CNORMAL}\n" >&2; }
+msgmsg() { printf "${CMSG}$1${CNORMAL}\n"; }
+msginfo() { printf "${CINFO}I: $1${CNORMAL}\n"; }
+msgdebug() { printf "${CDEBUG}D: $1${CNORMAL}\n"; }
+msgdone() { printf "${CDONE}DONE${CNORMAL}\n"; }
+msgnwarn() { printf "${CWARNING}W: $1${CNORMAL}" >&2; }
+msgnmsg() { printf "${CMSG}$1${CNORMAL}"; }
+msgninfo() { printf "${CINFO}I: $1${CNORMAL}"; }
+msgndebug() { printf "${CDEBUG}D: $1${CNORMAL}"; }
+msgtest() {
+ while [ -n "$1" ]; do
+ printf "${CINFO}$1${CCMD} "
+ printf -- "$(echo "$2" | sed -e 's#^apt\([cgfs]\)#apt-\1#')${CINFO} "
+ shift
+ if [ -n "$1" ]; then shift; else break; fi
+ done
+ printf "…${CNORMAL} "
+}
+msgpass() { printf "${CPASS}PASS${CNORMAL}\n"; }
+msgskip() { printf "${CWARNING}SKIP${CNORMAL}\n" >&2; }
+msgfail() {
+ if [ $# -gt 0 ]; then printf "${CFAIL}FAIL: $*${CNORMAL}\n" >&2;
+ else printf "${CFAIL}FAIL${CNORMAL}\n" >&2; fi
+ EXIT_CODE=$((EXIT_CODE+1));
+}
+
+# enable / disable Debugging
+MSGLEVEL=${MSGLEVEL:-3}
+if [ $MSGLEVEL -le 0 ]; then
+ msgdie() { true; }
+fi
+if [ $MSGLEVEL -le 1 ]; then
+ msgwarn() { true; }
+ msgnwarn() { true; }
+fi
+if [ $MSGLEVEL -le 2 ]; then
+ msgmsg() { true; }
+ msgnmsg() { true; }
+ msgtest() { true; }
+ msgpass() { printf " ${CPASS}P${CNORMAL}"; }
+ msgskip() { printf " ${CWARNING}S${CNORMAL}" >&2; }
+ if [ -n "$CFAIL" ]; then
+ msgfail() { printf " ${CFAIL}FAIL${CNORMAL}" >&2; EXIT_CODE=$((EXIT_CODE+1)); }
+ else
+ msgfail() { printf " ###FAILED###" >&2; EXIT_CODE=$((EXIT_CODE+1)); }
+ fi
+fi
+if [ $MSGLEVEL -le 3 ]; then
+ msginfo() { true; }
+ msgninfo() { true; }
+fi
+if [ $MSGLEVEL -le 4 ]; then
+ msgdebug() { true; }
+ msgndebug() { true; }
+fi
+msgdone() {
+ if [ "$1" = "debug" -a $MSGLEVEL -le 4 ] ||
+ [ "$1" = "info" -a $MSGLEVEL -le 3 ] ||
+ [ "$1" = "msg" -a $MSGLEVEL -le 2 ] ||
+ [ "$1" = "warn" -a $MSGLEVEL -le 1 ] ||
+ [ "$1" = "die" -a $MSGLEVEL -le 0 ]; then
+ true;
+ else
+ printf "${CDONE}DONE${CNORMAL}\n";
+ fi
+}
+getaptconfig() {
+ if [ -f ./aptconfig.conf ]; then
+ echo "./aptconfig.conf"
+ elif [ -f ../aptconfig.conf ]; then
+ echo "../aptconfig.conf"
+ fi
+}
+runapt() {
+ msgdebug "Executing: ${CCMD}$*${CDEBUG} "
+ local CMD="$1"
+ shift
+ case $CMD in
+ sh|aptitude|*/*|command) ;;
+ *) CMD="${BUILDDIRECTORY}/$CMD";;
+ esac
+ MALLOC_PERTURB_=21 MALLOC_CHECK_=2 APT_CONFIG="$(getaptconfig)" LD_LIBRARY_PATH=${BUILDDIRECTORY} $CMD "$@"
+}
+aptconfig() { runapt apt-config "$@"; }
+aptcache() { runapt apt-cache "$@"; }
+aptcdrom() { runapt apt-cdrom "$@"; }
+aptget() { runapt apt-get "$@"; }
+aptftparchive() { runapt apt-ftparchive "$@"; }
+aptkey() { runapt apt-key "$@"; }
+aptmark() { runapt apt-mark "$@"; }
+aptsortpkgs() { runapt apt-sortpkgs "$@"; }
+apt() { runapt apt "$@"; }
+apthelper() { runapt "${APTHELPERBINDIR}/apt-helper" "$@"; }
+aptwebserver() { runapt "${APTWEBSERVERBINDIR}/aptwebserver" "$@"; }
+aptitude() { runapt aptitude "$@"; }
+aptextracttemplates() { runapt apt-extracttemplates "$@"; }
+aptinternalsolver() { runapt "${APTINTERNALSOLVER}" "$@"; }
+
+dpkg() {
+ command dpkg --root=${TMPWORKINGDIRECTORY}/rootdir --force-not-root --force-bad-path --log=${TMPWORKINGDIRECTORY}/rootdir/var/log/dpkg.log "$@"
+}
+dpkgcheckbuilddeps() {
+ command dpkg-checkbuilddeps --admindir=${TMPWORKINGDIRECTORY}/rootdir/var/lib/dpkg "$@"
+}
+gdb() {
+ echo "gdb: run »$*«"
+ CMD="$1"
+ shift
+
+ APT_CONFIG=aptconfig.conf LD_LIBRARY_PATH=${LIBRARYPATH} command gdb ${BUILDDIRECTORY}/$CMD --args ${BUILDDIRECTORY}/$CMD "$@"
+}
+gpg() {
+ # see apt-key for the whole trickery. Setup is done in setupenvironment
+ command gpg --ignore-time-conflict --no-options --no-default-keyring \
+ --homedir "${TMPWORKINGDIRECTORY}/gnupghome" \
+ --no-auto-check-trustdb --trust-model always \
+ "$@"
+}
+
+exitwithstatus() {
+ # error if we about to overflow, but ...
+ # "255 failures ought to be enough for everybody"
+ if [ $EXIT_CODE -gt 255 ]; then
+ msgdie "Total failure count $EXIT_CODE too big"
+ fi
+ exit $((EXIT_CODE <= 255 ? EXIT_CODE : 255));
+}
+
+shellsetedetector() {
+ local exit_status=$?
+ if [ "$exit_status" != '0' ]; then
+ printf >&2 "${CERROR}E: Looks like the testcases ended prematurely with exitcode: ${exit_status}${CNORMAL}\n"
+ if [ "$EXIT_CODE" = '0' ]; then
+ EXIT_CODE="$exit_status"
+ fi
+ fi
+}
+
+addtrap() {
+ if [ "$1" = 'prefix' ]; then
+ CURRENTTRAP="$2 $CURRENTTRAP"
+ else
+ CURRENTTRAP="$CURRENTTRAP $1"
+ fi
+ trap "shellsetedetector; $CURRENTTRAP exitwithstatus;" 0 HUP INT QUIT ILL ABRT FPE SEGV PIPE TERM
+}
+
+setupenvironment() {
+ TMPWORKINGDIRECTORY=$(mktemp -d)
+ TESTDIRECTORY=$(readlink -f $(dirname $0))
+ msgninfo "Preparing environment for ${CCMD}$(basename $0)${CINFO} in ${TMPWORKINGDIRECTORY}… "
+
+ # allow overriding the default BUILDDIR location
+ BUILDDIRECTORY=${APT_INTEGRATION_TESTS_BUILD_DIR:-"${TESTDIRECTORY}/../../build/bin"}
+ LIBRARYPATH=${APT_INTEGRATION_TESTS_LIBRARY_PATH:-"${BUILDDIRECTORY}"}
+ METHODSDIR=${APT_INTEGRATION_TESTS_METHODS_DIR:-"${BUILDDIRECTORY}/methods"}
+ APTHELPERBINDIR=${APT_INTEGRATION_TESTS_LIBEXEC_DIR:-"${BUILDDIRECTORY}"}
+ APTWEBSERVERBINDIR=${APT_INTEGRATION_TESTS_WEBSERVER_BIN_DIR:-"${BUILDDIRECTORY}"}
+ APTINTERNALSOLVER=${APT_INTEGRATION_TESTS_INTERNAL_SOLVER:-"${BUILDDIRECTORY}/apt-internal-solver"}
+ test -x "${BUILDDIRECTORY}/apt-get" || msgdie "You need to build tree first"
+ # -----
+
+ addtrap "cd /; rm -rf $TMPWORKINGDIRECTORY;"
+ cd $TMPWORKINGDIRECTORY
+ mkdir rootdir aptarchive keys
+ cd rootdir
+ mkdir -p etc/apt/apt.conf.d etc/apt/sources.list.d etc/apt/trusted.gpg.d etc/apt/preferences.d
+ mkdir -p var/cache var/lib/apt var/log tmp
+ mkdir -p var/lib/dpkg/info var/lib/dpkg/updates var/lib/dpkg/triggers
+ touch var/lib/dpkg/available
+ mkdir -p usr/lib/apt
+ ln -s ${METHODSDIR} usr/lib/apt/methods
+ if [ "$BUILDDIRECTORY" = "$LIBRARYPATH" ]; then
+ mkdir -p usr/lib/apt/solvers
+ ln -s "${BUILDDIRECTORY}/apt-dump-solver" usr/lib/apt/solvers/dump
+ ln -s "${BUILDDIRECTORY}/apt-internal-solver" usr/lib/apt/solvers/apt
+ echo "Dir::Bin::Solvers \"${TMPWORKINGDIRECTORY}/rootdir/usr/lib/apt/solvers\";" > etc/apt/apt.conf.d/externalsolver.conf
+ fi
+ # use the autoremove from the BUILDDIRECTORY if its there, otherwise
+ # system
+ if [ -e ${BUILDDIRECTORY}/../../debian/apt.conf.autoremove ]; then
+ ln -s ${BUILDDIRECTORY}/../../debian/apt.conf.autoremove etc/apt/apt.conf.d/01autoremove
+ else
+ ln -s /etc/apt/apt.conf.d/01autoremove etc/apt/apt.conf.d/01autoremove
+ fi
+ cd ..
+ local PACKAGESFILE=$(echo "$(basename $0)" | sed -e 's/^test-/Packages-/' -e 's/^skip-/Packages-/')
+ if [ -f "${TESTDIRECTORY}/${PACKAGESFILE}" ]; then
+ cp "${TESTDIRECTORY}/${PACKAGESFILE}" aptarchive/Packages
+ fi
+ local SOURCESSFILE=$(echo "$(basename $0)" | sed -e 's/^test-/Sources-/' -e 's/^skip-/Sources-/')
+ if [ -f "${TESTDIRECTORY}/${SOURCESSFILE}" ]; then
+ cp "${TESTDIRECTORY}/${SOURCESSFILE}" aptarchive/Sources
+ fi
+ cp $(find $TESTDIRECTORY -name '*.pub' -o -name '*.sec') keys/
+ ln -s ${TMPWORKINGDIRECTORY}/keys/joesixpack.pub rootdir/etc/apt/trusted.gpg.d/joesixpack.gpg
+ echo "Dir \"${TMPWORKINGDIRECTORY}/rootdir\";" > aptconfig.conf
+ echo "Dir::state::status \"${TMPWORKINGDIRECTORY}/rootdir/var/lib/dpkg/status\";" >> aptconfig.conf
+ echo "Debug::NoLocking \"true\";" >> aptconfig.conf
+ echo "APT::Get::Show-User-Simulation-Note \"false\";" >> aptconfig.conf
+ echo "Dir::Bin::Methods \"${METHODSDIR}\";" >> aptconfig.conf
+ echo "Dir::Bin::dpkg \"fakeroot\";" >> aptconfig.conf
+ echo "DPKG::options:: \"dpkg\";" >> aptconfig.conf
+ echo "DPKG::options:: \"--root=${TMPWORKINGDIRECTORY}/rootdir\";" >> aptconfig.conf
+ echo "DPKG::options:: \"--force-not-root\";" >> aptconfig.conf
+ echo "DPKG::options:: \"--force-bad-path\";" >> aptconfig.conf
+ if ! command dpkg --assert-multi-arch >/dev/null 2>&1; then
+ echo "DPKG::options:: \"--force-architecture\";" >> aptconfig.conf # Added to test multiarch before dpkg is ready for it…
+ fi
+ echo "DPKG::options:: \"--log=${TMPWORKINGDIRECTORY}/rootdir/var/log/dpkg.log\";" >> aptconfig.conf
+ echo 'quiet::NoUpdate "true";' >> aptconfig.conf
+ echo "Acquire::https::CaInfo \"${TESTDIR}/apt.pem\";" > rootdir/etc/apt/apt.conf.d/99https
+ echo "Apt::Cmd::Disable-Script-Warning \"1\";" > rootdir/etc/apt/apt.conf.d/apt-binary
+ configcompression '.' 'gz' #'bz2' 'lzma' 'xz'
+
+ # gpg needs a trustdb to function, but it can't be invalid (not even empty)
+ # see also apt-key where this trickery comes from:
+ local TRUSTDBDIR="${TMPWORKINGDIRECTORY}/gnupghome"
+ mkdir "$TRUSTDBDIR"
+ chmod 700 "$TRUSTDBDIR"
+ # We also don't use a secret keyring, of course, but gpg panics and
+ # implodes if there isn't one available - and writeable for imports
+ local SECRETKEYRING="${TRUSTDBDIR}/secring.gpg"
+ touch $SECRETKEYRING
+ # now create the trustdb with an (empty) dummy keyring
+ # newer gpg versions are fine without it, but play it safe for now
+ gpg --quiet --check-trustdb --secret-keyring $SECRETKEYRING --keyring $SECRETKEYRING >/dev/null 2>&1
+
+ # cleanup the environment a bit
+ export PATH="${PATH}:/usr/local/sbin:/usr/sbin:/sbin"
+ export LC_ALL=C.UTF-8
+ unset LANGUAGE APT_CONFIG
+ unset GREP_OPTIONS DEB_BUILD_PROFILES
+
+ msgdone "info"
+}
+
+getarchitecture() {
+ if [ "$1" = "native" -o -z "$1" ]; then
+ eval `aptconfig shell ARCH APT::Architecture`
+ if [ -n "$ARCH" ]; then
+ echo $ARCH
+ else
+ dpkg --print-architecture
+ fi
+ else
+ echo $1
+ fi
+}
+
+getarchitectures() {
+ echo "$(aptconfig dump | grep APT::Architecture | cut -d'"' -f 2 | sed '/^$/ d' | sort | uniq | tr '\n' ' ')"
+}
+
+getarchitecturesfromcommalist() {
+ echo "$1" | sed -e 's#,#\n#g' | sed -e "s/^native\$/$(getarchitecture 'native')/"
+}
+
+configarchitecture() {
+ {
+ echo "APT::Architecture \"$(getarchitecture $1)\";"
+ while [ -n "$1" ]; do
+ echo "APT::Architectures:: \"$(getarchitecture $1)\";"
+ shift
+ done
+ } >rootdir/etc/apt/apt.conf.d/01multiarch.conf
+ configdpkg
+}
+
+configdpkg() {
+ if [ ! -e rootdir/var/lib/dpkg/status ]; then
+ local STATUSFILE=$(echo "$(basename $0)" | sed -e 's/^test-/status-/' -e 's/^skip-/status-/')
+ if [ -f "${TESTDIRECTORY}/${STATUSFILE}" ]; then
+ cp "${TESTDIRECTORY}/${STATUSFILE}" rootdir/var/lib/dpkg/status
+ else
+ echo -n > rootdir/var/lib/dpkg/status
+ fi
+ fi
+ rm -f rootdir/etc/apt/apt.conf.d/00foreigndpkg
+ if command dpkg --assert-multi-arch >/dev/null 2>&1 ; then
+ local ARCHS="$(getarchitectures)"
+ if echo "$ARCHS" | grep -E -q '[^ ]+ [^ ]+'; then
+ DPKGARCH="$(dpkg --print-architecture)"
+ for ARCH in ${ARCHS}; do
+ if [ "${ARCH}" != "${DPKGARCH}" ]; then
+ if ! dpkg --add-architecture ${ARCH} >/dev/null 2>&1; then
+ # old-style used e.g. in Ubuntu-P – and as it seems travis
+ echo "DPKG::options:: \"--foreign-architecture\";" >> rootdir/etc/apt/apt.conf.d/00foreigndpkg
+ echo "DPKG::options:: \"${ARCH}\";" >> rootdir/etc/apt/apt.conf.d/00foreigndpkg
+ fi
+ fi
+ done
+ if [ "0" = "$(dpkg -l dpkg 2> /dev/null | grep '^i' | wc -l)" ]; then
+ # dpkg doesn't really check the version as long as it is fully installed,
+ # but just to be sure we choose one above the required version
+ insertinstalledpackage 'dpkg' "all" '1.16.2+fake'
+ fi
+ fi
+ fi
+}
+
+configdpkgnoopchroot() {
+ # create a library to noop chroot() and rewrite maintainer script executions
+ # via execvp() as used by dpkg as we don't want our rootdir to be a fullblown
+ # chroot directory dpkg could chroot into to execute the maintainer scripts
+ msgtest 'Building library to preload to make maintainerscript work in' 'dpkg'
+ cat << EOF > noopchroot.c
+#define _GNU_SOURCE
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <dlfcn.h>
+
+static char * chrootdir = NULL;
+
+int chroot(const char *path) {
+ printf("WARNING: CHROOTing to %s was ignored!\n", path);
+ free(chrootdir);
+ chrootdir = strdup(path);
+ return 0;
+}
+int execvp(const char *file, char *const argv[]) {
+ static int (*func_execvp) (const char *, char * const []) = NULL;
+ if (func_execvp == NULL)
+ func_execvp = (int (*) (const char *, char * const [])) dlsym(RTLD_NEXT, "execvp");
+ if (chrootdir == NULL || strncmp(file, "/var/lib/dpkg/", strlen("/var/lib/dpkg/")) != 0)
+ return func_execvp(file, argv);
+ printf("REWRITE execvp call %s into %s\n", file, chrootdir);
+ char newfile[strlen(chrootdir) + strlen(file)];
+ strcpy(newfile, chrootdir);
+ strcat(newfile, file);
+ return func_execvp(newfile, argv);
+}
+EOF
+ testsuccess --nomsg gcc -fPIC -shared -o noopchroot.so noopchroot.c -ldl
+
+ mkdir -p "${TMPWORKINGDIRECTORY}/rootdir/usr/bin/"
+ DPKG="${TMPWORKINGDIRECTORY}/rootdir/usr/bin/dpkg"
+ echo "#!/bin/sh
+if [ -n \"\$LD_PRELOAD\" ]; then
+ export LD_PRELOAD=\"${TMPWORKINGDIRECTORY}/noopchroot.so \${LD_PRELOAD}\"
+else
+ export LD_PRELOAD=\"${TMPWORKINGDIRECTORY}/noopchroot.so\"
+fi
+dpkg \"\$@\"" > $DPKG
+ chmod +x $DPKG
+ sed -ie "s|^DPKG::options:: \"dpkg\";\$|DPKG::options:: \"$DPKG\";|" aptconfig.conf
+}
+
+configallowinsecurerepositories() {
+ echo "Acquire::AllowInsecureRepositories \"$1\";" > rootdir/etc/apt/apt.conf.d/allow-insecure-repositories.conf
+
+}
+
+configcompression() {
+ while [ -n "$1" ]; do
+ case "$1" in
+ '.') printf ".\t.\tcat\n";;
+ 'gz') printf "gzip\tgz\tgzip\n";;
+ 'bz2') printf "bzip2\tbz2\tbzip2\n";;
+ 'lzma') printf "lzma\tlzma\txz --format=lzma\n";;
+ 'xz') printf "xz\txz\txz\n";;
+ *) printf "$1\t$1\t$1\n";;
+ esac
+ shift
+ done > ${TMPWORKINGDIRECTORY}/rootdir/etc/testcase-compressor.conf
+}
+
+forcecompressor() {
+ COMPRESSOR="$1"
+ COMPRESSOR_CMD="$1"
+ case $COMPRESSOR in
+ gzip) COMPRESS='gz';;
+ bzip2) COMPRESS='bz2';;
+ lzma) COMPRESS='lzma';;
+ xz) COMPRESS='xz';;
+ *) msgdie "Compressor $COMPRESSOR is unknown to framework, so can't be forced by forcecompressor!";;
+ esac
+ local CONFFILE="${TMPWORKINGDIRECTORY}/rootdir/etc/apt/apt.conf.d/00force-compressor"
+ echo "Acquire::CompressionTypes::Order { \"${COMPRESS}\"; };
+Dir::Bin::uncompressed \"/does/not/exist\";
+Dir::Bin::gzip \"/does/not/exist\";
+Dir::Bin::bzip2 \"/does/not/exist\";
+Dir::Bin::lzma \"/does/not/exist\";
+Dir::Bin::xz \"/does/not/exist\";" > "$CONFFILE"
+ if [ -e "/bin/${COMPRESSOR}" ]; then
+ echo "Dir::Bin::${COMPRESSOR} \"/bin/${COMPRESSOR}\";" >> "$CONFFILE"
+ elif [ -e "/usr/bin/${COMPRESSOR}" ]; then
+ echo "Dir::Bin::${COMPRESSOR} \"/usr/bin/${COMPRESSOR}\";" >> "$CONFFILE"
+ elif [ "${COMPRESSOR}" = 'lzma' ]; then
+ echo 'Dir::Bin::xz "/usr/bin/xz";' >> "$CONFFILE"
+ COMPRESSOR_CMD='xz --format=lzma'
+ else
+ msgtest 'Test for availability of compressor' "${COMPRESSOR}"
+ msgfail
+ fi
+}
+
+setupsimplenativepackage() {
+ local NAME="$1"
+ local ARCH="$2"
+ local VERSION="$3"
+ local RELEASE="${4:-unstable}"
+ local DEPENDENCIES="$5"
+ local DESCRIPTION="${6:-"an autogenerated dummy ${NAME}=${VERSION}/${RELEASE}
+ If you find such a package installed on your system,
+ something went horribly wrong! They are autogenerated
+ und used only by testcases and surf no other propose…"}"
+
+ local SECTION="${7:-others}"
+ local DISTSECTION
+ if [ "$SECTION" = "$(echo "$SECTION" | cut -d'/' -f 2)" ]; then
+ DISTSECTION="main"
+ else
+ DISTSECTION="$(echo "$SECTION" | cut -d'/' -f 1)"
+ fi
+ local BUILDDIR=incoming/${NAME}-${VERSION}
+ mkdir -p ${BUILDDIR}/debian/source
+ cd ${BUILDDIR}
+ echo "* most suckless software product ever" > FEATURES
+ test -e debian/copyright || echo "Copyleft by Joe Sixpack $(date +%Y)" > debian/copyright
+ test -e debian/changelog || echo "$NAME ($VERSION) $RELEASE; urgency=low
+
+ * Initial release
+
+ -- Joe Sixpack <joe@example.org> $(date -R)" > debian/changelog
+ test -e debian/control || echo "Source: $NAME
+Section: $SECTION
+Priority: optional
+Maintainer: Joe Sixpack <joe@example.org>
+Build-Depends: debhelper (>= 7)
+Standards-Version: 3.9.1
+
+Package: $NAME" > debian/control
+ if [ "$ARCH" = 'all' ]; then
+ echo "Architecture: all" >> debian/control
+ else
+ echo "Architecture: any" >> debian/control
+ fi
+ test -z "$DEPENDENCIES" || echo "$DEPENDENCIES" >> debian/control
+ echo "Description: $DESCRIPTION" >> debian/control
+
+ test -e debian/compat || echo "7" > debian/compat
+ test -e debian/source/format || echo "3.0 (native)" > debian/source/format
+ test -e debian/rules || cp /usr/share/doc/debhelper/examples/rules.tiny debian/rules
+ cd - > /dev/null
+}
+
+buildsimplenativepackage() {
+ local NAME="$1"
+ local ARCH="$2"
+ local VERSION="$3"
+ local RELEASE="${4:-unstable}"
+ local DEPENDENCIES="$5"
+ local DESCRIPTION="${6:-"an autogenerated dummy ${NAME}=${VERSION}/${RELEASE}
+ If you find such a package installed on your system,
+ something went horribly wrong! They are autogenerated
+ und used only by testcases and surf no other propose…"}"
+
+ local SECTION="${7:-others}"
+ local PRIORITY="${8:-optional}"
+ local FILE_TREE="$9"
+ local COMPRESS_TYPE="${10:-gzip}"
+ local DISTSECTION
+ if [ "$SECTION" = "$(echo "$SECTION" | cut -d'/' -f 2)" ]; then
+ DISTSECTION="main"
+ else
+ DISTSECTION="$(echo "$SECTION" | cut -d'/' -f 1)"
+ fi
+ local BUILDDIR=${TMPWORKINGDIRECTORY}/incoming/${NAME}-${VERSION}
+
+ msgtest "Build source package in version ${VERSION} for ${RELEASE} in ${DISTSECTION}" "$NAME"
+ mkdir -p $BUILDDIR/debian/source
+ echo "* most suckless software product ever" > ${BUILDDIR}/FEATURES
+ echo "#!/bin/sh
+echo '$NAME says \"Hello!\"'" > ${BUILDDIR}/${NAME}
+
+ echo "Copyleft by Joe Sixpack $(date +%Y)" > ${BUILDDIR}/debian/copyright
+ echo "$NAME ($VERSION) $RELEASE; urgency=low
+
+ * Initial release
+
+ -- Joe Sixpack <joe@example.org> $(date -R)" > ${BUILDDIR}/debian/changelog
+ echo "Source: $NAME
+Priority: $PRIORITY
+Maintainer: Joe Sixpack <joe@example.org>
+Standards-Version: 3.9.3" > ${BUILDDIR}/debian/control
+ if [ "$SECTION" != '<none>' ]; then
+ echo "Section: $SECTION" >> ${BUILDDIR}/debian/control
+ fi
+ local BUILDDEPS="$(echo "$DEPENDENCIES" | grep '^Build-')"
+ test -z "$BUILDDEPS" || echo "$BUILDDEPS" >> ${BUILDDIR}/debian/control
+ echo "
+Package: $NAME" >> ${BUILDDIR}/debian/control
+
+ if [ "$ARCH" = 'all' ]; then
+ echo "Architecture: all" >> ${BUILDDIR}/debian/control
+ else
+ echo "Architecture: any" >> ${BUILDDIR}/debian/control
+ fi
+ local DEPS="$(echo "$DEPENDENCIES" | grep -v '^Build-')"
+ test -z "$DEPS" || echo "$DEPS" >> ${BUILDDIR}/debian/control
+ echo "Description: $DESCRIPTION" >> ${BUILDDIR}/debian/control
+
+ echo '3.0 (native)' > ${BUILDDIR}/debian/source/format
+ cd ${BUILDDIR}/..
+ testsuccess --nomsg dpkg-source -b ${NAME}-${VERSION}
+ cd - >/dev/null
+ sed -n 's#^dpkg-source: info: building [^ ]\+ in ##p' ${TMPWORKINGDIRECTORY}/rootdir/tmp/testsuccess.output \
+ | while read SRC; do
+ echo "pool/${SRC}" >> ${BUILDDIR}/../${RELEASE}.${DISTSECTION}.srclist
+# if expr match "${SRC}" '.*\.dsc' >/dev/null 2>&1; then
+# gpg --yes --secret-keyring ./keys/joesixpack.sec \
+# --keyring ./keys/joesixpack.pub --default-key 'Joe Sixpack' \
+# --clearsign -o "${BUILDDIR}/../${SRC}.sign" "${BUILDDIR}/../$SRC"
+# mv "${BUILDDIR}/../${SRC}.sign" "${BUILDDIR}/../$SRC"
+# fi
+ done
+
+ for arch in $(getarchitecturesfromcommalist "$ARCH"); do
+ msgtest "Build binary package for ${RELEASE} in ${SECTION}" "$NAME"
+ rm -rf ${BUILDDIR}/debian/tmp
+ mkdir -p ${BUILDDIR}/debian/tmp/DEBIAN ${BUILDDIR}/debian/tmp/usr/share/doc/${NAME} ${BUILDDIR}/debian/tmp/usr/bin
+ cp ${BUILDDIR}/debian/copyright ${BUILDDIR}/debian/changelog ${BUILDDIR}/FEATURES ${BUILDDIR}/debian/tmp/usr/share/doc/${NAME}
+ cp ${BUILDDIR}/${NAME} ${BUILDDIR}/debian/tmp/usr/bin/${NAME}-${arch}
+ if [ -n "$FILE_TREE" ]; then
+ cp -ar "$FILE_TREE" ${BUILDDIR}/debian/tmp
+ fi
+
+ (cd ${BUILDDIR}; dpkg-gencontrol -DArchitecture=$arch)
+ (cd ${BUILDDIR}/debian/tmp; md5sum $(find usr/ -type f) > DEBIAN/md5sums)
+ local LOG="${BUILDDIR}/../${NAME}_${VERSION}_${arch}.dpkg-deb.log"
+ # ensure the right permissions as dpkg-deb ensists
+ chmod 755 ${BUILDDIR}/debian/tmp/DEBIAN
+ testsuccess --nomsg dpkg-deb -Z${COMPRESS_TYPE} --build ${BUILDDIR}/debian/tmp ${BUILDDIR}/..
+ echo "pool/${NAME}_${VERSION}_${arch}.deb" >> ${BUILDDIR}/../${RELEASE}.${DISTSECTION}.pkglist
+ done
+
+ mkdir -p ${BUILDDIR}/../${NAME}_${VERSION}
+ cp ${BUILDDIR}/debian/changelog ${BUILDDIR}/../${NAME}_${VERSION}/
+ cp ${BUILDDIR}/debian/changelog ${BUILDDIR}/../${NAME}_${VERSION}.changelog
+ rm -rf "${BUILDDIR}"
+ msgdone "info"
+}
+
+buildpackage() {
+ local BUILDDIR=$1
+ local RELEASE=$2
+ local SECTION=$3
+ local ARCH=$(getarchitecture $4)
+ local PKGNAME="$(echo "$BUILDDIR" | grep -o '[^/]*$')"
+ local BUILDLOG="$(readlink -f "${BUILDDIR}/../${PKGNAME}_${RELEASE}_${SECTION}.dpkg-bp.log")"
+ msgtest "Build package for ${RELEASE} in ${SECTION}" "$PKGNAME"
+ cd $BUILDDIR
+ if [ "$ARCH" = "all" ]; then
+ ARCH="$(dpkg-architecture -qDEB_HOST_ARCH 2> /dev/null)"
+ fi
+ testsuccess --nomsg dpkg-buildpackage -uc -us -a$ARCH
+ cp ${TMPWORKINGDIRECTORY}/rootdir/tmp/testsuccess.output $BUILDLOG
+ local PKGS="$(grep '^dpkg-deb: building package' $BUILDLOG | cut -d'/' -f 2 | sed -e "s#'\.##")"
+ local SRCS="$(grep '^dpkg-source: info: building' $BUILDLOG | grep -o '[a-z0-9._+~-]*$')"
+ cd - > /dev/null
+ for PKG in $PKGS; do
+ echo "pool/${PKG}" >> ${TMPWORKINGDIRECTORY}/incoming/${RELEASE}.${SECTION}.pkglist
+ done
+ for SRC in $SRCS; do
+ echo "pool/${SRC}" >> ${TMPWORKINGDIRECTORY}/incoming/${RELEASE}.${SECTION}.srclist
+ done
+}
+
+buildaptarchive() {
+ if [ -d incoming ]; then
+ buildaptarchivefromincoming "$@"
+ else
+ buildaptarchivefromfiles "$@"
+ fi
+}
+
+createaptftparchiveconfig() {
+ local COMPRESSORS="$(cut -d' ' -f 1 ${TMPWORKINGDIRECTORY}/rootdir/etc/testcase-compressor.conf | tr '\n' ' ')"
+ COMPRESSORS="${COMPRESSORS%* }"
+ local ARCHS="$(find pool/ -name '*.deb' | grep -oE '_[a-z0-9-]+\.deb$' | sort | uniq | sed -e '/^_all.deb$/ d' -e 's#^_\([a-z0-9-]*\)\.deb$#\1#' | tr '\n' ' ')"
+ if [ -z "$ARCHS" ]; then
+ # the pool is empty, so we will operate on faked packages - let us use the configured archs
+ ARCHS="$(getarchitectures)"
+ fi
+ echo -n 'Dir {
+ ArchiveDir "' >> ftparchive.conf
+ echo -n $(readlink -f .) >> ftparchive.conf
+ echo -n '";
+ CacheDir "' >> ftparchive.conf
+ echo -n $(readlink -f ..) >> ftparchive.conf
+ echo -n '";
+ FileListDir "' >> ftparchive.conf
+ echo -n $(readlink -f pool/) >> ftparchive.conf
+ echo -n '";
+};
+Default {
+ Packages::Compress "'"$COMPRESSORS"'";
+ Sources::Compress "'"$COMPRESSORS"'";
+ Contents::Compress "'"$COMPRESSORS"'";
+ Translation::Compress "'"$COMPRESSORS"'";
+ LongDescription "false";
+};
+TreeDefault {
+ Directory "pool/";
+ SrcDirectory "pool/";
+};
+APT {
+ FTPArchive {
+ Release {
+ Origin "joesixpack";
+ Label "apttestcases";
+ Suite "unstable";
+ Description "repository with dummy packages";
+ Architectures "' >> ftparchive.conf
+ echo -n "$ARCHS" >> ftparchive.conf
+ echo 'source";
+ };
+ };
+};' >> ftparchive.conf
+ for DIST in $(find ./pool/ -maxdepth 1 -name '*.pkglist' -type f | cut -d'/' -f 3 | cut -d'.' -f 1 | sort | uniq); do
+ echo -n 'tree "dists/' >> ftparchive.conf
+ echo -n "$DIST" >> ftparchive.conf
+ echo -n '" {
+ Architectures "' >> ftparchive.conf
+ echo -n "$ARCHS" >> ftparchive.conf
+ echo -n 'source";
+ FileList "' >> ftparchive.conf
+ echo -n "${DIST}.\$(SECTION).pkglist" >> ftparchive.conf
+ echo -n '";
+ SourceFileList "' >> ftparchive.conf
+ echo -n "${DIST}.\$(SECTION).srclist" >> ftparchive.conf
+ echo -n '";
+ Sections "' >> ftparchive.conf
+ echo -n "$(find ./pool/ -maxdepth 1 -name "${DIST}.*.pkglist" -type f | cut -d'/' -f 3 | cut -d'.' -f 2 | sort | uniq | tr '\n' ' ')" >> ftparchive.conf
+ echo '";
+};' >> ftparchive.conf
+ done
+}
+
+buildaptftparchivedirectorystructure() {
+ local DISTS="$(grep -i '^tree ' ftparchive.conf | cut -d'/' -f 2 | sed -e 's#".*##')"
+ for DIST in $DISTS; do
+ local SECTIONS="$(grep -i -A 5 "dists/$DIST" ftparchive.conf | grep -i 'Sections' | cut -d'"' -f 2)"
+ for SECTION in $SECTIONS; do
+ local ARCHS="$(grep -A 5 "dists/$DIST" ftparchive.conf | grep Architectures | cut -d'"' -f 2 | sed -e 's#source##')"
+ for ARCH in $ARCHS; do
+ mkdir -p dists/${DIST}/${SECTION}/binary-${ARCH}
+ done
+ mkdir -p dists/${DIST}/${SECTION}/source
+ mkdir -p dists/${DIST}/${SECTION}/i18n
+ done
+ done
+}
+
+insertpackage() {
+ local RELEASE="$1"
+ local NAME="$2"
+ local ARCH="$3"
+ local VERSION="$4"
+ local DEPENDENCIES="$5"
+ local PRIORITY="${6:-optional}"
+ local DESCRIPTION="${7:-"an autogenerated dummy ${NAME}=${VERSION}/${RELEASE}
+ If you find such a package installed on your system,
+ something went horribly wrong! They are autogenerated
+ und used only by testcases and surf no other propose…"}"
+ local ARCHS=""
+ for arch in $(getarchitecturesfromcommalist "$ARCH"); do
+ if [ "$arch" = 'all' -o "$arch" = 'none' ]; then
+ ARCHS="$(getarchitectures)"
+ else
+ ARCHS="$arch"
+ fi
+ for BUILDARCH in $ARCHS; do
+ local PPATH="aptarchive/dists/${RELEASE}/main/binary-${BUILDARCH}"
+ mkdir -p $PPATH aptarchive/dists/${RELEASE}/main/source
+ touch aptarchive/dists/${RELEASE}/main/source/Sources
+ local FILE="${PPATH}/Packages"
+ echo "Package: $NAME
+Priority: $PRIORITY
+Section: other
+Installed-Size: 42
+Maintainer: Joe Sixpack <joe@example.org>" >> $FILE
+ test "$arch" = 'none' || echo "Architecture: $arch" >> $FILE
+ echo "Version: $VERSION
+Filename: pool/main/${NAME}/${NAME}_${VERSION}_${arch}.deb" >> $FILE
+ test -z "$DEPENDENCIES" || echo "$DEPENDENCIES" >> $FILE
+ echo "Description: $DESCRIPTION" >> $FILE
+ echo >> $FILE
+ done
+ done
+}
+
+insertsource() {
+ local RELEASE="$1"
+ local NAME="$2"
+ local ARCH="$3"
+ local VERSION="$4"
+ local DEPENDENCIES="$5"
+ local ARCHS=""
+ local SPATH="aptarchive/dists/${RELEASE}/main/source"
+ mkdir -p $SPATH
+ local FILE="${SPATH}/Sources"
+ echo "Package: $NAME
+Binary: $NAME
+Version: $VERSION
+Maintainer: Joe Sixpack <joe@example.org>
+Architecture: $ARCH" >> $FILE
+ test -z "$DEPENDENCIES" || echo "$DEPENDENCIES" >> $FILE
+ echo "Files:
+ d41d8cd98f00b204e9800998ecf8427e 0 ${NAME}_${VERSION}.dsc
+ d41d8cd98f00b204e9800998ecf8427e 0 ${NAME}_${VERSION}.tar.gz
+" >> $FILE
+}
+
+insertinstalledpackage() {
+ local NAME="$1"
+ local ARCH="$2"
+ local VERSION="$3"
+ local DEPENDENCIES="$4"
+ local PRIORITY="${5:-optional}"
+ local STATUS="${6:-install ok installed}"
+ local DESCRIPTION="${7:-"an autogenerated dummy ${NAME}=${VERSION}/installed
+ If you find such a package installed on your system,
+ something went horribly wrong! They are autogenerated
+ und used only by testcases and surf no other propose…"}"
+
+ local FILE='rootdir/var/lib/dpkg/status'
+ local INFO='rootdir/var/lib/dpkg/info'
+ for arch in $(getarchitecturesfromcommalist "$ARCH"); do
+ echo "Package: $NAME
+Status: $STATUS
+Priority: $PRIORITY
+Section: other
+Installed-Size: 42
+Maintainer: Joe Sixpack <joe@example.org>
+Version: $VERSION" >> $FILE
+ test "$arch" = 'none' || echo "Architecture: $arch" >> $FILE
+ test -z "$DEPENDENCIES" || echo "$DEPENDENCIES" >> $FILE
+ echo "Description: $DESCRIPTION" >> $FILE
+ echo >> $FILE
+ if [ "$(dpkg-query -W --showformat='${Multi-Arch}')" = 'same' ]; then
+ echo -n > ${INFO}/${NAME}:${arch}.list
+ else
+ echo -n > ${INFO}/${NAME}.list
+ fi
+ done
+}
+
+
+buildaptarchivefromincoming() {
+ msginfo "Build APT archive for ${CCMD}$(basename $0)${CINFO} based on incoming packages…"
+ cd aptarchive
+ [ -e pool ] || ln -s ../incoming pool
+ [ -e ftparchive.conf ] || createaptftparchiveconfig
+ [ -e dists ] || buildaptftparchivedirectorystructure
+ msgninfo "\tGenerate Packages, Sources and Contents files… "
+ testsuccess aptftparchive generate ftparchive.conf
+ cd - > /dev/null
+ msgdone "info"
+ generatereleasefiles
+}
+
+buildaptarchivefromfiles() {
+ msginfo "Build APT archive for ${CCMD}$(basename $0)${CINFO} based on prebuild files…"
+ find aptarchive -name 'Packages' -o -name 'Sources' | while read line; do
+ msgninfo "\t${line} file… "
+ compressfile "$line" "$1"
+ msgdone "info"
+ done
+ generatereleasefiles "$@"
+}
+
+compressfile() {
+ cat ${TMPWORKINGDIRECTORY}/rootdir/etc/testcase-compressor.conf | while read compressor extension command; do
+ if [ "$compressor" = '.' ]; then
+ if [ -n "$2" ]; then
+ touch -d "$2" "$1"
+ fi
+ continue
+ fi
+ cat "$1" | $command > "${1}.${extension}"
+ if [ -n "$2" ]; then
+ touch -d "$2" "${1}.${extension}"
+ fi
+ done
+}
+
+# can be overridden by testcases for their pleasure
+getcodenamefromsuite() {
+ case "$1" in
+ unstable) echo 'sid';;
+ *) echo -n "$1";;
+ esac
+}
+getreleaseversionfromsuite() { true; }
+getlabelfromsuite() { true; }
+
+generatereleasefiles() {
+ # $1 is the Date header and $2 is the ValidUntil header to be set
+ # both should be given in notation date/touch can understand
+ msgninfo "\tGenerate Release files… "
+ if [ -e aptarchive/dists ]; then
+ for dir in $(find ./aptarchive/dists -mindepth 1 -maxdepth 1 -type d); do
+ local SUITE="$(echo "$dir" | cut -d'/' -f 4)"
+ local CODENAME="$(getcodenamefromsuite $SUITE)"
+ local VERSION="$(getreleaseversionfromsuite $SUITE)"
+ local LABEL="$(getlabelfromsuite $SUITE)"
+ if [ -n "$VERSION" ]; then
+ VERSION="-o APT::FTPArchive::Release::Version=${VERSION}"
+ fi
+ if [ -n "$LABEL" ]; then
+ LABEL="-o APT::FTPArchive::Release::Label=${LABEL}"
+ fi
+ aptftparchive -qq release $dir \
+ -o APT::FTPArchive::Release::Suite="${SUITE}" \
+ -o APT::FTPArchive::Release::Codename="${CODENAME}" \
+ ${LABEL} \
+ ${VERSION} \
+ | sed -e '/0 Release$/ d' > $dir/Release # remove the self reference
+ if [ "$SUITE" = "experimental" -o "$SUITE" = "experimental2" ]; then
+ sed -i '/^Date: / a\
+NotAutomatic: yes' $dir/Release
+ fi
+ if [ -n "$1" -a "$1" != "now" ]; then
+ sed -i "s/^Date: .*$/Date: $(date -d "$1" '+%a, %d %b %Y %H:%M:%S %Z')/" $dir/Release
+ fi
+ if [ -n "$2" ]; then
+ sed -i "/^Date: / a\
+Valid-Until: $(date -d "$2" '+%a, %d %b %Y %H:%M:%S %Z')" $dir/Release
+ fi
+ done
+ else
+ aptftparchive -qq release ./aptarchive | sed -e '/0 Release$/ d' > aptarchive/Release # remove the self reference
+ fi
+ if [ -n "$1" -a "$1" != "now" ]; then
+ for release in $(find ./aptarchive -name 'Release'); do
+ touch -d "$1" $release
+ done
+ fi
+ msgdone "info"
+}
+
+setupdistsaptarchive() {
+ local APTARCHIVE=$(readlink -f ./aptarchive)
+ rm -f root/etc/apt/sources.list.d/apt-test-*-deb.list
+ rm -f root/etc/apt/sources.list.d/apt-test-*-deb-src.list
+ for DISTS in $(find ./aptarchive/dists/ -mindepth 1 -maxdepth 1 -type d | cut -d'/' -f 4); do
+ SECTIONS=$(find ./aptarchive/dists/${DISTS}/ -mindepth 1 -maxdepth 1 -type d | cut -d'/' -f 5 | tr '\n' ' ')
+ msgninfo "\tadd deb and deb-src sources.list lines for ${CCMD}${DISTS} ${SECTIONS}${CINFO}… "
+ echo "deb file://$APTARCHIVE $DISTS $SECTIONS" > rootdir/etc/apt/sources.list.d/apt-test-${DISTS}-deb.list
+ echo "deb-src file://$APTARCHIVE $DISTS $SECTIONS" > rootdir/etc/apt/sources.list.d/apt-test-${DISTS}-deb-src.list
+ msgdone "info"
+ done
+}
+
+setupflataptarchive() {
+ local APTARCHIVE=$(readlink -f ./aptarchive)
+ if [ -f ${APTARCHIVE}/Packages ]; then
+ msgninfo "\tadd deb sources.list line… "
+ echo "deb file://$APTARCHIVE /" > rootdir/etc/apt/sources.list.d/apt-test-archive-deb.list
+ msgdone "info"
+ else
+ rm -f rootdir/etc/apt/sources.list.d/apt-test-archive-deb.list
+ fi
+ if [ -f ${APTARCHIVE}/Sources ]; then
+ msgninfo "\tadd deb-src sources.list line… "
+ echo "deb-src file://$APTARCHIVE /" > rootdir/etc/apt/sources.list.d/apt-test-archive-deb-src.list
+ msgdone "info"
+ else
+ rm -f rootdir/etc/apt/sources.list.d/apt-test-archive-deb-src.list
+ fi
+}
+
+setupaptarchive() {
+ buildaptarchive
+ if [ -e aptarchive/dists ]; then
+ setupdistsaptarchive
+ else
+ setupflataptarchive
+ fi
+ signreleasefiles
+ if [ "$1" != '--no-update' ]; then
+ msgninfo "\tSync APT's cache with the archive… "
+ aptget update -qq
+ msgdone "info"
+ fi
+}
+
+signreleasefiles() {
+ local SIGNER="${1:-Joe Sixpack}"
+ local GPG="gpg --batch --yes"
+ msgninfo "\tSign archive with $SIGNER key… "
+ local REXKEY='keys/rexexpired'
+ local SECEXPIREBAK="${REXKEY}.sec.bak"
+ local PUBEXPIREBAK="${REXKEY}.pub.bak"
+ if [ "${SIGNER}" = 'Rex Expired' ]; then
+ # the key is expired, so gpg doesn't allow to sign with and the --faked-system-time
+ # option doesn't exist anymore (and using faketime would add a new obscure dependency)
+ # therefore we 'temporary' make the key not expired and restore a backup after signing
+ cp ${REXKEY}.sec $SECEXPIREBAK
+ cp ${REXKEY}.pub $PUBEXPIREBAK
+ local SECUNEXPIRED="${REXKEY}.sec.unexpired"
+ local PUBUNEXPIRED="${REXKEY}.pub.unexpired"
+ if [ -f "$SECUNEXPIRED" ] && [ -f "$PUBUNEXPIRED" ]; then
+ cp $SECUNEXPIRED ${REXKEY}.sec
+ cp $PUBUNEXPIRED ${REXKEY}.pub
+ else
+ printf "expire\n1w\nsave\n" | $GPG --keyring ${REXKEY}.pub --secret-keyring ${REXKEY}.sec --command-fd 0 --edit-key "${SIGNER}" >/dev/null 2>&1 || true
+ cp ${REXKEY}.sec $SECUNEXPIRED
+ cp ${REXKEY}.pub $PUBUNEXPIRED
+ fi
+ fi
+ for KEY in $(find keys/ -name '*.sec'); do
+ GPG="$GPG --secret-keyring $KEY"
+ done
+ for KEY in $(find keys/ -name '*.pub'); do
+ GPG="$GPG --keyring $KEY"
+ done
+ for RELEASE in $(find aptarchive/ -name Release); do
+ $GPG --default-key "$SIGNER" --armor --detach-sign --sign --output ${RELEASE}.gpg ${RELEASE}
+ local INRELEASE="$(echo "${RELEASE}" | sed 's#/Release$#/InRelease#')"
+ $GPG --default-key "$SIGNER" --clearsign --output $INRELEASE $RELEASE
+ # we might have set a specific date for the Release file, so copy it
+ touch -d "$(stat --format "%y" ${RELEASE})" ${RELEASE}.gpg ${INRELEASE}
+ done
+ if [ -f "$SECEXPIREBAK" ] && [ -f "$PUBEXPIREBAK" ]; then
+ mv -f $SECEXPIREBAK ${REXKEY}.sec
+ mv -f $PUBEXPIREBAK ${REXKEY}.pub
+ fi
+ msgdone "info"
+}
+
+webserverconfig() {
+ msgtest "Set webserver config option '${1}' to" "$2"
+ local DOWNLOG='rootdir/tmp/download-testfile.log'
+ local STATUS='rootdir/tmp/webserverconfig.status'
+ rm -f "$STATUS" "$DOWNLOG"
+ if downloadfile "http://localhost:8080/_config/set/${1}/${2}" "$STATUS" > "$DOWNLOG"; then
+ msgpass
+ else
+ cat "$DOWNLOG" "$STATUS"
+ msgfail
+ fi
+ testwebserverlaststatuscode '200'
+}
+
+rewritesourceslist() {
+ local APTARCHIVE="file://$(readlink -f "${TMPWORKINGDIRECTORY}/aptarchive")"
+ for LIST in $(find rootdir/etc/apt/sources.list.d/ -name 'apt-test-*.list'); do
+ sed -i $LIST -e "s#$APTARCHIVE#${1}#" -e "s#http://localhost:8080/#${1}#" -e "s#http://localhost:4433/#${1}#"
+ done
+}
+
+# wait for up to 10s for a pid file to appear to avoid possible race
+# when a helper is started and dosn't write the PID quick enough
+waitforpidfile() {
+ local PIDFILE="$1"
+ for i in $(seq 10); do
+ if test -s "$PIDFILE"; then
+ return 0
+ fi
+ sleep 1
+ done
+ msgdie "waiting for $PIDFILE failed"
+ return 1
+}
+
+changetowebserver() {
+ if [ "$1" != '--no-rewrite' ]; then
+ rewritesourceslist 'http://localhost:8080/'
+ else
+ shift
+ fi
+ if test -x ${APTWEBSERVERBINDIR}/aptwebserver; then
+ cd aptarchive
+ local LOG="webserver.log"
+ if ! aptwebserver -o aptwebserver::fork=1 "$@" >$LOG 2>&1 ; then
+ cat $LOG
+ false
+ fi
+ waitforpidfile aptwebserver.pid
+ local PID="$(cat aptwebserver.pid)"
+ if [ -z "$PID" ]; then
+ msgdie 'Could not fork aptwebserver successfully'
+ fi
+ addtrap "kill $PID;"
+ cd - > /dev/null
+ else
+ msgdie 'You have to build aptwerbserver or install a webserver'
+ fi
+}
+
+changetohttpswebserver() {
+ if ! which stunnel4 >/dev/null; then
+ msgdie 'You need to install stunnel4 for https testcases'
+ fi
+ if [ ! -e "${TMPWORKINGDIRECTORY}/aptarchive/aptwebserver.pid" ]; then
+ changetowebserver --no-rewrite "$@"
+ fi
+ echo "pid = ${TMPWORKINGDIRECTORY}/aptarchive/stunnel.pid
+cert = ${TESTDIRECTORY}/apt.pem
+output = /dev/null
+
+[https]
+accept = 4433
+connect = 8080
+" > ${TMPWORKINGDIRECTORY}/stunnel.conf
+ stunnel4 "${TMPWORKINGDIRECTORY}/stunnel.conf"
+ waitforpidfile "${TMPWORKINGDIRECTORY}/aptarchive/stunnel.pid"
+ local PID="$(cat ${TMPWORKINGDIRECTORY}/aptarchive/stunnel.pid)"
+ if [ -z "$PID" ]; then
+ msgdie 'Could not fork stunnel4 successfully'
+ fi
+ addtrap 'prefix' "kill ${PID};"
+ rewritesourceslist 'https://localhost:4433/'
+}
+
+changetocdrom() {
+ mkdir -p rootdir/media/cdrom/.disk
+ local CD="$(readlink -f rootdir/media/cdrom)"
+ echo "acquire::cdrom::mount \"${CD}\";
+acquire::cdrom::${CD}/::mount \"mv ${CD}-unmounted ${CD}\";
+acquire::cdrom::${CD}/::umount \"mv ${CD} ${CD}-unmounted\";
+acquire::cdrom::autodetect 0;" > rootdir/etc/apt/apt.conf.d/00cdrom
+ echo -n "$1" > ${CD}/.disk/info
+ if [ ! -d aptarchive/dists ]; then
+ msgdie 'Flat file archive cdroms can not be created currently'
+ return 1
+ fi
+ mv aptarchive/dists "$CD"
+ ln -s "$(readlink -f ./incoming)" $CD/pool
+ find rootdir/etc/apt/sources.list.d/ -name 'apt-test-*.list' -delete
+ # start with an unmounted disk
+ mv "${CD}" "${CD}-unmounted"
+ # we don't want the disk to be modifiable
+ addtrap 'prefix' "chmod -f -R +w $PWD/rootdir/media/cdrom/dists/ $PWD/rootdir/media/cdrom-unmounted/dists/ || true;"
+ chmod -R -w rootdir/media/cdrom-unmounted/dists
+}
+
+downloadfile() {
+ local PROTO="${1%%:*}"
+ apthelper -o Debug::Acquire::${PROTO}=1 -o Debug::pkgAcquire::Worker=1 \
+ download-file "$1" "$2" 2>&1 || true
+ # only if the file exists the download was successful
+ if [ -e "$2" ]; then
+ return 0
+ else
+ return 1
+ fi
+}
+
+checkdiff() {
+ local DIFFTEXT="$(command diff -u "$@" | sed -e '/^---/ d' -e '/^+++/ d' -e '/^@@/ d')"
+ if [ -n "$DIFFTEXT" ]; then
+ echo >&2
+ echo >&2 "$DIFFTEXT"
+ return 1
+ else
+ return 0
+ fi
+}
+
+testfileequal() {
+ local FILE="$1"
+ shift
+ msgtest "Test for correctness of file" "$FILE"
+ if [ -z "$*" ]; then
+ echo -n "" | checkdiff $FILE - && msgpass || msgfail
+ else
+ echo "$*" | checkdiff $FILE - && msgpass || msgfail
+ fi
+}
+
+testempty() {
+ msgtest "Test for no output of" "$*"
+ local COMPAREFILE="${TMPWORKINGDIRECTORY}/rootdir/tmp/testempty.comparefile"
+ if $* >$COMPAREFILE 2>&1 && test ! -s $COMPAREFILE; then
+ msgpass
+ else
+ cat $COMPAREFILE
+ msgfail
+ fi
+}
+
+testequal() {
+ local MSG='Test of equality of'
+ if [ "$1" = '--nomsg' ]; then
+ MSG=''
+ shift
+ fi
+
+ local COMPAREFILE="${TMPWORKINGDIRECTORY}/rootdir/tmp/testequal.comparefile"
+ echo "$1" > $COMPAREFILE
+ shift
+
+ if [ -n "$MSG" ]; then
+ msgtest "$MSG" "$*"
+ fi
+ "$@" 2>&1 | checkdiff $COMPAREFILE - && msgpass || msgfail
+}
+
+testequalor2() {
+ local COMPAREFILE1="${TMPWORKINGDIRECTORY}/rootdir/tmp/testequalor2.comparefile1"
+ local COMPAREFILE2="${TMPWORKINGDIRECTORY}/rootdir/tmp/testequalor2.comparefile2"
+ local COMPAREAGAINST="${TMPWORKINGDIRECTORY}/rootdir/tmp/testequalor2.compareagainst"
+ echo "$1" > $COMPAREFILE1
+ echo "$2" > $COMPAREFILE2
+ shift 2
+ msgtest "Test for equality OR of" "$*"
+ $* >$COMPAREAGAINST 2>&1 || true
+ if checkdiff $COMPAREFILE1 $COMPAREAGAINST >/dev/null 2>&1 || \
+ checkdiff $COMPAREFILE2 $COMPAREAGAINST >/dev/null 2>&1
+ then
+ msgpass
+ else
+ echo -n "\n${CINFO}Diff against OR 1${CNORMAL}"
+ checkdiff $COMPAREFILE1 $COMPAREAGAINST || true
+ echo -n "${CINFO}Diff against OR 2${CNORMAL}"
+ checkdiff $COMPAREFILE2 $COMPAREAGAINST || true
+ msgfail
+ fi
+}
+
+testshowvirtual() {
+ local VIRTUAL="N: Can't select versions from package '$1' as it is purely virtual"
+ local PACKAGE="$1"
+ shift
+ while [ -n "$1" ]; do
+ VIRTUAL="${VIRTUAL}
+N: Can't select versions from package '$1' as it is purely virtual"
+ PACKAGE="${PACKAGE} $1"
+ shift
+ done
+ msgtest "Test for virtual packages" "apt-cache show $PACKAGE"
+ VIRTUAL="${VIRTUAL}
+N: No packages found"
+ local COMPAREFILE="${TMPWORKINGDIRECTORY}/rootdir/tmp/testshowvirtual.comparefile"
+ local ARCH="$(getarchitecture 'native')"
+ echo "$VIRTUAL" | sed -e "s/:$ARCH//" -e 's/:all//' > $COMPAREFILE
+ aptcache show -q=0 $PACKAGE 2>&1 | checkdiff $COMPAREFILE - && msgpass || msgfail
+}
+
+testnopackage() {
+ msgtest "Test for non-existent packages" "apt-cache show $*"
+ local SHOWPKG="$(aptcache show "$@" 2>&1 | grep '^Package: ')"
+ if [ -n "$SHOWPKG" ]; then
+ echo >&2
+ echo >&2 "$SHOWPKG"
+ msgfail
+ else
+ msgpass
+ fi
+}
+
+testdpkgstatus() {
+ local STATE="$1"
+ local NR="$2"
+ shift 2
+ msgtest "Test that $NR package(s) are in state $STATE with" "dpkg -l $*"
+ local PKGS="$(dpkg -l "$@" 2>/dev/null | grep "^${STATE}" | wc -l)"
+ if [ "$PKGS" != $NR ]; then
+ echo >&2 $PKGS
+ dpkg -l "$@" | grep '^[a-z]' >&2
+ msgfail
+ else
+ msgpass
+ fi
+}
+
+testdpkginstalled() {
+ testdpkgstatus 'ii' "$#" "$@"
+}
+
+testdpkgnotinstalled() {
+ testdpkgstatus 'ii' '0' "$@"
+}
+
+testmarkedauto() {
+ local COMPAREFILE="${TMPWORKINGDIRECTORY}/rootdir/tmp/testmarkedauto.comparefile"
+ if [ -n "$1" ]; then
+ msgtest 'Test for correctly marked as auto-installed' "$*"
+ while [ -n "$1" ]; do echo "$1"; shift; done | sort > $COMPAREFILE
+ else
+ msgtest 'Test for correctly marked as auto-installed' 'no package'
+ echo -n > $COMPAREFILE
+ fi
+ aptmark showauto 2>&1 | checkdiff $COMPAREFILE - && msgpass || msgfail
+}
+
+testsuccess() {
+ if [ "$1" = '--nomsg' ]; then
+ shift
+ else
+ msgtest 'Test for successful execution of' "$*"
+ fi
+ local OUTPUT="${TMPWORKINGDIRECTORY}/rootdir/tmp/testsuccess.output"
+ if "$@" >${OUTPUT} 2>&1; then
+ msgpass
+ else
+ echo >&2
+ cat >&2 $OUTPUT
+ msgfail
+ fi
+}
+
+testfailure() {
+ if [ "$1" = '--nomsg' ]; then
+ shift
+ else
+ msgtest 'Test for failure in execution of' "$*"
+ fi
+ local OUTPUT="${TMPWORKINGDIRECTORY}/rootdir/tmp/testfailure.output"
+ if $@ >${OUTPUT} 2>&1; then
+ echo >&2
+ cat >&2 $OUTPUT
+ msgfail
+ else
+ msgpass
+ fi
+}
+
+testwebserverlaststatuscode() {
+ local DOWNLOG='rootdir/tmp/webserverstatus-testfile.log'
+ local STATUS='rootdir/tmp/webserverstatus-statusfile.log'
+ rm -f "$DOWNLOG" "$STATUS"
+ msgtest 'Test last status code from the webserver was' "$1"
+ downloadfile "http://localhost:8080/_config/find/aptwebserver::last-status-code" "$STATUS" > "$DOWNLOG"
+ if [ "$(cat "$STATUS")" = "$1" ]; then
+ msgpass
+ else
+ echo >&2
+ if [ -n "$2" ]; then
+ shift
+ echo >&2 '#### Additionally provided output files contain:'
+ cat >&2 "$@"
+ fi
+ echo >&2 '#### Download log of the status code:'
+ cat >&2 "$DOWNLOG"
+ msgfail "Status was $(cat "$STATUS")"
+ fi
+}
+
+pause() {
+ echo "STOPPED execution. Press enter to continue"
+ local IGNORE
+ read IGNORE
+}
diff --git a/apt/test/integration/run-tests b/apt/test/integration/run-tests
new file mode 100755
index 0000000..c39a2ac
--- /dev/null
+++ b/apt/test/integration/run-tests
@@ -0,0 +1,66 @@
+#!/bin/sh
+set -e
+
+FAIL=0
+PASS=0
+ALL=0
+
+FAILED_TESTS=""
+DIR=$(readlink -f $(dirname $0))
+while [ -n "$1" ]; do
+ if [ "$1" = "-q" ]; then
+ export MSGLEVEL=2
+ elif [ "$1" = "-v" ]; then
+ export MSGLEVEL=4
+ elif [ "$1" = '--color=no' ]; then
+ export MSGCOLOR='NO'
+ else
+ echo >&2 "WARNING: Unknown parameter »$1« will be ignored"
+ fi
+ shift
+done
+export MSGLEVEL="${MSGLEVEL:-3}"
+
+if [ "$MSGCOLOR" != 'NO' ]; then
+ if [ ! -t 1 ]; then # but check that we output to a terminal
+ export MSGCOLOR='NO'
+ fi
+fi
+if [ "$MSGCOLOR" != 'NO' ]; then
+ CTEST='\033[1;32m'
+ CHIGH='\033[1;35m'
+ CRESET='\033[0m'
+else
+ CTEST=''
+ CHIGH=''
+ CRESET=''
+fi
+
+TOTAL="$(run-parts --list $DIR | grep '/test-' | wc -l)"
+for testcase in $(run-parts --list $DIR | grep '/test-'); do
+ if [ "$MSGLEVEL" -le 2 ]; then
+ printf "($(($ALL+1))/${TOTAL}) ${CTEST}Testcase ${CHIGH}$(basename ${testcase})${CRESET}: "
+ else
+ printf "${CTEST}Run Testcase ($(($ALL+1))/${TOTAL}) ${CHIGH}$(basename ${testcase})${CRESET}\n"
+ fi
+ if ! ${testcase}; then
+ FAIL=$((FAIL+1))
+ FAILED_TESTS="$FAILED_TESTS $(basename $testcase)"
+ echo >&2 "$(basename $testcase) ... FAIL"
+ else
+ PASS=$((PASS+1))
+ fi
+ ALL=$((ALL+1))
+ if [ "$MSGLEVEL" -le 2 ]; then
+ echo
+ fi
+done
+
+echo >&2 "Statistics: $ALL tests were run: $PASS successfully and $FAIL failed"
+if [ -n "$FAILED_TESTS" ]; then
+ echo >&2 "Failed tests: $FAILED_TESTS"
+else
+ echo >&2 'All tests seem to have been run successfully. What could possibly go wrong?'
+fi
+# ensure we don't overflow
+exit $((FAIL <= 255 ? FAIL : 255))
--
2.24.0
^ permalink raw reply [flat|nested] 84+ messages in thread
* [devel] [PATCH for apt 34/38] Add initial integration tests
2019-12-10 15:23 [devel] [PATCH for apt 00/38] Various fixes for Apt and basic integration test suite Aleksei Nikiforov
` (32 preceding siblings ...)
2019-12-10 15:23 ` [devel] [PATCH for apt 33/38] Import integration tests framework from Debian Aleksei Nikiforov
@ 2019-12-10 15:23 ` Aleksei Nikiforov
2019-12-10 15:23 ` [devel] [PATCH for apt 35/38] Add basic tests to ensure that lua and rpm scripts are called Aleksei Nikiforov
` (3 subsequent siblings)
37 siblings, 0 replies; 84+ messages in thread
From: Aleksei Nikiforov @ 2019-12-10 15:23 UTC (permalink / raw)
To: devel; +Cc: Aleksei Nikiforov
---
apt/test/integration/framework | 1093 +++--------------
apt/test/integration/run-tests | 8 +-
.../conflicting-package-distupgrade.spec | 18 +
.../specs/conflicting-package-one.spec | 17 +
.../specs/conflicting-package-two.spec | 17 +
.../integration/specs/missing-dependency.spec | 17 +
.../integration/specs/simple-package-new.spec | 19 +
.../specs/simple-package-noarch.spec | 17 +
.../specs/simple-package-update-conflict.spec | 17 +
.../specs/simple-package-update.spec | 15 +
.../integration/specs/simple-package.spec | 15 +
.../integration/specs/simple-virtual.spec | 17 +
.../integration/test-apt-cache-depends-simple | 38 +
apt/test/integration/test-apt-cache-dump | 92 ++
apt/test/integration/test-apt-cache-dumpavail | 115 ++
apt/test/integration/test-apt-cache-pkgnames | 32 +
.../integration/test-apt-cache-search-simple | 38 +
.../integration/test-apt-cache-show-simple | 67 +
.../integration/test-apt-cache-showpkg-simple | 44 +
apt/test/integration/test-apt-cache-stats | 36 +
apt/test/integration/test-apt-cache-unmet | 31 +
.../test-apt-cache-whatdepends-simple | 43 +
apt/test/integration/test-apt-check-simple | 26 +
apt/test/integration/test-apt-config-dump | 61 +
.../integration/test-apt-distupgrade-conflict | 30 +
.../test-apt-distupgrade-mutual-conflict | 31 +
.../integration/test-apt-distupgrade-obsolete | 26 +
.../integration/test-apt-distupgrade-simple | 23 +
.../test-apt-install-conflicting-packages | 27 +
apt/test/integration/test-apt-install-double | 17 +
apt/test/integration/test-apt-install-simple | 13 +
apt/test/integration/test-apt-mark-simple | 58 +
apt/test/integration/test-apt-remove-double | 22 +
apt/test/integration/test-apt-remove-simple | 15 +
apt/test/integration/test-apt-update-simple | 19 +
apt/test/integration/test-apt-upgrade-simple | 26 +
36 files changed, 1263 insertions(+), 937 deletions(-)
create mode 100644 apt/test/integration/specs/conflicting-package-distupgrade.spec
create mode 100644 apt/test/integration/specs/conflicting-package-one.spec
create mode 100644 apt/test/integration/specs/conflicting-package-two.spec
create mode 100644 apt/test/integration/specs/missing-dependency.spec
create mode 100644 apt/test/integration/specs/simple-package-new.spec
create mode 100644 apt/test/integration/specs/simple-package-noarch.spec
create mode 100644 apt/test/integration/specs/simple-package-update-conflict.spec
create mode 100644 apt/test/integration/specs/simple-package-update.spec
create mode 100644 apt/test/integration/specs/simple-package.spec
create mode 100644 apt/test/integration/specs/simple-virtual.spec
create mode 100755 apt/test/integration/test-apt-cache-depends-simple
create mode 100755 apt/test/integration/test-apt-cache-dump
create mode 100755 apt/test/integration/test-apt-cache-dumpavail
create mode 100755 apt/test/integration/test-apt-cache-pkgnames
create mode 100755 apt/test/integration/test-apt-cache-search-simple
create mode 100755 apt/test/integration/test-apt-cache-show-simple
create mode 100755 apt/test/integration/test-apt-cache-showpkg-simple
create mode 100755 apt/test/integration/test-apt-cache-stats
create mode 100755 apt/test/integration/test-apt-cache-unmet
create mode 100755 apt/test/integration/test-apt-cache-whatdepends-simple
create mode 100755 apt/test/integration/test-apt-check-simple
create mode 100755 apt/test/integration/test-apt-config-dump
create mode 100755 apt/test/integration/test-apt-distupgrade-conflict
create mode 100755 apt/test/integration/test-apt-distupgrade-mutual-conflict
create mode 100755 apt/test/integration/test-apt-distupgrade-obsolete
create mode 100755 apt/test/integration/test-apt-distupgrade-simple
create mode 100755 apt/test/integration/test-apt-install-conflicting-packages
create mode 100755 apt/test/integration/test-apt-install-double
create mode 100755 apt/test/integration/test-apt-install-simple
create mode 100755 apt/test/integration/test-apt-mark-simple
create mode 100755 apt/test/integration/test-apt-remove-double
create mode 100755 apt/test/integration/test-apt-remove-simple
create mode 100755 apt/test/integration/test-apt-update-simple
create mode 100755 apt/test/integration/test-apt-upgrade-simple
diff --git a/apt/test/integration/framework b/apt/test/integration/framework
index bccbb71..326874a 100644
--- a/apt/test/integration/framework
+++ b/apt/test/integration/framework
@@ -1,4 +1,4 @@
-#!/bin/sh -- # no runable script, just for vi
+#!/bin/bash
EXIT_CODE=0
@@ -9,7 +9,6 @@ if [ "$MSGCOLOR" != 'NO' ]; then
fi
fi
-
if [ "$MSGCOLOR" != 'NO' ]; then
CERROR="\033[1;31m" # red
CWARNING="\033[1;33m" # yellow
@@ -101,47 +100,14 @@ runapt() {
msgdebug "Executing: ${CCMD}$*${CDEBUG} "
local CMD="$1"
shift
- case $CMD in
- sh|aptitude|*/*|command) ;;
- *) CMD="${BUILDDIRECTORY}/$CMD";;
- esac
- MALLOC_PERTURB_=21 MALLOC_CHECK_=2 APT_CONFIG="$(getaptconfig)" LD_LIBRARY_PATH=${BUILDDIRECTORY} $CMD "$@"
+ APT_CONFIG="$(getaptconfig)" $CMD "$@"
}
aptconfig() { runapt apt-config "$@"; }
aptcache() { runapt apt-cache "$@"; }
aptcdrom() { runapt apt-cdrom "$@"; }
aptget() { runapt apt-get "$@"; }
-aptftparchive() { runapt apt-ftparchive "$@"; }
-aptkey() { runapt apt-key "$@"; }
aptmark() { runapt apt-mark "$@"; }
-aptsortpkgs() { runapt apt-sortpkgs "$@"; }
-apt() { runapt apt "$@"; }
-apthelper() { runapt "${APTHELPERBINDIR}/apt-helper" "$@"; }
-aptwebserver() { runapt "${APTWEBSERVERBINDIR}/aptwebserver" "$@"; }
-aptitude() { runapt aptitude "$@"; }
-aptextracttemplates() { runapt apt-extracttemplates "$@"; }
-aptinternalsolver() { runapt "${APTINTERNALSOLVER}" "$@"; }
-
-dpkg() {
- command dpkg --root=${TMPWORKINGDIRECTORY}/rootdir --force-not-root --force-bad-path --log=${TMPWORKINGDIRECTORY}/rootdir/var/log/dpkg.log "$@"
-}
-dpkgcheckbuilddeps() {
- command dpkg-checkbuilddeps --admindir=${TMPWORKINGDIRECTORY}/rootdir/var/lib/dpkg "$@"
-}
-gdb() {
- echo "gdb: run »$*«"
- CMD="$1"
- shift
- APT_CONFIG=aptconfig.conf LD_LIBRARY_PATH=${LIBRARYPATH} command gdb ${BUILDDIRECTORY}/$CMD --args ${BUILDDIRECTORY}/$CMD "$@"
-}
-gpg() {
- # see apt-key for the whole trickery. Setup is done in setupenvironment
- command gpg --ignore-time-conflict --no-options --no-default-keyring \
- --homedir "${TMPWORKINGDIRECTORY}/gnupghome" \
- --no-auto-check-trustdb --trust-model always \
- "$@"
-}
exitwithstatus() {
# error if we about to overflow, but ...
@@ -176,87 +142,52 @@ setupenvironment() {
TESTDIRECTORY=$(readlink -f $(dirname $0))
msgninfo "Preparing environment for ${CCMD}$(basename $0)${CINFO} in ${TMPWORKINGDIRECTORY}… "
- # allow overriding the default BUILDDIR location
- BUILDDIRECTORY=${APT_INTEGRATION_TESTS_BUILD_DIR:-"${TESTDIRECTORY}/../../build/bin"}
- LIBRARYPATH=${APT_INTEGRATION_TESTS_LIBRARY_PATH:-"${BUILDDIRECTORY}"}
- METHODSDIR=${APT_INTEGRATION_TESTS_METHODS_DIR:-"${BUILDDIRECTORY}/methods"}
- APTHELPERBINDIR=${APT_INTEGRATION_TESTS_LIBEXEC_DIR:-"${BUILDDIRECTORY}"}
- APTWEBSERVERBINDIR=${APT_INTEGRATION_TESTS_WEBSERVER_BIN_DIR:-"${BUILDDIRECTORY}"}
- APTINTERNALSOLVER=${APT_INTEGRATION_TESTS_INTERNAL_SOLVER:-"${BUILDDIRECTORY}/apt-internal-solver"}
- test -x "${BUILDDIRECTORY}/apt-get" || msgdie "You need to build tree first"
- # -----
-
addtrap "cd /; rm -rf $TMPWORKINGDIRECTORY;"
cd $TMPWORKINGDIRECTORY
mkdir rootdir aptarchive keys
cd rootdir
mkdir -p etc/apt/apt.conf.d etc/apt/sources.list.d etc/apt/trusted.gpg.d etc/apt/preferences.d
mkdir -p var/cache var/lib/apt var/log tmp
- mkdir -p var/lib/dpkg/info var/lib/dpkg/updates var/lib/dpkg/triggers
- touch var/lib/dpkg/available
- mkdir -p usr/lib/apt
- ln -s ${METHODSDIR} usr/lib/apt/methods
- if [ "$BUILDDIRECTORY" = "$LIBRARYPATH" ]; then
- mkdir -p usr/lib/apt/solvers
- ln -s "${BUILDDIRECTORY}/apt-dump-solver" usr/lib/apt/solvers/dump
- ln -s "${BUILDDIRECTORY}/apt-internal-solver" usr/lib/apt/solvers/apt
- echo "Dir::Bin::Solvers \"${TMPWORKINGDIRECTORY}/rootdir/usr/lib/apt/solvers\";" > etc/apt/apt.conf.d/externalsolver.conf
- fi
- # use the autoremove from the BUILDDIRECTORY if its there, otherwise
- # system
- if [ -e ${BUILDDIRECTORY}/../../debian/apt.conf.autoremove ]; then
- ln -s ${BUILDDIRECTORY}/../../debian/apt.conf.autoremove etc/apt/apt.conf.d/01autoremove
- else
- ln -s /etc/apt/apt.conf.d/01autoremove etc/apt/apt.conf.d/01autoremove
- fi
+ mkdir -p var/lib/rpm
+ mkdir -p var/lib/apt/lists/partial var/cache/apt/archives/partial
cd ..
- local PACKAGESFILE=$(echo "$(basename $0)" | sed -e 's/^test-/Packages-/' -e 's/^skip-/Packages-/')
- if [ -f "${TESTDIRECTORY}/${PACKAGESFILE}" ]; then
- cp "${TESTDIRECTORY}/${PACKAGESFILE}" aptarchive/Packages
- fi
- local SOURCESSFILE=$(echo "$(basename $0)" | sed -e 's/^test-/Sources-/' -e 's/^skip-/Sources-/')
- if [ -f "${TESTDIRECTORY}/${SOURCESSFILE}" ]; then
- cp "${TESTDIRECTORY}/${SOURCESSFILE}" aptarchive/Sources
- fi
- cp $(find $TESTDIRECTORY -name '*.pub' -o -name '*.sec') keys/
- ln -s ${TMPWORKINGDIRECTORY}/keys/joesixpack.pub rootdir/etc/apt/trusted.gpg.d/joesixpack.gpg
+
echo "Dir \"${TMPWORKINGDIRECTORY}/rootdir\";" > aptconfig.conf
- echo "Dir::state::status \"${TMPWORKINGDIRECTORY}/rootdir/var/lib/dpkg/status\";" >> aptconfig.conf
echo "Debug::NoLocking \"true\";" >> aptconfig.conf
- echo "APT::Get::Show-User-Simulation-Note \"false\";" >> aptconfig.conf
- echo "Dir::Bin::Methods \"${METHODSDIR}\";" >> aptconfig.conf
- echo "Dir::Bin::dpkg \"fakeroot\";" >> aptconfig.conf
- echo "DPKG::options:: \"dpkg\";" >> aptconfig.conf
- echo "DPKG::options:: \"--root=${TMPWORKINGDIRECTORY}/rootdir\";" >> aptconfig.conf
- echo "DPKG::options:: \"--force-not-root\";" >> aptconfig.conf
- echo "DPKG::options:: \"--force-bad-path\";" >> aptconfig.conf
- if ! command dpkg --assert-multi-arch >/dev/null 2>&1; then
- echo "DPKG::options:: \"--force-architecture\";" >> aptconfig.conf # Added to test multiarch before dpkg is ready for it…
+ echo "Dir::Etc::sourcelist \"${TMPWORKINGDIRECTORY}/rootdir/etc/apt/sources.list\";" >> aptconfig.conf
+
+ if [ -n "$METHODSDIR" ] ; then
+ echo "Dir::Bin::methods \"$METHODSDIR\";" >> aptconfig.conf
fi
- echo "DPKG::options:: \"--log=${TMPWORKINGDIRECTORY}/rootdir/var/log/dpkg.log\";" >> aptconfig.conf
- echo 'quiet::NoUpdate "true";' >> aptconfig.conf
- echo "Acquire::https::CaInfo \"${TESTDIR}/apt.pem\";" > rootdir/etc/apt/apt.conf.d/99https
- echo "Apt::Cmd::Disable-Script-Warning \"1\";" > rootdir/etc/apt/apt.conf.d/apt-binary
- configcompression '.' 'gz' #'bz2' 'lzma' 'xz'
-
- # gpg needs a trustdb to function, but it can't be invalid (not even empty)
- # see also apt-key where this trickery comes from:
- local TRUSTDBDIR="${TMPWORKINGDIRECTORY}/gnupghome"
- mkdir "$TRUSTDBDIR"
- chmod 700 "$TRUSTDBDIR"
- # We also don't use a secret keyring, of course, but gpg panics and
- # implodes if there isn't one available - and writeable for imports
- local SECRETKEYRING="${TRUSTDBDIR}/secring.gpg"
- touch $SECRETKEYRING
- # now create the trustdb with an (empty) dummy keyring
- # newer gpg versions are fine without it, but play it safe for now
- gpg --quiet --check-trustdb --secret-keyring $SECRETKEYRING --keyring $SECRETKEYRING >/dev/null 2>&1
+
+ cat > rootdir/etc/apt/pkgpriorities << END
+Important:
+ basesystem
+Required:
+ apt
+ systemd-sysvinit
+ sysvinit
+ openssh-server
+Standard:
+ postfix
+END
+
+ cat > rootdir/etc/apt/sources.list << END
+rpm file://$TMPWORKINGDIRECTORY/usr/src/RPM/REPO $(getarchitecture) apt-tests
+rpm file://$TMPWORKINGDIRECTORY/usr/src/RPM/REPO noarch apt-tests
+END
# cleanup the environment a bit
export PATH="${PATH}:/usr/local/sbin:/usr/sbin:/sbin"
export LC_ALL=C.UTF-8
unset LANGUAGE APT_CONFIG
- unset GREP_OPTIONS DEB_BUILD_PROFILES
+ unset GREP_OPTIONS
+
+ # Initialize rpmdb
+ rpmdb --dbpath="$TMPWORKINGDIRECTORY/var/lib/rpm" --initdb
+
+ # setup rpm dbpath
+ echo "RPM::DBPath \"$TMPWORKINGDIRECTORY/var/lib/rpm\";" > rootdir/etc/apt/apt.conf.d/99rpmdbpath.conf
msgdone "info"
}
@@ -267,7 +198,7 @@ getarchitecture() {
if [ -n "$ARCH" ]; then
echo $ARCH
else
- dpkg --print-architecture
+ uname -m
fi
else
echo $1
@@ -282,799 +213,31 @@ getarchitecturesfromcommalist() {
echo "$1" | sed -e 's#,#\n#g' | sed -e "s/^native\$/$(getarchitecture 'native')/"
}
-configarchitecture() {
- {
- echo "APT::Architecture \"$(getarchitecture $1)\";"
- while [ -n "$1" ]; do
- echo "APT::Architectures:: \"$(getarchitecture $1)\";"
- shift
- done
- } >rootdir/etc/apt/apt.conf.d/01multiarch.conf
- configdpkg
-}
-
-configdpkg() {
- if [ ! -e rootdir/var/lib/dpkg/status ]; then
- local STATUSFILE=$(echo "$(basename $0)" | sed -e 's/^test-/status-/' -e 's/^skip-/status-/')
- if [ -f "${TESTDIRECTORY}/${STATUSFILE}" ]; then
- cp "${TESTDIRECTORY}/${STATUSFILE}" rootdir/var/lib/dpkg/status
- else
- echo -n > rootdir/var/lib/dpkg/status
- fi
- fi
- rm -f rootdir/etc/apt/apt.conf.d/00foreigndpkg
- if command dpkg --assert-multi-arch >/dev/null 2>&1 ; then
- local ARCHS="$(getarchitectures)"
- if echo "$ARCHS" | grep -E -q '[^ ]+ [^ ]+'; then
- DPKGARCH="$(dpkg --print-architecture)"
- for ARCH in ${ARCHS}; do
- if [ "${ARCH}" != "${DPKGARCH}" ]; then
- if ! dpkg --add-architecture ${ARCH} >/dev/null 2>&1; then
- # old-style used e.g. in Ubuntu-P – and as it seems travis
- echo "DPKG::options:: \"--foreign-architecture\";" >> rootdir/etc/apt/apt.conf.d/00foreigndpkg
- echo "DPKG::options:: \"${ARCH}\";" >> rootdir/etc/apt/apt.conf.d/00foreigndpkg
- fi
- fi
- done
- if [ "0" = "$(dpkg -l dpkg 2> /dev/null | grep '^i' | wc -l)" ]; then
- # dpkg doesn't really check the version as long as it is fully installed,
- # but just to be sure we choose one above the required version
- insertinstalledpackage 'dpkg' "all" '1.16.2+fake'
- fi
- fi
- fi
-}
-
-configdpkgnoopchroot() {
- # create a library to noop chroot() and rewrite maintainer script executions
- # via execvp() as used by dpkg as we don't want our rootdir to be a fullblown
- # chroot directory dpkg could chroot into to execute the maintainer scripts
- msgtest 'Building library to preload to make maintainerscript work in' 'dpkg'
- cat << EOF > noopchroot.c
-#define _GNU_SOURCE
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <dlfcn.h>
-
-static char * chrootdir = NULL;
-
-int chroot(const char *path) {
- printf("WARNING: CHROOTing to %s was ignored!\n", path);
- free(chrootdir);
- chrootdir = strdup(path);
- return 0;
-}
-int execvp(const char *file, char *const argv[]) {
- static int (*func_execvp) (const char *, char * const []) = NULL;
- if (func_execvp == NULL)
- func_execvp = (int (*) (const char *, char * const [])) dlsym(RTLD_NEXT, "execvp");
- if (chrootdir == NULL || strncmp(file, "/var/lib/dpkg/", strlen("/var/lib/dpkg/")) != 0)
- return func_execvp(file, argv);
- printf("REWRITE execvp call %s into %s\n", file, chrootdir);
- char newfile[strlen(chrootdir) + strlen(file)];
- strcpy(newfile, chrootdir);
- strcat(newfile, file);
- return func_execvp(newfile, argv);
-}
-EOF
- testsuccess --nomsg gcc -fPIC -shared -o noopchroot.so noopchroot.c -ldl
-
- mkdir -p "${TMPWORKINGDIRECTORY}/rootdir/usr/bin/"
- DPKG="${TMPWORKINGDIRECTORY}/rootdir/usr/bin/dpkg"
- echo "#!/bin/sh
-if [ -n \"\$LD_PRELOAD\" ]; then
- export LD_PRELOAD=\"${TMPWORKINGDIRECTORY}/noopchroot.so \${LD_PRELOAD}\"
-else
- export LD_PRELOAD=\"${TMPWORKINGDIRECTORY}/noopchroot.so\"
-fi
-dpkg \"\$@\"" > $DPKG
- chmod +x $DPKG
- sed -ie "s|^DPKG::options:: \"dpkg\";\$|DPKG::options:: \"$DPKG\";|" aptconfig.conf
-}
-
-configallowinsecurerepositories() {
- echo "Acquire::AllowInsecureRepositories \"$1\";" > rootdir/etc/apt/apt.conf.d/allow-insecure-repositories.conf
-
-}
-
-configcompression() {
- while [ -n "$1" ]; do
- case "$1" in
- '.') printf ".\t.\tcat\n";;
- 'gz') printf "gzip\tgz\tgzip\n";;
- 'bz2') printf "bzip2\tbz2\tbzip2\n";;
- 'lzma') printf "lzma\tlzma\txz --format=lzma\n";;
- 'xz') printf "xz\txz\txz\n";;
- *) printf "$1\t$1\t$1\n";;
- esac
- shift
- done > ${TMPWORKINGDIRECTORY}/rootdir/etc/testcase-compressor.conf
-}
-
-forcecompressor() {
- COMPRESSOR="$1"
- COMPRESSOR_CMD="$1"
- case $COMPRESSOR in
- gzip) COMPRESS='gz';;
- bzip2) COMPRESS='bz2';;
- lzma) COMPRESS='lzma';;
- xz) COMPRESS='xz';;
- *) msgdie "Compressor $COMPRESSOR is unknown to framework, so can't be forced by forcecompressor!";;
- esac
- local CONFFILE="${TMPWORKINGDIRECTORY}/rootdir/etc/apt/apt.conf.d/00force-compressor"
- echo "Acquire::CompressionTypes::Order { \"${COMPRESS}\"; };
-Dir::Bin::uncompressed \"/does/not/exist\";
-Dir::Bin::gzip \"/does/not/exist\";
-Dir::Bin::bzip2 \"/does/not/exist\";
-Dir::Bin::lzma \"/does/not/exist\";
-Dir::Bin::xz \"/does/not/exist\";" > "$CONFFILE"
- if [ -e "/bin/${COMPRESSOR}" ]; then
- echo "Dir::Bin::${COMPRESSOR} \"/bin/${COMPRESSOR}\";" >> "$CONFFILE"
- elif [ -e "/usr/bin/${COMPRESSOR}" ]; then
- echo "Dir::Bin::${COMPRESSOR} \"/usr/bin/${COMPRESSOR}\";" >> "$CONFFILE"
- elif [ "${COMPRESSOR}" = 'lzma' ]; then
- echo 'Dir::Bin::xz "/usr/bin/xz";' >> "$CONFFILE"
- COMPRESSOR_CMD='xz --format=lzma'
- else
- msgtest 'Test for availability of compressor' "${COMPRESSOR}"
- msgfail
- fi
-}
-
-setupsimplenativepackage() {
+buildpackage() {
local NAME="$1"
- local ARCH="$2"
- local VERSION="$3"
- local RELEASE="${4:-unstable}"
- local DEPENDENCIES="$5"
- local DESCRIPTION="${6:-"an autogenerated dummy ${NAME}=${VERSION}/${RELEASE}
- If you find such a package installed on your system,
- something went horribly wrong! They are autogenerated
- und used only by testcases and surf no other propose…"}"
-
- local SECTION="${7:-others}"
- local DISTSECTION
- if [ "$SECTION" = "$(echo "$SECTION" | cut -d'/' -f 2)" ]; then
- DISTSECTION="main"
- else
- DISTSECTION="$(echo "$SECTION" | cut -d'/' -f 1)"
- fi
- local BUILDDIR=incoming/${NAME}-${VERSION}
- mkdir -p ${BUILDDIR}/debian/source
- cd ${BUILDDIR}
- echo "* most suckless software product ever" > FEATURES
- test -e debian/copyright || echo "Copyleft by Joe Sixpack $(date +%Y)" > debian/copyright
- test -e debian/changelog || echo "$NAME ($VERSION) $RELEASE; urgency=low
-
- * Initial release
-
- -- Joe Sixpack <joe@example.org> $(date -R)" > debian/changelog
- test -e debian/control || echo "Source: $NAME
-Section: $SECTION
-Priority: optional
-Maintainer: Joe Sixpack <joe@example.org>
-Build-Depends: debhelper (>= 7)
-Standards-Version: 3.9.1
-
-Package: $NAME" > debian/control
- if [ "$ARCH" = 'all' ]; then
- echo "Architecture: all" >> debian/control
- else
- echo "Architecture: any" >> debian/control
- fi
- test -z "$DEPENDENCIES" || echo "$DEPENDENCIES" >> debian/control
- echo "Description: $DESCRIPTION" >> debian/control
- test -e debian/compat || echo "7" > debian/compat
- test -e debian/source/format || echo "3.0 (native)" > debian/source/format
- test -e debian/rules || cp /usr/share/doc/debhelper/examples/rules.tiny debian/rules
- cd - > /dev/null
+ msgmsg "Building package: ${NAME}"
+ HOME="$TMPWORKINGDIRECTORY" rpmbuild --target="$(getarchitecture)" --define="_usr $TMPWORKINGDIRECTORY/usr" --root="$TMPWORKINGDIRECTORY" -ba "${TESTDIRECTORY}/specs/${NAME}.spec" 1>/dev/null
}
-buildsimplenativepackage() {
+installpackage() {
local NAME="$1"
- local ARCH="$2"
- local VERSION="$3"
- local RELEASE="${4:-unstable}"
- local DEPENDENCIES="$5"
- local DESCRIPTION="${6:-"an autogenerated dummy ${NAME}=${VERSION}/${RELEASE}
- If you find such a package installed on your system,
- something went horribly wrong! They are autogenerated
- und used only by testcases and surf no other propose…"}"
-
- local SECTION="${7:-others}"
- local PRIORITY="${8:-optional}"
- local FILE_TREE="$9"
- local COMPRESS_TYPE="${10:-gzip}"
- local DISTSECTION
- if [ "$SECTION" = "$(echo "$SECTION" | cut -d'/' -f 2)" ]; then
- DISTSECTION="main"
- else
- DISTSECTION="$(echo "$SECTION" | cut -d'/' -f 1)"
- fi
- local BUILDDIR=${TMPWORKINGDIRECTORY}/incoming/${NAME}-${VERSION}
-
- msgtest "Build source package in version ${VERSION} for ${RELEASE} in ${DISTSECTION}" "$NAME"
- mkdir -p $BUILDDIR/debian/source
- echo "* most suckless software product ever" > ${BUILDDIR}/FEATURES
- echo "#!/bin/sh
-echo '$NAME says \"Hello!\"'" > ${BUILDDIR}/${NAME}
-
- echo "Copyleft by Joe Sixpack $(date +%Y)" > ${BUILDDIR}/debian/copyright
- echo "$NAME ($VERSION) $RELEASE; urgency=low
-
- * Initial release
-
- -- Joe Sixpack <joe@example.org> $(date -R)" > ${BUILDDIR}/debian/changelog
- echo "Source: $NAME
-Priority: $PRIORITY
-Maintainer: Joe Sixpack <joe@example.org>
-Standards-Version: 3.9.3" > ${BUILDDIR}/debian/control
- if [ "$SECTION" != '<none>' ]; then
- echo "Section: $SECTION" >> ${BUILDDIR}/debian/control
- fi
- local BUILDDEPS="$(echo "$DEPENDENCIES" | grep '^Build-')"
- test -z "$BUILDDEPS" || echo "$BUILDDEPS" >> ${BUILDDIR}/debian/control
- echo "
-Package: $NAME" >> ${BUILDDIR}/debian/control
+ local VERSION="$2"
+ local RELEASE="$3"
+ local ARCH="$4"
- if [ "$ARCH" = 'all' ]; then
- echo "Architecture: all" >> ${BUILDDIR}/debian/control
- else
- echo "Architecture: any" >> ${BUILDDIR}/debian/control
- fi
- local DEPS="$(echo "$DEPENDENCIES" | grep -v '^Build-')"
- test -z "$DEPS" || echo "$DEPS" >> ${BUILDDIR}/debian/control
- echo "Description: $DESCRIPTION" >> ${BUILDDIR}/debian/control
-
- echo '3.0 (native)' > ${BUILDDIR}/debian/source/format
- cd ${BUILDDIR}/..
- testsuccess --nomsg dpkg-source -b ${NAME}-${VERSION}
- cd - >/dev/null
- sed -n 's#^dpkg-source: info: building [^ ]\+ in ##p' ${TMPWORKINGDIRECTORY}/rootdir/tmp/testsuccess.output \
- | while read SRC; do
- echo "pool/${SRC}" >> ${BUILDDIR}/../${RELEASE}.${DISTSECTION}.srclist
-# if expr match "${SRC}" '.*\.dsc' >/dev/null 2>&1; then
-# gpg --yes --secret-keyring ./keys/joesixpack.sec \
-# --keyring ./keys/joesixpack.pub --default-key 'Joe Sixpack' \
-# --clearsign -o "${BUILDDIR}/../${SRC}.sign" "${BUILDDIR}/../$SRC"
-# mv "${BUILDDIR}/../${SRC}.sign" "${BUILDDIR}/../$SRC"
-# fi
- done
-
- for arch in $(getarchitecturesfromcommalist "$ARCH"); do
- msgtest "Build binary package for ${RELEASE} in ${SECTION}" "$NAME"
- rm -rf ${BUILDDIR}/debian/tmp
- mkdir -p ${BUILDDIR}/debian/tmp/DEBIAN ${BUILDDIR}/debian/tmp/usr/share/doc/${NAME} ${BUILDDIR}/debian/tmp/usr/bin
- cp ${BUILDDIR}/debian/copyright ${BUILDDIR}/debian/changelog ${BUILDDIR}/FEATURES ${BUILDDIR}/debian/tmp/usr/share/doc/${NAME}
- cp ${BUILDDIR}/${NAME} ${BUILDDIR}/debian/tmp/usr/bin/${NAME}-${arch}
- if [ -n "$FILE_TREE" ]; then
- cp -ar "$FILE_TREE" ${BUILDDIR}/debian/tmp
- fi
-
- (cd ${BUILDDIR}; dpkg-gencontrol -DArchitecture=$arch)
- (cd ${BUILDDIR}/debian/tmp; md5sum $(find usr/ -type f) > DEBIAN/md5sums)
- local LOG="${BUILDDIR}/../${NAME}_${VERSION}_${arch}.dpkg-deb.log"
- # ensure the right permissions as dpkg-deb ensists
- chmod 755 ${BUILDDIR}/debian/tmp/DEBIAN
- testsuccess --nomsg dpkg-deb -Z${COMPRESS_TYPE} --build ${BUILDDIR}/debian/tmp ${BUILDDIR}/..
- echo "pool/${NAME}_${VERSION}_${arch}.deb" >> ${BUILDDIR}/../${RELEASE}.${DISTSECTION}.pkglist
- done
-
- mkdir -p ${BUILDDIR}/../${NAME}_${VERSION}
- cp ${BUILDDIR}/debian/changelog ${BUILDDIR}/../${NAME}_${VERSION}/
- cp ${BUILDDIR}/debian/changelog ${BUILDDIR}/../${NAME}_${VERSION}.changelog
- rm -rf "${BUILDDIR}"
- msgdone "info"
-}
-
-buildpackage() {
- local BUILDDIR=$1
- local RELEASE=$2
- local SECTION=$3
- local ARCH=$(getarchitecture $4)
- local PKGNAME="$(echo "$BUILDDIR" | grep -o '[^/]*$')"
- local BUILDLOG="$(readlink -f "${BUILDDIR}/../${PKGNAME}_${RELEASE}_${SECTION}.dpkg-bp.log")"
- msgtest "Build package for ${RELEASE} in ${SECTION}" "$PKGNAME"
- cd $BUILDDIR
- if [ "$ARCH" = "all" ]; then
- ARCH="$(dpkg-architecture -qDEB_HOST_ARCH 2> /dev/null)"
- fi
- testsuccess --nomsg dpkg-buildpackage -uc -us -a$ARCH
- cp ${TMPWORKINGDIRECTORY}/rootdir/tmp/testsuccess.output $BUILDLOG
- local PKGS="$(grep '^dpkg-deb: building package' $BUILDLOG | cut -d'/' -f 2 | sed -e "s#'\.##")"
- local SRCS="$(grep '^dpkg-source: info: building' $BUILDLOG | grep -o '[a-z0-9._+~-]*$')"
- cd - > /dev/null
- for PKG in $PKGS; do
- echo "pool/${PKG}" >> ${TMPWORKINGDIRECTORY}/incoming/${RELEASE}.${SECTION}.pkglist
- done
- for SRC in $SRCS; do
- echo "pool/${SRC}" >> ${TMPWORKINGDIRECTORY}/incoming/${RELEASE}.${SECTION}.srclist
- done
-}
-
-buildaptarchive() {
- if [ -d incoming ]; then
- buildaptarchivefromincoming "$@"
- else
- buildaptarchivefromfiles "$@"
- fi
-}
-
-createaptftparchiveconfig() {
- local COMPRESSORS="$(cut -d' ' -f 1 ${TMPWORKINGDIRECTORY}/rootdir/etc/testcase-compressor.conf | tr '\n' ' ')"
- COMPRESSORS="${COMPRESSORS%* }"
- local ARCHS="$(find pool/ -name '*.deb' | grep -oE '_[a-z0-9-]+\.deb$' | sort | uniq | sed -e '/^_all.deb$/ d' -e 's#^_\([a-z0-9-]*\)\.deb$#\1#' | tr '\n' ' ')"
- if [ -z "$ARCHS" ]; then
- # the pool is empty, so we will operate on faked packages - let us use the configured archs
- ARCHS="$(getarchitectures)"
- fi
- echo -n 'Dir {
- ArchiveDir "' >> ftparchive.conf
- echo -n $(readlink -f .) >> ftparchive.conf
- echo -n '";
- CacheDir "' >> ftparchive.conf
- echo -n $(readlink -f ..) >> ftparchive.conf
- echo -n '";
- FileListDir "' >> ftparchive.conf
- echo -n $(readlink -f pool/) >> ftparchive.conf
- echo -n '";
-};
-Default {
- Packages::Compress "'"$COMPRESSORS"'";
- Sources::Compress "'"$COMPRESSORS"'";
- Contents::Compress "'"$COMPRESSORS"'";
- Translation::Compress "'"$COMPRESSORS"'";
- LongDescription "false";
-};
-TreeDefault {
- Directory "pool/";
- SrcDirectory "pool/";
-};
-APT {
- FTPArchive {
- Release {
- Origin "joesixpack";
- Label "apttestcases";
- Suite "unstable";
- Description "repository with dummy packages";
- Architectures "' >> ftparchive.conf
- echo -n "$ARCHS" >> ftparchive.conf
- echo 'source";
- };
- };
-};' >> ftparchive.conf
- for DIST in $(find ./pool/ -maxdepth 1 -name '*.pkglist' -type f | cut -d'/' -f 3 | cut -d'.' -f 1 | sort | uniq); do
- echo -n 'tree "dists/' >> ftparchive.conf
- echo -n "$DIST" >> ftparchive.conf
- echo -n '" {
- Architectures "' >> ftparchive.conf
- echo -n "$ARCHS" >> ftparchive.conf
- echo -n 'source";
- FileList "' >> ftparchive.conf
- echo -n "${DIST}.\$(SECTION).pkglist" >> ftparchive.conf
- echo -n '";
- SourceFileList "' >> ftparchive.conf
- echo -n "${DIST}.\$(SECTION).srclist" >> ftparchive.conf
- echo -n '";
- Sections "' >> ftparchive.conf
- echo -n "$(find ./pool/ -maxdepth 1 -name "${DIST}.*.pkglist" -type f | cut -d'/' -f 3 | cut -d'.' -f 2 | sort | uniq | tr '\n' ' ')" >> ftparchive.conf
- echo '";
-};' >> ftparchive.conf
- done
-}
-
-buildaptftparchivedirectorystructure() {
- local DISTS="$(grep -i '^tree ' ftparchive.conf | cut -d'/' -f 2 | sed -e 's#".*##')"
- for DIST in $DISTS; do
- local SECTIONS="$(grep -i -A 5 "dists/$DIST" ftparchive.conf | grep -i 'Sections' | cut -d'"' -f 2)"
- for SECTION in $SECTIONS; do
- local ARCHS="$(grep -A 5 "dists/$DIST" ftparchive.conf | grep Architectures | cut -d'"' -f 2 | sed -e 's#source##')"
- for ARCH in $ARCHS; do
- mkdir -p dists/${DIST}/${SECTION}/binary-${ARCH}
- done
- mkdir -p dists/${DIST}/${SECTION}/source
- mkdir -p dists/${DIST}/${SECTION}/i18n
- done
- done
-}
-
-insertpackage() {
- local RELEASE="$1"
- local NAME="$2"
- local ARCH="$3"
- local VERSION="$4"
- local DEPENDENCIES="$5"
- local PRIORITY="${6:-optional}"
- local DESCRIPTION="${7:-"an autogenerated dummy ${NAME}=${VERSION}/${RELEASE}
- If you find such a package installed on your system,
- something went horribly wrong! They are autogenerated
- und used only by testcases and surf no other propose…"}"
- local ARCHS=""
- for arch in $(getarchitecturesfromcommalist "$ARCH"); do
- if [ "$arch" = 'all' -o "$arch" = 'none' ]; then
- ARCHS="$(getarchitectures)"
- else
- ARCHS="$arch"
- fi
- for BUILDARCH in $ARCHS; do
- local PPATH="aptarchive/dists/${RELEASE}/main/binary-${BUILDARCH}"
- mkdir -p $PPATH aptarchive/dists/${RELEASE}/main/source
- touch aptarchive/dists/${RELEASE}/main/source/Sources
- local FILE="${PPATH}/Packages"
- echo "Package: $NAME
-Priority: $PRIORITY
-Section: other
-Installed-Size: 42
-Maintainer: Joe Sixpack <joe@example.org>" >> $FILE
- test "$arch" = 'none' || echo "Architecture: $arch" >> $FILE
- echo "Version: $VERSION
-Filename: pool/main/${NAME}/${NAME}_${VERSION}_${arch}.deb" >> $FILE
- test -z "$DEPENDENCIES" || echo "$DEPENDENCIES" >> $FILE
- echo "Description: $DESCRIPTION" >> $FILE
- echo >> $FILE
- done
- done
-}
-
-insertsource() {
- local RELEASE="$1"
- local NAME="$2"
- local ARCH="$3"
- local VERSION="$4"
- local DEPENDENCIES="$5"
- local ARCHS=""
- local SPATH="aptarchive/dists/${RELEASE}/main/source"
- mkdir -p $SPATH
- local FILE="${SPATH}/Sources"
- echo "Package: $NAME
-Binary: $NAME
-Version: $VERSION
-Maintainer: Joe Sixpack <joe@example.org>
-Architecture: $ARCH" >> $FILE
- test -z "$DEPENDENCIES" || echo "$DEPENDENCIES" >> $FILE
- echo "Files:
- d41d8cd98f00b204e9800998ecf8427e 0 ${NAME}_${VERSION}.dsc
- d41d8cd98f00b204e9800998ecf8427e 0 ${NAME}_${VERSION}.tar.gz
-" >> $FILE
+ msgmsg "Installing package via rpm: ${NAME}-${VERSION}-${RELEASE}.${ARCH}.rpm"
+ rpm --dbpath="$TMPWORKINGDIRECTORY/var/lib/rpm" --nodeps -i "$TMPWORKINGDIRECTORY/usr/src/RPM/RPMS/${ARCH}/${NAME}-${VERSION}-${RELEASE}.${ARCH}.rpm" 1>/dev/null
}
-insertinstalledpackage() {
+aptgetinstallpackage() {
local NAME="$1"
- local ARCH="$2"
- local VERSION="$3"
- local DEPENDENCIES="$4"
- local PRIORITY="${5:-optional}"
- local STATUS="${6:-install ok installed}"
- local DESCRIPTION="${7:-"an autogenerated dummy ${NAME}=${VERSION}/installed
- If you find such a package installed on your system,
- something went horribly wrong! They are autogenerated
- und used only by testcases and surf no other propose…"}"
-
- local FILE='rootdir/var/lib/dpkg/status'
- local INFO='rootdir/var/lib/dpkg/info'
- for arch in $(getarchitecturesfromcommalist "$ARCH"); do
- echo "Package: $NAME
-Status: $STATUS
-Priority: $PRIORITY
-Section: other
-Installed-Size: 42
-Maintainer: Joe Sixpack <joe@example.org>
-Version: $VERSION" >> $FILE
- test "$arch" = 'none' || echo "Architecture: $arch" >> $FILE
- test -z "$DEPENDENCIES" || echo "$DEPENDENCIES" >> $FILE
- echo "Description: $DESCRIPTION" >> $FILE
- echo >> $FILE
- if [ "$(dpkg-query -W --showformat='${Multi-Arch}')" = 'same' ]; then
- echo -n > ${INFO}/${NAME}:${arch}.list
- else
- echo -n > ${INFO}/${NAME}.list
- fi
- done
-}
-
-
-buildaptarchivefromincoming() {
- msginfo "Build APT archive for ${CCMD}$(basename $0)${CINFO} based on incoming packages…"
- cd aptarchive
- [ -e pool ] || ln -s ../incoming pool
- [ -e ftparchive.conf ] || createaptftparchiveconfig
- [ -e dists ] || buildaptftparchivedirectorystructure
- msgninfo "\tGenerate Packages, Sources and Contents files… "
- testsuccess aptftparchive generate ftparchive.conf
- cd - > /dev/null
- msgdone "info"
- generatereleasefiles
-}
-
-buildaptarchivefromfiles() {
- msginfo "Build APT archive for ${CCMD}$(basename $0)${CINFO} based on prebuild files…"
- find aptarchive -name 'Packages' -o -name 'Sources' | while read line; do
- msgninfo "\t${line} file… "
- compressfile "$line" "$1"
- msgdone "info"
- done
- generatereleasefiles "$@"
-}
-
-compressfile() {
- cat ${TMPWORKINGDIRECTORY}/rootdir/etc/testcase-compressor.conf | while read compressor extension command; do
- if [ "$compressor" = '.' ]; then
- if [ -n "$2" ]; then
- touch -d "$2" "$1"
- fi
- continue
- fi
- cat "$1" | $command > "${1}.${extension}"
- if [ -n "$2" ]; then
- touch -d "$2" "${1}.${extension}"
- fi
- done
-}
-
-# can be overridden by testcases for their pleasure
-getcodenamefromsuite() {
- case "$1" in
- unstable) echo 'sid';;
- *) echo -n "$1";;
- esac
-}
-getreleaseversionfromsuite() { true; }
-getlabelfromsuite() { true; }
-
-generatereleasefiles() {
- # $1 is the Date header and $2 is the ValidUntil header to be set
- # both should be given in notation date/touch can understand
- msgninfo "\tGenerate Release files… "
- if [ -e aptarchive/dists ]; then
- for dir in $(find ./aptarchive/dists -mindepth 1 -maxdepth 1 -type d); do
- local SUITE="$(echo "$dir" | cut -d'/' -f 4)"
- local CODENAME="$(getcodenamefromsuite $SUITE)"
- local VERSION="$(getreleaseversionfromsuite $SUITE)"
- local LABEL="$(getlabelfromsuite $SUITE)"
- if [ -n "$VERSION" ]; then
- VERSION="-o APT::FTPArchive::Release::Version=${VERSION}"
- fi
- if [ -n "$LABEL" ]; then
- LABEL="-o APT::FTPArchive::Release::Label=${LABEL}"
- fi
- aptftparchive -qq release $dir \
- -o APT::FTPArchive::Release::Suite="${SUITE}" \
- -o APT::FTPArchive::Release::Codename="${CODENAME}" \
- ${LABEL} \
- ${VERSION} \
- | sed -e '/0 Release$/ d' > $dir/Release # remove the self reference
- if [ "$SUITE" = "experimental" -o "$SUITE" = "experimental2" ]; then
- sed -i '/^Date: / a\
-NotAutomatic: yes' $dir/Release
- fi
- if [ -n "$1" -a "$1" != "now" ]; then
- sed -i "s/^Date: .*$/Date: $(date -d "$1" '+%a, %d %b %Y %H:%M:%S %Z')/" $dir/Release
- fi
- if [ -n "$2" ]; then
- sed -i "/^Date: / a\
-Valid-Until: $(date -d "$2" '+%a, %d %b %Y %H:%M:%S %Z')" $dir/Release
- fi
- done
- else
- aptftparchive -qq release ./aptarchive | sed -e '/0 Release$/ d' > aptarchive/Release # remove the self reference
- fi
- if [ -n "$1" -a "$1" != "now" ]; then
- for release in $(find ./aptarchive -name 'Release'); do
- touch -d "$1" $release
- done
- fi
- msgdone "info"
-}
+ local VERSION="$2"
+ local RELEASE="$3"
+ local ARCH="$4"
-setupdistsaptarchive() {
- local APTARCHIVE=$(readlink -f ./aptarchive)
- rm -f root/etc/apt/sources.list.d/apt-test-*-deb.list
- rm -f root/etc/apt/sources.list.d/apt-test-*-deb-src.list
- for DISTS in $(find ./aptarchive/dists/ -mindepth 1 -maxdepth 1 -type d | cut -d'/' -f 4); do
- SECTIONS=$(find ./aptarchive/dists/${DISTS}/ -mindepth 1 -maxdepth 1 -type d | cut -d'/' -f 5 | tr '\n' ' ')
- msgninfo "\tadd deb and deb-src sources.list lines for ${CCMD}${DISTS} ${SECTIONS}${CINFO}… "
- echo "deb file://$APTARCHIVE $DISTS $SECTIONS" > rootdir/etc/apt/sources.list.d/apt-test-${DISTS}-deb.list
- echo "deb-src file://$APTARCHIVE $DISTS $SECTIONS" > rootdir/etc/apt/sources.list.d/apt-test-${DISTS}-deb-src.list
- msgdone "info"
- done
-}
-
-setupflataptarchive() {
- local APTARCHIVE=$(readlink -f ./aptarchive)
- if [ -f ${APTARCHIVE}/Packages ]; then
- msgninfo "\tadd deb sources.list line… "
- echo "deb file://$APTARCHIVE /" > rootdir/etc/apt/sources.list.d/apt-test-archive-deb.list
- msgdone "info"
- else
- rm -f rootdir/etc/apt/sources.list.d/apt-test-archive-deb.list
- fi
- if [ -f ${APTARCHIVE}/Sources ]; then
- msgninfo "\tadd deb-src sources.list line… "
- echo "deb-src file://$APTARCHIVE /" > rootdir/etc/apt/sources.list.d/apt-test-archive-deb-src.list
- msgdone "info"
- else
- rm -f rootdir/etc/apt/sources.list.d/apt-test-archive-deb-src.list
- fi
-}
-
-setupaptarchive() {
- buildaptarchive
- if [ -e aptarchive/dists ]; then
- setupdistsaptarchive
- else
- setupflataptarchive
- fi
- signreleasefiles
- if [ "$1" != '--no-update' ]; then
- msgninfo "\tSync APT's cache with the archive… "
- aptget update -qq
- msgdone "info"
- fi
-}
-
-signreleasefiles() {
- local SIGNER="${1:-Joe Sixpack}"
- local GPG="gpg --batch --yes"
- msgninfo "\tSign archive with $SIGNER key… "
- local REXKEY='keys/rexexpired'
- local SECEXPIREBAK="${REXKEY}.sec.bak"
- local PUBEXPIREBAK="${REXKEY}.pub.bak"
- if [ "${SIGNER}" = 'Rex Expired' ]; then
- # the key is expired, so gpg doesn't allow to sign with and the --faked-system-time
- # option doesn't exist anymore (and using faketime would add a new obscure dependency)
- # therefore we 'temporary' make the key not expired and restore a backup after signing
- cp ${REXKEY}.sec $SECEXPIREBAK
- cp ${REXKEY}.pub $PUBEXPIREBAK
- local SECUNEXPIRED="${REXKEY}.sec.unexpired"
- local PUBUNEXPIRED="${REXKEY}.pub.unexpired"
- if [ -f "$SECUNEXPIRED" ] && [ -f "$PUBUNEXPIRED" ]; then
- cp $SECUNEXPIRED ${REXKEY}.sec
- cp $PUBUNEXPIRED ${REXKEY}.pub
- else
- printf "expire\n1w\nsave\n" | $GPG --keyring ${REXKEY}.pub --secret-keyring ${REXKEY}.sec --command-fd 0 --edit-key "${SIGNER}" >/dev/null 2>&1 || true
- cp ${REXKEY}.sec $SECUNEXPIRED
- cp ${REXKEY}.pub $PUBUNEXPIRED
- fi
- fi
- for KEY in $(find keys/ -name '*.sec'); do
- GPG="$GPG --secret-keyring $KEY"
- done
- for KEY in $(find keys/ -name '*.pub'); do
- GPG="$GPG --keyring $KEY"
- done
- for RELEASE in $(find aptarchive/ -name Release); do
- $GPG --default-key "$SIGNER" --armor --detach-sign --sign --output ${RELEASE}.gpg ${RELEASE}
- local INRELEASE="$(echo "${RELEASE}" | sed 's#/Release$#/InRelease#')"
- $GPG --default-key "$SIGNER" --clearsign --output $INRELEASE $RELEASE
- # we might have set a specific date for the Release file, so copy it
- touch -d "$(stat --format "%y" ${RELEASE})" ${RELEASE}.gpg ${INRELEASE}
- done
- if [ -f "$SECEXPIREBAK" ] && [ -f "$PUBEXPIREBAK" ]; then
- mv -f $SECEXPIREBAK ${REXKEY}.sec
- mv -f $PUBEXPIREBAK ${REXKEY}.pub
- fi
- msgdone "info"
-}
-
-webserverconfig() {
- msgtest "Set webserver config option '${1}' to" "$2"
- local DOWNLOG='rootdir/tmp/download-testfile.log'
- local STATUS='rootdir/tmp/webserverconfig.status'
- rm -f "$STATUS" "$DOWNLOG"
- if downloadfile "http://localhost:8080/_config/set/${1}/${2}" "$STATUS" > "$DOWNLOG"; then
- msgpass
- else
- cat "$DOWNLOG" "$STATUS"
- msgfail
- fi
- testwebserverlaststatuscode '200'
-}
-
-rewritesourceslist() {
- local APTARCHIVE="file://$(readlink -f "${TMPWORKINGDIRECTORY}/aptarchive")"
- for LIST in $(find rootdir/etc/apt/sources.list.d/ -name 'apt-test-*.list'); do
- sed -i $LIST -e "s#$APTARCHIVE#${1}#" -e "s#http://localhost:8080/#${1}#" -e "s#http://localhost:4433/#${1}#"
- done
-}
-
-# wait for up to 10s for a pid file to appear to avoid possible race
-# when a helper is started and dosn't write the PID quick enough
-waitforpidfile() {
- local PIDFILE="$1"
- for i in $(seq 10); do
- if test -s "$PIDFILE"; then
- return 0
- fi
- sleep 1
- done
- msgdie "waiting for $PIDFILE failed"
- return 1
-}
-
-changetowebserver() {
- if [ "$1" != '--no-rewrite' ]; then
- rewritesourceslist 'http://localhost:8080/'
- else
- shift
- fi
- if test -x ${APTWEBSERVERBINDIR}/aptwebserver; then
- cd aptarchive
- local LOG="webserver.log"
- if ! aptwebserver -o aptwebserver::fork=1 "$@" >$LOG 2>&1 ; then
- cat $LOG
- false
- fi
- waitforpidfile aptwebserver.pid
- local PID="$(cat aptwebserver.pid)"
- if [ -z "$PID" ]; then
- msgdie 'Could not fork aptwebserver successfully'
- fi
- addtrap "kill $PID;"
- cd - > /dev/null
- else
- msgdie 'You have to build aptwerbserver or install a webserver'
- fi
-}
-
-changetohttpswebserver() {
- if ! which stunnel4 >/dev/null; then
- msgdie 'You need to install stunnel4 for https testcases'
- fi
- if [ ! -e "${TMPWORKINGDIRECTORY}/aptarchive/aptwebserver.pid" ]; then
- changetowebserver --no-rewrite "$@"
- fi
- echo "pid = ${TMPWORKINGDIRECTORY}/aptarchive/stunnel.pid
-cert = ${TESTDIRECTORY}/apt.pem
-output = /dev/null
-
-[https]
-accept = 4433
-connect = 8080
-" > ${TMPWORKINGDIRECTORY}/stunnel.conf
- stunnel4 "${TMPWORKINGDIRECTORY}/stunnel.conf"
- waitforpidfile "${TMPWORKINGDIRECTORY}/aptarchive/stunnel.pid"
- local PID="$(cat ${TMPWORKINGDIRECTORY}/aptarchive/stunnel.pid)"
- if [ -z "$PID" ]; then
- msgdie 'Could not fork stunnel4 successfully'
- fi
- addtrap 'prefix' "kill ${PID};"
- rewritesourceslist 'https://localhost:4433/'
-}
-
-changetocdrom() {
- mkdir -p rootdir/media/cdrom/.disk
- local CD="$(readlink -f rootdir/media/cdrom)"
- echo "acquire::cdrom::mount \"${CD}\";
-acquire::cdrom::${CD}/::mount \"mv ${CD}-unmounted ${CD}\";
-acquire::cdrom::${CD}/::umount \"mv ${CD} ${CD}-unmounted\";
-acquire::cdrom::autodetect 0;" > rootdir/etc/apt/apt.conf.d/00cdrom
- echo -n "$1" > ${CD}/.disk/info
- if [ ! -d aptarchive/dists ]; then
- msgdie 'Flat file archive cdroms can not be created currently'
- return 1
- fi
- mv aptarchive/dists "$CD"
- ln -s "$(readlink -f ./incoming)" $CD/pool
- find rootdir/etc/apt/sources.list.d/ -name 'apt-test-*.list' -delete
- # start with an unmounted disk
- mv "${CD}" "${CD}-unmounted"
- # we don't want the disk to be modifiable
- addtrap 'prefix' "chmod -f -R +w $PWD/rootdir/media/cdrom/dists/ $PWD/rootdir/media/cdrom-unmounted/dists/ || true;"
- chmod -R -w rootdir/media/cdrom-unmounted/dists
-}
-
-downloadfile() {
- local PROTO="${1%%:*}"
- apthelper -o Debug::Acquire::${PROTO}=1 -o Debug::pkgAcquire::Worker=1 \
- download-file "$1" "$2" 2>&1 || true
- # only if the file exists the download was successful
- if [ -e "$2" ]; then
- return 0
- else
- return 1
- fi
+ msgmsg "Installing package via apt-get: ${NAME}-${VERSION}-${RELEASE}.${ARCH}.rpm"
+ aptget install "$TMPWORKINGDIRECTORY/usr/src/RPM/RPMS/${ARCH}/${NAME}-${VERSION}-${RELEASE}.${ARCH}.rpm" 1>/dev/null
}
checkdiff() {
@@ -1127,6 +290,43 @@ testequal() {
"$@" 2>&1 | checkdiff $COMPAREFILE - && msgpass || msgfail
}
+testregexmatch() {
+ local MSG='Test of regex match of'
+ if [ "$1" = '--nomsg' ]; then
+ MSG=''
+ shift
+ fi
+
+ local COMPAREMSG="$1"
+ shift
+
+ if [ -n "$MSG" ]; then
+ msgtest "$MSG" "$*"
+ fi
+
+ local COMPAREFILE="${TMPWORKINGDIRECTORY}/rootdir/tmp/testregexmatch.comparefile"
+ local RESULTFILE="${TMPWORKINGDIRECTORY}/rootdir/tmp/testregexmatch.resultfile"
+
+ echo "^$COMPAREMSG\$" > $COMPAREFILE
+ set +e
+ "$@" &> $RESULTFILE
+ set -e
+
+ if [[ "$(cat $RESULTFILE)" =~ $(cat $COMPAREFILE) ]] ; then
+ msgpass
+ else
+ checkdiff $COMPAREFILE $RESULTFILE
+ msgfail
+ fi
+}
+
+skiplines() {
+ local count="$1"
+ shift
+
+ "$@" 2>&1 | tail +"$count"
+}
+
testequalor2() {
local COMPAREFILE1="${TMPWORKINGDIRECTORY}/rootdir/tmp/testequalor2.comparefile1"
local COMPAREFILE2="${TMPWORKINGDIRECTORY}/rootdir/tmp/testequalor2.comparefile2"
@@ -1180,39 +380,48 @@ testnopackage() {
fi
}
-testdpkgstatus() {
- local STATE="$1"
- local NR="$2"
- shift 2
- msgtest "Test that $NR package(s) are in state $STATE with" "dpkg -l $*"
- local PKGS="$(dpkg -l "$@" 2>/dev/null | grep "^${STATE}" | wc -l)"
- if [ "$PKGS" != $NR ]; then
- echo >&2 $PKGS
- dpkg -l "$@" | grep '^[a-z]' >&2
- msgfail
- else
+testpkginstalled() {
+ msgtest "Test that package(s) are installed with" "rpm -q $*"
+
+ local result=0
+
+ set +e
+ rpm --dbpath="$TMPWORKINGDIRECTORY/var/lib/rpm" -q "$@" &>/dev/null
+ result=$?
+ set -e
+
+ if [ $result -eq 0 ] ; then
msgpass
+ else
+ msgfail
fi
}
-testdpkginstalled() {
- testdpkgstatus 'ii' "$#" "$@"
-}
+getpackageversion() {
+ local result=
+
+ set +e
+ result=$(rpm --dbpath="$TMPWORKINGDIRECTORY/var/lib/rpm" -q --qf '%{EVR}\n' "$@" 2>/dev/null)
+ set -e
-testdpkgnotinstalled() {
- testdpkgstatus 'ii' '0' "$@"
+ echo $result
}
-testmarkedauto() {
- local COMPAREFILE="${TMPWORKINGDIRECTORY}/rootdir/tmp/testmarkedauto.comparefile"
- if [ -n "$1" ]; then
- msgtest 'Test for correctly marked as auto-installed' "$*"
- while [ -n "$1" ]; do echo "$1"; shift; done | sort > $COMPAREFILE
+testpkgnotinstalled() {
+ msgtest "Test that package(s) are not installed with" "rpm -q $*"
+
+ local result=0
+
+ set +e
+ rpm --dbpath="$TMPWORKINGDIRECTORY/var/lib/rpm" -q "$@" &>/dev/null
+ result=$?
+ set -e
+
+ if [ $result -ne 0 ] ; then
+ msgpass
else
- msgtest 'Test for correctly marked as auto-installed' 'no package'
- echo -n > $COMPAREFILE
+ msgfail
fi
- aptmark showauto 2>&1 | checkdiff $COMPAREFILE - && msgpass || msgfail
}
testsuccess() {
@@ -1247,29 +456,47 @@ testfailure() {
fi
}
-testwebserverlaststatuscode() {
- local DOWNLOG='rootdir/tmp/webserverstatus-testfile.log'
- local STATUS='rootdir/tmp/webserverstatus-statusfile.log'
- rm -f "$DOWNLOG" "$STATUS"
- msgtest 'Test last status code from the webserver was' "$1"
- downloadfile "http://localhost:8080/_config/find/aptwebserver::last-status-code" "$STATUS" > "$DOWNLOG"
- if [ "$(cat "$STATUS")" = "$1" ]; then
- msgpass
- else
- echo >&2
- if [ -n "$2" ]; then
- shift
- echo >&2 '#### Additionally provided output files contain:'
- cat >&2 "$@"
- fi
- echo >&2 '#### Download log of the status code:'
- cat >&2 "$DOWNLOG"
- msgfail "Status was $(cat "$STATUS")"
+generaterepository() {
+ local ORIG_DIR="$1"
+ local REPO_DIR="$2"
+ local REPO_DATE="$3"
+
+ local label="${GB_REPO_LABEL:-apt-tests}"
+ local description="${GB_REPO_DESCRIPTION:-ALT Linux $label}"
+ local date_s="$(date +%s)"
+ local arch="$(getarchitecture)"
+ local comps="${label}"
+
+ if [ -n "$REPO_DATE" ] ; then
+ date_s="$REPO_DATE"
fi
-}
-pause() {
- echo "STOPPED execution. Press enter to continue"
- local IGNORE
- read IGNORE
+ for dir in ${arch} noarch ; do
+ mkdir -p "${REPO_DIR}/${dir}/RPMS.${label}"
+ mkdir -p "${REPO_DIR}/${dir}/base"
+ stat "${ORIG_DIR}/${dir}/"*.rpm &>/dev/null && cp "${ORIG_DIR}/${dir}/"*.rpm "${REPO_DIR}/${dir}/RPMS.${label}"/
+ done
+
+ mkdir -p "${TMPWORKINGDIRECTORY}/cache"
+
+ for dir in ${arch} noarch ; do
+ genbasedir \
+ --cachedir="${TMPWORKINGDIRECTORY}/cache" \
+ --architecture="$dir" \
+ --architectures="$dir" \
+ --archive="${GB_REPO_ARCHIVE:-$description}" \
+ --codename="${GB_REPO_CODENAME:-$date_s}" \
+ --description="${GB_REPO_DESCRIPTION:-$description}" \
+ --label="$label" \
+ --origin="${GB_REPO_ORIGIN:-ALT Linux Team}" \
+ --suite="${GB_REPO_SUITE:-$label}" \
+ --version="${GB_REPO_VERSION:-$date_s}" \
+ --topdir="$REPO_DIR" \
+ --flat --no-oldhashfile --no-bz2 --no-xz --mapi \
+ $dir $comps
+
+ if [ -n "$REPO_DATE" ] ; then
+ touch -t $(date --date=@${REPO_DATE} '+%Y%m%d%H%M.%S') "${REPO_DIR}/${dir}/base/"*
+ fi
+ done
}
diff --git a/apt/test/integration/run-tests b/apt/test/integration/run-tests
index c39a2ac..8d51ebd 100755
--- a/apt/test/integration/run-tests
+++ b/apt/test/integration/run-tests
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
set -e
FAIL=0
@@ -36,14 +36,14 @@ else
CRESET=''
fi
-TOTAL="$(run-parts --list $DIR | grep '/test-' | wc -l)"
-for testcase in $(run-parts --list $DIR | grep '/test-'); do
+TOTAL="$(ls $DIR | egrep '^test-' | wc -l)"
+for testcase in $(ls $DIR | egrep '^test-'); do
if [ "$MSGLEVEL" -le 2 ]; then
printf "($(($ALL+1))/${TOTAL}) ${CTEST}Testcase ${CHIGH}$(basename ${testcase})${CRESET}: "
else
printf "${CTEST}Run Testcase ($(($ALL+1))/${TOTAL}) ${CHIGH}$(basename ${testcase})${CRESET}\n"
fi
- if ! ${testcase}; then
+ if ! ./${testcase}; then
FAIL=$((FAIL+1))
FAILED_TESTS="$FAILED_TESTS $(basename $testcase)"
echo >&2 "$(basename $testcase) ... FAIL"
diff --git a/apt/test/integration/specs/conflicting-package-distupgrade.spec b/apt/test/integration/specs/conflicting-package-distupgrade.spec
new file mode 100644
index 0000000..7f59ae6
--- /dev/null
+++ b/apt/test/integration/specs/conflicting-package-distupgrade.spec
@@ -0,0 +1,18 @@
+Name: conflicting-package-one
+Version: 2
+Release: alt1
+Summary: Test package
+License: LGPLv2+
+Group: Other
+
+Conflicts: conflicting-package-two
+Conflicts: simple-package
+
+%description
+Dummy description
+
+%files
+
+%changelog
+* Mon Sep 30 2019 Nobody <nobody@altlinux.org> 2-alt1
+- Test package created
diff --git a/apt/test/integration/specs/conflicting-package-one.spec b/apt/test/integration/specs/conflicting-package-one.spec
new file mode 100644
index 0000000..b0ae93f
--- /dev/null
+++ b/apt/test/integration/specs/conflicting-package-one.spec
@@ -0,0 +1,17 @@
+Name: conflicting-package-one
+Version: 1
+Release: alt1
+Summary: Test package
+License: LGPLv2+
+Group: Other
+
+Conflicts: conflicting-package-two
+
+%description
+Dummy description
+
+%files
+
+%changelog
+* Mon Sep 30 2019 Nobody <nobody@altlinux.org> 1-alt1
+- Test package created
diff --git a/apt/test/integration/specs/conflicting-package-two.spec b/apt/test/integration/specs/conflicting-package-two.spec
new file mode 100644
index 0000000..363bc77
--- /dev/null
+++ b/apt/test/integration/specs/conflicting-package-two.spec
@@ -0,0 +1,17 @@
+Name: conflicting-package-two
+Version: 1
+Release: alt1
+Summary: Test package
+License: LGPLv2+
+Group: Other
+
+Conflicts: conflicting-package-one
+
+%description
+Dummy description
+
+%files
+
+%changelog
+* Mon Sep 30 2019 Nobody <nobody@altlinux.org> 1-alt1
+- Test package created
diff --git a/apt/test/integration/specs/missing-dependency.spec b/apt/test/integration/specs/missing-dependency.spec
new file mode 100644
index 0000000..c53fdfc
--- /dev/null
+++ b/apt/test/integration/specs/missing-dependency.spec
@@ -0,0 +1,17 @@
+Name: missing-dependency
+Version: 1
+Release: alt1
+Summary: Test package
+License: LGPLv2+
+Group: Other
+
+Requires: no-such-package
+
+%description
+Dummy description
+
+%files
+
+%changelog
+* Mon Sep 30 2019 Nobody <nobody@altlinux.org> 1-alt1
+- Test package created
diff --git a/apt/test/integration/specs/simple-package-new.spec b/apt/test/integration/specs/simple-package-new.spec
new file mode 100644
index 0000000..caefd34
--- /dev/null
+++ b/apt/test/integration/specs/simple-package-new.spec
@@ -0,0 +1,19 @@
+Name: simple-package-new
+Version: 3
+Release: alt1
+Summary: Test package
+License: LGPLv2+
+Group: Other
+
+Provides: simple-package = %EVR
+Obsoletes: simple-package < %EVR
+Conflicts: simple-package < %EVR
+
+%description
+Dummy description
+
+%files
+
+%changelog
+* Mon Sep 30 2019 Nobody <nobody@altlinux.org> 3-alt1
+- Test package created
diff --git a/apt/test/integration/specs/simple-package-noarch.spec b/apt/test/integration/specs/simple-package-noarch.spec
new file mode 100644
index 0000000..5a4e724
--- /dev/null
+++ b/apt/test/integration/specs/simple-package-noarch.spec
@@ -0,0 +1,17 @@
+Name: simple-package-noarch
+Version: 1
+Release: alt1
+Summary: Test package
+License: LGPLv2+
+Group: Other
+
+BuildArch: noarch
+
+%description
+Dummy description
+
+%files
+
+%changelog
+* Mon Sep 30 2019 Nobody <nobody@altlinux.org> 1-alt1
+- Test package created
diff --git a/apt/test/integration/specs/simple-package-update-conflict.spec b/apt/test/integration/specs/simple-package-update-conflict.spec
new file mode 100644
index 0000000..debbf3e
--- /dev/null
+++ b/apt/test/integration/specs/simple-package-update-conflict.spec
@@ -0,0 +1,17 @@
+Name: simple-package
+Version: 2
+Release: alt1
+Summary: Test package
+License: LGPLv2+
+Group: Other
+
+Conflicts: conflicting-package-one
+
+%description
+Dummy description
+
+%files
+
+%changelog
+* Mon Sep 30 2019 Nobody <nobody@altlinux.org> 2-alt1
+- Test package created
diff --git a/apt/test/integration/specs/simple-package-update.spec b/apt/test/integration/specs/simple-package-update.spec
new file mode 100644
index 0000000..5cd1200
--- /dev/null
+++ b/apt/test/integration/specs/simple-package-update.spec
@@ -0,0 +1,15 @@
+Name: simple-package
+Version: 2
+Release: alt1
+Summary: Test package
+License: LGPLv2+
+Group: Other
+
+%description
+Dummy description
+
+%files
+
+%changelog
+* Mon Sep 30 2019 Nobody <nobody@altlinux.org> 2-alt1
+- Test package created
diff --git a/apt/test/integration/specs/simple-package.spec b/apt/test/integration/specs/simple-package.spec
new file mode 100644
index 0000000..ff10b63
--- /dev/null
+++ b/apt/test/integration/specs/simple-package.spec
@@ -0,0 +1,15 @@
+Name: simple-package
+Version: 1
+Release: alt1
+Summary: Test package
+License: LGPLv2+
+Group: Other
+
+%description
+Dummy description
+
+%files
+
+%changelog
+* Mon Sep 30 2019 Nobody <nobody@altlinux.org> 1-alt1
+- Test package created
diff --git a/apt/test/integration/specs/simple-virtual.spec b/apt/test/integration/specs/simple-virtual.spec
new file mode 100644
index 0000000..b915145
--- /dev/null
+++ b/apt/test/integration/specs/simple-virtual.spec
@@ -0,0 +1,17 @@
+Name: simple-virtual
+Version: 1
+Release: alt1
+Summary: Test package
+License: LGPLv2+
+Group: Other
+
+Provides: virtual(dummy)
+
+%description
+Dummy description
+
+%files
+
+%changelog
+* Mon Sep 30 2019 Nobody <nobody@altlinux.org> 1-alt1
+- Test package created
diff --git a/apt/test/integration/test-apt-cache-depends-simple b/apt/test/integration/test-apt-cache-depends-simple
new file mode 100755
index 0000000..b07bd79
--- /dev/null
+++ b/apt/test/integration/test-apt-cache-depends-simple
@@ -0,0 +1,38 @@
+#!/bin/bash
+set -e
+
+TESTDIR=$(readlink -f $(dirname $0))
+. $TESTDIR/framework
+
+setupenvironment
+
+buildpackage "conflicting-package-distupgrade"
+buildpackage "conflicting-package-one"
+buildpackage "conflicting-package-two"
+buildpackage "missing-dependency"
+buildpackage "simple-package-new"
+buildpackage "simple-package-noarch"
+buildpackage "simple-package"
+buildpackage "simple-package-update-conflict"
+buildpackage "simple-package-update"
+
+generaterepository "$TMPWORKINGDIRECTORY/usr/src/RPM/RPMS" "$TMPWORKINGDIRECTORY/usr/src/RPM/REPO"
+
+testsuccess aptget update
+
+testregexmatch "simple-package-2-alt1@[0-9]+" aptcache depends "simple-package"
+
+testregexmatch "missing-dependency-1-alt1@[0-9]+
+ Depends: <no-such-package>" aptcache depends "missing-dependency"
+
+testregexmatch "conflicting-package-one-2-alt1@[0-9]+
+ Conflicts: conflicting-package-two
+ Conflicts: simple-package
+ simple-package-new-3-alt1@[0-9]+" aptcache depends "conflicting-package-one"
+
+testregexmatch "missing-dependency-1-alt1@[0-9]+
+ Depends: <no-such-package>" aptcache depends "missing-dependency"
+
+testregexmatch "<no-such-package>" aptcache depends "no-such-package"
+
+testregexmatch "W: Unable to locate package definitely-no-such-package" aptcache depends "definitely-no-such-package"
diff --git a/apt/test/integration/test-apt-cache-dump b/apt/test/integration/test-apt-cache-dump
new file mode 100755
index 0000000..6cc0bb5
--- /dev/null
+++ b/apt/test/integration/test-apt-cache-dump
@@ -0,0 +1,92 @@
+#!/bin/bash
+set -e
+
+TESTDIR=$(readlink -f $(dirname $0))
+. $TESTDIR/framework
+
+setupenvironment
+
+buildpackage "conflicting-package-distupgrade"
+buildpackage "conflicting-package-one"
+buildpackage "conflicting-package-two"
+buildpackage "missing-dependency"
+buildpackage "simple-package-new"
+buildpackage "simple-package-noarch"
+buildpackage "simple-package"
+buildpackage "simple-package-update-conflict"
+buildpackage "simple-package-update"
+
+generaterepository "$TMPWORKINGDIRECTORY/usr/src/RPM/RPMS" "$TMPWORKINGDIRECTORY/usr/src/RPM/REPO"
+
+testsuccess aptget update
+
+testregexmatch "Using Versioning System: Standard \.rpm
+Package: conflicting-package-two
+ Version: 1-alt1@[0-9]+
+ File: /.*/rootdir/var/lib/apt/lists/.*_usr_src_RPM_REPO_.*_base_pkglist\.apt-tests
+ Depends: conflicting-package-one \(null\)
+Package: no-such-package
+Package: simple-package-noarch
+ Version: 1-alt1@[0-9]+
+ File: /.*/rootdir/var/lib/apt/lists/.*_usr_src_RPM_REPO_noarch_base_pkglist\.apt-tests
+Package: simple-package-new
+ Version: 3-alt1@[0-9]+
+ File: /.*/rootdir/var/lib/apt/lists/.*_usr_src_RPM_REPO_.*_base_pkglist\.apt-tests
+ Depends: simple-package 3-alt1
+ Depends: simple-package 3-alt1
+Package: missing-dependency
+ Version: 1-alt1@[0-9]+
+ File: /.*/rootdir/var/lib/apt/lists/.*_usr_src_RPM_REPO_.*_base_pkglist\.apt-tests
+ Depends: no-such-package \(null\)
+Package: simple-package
+ Version: 2-alt1@[0-9]+
+ File: /.*/rootdir/var/lib/apt/lists/.*_usr_src_RPM_REPO_.*_base_pkglist\.apt-tests
+ Version: 1-alt1@[0-9]+
+ File: /.*/rootdir/var/lib/apt/lists/.*_usr_src_RPM_REPO_.*_base_pkglist\.apt-tests
+Package: conflicting-package-one
+ Version: 2-alt1@[0-9]+
+ File: /.*/rootdir/var/lib/apt/lists/.*_usr_src_RPM_REPO_.*_base_pkglist\.apt-tests
+ Depends: conflicting-package-two \(null\)
+ Depends: simple-package \(null\)
+ Version: 1-alt1@[0-9]+
+ File: /.*/rootdir/var/lib/apt/lists/.*_usr_src_RPM_REPO_.*_base_pkglist\.apt-tests
+ Depends: conflicting-package-two \(null\)
+File: /.*/var/lib/rpm/Packages
+ Type: RPM Database
+ Size: [0-9]+
+ ID: 2
+ Flags: 1
+ Time: .*
+ Archive: \(null\)
+ Component: \(null\)
+ Version: \(null\)
+ Origin: \(null\)
+ Site:[ ]*
+ Label: \(null\)
+ Architecture: \(null\)
+File: /.*/rootdir/var/lib/apt/lists/.*_usr_src_RPM_REPO_noarch_base_pkglist\.apt-tests
+ Type: RPM Package Index
+ Size: [0-9]+
+ ID: 1
+ Flags: 0
+ Time: .*
+ Archive: ALT Linux apt-tests
+ Component: apt-tests
+ Version: [0-9]+
+ Origin: ALT Linux Team
+ Site:[ ]*
+ Label: apt-tests
+ Architecture: noarch
+File: /.*/rootdir/var/lib/apt/lists/.*_usr_src_RPM_REPO_.*_base_pkglist\.apt-tests
+ Type: RPM Package Index
+ Size: [0-9]+
+ ID: 0
+ Flags: 0
+ Time: .*
+ Archive: ALT Linux apt-tests
+ Component: apt-tests
+ Version: [0-9]+
+ Origin: ALT Linux Team
+ Site:[ ]*
+ Label: apt-tests
+ Architecture: $(getarchitecture)" aptcache dump
diff --git a/apt/test/integration/test-apt-cache-dumpavail b/apt/test/integration/test-apt-cache-dumpavail
new file mode 100755
index 0000000..2c56300
--- /dev/null
+++ b/apt/test/integration/test-apt-cache-dumpavail
@@ -0,0 +1,115 @@
+#!/bin/bash
+set -e
+
+TESTDIR=$(readlink -f $(dirname $0))
+. $TESTDIR/framework
+
+setupenvironment
+
+buildpackage "conflicting-package-distupgrade"
+buildpackage "conflicting-package-one"
+buildpackage "conflicting-package-two"
+buildpackage "missing-dependency"
+buildpackage "simple-package-new"
+buildpackage "simple-package-noarch"
+buildpackage "simple-package"
+buildpackage "simple-package-update-conflict"
+buildpackage "simple-package-update"
+
+generaterepository "$TMPWORKINGDIRECTORY/usr/src/RPM/RPMS" "$TMPWORKINGDIRECTORY/usr/src/RPM/REPO"
+
+testsuccess aptget update
+
+testregexmatch "Package: conflicting-package-two
+Section: Other
+Installed Size: 0
+Maintainer:
+Version: 1-alt1@[0-9]+
+Pre-Depends: rpmlib\(PayloadIsLzma\)
+Conflicts: conflicting-package-one
+Provides: conflicting-package-two \(= 1-alt1\)
+Architecture: $(getarchitecture)
+Size: [0-9]+
+MD5Sum: [0-9a-fA-F]+
+Filename: conflicting-package-two-1-alt1\.$(getarchitecture)\.rpm
+Description: Test package
+ Dummy description
+
+
+Package: simple-package-noarch
+Section: Other
+Installed Size: 0
+Maintainer:
+Version: 1-alt1@[0-9]+
+Pre-Depends: rpmlib\(PayloadIsLzma\)
+Provides: simple-package-noarch \(= 1-alt1\)
+Architecture: noarch
+Size: [0-9]+
+MD5Sum: [0-9a-fA-F]+
+Filename: simple-package-noarch-1-alt1\.noarch\.rpm
+Description: Test package
+ Dummy description
+
+
+Package: simple-package-new
+Section: Other
+Installed Size: 0
+Maintainer:
+Version: 3-alt1@[0-9]+
+Pre-Depends: rpmlib\(PayloadIsLzma\)
+Conflicts: simple-package \(< 3-alt1\)
+Provides: simple-package \(= 3-alt1\), simple-package-new \(= 3-alt1\)
+Obsoletes: simple-package \(< 3-alt1\)
+Architecture: $(getarchitecture)
+Size: [0-9]+
+MD5Sum: [0-9a-fA-F]+
+Filename: simple-package-new-3-alt1\.$(getarchitecture)\.rpm
+Description: Test package
+ Dummy description
+
+
+Package: missing-dependency
+Section: Other
+Installed Size: 0
+Maintainer:
+Version: 1-alt1@[0-9]+
+Pre-Depends: rpmlib\(PayloadIsLzma\)
+Depends: no-such-package
+Provides: missing-dependency \(= 1-alt1\)
+Architecture: $(getarchitecture)
+Size: [0-9]+
+MD5Sum: [0-9a-fA-F]+
+Filename: missing-dependency-1-alt1\.$(getarchitecture)\.rpm
+Description: Test package
+ Dummy description
+
+
+Package: simple-package
+Section: Other
+Installed Size: 0
+Maintainer:
+Version: 2-alt1@[0-9]+
+Pre-Depends: rpmlib\(PayloadIsLzma\)
+Provides: simple-package \(= 2-alt1\)
+Architecture: $(getarchitecture)
+Size: [0-9]+
+MD5Sum: [0-9a-fA-F]+
+Filename: simple-package-2-alt1\.$(getarchitecture)\.rpm
+Description: Test package
+ Dummy description
+
+
+Package: conflicting-package-one
+Section: Other
+Installed Size: 0
+Maintainer:
+Version: 2-alt1@[0-9]+
+Pre-Depends: rpmlib\(PayloadIsLzma\)
+Conflicts: conflicting-package-two, simple-package
+Provides: conflicting-package-one \(= 2-alt1\)
+Architecture: $(getarchitecture)
+Size: [0-9]+
+MD5Sum: [0-9a-fA-F]+
+Filename: conflicting-package-one-2-alt1\.$(getarchitecture)\.rpm
+Description: Test package
+ Dummy description" aptcache dumpavail
diff --git a/apt/test/integration/test-apt-cache-pkgnames b/apt/test/integration/test-apt-cache-pkgnames
new file mode 100755
index 0000000..2de38a7
--- /dev/null
+++ b/apt/test/integration/test-apt-cache-pkgnames
@@ -0,0 +1,32 @@
+#!/bin/bash
+set -e
+
+TESTDIR=$(readlink -f $(dirname $0))
+. $TESTDIR/framework
+
+setupenvironment
+
+buildpackage "conflicting-package-distupgrade"
+buildpackage "conflicting-package-one"
+buildpackage "conflicting-package-two"
+buildpackage "missing-dependency"
+buildpackage "simple-package-new"
+buildpackage "simple-package-noarch"
+buildpackage "simple-package"
+buildpackage "simple-package-update-conflict"
+buildpackage "simple-package-update"
+buildpackage "simple-virtual"
+
+generaterepository "$TMPWORKINGDIRECTORY/usr/src/RPM/RPMS" "$TMPWORKINGDIRECTORY/usr/src/RPM/REPO"
+
+testsuccess aptget update
+
+testequal "conflicting-package-two
+no-such-package
+simple-virtual
+simple-package-noarch
+virtual(dummy)
+simple-package-new
+missing-dependency
+simple-package
+conflicting-package-one" aptcache pkgnames
diff --git a/apt/test/integration/test-apt-cache-search-simple b/apt/test/integration/test-apt-cache-search-simple
new file mode 100755
index 0000000..bb8f023
--- /dev/null
+++ b/apt/test/integration/test-apt-cache-search-simple
@@ -0,0 +1,38 @@
+#!/bin/bash
+set -e
+
+TESTDIR=$(readlink -f $(dirname $0))
+. $TESTDIR/framework
+
+setupenvironment
+
+buildpackage "conflicting-package-distupgrade"
+buildpackage "conflicting-package-one"
+buildpackage "conflicting-package-two"
+buildpackage "missing-dependency"
+buildpackage "simple-package-new"
+buildpackage "simple-package-noarch"
+buildpackage "simple-package"
+buildpackage "simple-package-update-conflict"
+buildpackage "simple-package-update"
+
+generaterepository "$TMPWORKINGDIRECTORY/usr/src/RPM/RPMS" "$TMPWORKINGDIRECTORY/usr/src/RPM/REPO"
+
+testsuccess aptget update
+
+testequal "simple-package - Test package
+simple-package-new - Test package
+simple-package-noarch - Test package" aptcache search "simple-package"
+
+testequal "simple-package - Test package
+simple-package-new - Test package
+simple-package-noarch - Test package" aptcache search "simple-package-*"
+
+testequal "simple-package - Test package
+simple-package-new - Test package
+simple-package-noarch - Test package" aptcache search "simple-package*"
+
+testequal "simple-package-new - Test package
+simple-package-noarch - Test package" aptcache search "simple-package-n*"
+
+testempty aptcache search "no-such-package"
diff --git a/apt/test/integration/test-apt-cache-show-simple b/apt/test/integration/test-apt-cache-show-simple
new file mode 100755
index 0000000..b188714
--- /dev/null
+++ b/apt/test/integration/test-apt-cache-show-simple
@@ -0,0 +1,67 @@
+#!/bin/bash
+set -e
+
+TESTDIR=$(readlink -f $(dirname $0))
+. $TESTDIR/framework
+
+setupenvironment
+
+buildpackage "conflicting-package-distupgrade"
+buildpackage "conflicting-package-one"
+buildpackage "conflicting-package-two"
+buildpackage "missing-dependency"
+buildpackage "simple-package-new"
+buildpackage "simple-package-noarch"
+buildpackage "simple-package"
+buildpackage "simple-package-update-conflict"
+buildpackage "simple-package-update"
+
+generaterepository "$TMPWORKINGDIRECTORY/usr/src/RPM/RPMS" "$TMPWORKINGDIRECTORY/usr/src/RPM/REPO"
+
+testsuccess aptget update
+
+testregexmatch "Package: simple-package
+Section: Other
+Installed Size: 0
+Maintainer:
+Version: 2-alt1@[0-9]+
+Pre-Depends: rpmlib\(PayloadIsLzma\)
+Provides: simple-package \(= 2-alt1\)
+Architecture: $(getarchitecture)
+Size: [0-9]+
+MD5Sum: [0-9a-fA-F]+
+Filename: simple-package-2-alt1\.$(getarchitecture)\.rpm
+Description: Test package
+ Dummy description
+
+
+Package: simple-package
+Section: Other
+Installed Size: 0
+Maintainer:
+Version: 1-alt1@[0-9]+
+Pre-Depends: rpmlib\(PayloadIsLzma\)
+Provides: simple-package \(= 1-alt1\)
+Architecture: $(getarchitecture)
+Size: [0-9]+
+MD5Sum: [0-9a-fA-F]+
+Filename: simple-package-1-alt1\.$(getarchitecture)\.rpm
+Description: Test package
+ Dummy description" aptcache show "simple-package"
+
+testregexmatch "Package: missing-dependency
+Section: Other
+Installed Size: 0
+Maintainer:
+Version: 1-alt1@[0-9]+
+Pre-Depends: rpmlib\(PayloadIsLzma\)
+Depends: no-such-package
+Provides: missing-dependency \(= 1-alt1\)
+Architecture: $(getarchitecture)
+Size: [0-9]+
+MD5Sum: [0-9a-fA-F]+
+Filename: missing-dependency-1-alt1\.$(getarchitecture)\.rpm
+Description: Test package
+ Dummy description" aptcache show "missing-dependency"
+
+testempty aptcache show "no-such-package"
diff --git a/apt/test/integration/test-apt-cache-showpkg-simple b/apt/test/integration/test-apt-cache-showpkg-simple
new file mode 100755
index 0000000..3df1232
--- /dev/null
+++ b/apt/test/integration/test-apt-cache-showpkg-simple
@@ -0,0 +1,44 @@
+#!/bin/bash
+set -e
+
+TESTDIR=$(readlink -f $(dirname $0))
+. $TESTDIR/framework
+
+setupenvironment
+
+buildpackage "simple-package"
+
+testpkgnotinstalled "simple-package"
+testequal 'W: Unable to locate package simple-package' aptcache showpkg "simple-package"
+
+generaterepository "$TMPWORKINGDIRECTORY/usr/src/RPM/RPMS" "$TMPWORKINGDIRECTORY/usr/src/RPM/REPO"
+
+testsuccess aptget update
+
+testpkgnotinstalled "simple-package"
+testregexmatch "Package: simple-package[ ]*
+Versions:[ ]*
+1-alt1@[0-9]+\(.*\)[ ]*
+[ ]*
+Reverse Depends:[ ]*
+Dependencies:[ ]*
+1-alt1@[0-9]+ -[ ]*
+Provides:[ ]*
+1-alt1@[0-9]+ - simple-package[ ]*
+Reverse Provides:[ ]*
+simple-package 1-alt1@[0-9]+[ ]*" aptcache showpkg "simple-package"
+
+aptgetinstallpackage "simple-package" "1" "alt1" "$(getarchitecture)"
+
+testpkginstalled "simple-package"
+testregexmatch "Package: simple-package[ ]*
+Versions:[ ]*
+1-alt1@[0-9]+\(.*\)[ ]*
+[ ]*
+Reverse Depends:[ ]*
+Dependencies:[ ]*
+1-alt1@[0-9]+ -[ ]*
+Provides:[ ]*
+1-alt1@[0-9]+ - simple-package[ ]*
+Reverse Provides:[ ]*
+simple-package 1-alt1@[0-9]+[ ]*" aptcache showpkg "simple-package"
diff --git a/apt/test/integration/test-apt-cache-stats b/apt/test/integration/test-apt-cache-stats
new file mode 100755
index 0000000..3b540c6
--- /dev/null
+++ b/apt/test/integration/test-apt-cache-stats
@@ -0,0 +1,36 @@
+#!/bin/bash
+set -e
+
+TESTDIR=$(readlink -f $(dirname $0))
+. $TESTDIR/framework
+
+setupenvironment
+
+buildpackage "conflicting-package-distupgrade"
+buildpackage "conflicting-package-one"
+buildpackage "conflicting-package-two"
+buildpackage "missing-dependency"
+buildpackage "simple-package-new"
+buildpackage "simple-package-noarch"
+buildpackage "simple-package"
+buildpackage "simple-package-update-conflict"
+buildpackage "simple-package-update"
+
+generaterepository "$TMPWORKINGDIRECTORY/usr/src/RPM/RPMS" "$TMPWORKINGDIRECTORY/usr/src/RPM/REPO"
+
+testsuccess aptget update
+
+testregexmatch "Total Package Names : 7 \([^\)]*\)
+ Normal Packages: 0
+ Pure Virtual Packages: 0
+ Single Virtual Packages: 0
+ Mixed Virtual Packages: 6
+ Missing: 1
+Total Distinct Versions: 8 \([^\)]*\)
+Total Dependencies: 7 \([^\)]*\)
+Total Ver/File relations: 8 \([^\)]*\)
+Total Provides Mappings: 9 \([^\)]*\)
+Total Globbed Strings: 10 \([^\)]*\)
+Total Dependency Version space: 14
+Total Slack space: .*
+Total Space Accounted for: .*" aptcache stats
diff --git a/apt/test/integration/test-apt-cache-unmet b/apt/test/integration/test-apt-cache-unmet
new file mode 100755
index 0000000..e4f9950
--- /dev/null
+++ b/apt/test/integration/test-apt-cache-unmet
@@ -0,0 +1,31 @@
+#!/bin/bash
+set -e
+
+TESTDIR=$(readlink -f $(dirname $0))
+. $TESTDIR/framework
+
+setupenvironment
+
+buildpackage "conflicting-package-distupgrade"
+buildpackage "conflicting-package-one"
+buildpackage "conflicting-package-two"
+buildpackage "simple-package-new"
+buildpackage "simple-package-noarch"
+buildpackage "simple-package"
+buildpackage "simple-package-update-conflict"
+buildpackage "simple-package-update"
+
+generaterepository "$TMPWORKINGDIRECTORY/usr/src/RPM/RPMS" "$TMPWORKINGDIRECTORY/usr/src/RPM/REPO"
+
+testsuccess aptget update
+
+testempty aptcache unmet
+
+buildpackage "missing-dependency"
+
+generaterepository "$TMPWORKINGDIRECTORY/usr/src/RPM/RPMS" "$TMPWORKINGDIRECTORY/usr/src/RPM/REPO" "$(date +%s --date='now +1 day')"
+
+testsuccess aptget update
+
+testregexmatch "Package missing-dependency version 1-alt1@[0-9]+ has an unmet dep:
+ Depends: no-such-package" aptcache unmet
diff --git a/apt/test/integration/test-apt-cache-whatdepends-simple b/apt/test/integration/test-apt-cache-whatdepends-simple
new file mode 100755
index 0000000..16684a4
--- /dev/null
+++ b/apt/test/integration/test-apt-cache-whatdepends-simple
@@ -0,0 +1,43 @@
+#!/bin/bash
+set -e
+
+TESTDIR=$(readlink -f $(dirname $0))
+. $TESTDIR/framework
+
+setupenvironment
+
+buildpackage "conflicting-package-distupgrade"
+buildpackage "conflicting-package-one"
+buildpackage "conflicting-package-two"
+buildpackage "missing-dependency"
+buildpackage "simple-package-new"
+buildpackage "simple-package-noarch"
+buildpackage "simple-package"
+buildpackage "simple-package-update-conflict"
+buildpackage "simple-package-update"
+
+generaterepository "$TMPWORKINGDIRECTORY/usr/src/RPM/RPMS" "$TMPWORKINGDIRECTORY/usr/src/RPM/REPO"
+
+testsuccess aptget update
+
+testregexmatch "simple-package-2-alt1@[0-9]+
+ simple-package-new-3-alt1@[0-9]+
+ Conflicts: simple-package < 3-alt1
+ Obsoletes: simple-package < 3-alt1
+ conflicting-package-one-2-alt1@[0-9]+
+ Conflicts: simple-package
+ simple-package-new-3-alt1@[0-9]+" aptcache whatdepends "simple-package"
+
+testregexmatch "missing-dependency-1-alt1@[0-9]+" aptcache whatdepends "missing-dependency"
+
+testregexmatch "conflicting-package-one-2-alt1@[0-9]+
+ conflicting-package-two-1-alt1@[0-9]+
+ Conflicts: conflicting-package-one" aptcache whatdepends "conflicting-package-one"
+
+testregexmatch "missing-dependency-1-alt1@[0-9]+" aptcache whatdepends "missing-dependency"
+
+testregexmatch "<no-such-package>
+ missing-dependency-1-alt1@[0-9]+
+ Depends: <no-such-package>" aptcache whatdepends "no-such-package"
+
+testregexmatch "W: Unable to locate package definitely-no-such-package" aptcache whatdepends "definitely-no-such-package"
diff --git a/apt/test/integration/test-apt-check-simple b/apt/test/integration/test-apt-check-simple
new file mode 100755
index 0000000..bd56d1c
--- /dev/null
+++ b/apt/test/integration/test-apt-check-simple
@@ -0,0 +1,26 @@
+#!/bin/bash
+set -e
+
+TESTDIR=$(readlink -f $(dirname $0))
+. $TESTDIR/framework
+
+setupenvironment
+
+buildpackage "missing-dependency"
+buildpackage "simple-package"
+
+testpkgnotinstalled "missing-dependency"
+testpkgnotinstalled "simple-package"
+testsuccess aptget check
+
+installpackage "simple-package" "1" "alt1" "$(getarchitecture)"
+
+testpkgnotinstalled "missing-dependency"
+testpkginstalled "simple-package"
+testsuccess aptget check
+
+installpackage "missing-dependency" "1" "alt1" "$(getarchitecture)"
+
+testpkginstalled "missing-dependency"
+testpkginstalled "simple-package"
+testfailure aptget check
diff --git a/apt/test/integration/test-apt-config-dump b/apt/test/integration/test-apt-config-dump
new file mode 100755
index 0000000..134242f
--- /dev/null
+++ b/apt/test/integration/test-apt-config-dump
@@ -0,0 +1,61 @@
+#!/bin/bash
+set -e
+
+TESTDIR=$(readlink -f $(dirname $0))
+. $TESTDIR/framework
+
+setupenvironment
+
+testregexmatch "APT \"\";
+APT::Architecture \"$(getarchitecture)\";
+APT::DistroVersion \"\";
+APT::Get \"\";
+APT::Get::ReInstall \"\";
+APT::Get::ReInstall::MarkManual \"1\";
+APT::Get::Obsoletes \"\";
+APT::Get::Obsoletes::AptMarkInheritanceAuto \"all\";
+Dir \"[^\"]*\";
+Dir::State \"var/lib/apt/\";
+Dir::State::lists \"lists/\";
+Dir::State::cdroms \"cdroms\.list\";
+Dir::State::prefetch \"prefetch\";
+Dir::Cache \"var/cache/apt/\";
+Dir::Cache::archives \"archives/\";
+Dir::Cache::srcpkgcache \"srcpkgcache\.bin\";
+Dir::Cache::pkgcache \"pkgcache\.bin\";
+Dir::Etc \"etc/apt/\";
+Dir::Etc::sourcelist \"[^\"]*\";
+Dir::Etc::sourceparts \"sources\.list\.d\";
+Dir::Etc::vendorlist \"vendors\.list\";
+Dir::Etc::vendorparts \"vendors\.list\.d\";
+Dir::Etc::main \"apt\.conf\";
+Dir::Etc::parts \"apt\.conf\.d\";
+Dir::Etc::preferences \"preferences\";
+Dir::Etc::preferencesparts \"preferences\.d\";
+Dir::Etc::pkgpriorities \"pkgpriorities\";
+Dir::Etc::translatelist \"translate\.list\";
+Dir::Etc::translateparts \"translate\.list\.d\";
+Dir::Bin \"\";
+Dir::Bin::methods \"[^\"]*\";
+Dir::Bin::rpm \"/bin/rpm\";
+Dir::Bin::scripts \"/usr/share/apt/scripts\";
+Dir::Ignore-Files-Silently \"\";
+Dir::Ignore-Files-Silently:: \"~\\$\";
+Dir::Ignore-Files-Silently:: \"\\\.disabled\\$\";
+Dir::Ignore-Files-Silently:: \"\\\.bak\\$\";
+Dir::Ignore-Files-Silently:: \"\\\.dpkg-\[a-z\]\+\\$\";
+Dir::Ignore-Files-Silently:: \"\\\.ucf-\[a-z\]\+\\$\";
+Dir::Ignore-Files-Silently:: \"\\\.save\\$\";
+Dir::Ignore-Files-Silently:: \"\\\.orig\\$\";
+Dir::Ignore-Files-Silently:: \"[^\"]*\\$\";
+Dir::Locale \"/usr/share/locale\";
+Acquire \"\";
+Acquire::ComprExtension \"\.bz2\";
+Acquire::DistroID \"ALT Linux\";
+Acquire::CDROM \"\";
+Acquire::CDROM::Mount \"/media/ALTLinux\";
+Acquire::CDROM::Copy-All \"true\";
+Debug \"\";
+Debug::NoLocking \"true\";
+RPM \"\";
+RPM::DBPath \"[^\"]*\";" aptconfig dump
diff --git a/apt/test/integration/test-apt-distupgrade-conflict b/apt/test/integration/test-apt-distupgrade-conflict
new file mode 100755
index 0000000..d03413c
--- /dev/null
+++ b/apt/test/integration/test-apt-distupgrade-conflict
@@ -0,0 +1,30 @@
+#!/bin/bash
+set -e
+
+TESTDIR=$(readlink -f $(dirname $0))
+. $TESTDIR/framework
+
+setupenvironment
+
+buildpackage "simple-package"
+buildpackage "simple-package-update"
+buildpackage "conflicting-package-one"
+buildpackage "conflicting-package-distupgrade"
+
+testpkgnotinstalled "simple-package"
+testpkgnotinstalled "conflicting-package-one"
+aptgetinstallpackage "simple-package" "1" "alt1" "$(getarchitecture)"
+aptgetinstallpackage "conflicting-package-one" "1" "alt1" "$(getarchitecture)"
+testpkginstalled "simple-package"
+testpkginstalled "conflicting-package-one"
+
+testequal '1-alt1' getpackageversion "simple-package"
+testequal '1-alt1' getpackageversion "conflicting-package-one"
+
+generaterepository "$TMPWORKINGDIRECTORY/usr/src/RPM/RPMS" "$TMPWORKINGDIRECTORY/usr/src/RPM/REPO"
+
+testsuccess aptget update
+
+testsuccess aptget dist-upgrade -y
+testequal '2-alt1' getpackageversion "simple-package"
+testequal '1-alt1' getpackageversion "conflicting-package-one"
diff --git a/apt/test/integration/test-apt-distupgrade-mutual-conflict b/apt/test/integration/test-apt-distupgrade-mutual-conflict
new file mode 100755
index 0000000..6e1262c
--- /dev/null
+++ b/apt/test/integration/test-apt-distupgrade-mutual-conflict
@@ -0,0 +1,31 @@
+#!/bin/bash
+set -e
+
+TESTDIR=$(readlink -f $(dirname $0))
+. $TESTDIR/framework
+
+setupenvironment
+
+buildpackage "simple-package"
+buildpackage "simple-package-update-conflict"
+buildpackage "conflicting-package-one"
+buildpackage "conflicting-package-distupgrade"
+
+testpkgnotinstalled "simple-package"
+testpkgnotinstalled "conflicting-package-one"
+aptgetinstallpackage "simple-package" "1" "alt1" "$(getarchitecture)"
+aptgetinstallpackage "conflicting-package-one" "1" "alt1" "$(getarchitecture)"
+testpkginstalled "simple-package"
+testpkginstalled "conflicting-package-one"
+
+testequal '1-alt1' getpackageversion "simple-package"
+testequal '1-alt1' getpackageversion "conflicting-package-one"
+
+generaterepository "$TMPWORKINGDIRECTORY/usr/src/RPM/RPMS" "$TMPWORKINGDIRECTORY/usr/src/RPM/REPO"
+
+testsuccess aptget update
+
+testsuccess aptget dist-upgrade -y
+
+testequal '1-alt1' getpackageversion "simple-package"
+testequal '1-alt1' getpackageversion "conflicting-package-one"
diff --git a/apt/test/integration/test-apt-distupgrade-obsolete b/apt/test/integration/test-apt-distupgrade-obsolete
new file mode 100755
index 0000000..44110d0
--- /dev/null
+++ b/apt/test/integration/test-apt-distupgrade-obsolete
@@ -0,0 +1,26 @@
+#!/bin/bash
+set -e
+
+TESTDIR=$(readlink -f $(dirname $0))
+. $TESTDIR/framework
+
+setupenvironment
+
+buildpackage "simple-package"
+buildpackage "simple-package-new"
+
+testpkgnotinstalled "simple-package"
+testpkgnotinstalled "simple-package-new"
+
+aptgetinstallpackage "simple-package" "1" "alt1" "$(getarchitecture)"
+testpkginstalled "simple-package"
+testpkgnotinstalled "simple-package-new"
+
+generaterepository "$TMPWORKINGDIRECTORY/usr/src/RPM/RPMS" "$TMPWORKINGDIRECTORY/usr/src/RPM/REPO"
+
+testsuccess aptget update
+
+testsuccess aptget dist-upgrade -y
+
+testpkgnotinstalled "simple-package"
+testpkginstalled "simple-package-new"
diff --git a/apt/test/integration/test-apt-distupgrade-simple b/apt/test/integration/test-apt-distupgrade-simple
new file mode 100755
index 0000000..c330ecf
--- /dev/null
+++ b/apt/test/integration/test-apt-distupgrade-simple
@@ -0,0 +1,23 @@
+#!/bin/bash
+set -e
+
+TESTDIR=$(readlink -f $(dirname $0))
+. $TESTDIR/framework
+
+setupenvironment
+
+buildpackage "simple-package"
+buildpackage "simple-package-update"
+
+testpkgnotinstalled "simple-package"
+aptgetinstallpackage "simple-package" "1" "alt1" "$(getarchitecture)"
+testpkginstalled "simple-package"
+
+testequal '1-alt1' getpackageversion "simple-package"
+
+generaterepository "$TMPWORKINGDIRECTORY/usr/src/RPM/RPMS" "$TMPWORKINGDIRECTORY/usr/src/RPM/REPO"
+
+testsuccess aptget update
+
+testsuccess aptget dist-upgrade -y
+testequal '2-alt1' getpackageversion "simple-package"
diff --git a/apt/test/integration/test-apt-install-conflicting-packages b/apt/test/integration/test-apt-install-conflicting-packages
new file mode 100755
index 0000000..9fc8f19
--- /dev/null
+++ b/apt/test/integration/test-apt-install-conflicting-packages
@@ -0,0 +1,27 @@
+#!/bin/bash
+set -e
+
+TESTDIR=$(readlink -f $(dirname $0))
+. $TESTDIR/framework
+
+setupenvironment
+
+buildpackage "conflicting-package-one"
+buildpackage "conflicting-package-two"
+
+testpkgnotinstalled "conflicting-package-one" "conflicting-package-two"
+
+testregexmatch "Reading Package Lists\.\.\.
+Building Dependency Tree\.\.\.
+Selecting conflicting-package-one for '[^']+'
+Selecting conflicting-package-two for '[^']+'
+Some packages could not be installed\. This may mean that you have
+requested an impossible situation or if you are using the unstable
+distribution that some required packages have not yet been created
+or been moved out of Incoming\.
+The following information may help to resolve the situation:
+
+The following packages have unmet dependencies:
+ conflicting-package-one: Conflicts: conflicting-package-two
+ conflicting-package-two: Conflicts: conflicting-package-one
+E: Broken packages" aptget install "$TMPWORKINGDIRECTORY/usr/src/RPM/RPMS/$(getarchitecture)/conflicting-package-one-1-alt1.$(getarchitecture).rpm" "$TMPWORKINGDIRECTORY/usr/src/RPM/RPMS/$(getarchitecture)/conflicting-package-two-1-alt1.$(getarchitecture).rpm"
diff --git a/apt/test/integration/test-apt-install-double b/apt/test/integration/test-apt-install-double
new file mode 100755
index 0000000..4728b08
--- /dev/null
+++ b/apt/test/integration/test-apt-install-double
@@ -0,0 +1,17 @@
+#!/bin/bash
+set -e
+
+TESTDIR=$(readlink -f $(dirname $0))
+. $TESTDIR/framework
+
+setupenvironment
+
+buildpackage "simple-package"
+buildpackage "conflicting-package-one"
+
+testpkgnotinstalled "simple-package" "conflicting-package-one"
+aptgetinstallpackage "simple-package" "1" "alt1" "$(getarchitecture)"
+testpkginstalled "simple-package"
+testpkgnotinstalled "conflicting-package-one"
+aptgetinstallpackage "conflicting-package-one" "1" "alt1" "$(getarchitecture)"
+testpkginstalled "simple-package" "conflicting-package-one"
diff --git a/apt/test/integration/test-apt-install-simple b/apt/test/integration/test-apt-install-simple
new file mode 100755
index 0000000..b765b19
--- /dev/null
+++ b/apt/test/integration/test-apt-install-simple
@@ -0,0 +1,13 @@
+#!/bin/bash
+set -e
+
+TESTDIR=$(readlink -f $(dirname $0))
+. $TESTDIR/framework
+
+setupenvironment
+
+buildpackage "simple-package"
+
+testpkgnotinstalled "simple-package"
+aptgetinstallpackage "simple-package" "1" "alt1" "$(getarchitecture)"
+testpkginstalled "simple-package"
diff --git a/apt/test/integration/test-apt-mark-simple b/apt/test/integration/test-apt-mark-simple
new file mode 100755
index 0000000..0a6fe65
--- /dev/null
+++ b/apt/test/integration/test-apt-mark-simple
@@ -0,0 +1,58 @@
+#!/bin/bash
+set -e
+
+TESTDIR=$(readlink -f $(dirname $0))
+. $TESTDIR/framework
+
+setupenvironment
+
+buildpackage "simple-package"
+buildpackage "conflicting-package-one"
+
+aptgetinstallpackage "simple-package" "1" "alt1" "$(getarchitecture)"
+aptgetinstallpackage "conflicting-package-one" "1" "alt1" "$(getarchitecture)"
+
+testpkginstalled "simple-package"
+testpkginstalled "conflicting-package-one"
+
+testequal "Reading Package Lists...
+Building Dependency Tree...
+conflicting-package-one manual
+simple-package manual" aptmark showstate simple-package conflicting-package-one
+
+testequal "Reading Package Lists...
+Building Dependency Tree...
+conflicting-package-one manual
+simple-package manual" aptmark showstate
+
+testequal "Reading Package Lists...
+Building Dependency Tree..." aptmark showauto
+
+testequal "Reading Package Lists...
+Building Dependency Tree...
+conflicting-package-one
+simple-package" aptmark showmanual
+
+testsuccess aptmark auto simple-package
+
+testequal "Reading Package Lists...
+Building Dependency Tree...
+conflicting-package-one manual
+simple-package auto" aptmark showstate simple-package conflicting-package-one
+
+testequal "Reading Package Lists...
+Building Dependency Tree...
+conflicting-package-one manual" aptmark showstate conflicting-package-one
+
+testequal "Reading Package Lists...
+Building Dependency Tree...
+conflicting-package-one manual
+simple-package auto" aptmark showstate
+
+testequal "Reading Package Lists...
+Building Dependency Tree...
+simple-package" aptmark showauto
+
+testequal "Reading Package Lists...
+Building Dependency Tree...
+conflicting-package-one" aptmark showmanual
diff --git a/apt/test/integration/test-apt-remove-double b/apt/test/integration/test-apt-remove-double
new file mode 100755
index 0000000..87aa0d0
--- /dev/null
+++ b/apt/test/integration/test-apt-remove-double
@@ -0,0 +1,22 @@
+#!/bin/bash
+set -e
+
+TESTDIR=$(readlink -f $(dirname $0))
+. $TESTDIR/framework
+
+setupenvironment
+
+buildpackage "simple-package"
+buildpackage "conflicting-package-one"
+
+testpkgnotinstalled "simple-package" "conflicting-package-one"
+aptgetinstallpackage "simple-package" "1" "alt1" "$(getarchitecture)"
+msgmsg "Installed package \"simple-package\""
+aptgetinstallpackage "conflicting-package-one" "1" "alt1" "$(getarchitecture)"
+msgmsg "Installed package \"conflicting-package-one\""
+testpkginstalled "simple-package" "conflicting-package-one"
+testsuccess aptget -y remove "simple-package"
+testpkgnotinstalled "simple-package"
+testpkginstalled "conflicting-package-one"
+testsuccess aptget -y remove "conflicting-package-one"
+testpkgnotinstalled "simple-package" "conflicting-package-one"
diff --git a/apt/test/integration/test-apt-remove-simple b/apt/test/integration/test-apt-remove-simple
new file mode 100755
index 0000000..1b28e71
--- /dev/null
+++ b/apt/test/integration/test-apt-remove-simple
@@ -0,0 +1,15 @@
+#!/bin/bash
+set -e
+
+TESTDIR=$(readlink -f $(dirname $0))
+. $TESTDIR/framework
+
+setupenvironment
+
+buildpackage "simple-package"
+testpkgnotinstalled "simple-package"
+aptgetinstallpackage "simple-package" "1" "alt1" "$(getarchitecture)"
+msgmsg "Installed package \"simple-package\""
+testpkginstalled "simple-package"
+testsuccess aptget -y remove "simple-package"
+testpkgnotinstalled "simple-package"
diff --git a/apt/test/integration/test-apt-update-simple b/apt/test/integration/test-apt-update-simple
new file mode 100755
index 0000000..7ada61c
--- /dev/null
+++ b/apt/test/integration/test-apt-update-simple
@@ -0,0 +1,19 @@
+#!/bin/bash
+set -e
+
+TESTDIR=$(readlink -f $(dirname $0))
+. $TESTDIR/framework
+
+setupenvironment
+
+buildpackage "simple-package"
+buildpackage "simple-package-noarch"
+buildpackage "conflicting-package-one"
+buildpackage "conflicting-package-two"
+
+generaterepository "$TMPWORKINGDIRECTORY/usr/src/RPM/RPMS" "$TMPWORKINGDIRECTORY/usr/src/RPM/REPO"
+
+testsuccess aptget update
+testsuccess aptcache show simple-package
+testsuccess aptcache show simple-package-noarch
+testfailure aptcache show nosuchpkg
diff --git a/apt/test/integration/test-apt-upgrade-simple b/apt/test/integration/test-apt-upgrade-simple
new file mode 100755
index 0000000..0fc9d54
--- /dev/null
+++ b/apt/test/integration/test-apt-upgrade-simple
@@ -0,0 +1,26 @@
+#!/bin/bash
+set -e
+
+TESTDIR=$(readlink -f $(dirname $0))
+. $TESTDIR/framework
+
+setupenvironment
+
+buildpackage "simple-package"
+buildpackage "simple-package-update"
+
+testpkgnotinstalled "simple-package"
+aptgetinstallpackage "simple-package" "1" "alt1" "$(getarchitecture)"
+testpkginstalled "simple-package"
+
+testequal '1-alt1' getpackageversion "simple-package"
+
+generaterepository "$TMPWORKINGDIRECTORY/usr/src/RPM/RPMS" "$TMPWORKINGDIRECTORY/usr/src/RPM/REPO"
+
+testsuccess aptget update
+
+testfailure aptget upgrade -y
+testequal '1-alt1' getpackageversion "simple-package"
+
+testsuccess aptget upgrade -y -o APT::Get::EnableUpgrade=true
+testequal '2-alt1' getpackageversion "simple-package"
--
2.24.0
^ permalink raw reply [flat|nested] 84+ messages in thread
* [devel] [PATCH for apt 35/38] Add basic tests to ensure that lua and rpm scripts are called
2019-12-10 15:23 [devel] [PATCH for apt 00/38] Various fixes for Apt and basic integration test suite Aleksei Nikiforov
` (33 preceding siblings ...)
2019-12-10 15:23 ` [devel] [PATCH for apt 34/38] Add initial integration tests Aleksei Nikiforov
@ 2019-12-10 15:23 ` Aleksei Nikiforov
2019-12-10 15:23 ` [devel] [PATCH for apt 36/38] Add http and https methods tests Aleksei Nikiforov
` (2 subsequent siblings)
37 siblings, 0 replies; 84+ messages in thread
From: Aleksei Nikiforov @ 2019-12-10 15:23 UTC (permalink / raw)
To: devel; +Cc: Aleksei Nikiforov
---
apt/test/integration/framework | 52 ++++++++++++
apt/test/integration/test-apt-config-dump | 2 +-
apt/test/integration/test-apt-lua-simple | 82 +++++++++++++++++++
.../test-apt-rpm-bash-scripts-simple | 21 +++++
4 files changed, 156 insertions(+), 1 deletion(-)
create mode 100755 apt/test/integration/test-apt-lua-simple
create mode 100755 apt/test/integration/test-apt-rpm-bash-scripts-simple
diff --git a/apt/test/integration/framework b/apt/test/integration/framework
index 326874a..fa9672d 100644
--- a/apt/test/integration/framework
+++ b/apt/test/integration/framework
@@ -189,6 +189,15 @@ END
# setup rpm dbpath
echo "RPM::DBPath \"$TMPWORKINGDIRECTORY/var/lib/rpm\";" > rootdir/etc/apt/apt.conf.d/99rpmdbpath.conf
+ # setup lua stuff
+ mkdir -p $TMPWORKINGDIRECTORY/lua/scripts
+ mkdir -p $TMPWORKINGDIRECTORY/lua/results
+ echo "Dir::Bin::scripts \"$TMPWORKINGDIRECTORY/lua/scripts\";" > rootdir/etc/apt/apt.conf.d/90lua.conf
+
+ # setup bash scripts
+ mkdir -p $TMPWORKINGDIRECTORY/bash/scripts
+ mkdir -p $TMPWORKINGDIRECTORY/bash/results
+
msgdone "info"
}
@@ -290,6 +299,24 @@ testequal() {
"$@" 2>&1 | checkdiff $COMPAREFILE - && msgpass || msgfail
}
+testscriptoutput() {
+ local MSG="$1"
+ shift
+
+ msgtest "Test of output of" "$MSG"
+
+ testequal --nomsg "$@"
+}
+
+testscriptnooutput() {
+ local MSG="$1"
+ shift
+
+ msgtest "Test for no output of" "$MSG"
+
+ [ ! -e "$1" ] && msgpass || msgfail
+}
+
testregexmatch() {
local MSG='Test of regex match of'
if [ "$1" = '--nomsg' ]; then
@@ -500,3 +527,28 @@ generaterepository() {
fi
done
}
+
+createluascript() {
+ local APTNAME="$1"
+ local SCRIPTFILENAME="$2"
+
+ echo "$APTNAME:: \"${SCRIPTFILENAME}.lua\";" > rootdir/etc/apt/apt.conf.d/91lua-${SCRIPTFILENAME}.conf
+ cat > $TMPWORKINGDIRECTORY/lua/scripts/${SCRIPTFILENAME}.lua << ENDSCRIPT
+f = io.open("$TMPWORKINGDIRECTORY/lua/results/${SCRIPTFILENAME}.result", "a")
+f:write("$APTNAME called\n")
+f:close()
+ENDSCRIPT
+}
+
+createbashscript() {
+ local APTNAME="$1"
+ local SCRIPTFILENAME="$2"
+
+ echo "$APTNAME:: \"$TMPWORKINGDIRECTORY/bash/scripts/${SCRIPTFILENAME}.sh\";" > rootdir/etc/apt/apt.conf.d/92bash-${SCRIPTFILENAME}.conf
+ cat > $TMPWORKINGDIRECTORY/bash/scripts/${SCRIPTFILENAME}.sh << ENDSCRIPT
+#!/bin/bash
+echo "$APTNAME called" >> "$TMPWORKINGDIRECTORY/bash/results/${SCRIPTFILENAME}.result"
+ENDSCRIPT
+
+ chmod +x $TMPWORKINGDIRECTORY/bash/scripts/${SCRIPTFILENAME}.sh
+}
diff --git a/apt/test/integration/test-apt-config-dump b/apt/test/integration/test-apt-config-dump
index 134242f..6ddc031 100755
--- a/apt/test/integration/test-apt-config-dump
+++ b/apt/test/integration/test-apt-config-dump
@@ -37,8 +37,8 @@ Dir::Etc::translatelist \"translate\.list\";
Dir::Etc::translateparts \"translate\.list\.d\";
Dir::Bin \"\";
Dir::Bin::methods \"[^\"]*\";
+Dir::Bin::scripts \"[^\"]*\";
Dir::Bin::rpm \"/bin/rpm\";
-Dir::Bin::scripts \"/usr/share/apt/scripts\";
Dir::Ignore-Files-Silently \"\";
Dir::Ignore-Files-Silently:: \"~\\$\";
Dir::Ignore-Files-Silently:: \"\\\.disabled\\$\";
diff --git a/apt/test/integration/test-apt-lua-simple b/apt/test/integration/test-apt-lua-simple
new file mode 100755
index 0000000..878f7ad
--- /dev/null
+++ b/apt/test/integration/test-apt-lua-simple
@@ -0,0 +1,82 @@
+#!/bin/bash
+set -e
+
+TESTDIR=$(readlink -f $(dirname $0))
+. $TESTDIR/framework
+
+setupenvironment
+
+createluascript "Scripts::Init" "init"
+createluascript "Scripts::Cache::Init" "cache-init"
+createluascript "Scripts::Acquire::Archive::Done" "acquire-archive-done"
+createluascript "Scripts::PM::Pre" "pm-pre"
+createluascript "Scripts::PM::Post" "pm-post"
+createluascript "Scripts::AptGet::Update::Pre" "aptget-update-pre"
+createluascript "Scripts::AptGet::Update::Post-Invoke-Success" "aptget-update-post-invoke-success"
+createluascript "Scripts::AptGet::Update::Post" "aptget-update-post"
+createluascript "Scripts::AptCache::Script" "aptcache-script"
+createluascript "Scripts::AptCache::Help::Command" "aptcache-help-command"
+createluascript "Scripts::AptCache::Command" "aptcache-command"
+createluascript "Scripts::AptGet::Install::SelectPackage" "aptget-install-selectpackage"
+createluascript "Scripts::AptGet::Upgrade" "aptget-upgrade"
+createluascript "Scripts::AptGet::Install::TranslateArg" "aptget-install-translatearg"
+createluascript "Scripts::AptGet::Install::PreResolve" "aptget-install-preresolve"
+createluascript "Scripts::AptGet::Install::PostResolve" "aptget-install-postresolve"
+createluascript "Scripts::AptGet::DistUpgrade" "aptget-distupgrade"
+createluascript "Scripts::AptGet::Script" "aptget-script"
+createluascript "Scripts::AptGet::Help::Command" "aptget-help-command"
+createluascript "Scripts::AptGet::Command" "aptget-command"
+
+buildpackage "simple-package"
+
+testpkgnotinstalled "simple-package"
+
+rm -f $TMPWORKINGDIRECTORY/lua/results/* ||:
+aptgetinstallpackage "simple-package" "1" "alt1" "$(getarchitecture)"
+
+testscriptoutput "Scripts::Init" "Scripts::Init called
+Scripts::Init called" cat $TMPWORKINGDIRECTORY/lua/results/init.result
+testscriptoutput "Scripts::Cache::Init" "Scripts::Cache::Init called" cat $TMPWORKINGDIRECTORY/lua/results/cache-init.result
+testscriptoutput "Scripts::AptGet::Command" "Scripts::AptGet::Command called" cat $TMPWORKINGDIRECTORY/lua/results/aptget-command.result
+testscriptoutput "Scripts::AptGet::Install::PreResolve" "Scripts::AptGet::Install::PreResolve called" cat $TMPWORKINGDIRECTORY/lua/results/aptget-install-preresolve.result
+testscriptoutput "Scripts::AptGet::Install::PostResolve" "Scripts::AptGet::Install::PostResolve called" cat $TMPWORKINGDIRECTORY/lua/results/aptget-install-postresolve.result
+testscriptoutput "Scripts::Acquire::Archive::Done" "Scripts::Acquire::Archive::Done called" cat $TMPWORKINGDIRECTORY/lua/results/acquire-archive-done.result
+testscriptoutput "Scripts::PM::Pre" "Scripts::PM::Pre called" cat $TMPWORKINGDIRECTORY/lua/results/pm-pre.result
+testscriptoutput "Scripts::PM::Post" "Scripts::PM::Post called" cat $TMPWORKINGDIRECTORY/lua/results/pm-post.result
+
+testpkginstalled "simple-package"
+
+buildpackage "simple-package-update"
+
+rm -f $TMPWORKINGDIRECTORY/lua/results/* ||:
+testfailure aptget update
+
+testscriptoutput "Scripts::Init" "Scripts::Init called" cat $TMPWORKINGDIRECTORY/lua/results/init.result
+testscriptoutput "Scripts::AptGet::Command" "Scripts::AptGet::Command called" cat $TMPWORKINGDIRECTORY/lua/results/aptget-command.result
+testscriptoutput "Scripts::AptGet::Update::Pre" "Scripts::AptGet::Update::Pre called" cat $TMPWORKINGDIRECTORY/lua/results/aptget-update-pre.result
+testscriptoutput "Scripts::AptGet::Update::Post" "Scripts::AptGet::Update::Post called" cat $TMPWORKINGDIRECTORY/lua/results/aptget-update-post.result
+# this looks broken: it probably shouldn't return success on failure to update some items
+testscriptoutput "Scripts::AptGet::Update::Post-Invoke-Success" "Scripts::AptGet::Update::Post-Invoke-Success called" cat $TMPWORKINGDIRECTORY/lua/results/aptget-update-post-invoke-success.result
+
+generaterepository "$TMPWORKINGDIRECTORY/usr/src/RPM/RPMS" "$TMPWORKINGDIRECTORY/usr/src/RPM/REPO"
+
+rm -f $TMPWORKINGDIRECTORY/lua/results/* ||:
+testsuccess aptget update
+
+testscriptoutput "Scripts::Init" "Scripts::Init called" cat $TMPWORKINGDIRECTORY/lua/results/init.result
+testscriptoutput "Scripts::Cache::Init" "Scripts::Cache::Init called" cat $TMPWORKINGDIRECTORY/lua/results/cache-init.result
+testscriptoutput "Scripts::AptGet::Command" "Scripts::AptGet::Command called" cat $TMPWORKINGDIRECTORY/lua/results/aptget-command.result
+testscriptoutput "Scripts::AptGet::Update::Pre" "Scripts::AptGet::Update::Pre called" cat $TMPWORKINGDIRECTORY/lua/results/aptget-update-pre.result
+testscriptoutput "Scripts::AptGet::Update::Post-Invoke-Success" "Scripts::AptGet::Update::Post-Invoke-Success called" cat $TMPWORKINGDIRECTORY/lua/results/aptget-update-post-invoke-success.result
+testscriptoutput "Scripts::AptGet::Update::Post" "Scripts::AptGet::Update::Post called" cat $TMPWORKINGDIRECTORY/lua/results/aptget-update-post.result
+
+rm -f $TMPWORKINGDIRECTORY/lua/results/* ||:
+testsuccess aptget dist-upgrade -y
+
+testscriptoutput "Scripts::Init" "Scripts::Init called" cat $TMPWORKINGDIRECTORY/lua/results/init.result
+testscriptoutput "Scripts::Cache::Init" "Scripts::Cache::Init called" cat $TMPWORKINGDIRECTORY/lua/results/cache-init.result
+testscriptoutput "Scripts::AptGet::Command" "Scripts::AptGet::Command called" cat $TMPWORKINGDIRECTORY/lua/results/aptget-command.result
+testscriptoutput "Scripts::AptGet::DistUpgrade" "Scripts::AptGet::DistUpgrade called" cat $TMPWORKINGDIRECTORY/lua/results/aptget-distupgrade.result
+testscriptoutput "Scripts::Acquire::Archive::Done" "Scripts::Acquire::Archive::Done called" cat $TMPWORKINGDIRECTORY/lua/results/acquire-archive-done.result
+testscriptoutput "Scripts::PM::Pre" "Scripts::PM::Pre called" cat $TMPWORKINGDIRECTORY/lua/results/pm-pre.result
+testscriptoutput "Scripts::PM::Post" "Scripts::PM::Post called" cat $TMPWORKINGDIRECTORY/lua/results/pm-post.result
diff --git a/apt/test/integration/test-apt-rpm-bash-scripts-simple b/apt/test/integration/test-apt-rpm-bash-scripts-simple
new file mode 100755
index 0000000..918ca94
--- /dev/null
+++ b/apt/test/integration/test-apt-rpm-bash-scripts-simple
@@ -0,0 +1,21 @@
+#!/bin/bash
+set -e
+
+TESTDIR=$(readlink -f $(dirname $0))
+. $TESTDIR/framework
+
+setupenvironment
+
+createbashscript "RPM::Pre-Invoke" "rpm-pre-invoke"
+createbashscript "RPM::Pre-Install-Pkgs" "rpm-pre-install-pkgs"
+createbashscript "RPM::Post-Invoke" "rpm-post-invoke"
+
+buildpackage "simple-package"
+
+testpkgnotinstalled "simple-package"
+aptgetinstallpackage "simple-package" "1" "alt1" "$(getarchitecture)"
+testpkginstalled "simple-package"
+
+testscriptoutput "RPM::Pre-Invoke" "RPM::Pre-Invoke called" cat $TMPWORKINGDIRECTORY/bash/results/rpm-pre-invoke.result
+testscriptoutput "RPM::Pre-Install-Pkgs" "RPM::Pre-Install-Pkgs called" cat $TMPWORKINGDIRECTORY/bash/results/rpm-pre-install-pkgs.result
+testscriptoutput "RPM::Post-Invoke" "RPM::Post-Invoke called" cat $TMPWORKINGDIRECTORY/bash/results/rpm-post-invoke.result
--
2.24.0
^ permalink raw reply [flat|nested] 84+ messages in thread
* [devel] [PATCH for apt 36/38] Add http and https methods tests
2019-12-10 15:23 [devel] [PATCH for apt 00/38] Various fixes for Apt and basic integration test suite Aleksei Nikiforov
` (34 preceding siblings ...)
2019-12-10 15:23 ` [devel] [PATCH for apt 35/38] Add basic tests to ensure that lua and rpm scripts are called Aleksei Nikiforov
@ 2019-12-10 15:23 ` Aleksei Nikiforov
2019-12-10 15:23 ` [devel] [PATCH for apt 37/38] Enable integration test suite during package build Aleksei Nikiforov
2019-12-10 15:23 ` [devel] [PATCH for apt 38/38] Add code coverage support Aleksei Nikiforov
37 siblings, 0 replies; 84+ messages in thread
From: Aleksei Nikiforov @ 2019-12-10 15:23 UTC (permalink / raw)
To: devel; +Cc: Aleksei Nikiforov
---
apt/test/integration/framework | 104 +++++++++++++++++-
apt/test/integration/test-apt-method-http | 29 +++++
apt/test/integration/test-apt-method-https | 56 ++++++++++
...est-apt-method-https-invalid-cert-hostname | 41 +++++++
4 files changed, 229 insertions(+), 1 deletion(-)
create mode 100755 apt/test/integration/test-apt-method-http
create mode 100755 apt/test/integration/test-apt-method-https
create mode 100755 apt/test/integration/test-apt-method-https-invalid-cert-hostname
diff --git a/apt/test/integration/framework b/apt/test/integration/framework
index fa9672d..6098089 100644
--- a/apt/test/integration/framework
+++ b/apt/test/integration/framework
@@ -519,7 +519,7 @@ generaterepository() {
--suite="${GB_REPO_SUITE:-$label}" \
--version="${GB_REPO_VERSION:-$date_s}" \
--topdir="$REPO_DIR" \
- --flat --no-oldhashfile --no-bz2 --no-xz --mapi \
+ --flat --no-oldhashfile --bz2 --xz --mapi \
$dir $comps
if [ -n "$REPO_DATE" ] ; then
@@ -552,3 +552,105 @@ ENDSCRIPT
chmod +x $TMPWORKINGDIRECTORY/bash/scripts/${SCRIPTFILENAME}.sh
}
+
+nginxsetuphttp() {
+ mkdir -p $TMPWORKINGDIRECTORY/nginx ||:
+ mkdir -p $TMPWORKINGDIRECTORY/nginx/tmp ||:
+
+cat >> $TMPWORKINGDIRECTORY/nginx/nginx.conf << ENDCONFIG
+worker_processes 1;
+error_log $TMPWORKINGDIRECTORY/nginx/error.log;
+daemon off;
+pid $TMPWORKINGDIRECTORY/nginx/nginx.pid;
+
+events {
+ worker_connections 1024;
+}
+
+http {
+ client_body_temp_path $TMPWORKINGDIRECTORY/nginx/tmp/client_body;
+ fastcgi_temp_path $TMPWORKINGDIRECTORY/nginx/tmp/fastcgi_temp;
+ proxy_temp_path $TMPWORKINGDIRECTORY/nginx/tmp/proxy_temp;
+ scgi_temp_path $TMPWORKINGDIRECTORY/nginx/tmp/scgi_temp;
+ uwsgi_temp_path $TMPWORKINGDIRECTORY/nginx/tmp/uwsgi_temp;
+
+ include /etc/nginx/mime.types;
+ default_type application/octet-stream;
+
+ sendfile on;
+
+ keepalive_timeout 65;
+
+ ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
+ ssl_prefer_server_ciphers on;
+ access_log $TMPWORKINGDIRECTORY/nginx/http.access.log;
+ error_log $TMPWORKINGDIRECTORY/nginx/http.error.log;
+
+ server {
+ listen 8080;
+ server_name localhost localhost.localdomain;
+
+ location / {
+ root $TMPWORKINGDIRECTORY/nginx/repo;
+ autoindex on;
+ }
+ }
+}
+ENDCONFIG
+}
+
+nginxsetuphttps() {
+ mkdir -p $TMPWORKINGDIRECTORY/nginx ||:
+ mkdir -p $TMPWORKINGDIRECTORY/nginx/tmp ||:
+
+ cat >> $TMPWORKINGDIRECTORY/nginx/nginx.conf << ENDCONFIG
+worker_processes 1;
+error_log $TMPWORKINGDIRECTORY/nginx/error.log;
+daemon off;
+pid $TMPWORKINGDIRECTORY/nginx/nginx.pid;
+
+events {
+ worker_connections 1024;
+}
+
+http {
+ client_body_temp_path $TMPWORKINGDIRECTORY/nginx/tmp/client_body;
+ fastcgi_temp_path $TMPWORKINGDIRECTORY/nginx/tmp/fastcgi_temp;
+ proxy_temp_path $TMPWORKINGDIRECTORY/nginx/tmp/proxy_temp;
+ scgi_temp_path $TMPWORKINGDIRECTORY/nginx/tmp/scgi_temp;
+ uwsgi_temp_path $TMPWORKINGDIRECTORY/nginx/tmp/uwsgi_temp;
+
+ include /etc/nginx/mime.types;
+ default_type application/octet-stream;
+
+ sendfile on;
+
+ keepalive_timeout 65;
+
+ ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
+ ssl_prefer_server_ciphers on;
+ access_log $TMPWORKINGDIRECTORY/nginx/http.access.log;
+ error_log $TMPWORKINGDIRECTORY/nginx/http.error.log;
+
+ server {
+ listen 8080;
+ server_name localhost localhost.localdomain;
+
+ ssl_certificate $TMPWORKINGDIRECTORY/nginx/cert.crt;
+ ssl_certificate_key $TMPWORKINGDIRECTORY/nginx/cert.key;
+
+ ssl on;
+
+ ssl_session_cache builtin:1000 shared:SSL:10m;
+ ssl_protocols TLSv1.2;
+ ssl_ciphers HIGH:!aNULL:!eNULL:!EXPORT:!CAMELLIA:!DES:!MD5:!PSK:!RC4;
+ ssl_prefer_server_ciphers on;
+
+ location / {
+ root $TMPWORKINGDIRECTORY/nginx/repo;
+ autoindex on;
+ }
+ }
+}
+ENDCONFIG
+}
diff --git a/apt/test/integration/test-apt-method-http b/apt/test/integration/test-apt-method-http
new file mode 100755
index 0000000..0872c99
--- /dev/null
+++ b/apt/test/integration/test-apt-method-http
@@ -0,0 +1,29 @@
+#!/bin/bash
+set -e
+
+TESTDIR=$(readlink -f $(dirname $0))
+. $TESTDIR/framework
+
+setupenvironment
+
+nginxsetuphttp
+
+buildpackage "simple-package"
+
+generaterepository "$TMPWORKINGDIRECTORY/usr/src/RPM/RPMS" "$TMPWORKINGDIRECTORY/nginx/repo"
+
+cat > $TMPWORKINGDIRECTORY/rootdir/etc/apt/sources.list << END
+rpm http://localhost:8080/ $(getarchitecture) apt-tests
+rpm http://localhost:8080/ noarch apt-tests
+END
+
+/usr/sbin/nginx -c $TMPWORKINGDIRECTORY/nginx/nginx.conf -p $TMPWORKINGDIRECTORY &>> $TMPWORKINGDIRECTORY/nginx/process-stderr.log &
+NGINXPID=$!
+
+addtrap 'prefix' "kill -SIGTERM $NGINXPID; [ \"$EXIT_CODE\" = '0' ] || cat $TMPWORKINGDIRECTORY/nginx/process-stderr.log;"
+
+testsuccess aptget update
+
+testpkgnotinstalled "simple-package"
+testsuccess aptget install simple-package
+testpkginstalled "simple-package"
diff --git a/apt/test/integration/test-apt-method-https b/apt/test/integration/test-apt-method-https
new file mode 100755
index 0000000..29e4d2d
--- /dev/null
+++ b/apt/test/integration/test-apt-method-https
@@ -0,0 +1,56 @@
+#!/bin/bash
+set -e
+
+TESTDIR=$(readlink -f $(dirname $0))
+. $TESTDIR/framework
+
+setupenvironment
+
+nginxsetuphttps
+
+# generate key
+openssl req -x509 -newkey rsa:4096 -keyout $TMPWORKINGDIRECTORY/nginx/cert.key -out $TMPWORKINGDIRECTORY/nginx/cert.crt -nodes -days 365 -subj '/CN=localhost' &>/dev/null
+
+# add key to apt's config. Also pin the key
+cat > $TMPWORKINGDIRECTORY/rootdir/etc/apt/apt.conf.d/80https.conf << END
+Acquire::https::CaInfo "$TMPWORKINGDIRECTORY/nginx/cert.crt";
+END
+
+cat > $TMPWORKINGDIRECTORY/rootdir/etc/apt/apt.conf.d/81https-pinning.conf << END
+Acquire::https::PinnedCert "$TMPWORKINGDIRECTORY/nginx/cert.crt";
+END
+
+buildpackage "simple-package"
+buildpackage "conflicting-package-one"
+
+generaterepository "$TMPWORKINGDIRECTORY/usr/src/RPM/RPMS" "$TMPWORKINGDIRECTORY/nginx/repo"
+
+cat > $TMPWORKINGDIRECTORY/rootdir/etc/apt/sources.list << END
+rpm https://localhost:8080/ $(getarchitecture) apt-tests
+rpm https://localhost:8080/ noarch apt-tests
+END
+
+/usr/sbin/nginx -c $TMPWORKINGDIRECTORY/nginx/nginx.conf -p $TMPWORKINGDIRECTORY &>> $TMPWORKINGDIRECTORY/nginx/process-stderr.log &
+NGINXPID=$!
+
+addtrap 'prefix' "kill -SIGTERM $NGINXPID; [ \"$EXIT_CODE\" = '0' ] || cat $TMPWORKINGDIRECTORY/nginx/process-stderr.log;"
+
+testsuccess aptget update
+
+testpkgnotinstalled "simple-package"
+testsuccess aptget install simple-package
+testpkginstalled "simple-package"
+
+# generate another key, and pin apt to it. Check key pinning
+msgmsg "Pinning invalid key in apt"
+openssl req -x509 -newkey rsa:4096 -keyout $TMPWORKINGDIRECTORY/nginx/cert.invalid.key -out $TMPWORKINGDIRECTORY/nginx/cert.invalid.crt -nodes -days 365 -subj '/CN=localhost' &>/dev/null
+
+cat > $TMPWORKINGDIRECTORY/rootdir/etc/apt/apt.conf.d/81https-pinning.conf << END
+Acquire::https::PinnedCert "$TMPWORKINGDIRECTORY/nginx/cert.invalid.crt";
+END
+
+testfailure aptget update
+
+testpkgnotinstalled "conflicting-package-one"
+testfailure aptget install conflicting-package-one
+testpkgnotinstalled "conflicting-package-one"
diff --git a/apt/test/integration/test-apt-method-https-invalid-cert-hostname b/apt/test/integration/test-apt-method-https-invalid-cert-hostname
new file mode 100755
index 0000000..33e80b6
--- /dev/null
+++ b/apt/test/integration/test-apt-method-https-invalid-cert-hostname
@@ -0,0 +1,41 @@
+#!/bin/bash
+set -e
+
+TESTDIR=$(readlink -f $(dirname $0))
+. $TESTDIR/framework
+
+setupenvironment
+
+nginxsetuphttps
+
+# generate key
+openssl req -x509 -newkey rsa:4096 -keyout $TMPWORKINGDIRECTORY/nginx/cert.key -out $TMPWORKINGDIRECTORY/nginx/cert.crt -nodes -days 365 -subj '/CN=wronghost' &>/dev/null
+
+# add key to apt's config. Also pin the key
+cat > $TMPWORKINGDIRECTORY/rootdir/etc/apt/apt.conf.d/80https.conf << END
+Acquire::https::CaInfo "$TMPWORKINGDIRECTORY/nginx/cert.crt";
+END
+
+cat > $TMPWORKINGDIRECTORY/rootdir/etc/apt/apt.conf.d/81https-pinning.conf << END
+Acquire::https::PinnedCert "$TMPWORKINGDIRECTORY/nginx/cert.crt";
+END
+
+buildpackage "simple-package"
+
+generaterepository "$TMPWORKINGDIRECTORY/usr/src/RPM/RPMS" "$TMPWORKINGDIRECTORY/nginx/repo"
+
+cat > $TMPWORKINGDIRECTORY/rootdir/etc/apt/sources.list << END
+rpm https://localhost:8080/ $(getarchitecture) apt-tests
+rpm https://localhost:8080/ noarch apt-tests
+END
+
+/usr/sbin/nginx -c $TMPWORKINGDIRECTORY/nginx/nginx.conf -p $TMPWORKINGDIRECTORY &>> $TMPWORKINGDIRECTORY/nginx/process-stderr.log &
+NGINXPID=$!
+
+addtrap 'prefix' "kill -SIGTERM $NGINXPID; [ \"$EXIT_CODE\" = '0' ] || cat $TMPWORKINGDIRECTORY/nginx/process-stderr.log;"
+
+testfailure aptget update
+
+testpkgnotinstalled "conflicting-package-one"
+testfailure aptget install conflicting-package-one
+testpkgnotinstalled "conflicting-package-one"
--
2.24.0
^ permalink raw reply [flat|nested] 84+ messages in thread
* [devel] [PATCH for apt 37/38] Enable integration test suite during package build
2019-12-10 15:23 [devel] [PATCH for apt 00/38] Various fixes for Apt and basic integration test suite Aleksei Nikiforov
` (35 preceding siblings ...)
2019-12-10 15:23 ` [devel] [PATCH for apt 36/38] Add http and https methods tests Aleksei Nikiforov
@ 2019-12-10 15:23 ` Aleksei Nikiforov
2019-12-10 15:23 ` [devel] [PATCH for apt 38/38] Add code coverage support Aleksei Nikiforov
37 siblings, 0 replies; 84+ messages in thread
From: Aleksei Nikiforov @ 2019-12-10 15:23 UTC (permalink / raw)
To: devel; +Cc: Aleksei Nikiforov
---
apt.spec | 36 +++++++++++++++++++++++++++++++++++-
1 file changed, 35 insertions(+), 1 deletion(-)
diff --git a/apt.spec b/apt.spec
index 5291a4a..7c91f70 100644
--- a/apt.spec
+++ b/apt.spec
@@ -1,3 +1,5 @@
+%def_enable check
+
Name: apt
Version: 0.5.15lorg2
Release: alt71
@@ -56,6 +58,13 @@ BuildPreReq: liblua5.3-devel
BuildRequires: bzlib-devel cvs docbook-utils gcc-c++ libreadline-devel librpm-devel setproctitle-devel zlib-devel
BuildRequires: libgnutls-devel
+# dependencies of tests
+%if_enabled check
+BuildRequires: /usr/bin/genbasedir
+BuildRequires: /usr/sbin/nginx
+BuildRequires: /usr/bin/openssl
+%endif
+
%package -n libapt
Summary: APT's core libraries
Group: System/Libraries
@@ -92,6 +101,12 @@ Summary(ru_RU.UTF-8): Поддержка метода https для APT
Group: Other
Requires: %name = %EVR
+%package tests
+Summary: Test suite for APT
+Summary(ru_RU.UTF-8): Набор тестов для APT
+Group: Other
+Requires: %name = %EVR
+
# {{{ descriptions
%define risk_usage_en This package is still under development.
@@ -153,6 +168,9 @@ This package contains method 'https' for APT.
%risk_usage_en
+%description tests
+This package contains test suite for APT.
+
%description -n libapt -l ru_RU.UTF-8
В этом пакете находится библиотеки управления пакетами
из комплекта APT. В отличие от оригинальной версии для Debian, этот
@@ -195,7 +213,8 @@ This package contains method 'https' for APT.
%risk_usage
-# }}}
+%description tests -l ru_RU.UTF-8
+В этом пакете находится набор тестов для APT.
%prep
%setup
@@ -245,6 +264,7 @@ mkdir -p %buildroot%_sysconfdir/%name/{%name.conf,sources.list,vendors.list,pref
mkdir -p %buildroot%_libdir/%name/scripts
mkdir -p %buildroot%_localstatedir/%name/{lists/partial,prefetch}
mkdir -p %buildroot%_cachedir/%name/{archives/partial,gen{pkg,src}list}
+mkdir -p %buildroot%_libdir/%name/tests
%makeinstall includedir=%buildroot%_includedir/apt-pkg
@@ -272,17 +292,28 @@ find %buildroot%_includedir -type f -name '*.h' |while read f; do
EOF
done
+cp -r test/integration %buildroot%_libdir/%name/tests/
+
%find_lang %name
unset RPM_PYTHON
%set_verify_elf_method strict
+%check
+# run tests multiple times to make sure no tests are randomly failing
+pushd test/integration
+for i in $(seq 1 10) ; do
+LD_LIBRARY_PATH=%buildroot%_libdir PATH=$PATH:%buildroot%_bindir METHODSDIR=%buildroot%_libdir/apt/methods ./run-tests
+done
+popd
+
%files -f %name.lang
%_bindir/apt-*
%_libdir/%name
%exclude %_libdir/%name/methods/rsync
%exclude %_libdir/%name/methods/https
+%exclude %_libdir/%name/tests
%dir %_sysconfdir/%name
%config(noreplace) %_sysconfdir/%name/%name.conf
%dir %_sysconfdir/%name/*.d
@@ -319,6 +350,9 @@ unset RPM_PYTHON
%dir %_libdir/%name/methods
%_libdir/%name/methods/https
+%files tests
+%_libdir/%name/tests
+
%changelog
* Mon Jul 22 2019 Aleksei Nikiforov <darktemplar@altlinux.org> 0.5.15lorg2-alt71
- Introduced new function ListUpdate for improved packagekit support.
--
2.24.0
^ permalink raw reply [flat|nested] 84+ messages in thread
* [devel] [PATCH for apt 38/38] Add code coverage support
2019-12-10 15:23 [devel] [PATCH for apt 00/38] Various fixes for Apt and basic integration test suite Aleksei Nikiforov
` (36 preceding siblings ...)
2019-12-10 15:23 ` [devel] [PATCH for apt 37/38] Enable integration test suite during package build Aleksei Nikiforov
@ 2019-12-10 15:23 ` Aleksei Nikiforov
37 siblings, 0 replies; 84+ messages in thread
From: Aleksei Nikiforov @ 2019-12-10 15:23 UTC (permalink / raw)
To: devel; +Cc: Aleksei Nikiforov
---
apt.spec | 28 +++++++++++++++++++++++++++-
apt/apt-pkg/Makefile.am | 10 +++++++---
apt/apt-pkg/acquire-method.cc | 9 +++++++--
apt/apt-pkg/acquire.cc | 5 ++++-
apt/apt-pkg/contrib/cdromutl.cc | 15 ++++++++++++---
apt/apt-pkg/defs.h | 18 ++++++++++++++++++
apt/apt-pkg/rpm/rpmlistparser.cc | 2 ++
apt/apt-pkg/rpm/rpmpm.cc | 21 ++++++++++++++++-----
apt/cmdline/Makefile.am | 9 +++++++--
apt/cmdline/apt-get.cc | 6 ++++++
apt/configure.in | 2 ++
apt/methods/Makefile.am | 7 ++++++-
apt/methods/ftp.cc | 6 +++++-
apt/methods/http.cc | 10 ++++++++--
apt/methods/rsh.cc | 6 +++++-
apt/methods/rsync.cc | 2 ++
apt/tools/Makefile.am | 8 ++++++--
17 files changed, 140 insertions(+), 24 deletions(-)
create mode 100644 apt/apt-pkg/defs.h
diff --git a/apt.spec b/apt.spec
index 7c91f70..e3e3384 100644
--- a/apt.spec
+++ b/apt.spec
@@ -1,4 +1,5 @@
%def_enable check
+%def_disable coverage
Name: apt
Version: 0.5.15lorg2
@@ -57,6 +58,11 @@ BuildPreReq: liblua5.3-devel
BuildRequires: bzlib-devel cvs docbook-utils gcc-c++ libreadline-devel librpm-devel setproctitle-devel zlib-devel
BuildRequires: libgnutls-devel
+BuildRequires: autoconf-archive
+
+%if_enabled coverage
+BuildRequires: lcov
+%endif
# dependencies of tests
%if_enabled check
@@ -246,12 +252,21 @@ sed -i 's, > /dev/null 2>&1,,' buildlib/tools.m4
# Add trivial arch translation.
printf '%_target_cpu\t%_target_cpu' >> buildlib/archtable
+%if_enabled coverage
+%remove_optflags -O2
+%add_optflags -DENABLE_COVERAGE_GCOV
+%endif
+
%autoreconf
%add_optflags -DAPTRPM_ID=\\\"%name-%{?epoch:%epoch:}%version-%release%{?disttag::%disttag}.%_target_cpu\\\"
%ifarch %e2k
%add_optflags -std=c++14
%endif
-%configure --includedir=%_includedir/apt-pkg %{subst_enable static}
+%configure \
+ --includedir=%_includedir/apt-pkg \
+ %{subst_enable static} \
+ %{?_enable_coverage: --enable-code-coverage} \
+ %nil
# Probably this obsolete now?
find -type f -print0 |
@@ -308,6 +323,12 @@ LD_LIBRARY_PATH=%buildroot%_libdir PATH=$PATH:%buildroot%_bindir METHODSDIR=%bui
done
popd
+%if_enabled coverage
+find . -name '*.cc' -o -name '*.h' -o -name '*.c' | while read file ; do gcov $file ; done
+lcov --capture --directory . --exclude '/usr/include/*' --output-file %name.info
+genhtml %name.info --output-directory %name-coverage-output
+%endif
+
%files -f %name.lang
%_bindir/apt-*
%_libdir/%name
@@ -351,6 +372,11 @@ popd
%_libdir/%name/methods/https
%files tests
+%if_enabled coverage
+%if_enabled check
+%doc %name-coverage-output
+%endif
+%endif
%_libdir/%name/tests
%changelog
diff --git a/apt/apt-pkg/Makefile.am b/apt/apt-pkg/Makefile.am
index 4c0d234..bc6b717 100644
--- a/apt/apt-pkg/Makefile.am
+++ b/apt/apt-pkg/Makefile.am
@@ -1,10 +1,13 @@
+include $(top_srcdir)/aminclude_static.am
lib_LTLIBRARIES = libapt-pkg.la
-libapt_pkg_la_LIBADD = @RPMLIBS@
+libapt_pkg_la_LIBADD = @RPMLIBS@ $(CODE_COVERAGE_LIBS)
libapt_pkg_la_LDFLAGS = -version-info 9:0:1 -release @GLIBC_VER@-@LIBSTDCPP_VER@@NO_CXX11ABI_SUFFIX@@FILE_OFFSET_BITS_SUFFIX@
-AM_CPPFLAGS = -DLIBDIR=\"$(libdir)\" -D_RPM_4_4_COMPAT
+AM_CFLAGS = $(CODE_COVERAGE_CFLAGS)
+AM_CXXFLAGS = $(CODE_COVERAGE_CXXFLAGS)
+AM_CPPFLAGS = -DLIBDIR=\"$(libdir)\" -D_RPM_4_4_COMPAT $(CODE_COVERAGE_CPPFLAGS)
if WITH_LUA
libapt_pkg_la_LIBADD += -llua
@@ -72,6 +75,7 @@ libapt_pkg_la_SOURCES = \
cacheiterators.h \
clean.cc \
clean.h \
+ defs.h \
depcache.cc \
depcache.h \
indexfile.cc \
@@ -152,7 +156,7 @@ $(top_builddir)/include/%: rpm/%
@$(mkinstalldirs) $(top_builddir)/include/apt-pkg
cp -f -p $< $@
-clean-local:
+clean-local: code-coverage-clean
rm -f $(PRIVCOPYHEADERS)
rm -rf $(top_builddir)/include/apt-pkg
diff --git a/apt/apt-pkg/acquire-method.cc b/apt/apt-pkg/acquire-method.cc
index 3b5c580..9296e62 100644
--- a/apt/apt-pkg/acquire-method.cc
+++ b/apt/apt-pkg/acquire-method.cc
@@ -18,6 +18,7 @@
#pragma implementation "apt-pkg/acquire-method.h"
#endif
#include <config.h>
+#include <apt-pkg/defs.h>
#include <apt-pkg/acquire-method.h>
#include <apt-pkg/error.h>
@@ -140,8 +141,10 @@ void pkgAcqMethod::Fail(const char *Why, bool Transient)
/* */
void pkgAcqMethod::URIStart(FetchResult &Res)
{
- if (Queue == 0)
+ if (Queue == 0) {
+ GCOV_DUMP;
abort();
+ }
ostringstream s;
@@ -169,8 +172,10 @@ void pkgAcqMethod::URIStart(FetchResult &Res)
/* */
void pkgAcqMethod::URIDone(FetchResult &Res, FetchResult *Alt)
{
- if (Queue == 0)
+ if (Queue == 0) {
+ GCOV_DUMP;
abort();
+ }
ostringstream s;
diff --git a/apt/apt-pkg/acquire.cc b/apt/apt-pkg/acquire.cc
index 79784af..dec9ee7 100644
--- a/apt/apt-pkg/acquire.cc
+++ b/apt/apt-pkg/acquire.cc
@@ -16,6 +16,7 @@
#pragma implementation "apt-pkg/acquire.h"
#endif
#include <config.h>
+#include <apt-pkg/defs.h>
#include <apt-pkg/acquire.h>
#include <apt-pkg/acquire-item.h>
@@ -143,8 +144,10 @@ void pkgAcquire::Add(Worker *Work)
it cant.. */
void pkgAcquire::Remove(Worker *Work)
{
- if (Running == true)
+ if (Running == true) {
+ GCOV_DUMP;
abort();
+ }
Worker **I = &Workers;
for (; *I != 0;)
diff --git a/apt/apt-pkg/contrib/cdromutl.cc b/apt/apt-pkg/contrib/cdromutl.cc
index 139be84..bd10e02 100644
--- a/apt/apt-pkg/contrib/cdromutl.cc
+++ b/apt/apt-pkg/contrib/cdromutl.cc
@@ -15,6 +15,7 @@
// CNC:2004-03-19
#include <config.h>
+#include <apt-pkg/defs.h>
#include <apt-pkg/luaiface.h>
#include <apt-pkg/cdromutl.h>
@@ -95,8 +96,11 @@ bool UnmountCdrom(string Path)
if (_config->Exists("Acquire::cdrom::"+Path+"::UMount") == true)
{
- if (system(_config->Find("Acquire::cdrom::"+Path+"::UMount").c_str()) != 0)
+ if (system(_config->Find("Acquire::cdrom::"+Path+"::UMount").c_str()) != 0) {
+ GCOV_DUMP;
_exit(100);
+ }
+ GCOV_DUMP;
_exit(0);
}
else
@@ -111,8 +115,10 @@ bool UnmountCdrom(string Path)
if (MntDir[MntDir.length() - 1] != '/')
MntDir += '/';
if ( Path == MntDir )
- if ((strcmp ("subfs", mnt->mnt_type) == 0) || (strcmp ("supermount", mnt->mnt_type) == 0))
+ if ((strcmp ("subfs", mnt->mnt_type) == 0) || (strcmp ("supermount", mnt->mnt_type) == 0)) {
+ GCOV_DUMP;
_exit(0);
+ }
}
endmntent (f);
}
@@ -159,8 +165,11 @@ bool MountCdrom(string Path)
if (_config->Exists("Acquire::cdrom::"+Path+"::Mount") == true)
{
- if (system(_config->Find("Acquire::cdrom::"+Path+"::Mount").c_str()) != 0)
+ if (system(_config->Find("Acquire::cdrom::"+Path+"::Mount").c_str()) != 0) {
+ GCOV_DUMP;
_exit(100);
+ }
+ GCOV_DUMP;
_exit(0);
}
else
diff --git a/apt/apt-pkg/defs.h b/apt/apt-pkg/defs.h
new file mode 100644
index 0000000..33ed490
--- /dev/null
+++ b/apt/apt-pkg/defs.h
@@ -0,0 +1,18 @@
+#ifndef APT_DEFS_H
+#define APT_DEFS_H
+
+/* coverage support */
+#ifdef ENABLE_COVERAGE_GCOV
+#ifdef __cplusplus
+extern "C" {
+#endif
+extern void __gcov_dump(void);
+#ifdef __cplusplus
+}
+#endif
+#define GCOV_DUMP __gcov_dump()
+#else
+#define GCOV_DUMP
+#endif
+
+#endif /* APT_DEFS_H */
diff --git a/apt/apt-pkg/rpm/rpmlistparser.cc b/apt/apt-pkg/rpm/rpmlistparser.cc
index 9b2e9ad..6029520 100644
--- a/apt/apt-pkg/rpm/rpmlistparser.cc
+++ b/apt/apt-pkg/rpm/rpmlistparser.cc
@@ -12,6 +12,7 @@
// Include Files
#include <config.h>
+#include <apt-pkg/defs.h>
#ifdef HAVE_RPM
@@ -98,6 +99,7 @@ std::experimental::optional<map_ptrloc> rpmListParser::UniqFindTagWrite(int Tag)
Stop = Start + strlen(Start);
} else {
cout << "oh shit, not handled:"<<type<<" Package:"<<Package()<<endl;
+ GCOV_DUMP;
abort();
}
diff --git a/apt/apt-pkg/rpm/rpmpm.cc b/apt/apt-pkg/rpm/rpmpm.cc
index d2d3120..e2be6b9 100644
--- a/apt/apt-pkg/rpm/rpmpm.cc
+++ b/apt/apt-pkg/rpm/rpmpm.cc
@@ -12,6 +12,7 @@
#endif
#include <config.h>
+#include <apt-pkg/defs.h>
#ifdef HAVE_RPM
@@ -164,8 +165,10 @@ bool pkgRPMPM::RunScripts(const char *Cnf)
pid_t Process = ExecFork();
if (Process == 0)
{
- if (chdir("/tmp") != 0)
+ if (chdir("/tmp") != 0) {
+ GCOV_DUMP;
_exit(100);
+ }
const char *Args[4];
Args[0] = "/bin/sh";
@@ -627,23 +630,31 @@ bool pkgRPMExtPM::ExecRPM(Item::RPMOps op, const std::vector<apt_item> &files)
// This is the child
if (Child == 0)
{
- if (chdir(_config->FindDir("RPM::Run-Directory","/").c_str()) != 0)
+ if (chdir(_config->FindDir("RPM::Run-Directory","/").c_str()) != 0) {
+ GCOV_DUMP;
_exit(100);
+ }
if (_config->FindB("RPM::FlushSTDIN",true) == true)
{
int Flags,dummy;
- if ((Flags = fcntl(STDIN_FILENO,F_GETFL)) < 0)
+ if ((Flags = fcntl(STDIN_FILENO,F_GETFL)) < 0) {
+ GCOV_DUMP;
_exit(100);
+ }
// Discard everything in stdin before forking dpkg
- if (fcntl(STDIN_FILENO,F_SETFL,Flags | O_NONBLOCK) < 0)
+ if (fcntl(STDIN_FILENO,F_SETFL,Flags | O_NONBLOCK) < 0) {
+ GCOV_DUMP;
_exit(100);
+ }
while (read(STDIN_FILENO,&dummy,1) == 1);
- if (fcntl(STDIN_FILENO,F_SETFL,Flags & (~(long)O_NONBLOCK)) < 0)
+ if (fcntl(STDIN_FILENO,F_SETFL,Flags & (~(long)O_NONBLOCK)) < 0) {
+ GCOV_DUMP;
_exit(100);
+ }
}
execvp(Args[0],(char **)Args);
diff --git a/apt/cmdline/Makefile.am b/apt/cmdline/Makefile.am
index ad9b761..c030d90 100644
--- a/apt/cmdline/Makefile.am
+++ b/apt/cmdline/Makefile.am
@@ -1,3 +1,8 @@
+include $(top_srcdir)/aminclude_static.am
+
+AM_CFLAGS = $(CODE_COVERAGE_CFLAGS)
+AM_CXXFLAGS = $(CODE_COVERAGE_CXXFLAGS)
+AM_CPPFLAGS = $(CODE_COVERAGE_CPPFLAGS)
EXTRA_DIST = indexcopy.cc indexcopy.h
@@ -10,14 +15,14 @@ if COMPILE_STATIC
bin_PROGRAMS += apt-get-static apt-cache-static apt-cdrom-static
endif
-LDADD = ../apt-pkg/libapt-pkg.la $(RPMLIBS)
+LDADD = ../apt-pkg/libapt-pkg.la $(RPMLIBS) $(CODE_COVERAGE_LIBS)
apt_get_SOURCES = apt-get.cc acqprogress.cc acqprogress.h
apt_cache_SOURCES = apt-cache.cc
apt_shell_SOURCES = apt-shell.cc acqprogress.cc acqprogress.h
apt_shell_LDADD = $(LDADD) -lreadline
apt_pipe_SOURCES = $(apt_shell_SOURCES) apt-pipe.c
-apt_pipe_CPPFLAGS = -DAPT_PIPE
+apt_pipe_CPPFLAGS = -DAPT_PIPE $(CODE_COVERAGE_CPPFLAGS)
apt_pipe_LDADD = $(LDADD) -lsetproctitle
apt_config_SOURCES = apt-config.cc
apt_cdrom_SOURCES = apt-cdrom.cc rpmindexcopy.cc rpmindexcopy.h
diff --git a/apt/cmdline/apt-get.cc b/apt/cmdline/apt-get.cc
index 5484b95..5675973 100644
--- a/apt/cmdline/apt-get.cc
+++ b/apt/cmdline/apt-get.cc
@@ -28,6 +28,7 @@
/*}}}*/
// Include Files /*{{{*/
#include <config.h>
+#include <apt-pkg/defs.h>
#include <apt-pkg/error.h>
#include <apt-pkg/cmndline.h>
@@ -2090,6 +2091,7 @@ bool DoSource(CommandLine &CmdL)
if (system(S) != 0)
{
fprintf(stderr,_("Build command '%s' failed.\n"),S);
+ GCOV_DUMP;
_exit(1);
}
}
@@ -2102,6 +2104,7 @@ bool DoSource(CommandLine &CmdL)
if (system(S) != 0)
{
fprintf(stderr,_("Unpack command '%s' failed.\n"),S);
+ GCOV_DUMP;
_exit(1);
}
}
@@ -2124,6 +2127,7 @@ bool DoSource(CommandLine &CmdL)
if (system(S) != 0)
{
fprintf(stderr,_("Unpack command '%s' failed.\n"),S);
+ GCOV_DUMP;
_exit(1);
}
}
@@ -2141,12 +2145,14 @@ bool DoSource(CommandLine &CmdL)
if (system(S) != 0)
{
fprintf(stderr,_("Build command '%s' failed.\n"),S);
+ GCOV_DUMP;
_exit(1);
}
}
#endif
}
+ GCOV_DUMP;
_exit(0);
}
diff --git a/apt/configure.in b/apt/configure.in
index 10178c3..c8848b3 100644
--- a/apt/configure.in
+++ b/apt/configure.in
@@ -9,6 +9,8 @@ AC_CONFIG_SRCDIR([configure.in])
AM_INIT_AUTOMAKE([foreign subdir-objects dist-bzip2 1.7])
AM_MAINTAINER_MODE
+AX_CODE_COVERAGE
+
AC_CONFIG_HEADER([include/config.h:buildlib/config.h.in])
dnl Check our C compiler
diff --git a/apt/methods/Makefile.am b/apt/methods/Makefile.am
index 2d3510c..d29097f 100644
--- a/apt/methods/Makefile.am
+++ b/apt/methods/Makefile.am
@@ -1,8 +1,13 @@
+include $(top_srcdir)/aminclude_static.am
+
+AM_CFLAGS = $(CODE_COVERAGE_CFLAGS)
+AM_CXXFLAGS = $(CODE_COVERAGE_CXXFLAGS)
+AM_CPPFLAGS = $(CODE_COVERAGE_CPPFLAGS)
methodsdir=${libdir}/apt/methods
methods_PROGRAMS = cdrom copy file ftp gpg gzip bzip2 http https rsh ssh rsync
-LDADD = ../apt-pkg/libapt-pkg.la
+LDADD = ../apt-pkg/libapt-pkg.la $(CODE_COVERAGE_LIBS)
cdrom_SOURCES = cdrom.cc
copy_SOURCES = copy.cc
diff --git a/apt/methods/ftp.cc b/apt/methods/ftp.cc
index e79e70d..268f8d3 100644
--- a/apt/methods/ftp.cc
+++ b/apt/methods/ftp.cc
@@ -15,6 +15,7 @@
/*}}}*/
// Include Files /*{{{*/
#include <config.h>
+#include <apt-pkg/defs.h>
#include <apt-pkg/fileutl.h>
#include <apt-pkg/acquire-method.h>
@@ -936,8 +937,10 @@ FtpMethod::FtpMethod() : pkgAcqMethod("1.0",SendConfig)
resume behavoir on user abort */
void FtpMethod::SigTerm(int)
{
- if (FailFd == -1)
+ if (FailFd == -1) {
+ GCOV_DUMP;
_exit(100);
+ }
close(FailFd);
// Timestamp
@@ -946,6 +949,7 @@ void FtpMethod::SigTerm(int)
UBuf.modtime = FailTime;
utime(FailFile.c_str(),&UBuf);
+ GCOV_DUMP;
_exit(100);
}
/*}}}*/
diff --git a/apt/methods/http.cc b/apt/methods/http.cc
index 9302495..5c6f2e2 100644
--- a/apt/methods/http.cc
+++ b/apt/methods/http.cc
@@ -25,6 +25,7 @@
/*}}}*/
// Include Files /*{{{*/
#include <config.h>
+#include <apt-pkg/defs.h>
#include <apt-pkg/fileutl.h>
#include <apt-pkg/acquire-method.h>
@@ -628,8 +629,10 @@ void HttpMethod::SendReq(FetchItem *Itm,CircleBuf &Out)
string ProperHost = Uri.Address.to_string();
// Just in case.
- if (Itm->Uri.length() >= sizeof(Buf))
+ if (Itm->Uri.length() >= sizeof(Buf)) {
+ GCOV_DUMP;
abort();
+ }
/* Build the request. We include a keep-alive header only for non-proxy
requests. This is to tweak old http/1.0 servers that do support keep-alive
@@ -1034,8 +1037,10 @@ int HttpMethod::DealWithHeaders(FetchResult &Res,ServerState *Srv)
resume behavoir on user abort */
void HttpMethod::SigTerm(int)
{
- if (FailFd == -1)
+ if (FailFd == -1) {
+ GCOV_DUMP;
_exit(100);
+ }
close(FailFd);
// Timestamp
@@ -1044,6 +1049,7 @@ void HttpMethod::SigTerm(int)
UBuf.modtime = FailTime;
utime(FailFile.c_str(),&UBuf);
+ GCOV_DUMP;
_exit(100);
}
/*}}}*/
diff --git a/apt/methods/rsh.cc b/apt/methods/rsh.cc
index 2371e4a..0acb3d8 100644
--- a/apt/methods/rsh.cc
+++ b/apt/methods/rsh.cc
@@ -11,6 +11,7 @@
/*}}}*/
// Include Files /*{{{*/
#include <config.h>
+#include <apt-pkg/defs.h>
#include "rsh.h"
#include <apt-pkg/error.h>
@@ -389,8 +390,10 @@ bool RSHMethod::Configuration(const string &Message)
/* */
void RSHMethod::SigTerm(int sig)
{
- if (FailFd == -1)
+ if (FailFd == -1) {
+ GCOV_DUMP;
_exit(100);
+ }
close(FailFd);
// Timestamp
@@ -399,6 +402,7 @@ void RSHMethod::SigTerm(int sig)
UBuf.modtime = FailTime;
utime(FailFile.c_str(),&UBuf);
+ GCOV_DUMP;
_exit(100);
}
/*}}}*/
diff --git a/apt/methods/rsync.cc b/apt/methods/rsync.cc
index f28bb5a..0b974ea 100644
--- a/apt/methods/rsync.cc
+++ b/apt/methods/rsync.cc
@@ -8,6 +8,7 @@ RSYNC Aquire Method - This is the RSYNC aquire method for APT.
/*}}}*/
// Include Files /*{{{*/
#include <config.h>
+#include <apt-pkg/defs.h>
#include <apt-pkg/fileutl.h>
#include <apt-pkg/acquire-method.h>
@@ -482,6 +483,7 @@ RsyncMethod::RsyncMethod() : pkgAcqMethod("1.0",SendConfig),
void RsyncMethod::SigTerm(int)
{
delete server;
+ GCOV_DUMP;
_exit(100);
}
/*}}}*/
diff --git a/apt/tools/Makefile.am b/apt/tools/Makefile.am
index b0eab54..e661c8a 100644
--- a/apt/tools/Makefile.am
+++ b/apt/tools/Makefile.am
@@ -1,11 +1,15 @@
+include $(top_srcdir)/aminclude_static.am
+
+AM_CFLAGS = $(CODE_COVERAGE_CFLAGS)
+AM_CXXFLAGS = $(CODE_COVERAGE_CXXFLAGS)
bin_PROGRAMS = genpkglist gensrclist countpkglist
bin_SCRIPTS = genbasedir
EXTRA_DIST = genbasedir
-AM_CPPFLAGS = -D_RPM_4_4_COMPAT
-LDADD = ../apt-pkg/libapt-pkg.la $(RPMLIBS)
+AM_CPPFLAGS = -D_RPM_4_4_COMPAT $(CODE_COVERAGE_CPPFLAGS)
+LDADD = ../apt-pkg/libapt-pkg.la $(RPMLIBS) $(CODE_COVERAGE_LIBS)
genpkglist_SOURCES = genpkglist.cc cached_md5.cc cached_md5.h
gensrclist_SOURCES = gensrclist.cc cached_md5.cc cached_md5.h
--
2.24.0
^ permalink raw reply [flat|nested] 84+ messages in thread