mirror of
https://gitee.com/spark-store-project/spark-store
synced 2025-12-15 13:22:04 +08:00
Compare commits
17 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b1cb765b6e | |||
| 49c5583ea9 | |||
| b0dfd6a3da | |||
| a63c1202bd | |||
| dfe30f9d6d | |||
| b00f3fa501 | |||
| 03f35782c6 | |||
| 8f192d17ec | |||
| 0dc594b3f1 | |||
| 198384c552 | |||
| 958988d93c | |||
| 5f9599c47d | |||
| 766dc8b88a | |||
| 20d34a7369 | |||
| a0c14e7397 | |||
| f24565804d | |||
| 244176098c |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -51,3 +51,4 @@ debian/*.debhelper*
|
|||||||
debian/files
|
debian/files
|
||||||
debian/*.substvars
|
debian/*.substvars
|
||||||
debian/spark-store
|
debian/spark-store
|
||||||
|
|
||||||
|
|||||||
@@ -28,12 +28,19 @@ If you are using Debian11/Ubuntu 20.04, you will need extra dependency package.
|
|||||||
#### Compile and developement
|
#### Compile and developement
|
||||||
|
|
||||||
|
|
||||||
For Deepin V20/UOS 21/ Ubuntu 22.04/ Debian 11
|
For Deepin V20/UOS 21/ Debian 11
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
sudo apt install git qt5-default debhelper pkg-config qtchooser libqt5core5a libqt5gui5 libqt5widgets5 libqt5network5 libqt5concurrent5 libdtkcore-dev libdtkgui-dev libdtkwidget-dev qttools5-private-dev libnotify-dev qtwebengine5-dev
|
sudo apt install git qt5-default debhelper pkg-config qtchooser libqt5core5a libqt5gui5 libqt5widgets5 libqt5network5 libqt5concurrent5 libdtkcore-dev libdtkgui-dev libdtkwidget-dev qttools5-private-dev libnotify-dev qtwebengine5-dev
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Ubuntu 22.04
|
||||||
|
```shell
|
||||||
|
sudo apt install git qtbase5-dev debhelper pkg-config qtchooser libqt5core5a libqt5gui5 libqt5widgets5 libqt5network5 libqt5concurrent5 libdtkcore-dev libdtkgui-dev libdtkwidget-dev qttools5-private-dev libnotify-dev qtwebengine5-dev
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
Then
|
Then
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
|
|||||||
39
debian/changelog
vendored
39
debian/changelog
vendored
@@ -1,18 +1,43 @@
|
|||||||
spark-store (3.2) stable; urgency=medium
|
spark-store (3.1.4) stable; urgency=medium
|
||||||
|
|
||||||
|
* 发布正式版,同步到官网
|
||||||
|
* 修复安装时使用wget的问题
|
||||||
|
* 合并3.1.3-1和3.1.3-2的更改
|
||||||
|
* 屏蔽了ssinstall之外的安装方式
|
||||||
|
* 调整了报错框的形式
|
||||||
|
* 修复pkexec下ssinstall不处理依赖
|
||||||
|
|
||||||
|
-- shenmo <shenmo@spark-app.store> Fri, 30 Jan 2022 00:00:00 +0800
|
||||||
|
|
||||||
|
spark-store (3.1.3-2) stable; urgency=medium
|
||||||
|
|
||||||
|
* 调整 现在与系统更新分开,不再导致更新失败
|
||||||
|
* 支持直接更新软件源文件,不再让d.吃全部更新流量
|
||||||
|
* ss-apt-fast不再强制root权限
|
||||||
|
* 修改ss-apt-fast的策略,现在除了安装,下载和更新都改用apt
|
||||||
|
* ssinstall 现在也会在不适用ss-apt-fast的时候模拟源了(针对UOS)
|
||||||
|
|
||||||
|
|
||||||
|
-- shenmo <shenmo@spark-app.store> Fri, 30 Jan 2022 00:00:00 +0800
|
||||||
|
|
||||||
新增:ssinstall现在会在没有apt-fast的时候自动安装
|
spark-store (3.1.3-1) stable; urgency=medium
|
||||||
新增:ss-apt-fast现在会在没有apt-fast的时候自动安装
|
|
||||||
修改:删除ssinstall中无用的 || dpkg -P $1
|
* 修复 下载提前退出
|
||||||
新增:ss-apt-fast会先下载云上的conf以确保mirror是最新的
|
* 移除 下载量显示
|
||||||
修复:去除wget指令
|
|
||||||
|
|
||||||
|
|
||||||
|
-- shenmo <shenmo@spark-app.store> Fri, 30 Jan 2022 00:00:00 +0800
|
||||||
|
|
||||||
-- shenmo <shenmo@spark-app.store> Mon, 17 Jan 2022 00:00:00 +0800
|
spark-store (3.1.3) stable; urgency=medium
|
||||||
|
|
||||||
|
* Now uses aria2 to download softwares form all mirrors
|
||||||
|
* 新增:ssinstall现在会在没有apt-fast的时候自动安装
|
||||||
|
* 新增:ss-apt-fast现在会在没有apt-fast的时候自动安装
|
||||||
|
* 修改:删除ssinstall中无用的 || dpkg -P $1
|
||||||
|
* 新增:ss-apt-fast会先下载云上的conf以确保mirror是最新的
|
||||||
|
* 修复:去除wget指令
|
||||||
|
|
||||||
|
-- shenmo <shenmo@spark-app.store> Fri, 30 Jan 2022 00:00:00 +0800
|
||||||
|
|
||||||
spark-store (3.1.2) stable; urgency=medium
|
spark-store (3.1.2) stable; urgency=medium
|
||||||
|
|
||||||
|
|||||||
3
debian/control
vendored
3
debian/control
vendored
@@ -35,7 +35,8 @@ Depends:${shlibs:Depends}, ${misc:Depends},
|
|||||||
libnotify4,
|
libnotify4,
|
||||||
curl,
|
curl,
|
||||||
dde-qt5integration,
|
dde-qt5integration,
|
||||||
bubblewrap
|
bubblewrap,
|
||||||
|
aria2
|
||||||
Description: Spark Store
|
Description: Spark Store
|
||||||
A community powered app store, based on DTK.
|
A community powered app store, based on DTK.
|
||||||
Recommends: apt-fast
|
Recommends: apt-fast
|
||||||
|
|||||||
4
debian/rules
vendored
4
debian/rules
vendored
@@ -17,11 +17,12 @@ override_dh_auto_clean:
|
|||||||
|
|
||||||
override_dh_auto_configure:
|
override_dh_auto_configure:
|
||||||
mkdir -p $(CURDIR)/build
|
mkdir -p $(CURDIR)/build
|
||||||
|
|
||||||
dh_auto_configure MAKEFLAGS=-j$(JOBS) -- spark-store-project.pro \
|
dh_auto_configure MAKEFLAGS=-j$(JOBS) -- spark-store-project.pro \
|
||||||
-spec linux-g++ CONFIG+=qtquickcompiler \
|
-spec linux-g++ CONFIG+=qtquickcompiler \
|
||||||
-o $(CURDIR)/build/
|
-o $(CURDIR)/build/
|
||||||
|
|
||||||
|
|
||||||
override_dh_auto_build:
|
override_dh_auto_build:
|
||||||
make -C $(CURDIR)/build -j$(JOBS)
|
make -C $(CURDIR)/build -j$(JOBS)
|
||||||
|
|
||||||
@@ -29,6 +30,7 @@ override_dh_auto_install:
|
|||||||
make -C $(CURDIR)/build install \
|
make -C $(CURDIR)/build install \
|
||||||
INSTALL_ROOT=$(CURDIR)/debian/spark-store
|
INSTALL_ROOT=$(CURDIR)/debian/spark-store
|
||||||
|
|
||||||
|
|
||||||
# Ignore the dpkg-shlibdeps: warning (it uses none of the library's symbols)
|
# Ignore the dpkg-shlibdeps: warning (it uses none of the library's symbols)
|
||||||
# Qt Mutidedia lib will ref to network libraray.
|
# Qt Mutidedia lib will ref to network libraray.
|
||||||
override_dh_shlibdeps:
|
override_dh_shlibdeps:
|
||||||
|
|||||||
17
debian/spark-store.postinst
vendored
17
debian/spark-store.postinst
vendored
@@ -16,12 +16,23 @@ case "$1" in
|
|||||||
|
|
||||||
|
|
||||||
# Download and install key
|
# Download and install key
|
||||||
wget -O /tmp/spark-store-install/spark-store.asc https://d.store.deepinos.org.cn/dcs-repo.gpg-key.asc
|
curl --progress-bar -o /tmp/spark-store-install/spark-store.asc https://d.store.deepinos.org.cn/dcs-repo.gpg-key.asc
|
||||||
gpg --dearmor /tmp/spark-store-install/spark-store.asc
|
gpg --dearmor /tmp/spark-store-install/spark-store.asc
|
||||||
cp -f /tmp/spark-store-install/spark-store.asc.gpg /etc/apt/trusted.gpg.d/spark-store.gpg
|
cp -f /tmp/spark-store-install/spark-store.asc.gpg /etc/apt/trusted.gpg.d/spark-store.gpg
|
||||||
|
|
||||||
|
|
||||||
|
# Remove existing source file
|
||||||
|
rm -f /etc/apt/preferences.d/sparkstore
|
||||||
|
rm -f /etc/apt/sources.list.d/sparkstore.list
|
||||||
|
|
||||||
|
|
||||||
# Run apt update to avoid users being fucked up by the non-exist dependency problem
|
# Run apt update to avoid users being fucked up by the non-exist dependency problem
|
||||||
apt update -o Dir::Etc::sourcelist="sources.list.d/sparkstore.list" -o Dir::Etc::sourceparts="-" -o APT::Get::List-Cleanup="0"
|
|
||||||
|
curl --progress-bar -o /opt/durapps/spark-store/bin/apt-fast-conf/sources.list.d/sparkstore.list "https://gitee.com/deepin-community-store/repo_auto_update_script/raw/master/mirror-list-for-apt-fast/sources.list.d/sparkstore.list"
|
||||||
|
# 下载源列表
|
||||||
|
bwrap --dev-bind / / --bind '/opt/durapps/spark-store/bin/apt-fast-conf/sources.list.d/sparkstore.list' /etc/apt/sources.list.d/sparkstore.list apt update -o Dir::Etc::sourcelist="sources.list.d/sparkstore.list" -o Dir::Etc::sourceparts="-" -o APT::Get::List-Cleanup="0"
|
||||||
|
# 更新
|
||||||
|
|
||||||
|
|
||||||
# Create symbo links to start upgrade detect
|
# Create symbo links to start upgrade detect
|
||||||
ln -s /opt/durapps/spark-store/bin/update-upgrade/autostart/spark-update-notifier.desktop /etc/xdg/autostart/spark-update-notifier.desktop
|
ln -s /opt/durapps/spark-store/bin/update-upgrade/autostart/spark-update-notifier.desktop /etc/xdg/autostart/spark-update-notifier.desktop
|
||||||
@@ -42,6 +53,8 @@ case "$1" in
|
|||||||
|
|
||||||
# Remove temp dir
|
# Remove temp dir
|
||||||
rm -rf /tmp/spark-store-install
|
rm -rf /tmp/spark-store-install
|
||||||
|
|
||||||
|
|
||||||
;;
|
;;
|
||||||
|
|
||||||
triggered)
|
triggered)
|
||||||
|
|||||||
@@ -1,3 +0,0 @@
|
|||||||
Package: *
|
|
||||||
Pin: origin *.deepinos.org.cn
|
|
||||||
Pin-Priority: 400
|
|
||||||
@@ -45,18 +45,18 @@ downloadlist::downloadlist(QWidget *parent) :
|
|||||||
menu_install->addAction(action_dpkg);
|
menu_install->addAction(action_dpkg);
|
||||||
}
|
}
|
||||||
|
|
||||||
QFile deepin("/usr/bin/deepin-deb-installer");
|
// QFile deepin("/usr/bin/deepin-deb-installer");
|
||||||
deepin.open(QIODevice::ReadOnly);
|
// deepin.open(QIODevice::ReadOnly);
|
||||||
if(deepin.isOpen())
|
// if(deepin.isOpen())
|
||||||
{
|
// {
|
||||||
menu_install->addAction(action_deepin);
|
// menu_install->addAction(action_deepin);
|
||||||
}
|
// }
|
||||||
QFile gdebi("/usr/bin/gdebi");
|
// QFile gdebi("/usr/bin/gdebi");
|
||||||
gdebi.open(QIODevice::ReadOnly);
|
// gdebi.open(QIODevice::ReadOnly);
|
||||||
if(gdebi.isOpen())
|
// if(gdebi.isOpen())
|
||||||
{
|
// {
|
||||||
menu_install->addAction(action_gdebi);
|
// menu_install->addAction(action_gdebi);
|
||||||
}
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -92,19 +92,6 @@ QString downloadlist::getName()
|
|||||||
|
|
||||||
void downloadlist::readyInstall()
|
void downloadlist::readyInstall()
|
||||||
{
|
{
|
||||||
if(ui->progressBar->value() != ui->progressBar->maximum() && !close)
|
|
||||||
{
|
|
||||||
ui->progressBar->hide();
|
|
||||||
ui->pushButton_install->show();
|
|
||||||
ui->pushButton_2->hide();
|
|
||||||
Widget::sendNotification(tr("Failed to download %1").arg(ui->label->text()), 5000,
|
|
||||||
"/tmp/spark-store/icon_" + QString::number(num).toUtf8() + ".png");
|
|
||||||
ui->label_2->setText(tr("Download Failed,Check Your Connection"));
|
|
||||||
ui->pushButton_install->setEnabled(false);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!close)
|
if(!close)
|
||||||
{
|
{
|
||||||
ui->progressBar->hide();
|
ui->progressBar->hide();
|
||||||
@@ -232,6 +219,7 @@ void downloadlist::on_pushButton_3_clicked()
|
|||||||
{
|
{
|
||||||
textbrowser->setLineWidth(0);
|
textbrowser->setLineWidth(0);
|
||||||
textbrowser->setText(out);
|
textbrowser->setText(out);
|
||||||
|
textbrowser->setMinimumHeight(500);
|
||||||
|
|
||||||
output_w->setMinimumHeight(600);
|
output_w->setMinimumHeight(600);
|
||||||
output_w->setAttribute(Qt::WA_TranslucentBackground);
|
output_w->setAttribute(Qt::WA_TranslucentBackground);
|
||||||
|
|||||||
@@ -1,93 +1,15 @@
|
|||||||
#include "downloadworker.h"
|
#include "downloadworker.h"
|
||||||
|
|
||||||
#include <QEventLoop>
|
#include <QEventLoop>
|
||||||
#include <QNetworkAccessManager>
|
#include <QNetworkAccessManager>
|
||||||
#include <QNetworkRequest>
|
#include <QNetworkRequest>
|
||||||
#include <QNetworkReply>
|
#include <QNetworkReply>
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
|
#include <QProcess>
|
||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
|
#include <QElapsedTimer>
|
||||||
DownloadWorker::DownloadWorker(QObject *parent)
|
#include <QtConcurrent>
|
||||||
{
|
|
||||||
Q_UNUSED(parent)
|
|
||||||
}
|
|
||||||
|
|
||||||
void DownloadWorker::setIdentifier(int identifier)
|
|
||||||
{
|
|
||||||
this->identifier = identifier;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DownloadWorker::setParamter(const QString &url, QPair<qint64, qint64> range, QFile *file)
|
|
||||||
{
|
|
||||||
this->url = url;
|
|
||||||
this->startPos = range.first;
|
|
||||||
this->endPos = range.second;
|
|
||||||
this->file = file;
|
|
||||||
}
|
|
||||||
|
|
||||||
qint64 DownloadWorker::getReceivedPos()
|
|
||||||
{
|
|
||||||
return receivedPos;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DownloadWorker::doWork()
|
|
||||||
{
|
|
||||||
mgr = new QNetworkAccessManager(this);
|
|
||||||
QNetworkRequest request;
|
|
||||||
request.setUrl(url);
|
|
||||||
request.setAttribute(QNetworkRequest::FollowRedirectsAttribute, true);
|
|
||||||
request.setRawHeader("Range", QString("bytes=%1-%2").arg(startPos).arg(endPos).toLocal8Bit());
|
|
||||||
reply = mgr->get(request);
|
|
||||||
qDebug() << "开始下载数据:" << QString(" %1~%2 -> writePos Start %3").arg(startPos).arg(endPos).arg(receivedPos);
|
|
||||||
|
|
||||||
connect(reply, static_cast<void(QNetworkReply::*)(QNetworkReply::NetworkError) > (&QNetworkReply::error),
|
|
||||||
[this](QNetworkReply::NetworkError error)
|
|
||||||
{
|
|
||||||
if(error != QNetworkReply::NoError)
|
|
||||||
{
|
|
||||||
qDebug() << "出错了:" << reply->errorString();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
connect(reply, &QNetworkReply::finished, mgr, &QNetworkAccessManager::deleteLater);
|
|
||||||
connect(reply, &QNetworkReply::readyRead, this, &DownloadWorker::dataReady);
|
|
||||||
connect(reply, &QNetworkReply::finished, this, &DownloadWorker::slotFinish);
|
|
||||||
connect(reply, &QNetworkReply::downloadProgress, this, &DownloadWorker::handleProcess);
|
|
||||||
// connect(reply, &QNetworkReply::finished, reply, &QNetworkReply::deleteLater);
|
|
||||||
connect(reply, &QNetworkReply::finished, this, &DownloadWorker::doStop);
|
|
||||||
}
|
|
||||||
|
|
||||||
void DownloadWorker::doStop()
|
|
||||||
{
|
|
||||||
if (reply) {
|
|
||||||
reply->disconnect();
|
|
||||||
reply->aboutToClose();
|
|
||||||
reply->deleteLater();
|
|
||||||
reply = nullptr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void DownloadWorker::dataReady()
|
|
||||||
{
|
|
||||||
QByteArray data = reply->readAll();
|
|
||||||
file->seek(startPos + receivedPos);
|
|
||||||
file->write(data);
|
|
||||||
receivedPos += data.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
void DownloadWorker::slotFinish()
|
|
||||||
{
|
|
||||||
file->flush();
|
|
||||||
qDebug() << "数据块下载完毕:" << QString(" %1~%2 -> writePos Start %3").arg(startPos).arg(endPos).arg(receivedPos);
|
|
||||||
emit workFinished();
|
|
||||||
}
|
|
||||||
|
|
||||||
void DownloadWorker::handleProcess(qint64, qint64)
|
|
||||||
{
|
|
||||||
emit this->downloadProcess();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
DownloadController::DownloadController(QObject *parent)
|
DownloadController::DownloadController(QObject *parent)
|
||||||
{
|
{
|
||||||
@@ -97,29 +19,6 @@ DownloadController::DownloadController(QObject *parent)
|
|||||||
domains.clear();
|
domains.clear();
|
||||||
domains.append("d.store.deepinos.org.cn");
|
domains.append("d.store.deepinos.org.cn");
|
||||||
|
|
||||||
QFile serverList(QDir::homePath().toUtf8() + "/.config/spark-store/server.list");
|
|
||||||
if(serverList.open(QFile::ReadOnly))
|
|
||||||
{
|
|
||||||
QStringList list = QString(serverList.readAll()).trimmed().split("\n");
|
|
||||||
qDebug() << list << list.size();
|
|
||||||
|
|
||||||
for (int i = 0; i < list.size(); i++) {
|
|
||||||
if (list.at(i).contains("镜像源 Download only") && i + 1 < list.size()) {
|
|
||||||
for (int j = i + 1; j < list.size(); j++) {
|
|
||||||
system("curl -I -s --connect-timeout 5 " + list.at(j).toUtf8()
|
|
||||||
+ "/dcs-repo.gpg-key.asc -w %{http_code} |tail -n1 > /tmp/spark-store/cdnStatus.txt");
|
|
||||||
QFile cdnStatus("/tmp/spark-store/cdnStatus.txt");
|
|
||||||
if(cdnStatus.open(QFile::ReadOnly) && QString(cdnStatus.readAll()).toUtf8()=="200"){
|
|
||||||
qDebug() << list.at(j);
|
|
||||||
domains.append(list.at(j));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
qDebug() << domains << domains.size();
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
domains = {
|
domains = {
|
||||||
"d1.store.deepinos.org.cn",
|
"d1.store.deepinos.org.cn",
|
||||||
@@ -132,94 +31,159 @@ DownloadController::DownloadController(QObject *parent)
|
|||||||
this->threadNum = domains.size();
|
this->threadNum = domains.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
DownloadController::~DownloadController()
|
|
||||||
{
|
|
||||||
if(workers.size() > 0)
|
|
||||||
{
|
|
||||||
for(int i = 0; i < workers.size(); i++)
|
|
||||||
{
|
|
||||||
workers.at(i)->doStop();
|
|
||||||
workers.at(i)->disconnect();
|
|
||||||
workers.at(i)->deleteLater();
|
|
||||||
}
|
|
||||||
workers.clear();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void DownloadController::setFilename(QString filename)
|
void DownloadController::setFilename(QString filename)
|
||||||
{
|
{
|
||||||
this->filename = filename;
|
this->filename = filename;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DownloadController::setThreadNum(int threadNum)
|
void timeSleeper(int time)
|
||||||
{
|
{
|
||||||
this->threadNum = threadNum;
|
QElapsedTimer t1;
|
||||||
|
t1.start();
|
||||||
|
while(t1.elapsed()<time);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief 开始下载
|
* @brief 开始下载
|
||||||
*/
|
*/
|
||||||
void DownloadController::startDownload(const QString &url)
|
void DownloadController::startDownload(const QString &url)
|
||||||
{
|
{
|
||||||
finish = 0;
|
// 获取下载任务信息
|
||||||
|
|
||||||
// 下载任务等分,计算每个线程的下载数据
|
|
||||||
fileSize = getFileSize(url);
|
fileSize = getFileSize(url);
|
||||||
if(fileSize == 0)
|
if (fileSize == 0)
|
||||||
{
|
{
|
||||||
emit errorOccur("文件大小获取失败");
|
emit errorOccur("文件大小获取失败");
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
qint64 segmentSize = fileSize / threadNum;
|
|
||||||
ranges.resize(threadNum);
|
|
||||||
QVector<qint64> receivedBytes;
|
|
||||||
receivedBytes.resize(threadNum);
|
|
||||||
for(int i = 0; i < threadNum; i++)
|
|
||||||
{
|
|
||||||
ranges[i].first = i * segmentSize;
|
|
||||||
ranges[i].second = i * segmentSize + segmentSize - 1;
|
|
||||||
receivedBytes[i] = 0;
|
|
||||||
}
|
|
||||||
ranges[threadNum - 1].second = fileSize; // 余数部分加入最后一个
|
|
||||||
|
|
||||||
// 打开文件
|
|
||||||
QDir tmpdir("/tmp/spark-store");
|
|
||||||
file = new QFile;
|
|
||||||
file->setFileName(tmpdir.absoluteFilePath(filename));
|
|
||||||
|
|
||||||
if(file->exists())
|
|
||||||
{
|
|
||||||
file->remove();
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!file->open(QIODevice::WriteOnly))
|
|
||||||
{
|
|
||||||
delete file;
|
|
||||||
file = nullptr;
|
|
||||||
emit errorOccur(file->errorString());
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
file->resize(fileSize);
|
QtConcurrent::run([=]()
|
||||||
|
|
||||||
// 创建下载线程
|
|
||||||
workers.clear();
|
|
||||||
for(int i = 0; i < ranges.size(); i++)
|
|
||||||
{
|
{
|
||||||
qDebug() << QString("第%1个下载请求:%2-%3").arg(i).arg(ranges.at(i).first).arg(ranges.at(i).second);
|
QFile serverList(QDir::homePath().toUtf8() + "/.config/spark-store/server.list");
|
||||||
auto worker = new DownloadWorker(this);
|
if (serverList.open(QFile::ReadOnly))
|
||||||
auto range = ranges.at(i);
|
{
|
||||||
QString chunkUrl = replaceDomain(url, domains.at(i));
|
QStringList list = QString(serverList.readAll()).trimmed().split("\n");
|
||||||
worker->setIdentifier(i);
|
qDebug() << list << list.size();
|
||||||
worker->setParamter(chunkUrl, range, file);
|
domains.clear();
|
||||||
workers.append(worker);
|
|
||||||
|
|
||||||
connect(worker, &DownloadWorker::downloadProcess, this, &DownloadController::handleProcess);
|
for (int i = 0; i < list.size(); i++)
|
||||||
connect(worker, &DownloadWorker::workFinished, this, &DownloadController::chunkDownloadFinish);
|
{
|
||||||
|
if (list.at(i).contains("镜像源 Download only") && i + 1 < list.size())
|
||||||
|
{
|
||||||
|
for (int j = i + 1; j < list.size(); j++)
|
||||||
|
{
|
||||||
|
system("curl -I -s --connect-timeout 5 https://" + list.at(j).toUtf8() + "/dcs-repo.gpg-key.asc -w %{http_code} |tail -n1 > /tmp/spark-store/cdnStatus.txt");
|
||||||
|
QFile cdnStatus("/tmp/spark-store/cdnStatus.txt");
|
||||||
|
if (cdnStatus.open(QFile::ReadOnly) && QString(cdnStatus.readAll()).toUtf8() == "200")
|
||||||
|
{
|
||||||
|
qDebug() << list.at(j);
|
||||||
|
domains.append(list.at(j));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (domains.size() == 0)
|
||||||
|
{
|
||||||
|
domains.append("d.store.deepinos.org.cn");
|
||||||
|
}
|
||||||
|
qDebug() << domains << domains.size();
|
||||||
|
}
|
||||||
|
|
||||||
worker->doWork();
|
QDir tmpdir("/tmp/spark-store/");
|
||||||
}
|
QString aria2Command = "-d";
|
||||||
|
QString aria2Urls = "";
|
||||||
|
QString aria2Verbose = "--summary-interval=1";
|
||||||
|
QString aria2Threads = "-s " + QString::number(domains.size());
|
||||||
|
QString aria2NoConfig = "--no-conf";
|
||||||
|
QStringList command;
|
||||||
|
QString downloadDir = "/tmp/spark-store/";
|
||||||
|
|
||||||
|
|
||||||
|
for (int i = 0; i < domains.size(); i++)
|
||||||
|
{
|
||||||
|
command.append(replaceDomain(url, domains.at(i)).toUtf8());
|
||||||
|
aria2Urls += replaceDomain(url, domains.at(i));
|
||||||
|
aria2Urls += " ";
|
||||||
|
}
|
||||||
|
|
||||||
|
qint64 downloadSizeRecord = 0;
|
||||||
|
QString speedInfo = "";
|
||||||
|
QString percentInfo = "";
|
||||||
|
command.append(aria2Command.toUtf8());
|
||||||
|
command.append(downloadDir.toUtf8());
|
||||||
|
command.append(aria2Verbose.toUtf8());
|
||||||
|
command.append(aria2Threads.toUtf8());
|
||||||
|
command.append(aria2NoConfig.toUtf8());
|
||||||
|
qDebug() << command;
|
||||||
|
auto cmd = new QProcess();
|
||||||
|
cmd->setProcessChannelMode(QProcess::MergedChannels);
|
||||||
|
cmd->setProgram("aria2c");
|
||||||
|
cmd->setArguments(command);
|
||||||
|
cmd->start();
|
||||||
|
cmd->waitForStarted(); //等待启动完成
|
||||||
|
|
||||||
|
QObject::connect(cmd, &QProcess::readyReadStandardOutput,
|
||||||
|
[&]()
|
||||||
|
{
|
||||||
|
//通过读取输出计算下载速度
|
||||||
|
QFileInfo info(tmpdir.absoluteFilePath(filename));
|
||||||
|
QString message = cmd->readAllStandardOutput().data();
|
||||||
|
message = message.replace(" ", "").replace("\n", "").replace("-", "");
|
||||||
|
message = message.replace("*", "").replace("=", "");
|
||||||
|
QStringList list;
|
||||||
|
qint64 downloadSize = 0;
|
||||||
|
int downloadSizePlace1 = message.indexOf("(");
|
||||||
|
int downloadSizePlace2 = message.indexOf(")");
|
||||||
|
int speedPlace1 = message.indexOf("DL:");
|
||||||
|
int speedPlace2 = message.indexOf("ETA");
|
||||||
|
if (downloadSizePlace1 != -1 && downloadSizePlace2 != -1)
|
||||||
|
{
|
||||||
|
percentInfo = message.mid(downloadSizePlace1 + 1, downloadSizePlace2 - downloadSizePlace1 - 1).replace("%", "");
|
||||||
|
if (percentInfo != "s")
|
||||||
|
{
|
||||||
|
int percentInfoNumber = percentInfo.toUInt();
|
||||||
|
|
||||||
|
downloadSize = (percentInfoNumber + 1) * fileSize / 100;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (speedPlace1 != -1 && speedPlace2 != -1)
|
||||||
|
{
|
||||||
|
speedInfo = message.mid(speedPlace1 + 3, speedPlace2 - speedPlace1 - 3);
|
||||||
|
speedInfo += "/s";
|
||||||
|
}
|
||||||
|
qDebug() << percentInfo << speedInfo;
|
||||||
|
if (downloadSize >= downloadSizeRecord)
|
||||||
|
{
|
||||||
|
downloadSizeRecord = downloadSize;
|
||||||
|
}
|
||||||
|
if (percentInfo == "OK")
|
||||||
|
{
|
||||||
|
finished = true;
|
||||||
|
emit downloadProcess("", fileSize, fileSize);
|
||||||
|
qDebug() << "finished:" << finished;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
emit downloadProcess(speedInfo, downloadSizeRecord, fileSize);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
QObject::connect(cmd, &QProcess::readyReadStandardError,
|
||||||
|
[&]()
|
||||||
|
{
|
||||||
|
emit errorOccur(cmd->readAllStandardError().data());
|
||||||
|
return;
|
||||||
|
});
|
||||||
|
|
||||||
|
auto pidNumber = cmd->processId();
|
||||||
|
this->pidNumber = pidNumber;
|
||||||
|
while (cmd->waitForFinished(-1))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
emit downloadFinished();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -227,45 +191,13 @@ void DownloadController::startDownload(const QString &url)
|
|||||||
*/
|
*/
|
||||||
void DownloadController::stopDownload()
|
void DownloadController::stopDownload()
|
||||||
{
|
{
|
||||||
for(int i = 0; i < workers.size(); i++)
|
// 实现下载进程退出
|
||||||
{
|
QString killCmd = QString("kill -9 %1").arg(pidNumber);
|
||||||
workers.at(i)->doStop();
|
system(killCmd.toUtf8());
|
||||||
workers.at(i)->disconnect();
|
qDebug() << "kill aria2!";
|
||||||
workers.at(i)->deleteLater();
|
|
||||||
}
|
|
||||||
workers.clear();
|
|
||||||
qDebug() << "文件下载路径:" << QFileInfo(file->fileName()).absoluteFilePath();
|
|
||||||
|
|
||||||
file->flush();
|
|
||||||
file->close();
|
|
||||||
delete file;
|
|
||||||
file = nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
qint64 DownloadController::getFileSize(const QString &url)
|
||||||
void DownloadController::handleProcess()
|
|
||||||
{
|
|
||||||
qint64 bytesReceived = 0;
|
|
||||||
for(int i = 0; i < workers.size(); i++)
|
|
||||||
{
|
|
||||||
bytesReceived += workers.at(i)->getReceivedPos();
|
|
||||||
}
|
|
||||||
qDebug() << QString("下载进度 %1-%2").arg(bytesReceived).arg(fileSize);
|
|
||||||
emit downloadProcess(bytesReceived, fileSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
void DownloadController::chunkDownloadFinish()
|
|
||||||
{
|
|
||||||
finish++;
|
|
||||||
qDebug() << QString("已下载了%1块,共%2块!!!").arg(finish).arg(threadNum);
|
|
||||||
if(finish == threadNum)
|
|
||||||
{
|
|
||||||
stopDownload();
|
|
||||||
emit downloadFinished();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
qint64 DownloadController::getFileSize(const QString& url)
|
|
||||||
{
|
{
|
||||||
QEventLoop event;
|
QEventLoop event;
|
||||||
QNetworkAccessManager requestManager;
|
QNetworkAccessManager requestManager;
|
||||||
@@ -273,20 +205,19 @@ qint64 DownloadController::getFileSize(const QString& url)
|
|||||||
request.setUrl(QUrl(url));
|
request.setUrl(QUrl(url));
|
||||||
request.setAttribute(QNetworkRequest::FollowRedirectsAttribute, true);
|
request.setAttribute(QNetworkRequest::FollowRedirectsAttribute, true);
|
||||||
QNetworkReply *reply = requestManager.head(request);
|
QNetworkReply *reply = requestManager.head(request);
|
||||||
connect(reply, static_cast<void(QNetworkReply::*)(QNetworkReply::NetworkError) > (&QNetworkReply::error),
|
connect(reply, static_cast<void (QNetworkReply::*)(QNetworkReply::NetworkError)>(&QNetworkReply::error),
|
||||||
[this, reply](QNetworkReply::NetworkError error)
|
[this, reply](QNetworkReply::NetworkError error)
|
||||||
{
|
{
|
||||||
if(error != QNetworkReply::NoError)
|
if (error != QNetworkReply::NoError)
|
||||||
{
|
{
|
||||||
emit errorOccur(reply->errorString());
|
emit errorOccur(reply->errorString());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
connect(reply, &QNetworkReply::finished, &event, &QEventLoop::quit);
|
connect(reply, &QNetworkReply::finished, &event, &QEventLoop::quit);
|
||||||
event.exec();
|
event.exec();
|
||||||
|
|
||||||
qint64 fileSize = 0;
|
qint64 fileSize = 0;
|
||||||
if(reply->rawHeader("Accept-Ranges") == QByteArrayLiteral("bytes")
|
if (reply->rawHeader("Accept-Ranges") == QByteArrayLiteral("bytes") && reply->hasRawHeader(QString("Content-Length").toLocal8Bit()))
|
||||||
&& reply->hasRawHeader(QString("Content-Length").toLocal8Bit()))
|
|
||||||
{
|
{
|
||||||
fileSize = reply->header(QNetworkRequest::ContentLengthHeader).toUInt();
|
fileSize = reply->header(QNetworkRequest::ContentLengthHeader).toUInt();
|
||||||
}
|
}
|
||||||
@@ -295,10 +226,10 @@ qint64 DownloadController::getFileSize(const QString& url)
|
|||||||
return fileSize;
|
return fileSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString DownloadController::replaceDomain(const QString& url, const QString domain)
|
QString DownloadController::replaceDomain(const QString &url, const QString domain)
|
||||||
{
|
{
|
||||||
QRegularExpression regex(R"((?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z0-9][a-z0-9-]{0,61}[a-z0-9])");
|
QRegularExpression regex(R"((?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z0-9][a-z0-9-]{0,61}[a-z0-9])");
|
||||||
if(regex.match(url).hasMatch())
|
if (regex.match(url).hasMatch())
|
||||||
{
|
{
|
||||||
return QString(url).replace(regex.match(url).captured(), domain);
|
return QString(url).replace(regex.match(url).captured(), domain);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,52 +6,14 @@
|
|||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QNetworkReply>
|
#include <QNetworkReply>
|
||||||
|
|
||||||
class DownloadWorker : public QObject
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
explicit DownloadWorker(QObject *parent = nullptr);
|
|
||||||
|
|
||||||
void setIdentifier(int identifier);
|
|
||||||
void setParamter(const QString &url, QPair<qint64, qint64> range, QFile *flle);
|
|
||||||
qint64 getReceivedPos();
|
|
||||||
|
|
||||||
public slots:
|
|
||||||
void doWork();
|
|
||||||
void doStop();
|
|
||||||
void dataReady();
|
|
||||||
void slotFinish();
|
|
||||||
void handleProcess(qint64, qint64);
|
|
||||||
|
|
||||||
private:
|
|
||||||
int identifier;
|
|
||||||
QString url;
|
|
||||||
qint64 startPos;
|
|
||||||
qint64 endPos;
|
|
||||||
qint64 receivedPos = 0;
|
|
||||||
QNetworkReply *reply;
|
|
||||||
QNetworkAccessManager *mgr;
|
|
||||||
QFile *file;
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void resultReady(int identifier, QByteArray data);
|
|
||||||
void testSignals();
|
|
||||||
void workFinished();
|
|
||||||
void downloadProcess();
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
class DownloadController : public QObject
|
class DownloadController : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit DownloadController(QObject *parent = nullptr);
|
explicit DownloadController(QObject *parent = nullptr);
|
||||||
~DownloadController();
|
|
||||||
|
|
||||||
void setFilename(QString filename);
|
void setFilename(QString filename);
|
||||||
void setThreadNum(int threadNum);
|
|
||||||
void startDownload(const QString &url);
|
void startDownload(const QString &url);
|
||||||
void stopDownload();
|
void stopDownload();
|
||||||
qint64 getFileSize(const QString& url);
|
qint64 getFileSize(const QString& url);
|
||||||
@@ -59,21 +21,19 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
int threadNum;
|
int threadNum;
|
||||||
|
int pidNumber;
|
||||||
QString filename;
|
QString filename;
|
||||||
qint64 fileSize;
|
qint64 fileSize;
|
||||||
QVector<QPair<qint64, qint64>> ranges;
|
QVector<QPair<qint64, qint64>> ranges;
|
||||||
QFile *file;
|
QFile *file;
|
||||||
QList<DownloadWorker*> workers;
|
bool finished = false;
|
||||||
int finish = 0;
|
|
||||||
QVector<QString> domains;
|
QVector<QString> domains;
|
||||||
|
|
||||||
public slots:
|
|
||||||
void handleProcess();
|
|
||||||
void chunkDownloadFinish();
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void errorOccur(const QString& msg);
|
void errorOccur(const QString& msg);
|
||||||
void downloadProcess(qint64, qint64);
|
void downloadProcess(QString, qint64, qint64);
|
||||||
void downloadFinished();
|
void downloadFinished();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ int main(int argc, char *argv[])
|
|||||||
DAboutDialog dialog;
|
DAboutDialog dialog;
|
||||||
a.setAboutDialog(&dialog);
|
a.setAboutDialog(&dialog);
|
||||||
dialog.setLicense(QObject::tr("We publish this program under GPL V3"));
|
dialog.setLicense(QObject::tr("We publish this program under GPL V3"));
|
||||||
dialog.setVersion(DApplication::buildVersion("Version 3.2"));
|
dialog.setVersion(DApplication::buildVersion("Version 3.1.4"));
|
||||||
dialog.setProductIcon(QIcon::fromTheme("spark-store")); // 设置Logo
|
dialog.setProductIcon(QIcon::fromTheme("spark-store")); // 设置Logo
|
||||||
dialog.setProductName(QLabel::tr("Spark Store"));
|
dialog.setProductName(QLabel::tr("Spark Store"));
|
||||||
dialog.setDescription(
|
dialog.setDescription(
|
||||||
@@ -51,7 +51,7 @@ int main(int argc, char *argv[])
|
|||||||
a.setOrganizationName("spark-union");
|
a.setOrganizationName("spark-union");
|
||||||
a.setOrganizationDomain("https://www.deepinos.org/");
|
a.setOrganizationDomain("https://www.deepinos.org/");
|
||||||
a.setApplicationName("Spark Store"); //不需要翻译,否则 ~/.local/share/ 下文件夹名称也被翻译为中文
|
a.setApplicationName("Spark Store"); //不需要翻译,否则 ~/.local/share/ 下文件夹名称也被翻译为中文
|
||||||
a.setApplicationVersion(DApplication::buildVersion("3.2"));
|
a.setApplicationVersion(DApplication::buildVersion("3.1.4"));
|
||||||
a.setApplicationAcknowledgementPage("https://gitee.com/deepin-community-store/spark-store");
|
a.setApplicationAcknowledgementPage("https://gitee.com/deepin-community-store/spark-store");
|
||||||
a.setApplicationDescription(
|
a.setApplicationDescription(
|
||||||
QObject::tr(
|
QObject::tr(
|
||||||
|
|||||||
@@ -47,11 +47,6 @@ Widget::Widget(DBlurEffectWidget *parent) :
|
|||||||
|
|
||||||
httpClient = new AeaQt::HttpClient;
|
httpClient = new AeaQt::HttpClient;
|
||||||
|
|
||||||
QtConcurrent::run([=]()
|
|
||||||
{
|
|
||||||
downloadController = new DownloadController(this); // 并发下载
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
connect(ui->menu_main, &QPushButton::clicked, this, [=](){Widget::chooseLeftMenu(0);});
|
connect(ui->menu_main, &QPushButton::clicked, this, [=](){Widget::chooseLeftMenu(0);});
|
||||||
connect(ui->menu_network, &QPushButton::clicked, this, [=](){Widget::chooseLeftMenu(1);});
|
connect(ui->menu_network, &QPushButton::clicked, this, [=](){Widget::chooseLeftMenu(1);});
|
||||||
@@ -113,10 +108,9 @@ Widget::Widget(DBlurEffectWidget *parent) :
|
|||||||
download_speed.start();
|
download_speed.start();
|
||||||
connect(&download_speed,&QTimer::timeout,[=]()
|
connect(&download_speed,&QTimer::timeout,[=]()
|
||||||
{
|
{
|
||||||
if(isdownload)
|
if(isdownload && theSpeed == "")
|
||||||
{
|
{
|
||||||
size1 = download_size;
|
size1 = download_size;
|
||||||
QString theSpeed;
|
|
||||||
double bspeed;
|
double bspeed;
|
||||||
bspeed = size1 - size2;
|
bspeed = size1 - size2;
|
||||||
if(bspeed < 1024)
|
if(bspeed < 1024)
|
||||||
@@ -134,10 +128,12 @@ Widget::Widget(DBlurEffectWidget *parent) :
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
theSpeed = QString::number(0.01 * int(100 * (bspeed / (1024 * 1024 * 1024)))) + "GB/s";
|
theSpeed = QString::number(0.01 * int(100 * (bspeed / (1024 * 1024 * 1024)))) + "GB/s";
|
||||||
}
|
}
|
||||||
download_list[nowDownload - 1].setSpeed(theSpeed);
|
|
||||||
size2 = download_size;
|
size2 = download_size;
|
||||||
}
|
}
|
||||||
|
if(isdownload){
|
||||||
|
download_list[nowDownload - 1].setSpeed(theSpeed);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
notify_init(tr("Spark\\ Store").toLocal8Bit());
|
notify_init(tr("Spark\\ Store").toLocal8Bit());
|
||||||
@@ -672,6 +668,7 @@ void Widget::startRequest(QUrl url, QString fileName)
|
|||||||
isdownload = true;
|
isdownload = true;
|
||||||
download_list[allDownload - 1].free = false;
|
download_list[allDownload - 1].free = false;
|
||||||
|
|
||||||
|
downloadController = new DownloadController(this); // 并发下载,在点击下载按钮的时候才会初始化
|
||||||
connect(downloadController, &DownloadController::downloadProcess, this, &Widget::updateDataReadProgress);
|
connect(downloadController, &DownloadController::downloadProcess, this, &Widget::updateDataReadProgress);
|
||||||
connect(downloadController, &DownloadController::downloadFinished, this, &Widget::httpFinished);
|
connect(downloadController, &DownloadController::downloadFinished, this, &Widget::httpFinished);
|
||||||
connect(downloadController, &DownloadController::errorOccur, this, [=](QString msg){this->sendNotification(msg);});
|
connect(downloadController, &DownloadController::errorOccur, this, [=](QString msg){this->sendNotification(msg);});
|
||||||
@@ -792,15 +789,15 @@ void Widget::httpReadyRead()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Widget::updateDataReadProgress(qint64 bytesRead, qint64 totalBytes)
|
void Widget::updateDataReadProgress(QString speedInfo, qint64 bytesRead, qint64 totalBytes)
|
||||||
{
|
{
|
||||||
if(totalBytes <= 0)
|
if(totalBytes <= 0)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
theSpeed = speedInfo;
|
||||||
download_list[nowDownload - 1].setMax(10000); // 最大值
|
download_list[nowDownload - 1].setMax(10000); // 最大值
|
||||||
download_list[nowDownload - 1].setValue((bytesRead * 10000) / totalBytes); // 当前值
|
download_list[nowDownload - 1].setValue(int(bytesRead * 100 / totalBytes) * 100); // 当前值
|
||||||
download_size = bytesRead;
|
download_size = bytesRead;
|
||||||
if(download_list[nowDownload - 1].close)
|
if(download_list[nowDownload - 1].close)
|
||||||
{
|
{
|
||||||
@@ -959,7 +956,9 @@ void Widget::httpFinished() // 完成下载
|
|||||||
download_list[nowDownload - 1].free = true;
|
download_list[nowDownload - 1].free = true;
|
||||||
if(nowDownload < allDownload)
|
if(nowDownload < allDownload)
|
||||||
{
|
{
|
||||||
|
|
||||||
// 如果有排队则下载下一个
|
// 如果有排队则下载下一个
|
||||||
|
qDebug() << "切换下一个下载...";
|
||||||
nowDownload += 1;
|
nowDownload += 1;
|
||||||
while(download_list[nowDownload - 1].close)
|
while(download_list[nowDownload - 1].close)
|
||||||
{
|
{
|
||||||
@@ -1043,7 +1042,7 @@ void Widget::on_pushButton_updateServer_clicked()
|
|||||||
ui->comboBox_server->clear();
|
ui->comboBox_server->clear();
|
||||||
|
|
||||||
QFile::remove(QDir::homePath().toUtf8() + "/.config/spark-store/server.list");
|
QFile::remove(QDir::homePath().toUtf8() + "/.config/spark-store/server.list");
|
||||||
system("curl -o " + QDir::homePath().toUtf8() + "/.config/spark-store/server.list https://d.store.deepinos.org.cn/store/server.list");
|
system("curl -o " + QDir::homePath().toUtf8() + "/.config/spark-store/server.list https://d.store.deepinos.org.cn/store/server-and-mirror.list");
|
||||||
std::fstream server;
|
std::fstream server;
|
||||||
server.open(QDir::homePath().toUtf8() + "/.config/spark-store/server.list", std::ios::in);
|
server.open(QDir::homePath().toUtf8() + "/.config/spark-store/server.list", std::ios::in);
|
||||||
std::string lineTmp;
|
std::string lineTmp;
|
||||||
@@ -1329,7 +1328,7 @@ void Widget::on_webEngineView_urlChanged(const QUrl &arg1)
|
|||||||
ui->label_appname->clear();
|
ui->label_appname->clear();
|
||||||
ui->pushButton_download->setEnabled(false);
|
ui->pushButton_download->setEnabled(false);
|
||||||
ui->stackedWidget->setCurrentIndex(2);
|
ui->stackedWidget->setCurrentIndex(2);
|
||||||
qDebug() << "https://demo-one-vert.vercel.app/" + type_name + "/" + pname;
|
qDebug() << "https://d.store.deepinos.org.cn/" + type_name + "/" + pname;
|
||||||
qDebug() << "链接地址:" << arg1;
|
qDebug() << "链接地址:" << arg1;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ private slots:
|
|||||||
|
|
||||||
void httpFinished();
|
void httpFinished();
|
||||||
void httpReadyRead();
|
void httpReadyRead();
|
||||||
void updateDataReadProgress(qint64,qint64);
|
void updateDataReadProgress(QString, qint64, qint64);
|
||||||
|
|
||||||
// SpkAppInfoLoaderThread的槽函数
|
// SpkAppInfoLoaderThread的槽函数
|
||||||
void sltAppinfoResetUi();
|
void sltAppinfoResetUi();
|
||||||
@@ -147,6 +147,7 @@ private:
|
|||||||
QFuture<void> load;
|
QFuture<void> load;
|
||||||
QFutureWatcher<void> watchScreenshotLoad;
|
QFutureWatcher<void> watchScreenshotLoad;
|
||||||
QTimer download_speed;
|
QTimer download_speed;
|
||||||
|
QString theSpeed;
|
||||||
QString type_name;
|
QString type_name;
|
||||||
QColor main_color;
|
QColor main_color;
|
||||||
int foot;
|
int foot;
|
||||||
|
|||||||
1
tool/apt-fast-conf/sources.list.d/sparkstore.list
Normal file
1
tool/apt-fast-conf/sources.list.d/sparkstore.list
Normal file
@@ -0,0 +1 @@
|
|||||||
|
deb [by-hash=force] https://d.store.deepinos.org.cn /
|
||||||
@@ -1,18 +1,42 @@
|
|||||||
#/bin/bash
|
#/bin/bash
|
||||||
|
|
||||||
if [ "$(id -u)" != "0" ]
|
|
||||||
then
|
|
||||||
echo "ss-apt-fast需要在root下运行"
|
|
||||||
exit
|
if [ "$1" = "install" ] || [ "$1" = "upgrade" ] || [ "$1" = "download" ] ; then
|
||||||
fi
|
|
||||||
|
###刷新apt-fast配置
|
||||||
|
mkdir -p /tmp/ss-apt-fast-conf/sources.list.d
|
||||||
|
# 创建文件夹
|
||||||
|
echo "从服务器获取配置和镜像列表..."
|
||||||
|
echo "Getting server and mirror lists..."
|
||||||
|
echo
|
||||||
|
curl --progress-bar -o /tmp/ss-apt-fast-conf/apt-fast.conf "https://gitee.com/deepin-community-store/repo_auto_update_script/raw/master/mirror-list-for-apt-fast/apt-fast.conf"
|
||||||
|
chmod -R 755 /tmp/ss-apt-fast-conf
|
||||||
|
|
||||||
|
|
||||||
DEPEND=`which apt-fast`
|
DEPEND=`which apt-fast`
|
||||||
if [ "$DEPEND" = "" ] ; then
|
if [ "$DEPEND" = "" ] ; then
|
||||||
echo "未安装依赖:apt-fast 开始安装"
|
echo "未安装依赖:apt-fast 开始安装"
|
||||||
apt install apt-fast -y
|
sudo bwrap --dev-bind / / --bind '/opt/durapps/spark-store/bin/apt-fast-conf/sources.list.d/sparkstore.list' /etc/apt/sources.list.d/sparkstore.list apt update && sudo bwrap --dev-bind / / --bind '/opt/durapps/spark-store/bin/apt-fast-conf/sources.list.d/sparkstore.list' /etc/apt/sources.list.d/sparkstore.list apt install apt-fast -y
|
||||||
|
fi
|
||||||
|
###执行安装
|
||||||
|
bwrap --dev-bind / / \
|
||||||
|
--bind '/tmp/ss-apt-fast-conf/apt-fast.conf' /etc/apt-fast.conf \
|
||||||
|
--bind '/opt/durapps/spark-store/bin/apt-fast-conf/sources.list.d/sparkstore.list' /etc/apt/sources.list.d/sparkstore.list \
|
||||||
|
apt-fast "$@"
|
||||||
|
|
||||||
|
rm -rf /tmp/ss-apt-fast-conf
|
||||||
|
|
||||||
|
elif [ "$1" = "ssupdate" ];then
|
||||||
|
sudo curl --progress-bar -o /opt/durapps/spark-store/bin/apt-fast-conf/sources.list.d/sparkstore.list "https://gitee.com/deepin-community-store/repo_auto_update_script/raw/master/mirror-list-for-apt-fast/sources.list.d/sparkstore.list"
|
||||||
|
sudo bwrap --dev-bind / / --bind '/opt/durapps/spark-store/bin/apt-fast-conf/sources.list.d/sparkstore.list' /etc/apt/sources.list.d/sparkstore.list apt update -o Dir::Etc::sourcelist="sources.list.d/sparkstore.list" -o Dir::Etc::sourceparts="-" -o APT::Get::List-Cleanup="0"
|
||||||
|
#只更新星火源
|
||||||
|
|
||||||
|
else
|
||||||
|
bwrap --dev-bind / / \
|
||||||
|
--bind '/opt/durapps/spark-store/bin/apt-fast-conf/sources.list.d/sparkstore.list' /etc/apt/sources.list.d/sparkstore.list \
|
||||||
|
apt "$@"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
rm /opt/durapps/spark-store/bin/apt-fast-conf/apt-fast.conf
|
|
||||||
curl -o /opt/durapps/spark-store/bin/apt-fast-conf/apt-fast.conf "https://gitee.com/deepin-community-store/repo_auto_update_script/raw/master/mirror-list-for-apt-fast/apt-fast.conf"
|
|
||||||
|
|
||||||
bwrap --dev-bind / / --bind '/opt/durapps/spark-store/bin/apt-fast-conf/apt-fast.conf' /etc/apt-fast.conf apt-fast "$@"
|
|
||||||
@@ -21,7 +21,7 @@ then
|
|||||||
echo "ssinstall需要在root下运行";
|
echo "ssinstall需要在root下运行";
|
||||||
uname=`whoami`
|
uname=`whoami`
|
||||||
echo "Now input the password of $uname"
|
echo "Now input the password of $uname"
|
||||||
read upass
|
read -e upass
|
||||||
################检查密码对不对
|
################检查密码对不对
|
||||||
echo "$upass" | sudo -S echo "i love amber forever"
|
echo "$upass" | sudo -S echo "i love amber forever"
|
||||||
passcheck=`echo "$upass" | sudo -S echo "i love amber forever"`
|
passcheck=`echo "$upass" | sudo -S echo "i love amber forever"`
|
||||||
@@ -46,61 +46,45 @@ isuos=`cat /etc/os-release | grep UnionTech`
|
|||||||
##############判断是否是root运行,如果是,则正常走;如果不是,则代输密码
|
##############判断是否是root运行,如果是,则正常走;如果不是,则代输密码
|
||||||
if [ "$(id -u)" != "0" ];then
|
if [ "$(id -u)" != "0" ];then
|
||||||
#############################无root权限时
|
#############################无root权限时
|
||||||
#临时提升星火源的优先级
|
|
||||||
echo "$upass" | sudo -S sed -i 's/400/500/g' /etc/apt/preferences.d/sparkstore
|
|
||||||
|
|
||||||
IS_INSTALLED=`which apt-fast`
|
|
||||||
if [ "$IS_INSTALLED" = "" ] ; then
|
|
||||||
echo "未安装依赖:apt-fast 开始安装"
|
|
||||||
echo "$upass" | sudo -S apt install apt-fast -y
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if [ "$DEPEND" != "" ] && [ "$isuos" != "" ]; then
|
if [ "$DEPEND" != "" ] && [ "$isuos" != "" ]; then
|
||||||
echo "UOS中系统依赖无法使用第三方下载工具,放弃使用apt-fast"
|
echo "UOS中系统依赖无法使用第三方下载工具,放弃使用apt-fast"
|
||||||
echo ----------------------------------------------------------------------------------
|
echo ----------------------------------------------------------------------------------
|
||||||
echo "$upass" | sudo -S dpkg -i $1 || apt install -yf
|
echo "$upass" | sudo -S dpkg -i $1 || sudo /usr/local/bin/ss-apt-fast ssupdate && sudo bwrap --dev-bind / / --bind '/opt/durapps/spark-store/bin/apt-fast-conf/sources.list.d/sparkstore.list' /etc/apt/sources.list.d/sparkstore.list apt install -yf
|
||||||
|
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$DEPEND" != "" ] && [ "$isuos" = "" ]; then
|
if [ "$DEPEND" != "" ] && [ "$isuos" = "" ]; then
|
||||||
echo "检测到apt-fast,使用ss-apt-fast进行多线程下载加速"
|
echo "检测到apt-fast,使用/usr/local/bin/ss-apt-fast进行多线程下载加速"
|
||||||
echo ----------------------------------------------------------------------------------
|
echo ----------------------------------------------------------------------------------
|
||||||
echo "$upass" | sudo -S dpkg -i $1 || ss-apt-fast install -yf
|
echo "$upass" | sudo -S dpkg -i $1 || sudo /usr/local/bin/ss-apt-fast ssupdate && sudo /usr/local/bin/ss-apt-fast install -yf
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "$upass" | sudo -S sed -i 's/500/400/g' /etc/apt/preferences.d/sparkstore
|
|
||||||
#恢复优先级
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
else
|
else
|
||||||
###########################有root权限时
|
###########################有root权限时
|
||||||
|
|
||||||
#临时提升星火源的优先级
|
|
||||||
sed -i 's/400/500/g' /etc/apt/preferences.d/sparkstore
|
|
||||||
|
|
||||||
IS_INSTALLED=`which apt-fast`
|
|
||||||
if [ "$IS_INSTALLED" = "" ] ; then
|
|
||||||
echo "未安装依赖:apt-fast 开始安装"
|
|
||||||
apt install apt-fast -y
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
if [ "$DEPEND" != "" ] && [ "$isuos" != "" ]; then
|
if [ "$DEPEND" != "" ] && [ "$isuos" != "" ]; then
|
||||||
echo "UOS中系统依赖无法使用第三方下载工具,放弃使用apt-fast"
|
echo "UOS中系统依赖无法使用第三方下载工具,放弃使用apt-fast"
|
||||||
echo ----------------------------------------------------------------------------------
|
echo ----------------------------------------------------------------------------------
|
||||||
dpkg -i $1 || apt install -yf
|
dpkg -i $1 || /usr/local/bin/ss-apt-fast ssupdate && bwrap --dev-bind / / --bind '/opt/durapps/spark-store/bin/apt-fast-conf/sources.list.d/sparkstore.list' /etc/apt/sources.list.d/sparkstore.list apt update && sudo bwrap --dev-bind / / --bind '/opt/durapps/spark-store/bin/apt-fast-conf/sources.list.d/sparkstore.list' /etc/apt/sources.list.d/sparkstore.list apt install -yf
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$DEPEND" != "" ] && [ "$isuos" = "" ]; then
|
if [ "$DEPEND" != "" ] && [ "$isuos" = "" ]; then
|
||||||
echo "检测到apt-fast,使用ss-apt-fast进行多线程下载加速"
|
echo "检测到apt-fast,使用/usr/local/bin/ss-apt-fast进行多线程下载加速"
|
||||||
echo ----------------------------------------------------------------------------------
|
echo ----------------------------------------------------------------------------------
|
||||||
dpkg -i $1 || ss-apt-fast install -yf
|
dpkg -i $1 || /usr/local/bin/ss-apt-fast ssupdate && /usr/local/bin/ss-apt-fast install -yf
|
||||||
fi
|
fi
|
||||||
|
|
||||||
sed -i 's/500/400/g' /etc/apt/preferences.d/sparkstore
|
|
||||||
#恢复优先级
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,12 @@
|
|||||||
echo "以上可升级,是否升级?[y/n]"
|
echo "以上可升级,是否升级?[y/n]"
|
||||||
read yes_or_no
|
read yes_or_no
|
||||||
if [ "$yes_or_no" = "y" ];then
|
if [ "$yes_or_no" = "y" ];then
|
||||||
sudo ss-apt-fast upgrade -y -o Dir::Etc::sourcelist="sources.list.d/sparkstore.list" -o Dir::Etc::sourceparts="-" -o APT::Get::List-Cleanup="0"
|
mkdir -p /tmp/ss-apt-fast-conf/sources.list.d
|
||||||
|
|
||||||
|
|
||||||
|
sudo bwrap --dev-bind / / --bind '/opt/durapps/spark-store/bin/apt-fast-conf/sources.list.d/sparkstore.list' /etc/apt/sources.list.d/sparkstore.list ss-apt-fast upgrade -y -o Dir::Etc::sourcelist="sources.list.d/sparkstore.list" -o Dir::Etc::sourceparts="-" -o APT::Get::List-Cleanup="0"
|
||||||
|
|
||||||
|
|
||||||
else
|
else
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
@@ -30,7 +30,7 @@ echo "输入2 查看可更新软件包列表并决定是否更新"
|
|||||||
echo "输入3 $text_auto_install_open点击安装免输入密码功能"
|
echo "输入3 $text_auto_install_open点击安装免输入密码功能"
|
||||||
echo "输入4 退出脚本"
|
echo "输入4 退出脚本"
|
||||||
echo
|
echo
|
||||||
read option
|
read -e option
|
||||||
|
|
||||||
case $option in
|
case $option in
|
||||||
0)
|
0)
|
||||||
@@ -73,7 +73,8 @@ case $option in
|
|||||||
2)
|
2)
|
||||||
echo "请注意:如果有些更新需要从系统获取更多依赖,你将需要手动操作 sudo ss-apt-fast upgrade"
|
echo "请注意:如果有些更新需要从系统获取更多依赖,你将需要手动操作 sudo ss-apt-fast upgrade"
|
||||||
echo "执行以下操作需要授权..."
|
echo "执行以下操作需要授权..."
|
||||||
/opt/durapps/spark-store/bin/update-upgrade/ss-upgrade-list.sh
|
sudo ss-apt-fast ssupdate
|
||||||
|
/opt/durapps/spark-store/bin/update-upgrade/ss-upgrade-list.sh
|
||||||
/opt/durapps/spark-store/bin/update-upgrade/ss-do-upgrade.sh
|
/opt/durapps/spark-store/bin/update-upgrade/ss-do-upgrade.sh
|
||||||
echo "---请按回车返回"
|
echo "---请按回车返回"
|
||||||
read
|
read
|
||||||
|
|||||||
@@ -36,8 +36,11 @@ fi
|
|||||||
|
|
||||||
#The code above is modified from https://blog.csdn.net/yaxuan88521/article/details/120516298
|
#The code above is modified from https://blog.csdn.net/yaxuan88521/article/details/120516298
|
||||||
|
|
||||||
|
curl --progress-bar -o /opt/durapps/spark-store/bin/apt-fast-conf/sources.list.d/sparkstore.list "https://gitee.com/deepin-community-store/repo_auto_update_script/raw/master/mirror-list-for-apt-fast/sources.list.d/sparkstore.list"
|
||||||
|
# 每日更新星火源文件
|
||||||
|
|
||||||
|
updatetext=`ss-apt-fast ssupdate`
|
||||||
|
|
||||||
updatetext=`sudo apt update -o Dir::Etc::sourcelist="sources.list.d/sparkstore.list" -o Dir::Etc::sourceparts="-" -o APT::Get::List-Cleanup="0"`
|
|
||||||
|
|
||||||
mkdir -p /tmp/spark-store-updatenum/
|
mkdir -p /tmp/spark-store-updatenum/
|
||||||
|
|
||||||
|
|||||||
@@ -3,4 +3,4 @@ set -e
|
|||||||
|
|
||||||
|
|
||||||
echo "---可更新的应用有:"
|
echo "---可更新的应用有:"
|
||||||
sudo apt list --upgradable -o Dir::Etc::sourcelist="sources.list.d/sparkstore.list" -o Dir::Etc::sourceparts="-" -o APT::Get::List-Cleanup="0"
|
bwrap --dev-bind / / --bind '/opt/durapps/spark-store/bin/apt-fast-conf/sources.list.d/sparkstore.list' /etc/apt/sources.list.d/sparkstore.list apt list --upgradable -o Dir::Etc::sourcelist="sources.list.d/sparkstore.list" -o Dir::Etc::sourceparts="-" -o APT::Get::List-Cleanup="0"
|
||||||
|
|||||||
@@ -38,9 +38,9 @@ else
|
|||||||
until [ -f "/usr/share/ca-certificates/deepin/private/priv.crt" ] ; do
|
until [ -f "/usr/share/ca-certificates/deepin/private/priv.crt" ] ; do
|
||||||
echo "没有检测到证书,准备调用证书工具生成证书,请输入您的UOS账号/密码。本脚本不会上传任何信息"
|
echo "没有检测到证书,准备调用证书工具生成证书,请输入您的UOS账号/密码。本脚本不会上传任何信息"
|
||||||
echo "请在此行输入您的UOS账号用户名/电话号/邮箱"
|
echo "请在此行输入您的UOS账号用户名/电话号/邮箱"
|
||||||
read account
|
read -e account
|
||||||
echo "请在此行输入您的UOS账号密码"
|
echo "请在此行输入您的UOS账号密码"
|
||||||
read passwd
|
read -e passwd
|
||||||
echo "即将安装证书,请在弹出的窗口安装"
|
echo "即将安装证书,请在弹出的窗口安装"
|
||||||
cert-tool -username="$account" -password="$passwd"
|
cert-tool -username="$account" -password="$passwd"
|
||||||
done
|
done
|
||||||
|
|||||||
Reference in New Issue
Block a user