mirror of
https://gitee.com/spark-store-project/spark-store
synced 2026-06-23 06:33:49 +08:00
加入包管理器模块雏形
This commit is contained in:
@@ -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)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -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,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;
|
||||
|
||||
Reference in New Issue
Block a user