Skip to content

Commit

Permalink
pkg
Browse files Browse the repository at this point in the history
the alias member is a set of string
  • Loading branch information
tnut committed Mar 20, 2024
1 parent 2b0d618 commit d3f52ad
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 93 deletions.
4 changes: 2 additions & 2 deletions src/pkg.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ unsigned short int Pkg::release()
{
return m_release;
}
void Pkg::alias(const std::string& alias)
void Pkg::alias(std::set<std::string>& alias)
{
m_alias = alias;
}
std::string Pkg::alias()
std::set<std::string> Pkg::alias()
{
return m_alias;
}
Expand Down
18 changes: 10 additions & 8 deletions src/pkg.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ class Pkg
const std::string version();
unsigned short int release();

std::string alias();
std::string group();
std::string collection();
std::set<std::string> alias();
std::set<std::string> sets();
std::set<std::string> categories();
std::string arch();
Expand All @@ -42,11 +42,12 @@ class Pkg
void version(const std::string& version);
void release(unsigned short int release);

void alias(const std::string& alias);
void group(const std::string& group);
void alias(std::set<std::string>& alias);
void sets(const std::set<std::string>& sets);
void collection(const std::string& collection);
void categories(const std::set<std::string>& categories);

void collection(const std::string& collection);
void group(const std::string& group);
void arch(const std::string& arch);
void license(const std::string& license);
void signature(const std::string& signature);
Expand All @@ -64,17 +65,18 @@ class Pkg
std::string m_version;
unsigned short int m_release;

std::string m_alias;
std::string m_group;
std::string m_collection;
std::set<std::string> m_alias;
std::set<std::string> m_sets;
std::set<std::string> m_categories;
std::set<std::pair<std::string,time_t>> m_dependencies;

std::string m_group;
std::string m_collection;
std::string m_arch;
std::string m_license;
std::string m_signature;
std::string m_origin;
std::string m_branch;
std::set<std::pair<std::string,time_t>> m_dependencies;

time_t m_build;

