Fill out pkg installer targets

This causes three pkg files to be produced:

* A component pkg for the shared framework.
* A component pkg for the shared host.
* A product archive which includes the above two components.

The product archive also needs a distribution.xml file which contains
metadata about the package (name, title, images, etc.).

The installer for the "SDK" itself is still using logic implemented in
package-osx.sh. We should move this logic into the build target as well,
but we may want to wait until the CLI is using the shared framework to do so.
This commit is contained in:
Eric Mellino 2016-03-09 13:26:37 -08:00
parent 4df5ed39d5
commit edbbc64b03
5 changed files with 174 additions and 37 deletions

View file

@ -0,0 +1,13 @@
#!/bin/sh
#
# 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.
#
PACKAGE=$1
INSTALL_DESTINATION=$2
# A temporary fix for the permissions issue(s)
chmod -R 755 $INSTALL_DESTINATION/shared
exit 0

View file

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<installer-gui-script minSpecVersion="1">
<title>.NET Core Shared Framework ({SharedFrameworkNugetVersion})</title>
<license file="eula.rtf" mime-type="application/rtf" />
<background file="dotnetbackground.png" mime-type="image/png"/>
<options customize="never" require-scripts="false" />
<volume-check>
<allowed-os-version>
<os-version min="10.10" />
</allowed-os-version>
</volume-check>
<choices-outline>
<line choice="com.microsoft.dotnet.sharedframework.{SharedFrameworkNugetVersion}.component.osx.x64.pkg" />
<line choice="com.microsoft.dotnet.sharedhost.osx.x64" />
</choices-outline>
<choice id="com.microsoft.dotnet.sharedframework.{SharedFrameworkNugetVersion}.component.osx.x64.pkg" visible="true" title=".NET Core Shared Framework (x64)" description="The .NET Core Shared Framework">
<pkg-ref id="com.microsoft.dotnet.sharedframework.{SharedFrameworkNugetVersion}.component.osx.x64.pkg" />
</choice>
<choice id="com.microsoft.dotnet.sharedhost.osx.x64" visible="true" title=".NET Core Shared Host (x64)" description="The .NET Core Shared Host." >
<pkg-ref id="com.microsoft.dotnet.sharedhost.osx.x64" />
</choice>
<pkg-ref id="com.microsoft.dotnet.sharedframework.{SharedFrameworkNugetVersion}.component.osx.x64.pkg">com.microsoft.dotnet.sharedframework.{SharedFrameworkNugetVersion}.component.osx.x64.pkg</pkg-ref>
<pkg-ref id="com.microsoft.dotnet.sharedhost.osx.x64">com.microsoft.dotnet.sharedhost.osx.x64.pkg</pkg-ref>
</installer-gui-script>

View file

@ -0,0 +1,13 @@
#!/bin/sh
#
# 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.
#
PACKAGE=$1
INSTALL_DESTINATION=$2
# A temporary fix for the permissions issue(s)
chmod 755 $INSTALL_DESTINATION/dotnet
exit 0

View file

