forked from qt-creator/qt-creator
Maemo: Implement basic packaging.
This commit is contained in:
@@ -76,13 +76,6 @@ void AbstractMaemoRunControl::startDeployment(bool forDebugging)
|
||||
deployables.append(Deployable(executableFileName(),
|
||||
QFileInfo(executableOnHost()).canonicalPath(),
|
||||
&MaemoRunConfiguration::wasDeployed));
|
||||
if (false) {
|
||||
if (!buildPackage()) {
|
||||
qDebug("Error: Could not build package");
|
||||
handleDeploymentFinished(false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (forDebugging
|
||||
&& runConfig->debuggingHelpersNeedDeployment(devConfig.host)) {
|
||||
@@ -97,106 +90,6 @@ void AbstractMaemoRunControl::startDeployment(bool forDebugging)
|
||||
}
|
||||
}
|
||||
|
||||
bool AbstractMaemoRunControl::buildPackage()
|
||||
{
|
||||
qDebug("%s", Q_FUNC_INFO);
|
||||
const QString projectDir = QFileInfo(executableOnHost()).absolutePath();
|
||||
|
||||
QFile configFile(runConfig->targetRoot() % QLatin1String("/config.sh"));
|
||||
if (!configFile.open(QIODevice::ReadOnly)) {
|
||||
qDebug("Cannot open config file '%s'", qPrintable(configFile.fileName()));
|
||||
return false;
|
||||
}
|
||||
const QString &maddeRoot = runConfig->maddeRoot();
|
||||
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
|
||||
const QLatin1String pathKey("PATH");
|
||||
env.insert(pathKey, maddeRoot % QLatin1String("/madbin:")
|
||||
% env.value(pathKey));
|
||||
env.insert(QLatin1String("PERL5LIB"),
|
||||
maddeRoot % QLatin1String("/madlib/perl5"));
|
||||
const QRegExp envPattern(QLatin1String("([^=]+)=[\"']?([^;\"']+)[\"']? ;.*"));
|
||||
env.insert(QLatin1String("PWD"), projectDir);
|
||||
QByteArray line;
|
||||
do {
|
||||
line = configFile.readLine(200);
|
||||
if (envPattern.exactMatch(line))
|
||||
env.insert(envPattern.cap(1), envPattern.cap(2));
|
||||
} while (!line.isEmpty());
|
||||
qDebug("Process environment: %s",
|
||||
qPrintable(env.toStringList().join(QLatin1String(":"))));
|
||||
qDebug("sysroot: '%s'", qPrintable(env.value(QLatin1String("SYSROOT_DIR"))));
|
||||
QProcess buildProc;
|
||||
buildProc.setProcessEnvironment(env);
|
||||
buildProc.setWorkingDirectory(projectDir);
|
||||
|
||||
if (!QFileInfo(projectDir + QLatin1String("/debian")).exists()) {
|
||||
if (!runCommand(buildProc, QLatin1String("dh_make -s -n")))
|
||||
return false;
|
||||
QFile rulesFile(projectDir + QLatin1String("/debian/rules"));
|
||||
if (!rulesFile.open(QIODevice::ReadWrite)) {
|
||||
qDebug("Error: Could not open debian/rules.");
|
||||
return false;
|
||||
}
|
||||
|
||||
QByteArray rulesContents = rulesFile.readAll();
|
||||
rulesContents.replace("DESTDIR", "INSTALL_ROOT");
|
||||
rulesFile.resize(0);
|
||||
rulesFile.write(rulesContents);
|
||||
if (rulesFile.error() != QFile::NoError) {
|
||||
qDebug("Error: could not access debian/rules");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!runCommand(buildProc, QLatin1String("dh_installdirs")))
|
||||
return false;
|
||||
const QString targetFile(projectDir % QLatin1String("/debian/")
|
||||
% executableFileName().toLower() % QLatin1String("/usr/bin/")
|
||||
% executableFileName());
|
||||
if (QFile::exists(targetFile)) {
|
||||
if (!QFile::remove(targetFile)) {
|
||||
qDebug("Error: Could not remove '%s'", qPrintable(targetFile));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (!QFile::copy(executableOnHost(), targetFile)) {
|
||||
qDebug("Error: Could not copy '%s' to '%s'",
|
||||
qPrintable(executableOnHost()), qPrintable(targetFile));
|
||||
return false;
|
||||
}
|
||||
|
||||
const QStringList commands = QStringList() << QLatin1String("dh_link")
|
||||
<< QLatin1String("dh_fixperms") << QLatin1String("dh_installdeb")
|
||||
<< QLatin1String("dh_shlibdeps") << QLatin1String("dh_gencontrol")
|
||||
<< QLatin1String("dh_md5sums") << QLatin1String("dh_builddeb --destdir=.");
|
||||
foreach (const QString &command, commands) {
|
||||
if (!runCommand(buildProc, command))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AbstractMaemoRunControl::runCommand(QProcess &proc,
|
||||
const QString &command)
|
||||
{
|
||||
qDebug("Running command '%s'", qPrintable(command));
|
||||
proc.start(runConfig->maddeRoot() % QLatin1String("/madbin/") % command);
|
||||
proc.write("\n"); // For dh_make
|
||||
if (!proc.waitForFinished(5000) && proc.error() == QProcess::Timedout) {
|
||||
qDebug("command '%s' hangs", qPrintable(command));
|
||||
return false;
|
||||
}
|
||||
if (proc.exitCode() != 0) {
|
||||
qDebug("command '%s' failed with return value %d and output '%s'",
|
||||
qPrintable(command), proc.exitCode(),
|
||||
(proc.readAllStandardOutput() + "\n" + proc.readAllStandardError()).data());
|
||||
return false;
|
||||
}
|
||||
qDebug("Command finished, output was '%s'",
|
||||
(proc.readAllStandardOutput() + "\n" + proc.readAllStandardError()).data());
|
||||
return true;
|
||||
}
|
||||
|
||||
void AbstractMaemoRunControl::deploy()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user