Build .deb installers

This commit is contained in:
John Luo 2017-06-15 11:17:00 -07:00
commit 4a779545a4
11 changed files with 433 additions and 1 deletions

View File

@ -3,6 +3,7 @@
<AspNetCoreIntegrationTestingVersion>0.4.0-*</AspNetCoreIntegrationTestingVersion>
<AspNetCoreVersion>2.0.0-*</AspNetCoreVersion>
<CoreFxVersion>4.4.0-*</CoreFxVersion>
<DotnetDebToolVersion>2.0.0-preview2-*</DotnetDebToolVersion>
<InternalAspNetCoreSdkVersion>2.1.0-*</InternalAspNetCoreSdkVersion>
<MoqVersion>4.7.1</MoqVersion>
<NETStandardLibraryNETFrameworkVersion>2.0.0-*</NETStandardLibraryNETFrameworkVersion>

View File

@ -31,12 +31,26 @@
<RuntimeStoreZipNoTimestampDir>$(ArtifactsZipDir)n\</RuntimeStoreZipNoTimestampDir>
<RuntimeStoreSymbolsZipTimestampDir>$(ArtifactsZipDir)st\</RuntimeStoreSymbolsZipTimestampDir>
<RuntimeStoreSymbolsZipNoTimestampDir>$(ArtifactsZipDir)sn\</RuntimeStoreSymbolsZipNoTimestampDir>
<RuntimeStoreInstallerDirectory>$(ArtifactsDir)installers\</RuntimeStoreInstallerDirectory>
<RuntimeStoreArchiveDirectory>$(ArtifactsDir)rsArchive\</RuntimeStoreArchiveDirectory>
<RuntimeStoreInstallerLayoutTimestampDirectory>$(ArtifactsDir)itLayout\</RuntimeStoreInstallerLayoutTimestampDirectory>
<RuntimeStoreInstallerLayoutPackageRootTimestampDirectory>$(RuntimeStoreInstallerLayoutTimestampDirectory)package_root\</RuntimeStoreInstallerLayoutPackageRootTimestampDirectory>
<RuntimeStoreInstallerLayoutNoTimestampDirectory>$(ArtifactsDir)inLayout\</RuntimeStoreInstallerLayoutNoTimestampDirectory>
<RuntimeStoreInstallerLayoutPackageRootNoTimestampDirectory>$(RuntimeStoreInstallerLayoutNoTimestampDirectory)package_root\</RuntimeStoreInstallerLayoutPackageRootNoTimestampDirectory>
<RuntimeStoreInstallerOutputTimeStampDirectory>$(ArtifactsDir)itOutput\</RuntimeStoreInstallerOutputTimeStampDirectory>
<RuntimeStoreInstallerOutputNoTimeStampDirectory>$(ArtifactsDir)inOutput\</RuntimeStoreInstallerOutputNoTimeStampDirectory>
<TempDir>$(ArtifactsDir)temp\</TempDir>
<ToolsDir>$(RepositoryRoot)tools\</ToolsDir>
<DockerDir>$(ToolsDir)docker\</DockerDir>
<DependencyBuildDirectory>$(RepositoryRoot).deps\build\</DependencyBuildDirectory>
<RuntimeStoreReferenceDirectory>$(ToolsDir)Build.RuntimeStore.References\</RuntimeStoreReferenceDirectory>
<RuntimeStoreReferencePackageDirectory>$(RuntimeStoreReferenceDirectory)bin\Release\</RuntimeStoreReferencePackageDirectory>
<BuildTempDirectory>$(RepositoryRoot).build\temp\</BuildTempDirectory>
<DebianConfigTemplateFile>$(ToolsDir)debian_config.json</DebianConfigTemplateFile>
<DotnetDebToolDirectory>$(ToolsDir)dotnet-deb-tool-consumer\</DotnetDebToolDirectory>
<RestoreRuntimeStoreDirectory>$(ToolsDir)RestoreRuntimeStore\</RestoreRuntimeStoreDirectory>
<BuildDirectory>$(RepositoryRoot).build\</BuildDirectory>
<BuildTempDirectory>$(BuildDirectory)temp\</BuildTempDirectory>
<BuildDotnetDirectory>$(BuildDirectory)dotnet\</BuildDotnetDirectory>
<PrepareDependsOn>
$(PrepareDependsOn);
@ -289,4 +303,147 @@
<ZipArchive File="%(MetaPackageNupkg.FullPath)" SourceFiles="@(ArchiveFiles)" WorkingDirectory="@(MetaPackageNupkg->'$(TempDir)%(Filename)')" Overwrite="true" />
</Target>
<Target Name="BuildInstallers" DependsOnTargets="GenerateDebs" />
<Target Name="GenerateDebs">
<!-- Check Docker server OS -->
<Exec Command="docker version -f &quot;{{.Server.Os}}&quot;" ConsoleToMSBuild="true">
<Output TaskParameter="ConsoleOutput" PropertyName="DockerHostOS" />
</Exec>
<Error Text="Docker host must be using Linux containers." Condition="'$(DockerHostOS)' != 'linux'"/>
<!-- Download runtime store archives -->
<Exec Command="dotnet restore --packages $(RuntimeStoreArchiveDirectory)" WorkingDirectory="$(RestoreRuntimeStoreDirectory)" />
<ItemGroup>
<RuntimeStoreTimestampArchive Include="$(RuntimeStoreArchiveDirectory)**\Build.RS.linux-*"/>
<RuntimeStoreNoTimestampArchive Include="$(RuntimeStoreArchiveDirectory)**\Build.RS.linux.*"/>
</ItemGroup>
<Error Text="@(RuntimeStoreTimestampArchive->Count()) timestamp linux archives found." Condition="'@(RuntimeStoreTimestampArchive->Count())' != 1" />
<Error Text="@(RuntimeStoreNoTimestampArchive->Count()) no timestamp linux archives found." Condition="'@(RuntimeStoreNoTimestampArchive->Count())' != 1" />
<!-- Create layout: Aspnet runtime store -->
<RemoveDir Directories="$(RuntimeStoreInstallerLayoutPackageRootTimestampDirectory)" />
<MakeDir Directories="$(RuntimeStoreInstallerLayoutPackageRootTimestampDirectory)" />
<Exec Command="tar -xzf @(RuntimeStoreTimestampArchive) -C $(RuntimeStoreInstallerLayoutPackageRootTimestampDirectory)" />
<RemoveDir Directories="$(RuntimeStoreInstallerLayoutPackageRootNoTimestampDirectory)" />
<MakeDir Directories="$(RuntimeStoreInstallerLayoutPackageRootNoTimestampDirectory)" />
<Exec Command="tar -xzf @(RuntimeStoreNoTimestampArchive) -C $(RuntimeStoreInstallerLayoutPackageRootNoTimestampDirectory)" />
<!-- Create layout: Generate and Place debian_config.json -->
<Copy
SourceFiles="$(DebianConfigTemplateFile)"
DestinationFiles="$(RuntimeStoreInstallerLayoutTimestampDirectory)debian_config.json"
OverwriteReadOnlyFiles="True"
SkipUnchangedFiles="False"
UseHardlinksIfPossible="False" />
<Copy
SourceFiles="$(DebianConfigTemplateFile)"
DestinationFiles="$(RuntimeStoreInstallerLayoutNoTimestampDirectory)debian_config.json"
OverwriteReadOnlyFiles="True"
SkipUnchangedFiles="False"
UseHardlinksIfPossible="False" />
<MSBuild Projects="$(ProjectPath)" Targets="BuildRuntimeStoreDeb" Properties="InstallerPlatform=debian" />
<MSBuild Projects="$(ProjectPath)" Targets="BuildRuntimeStoreDeb" Properties="InstallerPlatform=ubuntu.14.04" />
<MSBuild Projects="$(ProjectPath)" Targets="BuildRuntimeStoreDeb" Properties="InstallerPlatform=ubuntu.16.04" />
<MSBuild Projects="$(ProjectPath)" Targets="BuildRuntimeStoreDeb" Properties="InstallerPlatform=ubuntu.16.10" />
</Target>
<Target Name="BuildRuntimeStoreDeb">
<PropertyGroup>
<RuntimeStoreTimestampDebianPackageName>aspnetcore-store-$(TimestampVersion)</RuntimeStoreTimestampDebianPackageName>
<RuntimeStoreNoTimestampDebianPackageName>aspnetcore-store-$(NoTimestampVersion)</RuntimeStoreNoTimestampDebianPackageName>
<RuntimeStoreTimestampDebianFileName>$(RuntimeStoreTimestampDebianPackageName)-$(InstallerPlatform)-$(PACKAGE_CACHE_PLATFORM).deb</RuntimeStoreTimestampDebianFileName>
<RuntimeStoreNoTimestampDebianFileName>$(RuntimeStoreNoTimestampDebianPackageName)-$(InstallerPlatform)-$(PACKAGE_CACHE_PLATFORM).deb</RuntimeStoreNoTimestampDebianFileName>
</PropertyGroup>
<!-- Clear the output dir -->
<RemoveDir Directories="$(RuntimeStoreInstallerOutputTimeStampDirectory)" />
<RemoveDir Directories="$(RuntimeStoreInstallerOutputNoTimeStampDirectory)" />
<MakeDir Directories="$(RuntimeStoreInstallerOutputTimeStampDirectory)" />
<MakeDir Directories="$(RuntimeStoreInstallerOutputNoTimeStampDirectory)" />
<!-- Build Docker Image -->
<Exec
Command="docker build --build-arg USER_ID=%24(id -u) -t docker-image-$(InstallerPlatform) $(InstallerPlatform)"
WorkingDirectory="$(DockerDir)" />
<!-- Parse CLI version -->
<ReadLinesFromFile File="$(BuildDirectory)cli.version">
<Output TaskParameter="Lines" PropertyName="CLIVersionNumber" />
</ReadLinesFromFile>
<!-- Build Runtime Store Deb package -->
<Exec Command="docker run
--rm
-v %24(pwd):/opt/code
-e DOTNET_SKIP_FIRST_TIME_EXPERIENCE=true
-e KOREBUILD_SKIP_RUNTIME_INSTALL=true
-e BuildNumber=$(BuildNumber)
-e RUNTIMESTORE_TIMESTAMP_INSTALLERNAME=$(RuntimeStoreTimestampDebianPackageName)
-e RUNTIMESTORE_NOTIMESTAMP_INSTALLERNAME=$(RuntimeStoreNoTimestampDebianPackageName)
docker-image-$(InstallerPlatform)
/bin/bash -c &quot;
/opt/code/.build/dotnet/dotnet-install.sh
--channel preview
--version $(CLIVersionNumber) &amp;&amp;
export PATH=$PATH:/home/code_executor/.dotnet &amp;&amp;
./build.sh /t:RunDebTool
&quot;"
WorkingDirectory="$(RepositoryRoot)"
ContinueOnError="WarnAndContinue" />
<!-- Remove Docker Image to save disk space -->
<Exec Command="docker rmi docker-image-$(InstallerPlatform)" />
<!-- Copy Runtime Store package to output -->
<ItemGroup>
<GeneratedTimestampDebFiles Include="$(RuntimeStoreInstallerOutputTimeStampDirectory)/*.deb" />
<GeneratedNoTimestampDebFiles Include="$(RuntimeStoreInstallerOutputNoTimeStampDirectory)/*.deb" />
</ItemGroup>
<Error Text="@(GeneratedTimestampDebFiles->Count()) timestamp .deb files generated." Condition="'@(GeneratedTimestampDebFiles->Count())' != 1" />
<Error Text="@(GeneratedNoTimestampDebFiles->Count()) no timestamp .deb files generated." Condition="'@(GeneratedTimestampDebFiles->Count())' != 1" />
<Copy
DestinationFiles="$(RuntimeStoreInstallerDirectory)$(RuntimeStoreTimestampDebianFileName)"
SourceFiles="@(GeneratedTimestampDebFiles)"
OverwriteReadOnlyFiles="True"
SkipUnchangedFiles="False"
UseHardlinksIfPossible="False" />
<Copy
DestinationFiles="$(RuntimeStoreInstallerDirectory)$(RuntimeStoreNoTimestampDebianFileName)"
SourceFiles="@(GeneratedNoTimestampDebFiles)"
OverwriteReadOnlyFiles="True"
SkipUnchangedFiles="False"
UseHardlinksIfPossible="False" />
</Target>
<Target Name="RunDebTool">
<!-- Install dotnet-deb tool -->
<Exec Command="dotnet restore" WorkingDirectory="$(DotnetDebToolDirectory)" />
<!-- Build Runtime Store Timestamp Deb package -->
<Exec Command="
dotnet deb-tool
-i $(RuntimeStoreInstallerLayoutTimestampDirectory)
-o $(RuntimeStoreInstallerOutputTimeStampDirectory)
-n $(RUNTIMESTORE_TIMESTAMP_INSTALLERNAME)
-v $(TimestampVersion)"
WorkingDirectory="$(DotnetDebToolDirectory)" />
<!-- Build Runtime Store NoTimestamp Deb package -->
<Exec Command="
dotnet deb-tool
-i $(RuntimeStoreInstallerLayoutNoTimestampDirectory)
-o $(RuntimeStoreInstallerOutputNoTimeStampDirectory)
-n $(RUNTIMESTORE_NOTIMESTAMP_INSTALLERNAME)
-v $(NoTimestampVersion)"
WorkingDirectory="$(DotnetDebToolDirectory)" />
</Target>
</Project>

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<clear />
<add key="AspNetCore" value="https://dotnet.myget.org/F/aspnetcore-release/api/v3/index.json" />
</packageSources>
</configuration>

