Allow the user to set the version number used for the build deb package.

Task-number: QTCREATORBUG-1670
Reviewed-by: ck
This commit is contained in:
kh1
2010-06-28 11:59:36 +02:00
parent 38e91624de
commit eaf8d2692e
5 changed files with 271 additions and 19 deletions

View File

@@ -59,7 +59,11 @@
#include <QtCore/QStringBuilder> #include <QtCore/QStringBuilder>
#include <QtGui/QWidget> #include <QtGui/QWidget>
namespace { const QLatin1String PackagingEnabledKey("Packaging Enabled"); } namespace {
const QLatin1String PackagingEnabledKey("Packaging Enabled");
const QLatin1String DefaultVersionNumber("0.0.1");
const QLatin1String VersionNumberKey("Version Number");
}
using namespace ProjectExplorer::Constants; using namespace ProjectExplorer::Constants;
using ProjectExplorer::BuildConfiguration; using ProjectExplorer::BuildConfiguration;
@@ -72,7 +76,8 @@ namespace Internal {
MaemoPackageCreationStep::MaemoPackageCreationStep(BuildConfiguration *buildConfig) MaemoPackageCreationStep::MaemoPackageCreationStep(BuildConfiguration *buildConfig)
: ProjectExplorer::BuildStep(buildConfig, CreatePackageId), : ProjectExplorer::BuildStep(buildConfig, CreatePackageId),
m_packageContents(new MaemoPackageContents(this)), m_packageContents(new MaemoPackageContents(this)),
m_packagingEnabled(true) m_packagingEnabled(true),
m_versionString(DefaultVersionNumber)
{ {
} }
@@ -80,10 +85,9 @@ MaemoPackageCreationStep::MaemoPackageCreationStep(BuildConfiguration *buildConf
MaemoPackageCreationStep *other) MaemoPackageCreationStep *other)
: BuildStep(buildConfig, other), : BuildStep(buildConfig, other),
m_packageContents(new MaemoPackageContents(this)), m_packageContents(new MaemoPackageContents(this)),
m_packagingEnabled(other->m_packagingEnabled) m_packagingEnabled(other->m_packagingEnabled),
m_versionString(other->m_versionString)
{ {
} }
bool MaemoPackageCreationStep::init() bool MaemoPackageCreationStep::init()
@@ -95,6 +99,7 @@ QVariantMap MaemoPackageCreationStep::toMap() const
{ {
QVariantMap map(ProjectExplorer::BuildStep::toMap()); QVariantMap map(ProjectExplorer::BuildStep::toMap());
map.insert(PackagingEnabledKey, m_packagingEnabled); map.insert(PackagingEnabledKey, m_packagingEnabled);
map.insert(VersionNumberKey, m_versionString);
return map.unite(m_packageContents->toMap()); return map.unite(m_packageContents->toMap());
} }
@@ -102,6 +107,7 @@ bool MaemoPackageCreationStep::fromMap(const QVariantMap &map)
{ {
m_packageContents->fromMap(map); m_packageContents->fromMap(map);
m_packagingEnabled = map.value(PackagingEnabledKey, true).toBool(); m_packagingEnabled = map.value(PackagingEnabledKey, true).toBool();
m_versionString = map.value(VersionNumberKey, DefaultVersionNumber).toString();
return ProjectExplorer::BuildStep::fromMap(map); return ProjectExplorer::BuildStep::fromMap(map);
} }
@@ -159,9 +165,10 @@ bool MaemoPackageCreationStep::createPackage()
if (!QFileInfo(buildDir + QLatin1String("/debian")).exists()) { if (!QFileInfo(buildDir + QLatin1String("/debian")).exists()) {
const QString command = QLatin1String("dh_make -s -n -p ") const QString command = QLatin1String("dh_make -s -n -p ")
% executableFileName().toLower() % versionString(); % executableFileName().toLower() % QLatin1Char('_') % versionString();
if (!runCommand(buildProc, command)) if (!runCommand(buildProc, command))
return false; return false;
QFile rulesFile(buildDir + QLatin1String("/debian/rules")); QFile rulesFile(buildDir + QLatin1String("/debian/rules"));
if (!rulesFile.open(QIODevice::ReadWrite)) { if (!rulesFile.open(QIODevice::ReadWrite)) {
raiseError(tr("Packaging Error: Cannot open file '%1'.") raiseError(tr("Packaging Error: Cannot open file '%1'.")
@@ -180,6 +187,17 @@ bool MaemoPackageCreationStep::createPackage()
} }
} }
{
QFile changeLog(buildDir + QLatin1String("/debian/changelog"));
if (changeLog.open(QIODevice::ReadWrite)) {
QString content = QString::fromUtf8(changeLog.readAll());
content.replace(QRegExp("\\([a-zA-Z0-9_\\.]+\\)"),
QLatin1Char('(') % versionString() % QLatin1Char(')'));
changeLog.resize(0);
changeLog.write(content.toUtf8());
}
}
if (!runCommand(buildProc, QLatin1String("dh_installdirs"))) if (!runCommand(buildProc, QLatin1String("dh_installdirs")))
return false; return false;
@@ -310,12 +328,17 @@ QString MaemoPackageCreationStep::packageFilePath() const
{ {
QFileInfo execInfo(localExecutableFilePath()); QFileInfo execInfo(localExecutableFilePath());
return execInfo.path() % QDir::separator() % execInfo.fileName().toLower() return execInfo.path() % QDir::separator() % execInfo.fileName().toLower()
% versionString() % QLatin1String("_armel.deb"); % QLatin1Char('_') % versionString() % QLatin1String("_armel.deb");
} }
QString MaemoPackageCreationStep::versionString() const QString MaemoPackageCreationStep::versionString() const
{ {
return QLatin1String("_0.1"); return m_versionString;
}
void MaemoPackageCreationStep::setVersionString(const QString &version)
{
m_versionString = version;
} }
QString MaemoPackageCreationStep::nativePath(const QFile &file) const QString MaemoPackageCreationStep::nativePath(const QFile &file) const

View File

@@ -71,6 +71,9 @@ public:
bool isPackagingEnabled() const { return m_packagingEnabled; } bool isPackagingEnabled() const { return m_packagingEnabled; }
void setPackagingEnabled(bool enabled) { m_packagingEnabled = enabled; } void setPackagingEnabled(bool enabled) { m_packagingEnabled = enabled; }
QString versionString() const;
void setVersionString(const QString &version);
private: private:
MaemoPackageCreationStep(ProjectExplorer::BuildConfiguration *buildConfig, MaemoPackageCreationStep(ProjectExplorer::BuildConfiguration *buildConfig,
MaemoPackageCreationStep *other); MaemoPackageCreationStep *other);
@@ -90,7 +93,6 @@ private:
QString targetRoot() const; QString targetRoot() const;
QString nativePath(const QFile &file) const; QString nativePath(const QFile &file) const;
bool packagingNeeded() const; bool packagingNeeded() const;
QString versionString() const;
void raiseError(const QString &shortMsg, void raiseError(const QString &shortMsg,
const QString &detailedMsg = QString()); const QString &detailedMsg = QString());
@@ -98,6 +100,7 @@ private:
MaemoPackageContents *const m_packageContents; MaemoPackageContents *const m_packageContents;
bool m_packagingEnabled; bool m_packagingEnabled;
QString m_versionString;
}; };
} // namespace Internal } // namespace Internal

