Skip to content

Commit

Permalink
pkg
Browse files Browse the repository at this point in the history
set of packages and categories must be set of strings
  • Loading branch information
tnut committed Mar 20, 2024
1 parent 4e207d1 commit c064525
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 35 deletions.
17 changes: 11 additions & 6 deletions src/cards_info.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,14 @@ Cards_info::Cards_info(const CardsArgumentParser& argParser, const std::string&
std::set<std::string> sortedPackagesList;
std::set<cards::Cache*> binaryList = getBinaryPackageSet();
for ( auto i : binaryList) {
std::string s;
if ( i->sets().size() > 0 )
s = "(" + i->sets() + ") ";
else
std::string s, _s;
if ( i->sets().size() > 0 ) {
for (auto s: i->sets())
_s += s + " ";
s = "(" + _s + ") ";
} else {
s = "(" + i->collection() + ") ";
}
s += i->name() + " ";
s += i->version() + " ";
s += i->description();
Expand All @@ -76,8 +79,10 @@ Cards_info::Cards_info(const CardsArgumentParser& argParser, const std::string&
std::set<std::string> sortedSetList;
std::set<cards::Cache*> binaryList = getBinaryPackageSet();
for ( auto i : binaryList )
if ( i->sets().size() > 0 )
sortedSetList.insert(i->sets());
if ( i->sets().size() > 0 ) {
for ( auto s:i->sets() )
sortedSetList.insert(s);
}
for ( auto i : sortedSetList )
std::cout << i << std::endl;
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/cards_remove.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ Cards_remove::Cards_remove(const std::string& commandName,
}
if ( listOfPackagesToRemove.empty()) {
for (auto j : m_listOfPackages) {
for (auto k : parseDelimitedSetList(j.second.sets()," ")) {
for (auto k : j.second.sets()) {
if ( i == k ) {
PackageToRemove.first = j.first;
PackageToRemove.second=j.second.collection();
Expand Down
8 changes: 4 additions & 4 deletions src/pkg.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,11 @@ std::string Pkg::group()
{
return m_group;
}
void Pkg::sets(const std::string& sets)
void Pkg::sets(const std::set<std::string>& sets)
{
m_sets = sets;
}
std::string Pkg::sets()
std::set<std::string> Pkg::sets()
{
return m_sets;
}
Expand All @@ -97,11 +97,11 @@ std::string Pkg::collection()
{
return m_collection;
}
void Pkg::categories(const std::string& categories)
void Pkg::categories(const std::set<std::string>& categories)
{
m_categories = categories;
}
std::string Pkg::categories()
std::set<std::string> Pkg::categories()
{
return m_categories;
}
Expand Down
12 changes: 6 additions & 6 deletions src/pkg.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ class Pkg

std::string alias();
std::string group();
std::string sets();
std::string collection();
std::string categories();
std::set<std::string> sets();
std::set<std::string> categories();
std::string arch();
std::string license();
std::string signature();
Expand All @@ -44,9 +44,9 @@ class Pkg

void alias(const std::string& alias);
void group(const std::string& group);
void sets(const std::string& sets);
void sets(const std::set<std::string>& sets);
void collection(const std::string& collection);
void categories(const std::string& categories);
void categories(const std::set<std::string>& categories);
void arch(const std::string& arch);
void license(const std::string& license);
void signature(const std::string& signature);
Expand All @@ -66,9 +66,9 @@ class Pkg

std::string m_alias;
std::string m_group;
std::string m_sets;
std::string m_collection;
std::string m_categories;
std::set<std::string> m_sets;
std::set<std::string> m_categories;
std::string m_arch;
std::string m_license;
std::string m_signature;
Expand Down
26 changes: 13 additions & 13 deletions src/pkgdbh.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,8 @@ Pkgdbh::buildDatabase(const bool& progress,
}
return;
}

std::set<std::string> sets;
if (simple) {
cards::Db info;
for ( auto pkgName : m_listOfPackagesNames) {
Expand Down Expand Up @@ -552,15 +554,14 @@ Pkgdbh::buildDatabase(const bool& progress,
/* As a std::set is not always present we cannot
* depen on a found one to break */
if ( attribute[0] == 's' ) {
std::string s;
s = s + " " + attribute.substr(1);
info.sets(s);
sets.insert(attribute.substr(1));
}
if ( attribute[0] == 'r' ) {
info.release(atoi(attribute.substr(1).c_str()));
flags = flags + 8;
}
if ( flags == 15 ) {
info.sets(sets);
m_listOfPackages[pkgName] = info;
break;
}
Expand Down Expand Up @@ -624,16 +625,15 @@ Pkgdbh::buildSimpleDatabase()
parseFile(fileContent,metaFile.c_str());
info.release(1);
info.dependency(false);
std::set<std::string> sets;
m_listOfAlias[i] = i;
for (auto attribute : fileContent) {
if ( attribute[0] == 'c' ) {
std::string s = attribute;
info.collection(s.substr(1));
}
if ( attribute[0] == 's' ) {
std::string s;
s = s + " " + attribute.substr(1);
info.sets(s);
sets.insert(attribute.substr(1));
}
if ( attribute[0] == 'V' ) {
std::string s = attribute;
Expand Down Expand Up @@ -665,8 +665,8 @@ Pkgdbh::buildSimpleDatabase()
if ( s == "d1" )
info.dependency(true);
}

}
info.sets(sets);
m_listOfPackages[i] = info;
}
m_miniDB_Empty=false;
Expand Down Expand Up @@ -704,6 +704,8 @@ void Pkgdbh::buildCompleteDatabase(const bool& silent)
info.install( getEpochModifyTimeFile(metaFileDir) );
std::set<std::pair<std::string,time_t>> dependencies;
std::set<std::string> fileContent;
std::set<std::string> categories;
std::set<std::string> sets;
parseFile(fileContent,metaFile.c_str());
info.release(1);
info.dependency(false);
Expand Down Expand Up @@ -753,9 +755,7 @@ void Pkgdbh::buildCompleteDatabase(const bool& silent)
info.collection(attribute.substr(1));
}
if ( attribute[0] == 's' ) {
std::string s;
s = s + " " + attribute.substr(1);
info.sets(s);
sets.insert(attribute.substr(1));
}
if ( attribute[0] == 'g' ) {
std::string s = attribute;
Expand All @@ -777,9 +777,7 @@ void Pkgdbh::buildCompleteDatabase(const bool& silent)
m_listOfAlias[attribute.substr(1)] = i;
}
if ( attribute[0] == 'T' ) {
std::string s;
s = s + " " + attribute.substr(1);
info.categories(s);
categories.insert(attribute.substr(1));
}
if ( attribute[0] == 'R' ) {
std::string s = attribute;
Expand All @@ -789,6 +787,8 @@ void Pkgdbh::buildCompleteDatabase(const bool& silent)
dependencies.insert(NameEpoch);
}
}
info.sets(sets);
info.categories(categories);
info.dependencies(dependencies);
// list of files
const std::string filelist = m_root + PKG_DB_DIR + i + PKG_FILES;
Expand Down
12 changes: 10 additions & 2 deletions src/pkginfo.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -341,10 +341,18 @@ void Pkginfo::run()
std::cout << _("Alias : ") << m_listOfPackages[arg].alias() << std::endl;
}
if (m_listOfPackages[arg].categories().size() > 0 ) {
std::cout << _("Categories : ") << m_listOfPackages[arg].categories() << std::endl;;
std::cout << _("Categories : ");
for (auto c : m_listOfPackages[arg].categories() )
std:: cout << c
<< " ";
std::cout << std::endl;
}
if (m_listOfPackages[arg].sets().size() > 0 ) {
std::cout << _("Set : ") << m_listOfPackages[arg].sets() << std::endl;
std::cout << _("Set : ");
for (auto s:m_listOfPackages[arg].sets())
std::cout << s
<< " ";
std::cout << std::endl;
}
std::cout << _("Group : ") << m_listOfPackages[arg].group() << std::endl
<< _("Collection : ") << m_listOfPackages[arg].collection() << std::endl
Expand Down
8 changes: 5 additions & 3 deletions src/pkgrepo.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -466,16 +466,18 @@ Pkgrepo::getBinaryPackageSet()
<< j.version << std::endl;
#endif
cards::Cache* pkg = new cards::Cache();
std::set<std::string> sets;
std::string baseDir = basename(const_cast<char*>(i.dir.c_str()));
pkg->name(j.basePackageName);
pkg->version(j.version);
pkg->description(j.description);
if ( ( j.set=="none ") || (j.set.size()==0 ) ||
( j.set=="none") )
pkg->collection(baseDir);
else
pkg->sets(j.set);

else {
sets.insert(j.set);
pkg->sets(sets);
}
pkg->packager(j.packager);

m_packagesList.insert(pkg);
Expand Down

0 comments on commit c064525

Please sign in to comment.