View File

@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\build\dependencies.props" />
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Build.RS" Version="$(AspNetCoreVersion)" />
</ItemGroup>
</Project>

30
tools/debian_config.json Normal file
View File

@ -0,0 +1,30 @@
{
"maintainer_name":"Microsoft",
"maintainer_email": "nugetaspnet@microsoft.com",
"package_name": "aspnetcore-store",
"install_root": "/usr/share/dotnet",
"short_description": "Microsoft ASP.NET Core Runtime Package Store 2.0.0 - Preview 2",
"long_description": "Runtime package store for Microsoft ASP.NET Core. It is open source, cross-platform and is supported by Microsoft. We hope you enjoy using it! If you do, please consider joining the active community of developers that are contributing to the project on GitHub (https://github.com/aspnet/home). We happily accept issues and PRs.",
"homepage": "https://www.asp.net/",
"release":{
"package_version":"0.0.0.0",
"package_revision":"1",
"urgency" : "low",
"changelog_message" : "Bootstrap loop package"
},
"control": {
"priority":"standard",
"section":"devel",
"architecture":"any"
},
"copyright": "Microsoft",
"license": {
"type": "Apache",
"full_text": "Copyright (c) .NET Foundation. All rights reserved.\n\nLicensed under the Apache License, Version 2.0 (the \"License\"); you may not use\nthese files except in compliance with the License. You may obtain a copy of the\nLicense at\n\nhttp://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed\nunder the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR\nCONDITIONS OF ANY KIND, either express or implied. See the License for the\nspecific language governing permissions and limitations under the License."
}
}

