From c4efba28515fdf0da16697256ba46c6bfff9086c Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Wed, 10 Feb 2021 20:07:24 +0100 Subject: Make the package script "complex" Signed-off-by: Matthias Beyer --- examples/packages/README.md | 13 +++++++++++++ examples/packages/repo/config.toml | 6 +++++- examples/packages/repo/pkg.toml | 27 ++++++++++++++++++++++++--- 3 files changed, 42 insertions(+), 4 deletions(-) (limited to 'examples') diff --git a/examples/packages/README.md b/examples/packages/README.md index 5271689..838dc53 100644 --- a/examples/packages/README.md +++ b/examples/packages/README.md @@ -67,3 +67,16 @@ N, M, T and S starting right away. Multiple versions of one package are not yet considered in this setup. + +# The packaging + +The packaging script does the following: + +* In the "sourcecheck" phase, it checks whether the input is present (that would + be the .tar.gz file of the package to compile) +* In the "depcheck" phase, it checks whether all dependencies are present. This + is done to demonstrate what could be done, not because it makes a great deal + of sense +* In the "build" phase, it "builds" a package, by piping the version number of + the package itself to the output file. + diff --git a/examples/packages/repo/config.toml b/examples/packages/repo/config.toml index 62275e5..1f099ca 100644 --- a/examples/packages/repo/config.toml +++ b/examples/packages/repo/config.toml @@ -24,7 +24,11 @@ database_user = "pgdev" database_password = "password" database_name = "butido" -available_phases = [ "dummy" ] +available_phases = [ + "sourcecheck", + "depcheck", + "build" +] [docker] diff --git a/examples/packages/repo/pkg.toml b/examples/packages/repo/pkg.toml index aff709b..a16c49c 100644 --- a/examples/packages/repo/pkg.toml +++ b/examples/packages/repo/pkg.toml @@ -11,10 +11,31 @@ download_manually = false [phases] -dummy.script = ''' - echo "Dummy" +sourcecheck.script = ''' + filename="/inputs/src-{{this.sources.src.hash.hash}}.source" + [[ -e $filename ]] || { + echo "MISSING: $filename" + {{state "ERR" "Missing input"}} + exit 1 + } +''' + +depcheck.script = ''' + {{#each this.dependencies.runtime}} + # Try to find sha of dependency {{this}} + exp_sha="$(echo {{this}} | sed 's,.*\ =,,' | sha1sum | sed 's,\ \ -,,')" + sha1sum /inputs/*pkg | grep "$exp_sha" || { + echo "FAILED TO FIND SHA: $exp_sha" + {{state "ERR" "Failed to find SHA"}} + exit 1 + } + {{/each}} +''' +build.script = ''' mkdir /outputs - touch /outputs/{{this.name}}-{{this.version}}.pkg + echo "{{this.version}}" > /outputs/{{this.name}}-{{this.version}}.pkg + + {{state "OK"}} ''' -- cgit v1.2.3