void mainWin::slotUpdateFinished() { qDebug() << "Updates all Finished"; QFile sysTrig( SYSTRIGGER ); if ( sysTrig.open( QIODevice::WriteOnly ) ) { QTextStream streamTrig( &sysTrig ); streamTrig << "INSTALLFINISHED: "; } sysTrig.close(); progressUpdate->setHidden(true); slotRescanUpdates(); }
void UpdaterTray::slotAutoUpdateStatusChanged() { QString line; QFile file( SYSTRIGGER ); if ( file.open( QIODevice::ReadOnly ) ) { QTextStream stream( &file ); while ( !stream.atEnd() ) { line = stream.readLine(); // line of text excluding '\n' if ( line.indexOf("DOWNLOADING: " ) == 0) { line.replace("DOWNLOADING: ", ""); autoStatus = AUTODOWNLOAD; autoCurrentUpdate = line; } if ( line.indexOf("INSTALLFAILED: " ) == 0) { autoStatus = AUTOFINISHED; QTimer::singleShot(2000, this, SLOT(slotStartUpdateCheck())); qDebug() << "FAILED INSTALLING UPDATES"; } if ( line.indexOf("INSTALLFINISHED: " ) == 0) { autoStatus = AUTOFINISHED; QTimer::singleShot(2000, this, SLOT(slotStartUpdateCheck())); qDebug() << "DONE INSTALLING UPDATES"; } } contextMenuRefresh(); } file.close(); if ( ! file.exists() ) { QFile sysTrig( SYSTRIGGER ); if ( sysTrig.open( QIODevice::WriteOnly ) ) { QTextStream streamTrig( &sysTrig ); streamTrig << QDateTime::currentDateTime().toString("hhmmss"); } sysTrig.close(); // Start our file watchers fileWatcherAutoUpdate = new QFileSystemWatcher(); fileWatcherAutoUpdate->addPath(SYSTRIGGER); connect(fileWatcherAutoUpdate, SIGNAL(fileChanged(const QString&)), this, SLOT(slotSetTimerReadAutoStatus() )); }
void mainWin::slotPkgDone() { if ( uProc->exitCode() != 0 ) pkgHasFailed=true; // Run the next command on the stack if necessary if ( pkgCmdList.size() > 1 ) { pkgCmdList.removeAt(0); startPkgProcess(); return; } // Nothing left to run! Lets wrap up QFile sysTrig( SYSTRIGGER ); if ( sysTrig.open( QIODevice::WriteOnly ) ) { QTextStream streamTrig( &sysTrig ); streamTrig << "INSTALLFINISHED: "; } if ( pkgHasFailed ) { QFile file( "/tmp/pkg-output.log" ); if ( file.open( QIODevice::WriteOnly ) ) { QTextStream stream( &file ); stream << textDisplayOut->toPlainText(); file.close(); } QMessageBox::warning(this, tr("Failed!"), tr("The package commands failed. A copy of the output was saved to /tmp/pkg-output.log")); } else QMessageBox::warning(this, tr("Finished!"), tr("Package changes complete!" )); // Clear out the old commands pkgCmdList.clear(); // Switch back to our main display stackedTop->setCurrentIndex(0); // Re-init the meta-widget initMetaWidget(); }
void mainWin::slotUpdateLoop() { QString tmp, tmp2, mUrl, PkgSet, Version, Arch; // Check if the last update process finished if ( curUpdate != -1 ) { qDebug() << "Finished Update"; if ( uProc->exitStatus() != QProcess::NormalExit || uProc->exitCode() != 0) { // Read any remaining buffers slotReadUpdateOutput(); // Warn user that this update failed if ( lastError.isEmpty() ) QMessageBox::critical(this, tr("Update Failed!"), tr("Failed to install:") + listUpdates.at(curUpdate).at(0) + " " + tr("An unknown error occured!")); else QMessageBox::critical(this, tr("Update Failed!"), tr("Failed to install:") + listUpdates.at(curUpdate).at(0) + " " + lastError); } else { // If successfull system update download if ( listUpdates.at(curUpdate).at(1) == "SYSUPDATE" ) QMessageBox::information(this, tr("Update Ready"), tr("Please reboot to start the update to PC-BSD version \"") + listUpdates.at(curUpdate).at(0) + "\". " + tr("This process may take a while, please do NOT interrupt the process.")); } // Remove the lock file if ( listUpdates.at(curUpdate).at(1) == "FBSDUPDATE" ) { system("rm /tmp/.fbsdup-lock"); } listViewUpdates->item(curUpdate)->setIcon(QIcon()); setWindowTitle(tr("Update Manager")); } // Start looking for the next update for (int z=0; z < listViewUpdates->count(); ++z) { if ( listViewUpdates->item(z)->checkState() == Qt::Checked && curUpdate < z ) { // Check for a freebsd-update lock file if ( listUpdates.at(z).at(1) == "FBSDUPDATE" ) { if ( QFile::exists("/tmp/.fbsdup-lock") ) { QMessageBox::critical(this, tr("Update Failed!"), tr("Could not run freebsd-update, another process is already running!")); slotUpdateFinished(); return; } // Lock out freebsd-update system("touch /tmp/.fbsdup-lock"); } curUpdate = z; curUpdateIndex++; progressUpdate->setHidden(false); progressUpdate->setRange(0, 0); tmp.setNum(curUpdateIndex); tmp2.setNum(totUpdate); setWindowTitle(tr("Updating:") + " " + listUpdates.at(z).at(0)); textLabel->setText(tr("Starting Update: %1 (%2 of %3)") .arg(listUpdates.at(z).at(0)) .arg(tmp) .arg(tmp2)); // Get the icon listViewUpdates->item(z)->setIcon(QIcon(":images/current-item.png")); // Get the install tag QString tag; if ( listUpdates.at(z).at(1) == "SYSUPDATE" ) tag = listUpdates.at(z).at(4); if ( listUpdates.at(z).at(1) == "PATCH" ) tag = listUpdates.at(z).at(3); // Show tray that we are doing a download QFile sysTrig( SYSTRIGGER ); if ( sysTrig.open( QIODevice::WriteOnly ) ) { QTextStream streamTrig( &sysTrig ); streamTrig << "DOWNLOADING: "; } // Setup the upgrade process labelIcon->setPixmap(QPixmap(":/images/sysinstall.png")); uProc = new QProcess(); QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); env.insert("PCFETCHGUI", "YES"); uProc->setProcessEnvironment(env); uProc->setProcessChannelMode(QProcess::MergedChannels); // Connect the slots connect( uProc, SIGNAL(readyReadStandardOutput()), this, SLOT(slotReadUpdateOutput()) ); connect( uProc, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(slotUpdateLoop()) ); // If doing FreeBSD Update run freebsd-update cmd if ( wDir.isEmpty() ) { if ( listUpdates.at(z).at(1) == "FBSDUPDATE" ) { uProc->start("freebsd-update", QStringList() << "install"); system("touch /tmp/.fbsdup-reboot"); } else { uProc->start("pc-updatemanager", QStringList() << "install" << tag ); } } else { // Doing a warden update in a chroot environment if ( listUpdates.at(z).at(1) == "FBSDUPDATE" ) { uProc->start("chroot", QStringList() << wDir << "freebsd-update" << "install"); } } qDebug() << "Update started"; return; } } // If we get here, no more updates to do slotUpdateFinished(); }
void UpdaterTray::programInit() { QString tmp, command; autoStatus = AUTOINACTIVE; doingCheck=false; shownPopup=false; // Use built-in frequency until we load another updateFrequency = -1; sysTimer = new QTimer(this); pbiTimer = new QTimer(this); connect( sysTimer, SIGNAL(timeout()), this, SLOT(slotScheduledSystemCheck()) ); connect( pbiTimer, SIGNAL(timeout()), this, SLOT(slotScheduledPBICheck()) ); // Get the username of the person running X username = getlogin(); // Setup our Context Menu QIcon contextIcon; contextIcon.addFile(":/images/updated.png"); trayIconMenu = new QMenu(this); trayIconMenu->setIcon(contextIcon); trayIconMenu->addSeparator(); trayIconMenu->addAction( QIcon(":/images/sysupdater.png"), tr("Start the Update Manager"), this, SLOT(slotOpenUpdateManager())); trayIconMenu->addAction( QIcon(":/images/pkgmanager.png"), tr("Start the Package Manager"), this, SLOT(slotOpenPackageManager())); trayIconMenu->addSeparator(); trayIconMenu->addAction( QIcon(":/images/appcafe.png"), tr("Start the AppCafe"), this, SLOT(slotOpenSoftwareManager())); trayIconMenu->addAction( QIcon(":/images/warden.png"), tr("Start the Warden"), this, SLOT(slotOpenJailManager())); trayIconMenu->addSeparator(); trayIconMenu->addAction( QIcon(":/images/view-refresh.png"),tr("Check for updates"),this, SLOT(slotCheckAllUpdates())); trayIconMenu->addSeparator(); runAction = trayIconMenu->addAction( tr("Run at startup"), this, SLOT(slotChangeRunStartup()) ); runAction->setCheckable( TRUE ); runAction->setChecked( TRUE ); popAction = trayIconMenu->addAction( tr("Display notifications"), this, SLOT(slotChangePopup()) ); popAction->setCheckable( TRUE ); popAction->setChecked( TRUE ); trayIconMenu->addSeparator(); trayIconMenu->addAction( tr("Quit"), this, SLOT(slotQuitTray()) ); // Init the tray icon trayIcon = new QSystemTrayIcon(this); trayIcon->setContextMenu(trayIconMenu); QIcon Icon(":/images/working.png"); trayIcon->setIcon(Icon); trayIcon->show(); connect( trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(slotTrayActivated(QSystemTrayIcon::ActivationReason) ) ); // Load the program preferences loadUpdaterPrefs(); // Start the monitor service for system updates QTimer::singleShot(1000, this, SLOT(slotScheduledSystemCheck())); // Start the monitor service for PBI updates QTimer::singleShot(60000, this, SLOT(slotScheduledPBICheck())); // Monitor if we need to start any update checks QTimer::singleShot(500, this, SLOT(slotMonitorForChanges())); // Watch our trigger file, to see if any automated updates are being downloaded QFile sysTrig( SYSTRIGGER ); if ( sysTrig.open( QIODevice::WriteOnly ) ) { QTextStream streamTrig( &sysTrig ); streamTrig << QDateTime::currentDateTime().toString("hhmmss"); } sysTrig.close(); // Start our file watchers fileWatcherAutoUpdate = new QFileSystemWatcher(); fileWatcherAutoUpdate->addPath(SYSTRIGGER); connect(fileWatcherAutoUpdate, SIGNAL(fileChanged(const QString&)), this, SLOT(slotSetTimerReadAutoStatus() )); // Watch for PBI updates and refresh QFile pbiTrig( PBITRIGGER ); if ( pbiTrig.open( QIODevice::WriteOnly ) ) { QTextStream streamTrig1( &pbiTrig ); streamTrig1 << QDateTime::currentDateTime().toString("hhmmss"); pbiTrig.close(); } pbiWatcherAutoUpdate = new QFileSystemWatcher(); pbiWatcherAutoUpdate->addPath(PBITRIGGER); connect(pbiWatcherAutoUpdate, SIGNAL(fileChanged(const QString&)), this, SLOT(slotScheduledPBICheck() )); // Watch our trigger file, to see if any automated updates are being downloaded fileWatcherSys = new QFileSystemWatcher(); fileWatcherSys->addPath(PREFIX + "/share/pcbsd/pc-updatemanager/conf/sysupdate.conf"); connect(fileWatcherSys, SIGNAL(fileChanged(const QString&)), this, SLOT(slotScheduledSystemCheck() )); }