std::string GetVisItInstallationDirectory(const char *version) { #if defined(_WIN32) // Get the installation dir for the specified from the registry. char *visitHome = 0; std::string installDir("C:\\"); if(ReadKey(version, "VISITHOME", &visitHome) == 1) { installDir = visitHome; } else { // try the environment const std::string idir = Environment::get("VISITHOME"); if (!idir.empty()) { installDir = idir; } else { // get the path for this process char tmpdir[MAX_PATH]; if (GetModuleFileName(NULL, tmpdir, MAX_PATH) != 0) { std::string visitpath(tmpdir); size_t lastSlash = visitpath.rfind("\\"); if(lastSlash != std::string::npos) installDir = visitpath.substr(0, lastSlash); else installDir = visitpath; } } } if (visitHome != 0) free(visitHome); return installDir; #else // Get the installation dir for the version that's running. They all use // the same "visit" script so it's okay to do this. std::string installDir("/usr/local/visit"); const std::string idir = Environment::get("VISITHOME"); if(!idir.empty()) { if(isDevelopmentVersion) installDir = idir; else { // The directory often has a "/bin" on the end. Strip it off. std::string home(idir); int lastSlash = home.rfind("/"); if(lastSlash != -1) installDir = home.substr(0, lastSlash); else installDir = idir; } } return installDir; #endif }
Settings::Settings() : m_settingsMain( new QSettings(QSettings::IniFormat, QSettings::UserScope, "KDE", "Installer") ) { m_settings = new QSettings(installDir()+"/etc/installer.ini",QSettings::IniFormat); QString version = m_settings->value("version", "").toString(); // update to current version if (version.isEmpty()) // version 1 { m_settings->setValue("version", SETTINGS_VERSION); setPackageManagerMode(m_settings->value("DeveloperMode",false).toBool()); m_settings->remove("DeveloperMode"); m_settings->sync(); } else if (version != SETTINGS_VERSION) { qCritical() << "unknown settings version" << version << "found"; } #ifdef DEBUG qDebug() << "installDir:" << installDir(); qDebug() << "downloadDir:" << downloadDir(); qDebug() << "showTitlePage:" << showTitlePage(); qDebug() << "createStartMenuEntries:" << createStartMenuEntries(); qDebug() << "isFirstRun" << isFirstRun(); qDebug() << "proxyMode" << proxyMode(); qDebug() << "proxyHost" << proxyHost(); qDebug() << "proxyPort" << proxyPort(); #endif #ifndef Q_OS_WIN // setProxyMode(Environment); #endif }
static void OnButtonBrowse() { ScopedMem<WCHAR> installDir(win::GetText(gHwndTextboxInstDir)); // strip a trailing "\SumatraPDF" if that directory doesn't exist (yet) if (!dir::Exists(installDir)) installDir.Set(path::GetDir(installDir)); WCHAR path[MAX_PATH]; BOOL ok = BrowseForFolder(gHwndFrame, installDir, _TR("Select the folder where SumatraPDF should be installed:"), path, dimof(path)); if (!ok) { SetFocus(gHwndButtonBrowseDir); return; } WCHAR *installPath = path; // force paths that aren't entered manually to end in ...\SumatraPDF // to prevent unintended installations into e.g. %ProgramFiles% itself if (!str::EndsWithI(path, L"\\" APP_NAME_STR)) installPath = path::Join(path, APP_NAME_STR); win::SetText(gHwndTextboxInstDir, installPath); Edit_SetSel(gHwndTextboxInstDir, 0, -1); SetFocus(gHwndTextboxInstDir); if (installPath != path) free(installPath); }
static bool WriteUninstallerRegistryInfo(HKEY hkey) { bool ok = true; ScopedMem<WCHAR> installedExePath(GetInstalledExePath()); ScopedMem<WCHAR> installDate(GetInstallDate()); ScopedMem<WCHAR> installDir(path::GetDir(installedExePath)); ScopedMem<WCHAR> uninstallCmdLine(str::Format(L"\"%s\"", ScopedMem<WCHAR>(GetUninstallerPath()))); ok &= WriteRegStr(hkey, REG_PATH_UNINST, DISPLAY_ICON, installedExePath); ok &= WriteRegStr(hkey, REG_PATH_UNINST, DISPLAY_NAME, APP_NAME_STR); ok &= WriteRegStr(hkey, REG_PATH_UNINST, DISPLAY_VERSION, CURR_VERSION_STR); // Windows XP doesn't allow to view the version number at a glance, // so include it in the DisplayName if (!IsVistaOrGreater()) ok &= WriteRegStr(hkey, REG_PATH_UNINST, DISPLAY_NAME, APP_NAME_STR L" " CURR_VERSION_STR); DWORD size = GetDirSize(gGlobalData.installDir) / 1024; ok &= WriteRegDWORD(hkey, REG_PATH_UNINST, ESTIMATED_SIZE, size); ok &= WriteRegStr(hkey, REG_PATH_UNINST, INSTALL_DATE, installDate); ok &= WriteRegStr(hkey, REG_PATH_UNINST, INSTALL_LOCATION, installDir); ok &= WriteRegDWORD(hkey, REG_PATH_UNINST, NO_MODIFY, 1); ok &= WriteRegDWORD(hkey, REG_PATH_UNINST, NO_REPAIR, 1); ok &= WriteRegStr(hkey, REG_PATH_UNINST, PUBLISHER, TEXT(PUBLISHER_STR)); ok &= WriteRegStr(hkey, REG_PATH_UNINST, UNINSTALL_STRING, uninstallCmdLine); ok &= WriteRegStr(hkey, REG_PATH_UNINST, URL_INFO_ABOUT, L"http://www.sumatrapdfreader.org/"); ok &= WriteRegStr(hkey, REG_PATH_UNINST, URL_UPDATE_INFO, L"http://www.sumatrapdfreader.org/news.html"); return ok; }
static bool WriteUninstallerRegistryInfo(HKEY hkey) { bool success = true; ScopedMem<WCHAR> uninstallerPath(GetUninstallerPath()); ScopedMem<WCHAR> installedExePath(GetInstalledExePath()); ScopedMem<WCHAR> installDate(GetInstallDate()); ScopedMem<WCHAR> installDir(path::GetDir(installedExePath)); success &= WriteRegStr(hkey, REG_PATH_UNINST, DISPLAY_ICON, installedExePath); success &= WriteRegStr(hkey, REG_PATH_UNINST, DISPLAY_NAME, TAPP); success &= WriteRegStr(hkey, REG_PATH_UNINST, DISPLAY_VERSION, CURR_VERSION_STR); // Windows XP doesn't allow to view the version number at a glance, // so include it in the DisplayName if (!IsVistaOrGreater()) success &= WriteRegStr(hkey, REG_PATH_UNINST, DISPLAY_NAME, TAPP L" " CURR_VERSION_STR); DWORD size = GetDirSize(gGlobalData.installDir) / 1024; success &= WriteRegDWORD(hkey, REG_PATH_UNINST, ESTIMATED_SIZE, size); success &= WriteRegStr(hkey, REG_PATH_UNINST, INSTALL_DATE, installDate); success &= WriteRegStr(hkey, REG_PATH_UNINST, INSTALL_LOCATION, installDir); success &= WriteRegDWORD(hkey, REG_PATH_UNINST, NO_MODIFY, 1); success &= WriteRegDWORD(hkey, REG_PATH_UNINST, NO_REPAIR, 1); success &= WriteRegStr(hkey, REG_PATH_UNINST, PUBLISHER, TEXT(PUBLISHER_STR)); success &= WriteRegStr(hkey, REG_PATH_UNINST, UNINSTALL_STRING, uninstallerPath); success &= WriteRegStr(hkey, REG_PATH_UNINST, URL_INFO_ABOUT, L"http://blog.kowalczyk.info/software/sumatrapdf/"); success &= WriteRegStr(hkey, REG_PATH_UNINST, URL_UPDATE_INFO, L"http://blog.kowalczyk.info/software/sumatrapdf/news.html"); return success; }
void Settings::setInstallDir(const QString &dir, bool persistent) { if (dir != installDir()) { if (!persistent) m_installDir = dir; else { m_settingsMain->setValue("rootdir", dir); m_settingsMain->sync(); } m_settings->sync(); delete m_settings; m_settings = new QSettings(dir+"/etc/installer.ini",QSettings::IniFormat); emit installDirChanged(dir); } }
/** * General install/uninstall rules: * Directories are installed as directories (through mkdir). Existing directories or links to * existing directories are not changed and OK. * Directories are uninstalled with rmdir, but failures are reported as notices only. * That is because other packages may have installed files into a folder from this package. * If the installed object is not a directory or a link, it raises an error. * * Links are installed as copy of the link (so that source file and install file report the * smae string from readlink()). * * Files are installed as link to the source file. * * Ownership: is not changed on install for any existing object, is set to the package owner on * newly created objects. Existing objects other than directories with wrong ownership are reported. * If _ignore is set they are not reported. * On uninstall, objects with other owner (other than package user), are handle like this: * For directories the owner ship is ignored. * For any other files: if the owner is not the package user, an error is reported and no action * is done. If _ignore is set, the ownership is ignored (but reported). If force is set, the * action is taken regardless of the actual ownership. */ void InstallItem::install(MXOSet &mxo) const { if(ignore(mxo)) { return; } switch(_type) { case T_LINK: installLink(mxo); break; case T_DIR: installDir(mxo); break; case T_REG: installLink(mxo); break; default: mxo.addError('?', "unknown file type of source", _absSourcePath); } }
void TestDataTest::testInstall() { QTemporaryDir dir; QDir installDir(dir.path()); QDir curDir; const QString indexFilePattern = QStringLiteral(".%1.index"); QVERIFY(TestDataUtil::installFolder(QLatin1String("mbox"), dir.path(), QStringLiteral("mbox1"))); QVERIFY(installDir.exists(QLatin1String("mbox1"))); QVERIFY(installDir.exists(indexFilePattern.arg(QLatin1String("mbox1")))); QVERIFY(TestDataUtil::installFolder(QLatin1String("mbox-tagged"), dir.path(), QStringLiteral("mbox2"))); QVERIFY(installDir.exists(QLatin1String("mbox2"))); QVERIFY(installDir.exists(indexFilePattern.arg(QLatin1String("mbox2")))); QVERIFY(TestDataUtil::installFolder(QLatin1String("maildir"), dir.path(), QStringLiteral("md1"))); QVERIFY(installDir.exists(QLatin1String("md1"))); QVERIFY(installDir.exists(QLatin1String("md1/new"))); QVERIFY(installDir.exists(QLatin1String("md1/cur"))); QVERIFY(installDir.exists(QLatin1String("md1/tmp"))); QVERIFY(installDir.exists(indexFilePattern.arg(QLatin1String("md1")))); curDir = installDir; curDir.cd(QStringLiteral("md1")); curDir.cd(QStringLiteral("cur")); curDir.setFilter(QDir::Files); QCOMPARE((int)curDir.count(), 4); QVERIFY(TestDataUtil::installFolder(QLatin1String("maildir-tagged"), dir.path(), QStringLiteral("md2"))); QVERIFY(installDir.exists(QLatin1String("md2"))); QVERIFY(installDir.exists(QLatin1String("md2/new"))); QVERIFY(installDir.exists(QLatin1String("md2/cur"))); QVERIFY(installDir.exists(QLatin1String("md2/tmp"))); QVERIFY(installDir.exists(indexFilePattern.arg(QLatin1String("md2")))); curDir = installDir; curDir.cd(QStringLiteral("md2")); curDir.cd(QStringLiteral("cur")); curDir.setFilter(QDir::Files); QCOMPARE((int)curDir.count(), 4); }
//--------------------utech--------------------utech--------------------utech-------------------- void ULoadVerInfo::replyFinished(QNetworkReply* netReply) { #ifdef U_DEVELOP qDebug() << "slot void replyFinished(QNetworkReply* netReply) loaded."; #endif timer->stop(); delete timer; netRequestDone = true; QTextStream stream(netReply); downloadedFile = stream.readAll(); _newVersion = downloadedFile.section("<br>",1,1).trimmed(); _downloadUrl = downloadedFile.section("<br>",2,2).trimmed(); #ifdef U_DEVELOP qDebug() << "downloadedFile:" << downloadedFile; qDebug() << "_newVersion:" << _newVersion; qDebug() << "_downloadUrl:" << _downloadUrl; #endif QString installedVersion = readCurInstalledProgVersion(); if ((installedVersion.size() < 3) || (_newVersion.size() < 3)){ correctExit(); return; } if (_newVersion == installedVersion){ correctExit(); return; } QApplication::setStyle( new QCleanlooksStyle() ); UProgUpdaterDialog * d = new UProgUpdaterDialog(installedVersion, _newVersion, _downloadUrl); int dRes = d->exec(); delete d; if (dRes == QDialog::Rejected){ #ifdef U_DEVELOP qDebug() << "dialogRejected()"; #endif correctExit(); return; } #ifdef U_DEVELOP qDebug() << "dialogAccepted()"; #endif #ifdef Q_OS_WIN32 QString updaterFileName = QString(QDir::tempPath())+"\\"+UPDATION_LOCAL_FILE_NAME+_newVersion+".exe"; #ifdef U_DEVELOP qDebug() << "updaterLoadingPath: " << updaterFileName; #endif QDir installDir(QApplication::applicationDirPath()); installDir.cdUp(); QProcess::startDetached(updaterFileName+" /S /D="+installDir.absolutePath().replace("/","\\")); //QFile::remove(updaterFileName); exit(0); //correctExit(); #endif #ifdef Q_OS_LINUX QFileInfo fInfo(_downloadUrl); QString updaterFileName = fInfo.fileName(); QDir::setCurrent(QCoreApplication::applicationDirPath()+"/.."); #ifdef U_DEVELOP qDebug() << "updaterLoadingPath: " << updaterFileName; qDebug() << "command: " << "tar --overwrite -xvjf "+updaterFileName; #endif QProcess::execute("chmod 755 "+updaterFileName); QProcess::execute("./"+updaterFileName+" -y"); //Запуск конфігураційного скрипта QDir::setCurrent(QCoreApplication::applicationDirPath()); QProcess::execute("../install/linux/config.sh"); QDir::setCurrent(QCoreApplication::applicationDirPath()); QProcess::execute("rm -f ../"+updaterFileName); correctExit(); #endif }
// boolean return value no longer required // was used to detect whether all settings were present in the ini, // since writing in 'preserved' mode would not create settings not present. // that is now fixed, so return value redundant. void EditorConfigDialog::syncData(ini::AttributeMap& data, bool saveDialogData) { bool /*preserve = true,*/ read = !saveDialogData; QString pathDefaults[pathSize] = { paths[d2charPath]->text(), paths[d2dataPath]->text(), paths[d2expPath]->text(), paths[patch_d2Path]->text(), paths[mod_dirPath]->text() }; #ifdef Q_WS_WIN // get default mpq path based on diablo install path in registry QSettings diabloSettings("HKEY_CURRENT_USER\\Software\\Blizzard Entertainment\\Diablo II", QSettings::NativeFormat); if (diabloSettings.contains("InstallPath")) { QString installPath = diabloSettings.value("InstallPath").toString(); if (installPath.length()) { QDir installDir(installPath); #define DEFPATHFROMINST(name) pathDefaults[( name##Path )] = installDir.filePath( #name ".mpq" ) DEFPATHFROMINST(d2char); DEFPATHFROMINST(d2data); DEFPATHFROMINST(d2exp); DEFPATHFROMINST(patch_d2); } } #undef DEFPATHFROMINST #endif //#define SYNCPATH(name) preserve *= lineedit(#name, paths[ name##Path ], \ /**/ #define SYNCPATH(name) lineedit(#name, paths[ name##Path ], \ pathDefaults[ name##Path ], read, data) SYNCPATH(d2char); SYNCPATH(d2data); SYNCPATH(d2exp); SYNCPATH(patch_d2); SYNCPATH(mod_dir); #undef SYNCPATH /*preserve *=*/ checkbox("full_screen", useFullscreen, true, false, read, data); /*preserve *=*/ lineedit("screen_width", screenWidth, "800", read, data); /*preserve *=*/ lineedit("screen_height", screenHeight, "600", read, data); /*preserve *=*/ combobox("screen_depth", screenDepth, 4, read, data); /*preserve *=*/ lineedit("refresh_rate", screenRefresh, "60", read, data); /*preserve *=*/ lineedit("keyb_scroll_x", scrollSpeeds[keyboardScroll][0], "40", read, data); /*preserve *=*/ lineedit("keyb_scroll_y", scrollSpeeds[keyboardScroll][1], "20", read, data); /*preserve *=*/ lineedit("mouse_scroll_x", scrollSpeeds[mouseScroll][0], "20", read, data); /*preserve *=*/ lineedit("mouse_scroll_y", scrollSpeeds[mouseScroll][1], "10", read, data); /*preserve *=*/ lineedit("edit_scroll_x", scrollSpeeds[tileeditScroll][0], "20", read, data); /*preserve *=*/ lineedit("edit_scroll_y", scrollSpeeds[tileeditScroll][1], "20", read, data); /*preserve *=*/ lineedit("obj_edit_scroll", editScrollSpeed, "2", read, data); /*preserve *=*/ lineedit("mouse_speed_x", mouseSpeeds[0], "2", read, data); /*preserve *=*/ lineedit("mouse_speed_y", mouseSpeeds[1], "2", read, data); /*preserve *=*/ combobox("gamma_correction", gammaCorrection, 23, read, data); /*preserve *=*/ checkbox("only_normal_type2", allowHigherType2, false, true, read, data); /*preserve *=*/ checkbox("always_max_layers", alwaysMaxLayerCount, true, false, read, data); /*preserve *=*/ checkbox("stretch_sprite", stretchSpritesOnZoom, true, false, read, data); /*preserve *=*/ checkbox("ds1_saved_minimize", minimizeSavedDs1, true, false, read, data); /*preserve *=*/ combobox("center_zoom", zoomAfterCentering, 1, read, data); /*preserve *=*/ checkbox("winobj_can_scroll_keyb", mouseScrollsMain, true, false, read, data); /*preserve *=*/ checkbox("winobj_can_scroll_mouse", keybScrollsMain, false, false, read, data); /*preserve *=*/ lineedit("nb_type1_per_act", type1TableSize, "60", read, data); /*preserve *=*/ lineedit("nb_type2_per_act", type2TableSize, "150", read, data); /*preserve *=*/ checkbox("lower_speed_zoom_out", lowZoomedScrollSpeed, false, false, read, data); /*preserve *=*/ checkbox("workspace_enable", enableWorkspace, true, false, read, data); //return preserve; }
void QvisVisItUpdate::installVisIt() { if(files.count() > 0) { // If we've created the installer before, delete it. if(installProcess != 0) { #if !defined(_WIN32) disconnect(installProcess, SIGNAL(readyReadStandardOutput()), this, SLOT(readInstallerStdout())); disconnect(installProcess, SIGNAL(readyReadStandardError()), this, SLOT(readInstallerStderr())); #endif disconnect(installProcess, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(emitInstallationComplete(int))); delete installProcess; installProcess = 0; } // Set the cursor to busy and tell the user that we're installing. QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); Status(tr("Installing..."), 120000); installProcess = new QProcess(0); QStringList installerArgs; #if defined(_WIN32) // Install VisIt the WIN32 way by running the visit installer. QString installer(files.front()); #else QString installer; if(files[1].endsWith(".dmg")) { // Assume we want to do a Mac bundle so just open the volume. installer = "open"; installerArgs.append(files[1]); } else { // Install VisIt the UNIX way. QString visit_install(files.front()); QFile::setPermissions(visit_install, QFile::ReadOwner | QFile::WriteOwner | QFile::ExeOwner); // Get the VisIt installation directory. QString installDir(getInstallationDir()); // Create an installation process that will run visit-install. installer = QString(visit_install); // Add installer arguments. installerArgs.append("-c"); installerArgs.append(configName); installerArgs.append("-b"); installerArgs.append(bankName); installerArgs.append(latestVersion); installerArgs.append(distName); installerArgs.append(installDir); connect(installProcess, SIGNAL(readyReadStandardOutput()), this, SLOT(readInstallerStdout())); connect(installProcess, SIGNAL(readyReadStandardError()), this, SLOT(readInstallerStderr())); debug1 << "Going to run: " << visit_install.toStdString() << " -c " << configName.toStdString() << " -b " << bankName.toStdString() << " " << latestVersion.toStdString() << " " << distName.toStdString() << " " << installDir.toStdString() << endl; } #endif debug1 << "Connecting finished->emitInstallationComplete" << endl; // We want to know when the installer completes. connect(installProcess, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(emitInstallationComplete(int))); // Start the visit installer. installProcess->start(installer, installerArgs); }