解决linux上升级的问题

This commit is contained in:
luoliangyi 2022-07-22 09:46:34 +08:00
parent bd5706e333
commit ff85917c60
2 changed files with 95 additions and 43 deletions

View File

@ -1101,46 +1101,70 @@ void MainWindow::on_upgradeApp(QString pkgPath)
{
QString curPath = QDir::currentPath();
QString tmpPath = QDir::tempPath();
QFile file(curPath);
#if defined(HG_CMP_MSC)
#if defined(OEM_HANWANG)
file.copy("HwUpgradeApp.exe", tmpPath + "/HwUpgradeApp.exe");
file.copy("HwBase.dll", tmpPath + "/HwBase.dll");
file.copy("HwVersion.dll", tmpPath + "/HwVersion.dll");
QFile::remove(tmpPath + "/HwUpgradeApp.exe");
QFile::copy(curPath + "/HwUpgradeApp.exe", tmpPath + "/HwUpgradeApp.exe");
QFile::remove(tmpPath + "/HwBase.dll");
QFile::copy(curPath + "/HwBase.dll", tmpPath + "/HwBase.dll");
QFile::remove(tmpPath + "/HwVersion.dll");
QFile::copy(curPath + "/HwVersion.dll", tmpPath + "/HwVersion.dll");
#elif defined(OEM_LISICHENG)
file.copy("LscUpgradeApp.exe", tmpPath + "/LscUpgradeApp.exe");
file.copy("LscBase.dll", tmpPath + "/LscBase.dll");
file.copy("LscVersion.dll", tmpPath + "/LscVersion.dll");
QFile::remove(tmpPath + "/LscUpgradeApp.exe");
QFile::copy(curPath + "/LscUpgradeApp.exe", tmpPath + "/LscUpgradeApp.exe");
QFile::remove(tmpPath + "/LscBase.dll");
QFile::copy(curPath + "/LscBase.dll", tmpPath + "/LscBase.dll");
QFile::remove(tmpPath + "/LscVersion.dll");
QFile::copy(curPath + "/LscVersion.dll", tmpPath + "/LscVersion.dll");
#else
file.copy("HGUpgradeApp.exe", tmpPath + "/HGUpgradeApp.exe");
file.copy("HGBase.dll", tmpPath + "/HGBase.dll");
file.copy("HGVersion.dll", tmpPath + "/HGVersion.dll");
QFile::remove(tmpPath + "/HGUpgradeApp.exe");
QFile::copy(curPath + "/HGUpgradeApp.exe", tmpPath + "/HGUpgradeApp.exe");
QFile::remove(tmpPath + "/HGBase.dll");
QFile::copy(curPath + "/HGBase.dll", tmpPath + "/HGBase.dll");
QFile::remove(tmpPath + "/HGVersion.dll");
QFile::copy(curPath + "/HGVersion.dll", tmpPath + "/HGVersion.dll");
#endif
file.copy("msvcp140.dll", tmpPath + "/msvcp140.dll");
file.copy("Qt5Core.dll", tmpPath + "/Qt5Core.dll");
file.copy("Qt5Gui.dll", tmpPath + "/Qt5Gui.dll");
file.copy("Qt5Widgets.dll", tmpPath + "/Qt5Widgets.dll");
file.copy("vcruntime140.dll", tmpPath + "/vcruntime140.dll");
QFile::remove(tmpPath + "/msvcp140.dll");
QFile::copy(curPath + "/msvcp140.dll", tmpPath + "/msvcp140.dll");
QFile::remove(tmpPath + "/Qt5Core.dll");
QFile::copy(curPath + "/Qt5Core.dll", tmpPath + "/Qt5Core.dll");
QFile::remove(tmpPath + "/Qt5Gui.dll");
QFile::copy(curPath + "/Qt5Gui.dll", tmpPath + "/Qt5Gui.dll");
QFile::remove(tmpPath + "/Qt5Widgets.dll");
QFile::copy(curPath + "/Qt5Widgets.dll", tmpPath + "/Qt5Widgets.dll");
QFile::remove(tmpPath + "/vcruntime140.dll");
QFile::copy(curPath + "/vcruntime140.dll", tmpPath + "/vcruntime140.dll");
QDir dir;
dir.mkdir(tmpPath + "/platforms");
file.copy("platforms/qwindows.dll", tmpPath + "/platforms/qwindows.dll");
QFile::remove(tmpPath + "/platforms/qwindows.dll");
QFile::copy(curPath + "/platforms/qwindows.dll", tmpPath + "/platforms/qwindows.dll");
dir.mkdir(tmpPath + "/imageformats");
file.copy("imageformats/qgif.dll", tmpPath + "/imageformats/qgif.dll");
QFile::remove(tmpPath + "/imageformats/qgif.dll");
QFile::copy(curPath + "/imageformats/qgif.dll", tmpPath + "/imageformats/qgif.dll");
#else
#if defined(OEM_HANWANG)
file.copy("HwUpgradeApp", tmpPath + "/HwUpgradeApp");
file.copy("libHwBase.so", tmpPath + "/libHwBase.so");
file.copy("libHwVersion.so", tmpPath + "/libHwVersion.so");
QFile::remove(tmpPath + "/HwUpgradeApp");
QFile::copy(curPath + "/HwUpgradeApp", tmpPath + "/HwUpgradeApp");
QFile::remove(tmpPath + "/libHwBase.so");
QFile::copy(curPath + "/libHwBase.so", tmpPath + "/libHwBase.so");
QFile::remove(tmpPath + "/libHwVersion.so");
QFile::copy(curPath + "/libHwVersion.so", tmpPath + "/libHwVersion.so");
#elif defined(OEM_LISICHENG)
file.copy("LscUpgradeApp", tmpPath + "/LscUpgradeApp");
file.copy("libLscBase.so", tmpPath + "/libLscBase.so");
file.copy("libLscVersion.so", tmpPath + "/libLscVersion.so");
QFile::remove(tmpPath + "/LscUpgradeApp");
QFile::copy(curPath + "/LscUpgradeApp", tmpPath + "/LscUpgradeApp");
QFile::remove(tmpPath + "/libLscBase.so");
QFile::copy(curPath + "/libLscBase.so", tmpPath + "/libLscBase.so");
QFile::remove(tmpPath + "/libLscVersion.so");
QFile::copy(curPath + "/libLscVersion.so", tmpPath + "/libLscVersion.so");
#else
file.copy("HGUpgradeApp", tmpPath + "/HGUpgradeApp");
file.copy("libHGBase.so", tmpPath + "/libHGBase.so");
file.copy("libHGVersion.so", tmpPath + "/libHGVersion.so");
QFile::remove(tmpPath + "/HGUpgradeApp");
QFile::copy(curPath + "/HGUpgradeApp", tmpPath + "/HGUpgradeApp");
QFile::remove(tmpPath + "/libHGBase.so");
QFile::copy(curPath + "/libHGBase.so", tmpPath + "/libHGBase.so");
QFile::remove(tmpPath + "/libHGVersion.so");
QFile::copy(curPath + "/libHGVersion.so", tmpPath + "/libHGVersion.so");
#endif
#endif
@ -3234,10 +3258,15 @@ void MainWindow::on_actionact_update_triggered()
assert(!url.isEmpty() && !md5.isEmpty());
HGChar suffix[64];
HGBase_GetFileSuffix(url.toStdString().c_str(), suffix, 64);
HGChar savePath[512];
HGBase_GetConfigPath(savePath, 512);
HGBase_CreateDir(savePath);
strcat(savePath, (versionNum + QString("%1").arg(".exe")).toLatin1().data());
HGChar fileName[128];
sprintf(fileName, "%s.%s", versionNum.toStdString().c_str(), suffix);
strcat(savePath, fileName);
QFile saveFile(savePath);
saveFile.open(QFile::ReadOnly);

View File

@ -80,6 +80,7 @@ bool AppIsRun(const std::string& appName)
std::string cmd;
std::string appPath;
#if defined (UOS)
#if defined(OEM_HANWANG)
cmd = "ps -wef | grep HanvonScan";
appPath = "/opt/apps/com.hanvonchina.hanvonscan/files/bin/HanvonScan";
@ -90,6 +91,18 @@ bool AppIsRun(const std::string& appName)
cmd = "ps -wef | grep HuaGoScan";
appPath = "/opt/apps/com.huagaochina.huagoscan/files/bin/HuaGoScan";
#endif
#else
#if defined(OEM_HANWANG)
cmd = "ps -wef | grep HanvonScan";
appPath = "/opt/apps/scanner-driver-hanvon/HanvonScan";
#elif defined(OEM_LISICHENG)
cmd = "ps -wef | grep LanxumScan";
appPath = "/opt/apps/scanner-driver-lanxum/LanxumScan";
#else
cmd = "ps -wef | grep HuaGoScan";
appPath = "/opt/apps/scanner-driver-huagao/HuaGoScan";
#endif
#endif
bool ret = false;
FILE *fp = popen(cmd.c_str(), "r");
@ -184,6 +197,7 @@ void RunApp(const std::string& appName)
#else
std::string appPath;
#if defined (UOS)
#if defined(OEM_HANWANG)
appPath = "sh /opt/apps/com.hanvonchina.hanvonscan/files/bin/HanvonScan.sh &";
#elif defined(OEM_LISICHENG)
@ -191,6 +205,15 @@ void RunApp(const std::string& appName)
#else
appPath = "sh /opt/apps/com.huagaochina.huagoscan/files/bin/HuaGoScan.sh &";
#endif
#else
#if defined(OEM_HANWANG)
appPath = "sh /opt/apps/scanner-driver-hanvon/HanvonScan.sh &";
#elif defined(OEM_LISICHENG)
appPath = "sh /opt/apps/scanner-driver-lanxum/LanxumScan.sh &";
#else
appPath = "sh /opt/apps/scanner-driver-huagao/HuaGoScan.sh &";
#endif
#endif
system(appPath.c_str());