View File

@@ -77,6 +77,12 @@ MaemoPackageCreationWidget::MaemoPackageCreationWidget(MaemoPackageCreationStep
m_ui->packageContentsView->resizeColumnsToContents(); m_ui->packageContentsView->resizeColumnsToContents();
m_ui->packageContentsView->horizontalHeader()->setStretchLastSection(true); m_ui->packageContentsView->horizontalHeader()->setStretchLastSection(true);
enableOrDisableRemoveButton(); enableOrDisableRemoveButton();
const QStringList list = m_step->versionString().split(QLatin1Char('.'),
QString::SkipEmptyParts);
m_ui->major->setValue(list.value(0, QLatin1String("0")).toInt());
m_ui->minor->setValue(list.value(1, QLatin1String("0")).toInt());
m_ui->patch->setValue(list.value(2, QLatin1String("0")).toInt());
} }
void MaemoPackageCreationWidget::init() void MaemoPackageCreationWidget::init()
@@ -141,5 +147,12 @@ void MaemoPackageCreationWidget::handleSkipButtonToggled(bool checked)
m_step->setPackagingEnabled(!checked); m_step->setPackagingEnabled(!checked);
} }
void MaemoPackageCreationWidget::versionInfoChanged()
{
m_step->setVersionString(m_ui->major->text() + QLatin1Char('.')
+ m_ui->minor->text() + QLatin1Char('.') + m_ui->patch->text());
emit updateSummary();
}
} // namespace Internal } // namespace Internal
} // namespace Qt4ProjectManager } // namespace Qt4ProjectManager

