Skip to content
This repository was archived by the owner on Nov 21, 2018. It is now read-only.

Debian installers #154

Merged
merged 1 commit into from
Jun 15, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions build/dependencies.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<AspNetCoreVersion>2.0.0-preview2-*</AspNetCoreVersion>
<CoreFxVersion>4.4.0-*</CoreFxVersion>
<DepsRuntimeFrameworkVersion>2.0.0-preview2-25407-01</DepsRuntimeFrameworkVersion>
<DotnetDebToolVersion>2.0.0-preview2-*</DotnetDebToolVersion>
<InternalAspNetCoreSdkVersion>2.1.0-*</InternalAspNetCoreSdkVersion>
<MoqVersion>4.7.1</MoqVersion>
<NETStandardLibraryNETFrameworkVersion>2.0.0-*</NETStandardLibraryNETFrameworkVersion>
Expand Down
159 changes: 158 additions & 1 deletion build/repo.targets
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This follows the CLI naming scheme:

Package name: aspnetcore-store-{version}, in the CLI: https://github.com/dotnet/cli/blob/358568b07f16749108dd33e7fea2f2c84ccf4563/build/package/Installer.DEB.targets#L30
Package file name: aspnetcore-store-{version}-{RID}, in the CLI: https://github.com/dotnet/cli/blob/358568b07f16749108dd33e7fea2f2c84ccf4563/build/Branding.props#L31

<RuntimeStoreNoTimestampDebianPackageName>aspnetcore-store-$(NoTimestampVersion)</RuntimeStoreNoTimestampDebianPackageName>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have we verified the naming of runtimes-store installers with the PMs? //cc @richlander, cref https://github.com/dotnet/designs/issues/2

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm following the convention highlighted by @DamianEdwards in #124 though I'm not sure if this is correct. That's why I called out on it in my previous comment. This needs to be checked by a PM.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@glennc, can you signoff on the naming here?

<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)"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be good to assert that the docker host is using Linux containers, not windows containers.

$ docker version -f "{{ .Server.Os }}"
linux

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assert added.

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>
7 changes: 7 additions & 0 deletions tools/RestoreRuntimeStore/NuGet.config
Original file line number Diff line number Diff line change
@@ -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>
13 changes: 13 additions & 0 deletions tools/RestoreRuntimeStore/RestoreRuntimeStore.csproj
Original file line number Diff line number Diff line change
@@ -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 changes: 30 additions & 0 deletions tools/debian_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"maintainer_name":"Microsoft",
Copy link
Contributor Author

@JunTaoLuo JunTaoLuo Jun 13, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Eilon Please review this debian config file. This is mostly copied over from https://github.com/dotnet/cli/blob/3419a87d6fb620a2ea7981cdd6cd43db3b17cb5f/packaging/deb/dotnet-debian_config.json

Nodes especially important are maintainer_*, maintainer_email, install_root, *_description, homepage, copyright and license.

The package_name and package_version are overridden by the values passed explicitly to the dotnet deb tool. The values in release and control seem to be dummy values though I need to verify them.

"maintainer_email": "[email protected]",

"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."
}
}
51 changes: 51 additions & 0 deletions tools/docker/debian/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
52 changes: 52 additions & 0 deletions tools/docker/ubuntu.14.04/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
48 changes: 48 additions & 0 deletions tools/docker/ubuntu.16.04/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
Loading