aboutsummaryrefslogtreecommitdiffstats
path: root/src/packages
diff options
context:
space:
mode:
authorJake Petroules <jake.petroules@qt.io>2017-07-13 21:03:50 -0700
committerJake Petroules <jake.petroules@qt.io>2017-07-19 07:22:06 +0000
commitc52731a65f80ef557998bbc0b06b24f189a88724 (patch)
tree65c4f67604dfaf8bb25d59fbe399956f682dfb08 /src/packages
parent74616c4690b4f638314aae53de7de7f8ac1998f9 (diff)
Add the creation of a Chocolatey package to our release process
This is maintained by upstream developers and so should just be a part of the official release process to begin with. This has been tested with the Docker-based release instructions and provides the additional security property to Chocolatey users of having an authoritative source from which to obtain to the .nupkg which can then be installed without network access to packages.chocolatey.org. Change-Id: I6d20201451cd3a7f080a81c1dee6b515671e2105 Reviewed-by: Kai Koehne <kai.koehne@qt.io>
Diffstat (limited to 'src/packages')
-rw-r--r--src/packages/chocolatey/chocolatey.qbs124
-rw-r--r--src/packages/chocolatey/chocolateyinstall.ps123
-rw-r--r--src/packages/chocolatey/qbs.nuspec23
-rw-r--r--src/packages/packages.qbs2
4 files changed, 172 insertions, 0 deletions
diff --git a/src/packages/chocolatey/chocolatey.qbs b/src/packages/chocolatey/chocolatey.qbs
new file mode 100644
index 000000000..392ae78d0
--- /dev/null
+++ b/src/packages/chocolatey/chocolatey.qbs
@@ -0,0 +1,124 @@
+import qbs
+import qbs.Environment
+import qbs.File
+import qbs.FileInfo
+import qbs.Probes
+import qbs.TextFile
+import qbs.Xml
+
+Product {
+ Depends { name: "qbsversion" }
+
+ Probes.BinaryProbe {
+ id: choco
+ condition: qbs.targetOS.contains("windows")
+ names: ["choco"]
+ platformPaths: {
+ var chocolateyInstall = Environment.getEnv("ChocolateyInstall");
+ if (chocolateyInstall)
+ return [FileInfo.joinPaths(chocolateyInstall, "bin")];
+ else
+ return [FileInfo.joinPaths(Environment.getEnv("PROGRAMDATA"),
+ "chocolatey", "bin")];
+ }
+ }
+
+ condition: choco.found
+ builtByDefault: false
+ name: "qbs chocolatey"
+ type: ["chocolatey.nupkg"]
+ targetName: "qbs." + qbsversion.version
+ destinationDirectory: project.buildDirectory
+
+ property string chocoFilePath: choco.filePath
+
+ Group {
+ files: ["qbs.nuspec"]
+ fileTags: ["chocolatey.nuspec"]
+ }
+
+ Group {
+ files: ["chocolateyinstall.ps1"]
+ fileTags: ["powershell.source"]
+ }
+
+ Group {
+ files: ["../../../changelogs/*"]
+ fileTags: ["changelog"]
+ }
+
+ Rule {
+ inputs: ["chocolatey.nuspec", "powershell.source", "changelog"]
+ multiplex: true
+
+ Artifact {
+ filePath: FileInfo.joinPaths(product.destinationDirectory,
+ product.targetName + ".nupkg")
+ fileTags: ["chocolatey.nupkg"]
+ }
+
+ prepare: {
+ var cmd = new JavaScriptCommand();
+ cmd.silent = true;
+ cmd.qbsVersion = product.qbsversion.version;
+ cmd.powershellFilePath = inputs["powershell.source"][0].filePath;
+ cmd.nuspecFileName = inputs["chocolatey.nuspec"][0].fileName;
+ cmd.nuspecFilePath = inputs["chocolatey.nuspec"][0].filePath;
+ cmd.chocoBuildDirectory = FileInfo.joinPaths(product.buildDirectory, "choco");
+ cmd.chocoOutDirectory = FileInfo.path(outputs["chocolatey.nupkg"][0].filePath);
+ cmd.changelogPaths = (inputs["changelog"] || []).map(function (a) {
+ return a.filePath;
+ }).sort().reverse();
+ cmd.sourceCode = function () {
+ File.makePath(chocoBuildDirectory);
+ File.makePath(FileInfo.joinPaths(chocoBuildDirectory, "tools"));
+
+ var tf = new TextFile(FileInfo.joinPaths(
+ chocoBuildDirectory, "tools", "chocolateyinstall.ps1"),
+ TextFile.WriteOnly);
+ try {
+ tf.writeLine("$qbsVersion = '" + qbsVersion + "'");
+ tf.writeLine("");
+ var tf2 = new TextFile(powershellFilePath, TextFile.ReadOnly);
+ try {
+ tf.write(tf2.readAll());
+ } finally {
+ tf2.close();
+ }
+ } finally {
+ tf.close();
+ }
+
+ var doc = new XmlDomDocument();
+ doc.load(nuspecFilePath);
+ var versionNode = doc.createElement("version");
+ versionNode.appendChild(doc.createTextNode(qbsVersion));
+ var releaseNotesNode = doc.createElement("releaseNotes");
+
+ var releaseNotesText = "";
+ changelogPaths.map(function (changelogPath) {
+ releaseNotesText += FileInfo.fileName(changelogPath).replace(
+ "changes-", "qbs ").replace(".md", "") + "\n\n";
+ var tf = new TextFile(changelogPath, TextFile.ReadOnly);
+ try {
+ releaseNotesText += tf.readAll() + "\n";
+ } finally {
+ tf.close();
+ }
+ });
+ releaseNotesNode.appendChild(doc.createTextNode(releaseNotesText.trim()));
+
+ var metadataNode = doc.documentElement().firstChild("metadata");
+ metadataNode.appendChild(versionNode);
+ metadataNode.appendChild(releaseNotesNode);
+ doc.save(FileInfo.joinPaths(chocoBuildDirectory, nuspecFileName));
+ };
+ var cmd2 = new Command(product.chocoFilePath,
+ ["pack", FileInfo.joinPaths(cmd.chocoBuildDirectory,
+ cmd.nuspecFileName),
+ "--outputdirectory", cmd.chocoOutDirectory]);
+ cmd2.description = "choco pack " + inputs["chocolatey.nuspec"][0].fileName;
+ return [cmd, cmd2];
+ }
+ }
+}
diff --git a/src/packages/chocolatey/chocolateyinstall.ps1 b/src/packages/chocolatey/chocolateyinstall.ps1
new file mode 100644
index 000000000..f55d87eb9
--- /dev/null
+++ b/src/packages/chocolatey/chocolateyinstall.ps1
@@ -0,0 +1,23 @@
+$ErrorActionPreference = 'Stop'
+
+$qbsBaseUrl = "https://download.qt.io/official_releases/qbs/$qbsVersion"
+$checksumType = 'md5'
+$checksums = @{}
+ForEach ($line in (New-Object Net.WebClient).DownloadString("$qbsBaseUrl/${checksumType}sums.txt").Split(`
+ "`n", [System.StringSplitOptions]::RemoveEmptyEntries)) {
+ $items = $line.Split(" ", [System.StringSplitOptions]::RemoveEmptyEntries)
+ $checksums.Add($items[1], $items[0])
+}
+
+$qbs32 = "qbs-windows-x86-$qbsVersion.zip"
+$qbs64 = "qbs-windows-x86_64-$qbsVersion.zip"
+
+Install-ChocolateyZipPackage `
+ -PackageName 'qbs' `
+ -Url "$qbsBaseUrl/$qbs32" `
+ -UnzipLocation "$(Split-Path -parent $MyInvocation.MyCommand.Definition)" `
+ -Url64bit "$qbsBaseUrl/$qbs64" `
+ -Checksum $checksums[$qbs32] `
+ -ChecksumType $checksumType `
+ -Checksum64 $checksums[$qbs64] `
+ -ChecksumType64 $checksumType
diff --git a/src/packages/chocolatey/qbs.nuspec b/src/packages/chocolatey/qbs.nuspec
new file mode 100644
index 000000000..3926ec7db
--- /dev/null
+++ b/src/packages/chocolatey/qbs.nuspec
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Do not remove this test for UTF-8: if “Ω” doesn’t appear as greek uppercase omega letter enclosed in quotation marks, you should use an editor that supports UTF-8, not this one. -->
+<package xmlns="http://schemas.microsoft.com/packaging/2015/06/nuspec.xsd">
+ <metadata>
+ <id>qbs</id>
+ <title>Qbs</title>
+ <authors>Qt Project</authors>
+ <owners>jakepetroules</owners>
+ <summary>Build tool that helps simplify the build process for developing projects across multiple platforms.</summary>
+ <description>Qbs is a tool that helps simplify the build process for developing projects across multiple platforms.</description>
+ <projectUrl>https://wiki.qt.io/Qbs</projectUrl>
+ <packageSourceUrl>https://code.qt.io/cgit/qt-labs/qbs.git</packageSourceUrl>
+ <projectSourceUrl>https://code.qt.io/cgit/qt-labs/qbs.git</projectSourceUrl>
+ <docsUrl>https://doc.qt.io/qbs/</docsUrl>
+ <mailingListUrl>http://lists.qt-project.org/mailman/listinfo/qbs</mailingListUrl>
+ <bugTrackerUrl>https://bugreports.qt.io/browse/QBS</bugTrackerUrl>
+ <tags>qbs qt build</tags>
+ <copyright>© 2017 The Qt Company Ltd.</copyright>
+ <licenseUrl>http://doc.qt.io/qt-5/licensing.html</licenseUrl>
+ <requireLicenseAcceptance>false</requireLicenseAcceptance>
+ <iconUrl>https://d3hp9ud7yvwzy0.cloudfront.net/wp-content/uploads/2015/02/Qt-logo-medium.png</iconUrl>
+ </metadata>
+</package>
diff --git a/src/packages/packages.qbs b/src/packages/packages.qbs
index e4870cf31..a4e0f3b4b 100644
--- a/src/packages/packages.qbs
+++ b/src/packages/packages.qbs
@@ -3,11 +3,13 @@ import qbs
Project {
references: [
"archive/archive.qbs",
+ "chocolatey/chocolatey.qbs",
]
// Virtual product for building all possible packagings
Product {
Depends { name: "qbs archive"; required: false }
+ Depends { name: "qbs chocolatey"; required: false }
name: "dist"
Group {