View File

@ -0,0 +1,51 @@
#
# Copyright (c) .NET Foundation. All rights reserved.
# Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
#
# Dockerfile that creates a container suitable to build dotnet-cli
FROM debian:jessie
# Misc Dependencies for build
RUN apt-get update && \
apt-get -qqy install \
curl \
unzip \
gettext \
sudo \
libunwind8 \
libkrb5-3 \
libicu52 \
liblttng-ust0 \
libssl1.0.0 \
zlib1g \
libuuid1 \
debhelper \
build-essential \
devscripts \
git \
cmake \
clang-3.5 \
wget && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# Use clang as c++ compiler
RUN update-alternatives --install /usr/bin/c++ c++ /usr/bin/clang++-3.5 100
RUN update-alternatives --set c++ /usr/bin/clang++-3.5
# Setup User to match Host User, and give superuser permissions
ARG USER_ID=0
RUN useradd -m code_executor -u ${USER_ID} -g sudo
RUN echo 'code_executor ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
# With the User Change, we need to change permissions on these directories
RUN chmod -R a+rwx /usr/local
RUN chmod -R a+rwx /home
RUN chmod -R 755 /usr/lib/sudo
# Set user to the one we just created
USER ${USER_ID}
# Set working directory
WORKDIR /opt/code

