void
IniDBBuilderPackage::buildPackageInstall (const std::string& path,
- const std::string& size)
+ const std::string& size,
+ char *hash,
+ hashType type)
{
process_src (*cbpv.source(), path);
setSourceSize (*cbpv.source(), size);
+
+ switch (type) {
+ case hashType::sha512:
+ if (hash && !cbpv.source()->sha512_isSet)
+ {
+ memcpy (cbpv.source()->sha512sum, hash, sizeof(cbpv.source()->sha512sum));
+ cbpv.source()->sha512_isSet = true;
+ }
+ break;
+
+ case hashType::md5:
+ if (hash && !cbpv.source()->md5.isSet())
+ cbpv.source()->md5.set((unsigned char *)hash);
+ break;
+
+ case hashType::none:
+ break;
+ }
}
void
IniDBBuilderPackage::buildPackageSource (const std::string& path,
- const std::string& size)
+ const std::string& size,
+ char *hash,
+ hashType type)
{
packagedb db;
/* get an appropriate metadata */
spec.setVersion (cbpv.Canonical_version());
setSourceSize (*cspv.source(), size);
+
+ switch (type) {
+ case hashType::sha512:
+ if (hash && !cspv.source()->sha512_isSet)
+ {
+ memcpy (cspv.source()->sha512sum, hash, sizeof(cspv.source()->sha512sum));
+ cspv.source()->sha512_isSet = true;
+ }
+ break;
+
+ case hashType::md5:
+ if (hash && !cspv.source()->md5.isSet())
+ cspv.source()->md5.set((unsigned char *)hash);
+ break;
+
+ case hashType::none:
+ break;
+ }
}
void
currentNodeList = cbpv.depends();
}
-void
-IniDBBuilderPackage::buildInstallSHA512 (unsigned char const *sha512)
-{
- if (sha512 && !cbpv.source()->sha512_isSet) {
- memcpy (cbpv.source()->sha512sum, sha512, sizeof cbpv.source()->sha512sum);
- cbpv.source()->sha512_isSet = true;
- }
-}
-
-void
-IniDBBuilderPackage::buildSourceSHA512 (unsigned char const *sha512)
-{
- if (sha512 && !cspv.source()->sha512_isSet) {
- memcpy (cspv.source()->sha512sum, sha512, sizeof cspv.source()->sha512sum);
- cspv.source()->sha512_isSet = true;
- }
-}
-
-void
-IniDBBuilderPackage::buildInstallMD5 (unsigned char const *md5)
-{
- if (md5 && !cbpv.source()->md5.isSet())
- cbpv.source()->md5.set(md5);
-}
-
-void
-IniDBBuilderPackage::buildSourceMD5 (unsigned char const *md5)
-{
- if (md5 && !cspv.source()->md5.isSet())
- cspv.source()->md5.set(md5);
-}
-
void
IniDBBuilderPackage::buildBeginBuildDepends ()
{
#include <vector>
#include "package_version.h"
+
class IniParseFeedback;
class packagesource;
class packagemeta;
+enum class hashType { none, md5, sha512 };
+
class IniDBBuilderPackage
{
public:
void buildPackageVersion (const std::string& );
void buildPackageSDesc (const std::string& );
void buildPackageLDesc (const std::string& );
- void buildPackageInstall (const std::string&, const std::string&);
- void buildPackageSource (const std::string&, const std::string&);
+ void buildPackageInstall (const std::string&, const std::string&,
+ char *, hashType);
+ void buildPackageSource (const std::string&, const std::string&,
+ char *, hashType);
+
+ // helpers for ScanFindVisitor
+ void buildPackageInstall (const std::string& path, const std::string& size)
+ { buildPackageInstall(path, size, NULL, hashType::none); }
+ void buildPackageSource (const std::string& path, const std::string& size)
+ { buildPackageSource(path, size, NULL, hashType::none); }
+
void buildPackageTrust (int);
void buildPackageCategory (const std::string& );
void buildBeginDepends ();
- void buildInstallSHA512 (unsigned char const[64]);
- void buildSourceSHA512 (unsigned char const[64]);
- void buildInstallMD5 (unsigned char const[16]);
- void buildSourceMD5 (unsigned char const[16]);
void buildBeginBuildDepends ();
void buildMessage (const std::string&, const std::string&);
void buildSourceName (const std::string& );
| T_OTHER NL { iniBuilder->buildPackageTrust (TRUST_OTHER); }
| SOURCEPACKAGE source NL
| CATEGORY categories NL
- | INSTALL STRING STRING { iniBuilder->buildPackageInstall ($2, $3);} installchksum NL
- | SOURCE STRING STRING sourcechksum NL {iniBuilder->buildPackageSource ($2, $3);}
+ | INSTALL STRING STRING MD5 NL { iniBuilder->buildPackageInstall ($2, $3, $4, hashType::md5); }
+ | INSTALL STRING STRING SHA512 NL { iniBuilder->buildPackageInstall ($2, $3, $4, hashType::sha512); }
+ | SOURCE STRING STRING MD5 NL {iniBuilder->buildPackageSource ($2, $3, $4, hashType::md5); }
+ | SOURCE STRING STRING SHA512 NL {iniBuilder->buildPackageSource ($2, $3, $4, hashType::sha512); }
| DEPENDS { iniBuilder->buildBeginDepends(); } versionedpackagelist NL
| REQUIRES { iniBuilder->buildBeginDepends(); } versionedpackagelistsp NL
| BUILDDEPENDS { iniBuilder->buildBeginBuildDepends(); } versionedpackagelist NL
| categories STRING { iniBuilder->buildPackageCategory ($2); }
;
-installchksum /* non-empty */
- : MD5 { iniBuilder->buildInstallMD5 ((unsigned char *)$1);}
- | SHA512 { iniBuilder->buildInstallSHA512 ((unsigned char *)$1);}
- ;
-
-sourcechksum /* non-empty */
- : MD5 { iniBuilder->buildSourceMD5 ((unsigned char *)$1); }
- | SHA512 { iniBuilder->buildSourceSHA512 ((unsigned char *)$1); }
- ;
-
source /* non-empty */
: STRING { iniBuilder->buildSourceName ($1); } versioninfo
;