View File

@@ -68,6 +68,7 @@ private slots:
void removeFile(); void removeFile();
void enableOrDisableRemoveButton(); void enableOrDisableRemoveButton();
void handleSkipButtonToggled(bool checked); void handleSkipButtonToggled(bool checked);
void versionInfoChanged();
private: private:
MaemoPackageCreationStep * const m_step; MaemoPackageCreationStep * const m_step;

View File

@@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>741</width> <width>470</width>
<height>574</height> <height>325</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy"> <property name="sizePolicy">
@@ -16,10 +16,7 @@
<verstretch>1</verstretch> <verstretch>1</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_2"> <layout class="QVBoxLayout" name="verticalLayout_3">
<property name="spacing">
<number>6</number>
</property>
<item> <item>
<widget class="QCheckBox" name="skipCheckBox"> <widget class="QCheckBox" name="skipCheckBox">
<property name="toolTip"> <property name="toolTip">
@@ -30,6 +27,156 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>5</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QLabel" name="label">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Version number:</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>13</width>
<height>13</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Major:</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="major">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximum">
<number>99</number>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_3">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Minor:</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="minor">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximum">
<number>99</number>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_4">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Patch:</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="patch">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximum">
<number>99</number>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</item>
<item> <item>
<widget class="QLabel" name="contentsLabel"> <widget class="QLabel" name="contentsLabel">
<property name="font"> <property name="font">
@@ -45,6 +192,22 @@
</item> </item>
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout"> <layout class="QHBoxLayout" name="horizontalLayout">
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>13</width>
<height>13</height>
</size>
</property>
</spacer>
</item>
<item> <item>
<widget class="QTableView" name="packageContentsView"> <widget class="QTableView" name="packageContentsView">
<property name="sizePolicy"> <property name="sizePolicy">
@@ -139,8 +302,8 @@
<slot>addFile()</slot> <slot>addFile()</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>729</x> <x>458</x>
<y>88</y> <y>134</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>732</x> <x>732</x>
@@ -155,8 +318,8 @@
<slot>removeFile()</slot> <slot>removeFile()</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>729</x> <x>458</x>
<y>124</y> <y>162</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>735</x> <x>735</x>
@@ -180,10 +343,59 @@
</hint> </hint>
</hints> </hints>
</connection> </connection>
<connection>
<sender>major</sender>
<signal>valueChanged(int)</signal>
<receiver>MaemoPackageCreationWidget</receiver>
<slot>versionInfoChanged()</slot>
<hints>
<hint type="sourcelabel">
<x>83</x>
<y>73</y>
</hint>
<hint type="destinationlabel">
<x>461</x>
<y>32</y>
</hint>
</hints>
</connection>
<connection>
<sender>minor</sender>
<signal>valueChanged(int)</signal>
<receiver>MaemoPackageCreationWidget</receiver>
<slot>versionInfoChanged()</slot>
<hints>
<hint type="sourcelabel">
<x>154</x>
<y>68</y>
</hint>
<hint type="destinationlabel">
<x>5</x>
<y>15</y>
</hint>
</hints>
</connection>
<connection>
<sender>patch</sender>
<signal>valueChanged(int)</signal>
<receiver>MaemoPackageCreationWidget</receiver>
<slot>versionInfoChanged()</slot>
<hints>
<hint type="sourcelabel">
<x>249</x>
<y>68</y>
</hint>
<hint type="destinationlabel">
<x>466</x>
<y>-7</y>
</hint>
</hints>
</connection>
</connections> </connections>
<slots> <slots>
<slot>addFile()</slot> <slot>addFile()</slot>
<slot>removeFile()</slot> <slot>removeFile()</slot>
<slot>handleSkipButtonToggled(bool)</slot> <slot>handleSkipButtonToggled(bool)</slot>
<slot>versionInfoChanged()</slot>
</slots> </slots>
</ui> </ui>