View File

@ -0,0 +1,52 @@
#
# Copyright (c) .NET Foundation. All rights reserved.
# Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
#
# Dockerfile that creates a container suitable to build dotnet-cli
FROM ubuntu:14.04
# Misc Dependencies for build
RUN apt-get update && \
apt-get -qqy install \
curl \
unzip \
gettext \
sudo \
libunwind8 \
libkrb5-3 \
libicu52 \
liblttng-ust0 \
libssl1.0.0 \
zlib1g \
libuuid1 \
debhelper \
build-essential \
devscripts \
git \
cmake \
clang-3.5 \
lldb-3.6 \
wget && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# Use clang as c++ compiler
RUN update-alternatives --install /usr/bin/c++ c++ /usr/bin/clang++-3.5 100
RUN update-alternatives --set c++ /usr/bin/clang++-3.5
# Setup User to match Host User, and give superuser permissions
ARG USER_ID=0
RUN useradd -m code_executor -u ${USER_ID} -g sudo
RUN echo 'code_executor ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
# With the User Change, we need to change permissions on these directories
RUN chmod -R a+rwx /usr/local
RUN chmod -R a+rwx /home
RUN chmod -R 755 /usr/lib/sudo
# Set user to the one we just created
USER ${USER_ID}
# Set working directory
WORKDIR /opt/code

