void RepoInfoFetcher::handlePackageFinished (int id)
	{
		if (!PendingPackages_.contains (id))
			return;

		PendingPackage pp = PendingPackages_ [id];

		QProcess *unarch = new QProcess (this);
		unarch->setProperty ("Filename", pp.Location_);
		unarch->setProperty ("URL", pp.URL_);
		unarch->setProperty ("TaskID", id);
		connect (unarch,
				SIGNAL (finished (int, QProcess::ExitStatus)),
				this,
				SLOT (handlePackageUnarchFinished (int, QProcess::ExitStatus)));
		connect (unarch,
				SIGNAL (error (QProcess::ProcessError)),
				this,
				SLOT (handleUnarchError (QProcess::ProcessError)));
#ifdef Q_OS_WIN32
		unarch->start ("7za", QStringList ("e") << "-so" << pp.Location_);
#else
		unarch->start ("gunzip", QStringList ("-c") << pp.Location_);
#endif
	}
	void RepoInfoFetcher::handleComponentFinished (int id)
	{
		if (!PendingComponents_.contains (id))
			return;

		PendingComponent pc = PendingComponents_.take (id);

		QProcess *unarch = new QProcess (this);
		unarch->setProperty ("Component", pc.Component_);
		unarch->setProperty ("Filename", pc.Location_);
		unarch->setProperty ("URL", pc.URL_);
		unarch->setProperty ("RepoID", pc.RepoID_);
		connect (unarch,
				SIGNAL (finished (int, QProcess::ExitStatus)),
				this,
				SLOT (handleComponentUnarchFinished (int, QProcess::ExitStatus)));
		connect (unarch,
				SIGNAL (error (QProcess::ProcessError)),
				this,
				SLOT (handleUnarchError (QProcess::ProcessError)));
#ifdef Q_OS_WIN32
		unarch->start ("7za", QStringList ("e") << "-so" << pc.Location_);
#else
		unarch->start ("gunzip", QStringList ("-c") << pc.Location_);
#endif
	}
	void RepoInfoFetcher::handleRIFinished (int id)
	{
		if (!PendingRIs_.contains (id))
			return;

		PendingRI pri = PendingRIs_.take (id);

		QString name = pri.Location_;
		QProcess *unarch = new QProcess (this);
		unarch->setProperty ("URL", pri.URL_);
		unarch->setProperty ("Filename", name);
		connect (unarch,
				SIGNAL (finished (int, QProcess::ExitStatus)),
				this,
				SLOT (handleRepoUnarchFinished (int, QProcess::ExitStatus)));
		connect (unarch,
				SIGNAL (error (QProcess::ProcessError)),
				this,
				SLOT (handleUnarchError (QProcess::ProcessError)));
#ifdef Q_OS_WIN32
		unarch->start ("7za", QStringList ("e") << "-so" << name);
#else
		unarch->start ("gunzip", QStringList ("-c") << name);
#endif
	}
Пример #4
0
			void PackageProcessor::HandleFile (int packageId,
					const QUrl& url, PackageProcessor::Mode mode)
			{
				QString path = Core::Instance ()
						.GetExtResourceManager ()->GetResourcePath (url);

				QProcess *unarch = new QProcess (this);
				connect (unarch,
						SIGNAL (finished (int, QProcess::ExitStatus)),
						this,
						SLOT (handlePackageUnarchFinished (int, QProcess::ExitStatus)));
				connect (unarch,
						SIGNAL (error (QProcess::ProcessError)),
						this,
						SLOT (handleUnarchError (QProcess::ProcessError)));

				QString dirname = Util::GetTemporaryName ("lackman_stagingarea");
				QStringList args;
#ifdef Q_WS_WIN
				args << "x";
#else
				args << "xzf";
#endif
				args << path;
#ifdef Q_WS_WIN
				args << "-o";
#else
				args << "-C";
#endif
				args << dirname;
				unarch->setProperty ("PackageID", packageId);
				unarch->setProperty ("StagingDirectory", dirname);
				unarch->setProperty ("Path", path);
				unarch->setProperty ("Mode", mode);

				QFileInfo sdInfo (dirname);
				QDir stagingParentDir (sdInfo.path ());
				if (!stagingParentDir.exists (sdInfo.fileName ()) &&
						!stagingParentDir.mkdir (sdInfo.fileName ()))
				{
					qWarning () << Q_FUNC_INFO
							<< "unable to create staging directory"
							<< sdInfo.fileName ()
							<< "in"
							<< sdInfo.path ();

					QString errorString = tr ("Unable to create staging directory %1.")
							.arg (sdInfo.fileName ());
					emit packageInstallError (packageId, errorString);

					return;
				}

#ifdef Q_WS_WIN
				QString command = "7za";
#else
				QString command = "tar";
#endif
				unarch->start (command, args);
			}
Пример #5
0
	void PackageProcessor::HandleFile (int packageId,
			const QUrl& url, PackageProcessor::Mode mode)
	{
		QString path = Core::Instance ().GetExtResourceManager ()->GetResourcePath (url);

		PackageShortInfo info;
		try
		{
			info = Core::Instance ().GetStorage ()->GetPackage (packageId);
		}
		catch (const std::exception& e)
		{
			qWarning () << Q_FUNC_INFO
					<< "unable to get package info for"
					<< packageId
					<< e.what ();
			return;
		}

		const QString& archiver = info.VersionArchivers_
				.value (info.Versions_.value (0), "gz");

		QProcess *unarch = new QProcess (this);
		connect (unarch,
				SIGNAL (finished (int, QProcess::ExitStatus)),
				this,
				SLOT (handlePackageUnarchFinished (int, QProcess::ExitStatus)));
		connect (unarch,
				SIGNAL (error (QProcess::ProcessError)),
				this,
				SLOT (handleUnarchError (QProcess::ProcessError)));

		QString dirname = Util::GetTemporaryName ("lackman_stagingarea");
		QStringList args;
#ifdef Q_OS_WIN32
		args << "x"
			<< "-ttar"
			<< "-y"
			<< "-si";

		QString outDirArg ("-o");
		outDirArg.append (dirname);
		args << outDirArg;

		QProcess *firstStep = new QProcess (unarch);
		firstStep->setStandardOutputProcess (unarch);
		QStringList firstStepArgs;
		firstStepArgs << "x"
			<< "-y"
			<< "-so"
			<< path;
#else
		if (archiver == "lzma")
			args << "--lzma";
		args << "-xf";
		args << path;
		args << "-C";
		args << dirname;
#endif
		unarch->setProperty ("PackageID", packageId);
		unarch->setProperty ("StagingDirectory", dirname);
		unarch->setProperty ("Path", path);
		unarch->setProperty ("Mode", mode);

		QFileInfo sdInfo (dirname);
		QDir stagingParentDir (sdInfo.path ());
		if (!stagingParentDir.exists (sdInfo.fileName ()) &&
				!stagingParentDir.mkdir (sdInfo.fileName ()))
		{
			qWarning () << Q_FUNC_INFO
					<< "unable to create staging directory"
					<< sdInfo.fileName ()
					<< "in"
					<< sdInfo.path ();

			QString errorString = tr ("Unable to create staging directory %1.")
					.arg (sdInfo.fileName ());
			emit packageInstallError (packageId, errorString);

			return;
		}

#ifdef Q_OS_WIN32
		QString command = "7za";
		firstStep->start (command, firstStepArgs);
#else
		QString command = "tar";
#endif
		unarch->start (command, args);
	}