AUR full package request
This commit is contained in:
parent
be6f06d534
commit
8043caf05b
|
@ -676,7 +676,7 @@ void Manager::cleanupAlpm()
|
|||
{
|
||||
if(m_handle) {
|
||||
alpm_release(m_handle);
|
||||
m_handle = 0;
|
||||
m_handle = nullptr;
|
||||
m_localDb.reset();
|
||||
m_syncDbs.clear();
|
||||
}
|
||||
|
|
|
@ -455,6 +455,11 @@ void Package::putInfo(const QList<QPair<QString, QString> > &baseInfo, const QLi
|
|||
}
|
||||
}
|
||||
|
||||
void Package::putSourceFile(const QString &path, const QByteArray &data)
|
||||
{
|
||||
m_sourceFiles.insert(make_pair(path, data));
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief The PackageVersion class helps parsing package versions.
|
||||
*/
|
||||
|
|
|
@ -176,6 +176,7 @@ public:
|
|||
|
||||
// parsing src/pkg info
|
||||
void putInfo(const QList<QPair<QString, QString> > &baseInfo, const QList<QPair<QString, QString> > &pkgInfo);
|
||||
void putSourceFile(const QString &path, const QByteArray &data);
|
||||
|
||||
protected:
|
||||
explicit Package(const QString &name, Repository *repository);
|
||||
|
@ -413,7 +414,8 @@ inline const QString &Package::fileName() const
|
|||
}
|
||||
|
||||
/*!
|
||||
* \brief Returns the file of the package as JSON array.
|
||||
* \brief Returns the paths of the files of the binary package as JSON array.
|
||||
* \remarks For source files see \a sourceFiles().
|
||||
*/
|
||||
inline const QJsonArray &Package::files() const
|
||||
{
|
||||
|
|
|
@ -92,12 +92,23 @@ void PackageInfoLookup::addResultsFromReply()
|
|||
assert(m_remainingReplies);
|
||||
auto *reply = static_cast<PackageReply *>(sender());
|
||||
reply->deleteLater();
|
||||
const auto *repo = reply->repository();
|
||||
addResultsDirectly(reply->requestedPackages(), repo);
|
||||
if(!--m_remainingReplies) {
|
||||
emit resultsAvailable(m_what, m_id, m_results);
|
||||
deleteLater();
|
||||
if(reply->error().isEmpty()) {
|
||||
addResultsDirectly(reply->requestedPackages(), reply->repository());
|
||||
if(!--m_remainingReplies) {
|
||||
emit resultsAvailable(m_what, m_id, m_results);
|
||||
deleteLater();
|
||||
}
|
||||
} else {
|
||||
// TODO: report error
|
||||
/*
|
||||
for(const auto &packageName : packageNames) {
|
||||
QJsonObject res;
|
||||
res.insert(QStringLiteral("name"), packageName);
|
||||
res.insert(QStringLiteral("repo"), repo->name());
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} // namespace RepoIndex
|
||||
|
|
|
@ -518,8 +518,8 @@ void Repository::restoreSpecificCacheHeader(QDataStream &in)
|
|||
}
|
||||
|
||||
/*!
|
||||
* \brief Adds a package parsed from the specified \a srcInfo.
|
||||
* \returns Returns the packages.
|
||||
* \brief Adds packages parsed from the specified \a srcInfo.
|
||||
* \returns Returns the added packages.
|
||||
*/
|
||||
QList<Package *> Repository::addPackagesFromSrcInfo(const QByteArray &srcInfo)
|
||||
{
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include <KTar>
|
||||
#include <KArchiveFile>
|
||||
#include <KFilterDev>
|
||||
|
||||
#include <QStringBuilder>
|
||||
#include <QUrlQuery>
|
||||
|
@ -15,6 +16,9 @@
|
|||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
#include <QJsonArray>
|
||||
#include <QDir>
|
||||
#include <QTemporaryFile>
|
||||
#include <QStringBuilder>
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -28,6 +32,8 @@ const QString rpcRequestTypeMultiInfo(QStringLiteral("multiinfo"));
|
|||
const QString rpcArgKey(QStringLiteral("arg"));
|
||||
const QString rpcArgArray(QStringLiteral("arg[]"));
|
||||
const QString pkgbuildRequestType(QString("pkgbuild"));
|
||||
|
||||
QString UserRepository::m_aurBaseUrl = QStringLiteral("https://aur.archlinux.org");
|
||||
QUrl UserRepository::m_aurRpcUrl = QUrl(QStringLiteral("https://aur.archlinux.org/rpc.php"));
|
||||
QUrl UserRepository::m_aurPkgbuildUrl = QUrl(QStringLiteral("https://aur.archlinux.org/cgit/aur.git/plain/PKGBUILD"));
|
||||
QUrl UserRepository::m_aurSrcInfoUrl = QUrl(QStringLiteral("https://aur.archlinux.org/cgit/aur.git/plain/.SRCINFO"));
|
||||
|
@ -79,20 +85,42 @@ void AurFullPackageReply::processData()
|
|||
{
|
||||
auto *reply = static_cast<QNetworkReply *>(sender());
|
||||
if(reply->error() == QNetworkReply::NoError) {
|
||||
KTar tar(reply);
|
||||
//QBuffer buffer;
|
||||
//buffer.setData(reply->readAll());
|
||||
QTemporaryFile tmpFile;
|
||||
tmpFile.setFileTemplate(QDir::tempPath() % QStringLiteral("/") % QStringLiteral("repoindex-XXXXXX.tar.gz"));
|
||||
tmpFile.open();
|
||||
tmpFile.write(reply->readAll());
|
||||
tmpFile.seek(0);
|
||||
//QFile testFile("/tmp/test.tar.gz");
|
||||
//testFile.open(QFile::WriteOnly);
|
||||
//testFile.write(buffer.data());
|
||||
//testFile.close();
|
||||
//testFile.open(QFile::ReadOnly);
|
||||
//buffer.open(QBuffer::ReadOnly);
|
||||
KCompressionDevice dev(&tmpFile, false, KCompressionDevice::GZip);
|
||||
KTar tar(tmpFile.fileName());
|
||||
if(tar.open(QIODevice::ReadOnly)) {
|
||||
const auto *baseDir = tar.directory();
|
||||
//const auto packageBase = baseDir->name();
|
||||
const auto *srcInfoEntry = baseDir->entry(QStringLiteral(".SRCINFO"));
|
||||
const KArchiveDirectory *baseDir;
|
||||
const KArchiveEntry *srcInfoEntry = nullptr;
|
||||
if(!tar.directory()->entries().isEmpty()) {
|
||||
const auto *baseEntry = tar.directory()->entry(tar.directory()->entries().front());
|
||||
if(baseEntry && baseEntry->isDirectory()) {
|
||||
baseDir = static_cast<const KArchiveDirectory *>(baseEntry);
|
||||
srcInfoEntry = baseDir->entry(QStringLiteral(".SRCINFO"));
|
||||
}
|
||||
}
|
||||
if(srcInfoEntry && srcInfoEntry->isFile()) {
|
||||
const QByteArray srcInfo = static_cast<const KArchiveFile *>(srcInfoEntry)->data();
|
||||
const auto srcInfo = static_cast<const KArchiveFile *>(srcInfoEntry)->data();
|
||||
const auto packages = m_userRepo->addPackagesFromSrcInfo(srcInfo);
|
||||
// TODO: error handling
|
||||
for(const auto &entryName : baseDir->entries()) {
|
||||
if(entryName != QLatin1String(".SRCINFO")) {
|
||||
const auto *entry = baseDir->entry(entryName);
|
||||
if(entry->isFile()) {
|
||||
for(const auto *package : packages) {
|
||||
const auto data = static_cast<const KArchiveFile *>(entry)->data();
|
||||
for(Package *package : packages) {
|
||||
package->putSourceFile(entry->name(), data);
|
||||
// TODO: add source files
|
||||
}
|
||||
} else {
|
||||
|
@ -109,6 +137,10 @@ void AurFullPackageReply::processData()
|
|||
} else {
|
||||
m_error = QStringLiteral("Error: Unable to request tarball from AUR: ") + reply->errorString();
|
||||
}
|
||||
if(!m_error.isEmpty()) {
|
||||
qDebug() << m_error;
|
||||
}
|
||||
emit resultsAvailable();
|
||||
}
|
||||
|
||||
AurSuggestionsReply::AurSuggestionsReply(QNetworkReply *networkReply, const QString &term, UserRepository *repo) :
|
||||
|
@ -241,7 +273,7 @@ AurFullPackageReply *UserRepository::requestFullPackageInfo(const QStringList &p
|
|||
if(pkg->tarUrl().isEmpty()) {
|
||||
replies << m_networkAccessManager.get(QNetworkRequest(m_aurSnapshotPath.arg(pkg->name())));
|
||||
} else {
|
||||
replies << m_networkAccessManager.get(QNetworkRequest(pkg->tarUrl()));
|
||||
replies << m_networkAccessManager.get(QNetworkRequest(m_aurBaseUrl + pkg->tarUrl()));
|
||||
}
|
||||
}
|
||||
} catch(const out_of_range &) {
|
||||
|
|
|
@ -74,6 +74,7 @@ protected:
|
|||
|
||||
private:
|
||||
QNetworkAccessManager &m_networkAccessManager;
|
||||
static QString m_aurBaseUrl;
|
||||
static QUrl m_aurRpcUrl;
|
||||
static QUrl m_aurPkgbuildUrl;
|
||||
static QUrl m_aurSrcInfoUrl;
|
||||
|
|
|
@ -11,8 +11,8 @@
|
|||
|
||||
"server": {
|
||||
"listeningPort": 1234,
|
||||
"certFile": "some.cert",
|
||||
"keyFile": "some.key",
|
||||
"certFile": "/run/media/martchus/files/programming/projects/c++/qmake/projects/repoindex/cert/test.crt",
|
||||
"keyFile": "/run/media/martchus/files/programming/projects/c++/qmake/projects/repoindex/cert/test.key",
|
||||
"insecure": false
|
||||
},
|
||||
|
||||
|
@ -20,14 +20,12 @@
|
|||
"fromPacmanConfig": true,
|
||||
|
||||
"add": [
|
||||
{"name": "examplerepo",
|
||||
"dataBaseFile": "path/to/database/file",
|
||||
{"name": "ownstuff",
|
||||
"sourcesDir": "path/to/local/source/dir",
|
||||
"packagesDir": "path/to/local/pkg/dir",
|
||||
"packagesDir": "/run/media/devel/repo/arch/ownstuff/os/x86_64",
|
||||
"upgradeSources": ["aur"],
|
||||
"server": [
|
||||
"https://some/mirror",
|
||||
"https://another/mirror"
|
||||
"https://localhost/repo/arch/$repo/os/$arch"
|
||||
]
|
||||
}
|
||||
]
|
Loading…
Reference in New Issue