diff options
Diffstat (limited to 'examples')
24 files changed, 278 insertions, 87 deletions
diff --git a/examples/packages/1/Makefile b/examples/packages/1/Makefile new file mode 100644 index 0000000..9de0fb9 --- /dev/null +++ b/examples/packages/1/Makefile @@ -0,0 +1,62 @@ +.PHONY: all +all: directories copyrepo + +directories: ${BUTIDO_RELEASES} ${BUTIDO_STAGING} ${BUTIDO_SOURCE_CACHE} ${BUTIDO_LOG_DIR} ${BUTIDO_REPO} + + +# to start a webserver for serving the source files. +webserver: ./sources ${BUTIDO_SOURCE_CACHE} + devd -A 127.0.0.1 -p 8180 -T ./sources + + +copyrepo: ${BUTIDO_REPO} check-env + cp -rv ./repo/* ${BUTIDO_REPO}/ + cd ${BUTIDO_REPO}/ && git init && git add . && git commit -m init + +${BUTIDO_RELEASES}: check-env + mkdir -p "${BUTIDO_RELEASES}" + +${BUTIDO_STAGING}: check-env + mkdir -p "${BUTIDO_STAGING}" + +${BUTIDO_SOURCE_CACHE}: check-env + mkdir -p "${BUTIDO_SOURCE_CACHE}" + +${BUTIDO_LOG_DIR}: check-env + mkdir -p "${BUTIDO_LOG_DIR}" + +${BUTIDO_REPO}: check-env + mkdir -p "${BUTIDO_REPO}" + + +check-env: +ifndef BUTIDO_RELEASES + $(error BUTIDO_RELEASES is undefined) +endif +ifndef BUTIDO_STAGING + $(error BUTIDO_STAGING is undefined) +endif +ifndef BUTIDO_SOURCE_CACHE + $(error BUTIDO_SOURCE_CACHE is undefined) +endif +ifndef BUTIDO_LOG_DIR + $(error BUTIDO_LOG_DIR is undefined) +endif +ifndef BUTIDO_REPO + $(error BUTIDO_REPO is undefined) +endif +ifndef BUTIDO_DATABASE_HOST + $(error BUTIDO_DATABASE_HOST is undefined) +endif +ifndef BUTIDO_DATABASE_PORT + $(error BUTIDO_DATABASE_PORT is undefined) +endif +ifndef BUTIDO_DATABASE_USER + $(error BUTIDO_DATABASE_USER is undefined) +endif +ifndef BUTIDO_DATABASE_PASSWORD + $(error BUTIDO_DATABASE_PASSWORD is undefined) +endif +ifndef BUTIDO_DATABASE_NAME + $(error BUTIDO_DATABASE_NAME is undefined) +endif diff --git a/examples/packages/1/README.md b/examples/packages/1/README.md index 2531f20..4c680d2 100644 --- a/examples/packages/1/README.md +++ b/examples/packages/1/README.md @@ -7,6 +7,16 @@ to resemble a real packaging process cleanly, including downloads and even failing builds (configurable via ENV variables). +## Setup + +The top-level `shell.nix` file contains a list of environment variables that are +required for butido and the Makefile to automagically find the right locations. + +The `shell.nix` file can be called with +`nix-shell ./shell.nix --argstr example 1` to explicitely select the environment +for example 1. + + ## Downloads The downloads are done from localhost, where a (python) web server has to serve @@ -21,16 +31,25 @@ The packages are dependend on eachother like this: ``` a `- b - | `- c - | | `- h | `- d + | | `- i | `- e + | `- f `- c - `- f `- g - `- i + `- h + `- j ``` +## Database + +The database host is to be expected to run with the settings specified in the +`shell.nix` file (see `example_1_env`). + +See `/scripts/dev-pg-container.sh` for how to start the container. +Use `diesel db reset` to setup the database. + + ## Build The actual build is done in /tmp, where directories are created for the sources, diff --git a/examples/packages/1/repo/a/pkg.toml b/examples/packages/1/repo/a/pkg.toml index 64364a2..6261999 100644 --- a/examples/packages/1/repo/a/pkg.toml +++ b/examples/packages/1/repo/a/pkg.toml @@ -1,17 +1,14 @@ name = "a" version = "1" +[sources.src] +url = "http://localhost:8180/a-1.source" +hash.hash = "eb68d0823f7047958133e66ebedc923825e8a8fe" + [dependencies] runtime = ["b =2", "c =3"] [phases] -package.script = ''' - mkdir /outputs - echo "#BUTIDO:PHASE:package" - echo "#BUTIDO:PROGRESS:90" - - touch /outputs/a-1.pkg - - echo "#BUTIDO:PROGRESS:100" - echo "#BUTIDO:STATE:OK:finished" +build.script = ''' + echo "Building {{name}} in version {{version}}" ''' diff --git a/examples/packages/1/repo/b/pkg.toml b/examples/packages/1/repo/b/pkg.toml index 2ca66e2..df8cd3f 100644 --- a/examples/packages/1/repo/b/pkg.toml +++ b/examples/packages/1/repo/b/pkg.toml @@ -1,18 +1,41 @@ name = "b" version = "2" +[sources.src] +url = "http://localhost:8180/b-2.source" +hash.hash = "89cad6f574693c02c8ecf94983ec20ffad43af0b" + +[dependencies] +build = ["f =6"] +runtime = ["d =4", "e =5"] + [environment] -FOO = "bar" -BAZ = "bla" +FOO = "123" +BAR = "bla" [phases] -package.script = ''' - mkdir /outputs - echo "#BUTIDO:PHASE:package" - echo "#BUTIDO:PROGRESS:90" +build.script = ''' + echo "Look my pretty variables: $FOO" + if [[ -z "$FOO" ]]; then + {{state "ERR" "Failed to find variable FOO"}} + exit 1 + fi + + if [[ "$FOO" != "123" ]]; then + {{state "ERR" "FOO is not equal to '123'"}} + exit 1 + fi + + echo "Look my pretty variables: $BAR" + if [[ -z "$BAR" ]]; then + {{state "ERR" "Failed to find variable BAR"}} + exit 1 + fi - touch /outputs/b-2.pkg + if [[ "$BAR" != "bla" ]]; then + {{state "ERR" "BAR is not equal to 'bla'"}} + exit 1 + fi - echo "#BUTIDO:PROGRESS:100" - echo "#BUTIDO:STATE:OK:finished" + echo "Building {{name}} in version {{version}}" ''' diff --git a/examples/packages/1/repo/c/pkg.toml b/examples/packages/1/repo/c/pkg.toml index 538c576..67533fb 100644 --- a/examples/packages/1/repo/c/pkg.toml +++ b/examples/packages/1/repo/c/pkg.toml @@ -1,14 +1,15 @@ name = "c" version = "3" -[phases] -package.script = ''' - mkdir /outputs - echo "#BUTIDO:PHASE:package" - echo "#BUTIDO:PROGRESS:90" +[sources.src] +url = "http://localhost:8180/c-3.source" +hash.hash = "ee4110c6e42791861e5720646c965580a0ddae8d" + +[dependencies] +runtime = ["g =7", "h =8"] - touch /outputs/c-3.pkg - echo "#BUTIDO:PROGRESS:100" - echo "#BUTIDO:STATE:OK:finished" +[phases] +build.script = ''' + echo "Building {{name}} in version {{version}}" ''' diff --git a/examples/packages/1/repo/config.toml b/examples/packages/1/repo/config.toml index fc0244b..1b63f06 100644 --- a/examples/packages/1/repo/config.toml +++ b/examples/packages/1/repo/config.toml @@ -1,31 +1,21 @@ # Configuration file for BUTIDO for this repository -# repository of package definitions -releases = "/tmp/example-3-releases" -staging = "/tmp/example-3-staging" -source_cache = "/tmp/example-3-sources" -log_dir = "/tmp/example-3-logs" +# In the example, these are configured via the environment. +# See README.md +#releases = "/tmp/example-1-releases" +#staging = "/tmp/example-1-staging" +#source_cache = "/tmp/example-1-sources" +#log_dir = "/tmp/example-1-logs" +#database_host = "localhost" +#database_port = 5432 +#database_user = "pgdev" +#database_password = "password" +#database_name = "butido" script_highlight_theme = "Solarized (dark)" -# #### -# -# Log database configuration -# -# #### - -# The database to use -# -# Can be overridden via environment vairbale BUTIDO_DATABASE_URI or set via CLI. -database_host = "localhost" -database_port = 5432 -database_user = "pgdev" -database_password = "password" -database_name = "butido" - - # Phases which can be configured in the packages -available_phases = [ "unpack", "depinst", "configure", "build", "install", "package" ] +available_phases = [ "checksource", "unpack", "build", "package" ] [docker] # Images which can be used to build @@ -35,15 +25,15 @@ verify_images_present = true # List of docker endpoints [[docker.endpoints]] -name = "example host name" +name = "localhost" uri = "http://0.0.0.0:8095" endpoint_type = "http" speed = 1 maxjobs = 10 - [containers] # environment variables which are allowed during container start # This way, errors (typos) when passing environment to a build can be prevented -allowed_env = [ "PATH" ] +check_env_names = true +allowed_env = [ "FOO", "BAR" ] diff --git a/examples/packages/1/repo/d/pkg.toml b/examples/packages/1/repo/d/pkg.toml new file mode 100644 index 0000000..ff4430d --- /dev/null +++ b/examples/packages/1/repo/d/pkg.toml @@ -0,0 +1,14 @@ +name = "d" +version = "4" + +[sources.src] +url = "http://localhost:8180/d-4.source" +hash.hash = "e8332116d7a7104f4affc10b6c65a93027441437" + +[dependencies] +build = ["i =9"] + +[phases] +build.script = ''' + echo "Building {{name}} in version {{version}}" +''' diff --git a/examples/packages/1/repo/e/pkg.toml b/examples/packages/1/repo/e/pkg.toml new file mode 100644 index 0000000..9bf14f6 --- /dev/null +++ b/examples/packages/1/repo/e/pkg.toml @@ -0,0 +1,11 @@ +name = "e" +version = "5" + +[sources.src] +url = "http://localhost:8180/e-5.source" +hash.hash = "f2c844feb6ccb9e4977f256a5126aac77334ec5a" + +[phases] +build.script = ''' + echo "Building {{name}} in version {{version}}" +''' diff --git a/examples/packages/1/repo/f/pkg.toml b/examples/packages/1/repo/f/pkg.toml new file mode 100644 index 0000000..c78e6fe --- /dev/null +++ b/examples/packages/1/repo/f/pkg.toml @@ -0,0 +1,11 @@ +name = "f" +version = "6" + +[sources.src] +url = "http://localhost:8180/f-6.source" +hash.hash = "1ad43418fb476e812c7c27c225a823eda89efc50" + +[phases] +build.script = ''' + echo "Building {{name}} in version {{version}}" +''' diff --git a/examples/packages/1/repo/g/pkg.toml b/examples/packages/1/repo/g/pkg.toml new file mode 100644 index 0000000..caaea2f --- /dev/null +++ b/examples/packages/1/repo/g/pkg.toml @@ -0,0 +1,11 @@ +name = "g" +version = "7" + +[sources.src] +url = "http://localhost:8180/g-7.source" +hash.hash = "c7af27a237cb21368eb2b25a068e72283b528684" + +[phases] +build.script = ''' + echo "Building {{name}} in version {{version}}" +''' diff --git a/examples/packages/1/repo/h/pkg.toml b/examples/packages/1/repo/h/pkg.toml new file mode 100644 index 0000000..eff3fdf --- /dev/null +++ b/examples/packages/1/repo/h/pkg.toml @@ -0,0 +1,14 @@ +name = "h" +version = "8" + +[sources.src] +url = "http://localhost:8180/h-8.source" +hash.hash = "387d6873dfbdbaf116e1091c8b11eaf406b98f8f" + +[dependencies] +build = ["j =10"] + +[phases] +build.script = ''' + echo "Building {{name}} in version {{version}}" +''' diff --git a/examples/packages/1/repo/i/pkg.toml b/examples/packages/1/repo/i/pkg.toml new file mode 100644 index 0000000..7545e0b --- /dev/null +++ b/examples/packages/1/repo/i/pkg.toml @@ -0,0 +1,11 @@ +name = "i" +version = "9" + +[sources.src] +url = "http://localhost:8180/i-9.source" +hash.hash = "11578a82ef30e5c9787f6a2342dec4b856c257d2" + +[phases] +build.script = ''' + echo "Building {{name}} in version {{version}}" +''' diff --git a/examples/packages/1/repo/j/pkg.toml b/examples/packages/1/repo/j/pkg.toml new file mode 100644 index 0000000..a1b87c6 --- /dev/null +++ b/examples/packages/1/repo/j/pkg.toml @@ -0,0 +1,11 @@ +name = "j" +version = "10" + +[sources.src] +url = "http://localhost:8180/j-10.source" +hash.hash = "96ef992ccecfcef89a6a964af8a83b88a1351129" + +[phases] +build.script = ''' + echo "Building {{name}} in version {{version}}" +''' diff --git a/examples/packages/1/repo/pkg.toml b/examples/packages/1/repo/pkg.toml index f908065..b13f069 100644 --- a/examples/packages/1/repo/pkg.toml +++ b/examples/packages/1/repo/pkg.toml @@ -5,9 +5,7 @@ version_is_semver = false patches = [] [sources.src] -url = "https://github.com/user/repo/archive/sources.tar.gz" hash.type = "sha1" -hash.hash = "5e8bcaa3c758f84f01935a914e2bbf01309462ae" [dependencies] build = [] @@ -17,49 +15,57 @@ runtime = [] # can be overridden as well [phases] -unpack.script = ''' +checksource.script = ''' + {{phase "Checking sources"}} + {{progress 0}} + + echo "Sources for this Package:" {{#each sources}} - echo "{{@key}} {{this.url}}" - echo " {{this.hash.hash}}" - ls /inputs/{{@key}}-{{this.hash.hash}}.source - {{/each}} + echo "{{@key}} : {{this.url}}" + echo "{{this.hash.type}}: {{this.hash.hash}}" - mkdir /build - echo "#BUTIDO:PHASE:unpack" -''' + if [ ! -e /inputs/{{@key}}-{{this.hash.hash}}.source ]; then + {{state "ERR" "Failed to find source" }} + exit 1 + fi + {{/each}} + {{progress 20}} -# We use a depinst phase here because we don't want to add a Dockerfile to the -# repo where we prepare a build container. -# This is, of course, not be the way it would be done in a real-world scenario! -depinst.script = ''' - {{phase "depinst"}} - {{progress 0}} - for n in {1..10}; do sleep 0.1; done - {{progress 10}} -''' + echo "All sources:" + echo "------------" -configure.script = ''' - {{phase "configure-preparing"}} - for n in {1..10}; do sleep 0.1; done + ls /inputs - {{progress 20}} - for n in {1..10}; do sleep 0.1; done + echo "------------" ''' -build.script = ''' - {{phase "build"}} +unpack.script = ''' + {{phase "Unpacking sources"}} - for n in {1..10}; do sleep 0.1; done + mkdir /build + {{#each sources}} + mv /inputs/{{@key}}-{{this.hash.hash}}.source /build/ + {{/each}} + {{progress 40}} - echo "#BUTIDO:PROGRESS:60" + echo "Moving dependencies to /build" + mv /inputs/*.pkg /build/ {{progress 60}} + + + ls /build ''' -install.script = ''' - {{phase "install"}} - for n in {1..10}; do sleep 0.1; done +package.script = ''' + {{phase "package"}} + + mkdir /outputs + for f in /build/*; do + cat "$f" | sed 's,^, ,' >> /outputs/{{name}}-{{version}}.pkg + done - {{progress 80}} + {{progress 100}} + {{state "OK" "Finished"}} ''' diff --git a/examples/packages/1/sources/a-1.source b/examples/packages/1/sources/a-1.source new file mode 100644 index 0000000..186e86d --- /dev/null +++ b/examples/packages/1/sources/a-1.source @@ -0,0 +1 @@ +a-1 diff --git a/examples/packages/1/sources/b-2.source b/examples/packages/1/sources/b-2.source new file mode 100644 index 0000000..99add72 --- /dev/null +++ b/examples/packages/1/sources/b-2.source @@ -0,0 +1 @@ +b-2 diff --git a/examples/packages/1/sources/c-3.source b/examples/packages/1/sources/c-3.source new file mode 100644 index 0000000..fff5324 --- /dev/null +++ b/examples/packages/1/sources/c-3.source @@ -0,0 +1 @@ +c-3 diff --git a/examples/packages/1/sources/d-4.source b/examples/packages/1/sources/d-4.source new file mode 100644 index 0000000..db8f742 --- /dev/null +++ b/examples/packages/1/sources/d-4.source @@ -0,0 +1 @@ +d-4 diff --git a/examples/packages/1/sources/e-5.source b/examples/packages/1/sources/e-5.source new file mode 100644 index 0000000..a55d5b7 --- /dev/null +++ b/examples/packages/1/sources/e-5.source @@ -0,0 +1 @@ +e-5 diff --git a/examples/packages/1/sources/f-6.source b/examples/packages/1/sources/f-6.source new file mode 100644 index 0000000..a959d8f --- /dev/null +++ b/examples/packages/1/sources/f-6.source @@ -0,0 +1 @@ +f-6 diff --git a/examples/packages/1/sources/g-7.source b/examples/packages/1/sources/g-7.source new file mode 100644 index 0000000..e0ede95 --- /dev/null +++ b/examples/packages/1/sources/g-7.source @@ -0,0 +1 @@ +g-7 diff --git a/examples/packages/1/sources/h-8.source b/examples/packages/1/sources/h-8.source new file mode 100644 index 0000000..7f16a18 --- /dev/null +++ b/examples/packages/1/sources/h-8.source @@ -0,0 +1 @@ +h-8 diff --git a/examples/packages/1/sources/i-9.source b/examples/packages/1/sources/i-9.source new file mode 100644 index 0000000..a1215d1 --- /dev/null +++ b/examples/packages/1/sources/i-9.source @@ -0,0 +1 @@ +i-9 diff --git a/examples/packages/1/sources/j-10.source b/examples/packages/1/sources/j-10.source new file mode 100644 index 0000000..7c049e2 --- /dev/null +++ b/examples/packages/1/sources/j-10.source @@ -0,0 +1 @@ +j-10 |