// 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.
usingSystem;
usingSystem.Collections.Generic;
usingMicrosoft.Build.Utilities;
usingMicrosoft.Build.Framework;
usingSystem.IO;
usingSystem.Linq;
usingSystem.Text;
usingNewtonsoft.Json;
namespaceMicrosoft.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>
publicclassBuildFPMToolPreReqs:Task
{
[Required]
publicstringInputDir{get;set;}
[Required]
publicstringOutputDir{get;set;}
[Required]
publicstringPackageVersion{get;set;}
[Required]
publicstringConfigJsonFile{get;set;}
[Output]
publicstringFPMParameters{get;set;}
publicoverrideboolExecute()
{
if(!File.Exists(ConfigJsonFile))
{
thrownewFileNotFoundException($"Expected file {ConfigJsonFile} was not found.");
}
// Open the Config Json and read the values into the model
// 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