From 56d2153c08ebc5abd30a8330630869c10dbb326f Mon Sep 17 00:00:00 2001 From: Piotr Puszkiewicz Date: Fri, 19 Aug 2016 14:52:06 -0700 Subject: [PATCH] WiP --- .../Microsoft.DotNet.Cli.Installer.DEB.props | 10 + ...Microsoft.DotNet.Cli.Installer.DEB.targets | 187 +++++++++++------- .../dotnet-cli-build/DotNetDebTool.cs | 50 +++++ .../Utils/DebPackageCreator.cs | 101 ---------- 4 files changed, 180 insertions(+), 168 deletions(-) create mode 100644 build_projects/dotnet-cli-build/DotNetDebTool.cs diff --git a/build/package/Microsoft.DotNet.Cli.Installer.DEB.props b/build/package/Microsoft.DotNet.Cli.Installer.DEB.props index eacf60d61..2431676c6 100644 --- a/build/package/Microsoft.DotNet.Cli.Installer.DEB.props +++ b/build/package/Microsoft.DotNet.Cli.Installer.DEB.props @@ -12,4 +12,14 @@ docs debian + + + + + + + + + + diff --git a/build/package/Microsoft.DotNet.Cli.Installer.DEB.targets b/build/package/Microsoft.DotNet.Cli.Installer.DEB.targets index 4bddd0c23..95460ea70 100644 --- a/build/package/Microsoft.DotNet.Cli.Installer.DEB.targets +++ b/build/package/Microsoft.DotNet.Cli.Installer.DEB.targets @@ -1,6 +1,13 @@ + + + @@ -12,84 +19,107 @@ Importance="High" /> - false - true + false + true - - + + + - $(RepoRoot)/scripts/package/package-debian.sh - $(RepoRoot)/Documentation/manpages + $(RepoRoot)/scripts/package/package-debian.sh + $(RepoRoot)/Documentation/manpages - $(PackagesDirectory) - $(InstallerOutputDirectory)/$(ArtifactNameWithVersionSdk)$(InstallerExtension) + $(PackagesDirectory) + $(InstallerOutputDirectory)/$(ArtifactNameWithVersionSdk)$(InstallerExtension) - dotnet-dev-$(SdkVersion) - dotnet-sharedframework-$(SharedFrameworkName)-$(SharedFrameworkVersion) - $(SharedFrameworkDebianPackageName.ToLower()) - dotnet-hostfxr-$(HostFxrVersion) - $(HostFxrDebianPackageName.ToLower()) - dotnet-host + dotnet-dev-$(SdkVersion) + dotnet-sharedframework-$(SharedFrameworkName)-$(SharedFrameworkVersion) + $(SharedFrameworkDebianPackageName.ToLower()) + dotnet-hostfxr-$(HostFxrVersion) + $(HostFxrDebianPackageName.ToLower()) + dotnet-host - $(IntermediateDirectory)/debian/sdk + $(IntermediateDirectory)/debian/sdk - $(SdkDebianIntermediateDirectory)/debian-testResults.xml - /usr/share/dotnet - $(RepoRoot)/test/EndToEnd + $(SdkDebianIntermediateDirectory)/debian-testResults.xml + /usr/share/dotnet + $(RepoRoot)/test/EndToEnd - - - + + $(SharedFrameworkDebianPackageName) + + + $(SharedFrameworkName) + + + $(SharedFrameworkVersion) + + + $(SharedFrameworkBrandName) + + + $(SdkVersion) + + + $(SdkBrandName) + + + - - - + + - - - - - - - - - - - - - - + + + + + + + - + @@ -106,7 +136,7 @@ $(SdkInstallerFile);" Outputs="$(DebianTestResultsXmlFile)" > - + @@ -125,27 +155,50 @@ - + + + $(SdkDebianLayoutOutputDirectory)/$(DebLayoutPackageRootDirName) + $(SdkDebianLayoutOutputDirectory)/$(DebLayoutAbsolutePlacementDirName) + $(SdkDebianLayoutOutputDirectory)/$(DebLayoutSamplesDirName) + $(SdkDebianLayoutOutputDirectory)/$(DebLayoutDocsDirName) + $(SdkDebianLayoutOutputDirectory)/$(DebLayoutDebianFilesDirName) + + + + + + + + + + + + + + + + + + + + - - - - - - - - - + + + diff --git a/build_projects/dotnet-cli-build/DotNetDebTool.cs b/build_projects/dotnet-cli-build/DotNetDebTool.cs new file mode 100644 index 000000000..5946d2c97 --- /dev/null +++ b/build_projects/dotnet-cli-build/DotNetDebTool.cs @@ -0,0 +1,50 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +namespace Microsoft.DotNet.Cli.Build +{ + public class DotNetDebTool : DotNetTool + { + protected override string Command + { + get { return "deb-tool"; } + } + + protected override string Args + { + get { return $"{GetInputDir()} {GetOutputFile()} {GetPackageName()} {GetPackageVersion()}"; } + } + + [Required] + public string InputDir { get; set; } + + [Required] + public string OutputFile { get; set; } + + [Required] + public string PackageName { get; set; } + + [Required] + public string PackageVersion { get; set; } + + private string GetInputDir() + { + return $"-i {InputDir}"; + } + + private string GetOutputFile() + { + return $"-o {OutputFile}"; + } + + private string GetPackageName() + { + return $"-n {PackageName}"; + } + + private string GetPackageVersion() + { + return $"-v {PackageVersion}"; + } + } +} diff --git a/build_projects/shared-build-targets-utils/Utils/DebPackageCreator.cs b/build_projects/shared-build-targets-utils/Utils/DebPackageCreator.cs index 747532227..97bd81162 100644 --- a/build_projects/shared-build-targets-utils/Utils/DebPackageCreator.cs +++ b/build_projects/shared-build-targets-utils/Utils/DebPackageCreator.cs @@ -11,22 +11,6 @@ using Microsoft.DotNet.Cli.Build.Framework; namespace Microsoft.DotNet.Cli.Build { - public class DebPackageCreator - { - private string _dotnet; - private string _intermediateDirectory; - private string _dotnetDebToolVersion; - private string _dotnetDebToolPackageSource; - private string _consumingProjectDirectory; - - public DebPackageCreator( - string dotnet, - string intermediateDirectory, - string dotnetDebToolVersion, - string dotnetDebToolPackageSource = null) - { - InitializeDotnetDebTool(); - } public void CreateDeb( string debianConfigJsonFile, @@ -57,15 +41,6 @@ namespace Microsoft.DotNet.Cli.Build CreateDebianPackage(debianLayoutDirectories, debIntermediatesDirectory, outputFile, packageName, packageVersion); } - private void CreateEmptyDebianLayout(DebianLayoutDirectories layoutDirectories) - { - Directory.CreateDirectory(layoutDirectories.AbsolutePlacement); - Directory.CreateDirectory(layoutDirectories.PackageRoot); - Directory.CreateDirectory(layoutDirectories.Samples); - Directory.CreateDirectory(layoutDirectories.Docs); - Directory.CreateDirectory(layoutDirectories.DebianFiles); - } - private void CopyFilesToDebianLayout( DebianLayoutDirectories layoutDirectories, string packageVersion, @@ -128,81 +103,5 @@ namespace Microsoft.DotNet.Cli.Build File.WriteAllText(debianConfigFile, debianConfigFileContents); } - - private void CreateDebianPackage( - DebianLayoutDirectories debianLayoutDirectories, - string intermediatesOutputDirectory, - string outputFile, - string packageName, - string packageVersion) - { - _dotnet.Exec("deb-tool", - "-i", debianLayoutDirectories.LayoutDirectory, - "-o", intermediatesOutputDirectory, - "-n", packageName, - "-v", packageVersion) - .WorkingDirectory(_consumingProjectDirectory) - .Execute() - .EnsureSuccessful(); - - var debianFile = Directory.EnumerateFiles(intermediatesOutputDirectory, "*.deb").First(); - File.Copy(debianFile, outputFile, true); - } - - private void InitializeDotnetDebTool() - { - CreateAndRestoreToolConsumingProject(); - } - - private void CreateAndRestoreToolConsumingProject() - { - if (Directory.Exists(_consumingProjectDirectory)) - { - FS.Rmdir(_consumingProjectDirectory); - } - FS.Mkdirp(_consumingProjectDirectory); - - var projectJsonFile = Path.Combine(_consumingProjectDirectory, "project.json"); - File.WriteAllText(projectJsonFile, GetDotnetDebProjectJsonContents()); - - Command restore = _dotnetDebToolPackageSource == null - ? _dotnet.Restore() - : _dotnet.Restore("-f", $"{_dotnetDebToolPackageSource}"); - - restore - .WorkingDirectory(Path.GetDirectoryName(projectJsonFile)) - .Execute() - .EnsureSuccessful(); - } - - private string GetDotnetDebProjectJsonContents() - { - var projectJson = new StringBuilder(); - projectJson.Append("{"); - projectJson.Append($" \"version\": \"1.0.0-*\","); - projectJson.Append($" \"name\": \"{s_toolConsumerProjectName}\","); - projectJson.Append(" \"frameworks\": { \"netcoreapp1.0\": { } },"); - projectJson.Append($" \"tools\": {{ \"{s_dotnetDebToolPackageId}\": \"{_dotnetDebToolVersion}\" }},"); - projectJson.Append("}"); - - return projectJson.ToString(); - } - - private class DebianLayoutDirectories - { - private string _layoutDirectory; - - public DebianLayoutDirectories(string layoutDirectory) - { - _layoutDirectory = layoutDirectory; - } - - public string LayoutDirectory => _layoutDirectory; - public string PackageRoot => Path.Combine(_layoutDirectory, "package_root"); - public string AbsolutePlacement => Path.Combine(_layoutDirectory, "$"); - public string Samples => Path.Combine(_layoutDirectory, "samples"); - public string Docs => Path.Combine(_layoutDirectory, "docs"); - public string DebianFiles => Path.Combine(_layoutDirectory, "debian"); - } } }