加入包管理器模块雏形

This commit is contained in:
RigoLigoRLC
2022-02-13 21:18:48 +08:00
parent f2e417e02a
commit 2221d5c816
10 changed files with 242 additions and 2 deletions
+23
View File
@@ -0,0 +1,23 @@
#include <QFile>
#include "pkgs/spkpkgmgrapt.h"
SpkPkgMgrApt::SpkPkgMgrApt(QObject *parent) :
SpkPkgMgrBase(parent)
{
}
bool SpkPkgMgrApt::DetectRequirements()
{
return QFile::exists("/usr/bin/apt") &&
QFile::exists("/etc/apt/apt.conf");
}
SpkPkgMgrBase::PkgInstallResult
SpkPkgMgrApt::ExecuteInstallation(QString pkgPath, int entryId)
{
}
+28
View File
@@ -0,0 +1,28 @@
#include "pkgs/spkpkgmgrpacman.h"
#include <QFile>
SpkPkgMgrBase *SpkPkgMgrBase::mInstance = nullptr;
SpkPkgMgrPacman::SpkPkgMgrPacman(QObject *parent) :
SpkPkgMgrBase(parent)
{
mActDesc = new QAction(tr("ArchLinux Pacman"), this);
mActDesc->setEnabled(false);
mMenu->addSeparator();
mMenu->addAction(mActDesc);
}
bool SpkPkgMgrPacman::DetectRequirements()
{
return QFile::exists("/usr/bin/pacman") &&
QFile::exists("/etc/pacman.conf");
}
SpkPkgMgrBase::PkgInstallResult
SpkPkgMgrPacman::ExecuteInstallation(QString pkgPath, int entryId)
{
SpkPkgMgrBase::ExecuteInstallation(pkgPath, entryId);
}
+11
View File
@@ -11,6 +11,8 @@
#include "spkpopup.h"
#include "spkstore.h"
#include "spkutils.h"
#include "pkgs/spkpkgmgrpacman.h"
#include "pkgs/spkpkgmgrapt.h"
SpkStore *SpkStore::Instance = nullptr;
static bool InstallDefaultConfigs(QString configPath);
@@ -54,6 +56,15 @@ SpkStore::SpkStore(bool aCli, QString &aLogPath)
.arg(mDistroName + " @SparkDeveloper");
#endif
// Initialize package management backend
// Test for which backend fits
if(SpkPkgMgrApt::DetectRequirements())
new SpkPkgMgrApt(this);
else if(SpkPkgMgrPacman::DetectRequirements())
new SpkPkgMgrPacman(this);
else
new SpkPkgMgrBase(this);
// Finish all essential initialization before this.
if(aCli)
return;