View File

@ -0,0 +1,48 @@
#
# Copyright (c) .NET Foundation. All rights reserved.
# Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
#
FROM ubuntu:16.04
# Install the base toolchain we need to build anything (clang, cmake, make and the like)
# this does not include libraries that we need to compile different projects, we'd like
# them in a different layer.
RUN apt-get update && \
apt-get install -y cmake \
make \
llvm-3.5 \
clang-3.5 \
git \
curl \
tar \
sudo \
debhelper \
build-essential \
devscripts \
libunwind8 \
libkrb5-3 \
libicu55 \
liblttng-ust0 \
libssl1.0.0 \
zlib1g \
libuuid1 \
liblldb-3.6 \
wget && \
apt-get clean
# Setup User to match Host User, and give superuser permissions
ARG USER_ID=0
RUN useradd -m code_executor -u ${USER_ID} -g sudo
RUN echo 'code_executor ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
# With the User Change, we need to change permissions on these directories
RUN chmod -R a+rwx /usr/local
RUN chmod -R a+rwx /home
RUN chmod -R 755 /usr/lib/sudo
# Set user to the one we just created
USER ${USER_ID}
# Set working directory
WORKDIR /opt/code

View File

@ -0,0 +1,52 @@
#
# Copyright (c) .NET Foundation. All rights reserved.
# Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
#
# Dockerfile that creates a container suitable to build dotnet-cli
FROM ubuntu:16.10
# Misc Dependencies for build
RUN apt-get update && \
apt-get -qqy install \
curl \
unzip \
gettext \
sudo \
libunwind8 \
libkrb5-3 \
libicu57 \
liblttng-ust0 \
libssl1.0.0 \
zlib1g \
libuuid1 \
liblldb-3.5 \
debhelper \
build-essential \
devscripts \
git \
cmake \
clang-3.5 \
wget && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# Use clang as c++ compiler
RUN update-alternatives --install /usr/bin/c++ c++ /usr/bin/clang++-3.5 100
RUN update-alternatives --set c++ /usr/bin/clang++-3.5
# Setup User to match Host User, and give superuser permissions
ARG USER_ID=0
RUN useradd -m code_executor -u ${USER_ID} -g sudo
RUN echo 'code_executor ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
# With the User Change, we need to change permissions on these directories
RUN chmod -R a+rwx /usr/local
RUN chmod -R a+rwx /home
RUN chmod -R 755 /usr/lib/sudo
# Set user to the one we just created
USER ${USER_ID}
# Set working directory
WORKDIR /opt/code

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<!--To inherit the global NuGet package sources remove the <clear/> line below -->
<clear />
<add key="cli-deps" value="https://dotnet.myget.org/F/cli-deps/api/v3/index.json" />
</packageSources>
</configuration>

View File

@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\build\dependencies.props" />
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<DotNetCliToolReference Include="dotnet-deb-tool" Version="$(DotnetDebToolVersion)" />
</ItemGroup>
</Project>