95 lines
3.2 KiB
C++
95 lines
3.2 KiB
C++
#include "./alpmpackage.h"
|
|
#include "./alpmdatabase.h"
|
|
#include "./utilities.h"
|
|
|
|
#include <QJsonObject>
|
|
|
|
#include <iostream>
|
|
|
|
using namespace ChronoUtilities;
|
|
|
|
namespace RepoIndex {
|
|
|
|
/*!
|
|
* \cond
|
|
*/
|
|
|
|
namespace Utilities {
|
|
|
|
inline QList<Dependency> depinfos(DependencyList list)
|
|
{
|
|
QList<Dependency> infos;
|
|
for(const auto *dep : list) {
|
|
infos << Dependency(qstr(dep->name), qstr(dep->version), dep->mod);
|
|
}
|
|
return infos;
|
|
}
|
|
|
|
}
|
|
|
|
/*!
|
|
* \endcond
|
|
*/
|
|
|
|
using namespace Utilities;
|
|
|
|
/*!
|
|
* \brief The AlpmPackage class wraps an ALPM package struct and holds additional meta information.
|
|
*/
|
|
|
|
/*!
|
|
* \brief Constructs a new instance for the specified ALPM \a package.
|
|
*/
|
|
AlpmPackage::AlpmPackage(alpm_pkg_t *package, AlpmDatabase *alpmDatabase) :
|
|
Package(QString::fromLocal8Bit(alpm_pkg_get_name(package)), alpmDatabase),
|
|
m_ptr(package)
|
|
{
|
|
m_origin = static_cast<PackageOrigin>(alpm_pkg_get_origin(package));
|
|
m_hasGeneralInfo = m_hasBuildRelatedMetaData = m_hasInstallRelatedMetaData = true;
|
|
m_version = qstr(alpm_pkg_get_version(package));
|
|
m_description = qstr(alpm_pkg_get_desc(package));
|
|
m_upstreamUrl = qstr(alpm_pkg_get_url(package));
|
|
m_licenses = qstrlist(alpm_pkg_get_licenses(package));
|
|
m_groups = qstrlist(alpm_pkg_get_groups(package));
|
|
m_dependencies = depinfos(alpm_pkg_get_depends(package));
|
|
m_optionalDependencies = depinfos(alpm_pkg_get_optdepends(package));
|
|
m_conflicts = depinfos(alpm_pkg_get_conflicts(package));
|
|
m_provides = depinfos(alpm_pkg_get_provides(package));
|
|
m_replaces = depinfos(alpm_pkg_get_replaces(package));
|
|
//alpm_list_t *tmp;
|
|
//m_requiredBy = qstrlist(tmp = alpm_pkg_compute_requiredby(package));
|
|
//FREELIST(tmp);
|
|
//m_optionalFor = qstrlist(tmp = alpm_pkg_compute_optionalfor(package));
|
|
//FREELIST(tmp);
|
|
m_hasInstallScript = alpm_pkg_has_scriptlet(package);
|
|
m_fileName = qstr(alpm_pkg_get_filename(package));
|
|
m_buildDate = DateTime::fromTimeStamp(alpm_pkg_get_builddate(package));
|
|
m_packer = qstr(alpm_pkg_get_packager(package));
|
|
m_md5 = qstr(alpm_pkg_get_md5sum(package));
|
|
m_sha256 = qstr(alpm_pkg_get_sha256sum(package));
|
|
m_buildArchitecture = qstr(alpm_pkg_get_arch(package));
|
|
m_packageSize = alpm_pkg_get_size(package);
|
|
m_installDate = DateTime::fromTimeStamp(alpm_pkg_get_installdate(package));
|
|
m_installedSize = alpm_pkg_get_isize(package);
|
|
for(const auto *backupEntry : BackupList(alpm_pkg_get_backup(package))) {
|
|
m_backupFiles << qstr(backupEntry->name);
|
|
}
|
|
m_validationMethods = alpm_pkg_get_validation(package);
|
|
m_installReason = alpm_pkg_get_reason(package);
|
|
alpm_filelist_t *fileList = alpm_pkg_get_files(package);
|
|
for(alpm_file_t *file = fileList->files, *end = fileList->files + fileList->count; file != end; ++file) {
|
|
QJsonObject fileInfo;
|
|
fileInfo.insert(QStringLiteral("name"), qstr(file->name));
|
|
if(file->mode) {
|
|
fileInfo.insert(QStringLiteral("mode"), static_cast<int>(file->mode));
|
|
}
|
|
if(file->size) {
|
|
fileInfo.insert(QStringLiteral("size"), static_cast<int>(file->size));
|
|
}
|
|
m_files << fileInfo;
|
|
}
|
|
}
|
|
|
|
} // namespace PackageManagement
|
|
|