@ -14,49 +14,13 @@ namespace Microsoft.DotNet.Cli.Build
{
[Target(nameof(MsiTargets.GenerateMsis),
nameof(MsiTargets.GenerateBundle),
nameof(InstallerTargets.GeneratePkgs),
nameof(PkgTargets.GeneratePkgs),
nameof(InstallerTargets.GenerateDebs))]
public static BuildTargetResult GenerateInstaller(BuildTargetContext c)
{
return c.Success();
}
[Target(nameof(InstallerTargets.GenerateSdkPkg),
nameof(InstallerTargets.GenerateSharedFrameworkPkg),
nameof(InstallerTargets.GenerateSharedHostPkg))]
[BuildPlatforms(BuildPlatform.OSX)]
public static BuildTargetResult GeneratePkgs(BuildTargetContext c)
{
return c.Success();
}
[Target]
[BuildPlatforms(BuildPlatform.OSX)]
public static BuildTargetResult GenerateSdkPkg(BuildTargetContext c)
{
var version = c.BuildContext.Get<BuildVersion>("BuildVersion").SimpleVersion;
var pkg = c.BuildContext.Get<string>("SdkInstallerFile");
Cmd(Path.Combine(Dirs.RepoRoot, "packaging", "osx", "package-osx.sh"),
"-v", version, "-i", Dirs.Stage2, "-o", pkg)
.Execute()
.EnsureSuccessful();
return c.Success();
}
[Target]
[BuildPlatforms(BuildPlatform.OSX)]
public static BuildTargetResult GenerateSharedFrameworkPkg(BuildTargetContext c)
{
return c.Success();
}
[Target]
[BuildPlatforms(BuildPlatform.OSX)]
public static BuildTargetResult GenerateSharedHostPkg(BuildTargetContext c)
{
return c.Success();
}
[Target(nameof(InstallerTargets.GenerateSdkDeb),
nameof(InstallerTargets.GenerateSharedFrameworkDeb),
nameof(InstallerTargets.GenerateSharedHostDeb))]

View file

@ -0,0 +1,123 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.IO.Compression;
using System.Runtime.InteropServices;
using Microsoft.DotNet.Cli.Build.Framework;
using Microsoft.Extensions.PlatformAbstractions;
using static Microsoft.DotNet.Cli.Build.Framework.BuildHelpers;
namespace Microsoft.DotNet.Cli.Build
{
public class PkgTargets
{
[Target(nameof(GenerateSdkProductArchive), nameof(GenerateSharedFrameworkProductArchive))]
[BuildPlatforms(BuildPlatform.OSX)]
public static BuildTargetResult GeneratePkgs(BuildTargetContext c)
{
return c.Success();
}
[Target]
[BuildPlatforms(BuildPlatform.OSX)]
public static BuildTargetResult GenerateSdkProductArchive(BuildTargetContext c)
{
var version = c.BuildContext.Get<BuildVersion>("BuildVersion").SimpleVersion;
var pkg = c.BuildContext.Get<string>("SdkInstallerFile");
Cmd(Path.Combine(Dirs.RepoRoot, "packaging", "osx", "package-osx.sh"),
"-v", version, "-i", Dirs.Stage2, "-o", pkg)
.Execute()
.EnsureSuccessful();
return c.Success();
}
[Target(nameof(GenerateSharedFrameworkPkg), nameof(GenerateSharedHostPkg))]
[BuildPlatforms(BuildPlatform.OSX)]
public static BuildTargetResult GenerateSharedFrameworkProductArchive(BuildTargetContext c)
{
string sharedFrameworkNugetVersion = c.BuildContext.Get<string>("SharedFrameworkNugetVersion");
string version = c.BuildContext.Get<BuildVersion>("BuildVersion").SimpleVersion;
string id = $"com.microsoft.dotnet.sharedframework.{sharedFrameworkNugetVersion}.osx.x64";
string packageIntermediatesPath = Path.Combine(Dirs.Output, "obj", "pkg");
string resourcePath = Path.Combine(Dirs.RepoRoot, "packaging", "osx", "resources");
string outFilePath = Path.Combine(packageIntermediatesPath, id + ".pkg");
string inputDistTemplatePath = Path.Combine(
Dirs.RepoRoot,
"packaging",
"osx",
"sharedframework",
"shared-framework-distribution-template.xml");
string distTemplate = File.ReadAllText(inputDistTemplatePath);
string distributionPath = Path.Combine(packageIntermediatesPath, "shared-framework-formatted-distribution.xml");
string formattedDistContents =
distTemplate.Replace("{SharedFrameworkNugetVersion}", sharedFrameworkNugetVersion)
.Replace("{VERSION}", version);
File.WriteAllText(distributionPath, formattedDistContents);
Cmd("productbuild",
"--version", version,
"--identifier", id,
"--package-path", packageIntermediatesPath,
"--resources", resourcePath,
"--distribution", distributionPath,
outFilePath
)
.Execute()
.EnsureSuccessful();
return c.Success();
}
[Target]
[BuildPlatforms(BuildPlatform.OSX)]
public static BuildTargetResult GenerateSharedFrameworkPkg(BuildTargetContext c)
{
string sharedFrameworkNugetVersion = c.BuildContext.Get<string>("SharedFrameworkNugetVersion");
Directory.CreateDirectory(Path.Combine(Dirs.Output, "obj", "pkg"));
string version = c.BuildContext.Get<BuildVersion>("BuildVersion").SimpleVersion;
string id = $"com.microsoft.dotnet.sharedframework.{sharedFrameworkNugetVersion}.component.osx.x64";
string outFilePath = Path.Combine(Dirs.Output, "obj", "pkg", id + ".pkg");
string installLocation = "/usr/local/share/dotnet";
string scriptsLocation = Path.Combine(Dirs.RepoRoot, "packaging", "osx", "sharedframework", "scripts");
Cmd("pkgbuild",
"--root", c.BuildContext.Get<string>("SharedFrameworkPublishRoot"),
"--identifier", id,
"--version", version,
"--install-location", installLocation,
"--scripts", scriptsLocation,
outFilePath)
.Execute()
.EnsureSuccessful();
return c.Success();
}
[Target]
[BuildPlatforms(BuildPlatform.OSX)]
public static BuildTargetResult GenerateSharedHostPkg(BuildTargetContext c)
{
Directory.CreateDirectory(Path.Combine(Dirs.Output, "obj", "pkg"));
string version = c.BuildContext.Get<BuildVersion>("BuildVersion").SimpleVersion;
string id = $"com.microsoft.dotnet.sharedhost.osx.x64";
string outFilePath = Path.Combine(Dirs.Output, "obj", "pkg", id + ".pkg");
string installLocation = "/usr/local/share/dotnet";
string scriptsLocation = Path.Combine(Dirs.RepoRoot, "packaging", "osx", "sharedhost", "scripts");
Cmd("pkgbuild",
"--root", c.BuildContext.Get<string>("SharedHostPublishRoot"),
"--identifier", id,
"--version", version,
"--install-location", installLocation,
"--scripts", scriptsLocation,
outFilePath)
.Execute()
.EnsureSuccessful();
return c.Success();
}
}
}