DEB start

This commit is contained in:
Piotr Puszkiewicz 2016-08-18 10:11:20 -07:00
parent 2db1997bc0
commit 5ffdcd5797
3 changed files with 147 additions and 119 deletions

View file

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<DotnetDebToolPackageId>dotnet-deb-tool</DotnetDebToolPackageId>
<DotnetDebToolVersion>1.0.0-*</DotnetDebToolVersion>
<DotnetDebToolConsumerProjectName>dotnet-deb-tool-consumer</DotnetDebToolConsumerProjectName>
<DotnetDebToolConfigJsonFileName>debian_config.json</DotnetDebToolConfigJsonFileName>
<DebLayoutPackageRootDirName>package_root</DebLayoutPackageRoot>
<DebLayoutAbsolutePlacementDirName>$</DebLayoutAbsolutePlacement>
<DebLayoutSamplesDirName>samples</DebLayoutSamplesDirName>
<DebLayoutDocsDirName>docs</DebLayoutDocsDirName>
<DebLayoutDebianFilesDirName>debian</DebLayoutDebianFilesDirName>
</PropertyGroup>
</Project>

View file

@ -1,114 +1,151 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target Name="SetupGenerateDebInputsOutputs">
<Exec Command="/usr/bin/env debuild -h" ContinueOnError="true">
<Output TaskParameter="ExitCode" PropertyName="DebuildExitCode" />
</Exec>
<Import Project="Microsoft.DotNet.Cli.Installer.DEB.props" />
<Target Name="SetupGenerateDebInputsOutputs">
<Exec Command="/usr/bin/env debuild -h" ContinueOnError="true">
<Output TaskParameter="ExitCode" PropertyName="DebuildExitCode" />
</Exec>
<!-- Workaround for Ubuntu16 Jenkins https://github.com/dotnet/core-setup/issues/167 -->
<Message Condition=" '$(DebuildPresent)' != 'true' "
Text="Debuild Not found, Debian packages will not be built."
Importance="High" />
<!-- Workaround for Ubuntu16 Jenkins https://github.com/dotnet/core-setup/issues/167 -->
<Message Condition=" '$(DebuildPresent)' != 'true' "
Text="Debuild Not found, Debian packages will not be built."
Importance="High" />
<PropertyGroup>
<DebuildPresent>false</DebuildPresent>
<DebuildPresent Condition=" '$(DebuildExitCode)' == '0' ">true</DebuildPresent>
<PropertyGroup>
<DebuildPresent>false</DebuildPresent>
<DebuildPresent Condition=" '$(DebuildExitCode)' == '0' ">true</DebuildPresent>
<DebianPackagingScript>$(RepoRoot)/scripts/package/package-debian.sh</DebianPackagingScript>
<ManpagesDirectory>$(RepoRoot)/Documentation/manpages</ManpagesDirectory>
<DotnetDebToolVersion></DotnetDebToolVersion>
<DotnetDebToolPackageSource></DotnetDebToolPackageSource>
<InstallerOutputDirectory>$(PackagesDirectory)</InstallerOutputDirectory>
<SdkInstallerFile>$(InstallerOutputDirectory)/$(ArtifactNameWithVersionSdk)$(InstallerExtension)</SdkInstallerFile>
<DebianPackagingScript>$(RepoRoot)/scripts/package/package-debian.sh</DebianPackagingScript>
<ManpagesDirectory>$(RepoRoot)/Documentation/manpages</ManpagesDirectory>
<SdkDebianPackageName>dotnet-dev-$(SdkVersion)</SdkDebianPackageName>
<SharedFrameworkDebianPackageName>dotnet-sharedframework-$(SharedFrameworkName)-$(SharedFrameworkVersion)</SharedFrameworkDebianPackageName>
<SharedFrameworkDebianPackageName>$(SharedFrameworkDebianPackageName.ToLower())</SharedFrameworkDebianPackageName>
<HostFxrDebianPackageName>dotnet-hostfxr-$(HostFxrVersion)</HostFxrDebianPackageName>
<HostFxrDebianPackageName>$(HostFxrDebianPackageName.ToLower())</HostFxrDebianPackageName>
<SharedHostDebianPackageName>dotnet-host</SharedHostDebianPackageName>
<InstallerOutputDirectory>$(PackagesDirectory)</InstallerOutputDirectory>
<SdkInstallerFile>$(InstallerOutputDirectory)/$(ArtifactNameWithVersionSdk)$(InstallerExtension)</SdkInstallerFile>
<SdkDebianIntermediateDirectory>$(IntermediateDirectory)/debian/sdk</SdkDebianIntermediateDirectory>
<SdkDebianPackageName>dotnet-dev-$(SdkVersion)</SdkDebianPackageName>
<SharedFrameworkDebianPackageName>dotnet-sharedframework-$(SharedFrameworkName)-$(SharedFrameworkVersion)</SharedFrameworkDebianPackageName>
<SharedFrameworkDebianPackageName>$(SharedFrameworkDebianPackageName.ToLower())</SharedFrameworkDebianPackageName>
<HostFxrDebianPackageName>dotnet-hostfxr-$(HostFxrVersion)</HostFxrDebianPackageName>
<HostFxrDebianPackageName>$(HostFxrDebianPackageName.ToLower())</HostFxrDebianPackageName>
<SharedHostDebianPackageName>dotnet-host</SharedHostDebianPackageName>
<DebianTestResultsXmlFile>$(SdkDebianIntermediateDirectory)/debian-testResults.xml</DebianTestResultsXmlFile>
<DebianInstalledDirectory>/usr/share/dotnet</DebianInstalledDirectory>
<EndToEndTestDirectory>$(RepoRoot)/test/EndToEnd</EndToEndTestDirectory>
</PropertyGroup>
<SdkDebianIntermediateDirectory>$(IntermediateDirectory)/debian/sdk</SdkDebianIntermediateDirectory>
<ItemGroup>
<TestSdkDebTaskEnvironmentVariables Include="PATH=$(DebianInstalledDirectory)$(PathListSeparator)$(PATH)" />
</ItemGroup>
<DebianTestResultsXmlFile>$(SdkDebianIntermediateDirectory)/debian-testResults.xml</DebianTestResultsXmlFile>
<DebianInstalledDirectory>/usr/share/dotnet</DebianInstalledDirectory>
<EndToEndTestDirectory>$(RepoRoot)/test/EndToEnd</EndToEndTestDirectory>
</PropertyGroup>
<!-- Consumed By Publish -->
<ItemGroup>
<GeneratedInstallers Include="$(SdkInstallerFile)" />
</ItemGroup>
<ItemGroup>
<TestSdkDebTaskEnvironmentVariables Include="PATH=$(DebianInstalledDirectory)$(PathListSeparator)$(PATH)" />
</ItemGroup>
<ItemGroup>
<SdkDebInputFiles Include="$(SdkLayoutOutputDirectory)/**/*" />
</ItemGroup>
</Target>
<!-- Consumed By Publish -->
<ItemGroup>
<GeneratedInstallers Include="$(SdkInstallerFile)" />
</ItemGroup>
<Target Name="GenerateSdkDeb"
Condition=" '$(OSName)' == 'ubuntu' and '$(DebuildPresent)' == 'true' "
Inputs="@(SdkDebInputFiles);"
Outputs="$(SdkInstallerFile)" >
<ItemGroup>
<SdkDebInputFiles Include="$(SdkLayoutOutputDirectory)/**/*" />
</ItemGroup>
</Target>
<!-- Install Packages -->
<Exec Command="sudo dpkg -i $(DownloadedSharedHostInstallerFile)" />
<Exec Command="sudo dpkg -i $(DownloadedHostFxrInstallerFile)" />
<Exec Command="sudo dpkg -i $(DownloadedSharedFrameworkInstallerFile)" />
<Target Name="GenerateSdkDeb"
Condition=" '$(OSName)' == 'ubuntu' and '$(DebuildPresent)' == 'true' "
Inputs="@(SdkDebInputFiles);"
Outputs="$(SdkInstallerFile)" >
<Exec Command="'$(DebianPackagingScript)'
-v '$(SdkVersion)'
-i '$(SdkLayoutOutputDirectory)'
-o '$(SdkInstallerFile)'
-p '$(SdkDebianPackageName)'
-b '$(SdkBrandName)'
-m '$(ManpagesDirectory)'
--framework-debian-package-name '$(SharedFrameworkDebianPackageName)'
--framework-nuget-name '$(SharedFrameworkName)'
--framework-nuget-version '$(SharedFrameworkVersion)'
--obj-root '$(SdkDebianIntermediateDirectory)'" />
<!-- Clean the workspace -->
<ItemGroup>
<SdkDebianFilesToClean Remove="*" />
<SdkDebianFilesToClean Include="$(SdkInstallerFile)" />
<!-- Remove Packages -->
<Exec Command="sudo dpkg -r $(SdkDebianPackageName)" />
<Exec Command="sudo dpkg -r $(SharedFrameworkDebianPackageName)" />
<Exec Command="sudo dpkg -r $(HostFxrDebianPackageName)" />
<Exec Command="sudo dpkg -r $(SharedHostDebianPackageName)" />
</Target>
<SdkDebianDirectoriesToClean Remove="*" />
<SdkDebianDirectoriesToClean Include="$(SdkDebianIntermediateDirectory)" />
<SdkDebianDirectoriesToClean Include="$(SdkDebianLayoutOutputDirectory)" />
</ItemGroup>
<Target Name="TestSdkDeb"
Condition=" '$(OSName)' == 'ubuntu' and '$(DebuildPresent)' == 'true' "
Inputs="$(DownloadedSharedHostInstallerFile);
$(DownloadedHostFxrInstallerFile);
$(DownloadedSharedFrameworkInstallerFile);
$(SdkInstallerFile);"
Outputs="$(DebianTestResultsXmlFile)" >
<Delete Condition=" 'Exists(%(SdkDebianFilesToClean))' " Files="%(SdkDebianFilesToClean)" />
<RemoveDir Condition=" 'Exists(%(SdkDebianDirectoriesToClean))' " Directories="%(SdkDebianDirectoriesToClean)" />
<MakeDir Directories="@(SdkDebianDirectoriesToClean)" />
<!-- Install Packages -->
<Exec Command="sudo dpkg -i $(DownloadedSharedHostInstallerFile)" />
<Exec Command="sudo dpkg -i $(DownloadedHostFxrInstallerFile)" />
<Exec Command="sudo dpkg -i $(DownloadedSharedFrameworkInstallerFile)" />
<Exec Command="sudo dpkg -i $(SdkInstallerFile)" />
<!-- Install Packages -->
<Exec Command="sudo dpkg -i $(DownloadedSharedHostInstallerFile)" />
<Exec Command="sudo dpkg -i $(DownloadedHostFxrInstallerFile)" />
<Exec Command="sudo dpkg -i $(DownloadedSharedFrameworkInstallerFile)" />
<!-- Run E2E -->
<DotNetTest WorkingDirectory="$(EndToEndTestDirectory)"
EnvironmentVariables="@(TestSdkDebTaskEnvironmentVariables)"
ToolPath="$(DebianInstalledDirectory)"
Xml="$(DebianTestResultsXmlFile)" />
<!-- Create layout -->
<!-- Remove Packages -->
<Exec Command="sudo dpkg -r $(SdkDebianPackageName)" />
<Exec Command="sudo dpkg -r $(SharedFrameworkDebianPackageName)" />
<Exec Command="sudo dpkg -r $(HostFxrDebianPackageName)" />
<Exec Command="sudo dpkg -r $(SharedHostDebianPackageName)" />
</Target>
<Target Name="GenerateDebs"
DependsOnTargets="Init;
Layout;
SetupGenerateDebInputsOutputs;
GenerateSdkDeb;
TestSdkDeb;"
Condition=" '$(OSName)' == 'ubuntu' " />
<Exec Command="'$(DebianPackagingScript)'
-v '$(SdkVersion)'
-i '$(SdkLayoutOutputDirectory)'
-o '$(SdkInstallerFile)'
-p '$(SdkDebianPackageName)'
-b '$(SdkBrandName)'
-m '$(ManpagesDirectory)'
--framework-debian-package-name '$(SharedFrameworkDebianPackageName)'
--framework-nuget-name '$(SharedFrameworkName)'
--framework-nuget-version '$(SharedFrameworkVersion)'
--obj-root '$(SdkDebianIntermediateDirectory)'" />
<!-- Remove Packages -->
<Exec Command="sudo dpkg -r $(SdkDebianPackageName)" />
<Exec Command="sudo dpkg -r $(SharedFrameworkDebianPackageName)" />
<Exec Command="sudo dpkg -r $(HostFxrDebianPackageName)" />
<Exec Command="sudo dpkg -r $(SharedHostDebianPackageName)" />
</Target>
<Target Name="TestSdkDeb"
Condition=" '$(OSName)' == 'ubuntu' and '$(DebuildPresent)' == 'true' "
Inputs="$(DownloadedSharedHostInstallerFile);
$(DownloadedHostFxrInstallerFile);
$(DownloadedSharedFrameworkInstallerFile);
$(SdkInstallerFile);"
Outputs="$(DebianTestResultsXmlFile)" >
<!-- Install Packages -->
<Exec Command="sudo dpkg -i $(DownloadedSharedHostInstallerFile)" />
<Exec Command="sudo dpkg -i $(DownloadedHostFxrInstallerFile)" />
<Exec Command="sudo dpkg -i $(DownloadedSharedFrameworkInstallerFile)" />
<Exec Command="sudo dpkg -i $(SdkInstallerFile)" />
<!-- Run E2E -->
<DotNetTest WorkingDirectory="$(EndToEndTestDirectory)"
EnvironmentVariables="@(TestSdkDebTaskEnvironmentVariables)"
ToolPath="$(DebianInstalledDirectory)"
Xml="$(DebianTestResultsXmlFile)" />
<!-- Remove Packages -->
<Exec Command="sudo dpkg -r $(SdkDebianPackageName)" />
<Exec Command="sudo dpkg -r $(SharedFrameworkDebianPackageName)" />
<Exec Command="sudo dpkg -r $(HostFxrDebianPackageName)" />
<Exec Command="sudo dpkg -r $(SharedHostDebianPackageName)" />
</Target>
<Target Name="GenerateDebs"
DependsOnTargets="Init;
Layout;
SetupGenerateDebInputsOutputs;
GenerateSdkDeb;
TestSdkDeb;"
Condition=" '$(OSName)' == 'ubuntu' " />
<Target Name="PrepareDotnetDebTool"
DependsOnTargets="WriteDotnetDebToolProjectJson;">
</Target>
<Target Name="WriteDotnetDebToolProjectJson" >
<ItemGroup>
<AssemblyInfoLines Include="{" />
<AssemblyInfoLines Include="%20%20%20%20&quot;version&quot;: &quot;1.0.0-*&quot;," />
<AssemblyInfoLines Include="%20%20%20%20&quot;name&quot;: &quot;$(DotnetDebToolConsumerProjectName)&quot;," />
<AssemblyInfoLines Include="%20%20%20%20&quot;frameworks&quot;: { &quot;netcoreapp1.0&quot;: {} }," />
<AssemblyInfoLines Include="%20%20%20%20&quot;tools&quot;: {{&quot;$(DotnetDebToolPackageId)&quot;: &quot;$(DotnetDebToolVersion)&quot; }}" />
<AssemblyInfoLines Include="}" />
</ItemGroup>
</Target>
</Project>