Expand Down
145 changes: 64 additions & 81 deletions src/pkgdbh.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -493,10 +493,10 @@ Pkgdbh::buildDatabase(const bool& progress,
std::set<std::string> fileContent;
parseFile(fileContent,metaFile.c_str());
m_listOfAlias[name] = name;
for ( auto attribute : fileContent) {
if ( attribute[0] != 'A' )
for ( auto s : fileContent) {
if ( s[0] != 'A' )
break;
m_listOfAlias[attribute.substr(1)] = name;
m_listOfAlias[s.substr(1)] = name;
}
}

Expand Down Expand Up @@ -533,31 +533,31 @@ Pkgdbh::buildDatabase(const bool& progress,
m_listOfAlias[pkgName] = pkgName;
unsigned short flags = 0;
info.release(1);
for ( auto attribute : fileContent) {
if ( attribute[0] == 'B' ) {
info.build(strtoul(attribute.substr(1).c_str(),NULL,0));
for ( auto s : fileContent) {
if ( s[0] == 'B' ) {
info.build(strtoul(s.substr(1).c_str(),NULL,0));
flags++;
}
if ( attribute[0] == 'V' ) {
info.version(attribute.substr(1));
if ( s[0] == 'V' ) {
info.version(s.substr(1));
flags=flags + 2;
}
if ( attribute[0] == 'c' ) {
info.collection(attribute.substr(1));
if ( s[0] == 'c' ) {
info.collection(s.substr(1));
flags = flags + 4;
}
/* As a group is not always present we cannot
* depend on a found one to break */
if ( attribute[0] == 'g' ) {
info.group(attribute.substr(1));
if ( s[0] == 'g' ) {
info.group(s.substr(1));
}
/* As a std::set is not always present we cannot
* depen on a found one to break */
if ( attribute[0] == 's' ) {
sets.insert(attribute.substr(1));
if ( s[0] == 's' ) {
sets.insert(s.substr(1));
}
if ( attribute[0] == 'r' ) {
info.release(atoi(attribute.substr(1).c_str()));
if ( s[0] == 'r' ) {
info.release(atoi(s.substr(1).c_str()));
flags = flags + 8;
}
if ( flags == 15 ) {
Expand Down Expand Up @@ -626,54 +626,51 @@ Pkgdbh::buildSimpleDatabase()
info.release(1);
info.dependency(false);
std::set<std::string> sets;
std::set<std::string> alias;
m_listOfAlias[i] = i;
for (auto attribute : fileContent) {
if ( attribute[0] == 'c' ) {
std::string s = attribute;
for (auto s : fileContent) {
if ( s[0] == 'c' ) {
info.collection(s.substr(1));
}
if ( attribute[0] == 's' ) {
sets.insert(attribute.substr(1));
if ( s[0] == 's' ) {
sets.insert(s.substr(1));
}
if ( attribute[0] == 'V' ) {
std::string s = attribute;
if ( s[0] == 'V' ) {
info.version(s.substr(1));
}
if ( attribute[0] == 'r' ) {
std::string s = attribute;
info.release( atoi(s.substr(1).c_str()) );
if ( s[0] == 'r' ) {
info.release(atoi(s.substr(1).c_str()));
}
if ( attribute[0] == 'B' ) {
std::string s = attribute;
info.build( strtoul(s.substr(1).c_str(),NULL,0) );
if ( s[0] == 'B' ) {
info.build(strtoul(s.substr(1).c_str(),NULL,0));
}
if ( attribute[0] == 'g' ) {
std::string s = attribute;
info.group( s.substr(1) );
if ( s[0] == 'g' ) {
info.group(s.substr(1));
}
if ( attribute[0] == 'A' ) {
std::string s;
s = s + " " + attribute.substr(1);
info.alias(s);
if ( s[0] == 'A' ) {
alias.insert(s.substr(1));
}
if ( attribute[0] == 'P' ) {
std::string s = attribute;
if ( s[0] == 'P' ) {
info.packager(s.substr(1));
}
if ( attribute[0] == 'd' ) {
std::string s = attribute;
if ( s[0] == 'd' ) {
if ( s == "d1" )
info.dependency(true);
}
}
info.sets(sets);
info.alias(alias);
m_listOfPackages[i] = info;
}
m_miniDB_Empty=false;
}
#ifndef NDEBUG
for (auto i : m_listOfAlias)
std::cerr << "Alias: " << i.first << ", Package: " << i.second << std::endl;
std::cerr << "Alias: "
<< i.first
<< ", Package: "
<< i.second
<< std::endl;
#endif
}
/**
Expand Down Expand Up @@ -706,87 +703,73 @@ void Pkgdbh::buildCompleteDatabase(const bool& silent)
std::set<std::string> fileContent;
std::set<std::string> categories;
std::set<std::string> sets;
std::set<std::string> alias;
parseFile(fileContent,metaFile.c_str());
info.release(1);
info.dependency(false);
m_listOfAlias[i] = i;
for (auto attribute : fileContent) {
if ( attribute[0] == 'C' ) {
std::string s = attribute;
for (auto s : fileContent) {
if ( s[0] == 'C' ) {
info.contributors( s.substr(1) );
}
if ( attribute[0] == 'D' ) {
std::string s = attribute;
if ( s[0] == 'D' ) {
info.description( s.substr(1) );
}
if ( attribute[0] == 'B' ) {
std::string s = attribute;
if ( s[0] == 'B' ) {
info.build( strtoul(s.substr(1).c_str(),NULL,0) );
}
if ( attribute[0] == 'U' ) {
std::string s = attribute;
if ( s[0] == 'U' ) {
info.url( s.substr(1) );
}
if ( attribute[0] == 'L' ) {
std::string s = attribute;
if ( s[0] == 'L' ) {
info.license( s.substr(1) );
}
if ( attribute[0] == 'M' ) {
std::string s = attribute;
if ( s[0] == 'M' ) {
info.maintainer( s.substr(1) );
}
if ( attribute[0] == 'P' ) {
std::string s = attribute;
if ( s[0] == 'P' ) {
info.packager( s.substr(1) );
}
if ( attribute[0] == 'V' ) {
std::string s = attribute;
if ( s[0] == 'V' ) {
info.version( s.substr(1) );
}
if ( attribute[0] == 'r' ) {
std::string s = attribute;
if ( s[0] == 'r' ) {
info.release( atoi(s.substr(1).c_str()) );
}
if ( attribute[0] == 'a' ) {
std::string s = attribute;
if ( s[0] == 'a' ) {
info.arch( s.substr(1) );
}
if ( attribute[0] == 'c' ) {
info.collection(attribute.substr(1));
if ( s[0] == 'c' ) {
info.collection(s.substr(1));
}
if ( attribute[0] == 's' ) {
sets.insert(attribute.substr(1));
if ( s[0] == 's' ) {
sets.insert(s.substr(1));
}
if ( attribute[0] == 'g' ) {
std::string s = attribute;
if ( s[0] == 'g' ) {
info.group( s.substr(1) );
}
if ( attribute[0] == 'd' ) {
std::string s = attribute;
if ( s[0] == 'd' ) {
if ( s == "d1" )
info.dependency(true);
}
if ( attribute[0] == 'S' ) {
std::string s = attribute;
if ( s[0] == 'S' ) {
info.space( atoi(s.substr(1).c_str()) );
}
if ( attribute[0] == 'A' ) {
std::string s;
s = s + " " + attribute.substr(1);
info.alias(s);
m_listOfAlias[attribute.substr(1)] = i;
if ( s[0] == 'A' ) {
alias.insert(s.substr(1));
m_listOfAlias[s.substr(1)] = i;
}
if ( attribute[0] == 'T' ) {
categories.insert(attribute.substr(1));
if ( s[0] == 'T' ) {
categories.insert(s.substr(1));
}
if ( attribute[0] == 'R' ) {
std::string s = attribute;
if ( s[0] == 'R' ) {
std::pair<std::string,time_t > NameEpoch;
NameEpoch.first=s.substr(1,s.size()-11);
NameEpoch.second=strtoul((s.substr(s.size()-10)).c_str(),NULL,0);
dependencies.insert(NameEpoch);
}
}
info.alias(alias);
info.sets(sets);
info.categories(categories);
info.dependencies(dependencies);
Expand Down
8 changes: 6 additions & 2 deletions src/pkginfo.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -338,11 +338,15 @@ void Pkginfo::run()
std::cout << _("Name : ") << arg << std::endl
<< _("Description : ") << m_listOfPackages[arg].description() << std::endl;
if (m_listOfPackages[arg].alias().size() > 0 ) {
std::cout << _("Alias : ") << m_listOfPackages[arg].alias() << std::endl;
std::cout << _("Alias : ");
for (auto a:m_listOfPackages[arg].alias() )
std:: cout << a
<< " ";
std::cout << std::endl;
}
if (m_listOfPackages[arg].categories().size() > 0 ) {
std::cout << _("Categories : ");
for (auto c : m_listOfPackages[arg].categories() )
for (auto c:m_listOfPackages[arg].categories() )
std:: cout << c
<< " ";
std::cout << std::endl;
Expand Down

0 comments on commit d3f52ad

Please sign in to comment.