Produce RPM packages
Reference from https://github.com/dotnet/core-setup/tree/master/src/pkg/packaging/rpm The goal is to have parity with Debian, but does not publish to the feed When run the script with rhel, it will produce rpm file in the package step and publish rpm to the blob storage
This commit is contained in:
parent
cda914a365
commit
3419a87d6f
14 changed files with 682 additions and 1 deletions
|
@ -68,6 +68,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "package", "package", "{FD7D
|
||||||
build\package\Installer.DEB.targets = build\package\Installer.DEB.targets
|
build\package\Installer.DEB.targets = build\package\Installer.DEB.targets
|
||||||
build\package\Installer.MSI.targets = build\package\Installer.MSI.targets
|
build\package\Installer.MSI.targets = build\package\Installer.MSI.targets
|
||||||
build\package\Installer.PKG.targets = build\package\Installer.PKG.targets
|
build\package\Installer.PKG.targets = build\package\Installer.PKG.targets
|
||||||
|
build\package\Installer.RPM.props = build\package\Installer.RPM.props
|
||||||
|
build\package\Installer.RPM.targets = build\package\Installer.RPM.targets
|
||||||
build\package\Layout.targets = build\package\Layout.targets
|
build\package\Layout.targets = build\package\Layout.targets
|
||||||
build\package\Nupkg.targets = build\package\Nupkg.targets
|
build\package\Nupkg.targets = build\package\Nupkg.targets
|
||||||
EndProjectSection
|
EndProjectSection
|
||||||
|
|
|
@ -1,16 +1,20 @@
|
||||||
<Project>
|
<Project>
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
|
|
||||||
|
<IsRPMBasedDistro Condition=" $(HostRid.StartsWith('rhel')) ">True</IsRPMBasedDistro>
|
||||||
|
|
||||||
<ArchiveExtension Condition=" '$(HostOSName)' == 'win' ">.zip</ArchiveExtension>
|
<ArchiveExtension Condition=" '$(HostOSName)' == 'win' ">.zip</ArchiveExtension>
|
||||||
<ArchiveExtension Condition=" '$(HostOSName)' != 'win' ">.tar.gz</ArchiveExtension>
|
<ArchiveExtension Condition=" '$(HostOSName)' != 'win' ">.tar.gz</ArchiveExtension>
|
||||||
|
|
||||||
<InstallerExtension Condition=" '$(HostOSName)' == 'win' ">.msi</InstallerExtension>
|
<InstallerExtension Condition=" '$(HostOSName)' == 'win' ">.msi</InstallerExtension>
|
||||||
<InstallerExtension Condition=" '$(HostOSName)' == 'osx' ">.pkg</InstallerExtension>
|
<InstallerExtension Condition=" '$(HostOSName)' == 'osx' ">.pkg</InstallerExtension>
|
||||||
<InstallerExtension Condition=" '$(HostOSName)' == 'ubuntu' OR '$(OSName)' == 'debian' ">.deb</InstallerExtension>
|
<InstallerExtension Condition=" '$(HostOSName)' == 'ubuntu' OR '$(OSName)' == 'debian' ">.deb</InstallerExtension>
|
||||||
|
<InstallerExtension Condition=" '$(IsRPMBasedDistro)' == True ">.rpm</InstallerExtension>
|
||||||
|
|
||||||
<BundleExtension Condition=" '$(HostOSName)' == 'win' ">.exe</BundleExtension>
|
<BundleExtension Condition=" '$(HostOSName)' == 'win' ">.exe</BundleExtension>
|
||||||
<BundleExtension Condition=" '$(HostOSName)' == 'osx' ">$(InstallerExtension)</BundleExtension>
|
<BundleExtension Condition=" '$(HostOSName)' == 'osx' ">$(InstallerExtension)</BundleExtension>
|
||||||
<BundleExtension Condition=" '$(HostOSName)' == 'ubuntu' OR '$(OSName)' == 'debian' ">$(InstallerExtension)</BundleExtension>
|
<BundleExtension Condition=" '$(HostOSName)' == 'ubuntu' OR '$(OSName)' == 'debian' ">$(InstallerExtension)</BundleExtension>
|
||||||
|
<BundleExtension Condition=" '$(IsRPMBasedDistro)' == True ">.rpm</BundleExtension>
|
||||||
|
|
||||||
<DynamicLibPrefix>lib</DynamicLibPrefix>
|
<DynamicLibPrefix>lib</DynamicLibPrefix>
|
||||||
<DynamicLibPrefix Condition=" '$(HostOSName)' == 'win' "></DynamicLibPrefix>
|
<DynamicLibPrefix Condition=" '$(HostOSName)' == 'win' "></DynamicLibPrefix>
|
||||||
|
|
|
@ -6,10 +6,11 @@
|
||||||
<Import Project="$(MSBuildThisFileDirectory)/package/Installer.DEB.proj" />
|
<Import Project="$(MSBuildThisFileDirectory)/package/Installer.DEB.proj" />
|
||||||
<Import Project="$(MSBuildThisFileDirectory)/package/Installer.MSI.targets" />
|
<Import Project="$(MSBuildThisFileDirectory)/package/Installer.MSI.targets" />
|
||||||
<Import Project="$(MSBuildThisFileDirectory)/package/Installer.PKG.targets" />
|
<Import Project="$(MSBuildThisFileDirectory)/package/Installer.PKG.targets" />
|
||||||
|
<Import Project="$(MSBuildThisFileDirectory)/package/Installer.RPM.targets" />
|
||||||
|
|
||||||
<Target Name="GenerateInstallers"
|
<Target Name="GenerateInstallers"
|
||||||
Condition=" '$(SkipBuildingInstallers)' != 'true' "
|
Condition=" '$(SkipBuildingInstallers)' != 'true' "
|
||||||
DependsOnTargets="Init;Layout;GeneratePkgs;GenerateDebs;GenerateMsis" />
|
DependsOnTargets="Init;Layout;GeneratePkgs;GenerateDebs;GenerateMsis;GenerateRpms" />
|
||||||
|
|
||||||
<Target Name="Package"
|
<Target Name="Package"
|
||||||
DependsOnTargets="BuildDotnetCliBuildFramework;
|
DependsOnTargets="BuildDotnetCliBuildFramework;
|
||||||
|
|
8
build/package/Installer.RPM.props
Normal file
8
build/package/Installer.RPM.props
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup>
|
||||||
|
<RpmConfigJsonName>rpm_config.json</RpmConfigJsonName>
|
||||||
|
<TemplatesDir>$(RepoRoot)/packaging/rpm/templates</TemplatesDir>
|
||||||
|
<ScriptsDir>$(RepoRoot)/packaging/rpm/scripts</ScriptsDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
</Project>
|
213
build/package/Installer.RPM.targets
Normal file
213
build/package/Installer.RPM.targets
Normal file
|
@ -0,0 +1,213 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<Import Project='Installer.RPM.props'/>
|
||||||
|
|
||||||
|
<UsingTask TaskName="ReplaceFileContents" AssemblyFile="$(CLIBuildDll)"/>
|
||||||
|
<UsingTask TaskName="BuildFPMToolPreReqs" AssemblyFile="$(CLIBuildDll)"/>
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<BuildRpmPackage Condition=" '$(IsRPMBasedDistro)' == 'True' ">True</BuildRpmPackage>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<Target Name="GenerateRpms"
|
||||||
|
DependsOnTargets="TestFPMTool;BuildRpms;TestSdkRpm"
|
||||||
|
Condition=" '$(BuildRpmPackage)' == 'True' "
|
||||||
|
Outputs="@(GeneratedInstallers)"/>
|
||||||
|
|
||||||
|
<Target Name="BuildRpms"
|
||||||
|
DependsOnTargets="GenerateSdkRpm"
|
||||||
|
Condition=" '$(BuildRpmPackage)' == 'True' and '$(FPMPresent)' == 'True' "/>
|
||||||
|
|
||||||
|
<Target Name="GenerateSdkRpm">
|
||||||
|
<PropertyGroup>
|
||||||
|
<RpmPackageVersion>$(SdkVersion)</RpmPackageVersion>
|
||||||
|
<InputRoot>$(OutputDirectory)/sdk</InputRoot>
|
||||||
|
<SdkInstallerFile>$(InstallerOutputDirectory)/$(DistroSpecificArtifactNameWithVersionCombinedHostHostFxrFrameworkSdk)$(InstallerExtension)</SdkInstallerFile>
|
||||||
|
<RpmFile>$(SdkInstallerFile)</RpmFile>
|
||||||
|
<ManPagesDir>$(RepoRoot)/Documentation/manpages</ManPagesDir>
|
||||||
|
<ConfigJsonFile>$(RepoRoot)/packaging/rpm/dotnet-config.json</ConfigJsonFile>
|
||||||
|
<RpmIntermediatesDir>$(IntermediateDirectory)/$(RpmPackageName)/$(RpmPackageVersion)</RpmIntermediatesDir>
|
||||||
|
<RpmTestResultsXmlFile>$(RpmIntermediatesDir)/debian-testResults.xml</RpmTestResultsXmlFile>
|
||||||
|
<RpmInstalledDirectory>/usr/share/dotnet</RpmInstalledDirectory>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<RpmLayoutDirectory>$(RpmIntermediatesDir)/RpmLayoutDirectory/</RpmLayoutDirectory>
|
||||||
|
<RpmLayoutPackageRoot>$(RpmLayoutDirectory)package_root</RpmLayoutPackageRoot>
|
||||||
|
<RpmLayoutSDK>$(RpmLayoutPackageRoot)/sdk</RpmLayoutSDK>
|
||||||
|
<RpmLayoutDocs>$(RpmLayoutDirectory)docs</RpmLayoutDocs> <!-- Man Pages -->
|
||||||
|
<RpmLayoutTemplates>$(RpmLayoutDirectory)templates</RpmLayoutTemplates> <!-- Copyright, Changelog -->
|
||||||
|
<RpmLayoutScripts>$(RpmLayoutDirectory)scripts</RpmLayoutScripts>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<SdkRpmPackageVersion>$(SdkVersion)</SdkRpmPackageVersion>
|
||||||
|
<SdkRpmPackageName>$(ArtifactNameCombinedHostHostFxrFrameworkSdk)-$(SdkRpmPackageVersion)</SdkRpmPackageName>
|
||||||
|
<SharedFxRpmPackageVersion>$(SharedFrameworkVersion)</SharedFxRpmPackageVersion>
|
||||||
|
<SharedFxRpmPackageName>dotnet-runtime-$(SharedFxRpmPackageVersion)</SharedFxRpmPackageName>
|
||||||
|
<SharedFxRpmPackageName>$(SharedFxRpmPackageName.ToLower())</SharedFxRpmPackageName>
|
||||||
|
<HostFxrRpmPackageVersion>$(HostFxrVersion)</HostFxrRpmPackageVersion>
|
||||||
|
<HostFxrRpmPackageName>dotnet-hostfxr-$(HostFxrRpmPackageVersion)</HostFxrRpmPackageName>
|
||||||
|
<HostFxrRpmPackageName>$(HostFxrRpmPackageName.ToLower())</HostFxrRpmPackageName>
|
||||||
|
<HostRpmPackageName>dotnet-host</HostRpmPackageName>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<EndToEndTestProject>$(RepoRoot)/test/EndToEnd/EndToEnd.csproj</EndToEndTestProject>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<RemoveDir Condition="Exists('$(RpmIntermediatesDir)')" Directories="$(RpmIntermediatesDir)"/>
|
||||||
|
<MakeDir Directories="$(RpmIntermediatesDir)"/>
|
||||||
|
|
||||||
|
<!-- Create empty rpm layout -->
|
||||||
|
<RemoveDir Condition="Exists('$(RpmLayoutDirectory)')" Directories="$(RpmLayoutDirectory)"/>
|
||||||
|
<MakeDir Directories="$(RpmLayoutDirectory)"/>
|
||||||
|
<MakeDir Directories="$(RpmLayoutPackageRoot)"/>
|
||||||
|
<MakeDir Directories="$(RpmLayoutSDK)"/>
|
||||||
|
<MakeDir Directories="$(RpmLayoutDocs)"/>
|
||||||
|
<MakeDir Directories="$(RpmLayoutTemplates)"/>
|
||||||
|
<MakeDir Directories="$(RpmLayoutScripts)"/>
|
||||||
|
|
||||||
|
<!-- Copy files to rpm layout -->
|
||||||
|
<ItemGroup>
|
||||||
|
<SDKFiles Include="$(InputRoot)/**/*"/>
|
||||||
|
<SDKManpages Include="$(ManPagesDir)/**/*"/>
|
||||||
|
<SDKTemplatesFiles Include="$(TemplatesDir)/**/*"/>
|
||||||
|
<SDKScriptsFiles Include="$(ScriptsDir)/**/*"/>
|
||||||
|
<AspNetRuntimeFilesInput Include="$(AspNetRuntimePackageStorePublishDirectory)/**/*" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<Copy SourceFiles="@(SDKFiles)"
|
||||||
|
DestinationFiles="@(SDKFiles->'$(RpmLayoutSDK)/%(RecursiveDir)%(Filename)%(Extension)')"
|
||||||
|
OverwriteReadOnlyFiles="True"
|
||||||
|
SkipUnchangedFiles="False"
|
||||||
|
UseHardlinksIfPossible="False"/>
|
||||||
|
|
||||||
|
<Copy SourceFiles="@(SDKManpages)"
|
||||||
|
DestinationFiles="@(SDKManpages->'$(RpmLayoutDocs)/%(RecursiveDir)%(Filename)%(Extension)')"
|
||||||
|
OverwriteReadOnlyFiles="True"
|
||||||
|
SkipUnchangedFiles="False"
|
||||||
|
UseHardlinksIfPossible="False"/>
|
||||||
|
|
||||||
|
<Copy SourceFiles="@(SDKTemplatesFiles)"
|
||||||
|
DestinationFiles="@(SDKTemplatesFiles->'$(RpmLayoutTemplates)/%(RecursiveDir)%(Filename)%(Extension)')"
|
||||||
|
OverwriteReadOnlyFiles="True"
|
||||||
|
SkipUnchangedFiles="False"
|
||||||
|
UseHardlinksIfPossible="False"/>
|
||||||
|
|
||||||
|
<Copy SourceFiles="@(SDKScriptsFiles)"
|
||||||
|
DestinationFiles="@(SDKScriptsFiles->'$(RpmLayoutScripts)/%(RecursiveDir)%(Filename)%(Extension)')"
|
||||||
|
OverwriteReadOnlyFiles="True"
|
||||||
|
SkipUnchangedFiles="False"
|
||||||
|
UseHardlinksIfPossible="False"/>
|
||||||
|
|
||||||
|
<Copy SourceFiles="@(AspNetRuntimeFilesInput)"
|
||||||
|
DestinationFiles="@(AspNetRuntimeFilesInput ->'$(RpmLayoutPackageRoot)/%(RecursiveDir)%(Filename)%(Extension)')"
|
||||||
|
OverwriteReadOnlyFiles="True"
|
||||||
|
SkipUnchangedFiles="False"
|
||||||
|
UseHardlinksIfPossible="False"/>
|
||||||
|
|
||||||
|
<!-- Replace config json variables -->
|
||||||
|
<ItemGroup>
|
||||||
|
<SDKTokenValue Include="%SHARED_HOST_RPM_VERSION%">
|
||||||
|
<ReplacementString>$(SharedFrameworkVersion)</ReplacementString>
|
||||||
|
</SDKTokenValue>
|
||||||
|
<SDKTokenValue Include="%SHARED_HOST_RPM_NAME%">
|
||||||
|
<ReplacementString>$(SharedFxRpmPackageName)</ReplacementString>
|
||||||
|
</SDKTokenValue>
|
||||||
|
<SDKTokenValue Include="%SDK_NUGET_VERSION%">
|
||||||
|
<ReplacementString>$(SdkVersion)</ReplacementString>
|
||||||
|
</SDKTokenValue>
|
||||||
|
<SDKTokenValue Include="%CLI_SDK_BRAND_NAME%">
|
||||||
|
<ReplacementString>$(SdkBrandName)</ReplacementString>
|
||||||
|
</SDKTokenValue>
|
||||||
|
<SDKTokenValue Include="%SDK_RPM_PACKAGE_NAME%">
|
||||||
|
<ReplacementString>$(SdkRpmPackageName)</ReplacementString>
|
||||||
|
</SDKTokenValue>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<TestSdkRpmTaskEnvironmentVariables Include="PATH=$(RpmInstalledDirectory)$(PathListSeparator)$(PATH)" />
|
||||||
|
<GeneratedInstallers Include="$(SdkInstallerFile)" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ReplaceFileContents InputFile="$(ConfigJsonFile)"
|
||||||
|
DestinationFile="$(RpmLayoutDirectory)$(RpmConfigJsonName)"
|
||||||
|
ReplacementItems="@(SDKTokenValue)"/>
|
||||||
|
|
||||||
|
<!-- Call the task to build the pre-reqs (parameters, copyright, changelog) for calling the FPM tool -->
|
||||||
|
<BuildFPMToolPreReqs InputDir="$(RpmLayoutDirectory)"
|
||||||
|
OutputDir="$(RpmIntermediatesDir)"
|
||||||
|
PackageVersion="$(RpmPackageVersion)"
|
||||||
|
ConfigJsonFile="$(RpmLayoutDirectory)$(RpmConfigJsonName)">
|
||||||
|
<Output TaskParameter="FPMParameters" PropertyName="FPMCmdParameters"/>
|
||||||
|
</BuildFPMToolPreReqs>
|
||||||
|
|
||||||
|
<!-- Build the RPM package by calling the FPM tool and passing the parameter list -->
|
||||||
|
<Exec Command="fpm $(FPMCmdParameters)" WorkingDirectory="$(RpmIntermediatesDir)"/>
|
||||||
|
|
||||||
|
<!-- Copy package to output -->
|
||||||
|
<ItemGroup>
|
||||||
|
<GeneratedRpmFiles Remove="@(GeneratedRpmFiles)"/>
|
||||||
|
<GeneratedRpmFiles Include="$(RpmIntermediatesDir)/*.rpm"/>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<Error Text="@(GeneratedRpmFiles->Count()) .rpm files generated." Condition="'@(GeneratedRpmFiles->Count())' != 1"/>
|
||||||
|
|
||||||
|
<Copy SourceFiles="@(GeneratedRpmFiles)"
|
||||||
|
DestinationFiles="$(RpmFile)"
|
||||||
|
OverwriteReadOnlyFiles="True"
|
||||||
|
SkipUnchangedFiles="False"
|
||||||
|
UseHardlinksIfPossible="False"/>
|
||||||
|
|
||||||
|
</Target>
|
||||||
|
|
||||||
|
<Target Name="TestFPMTool">
|
||||||
|
|
||||||
|
<!-- run FPM -->
|
||||||
|
<Exec Command="fpm --help > /dev/null" ContinueOnError="True">
|
||||||
|
<Output TaskParameter="ExitCode" PropertyName="FPMExitCode"/>
|
||||||
|
</Exec>
|
||||||
|
|
||||||
|
<!-- Check if it returned 0 -->
|
||||||
|
<PropertyGroup>
|
||||||
|
<FPMPresent>false</FPMPresent>
|
||||||
|
<FPMPresent Condition=" '$(FPMExitCode)' == '0' ">True</FPMPresent>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<!-- Workaround for Jenkins machines that don't have the necessary packages https://github.com/dotnet/core-setup/issues/2260 -->
|
||||||
|
<Message Condition=" '$(FPMPresent)' != 'True' "
|
||||||
|
Text="FPM tool Not found, RPM packages will not be built."
|
||||||
|
Importance="High"/>
|
||||||
|
</Target>
|
||||||
|
|
||||||
|
<Target Name="TestSdkRpm"
|
||||||
|
Condition=" '$(IsRPMBasedDistro)' == 'True' and '$(FPMPresent)' == 'True' "
|
||||||
|
Inputs="$(DownloadedSharedHostInstallerFile);
|
||||||
|
$(DownloadedHostFxrInstallerFile);
|
||||||
|
$(DownloadedSharedFrameworkInstallerFile);
|
||||||
|
$(RpmTestResultsXmlFile);"
|
||||||
|
Outputs="$(RpmTestResultsXmlFile)" >
|
||||||
|
|
||||||
|
<!-- Install Dependencies and SDK Packages -->
|
||||||
|
<Exec Command="sudo yum -y install $(DownloadedSharedHostInstallerFile)" />
|
||||||
|
<Exec Command="sudo yum -y install $(DownloadedHostFxrInstallerFile)" />
|
||||||
|
<Exec Command="sudo yum -y install $(DownloadedSharedFrameworkInstallerFile)" />
|
||||||
|
|
||||||
|
<Exec Command="sudo yum -y install $(SdkInstallerFile)" />
|
||||||
|
|
||||||
|
<!-- Run Tests -->
|
||||||
|
<DotNetRestore ProjectPath="$(EndToEndTestProject)"
|
||||||
|
ToolPath="$(RpmInstalledDirectory)" />
|
||||||
|
|
||||||
|
<DotNetTest ProjectPath="$(EndToEndTestProject)"
|
||||||
|
EnvironmentVariables="@(TestSdkDebTaskEnvironmentVariables)"
|
||||||
|
ToolPath="$(RpmInstalledDirectory)" />
|
||||||
|
|
||||||
|
<!-- Clean up Packages -->
|
||||||
|
<Exec Command="sudo yum remove -y $(SdkRpmPackageName)" />
|
||||||
|
<Exec Command="sudo yum remove -y $(SharedFxRpmPackageName)" />
|
||||||
|
<Exec Command="sudo yum remove -y $(HostFxrRpmPackageName)" />
|
||||||
|
<Exec Command="sudo yum remove -y $(HostRpmPackageName)" />
|
||||||
|
</Target>
|
||||||
|
</Project>
|
309
build_projects/dotnet-cli-build/BuildFPMToolPreReqs.cs
Normal file
309
build_projects/dotnet-cli-build/BuildFPMToolPreReqs.cs
Normal file
|
@ -0,0 +1,309 @@
|
||||||
|
// 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.
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using Microsoft.Build.Utilities;
|
||||||
|
using Microsoft.Build.Framework;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace Microsoft.DotNet.Build.Tasks
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// This task prepares the command line parameters for running a RPM build using FPM tool and also updates the copyright and changelog file tokens.
|
||||||
|
/// If parses various values from the config json by first reading it into a model and then builds the required string for parameters and passes it back.
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public class BuildFPMToolPreReqs : Task
|
||||||
|
{
|
||||||
|
[Required]
|
||||||
|
public string InputDir { get; set; }
|
||||||
|
|
||||||
|
[Required]
|
||||||
|
public string OutputDir { get; set; }
|
||||||
|
|
||||||
|
[Required]
|
||||||
|
public string PackageVersion { get; set; }
|
||||||
|
|
||||||
|
[Required]
|
||||||
|
public string ConfigJsonFile { get; set; }
|
||||||
|
|
||||||
|
[Output]
|
||||||
|
public string FPMParameters { get; set; }
|
||||||
|
|
||||||
|
public override bool Execute()
|
||||||
|
{
|
||||||
|
if (!File.Exists(ConfigJsonFile))
|
||||||
|
{
|
||||||
|
throw new FileNotFoundException($"Expected file {ConfigJsonFile} was not found.");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Open the Config Json and read the values into the model
|
||||||
|
TextReader projectFileReader = File.OpenText(ConfigJsonFile);
|
||||||
|
string jsonFileText = projectFileReader.ReadToEnd();
|
||||||
|
ConfigJson configJson = JsonConvert.DeserializeObject<ConfigJson>(jsonFileText);
|
||||||
|
|
||||||
|
// Update the Changelog and Copyright files by replacing tokens with values from config json
|
||||||
|
UpdateChangelog(configJson, PackageVersion);
|
||||||
|
UpdateCopyright(configJson);
|
||||||
|
|
||||||
|
// Build the full list of parameters
|
||||||
|
FPMParameters = BuildCmdParameters(configJson, PackageVersion);
|
||||||
|
Log.LogMessage(MessageImportance.Normal, "Generated RPM paramters: " + FPMParameters);
|
||||||
|
|
||||||
|
return !Log.HasLoggedErrors;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update the tokens in the changelog file from the config Json
|
||||||
|
private void UpdateChangelog(ConfigJson configJson, string package_version)
|
||||||
|
{
|
||||||
|
string changelogFile = Path.Combine(InputDir, "templates", "changelog");
|
||||||
|
if (!File.Exists(changelogFile))
|
||||||
|
{
|
||||||
|
throw new FileNotFoundException($"Expected file {changelogFile} was not found.");
|
||||||
|
}
|
||||||
|
string str = File.ReadAllText(changelogFile);
|
||||||
|
str = str.Replace("{PACKAGE_NAME}", configJson.Package_Name);
|
||||||
|
str = str.Replace("{PACKAGE_VERSION}", package_version);
|
||||||
|
str = str.Replace("{PACKAGE_REVISION}", configJson.Release.Package_Revision);
|
||||||
|
str = str.Replace("{CHANGELOG_MESSAGE}", configJson.Release.Changelog_Message);
|
||||||
|
str = str.Replace("{MAINTAINER_NAME}", configJson.Maintainer_Name);
|
||||||
|
str = str.Replace("{MAINTAINER_EMAIL}", configJson.Maintainer_Email);
|
||||||
|
// The date format needs to be like Wed May 17 2017
|
||||||
|
str = str.Replace("{DATE}", DateTime.UtcNow.ToString("ddd MMM dd yyyy"));
|
||||||
|
File.WriteAllText(changelogFile, str);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void UpdateCopyright(ConfigJson configJson)
|
||||||
|
{
|
||||||
|
string copyrightFile = Path.Combine(InputDir, "templates", "copyright");
|
||||||
|
if (!File.Exists(copyrightFile))
|
||||||
|
{
|
||||||
|
throw new FileNotFoundException($"Expected file {copyrightFile} was not found.");
|
||||||
|
}
|
||||||
|
string str = File.ReadAllText(copyrightFile);
|
||||||
|
str = str.Replace("{COPYRIGHT_TEXT}", configJson.CopyRight);
|
||||||
|
str = str.Replace("{LICENSE_NAME}", configJson.License.Type);
|
||||||
|
str = str.Replace("{LICENSE_TEXT}", configJson.License.Full_Text);
|
||||||
|
File.WriteAllText(copyrightFile, str);
|
||||||
|
}
|
||||||
|
|
||||||
|
private string BuildCmdParameters(ConfigJson configJson, string package_version)
|
||||||
|
{
|
||||||
|
// Parameter list that needs to be passed to FPM tool:
|
||||||
|
// -s : is the input source type(dir) --Static
|
||||||
|
// -t : is the type of package(rpm) --Static
|
||||||
|
// -n : is for the name of the package --JSON
|
||||||
|
// -v : is the version to give to the package --ARG
|
||||||
|
// -a : architecture --JSON
|
||||||
|
// -d : is for all dependent packages. This can be used multiple times to specify the dependencies of the package. --JSON
|
||||||
|
// --rpm-os : the operating system to target this rpm --Static
|
||||||
|
// --rpm-changelog : the changelog from FILEPATH contents --ARG
|
||||||
|
// --rpm-summary : it is the RPM summary that shows in the Title --JSON
|
||||||
|
// --description : it is the description for the package --JSON
|
||||||
|
// -p : The actual package name (with path) for your package. --ARG+JSON
|
||||||
|
// --conflicts : Other packages/versions this package conflicts with provided as CSV --JSON
|
||||||
|
// --directories : Recursively add directories as being owned by the package. --JSON
|
||||||
|
// --after-install : FILEPATH to the script to be run after install of the package --JSON
|
||||||
|
// --after-remove : FILEPATH to the script to be run after package removal --JSON
|
||||||
|
// --license : the licensing name for the package. This will include the license type in the meta-data for the package, but will not include the associated license file within the package itself. --JSON
|
||||||
|
// --iteration : the iteration to give to the package. This comes from the package_revision --JSON
|
||||||
|
// --url : url for this package. --JSON
|
||||||
|
// --verbose : Set verbose output for FPM tool --Static
|
||||||
|
// <All folder mappings> : Add all the folder mappings for packge_root, docs, man pages --Static
|
||||||
|
|
||||||
|
var parameters = new List<string>();
|
||||||
|
parameters.Add("-s dir");
|
||||||
|
parameters.Add("-t rpm");
|
||||||
|
parameters.Add(string.Concat("-n ", configJson.Package_Name));
|
||||||
|
parameters.Add(string.Concat("-v ", package_version));
|
||||||
|
parameters.Add(string.Concat("-a ", configJson.Control.Architecture));
|
||||||
|
|
||||||
|
// Build the list of dependencies as -d <dep1> -d <dep2>
|
||||||
|
if (configJson.Rpm_Dependencies != null)
|
||||||
|
{
|
||||||
|
foreach (RpmDependency rpmdep in configJson.Rpm_Dependencies)
|
||||||
|
{
|
||||||
|
string dependency = "";
|
||||||
|
if (rpmdep.Package_Name != "")
|
||||||
|
{
|
||||||
|
// If no version is specified then the dependency is just the package without >= check
|
||||||
|
if (rpmdep.Package_Version == "")
|
||||||
|
{
|
||||||
|
dependency = rpmdep.Package_Name;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dependency = string.Concat(rpmdep.Package_Name, " >= ", rpmdep.Package_Version);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (dependency != "") parameters.Add(string.Concat("-d ", EscapeArg(dependency)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Build the list of owned directories
|
||||||
|
if (configJson.Directories != null)
|
||||||
|
{
|
||||||
|
foreach (string dir in configJson.Directories)
|
||||||
|
{
|
||||||
|
if (dir != "")
|
||||||
|
{
|
||||||
|
parameters.Add(string.Concat("--directories ", EscapeArg(dir)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
parameters.Add("--rpm-os linux");
|
||||||
|
parameters.Add(string.Concat("--rpm-changelog ",
|
||||||
|
EscapeArg(Path.Combine(InputDir, "templates", "changelog")))); // Changelog File
|
||||||
|
parameters.Add(string.Concat("--rpm-summary ", EscapeArg(configJson.Short_Description)));
|
||||||
|
parameters.Add(string.Concat("--description ", EscapeArg(configJson.Long_Description)));
|
||||||
|
parameters.Add(string.Concat("--maintainer ",
|
||||||
|
EscapeArg(configJson.Maintainer_Name + " <" + configJson.Maintainer_Email + ">")));
|
||||||
|
parameters.Add(string.Concat("--vendor ", EscapeArg(configJson.Vendor)));
|
||||||
|
parameters.Add(string.Concat("-p ", Path.Combine(OutputDir, configJson.Package_Name + ".rpm")));
|
||||||
|
if (configJson.Package_Conflicts != null)
|
||||||
|
parameters.Add(string.Concat("--conflicts ",
|
||||||
|
EscapeArg(string.Join(",", configJson.Package_Conflicts))));
|
||||||
|
if (configJson.After_Install_Source != null)
|
||||||
|
parameters.Add(string.Concat("--after-install ",
|
||||||
|
Path.Combine(InputDir, EscapeArg(configJson.After_Install_Source))));
|
||||||
|
if (configJson.After_Remove_Source != null)
|
||||||
|
parameters.Add(string.Concat("--after-remove ",
|
||||||
|
Path.Combine(InputDir, EscapeArg(configJson.After_Remove_Source))));
|
||||||
|
parameters.Add(string.Concat("--license ", EscapeArg(configJson.License.Type)));
|
||||||
|
parameters.Add(string.Concat("--iteration ", configJson.Release.Package_Revision));
|
||||||
|
parameters.Add(string.Concat("--url ", "\"", EscapeArg(configJson.Homepage), "\""));
|
||||||
|
parameters.Add("--verbose");
|
||||||
|
|
||||||
|
// Map all the payload directories as they need to install on the system
|
||||||
|
if (configJson.Install_Root != null)
|
||||||
|
parameters.Add(string.Concat(Path.Combine(InputDir, "package_root/="),
|
||||||
|
configJson.Install_Root)); // Package Files
|
||||||
|
if (configJson.Install_Man != null)
|
||||||
|
parameters.Add(string.Concat(Path.Combine(InputDir, "docs", "host/="),
|
||||||
|
configJson.Install_Man)); // Man Pages
|
||||||
|
if (configJson.Install_Doc != null)
|
||||||
|
parameters.Add(string.Concat(Path.Combine(InputDir, "templates", "copyright="),
|
||||||
|
configJson.Install_Doc)); // CopyRight File
|
||||||
|
|
||||||
|
return string.Join(" ", parameters);
|
||||||
|
}
|
||||||
|
|
||||||
|
private string EscapeArg(string arg)
|
||||||
|
{
|
||||||
|
var sb = new StringBuilder();
|
||||||
|
|
||||||
|
bool quoted = ShouldSurroundWithQuotes(arg);
|
||||||
|
if (quoted) sb.Append("\"");
|
||||||
|
|
||||||
|
for (int i = 0; i < arg.Length; ++i)
|
||||||
|
{
|
||||||
|
var backslashCount = 0;
|
||||||
|
|
||||||
|
// Consume All Backslashes
|
||||||
|
while (i < arg.Length && arg[i] == '\\')
|
||||||
|
{
|
||||||
|
backslashCount++;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Escape any backslashes at the end of the arg
|
||||||
|
// This ensures the outside quote is interpreted as
|
||||||
|
// an argument delimiter
|
||||||
|
if (i == arg.Length)
|
||||||
|
{
|
||||||
|
sb.Append('\\', 2 * backslashCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Escape any preceding backslashes and the quote
|
||||||
|
else if (arg[i] == '"')
|
||||||
|
{
|
||||||
|
sb.Append('\\', (2 * backslashCount) + 1);
|
||||||
|
sb.Append('"');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Output any consumed backslashes and the character
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sb.Append('\\', backslashCount);
|
||||||
|
sb.Append(arg[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (quoted) sb.Append("\"");
|
||||||
|
|
||||||
|
return sb.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool ShouldSurroundWithQuotes(string argument)
|
||||||
|
{
|
||||||
|
// Don't quote already quoted strings
|
||||||
|
if (argument.StartsWith("\"", StringComparison.Ordinal) &&
|
||||||
|
argument.EndsWith("\"", StringComparison.Ordinal))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Only quote if whitespace exists in the string
|
||||||
|
if (argument.Contains(" ") || argument.Contains("\t") || argument.Contains("\n"))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Model classes for reading and storing the JSON.
|
||||||
|
/// </summary>
|
||||||
|
public class ConfigJson
|
||||||
|
{
|
||||||
|
public string Maintainer_Name { get; set; }
|
||||||
|
public string Maintainer_Email { get; set; }
|
||||||
|
public string Vendor { get; set; }
|
||||||
|
public string Package_Name { get; set; }
|
||||||
|
public string Install_Root { get; set; }
|
||||||
|
public string Install_Doc { get; set; }
|
||||||
|
public string Install_Man { get; set; }
|
||||||
|
public string Short_Description { get; set; }
|
||||||
|
public string Long_Description { get; set; }
|
||||||
|
public string Homepage { get; set; }
|
||||||
|
public string CopyRight { get; set; }
|
||||||
|
public Release Release { get; set; }
|
||||||
|
public Control Control { get; set; }
|
||||||
|
public License License { get; set; }
|
||||||
|
public List<RpmDependency> Rpm_Dependencies { get; set; }
|
||||||
|
public List<string> Package_Conflicts { get; set; }
|
||||||
|
public List<string> Directories { get; set; }
|
||||||
|
public string After_Install_Source { get; set; }
|
||||||
|
public string After_Remove_Source { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Release
|
||||||
|
{
|
||||||
|
public string Package_Version { get; set; }
|
||||||
|
public string Package_Revision { get; set; }
|
||||||
|
public string Changelog_Message { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Control
|
||||||
|
{
|
||||||
|
public string Architecture { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class License
|
||||||
|
{
|
||||||
|
public string Type { get; set; }
|
||||||
|
public string Full_Text { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class RpmDependency
|
||||||
|
{
|
||||||
|
public string Package_Name { get; set; }
|
||||||
|
public string Package_Version { get; set; }
|
||||||
|
}
|
||||||
|
}
|
38
packaging/rpm/dotnet-config.json
Normal file
38
packaging/rpm/dotnet-config.json
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
{
|
||||||
|
"maintainer_name": "Microsoft",
|
||||||
|
"maintainer_email": "dotnetcore@microsoft.com",
|
||||||
|
"vendor": ".NET Foundation",
|
||||||
|
"package_name": "%SDK_RPM_PACKAGE_NAME%",
|
||||||
|
"install_root": "/usr/share/dotnet",
|
||||||
|
"install_doc": "/usr/share/doc/%SDK_RPM_PACKAGE_NAME%/",
|
||||||
|
"short_description": "%CLI_SDK_BRAND_NAME% %SDK_NUGET_VERSION%",
|
||||||
|
"long_description": ".NET Core is a development platform that you can use to build command-line applications, microservices and modern websites. 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/dotnet/core). We happily accept issues and PRs.",
|
||||||
|
"homepage": "https://github.com/dotnet/core",
|
||||||
|
"release": {
|
||||||
|
"package_version": "1.0.0.0",
|
||||||
|
"package_revision": "1",
|
||||||
|
"changelog_message": "Bootstrap loop package"
|
||||||
|
},
|
||||||
|
"control": {
|
||||||
|
"architecture": "amd64"
|
||||||
|
},
|
||||||
|
"copyright": "2015 Microsoft",
|
||||||
|
"license": {
|
||||||
|
"type": "MIT",
|
||||||
|
"full_text": "Copyright (c) 2015 Microsoft\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE."
|
||||||
|
},
|
||||||
|
"rpm_dependencies": [
|
||||||
|
{
|
||||||
|
"package_name": "%SHARED_HOST_RPM_NAME%",
|
||||||
|
"package_version": "%SHARED_HOST_RPM_VERSION%"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"directories": [
|
||||||
|
"/usr/share/dotnet/sdk",
|
||||||
|
"/usr/share/dotnet/store",
|
||||||
|
"/usr/share/dotnet/additionalDeps",
|
||||||
|
"/usr/share/doc/%SDK_RPM_PACKAGE_NAME%"
|
||||||
|
],
|
||||||
|
"after_install_source": "scripts/after_install_host.sh",
|
||||||
|
"after_remove_source": "scripts/after_remove_host.sh"
|
||||||
|
}
|
22
packaging/rpm/scripts/after_install_host.sh
Normal file
22
packaging/rpm/scripts/after_install_host.sh
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
#!/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.
|
||||||
|
#
|
||||||
|
echo "This software may collect information about you and your use of the software, and send that to Microsoft."
|
||||||
|
echo "Please visit http://aka.ms/dotnet-cli-eula for more information."
|
||||||
|
|
||||||
|
# Run 'dotnet new' as the user to trigger the first time experience to initialize the cache
|
||||||
|
echo "Welcome to .NET Core!
|
||||||
|
---------------------
|
||||||
|
Learn more about .NET Core @ https://aka.ms/dotnet-docs. Use dotnet --help to see available commands or go to https://aka.ms/dotnet-cli-docs.
|
||||||
|
|
||||||
|
.NET Core Tools Telemetry
|
||||||
|
--------------
|
||||||
|
The .NET Core Tools include a telemetry feature that collects usage information. It is important that the .NET Team understands how the tools are being used so that we can improve them.
|
||||||
|
|
||||||
|
The data collected is anonymous and will be published in an aggregated form for use by both Microsoft and community engineers under the Creative Commons Attribution License.
|
||||||
|
|
||||||
|
The .NET Core Tools telemetry feature is enabled by default. You can opt-out of the telemetry feature by setting an environment variable DOTNET_CLI_TELEMETRY_OPTOUT (for example, 'export' on macOS/Linux, 'set' on Windows) to true (for example, 'true', 1). You can read more about .NET Core tools telemetry at https://aka.ms/dotnet-cli-telemetry."
|
||||||
|
|
||||||
|
su - $SUDO_USER -c "dotnet new > /dev/null 2>&1 || true"
|
5
packaging/rpm/scripts/after_remove_host.sh
Normal file
5
packaging/rpm/scripts/after_remove_host.sh
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
#!/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.
|
||||||
|
#
|
2
packaging/rpm/templates/changelog
Normal file
2
packaging/rpm/templates/changelog
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
* {DATE} {MAINTAINER_NAME} <{MAINTAINER_EMAIL}> - {PACKAGE_VERSION}-{PACKAGE_REVISION}
|
||||||
|
- {CHANGELOG_MESSAGE}
|
8
packaging/rpm/templates/copyright
Normal file
8
packaging/rpm/templates/copyright
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
Comment: 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.
|
||||||
|
|
||||||
|
Files: *
|
||||||
|
Copyright: {COPYRIGHT_TEXT}
|
||||||
|
License: {LICENSE_NAME}
|
||||||
|
|
||||||
|
License: {LICENSE_NAME}
|
||||||
|
{LICENSE_TEXT}
|
27
scripts/docker/rhel/Dockerfile
Normal file
27
scripts/docker/rhel/Dockerfile
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
#
|
||||||
|
# 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.
|
||||||
|
#
|
||||||
|
|
||||||
|
# Dockerfile that creates a container suitable to build dotnet-cli
|
||||||
|
FROM microsoft/dotnet-buildtools-prereqs:rhel-7-rpmpkg-c982313-20174116044113
|
||||||
|
|
||||||
|
# Install from sudo main package TODO This package needs to be mirrored
|
||||||
|
RUN yum install -y https://www.sudo.ws/sudo/dist/packages/RHEL/7/sudo-1.8.20-3.el7.x86_64.rpm \
|
||||||
|
&& yum clean all
|
||||||
|
|
||||||
|
# Setup User to match Host User, and give superuser permissions
|
||||||
|
ARG USER_ID=0
|
||||||
|
RUN useradd -m code_executor -u ${USER_ID} -g root
|
||||||
|
RUN echo 'code_executor ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
|
||||||
|
|
||||||
|
# With the User Change, we need to change permssions on these directories
|
||||||
|
RUN chmod -R a+rwx /usr/local
|
||||||
|
RUN chmod -R a+rwx /home
|
||||||
|
RUN chown root:root /usr/bin/sudo && chmod 4755 /usr/bin/sudo
|
||||||
|
|
||||||
|
# Set user to the one we just created
|
||||||
|
USER ${USER_ID}
|
||||||
|
|
||||||
|
# Set working directory
|
||||||
|
WORKDIR /opt/code
|
|
@ -67,6 +67,9 @@ if [ -z "$DOCKERFILE" ]; then
|
||||||
elif [ "$(cat /etc/*-release | grep -cim1 centos)" -eq 1 ]; then
|
elif [ "$(cat /etc/*-release | grep -cim1 centos)" -eq 1 ]; then
|
||||||
echo "Detected current OS as CentOS, using 'centos' image"
|
echo "Detected current OS as CentOS, using 'centos' image"
|
||||||
export DOCKERFILE=scripts/docker/centos
|
export DOCKERFILE=scripts/docker/centos
|
||||||
|
elif [ "$(cat /etc/*-release | grep -cim1 rhel)" -eq 1 ]; then
|
||||||
|
echo "Detected current OS as rhel, using 'rhel' image"
|
||||||
|
export DOCKERFILE=scripts/docker/rhel
|
||||||
elif [ "$(cat /etc/*-release | grep -cim1 debian)" -eq 1 ]; then
|
elif [ "$(cat /etc/*-release | grep -cim1 debian)" -eq 1 ]; then
|
||||||
echo "Detected current OS as Debian, using 'debian' image"
|
echo "Detected current OS as Debian, using 'debian' image"
|
||||||
export DOCKERFILE=scripts/docker/debian
|
export DOCKERFILE=scripts/docker/debian
|
||||||
|
|
39
scripts/obtain/uninstall/dotnet-uninstall-rpm-packages.sh
Executable file
39
scripts/obtain/uninstall/dotnet-uninstall-rpm-packages.sh
Executable file
|
@ -0,0 +1,39 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
# 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.
|
||||||
|
#
|
||||||
|
|
||||||
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
|
|
||||||
|
current_userid=$(id -u)
|
||||||
|
if [ $current_userid -ne 0 ]; then
|
||||||
|
echo "$(basename "$0") uninstallation script requires superuser privileges to run"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
host_package_name="dotnet-host"
|
||||||
|
|
||||||
|
remove_all(){
|
||||||
|
yum remove -y $host_package_name
|
||||||
|
}
|
||||||
|
|
||||||
|
is_dotnet_host_installed(){
|
||||||
|
local out="$(yum list installed | grep $host_package_name)"
|
||||||
|
[ -z "$out" ]
|
||||||
|
}
|
||||||
|
|
||||||
|
is_dotnet_host_installed
|
||||||
|
[ "$?" -eq 0 ] && echo "Unable to find dotnet installation to remove." >&2 \
|
||||||
|
&& exit 0
|
||||||
|
|
||||||
|
remove_all
|
||||||
|
[ "$?" -ne 0 ] && echo "Failed to remove dotnet packages." >&2 && exit 1
|
||||||
|
|
||||||
|
is_dotnet_host_installed
|
||||||
|
[ "$?" -ne 0 ] && \
|
||||||
|
echo "dotnet package removal succeeded but appear to still be installed. Please file an issue at https://github.com/dotnet/cli" >&2 && \
|
||||||
|
exit 1
|
||||||
|
|
||||||
|
echo "dotnet package removal succeeded." >&2
|
||||||
|
exit 0
|
Loading…
Add table
Reference in a new issue