View file

@ -9,35 +9,22 @@ using System.Text;
using System.Threading.Tasks;
using Microsoft.DotNet.Cli.Build.Framework;
using static Microsoft.DotNet.Cli.Build.Framework.BuildHelpers;
namespace Microsoft.DotNet.Cli.Build
{
public class DebPackageCreator
{
private static readonly string s_dotnetDebToolPackageId = "dotnet-deb-tool";
private static readonly string s_toolConsumerProjectName = "dotnet-deb-tool-consumer";
private static readonly string s_debianConfigJsonFileName = "debian_config.json";
private DotNetCli _dotnet;
private string _dotnet;
private string _intermediateDirectory;
private string _dotnetDebToolVersion;
private string _dotnetDebToolPackageSource;
private string _consumingProjectDirectory;
public DebPackageCreator(
DotNetCli dotnet,
string dotnet,
string intermediateDirectory,
string dotnetDebToolVersion = "1.0.0-*",
string dotnetDebToolVersion,
string dotnetDebToolPackageSource = null)
{
_dotnet = dotnet;
_intermediateDirectory = intermediateDirectory;
_dotnetDebToolVersion = dotnetDebToolVersion;
_dotnetDebToolPackageSource = dotnetDebToolPackageSource;
_consumingProjectDirectory = Path.Combine(_intermediateDirectory, s_toolConsumerProjectName);
InitializeDotnetDebTool();
}
@ -53,11 +40,6 @@ namespace Microsoft.DotNet.Cli.Build
IEnumerable<string> debianFiles = null)
{
string debIntermediatesDirectory = Path.Combine(_intermediateDirectory, packageName, packageVersion);
if (Directory.Exists(debIntermediatesDirectory))
{
FS.Rmdir(debIntermediatesDirectory);
}
FS.Mkdirp(debIntermediatesDirectory);
string layoutDirectory = Path.Combine(debIntermediatesDirectory, "debianLayoutDirectory");
var debianLayoutDirectories = new DebianLayoutDirectories(layoutDirectory);
@ -77,12 +59,6 @@ namespace Microsoft.DotNet.Cli.Build
private void CreateEmptyDebianLayout(DebianLayoutDirectories layoutDirectories)
{
if (Directory.Exists(layoutDirectories.LayoutDirectory))
{
FS.Rmdir(layoutDirectories.LayoutDirectory);
}
Directory.CreateDirectory(layoutDirectories.LayoutDirectory);
Directory.CreateDirectory(layoutDirectories.AbsolutePlacement);
Directory.CreateDirectory(layoutDirectories.PackageRoot);
Directory.CreateDirectory(layoutDirectories.Samples);