Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Debian packaging #1863

Merged
merged 6 commits into from
Jul 1, 2018
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
5 changes: 4 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@ env:
- HOME=/home/travis APPDATA=/home/travis LocalAppData=/home/travis


before install:
before_install:
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update ; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install openssl ; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew link --force openssl ; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install gnu-tar ; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt update; sudo apt install ruby ruby-dev rubygems-integration build-essential -y ; fi
- gem install --no-ri --no-rdoc fpm

mono:
- 5.0.1
Expand Down
98 changes: 29 additions & 69 deletions build.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -914,7 +914,7 @@ Target.create "CreateNuGet" (fun _ ->
)

let runtimes =
[ "win7-x86"; "win7-x64"; "osx.10.11-x64"; "ubuntu.14.04-x64"; "ubuntu.16.04-x64" ]
[ "win7-x86"; "win7-x64"; "osx.10.11-x64"; "linux-x64" ]

module CircleCi =
let isCircleCi = Environment.environVarAsBool "CIRCLECI"
Expand Down Expand Up @@ -1089,76 +1089,34 @@ Target.create "CheckReleaseSecrets" (fun _ ->
secret.Force() |> ignore
)

let executeFPM args =
printfn "%s %s" "fpm" args
Shell.Exec("fpm", args=args, dir="bin")


type SourceType =
| Dir of source:string * target:string
type DebPackageManifest =
{
SourceType : SourceType
Name : string
Version : string
Dependencies : (string * string option) list
BeforeInstall : string option
AfterInstall : string option
ConfigFile : string option
AdditionalOptions: string list
AdditionalArgs : string list
}
(*
See https://www.debian.org/doc/debian-policy/ch-maintainerscripts.html
Ask @theangrybyrd (slack)

{
SourceType = Dir("./MyCoolApp", "/opt/")
Name = "mycoolapp"
Version = originalVersion
Dependencies = [("mono-devel", None)]
BeforeInstall = "../deploy/preinst" |> Some
AfterInstall = "../deploy/postinst" |> Some
ConfigFile = "/etc/mycoolapp/default.conf" |> Some
AdditionalOptions = []
AdditionalArgs =
[ "../deplo/mycoolapp.service=/lib/systemd/system/" ]
}
23:08
so thats stuff i you want to setup like users or what not
23:09
adding to your path would be in the after script postinst
23:10
setting permissions also, its just a shell script
23:10
might also want a prerm and postrm if you want to play nice on cleanup
*)

Target.create "DotNetCoreCreateDebianPackage" (fun _ ->
let createDebianPackage (manifest : DebPackageManifest) =
let argsList = ResizeArray<string>()
argsList.Add <| match manifest.SourceType with
| Dir (_) -> "-s dir"
argsList.Add <| "-t deb"
argsList.Add <| "-f"
argsList.Add <| (sprintf "-n %s" manifest.Name)
argsList.Add <| (sprintf "-v %s" (manifest.Version.Replace("-","~")))
let dependency name version =
match version with
| Some v -> sprintf "-d '%s %s'" name v
| None -> sprintf "-d '%s'" name
argsList.AddRange <| (Seq.map(fun (a,b) -> dependency a b) manifest.Dependencies)
manifest.BeforeInstall |> Option.iter(sprintf "--before-install %s" >> argsList.Add)
manifest.AfterInstall |> Option.iter(sprintf "--after-install %s" >> argsList.Add)
manifest.ConfigFile |> Option.iter(sprintf "--config-files %s" >> argsList.Add)
argsList.AddRange <| manifest.AdditionalOptions
argsList.Add <| match manifest.SourceType with
| Dir (source,target) -> sprintf "%s=%s" source target
argsList.AddRange <| manifest.AdditionalArgs
if argsList |> String.concat " " |> executeFPM <> 0 then
failwith "Failed creating deb package"
ignore createDebianPackage
()
DotNet.restore (fun opt ->
{ opt with
Common = { opt.Common with WorkingDirectory = "src/app/Fake.netcore/" } |> dtntSmpl
Runtime = Some "linux-x64"}) "Fake.netcore.fsproj"

let runtime = "linux-x64"
let targetFramework = "netcoreapp2.1"
let args =
[
sprintf "/t:%s" "CreateDeb"
sprintf "/p:TargetFramework=%s" targetFramework
sprintf "/p:RuntimeIdentifier=%s" runtime
sprintf "/p:Configuration=%s" "Release"
sprintf "/p:PackageVersion=%s" release.NugetVersion
] |> String.concat " "
let result =
DotNet.exec (fun opt ->
{ opt with
WorkingDirectory = "src/app/Fake.netcore/" } |> dtntSmpl
) "msbuild" args
if result.OK |> not then
failwith "Debian package creation failed"

if fromArtifacts then
[(sprintf "src/app/Fake.netcore/bin/Release/%s/%s/fake.%s.%s.deb" targetFramework runtime release.NugetVersion runtime)]
|> Shell.copy artifactsDir

)

Expand Down Expand Up @@ -1487,6 +1445,8 @@ let prevDocs =
==> "CreateNuGet"
==> "CopyLicense"
=?> ("DotNetCoreCreateChocolateyPackage", Environment.isWindows)
==> "DotNetCoreCreateDebianPackage"
=?> ("GenerateDocs", BuildServer.isLocalBuild && Environment.isWindows)
==> "Default"
(if fromArtifacts then "PrepareArtifacts" else "_AfterBuild")
=?> ("GenerateDocs", not <| Environment.hasEnvironVar "SkipDocs")
Expand Down
6 changes: 3 additions & 3 deletions fake.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/usr/bin/env bash

# Install .NET Core (https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-install-script)
curl -sSL https://dot.net/v1/dotnet-install.sh | bash /dev/stdin --channel Current
# curl -sSL https://dot.net/v1/dotnet-install.sh | bash /dev/stdin --channel Current

PATH="~/.dotnet:$PATH"
# PATH="~/.dotnet:$PATH"
dotnet restore build.proj
dotnet fake $@
dotnet fake $@
4 changes: 4 additions & 0 deletions packaging/debian/postinst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh

chmod +x /opt/fake/fake-cli
ln -s /opt/fake/fake-cli /usr/local/bin/fake-cli
1 change: 1 addition & 0 deletions packaging/debian/postrm
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#!/bin/sh
1 change: 1 addition & 0 deletions packaging/debian/preinst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#!/bin/sh
1 change: 1 addition & 0 deletions packaging/debian/prerm
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#!/bin/sh
3 changes: 2 additions & 1 deletion paket.dependencies
Original file line number Diff line number Diff line change
Expand Up @@ -169,4 +169,5 @@ group netcore
nuget System.IO.Compression.ZipFile
nuget System.Runtime.Loader
nuget System.IO.FileSystem.Watcher

nuget Packaging.Targets

Loading