repoindex/alpm/package.h

871 lines
22 KiB
C
Raw Normal View History

2015-08-10 22:46:01 +02:00
#ifndef ALPM_PACKAGE_H
#define ALPM_PACKAGE_H
#include <c++utilities/chrono/datetime.h>
#include <QString>
#include <QHash>
2015-09-04 14:37:01 +02:00
#include <QJsonArray>
2015-08-10 22:46:01 +02:00
#include <map>
2016-02-15 01:27:50 +01:00
#include <functional>
2015-09-04 14:37:01 +02:00
QT_FORWARD_DECLARE_CLASS(QJsonObject)
QT_FORWARD_DECLARE_CLASS(QJsonValue)
2015-08-10 22:46:01 +02:00
namespace RepoIndex {
2015-08-10 22:46:01 +02:00
2015-09-04 14:37:01 +02:00
class Repository;
2015-08-10 22:46:01 +02:00
/*!
* \brief The PackageVersionComparsion enum defines possible results of packages version comparison.
*/
enum class PackageVersionComparsion
{
Equal, /*!< The version of this package is the same as the version of the package from the sync db. */
SoftwareUpgrade, /*!< The software version of the package from the sync db is newer. */
PackageUpgradeOnly, /*!< The package release number of the package from the sync db is newer. */
NewerThenSyncVersion /*!< The version of this package is NEWER then the version of the package from the sync db. */
};
/*!
* \brief The ComparsionResult enum defines possible results of package version part comparsion.
*/
enum class PackageVersionPartComparsion
{
Equal, /*!< Both parts are equal. */
Newer, /*!< Part 1 is newer then part 2. */
Older /*!< Part 2 is newer then part 1. */
};
2015-09-04 14:37:01 +02:00
/*!
* \brief The PackageOrigin enum describes where a Package instance comes from.
2016-02-14 23:48:43 +01:00
* \remarks ALPM type: alpm_pkgfrom_t
2015-09-04 14:37:01 +02:00
*/
enum class PackageOrigin
{
Unknown = 20, /*! The origin is unknown. */
2016-02-14 23:48:43 +01:00
File = 1, /*!< The instance has been created from a package file; source() returns nullptr in this case. */
LocalDb = 2, /*! The instance is from the local data base; source() is an AlpmDataBase instance. */
SyncDb = 3, /*! The instance is from a sync data base; source() is an AlpmDataBase instance. */
2015-09-04 14:37:01 +02:00
Aur = 21 /*! The instance is from the AUR; source() is a UserRepository instance. */
};
2016-02-14 23:48:43 +01:00
/*!
2016-02-25 22:53:33 +01:00
* \brief The InstallStatus enum specifies whether a package has been installed explicitely or as dependency.
2016-02-14 23:48:43 +01:00
*/
2015-09-04 14:37:01 +02:00
enum class InstallStatus
{
2016-02-14 23:48:43 +01:00
Explicit = 0,
AsDependency = 1,
2015-09-04 14:37:01 +02:00
None = 20
};
2016-02-14 23:48:43 +01:00
/*!
* \brief The PackageValidation enum specifies methods used to validate a package.
* \remarks ALMP type: alpm_pkgvalidation_t
*/
enum class PackageValidation {
Unknown = 0,
None = (1 << 0),
Md5Sum = (1 << 1),
Sha256Sum = (1 << 2),
2016-02-25 22:53:33 +01:00
PgpSignature = (1 << 3)
2016-02-14 23:48:43 +01:00
};
constexpr PackageValidation operator |(PackageValidation lhs, PackageValidation rhs)
{
2016-02-25 22:53:33 +01:00
return static_cast<PackageValidation>(static_cast<int>(lhs) | static_cast<int>(rhs));
2016-02-14 23:48:43 +01:00
}
constexpr bool operator &(PackageValidation lhs, PackageValidation rhs)
{
return (static_cast<int>(lhs) & static_cast<int>(rhs)) != 0;
}
2016-02-25 22:53:33 +01:00
constexpr int operator ~(PackageValidation lhs)
{
return ~static_cast<int>(lhs);
}
inline PackageValidation &operator |=(PackageValidation &lhs, PackageValidation rhs)
{
lhs = static_cast<PackageValidation>(static_cast<int>(lhs) | static_cast<int>(rhs));
return lhs;
}
inline PackageValidation &operator &=(PackageValidation &lhs, int rhs)
{
lhs = static_cast<PackageValidation>(static_cast<int>(lhs) & rhs);
return lhs;
}
2016-02-14 23:48:43 +01:00
/*!
* \brief The SignatureLevel enum specifies PGP signature verification options.
*/
enum class SignatureLevel {
Package = (1 << 0),
PackageOptional = (1 << 1),
PackageMarginalOk = (1 << 2),
PackageUnknownOk = (1 << 3),
Database = (1 << 10),
DatabaseOptional = (1 << 11),
DatabaseMarginalOk = (1 << 12),
DatabaseUnknownOk = (1 << 13),
UseDefault = (1 << 31)
};
constexpr SignatureLevel operator |(SignatureLevel lhs, SignatureLevel rhs)
{
return static_cast<SignatureLevel>(static_cast<int>(lhs) | static_cast<int>(rhs));
}
constexpr bool operator &(SignatureLevel lhs, SignatureLevel rhs)
{
return (static_cast<int>(lhs) & static_cast<int>(rhs)) != 0;
}
constexpr int operator ~(SignatureLevel lhs)
{
return ~static_cast<int>(lhs);
}
inline SignatureLevel &operator &=(SignatureLevel &lhs, int rhs)
{
lhs = static_cast<SignatureLevel>(static_cast<int>(lhs) & rhs);
return lhs;
}
inline SignatureLevel &operator |=(SignatureLevel &lhs, SignatureLevel rhs)
{
lhs = static_cast<SignatureLevel>(static_cast<int>(lhs) | static_cast<int>(rhs));
return lhs;
}
/*!
* \brief The SigStatus enum specifies PGP signature verification status return codes.
*/
enum class SignatureStatus {
Valid,
KeyExpired,
SigExpired,
KeyUnknown,
KeyDisabled,
InvalidId
};
2015-08-10 22:46:01 +02:00
class PackageVersion
{
public:
2015-09-04 14:37:01 +02:00
explicit PackageVersion(const QString &versionStr);
explicit PackageVersion();
2015-08-10 22:46:01 +02:00
static PackageVersionPartComparsion compareParts(const QString &part1, const QString &part2);
PackageVersionComparsion compare(const PackageVersion &other) const;
QString toString() const;
2015-08-10 22:46:01 +02:00
QString epoch;
QString version;
QString release;
};
2016-02-14 23:48:43 +01:00
/*!
* \brief The DependencyMode enum specifies the version constraints in dependency specs.
* \remarks ALPM: alpm_depmod_t
*/
enum class DependencyMode {
Any = 1, /*! No version constraint */
Equal, /*! Test version equality (package=x.y.z) */
GreatherEqual, /*! Test for at least a version (package>=x.y.z) */
LessEqual, /*! Test for at most a version (package<=x.y.z) */
GreatherThen, /*! Test for greater than some version (package>x.y.z) */
LessThen /*! Test for less than some version (package<x.y.z) */
};
2015-09-04 14:37:01 +02:00
class Dependency
{
public:
2016-02-14 23:48:43 +01:00
explicit Dependency(const QString &name, const QString &version, DependencyMode mode = DependencyMode::Any, const QString &description = QString());
explicit Dependency(const QString &dependency);
2015-09-27 19:29:45 +02:00
bool operator ==(const Dependency &other) const;
QString toString() const;
2015-09-27 19:29:45 +02:00
QJsonObject toJson() const;
2015-09-04 14:37:01 +02:00
QString name;
QString version;
2016-02-14 23:48:43 +01:00
DependencyMode mode;
2015-09-27 19:29:45 +02:00
QString description;
2015-09-04 14:37:01 +02:00
};
2016-02-14 23:48:43 +01:00
inline Dependency::Dependency(const QString &name, const QString &version, DependencyMode mode, const QString &description) :
2015-09-04 14:37:01 +02:00
name(name),
version(version),
2015-09-27 19:29:45 +02:00
mode(mode),
description(description)
2015-09-04 14:37:01 +02:00
{}
inline bool Dependency::operator ==(const Dependency &other) const
{
return other.name == name && other.description == description && other.mode == mode;
}
inline uint qHash(const Dependency &dependency, uint seed)
{
2016-02-14 23:48:43 +01:00
return qHash(dependency.name, seed) ^ qHash(dependency.version, seed) ^ static_cast<uint>(dependency.mode) ^ seed ^ qHash(dependency.description, seed);
}
class Manager;
2015-09-04 14:37:01 +02:00
class Package
2015-08-10 22:46:01 +02:00
{
public:
2015-09-04 14:37:01 +02:00
virtual ~Package();
2015-08-10 22:46:01 +02:00
2015-09-04 14:37:01 +02:00
// general package meta data
PackageOrigin origin() const;
2015-09-12 20:37:04 +02:00
Repository *repository() const;
ChronoUtilities::DateTime timeStamp() const;
2015-09-04 14:37:01 +02:00
bool hasGeneralInfo() const;
bool hasAllGeneralInfo() const;
2015-08-10 22:46:01 +02:00
const QString &name() const;
const QString &version() const;
2015-08-10 22:46:01 +02:00
const QString &description() const;
const QString &upstreamUrl() const;
2015-09-04 14:37:01 +02:00
const QStringList &licenses() const;
const QStringList &groups() const;
const QList<Dependency> &dependencies() const;
const QList<Dependency> &optionalDependencies() const;
const QList<Dependency> &conflicts() const;
const QList<Dependency> &provides() const;
const QList<Dependency> &replaces() const;
bool isRequiredByComputed() const;
2016-02-25 22:53:33 +01:00
void computeRequiredBy(const QList<Repository *> &relevantRepositories);
2015-09-04 14:37:01 +02:00
const QStringList &requiredBy() const;
2016-02-14 23:48:43 +01:00
QStringList &requiredBy();
2015-09-04 14:37:01 +02:00
const QStringList &optionalFor() const;
2016-02-14 23:48:43 +01:00
QStringList &optionalFor();
2015-09-04 14:37:01 +02:00
bool hasInstallScript() const;
2016-02-14 23:48:43 +01:00
void setHasInstallScript(bool hasInstallScript);
2015-09-04 14:37:01 +02:00
// build related meta data
bool hasBuildRelatedMetaData() const;
const QString &fileName() const;
const QJsonArray &files() const;
ChronoUtilities::DateTime buildDate() const;
2016-02-12 01:05:08 +01:00
const QString &packager() const;
2015-09-04 14:37:01 +02:00
const QString &md5() const;
const QString &sha256() const;
const QString &buildArchitecture() const;
uint32 packageSize() const;
const QList<Dependency> &makeDependencies() const;
const QList<Dependency> &checkDependencies() const;
2015-09-04 14:37:01 +02:00
// installation related meta data
bool hasInstallRelatedMetaData() const;
ChronoUtilities::DateTime installDate() const;
uint32 installedSize() const;
const QStringList &backupFiles() const;
2016-02-14 23:48:43 +01:00
PackageValidation validationMethods() const;
InstallStatus installReason() const;
2015-09-04 14:37:01 +02:00
// source related meta data
bool hasSourceRelatedMetaData() const;
const QString &baseName() const;
const QStringList &architectures() const;
int32 id() const;
int32 categoryId() const;
int32 votes() const;
ChronoUtilities::DateTime outOfDate() const;
2015-08-10 22:46:01 +02:00
const QString &maintainer() const;
ChronoUtilities::DateTime firstSubmitted() const;
ChronoUtilities::DateTime lastModified() const;
const QString &tarUrl() const;
const std::map<QString, QByteArray> &sourceFiles() const;
QList<const QList<Dependency> *> allDependencies() const;
2015-08-10 22:46:01 +02:00
2015-09-04 14:37:01 +02:00
// version comparsion
PackageVersionComparsion compareVersion(const Package *syncPackage) const;
PackageVersionComparsion compareVersion(const Dependency &dependency) const;
static bool matches(const QString &name, const QString &version, const Dependency &dependency);
bool matches(const Dependency &dependency);
// JSON serialization
2015-09-04 14:37:01 +02:00
QJsonObject basicInfo(bool includeRepoAndName = false) const;
QJsonObject detailedInfo() const;
2016-01-06 02:08:24 +01:00
QJsonObject simpleInfo() const;
// caching
void writeToCacheStream(QDataStream &out);
void restoreFromCacheStream(QDataStream &in);
2016-01-18 20:34:29 +01:00
void reinitEntries();
2016-02-12 01:05:08 +01:00
// parsing .SRCINFO/.PKGINFO/desc/depends/files info
void putInfo(const QList<QPair<QString, QString> > &baseInfo, const QList<QPair<QString, QString> > &pkgInfo, bool includesSourceRelatedMetaData = false, bool includesBuildRelatedMetaData = false);
2016-02-15 01:27:50 +01:00
void putDescription(const QString &name, const QList<QPair<QString, QStringList> > &description, PackageOrigin origin);
2015-10-28 19:55:36 +01:00
void putSourceFile(const QString &path, const QByteArray &data);
2015-09-04 14:37:01 +02:00
protected:
2015-09-12 20:37:04 +02:00
explicit Package(const QString &name, Repository *repository);
virtual void writeSpecificCacheHeader(QDataStream &out);
virtual void restoreSpecificCacheHeader(QDataStream &in);
2015-09-04 14:37:01 +02:00
PackageOrigin m_origin;
2015-09-12 20:37:04 +02:00
Repository *m_repository;
ChronoUtilities::DateTime m_timeStamp;
2015-09-04 14:37:01 +02:00
// general package meta data
bool m_hasGeneralInfo;
bool m_hasAllGeneralInfo;
2015-08-10 22:46:01 +02:00
QString m_name;
QString m_version;
2015-08-10 22:46:01 +02:00
QString m_description;
QString m_upstreamUrl;
2015-09-04 14:37:01 +02:00
QStringList m_licenses;
QStringList m_groups;
QList<Dependency> m_dependencies;
QList<Dependency> m_optionalDependencies;
QList<Dependency> m_conflicts;
QList<Dependency> m_provides;
QList<Dependency> m_replaces;
bool m_requiredByComputed;
2015-09-04 14:37:01 +02:00
QStringList m_requiredBy;
QStringList m_optionalFor;
bool m_hasInstallScript;
// build related meta data
bool m_hasBuildRelatedMetaData;
QString m_fileName;
QJsonArray m_files;
ChronoUtilities::DateTime m_buildDate;
2016-02-12 01:05:08 +01:00
QString m_packager;
2015-09-04 14:37:01 +02:00
QString m_md5;
QString m_sha256;
2016-02-25 22:53:33 +01:00
QString m_pgpSignature;
2015-09-04 14:37:01 +02:00
QString m_buildArchitecture;
uint32 m_packageSize;
QList<Dependency> m_makeDependencies;
QList<Dependency> m_checkDependencies;
2015-09-04 14:37:01 +02:00
// installation related meta data
bool m_hasInstallRelatedMetaData;
ChronoUtilities::DateTime m_installDate;
uint32 m_installedSize;
QStringList m_backupFiles;
2016-02-14 23:48:43 +01:00
PackageValidation m_validationMethods;
InstallStatus m_installReason;
2015-09-04 14:37:01 +02:00
// source related meta data
bool m_hasSourceRelatedMetaData;
QString m_baseName;
QStringList m_architectures;
int32 m_id;
int32 m_categoryId;
int32 m_votes;
ChronoUtilities::DateTime m_outOfDate;
2015-08-10 22:46:01 +02:00
QString m_maintainer;
ChronoUtilities::DateTime m_firstSubmitted;
ChronoUtilities::DateTime m_lastModified;
QString m_tarUrl;
std::map<QString, QByteArray> m_sourceFiles;
2016-02-15 01:27:50 +01:00
// setter used in putDescription
static const std::map<QString, void(Package::*)(const QStringList &)> m_descMap;
void setName(const QStringList &values);
void setVersion(const QStringList &values);
void setDescription(const QStringList &values);
void setUrl(const QStringList &values);
void setArch(const QStringList &values);
void setLicenses(const QStringList &values);
void setDepends(const QStringList &values);
void setMakeDepends(const QStringList &values);
void setCheckDepends(const QStringList &values);
void setOptDepends(const QStringList &values);
void setConflicts(const QStringList &values);
void setProvides(const QStringList &values);
void setReplaces(const QStringList &values);
void setBuildDate(const QStringList &values);
void setInstallDate(const QStringList &values);
void setInstalledSize(const QStringList &values);
void setPackageSize(const QStringList &values);
void setPackager(const QStringList &values);
void setMd5(const QStringList &values);
void setSha256(const QStringList &values);
2016-02-25 22:53:33 +01:00
void setPgpSignature(const QStringList &values);
2016-02-15 01:27:50 +01:00
void setFiles(const QStringList &values);
void setValidation(const QStringList &values);
void setGroups(const QStringList &values);
void setFileName(const QStringList &values);
void setInstallReason(const QStringList &values);
2015-08-10 22:46:01 +02:00
};
/*!
2015-09-04 14:37:01 +02:00
* \brief Returns where the package instance comes from (local db, sync db, pkg file, AUR).
*/
2015-09-04 14:37:01 +02:00
inline PackageOrigin Package::origin() const
{
2015-09-04 14:37:01 +02:00
return m_origin;
}
2015-08-10 22:46:01 +02:00
/*!
2015-09-12 20:37:04 +02:00
* \brief Returns the repository.
* \remarks Might be nullptr if no repository is associated.
2015-08-10 22:46:01 +02:00
*/
2015-09-12 20:37:04 +02:00
inline Repository *Package::repository() const
2015-08-10 22:46:01 +02:00
{
2015-09-12 20:37:04 +02:00
return m_repository;
2015-08-10 22:46:01 +02:00
}
/*!
* \brief Returns the package's timestamp.
*/
inline ChronoUtilities::DateTime Package::timeStamp() const
{
return m_timeStamp;
}
2015-08-10 22:46:01 +02:00
/*!
2015-09-04 14:37:01 +02:00
* \brief Returns whether general information is available for the package.
2015-08-10 22:46:01 +02:00
*/
2015-09-04 14:37:01 +02:00
inline bool Package::hasGeneralInfo() const
2015-08-10 22:46:01 +02:00
{
2015-09-04 14:37:01 +02:00
return m_hasGeneralInfo;
2015-08-10 22:46:01 +02:00
}
/*!
* \brief Returns whether all general information is available for the package.
*/
inline bool Package::hasAllGeneralInfo() const
{
return m_hasAllGeneralInfo;
}
2015-08-10 22:46:01 +02:00
/*!
2015-09-04 14:37:01 +02:00
* \brief Returns the name.
2015-08-10 22:46:01 +02:00
*/
2015-09-04 14:37:01 +02:00
inline const QString &Package::name() const
2015-08-10 22:46:01 +02:00
{
return m_name;
}
/*!
2015-09-04 14:37:01 +02:00
* \brief Returns the version.
*/
2015-09-04 14:37:01 +02:00
inline const QString &Package::version() const
{
return m_version;
}
2015-08-10 22:46:01 +02:00
/*!
2015-09-04 14:37:01 +02:00
* \brief Returns the description.
2015-08-10 22:46:01 +02:00
*/
2015-09-04 14:37:01 +02:00
inline const QString &Package::description() const
2015-08-10 22:46:01 +02:00
{
return m_description;
}
/*!
2015-09-04 14:37:01 +02:00
* \brief Returns the upstream URL.
2015-08-10 22:46:01 +02:00
*/
2015-09-04 14:37:01 +02:00
inline const QString &Package::upstreamUrl() const
2015-08-10 22:46:01 +02:00
{
return m_upstreamUrl;
}
/*!
2015-09-04 14:37:01 +02:00
* \brief Returns the licenses.
2015-08-10 22:46:01 +02:00
*/
2015-09-04 14:37:01 +02:00
inline const QStringList &Package::licenses() const
2015-08-10 22:46:01 +02:00
{
2015-09-04 14:37:01 +02:00
return m_licenses;
2015-08-10 22:46:01 +02:00
}
/*!
2015-09-04 14:37:01 +02:00
* \brief Returns the groups.
2015-08-10 22:46:01 +02:00
*/
2015-09-04 14:37:01 +02:00
inline const QStringList &Package::groups() const
2015-08-10 22:46:01 +02:00
{
2015-09-04 14:37:01 +02:00
return m_groups;
2015-08-10 22:46:01 +02:00
}
/*!
2015-09-04 14:37:01 +02:00
* \brief Returns the dependencies.
2015-08-10 22:46:01 +02:00
*/
2015-09-04 14:37:01 +02:00
inline const QList<Dependency> &Package::dependencies() const
2015-08-10 22:46:01 +02:00
{
2015-09-04 14:37:01 +02:00
return m_dependencies;
2015-08-10 22:46:01 +02:00
}
/*!
2015-09-04 14:37:01 +02:00
* \brief Returns the optional dependencies.
2015-08-10 22:46:01 +02:00
*/
2015-09-04 14:37:01 +02:00
inline const QList<Dependency> &Package::optionalDependencies() const
2015-08-10 22:46:01 +02:00
{
2015-09-04 14:37:01 +02:00
return m_optionalDependencies;
2015-08-10 22:46:01 +02:00
}
/*!
2015-09-04 14:37:01 +02:00
* \brief Returns conflicting packages.
2015-08-10 22:46:01 +02:00
*/
2015-09-04 14:37:01 +02:00
inline const QList<Dependency> &Package::conflicts() const
2015-08-10 22:46:01 +02:00
{
2015-09-04 14:37:01 +02:00
return m_conflicts;
2015-08-10 22:46:01 +02:00
}
/*!
2015-09-04 14:37:01 +02:00
* \brief Returns provides.
2015-08-10 22:46:01 +02:00
*/
2015-09-04 14:37:01 +02:00
inline const QList<Dependency> &Package::provides() const
2015-08-10 22:46:01 +02:00
{
2015-09-04 14:37:01 +02:00
return m_provides;
2015-08-10 22:46:01 +02:00
}
/*!
2015-09-04 14:37:01 +02:00
* \brief Returns packages which are replaced by this package.
2015-08-10 22:46:01 +02:00
*/
2015-09-04 14:37:01 +02:00
inline const QList<Dependency> &Package::replaces() const
2015-08-10 22:46:01 +02:00
{
2015-09-04 14:37:01 +02:00
return m_replaces;
}
/*!
* \brief Returns whether required-by and optional-for have been computed.
*/
inline bool Package::isRequiredByComputed() const
{
return m_requiredByComputed;
}
2015-08-10 22:46:01 +02:00
/*!
2015-09-04 14:37:01 +02:00
* \brief Returns packages requiring this packages.
2015-08-10 22:46:01 +02:00
*/
2015-09-04 14:37:01 +02:00
inline const QStringList &Package::requiredBy() const
{
2015-09-04 14:37:01 +02:00
return m_requiredBy;
}
2016-02-14 23:48:43 +01:00
/*!
* \brief Returns packages requiring this packages.
*/
inline QStringList &Package::requiredBy()
{
return m_requiredBy;
}
2015-09-04 14:37:01 +02:00
/*!
* \brief Returns packages having this package as optional dependency.
*/
inline const QStringList &Package::optionalFor() const
2015-08-10 22:46:01 +02:00
{
2015-09-04 14:37:01 +02:00
return m_optionalFor;
2015-08-10 22:46:01 +02:00
}
2016-02-14 23:48:43 +01:00
/*!
* \brief Returns packages having this package as optional dependency.
*/
inline QStringList &Package::optionalFor()
{
return m_optionalFor;
}
2015-09-04 14:37:01 +02:00
/*!
* \brief Returns whether the package has an install script.
*/
inline bool Package::hasInstallScript() const
2015-08-10 22:46:01 +02:00
{
2015-09-04 14:37:01 +02:00
return m_hasInstallScript;
2015-08-10 22:46:01 +02:00
}
2016-02-14 23:48:43 +01:00
/*!
* \brief Sets whether the package has an install script.
*/
inline void Package::setHasInstallScript(bool hasInstallScript)
{
m_hasInstallScript = hasInstallScript;
}
2015-08-10 22:46:01 +02:00
/*!
2015-09-04 14:37:01 +02:00
* \brief Returns whether the package has build-related meta data.
2015-08-10 22:46:01 +02:00
*
2015-09-04 14:37:01 +02:00
* Build-related meta data is information about a particular package file such
* as architecture, file name, build date, ....
2015-08-10 22:46:01 +02:00
*/
2015-09-04 14:37:01 +02:00
inline bool Package::hasBuildRelatedMetaData() const
2015-08-10 22:46:01 +02:00
{
2015-09-04 14:37:01 +02:00
return m_hasBuildRelatedMetaData;
2015-08-10 22:46:01 +02:00
}
2015-09-04 14:37:01 +02:00
/*!
* \brief Returns the file name of the package file.
*/
inline const QString &Package::fileName() const
2015-08-10 22:46:01 +02:00
{
2015-09-04 14:37:01 +02:00
return m_fileName;
2015-08-10 22:46:01 +02:00
}
2015-09-04 14:37:01 +02:00
/*!
2015-10-28 19:55:36 +01:00
* \brief Returns the paths of the files of the binary package as JSON array.
* \remarks For source files see \a sourceFiles().
2015-09-04 14:37:01 +02:00
*/
inline const QJsonArray &Package::files() const
2015-08-10 22:46:01 +02:00
{
2015-09-04 14:37:01 +02:00
return m_files;
2015-08-10 22:46:01 +02:00
}
2015-09-04 14:37:01 +02:00
/*!
* \brief Returns the build date of the package file.
*/
inline ChronoUtilities::DateTime Package::buildDate() const
2015-08-10 22:46:01 +02:00
{
2015-09-04 14:37:01 +02:00
return m_buildDate;
2015-08-10 22:46:01 +02:00
}
2015-09-04 14:37:01 +02:00
/*!
2016-02-12 01:05:08 +01:00
* \brief Returns the packager of the package file.
2015-09-04 14:37:01 +02:00
*/
2016-02-12 01:05:08 +01:00
inline const QString &Package::packager() const
2015-08-10 22:46:01 +02:00
{
2016-02-12 01:05:08 +01:00
return m_packager;
2015-08-10 22:46:01 +02:00
}
2015-09-04 14:37:01 +02:00
/*!
* \brief Returns the MD5 hash of the package file.
*/
inline const QString &Package::md5() const
2015-08-10 22:46:01 +02:00
{
2015-09-04 14:37:01 +02:00
return m_md5;
2015-08-10 22:46:01 +02:00
}
2015-09-04 14:37:01 +02:00
/*!
* \brief Returns the SHA-256 hash of the package file.
*/
inline const QString &Package::sha256() const
2015-08-10 22:46:01 +02:00
{
2015-09-04 14:37:01 +02:00
return m_sha256;
2015-08-10 22:46:01 +02:00
}
2015-09-04 14:37:01 +02:00
/*!
* \brief Returns the architecture of the package file.
*/
inline const QString &Package::buildArchitecture() const
2015-08-10 22:46:01 +02:00
{
2015-09-04 14:37:01 +02:00
return m_buildArchitecture;
2015-08-10 22:46:01 +02:00
}
2015-09-04 14:37:01 +02:00
/*!
* \brief Returns the size of the package file.
*/
inline uint32 Package::packageSize() const
2015-08-10 22:46:01 +02:00
{
2015-09-04 14:37:01 +02:00
return m_packageSize;
2015-08-10 22:46:01 +02:00
}
2015-09-04 14:37:01 +02:00
/*!
* \brief Returns dependencies required to make the package.
2015-09-04 14:37:01 +02:00
*/
inline const QList<Dependency> &Package::makeDependencies() const
2015-08-10 22:46:01 +02:00
{
2015-09-04 14:37:01 +02:00
return m_makeDependencies;
2015-08-10 22:46:01 +02:00
}
/*!
* \brief Returns dependencies required to run tests when making the package.
*/
inline const QList<Dependency> &Package::checkDependencies() const
{
return m_checkDependencies;
}
2015-09-04 14:37:01 +02:00
/*!
* \brief Returns whether install-related meta data is available.
*
* Install-related meta data is information such as the install date,
* the installed size, files backuped during installation, ...
*
* Most of the install-related meta data is only available for packages
* from the local data base (see origin()).
*/
inline bool Package::hasInstallRelatedMetaData() const
2015-08-10 22:46:01 +02:00
{
2015-09-04 14:37:01 +02:00
return m_hasInstallRelatedMetaData;
2015-08-10 22:46:01 +02:00
}
2015-09-04 14:37:01 +02:00
/*!
* \brief Returns the install date.
*/
inline ChronoUtilities::DateTime Package::installDate() const
2015-08-10 22:46:01 +02:00
{
2015-09-04 14:37:01 +02:00
return m_installDate;
2015-08-10 22:46:01 +02:00
}
2015-09-04 14:37:01 +02:00
/*!
* \brief Returns the installed size.
*/
inline uint32 Package::installedSize() const
2015-08-10 22:46:01 +02:00
{
2015-09-04 14:37:01 +02:00
return m_installedSize;
2015-08-10 22:46:01 +02:00
}
2015-09-04 14:37:01 +02:00
/*!
* \brief Returns the files which have been backued up during installation.
*/
inline const QStringList &Package::backupFiles() const
2015-08-10 22:46:01 +02:00
{
2015-09-04 14:37:01 +02:00
return m_backupFiles;
2015-08-10 22:46:01 +02:00
}
2015-09-04 14:37:01 +02:00
/*!
* \brief Returns the validation methods used during installation.
*/
2016-02-14 23:48:43 +01:00
inline PackageValidation Package::validationMethods() const
2015-08-10 22:46:01 +02:00
{
2015-09-04 14:37:01 +02:00
return m_validationMethods;
2015-08-10 22:46:01 +02:00
}
2015-09-04 14:37:01 +02:00
/*!
* \brief Returns whether the package has been installed explicitely or as a dependency.
*/
2016-02-14 23:48:43 +01:00
inline InstallStatus Package::installReason() const
2015-08-10 22:46:01 +02:00
{
2015-09-04 14:37:01 +02:00
return m_installReason;
2015-08-10 22:46:01 +02:00
}
2015-09-04 14:37:01 +02:00
/*!
* \brief Returns whether source-related meta data is available.
*
* Source-related meta data is information about the PKGBUILD file such has
* its AUR IDs, AUR votes, maintainer, flag date, ...
*/
inline bool Package::hasSourceRelatedMetaData() const
2015-08-10 22:46:01 +02:00
{
2015-09-04 14:37:01 +02:00
return m_hasSourceRelatedMetaData;
2015-08-10 22:46:01 +02:00
}
2015-09-04 14:37:01 +02:00
/*!
* \brief Returns the base name.
*/
inline const QString &Package::baseName() const
2015-08-10 22:46:01 +02:00
{
2015-09-04 14:37:01 +02:00
return m_baseName;
2015-08-10 22:46:01 +02:00
}
2015-09-04 14:37:01 +02:00
/*!
* \brief Returns the architecutes (from the PKGBUILD file).
* \remarks For the architecture of the particular package file
2015-09-04 14:37:01 +02:00
* see buildArchitecture().
*/
inline const QStringList &Package::architectures() const
2015-08-10 22:46:01 +02:00
{
2015-09-04 14:37:01 +02:00
return m_architectures;
2015-08-10 22:46:01 +02:00
}
2015-09-04 14:37:01 +02:00
/*!
* \brief Returns the ID.
*/
inline int32 Package::id() const
2015-08-10 22:46:01 +02:00
{
2015-09-04 14:37:01 +02:00
return m_id;
2015-08-10 22:46:01 +02:00
}
2015-09-04 14:37:01 +02:00
/*!
* \brief Returns the category ID.
*/
inline int32 Package::categoryId() const
2015-08-10 22:46:01 +02:00
{
2015-09-04 14:37:01 +02:00
return m_categoryId;
2015-08-10 22:46:01 +02:00
}
2015-09-04 14:37:01 +02:00
/*!
* \brief Returns the votes of the package.
*/
inline int32 Package::votes() const
2015-08-10 22:46:01 +02:00
{
2015-09-04 14:37:01 +02:00
return m_votes;
2015-08-10 22:46:01 +02:00
}
2015-09-04 14:37:01 +02:00
/*!
* \brief Returns the flag date.
*/
inline ChronoUtilities::DateTime Package::outOfDate() const
2015-08-10 22:46:01 +02:00
{
2015-09-04 14:37:01 +02:00
return m_outOfDate;
2015-08-10 22:46:01 +02:00
}
2015-09-04 14:37:01 +02:00
/*!
* \brief Returns the maintainer.
*/
inline const QString &Package::maintainer() const
2015-08-10 22:46:01 +02:00
{
2015-09-04 14:37:01 +02:00
return m_maintainer;
2015-08-10 22:46:01 +02:00
}
2015-09-04 14:37:01 +02:00
/*!
* \brief Returns when the package was first submitted.
*/
inline ChronoUtilities::DateTime Package::firstSubmitted() const
2015-08-10 22:46:01 +02:00
{
2015-09-04 14:37:01 +02:00
return m_firstSubmitted;
2015-08-10 22:46:01 +02:00
}
2015-09-04 14:37:01 +02:00
/*!
* \brief Returns the last time when the package was modified.
*/
inline ChronoUtilities::DateTime Package::lastModified() const
2015-08-10 22:46:01 +02:00
{
2015-09-04 14:37:01 +02:00
return m_lastModified;
2015-08-10 22:46:01 +02:00
}
2015-09-04 14:37:01 +02:00
/*!
* \brief Returns a URL to a tar file with the sources.
*/
inline const QString &Package::tarUrl() const
2015-08-10 22:46:01 +02:00
{
2015-09-04 14:37:01 +02:00
return m_tarUrl;
2015-08-10 22:46:01 +02:00
}
/*!
2016-02-12 01:05:08 +01:00
* \brief Returns the available source files.
*
* Contains usually the PKGBUILD/.SRCINFO file and patches.
*/
inline const std::map<QString, QByteArray> &Package::sourceFiles() const
{
return m_sourceFiles;
}
/*!
* \brief Returns all dependencies.
*/
inline QList<const QList<Dependency> *> Package::allDependencies() const
{
return {&dependencies(), &makeDependencies(), &checkDependencies()};
}
/*!
* \brief Compares the version of the package with the specified sync package.
*/
2015-09-04 14:37:01 +02:00
inline PackageVersionComparsion Package::compareVersion(const Package *syncPackage) const
2015-08-10 22:46:01 +02:00
{
2015-09-04 14:37:01 +02:00
return PackageVersion(version()).compare(PackageVersion(syncPackage->version()));
2015-08-10 22:46:01 +02:00
}
/*!
* \brief Compares the version of the package with the version of the specified \a dependency.
*/
2015-09-04 14:37:01 +02:00
inline PackageVersionComparsion Package::compareVersion(const Dependency &dependency) const
2015-08-10 22:46:01 +02:00
{
2015-09-04 14:37:01 +02:00
return PackageVersion(version()).compare(PackageVersion(dependency.version));
2015-08-10 22:46:01 +02:00
}
2016-02-14 23:48:43 +01:00
inline uint qHash(const Package &package, uint seed)
{
return static_cast<uint>(((reinterpret_cast<quint64>(package.repository()) >> (8 * sizeof(uint) - 1)) ^ reinterpret_cast<quint64>(package.repository())) & (~0U)) ^ seed ^ qHash(package.name(), seed);
}
2015-08-10 22:46:01 +02:00
}
#endif // ALPM_PACKAGE_H