mirror of
https://gitee.com/spark-store-project/spark-store
synced 2025-07-16 18:42:22 +08:00
更新到spark,加入apt-list的修改功能
This commit is contained in:
parent
147258a7ac
commit
a3ca04ddc5
@ -1,7 +1,7 @@
|
||||
# 星火商店
|
||||
|
||||
#### 介绍
|
||||
星火商店商店,由深度社区维护
|
||||
星火商店商店,由深度社区爱好者维护
|
||||
web页面部分正在开发当中,详情请见[web仓库](https://gitee.com/deepin-community-store/DCSAPP_WEB)
|
||||
|
||||
#### 说明
|
||||
|
54
widget.cpp
54
widget.cpp
@ -70,6 +70,7 @@ Widget::Widget(QWidget *parent) :
|
||||
configCanSeve=true;
|
||||
qDebug()<<serverUrl;
|
||||
menuUrl[0]=serverUrl + "store/#/";
|
||||
// menuUrl[0]="http://127.0.0.1:8000/#/relations";
|
||||
menuUrl[1]=serverUrl + "store/#/network/";
|
||||
menuUrl[2]=serverUrl + "store/#/relations";
|
||||
menuUrl[3]=serverUrl + "store/#/musicandsound";
|
||||
@ -117,7 +118,14 @@ Widget::Widget(QWidget *parent) :
|
||||
}
|
||||
});
|
||||
chooseLeftMenu(0);
|
||||
|
||||
QFile aptserver("/etc/apt/sources.list.d/sparkstore.list");
|
||||
aptserver.open(QIODevice::ReadOnly);
|
||||
if(aptserver.isOpen()){
|
||||
ui->label_aptserver->setText(aptserver.readAll());
|
||||
}else {
|
||||
ui->label_aptserver->setText("不存在");
|
||||
}
|
||||
aptserver.close();
|
||||
|
||||
}
|
||||
|
||||
@ -516,3 +524,47 @@ void Widget::on_pushButton_3_clicked()
|
||||
ui->comboBox_server->setCurrentIndex(0);
|
||||
});
|
||||
}
|
||||
|
||||
void Widget::on_pushButton_4_clicked()
|
||||
{
|
||||
QtConcurrent::run([=](){
|
||||
ui->pushButton_4->setEnabled(false);
|
||||
ui->label_aptserver->setText("请稍等,正在更新");
|
||||
std::fstream sourcesList;
|
||||
system("mkdir /tmp/spark-store");
|
||||
sourcesList.open("/tmp/spark-store/sparkstore.list",std::ios::out);
|
||||
if(sourcesList){
|
||||
sourcesList<<"deb [by-hash=force] ";
|
||||
sourcesList<<QString::fromUtf8(ui->comboBox_server->currentText().toUtf8()).toStdString();
|
||||
sourcesList<<" ./";
|
||||
std::fstream update;
|
||||
update.open("/tmp/spark-store/update.sh",std::ios::out);
|
||||
update<<"#!/bin/sh\n";
|
||||
update<<"mv /tmp/spark-store/sparkstore.list /etc/apt/sources.list.d/sparkstore.list && apt update";
|
||||
update.close();
|
||||
system("chmod +x /tmp/spark-store/update.sh");
|
||||
QProcess runupdate;
|
||||
runupdate.start("pkexec /tmp/spark-store/update.sh");
|
||||
runupdate.waitForFinished();
|
||||
qDebug()<<runupdate.readAllStandardError();
|
||||
QString error=QString::fromStdString(runupdate.readAllStandardError().toStdString());
|
||||
QStringList everyError=error.split("\n");
|
||||
bool haveError=false;
|
||||
for (int i=0;i<everyError.size();i++) {
|
||||
qDebug()<<everyError[i].left(2);
|
||||
if(everyError[i].left(2)=="E:"){
|
||||
haveError=true;
|
||||
}
|
||||
}
|
||||
if(!haveError){
|
||||
ui->label_aptserver->setText("deb [by-hash=force] "+ui->comboBox_server->currentText().toUtf8()+" ./");
|
||||
}else {
|
||||
ui->label_aptserver->setText("更新中发生错误,请在终端使用apt update来查看错误原因");
|
||||
}
|
||||
}else {
|
||||
qDebug()<<"更新源失败";
|
||||
}
|
||||
|
||||
ui->pushButton_4->setEnabled(true);
|
||||
});
|
||||
}
|
||||
|
2
widget.h
2
widget.h
@ -85,6 +85,8 @@ private slots:
|
||||
|
||||
void on_pushButton_3_clicked();
|
||||
|
||||
void on_pushButton_4_clicked();
|
||||
|
||||
public:
|
||||
QUrl url;
|
||||
bool isBusy=false;
|
||||
|
54
widget.ui
54
widget.ui
@ -1166,7 +1166,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>376</width>
|
||||
<height>39</height>
|
||||
<height>325</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
@ -1306,7 +1306,7 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>765</width>
|
||||
<width>807</width>
|
||||
<height>595</height>
|
||||
</rect>
|
||||
</property>
|
||||
@ -1394,6 +1394,56 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="widget_8" native="true">
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="1" column="0" colspan="4">
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="styleSheet">
|
||||
<string notr="true">color:#808080</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string><html><head/><body><p>源服务器的作用是保证软件更新,并且支持使用apt工具获取软件。通常我们更建议你使用第一个线路作为更新源。</p></body></html></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QPushButton" name="pushButton_4">
|
||||
<property name="text">
|
||||
<string>更新源</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="text">
|
||||
<string>更新源服务器:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<spacer name="horizontalSpacer_4">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="label_aptserver">
|
||||
<property name="text">
|
||||
<string>服务器</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
Loading…
x
Reference in New Issue
Block a user