From 27859af307fda46732209e29a09e8a4b552212d1 Mon Sep 17 00:00:00 2001 From: Tim Byrne Date: Thu, 28 Feb 2019 22:59:04 -0600 Subject: [PATCH] Add make target "scripthost" Hopefully this target will help others demonstrate problems in a reproducible way. --- Makefile | 48 ++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 42 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 65edc57..b0172f0 100644 --- a/Makefile +++ b/Makefile @@ -27,6 +27,13 @@ usage: @echo ' The targeted "version" will be retrieved from the repo, and' @echo ' linked into the container as a local volume.' @echo + @echo ' make scripthost [version=VERSION]' + @echo ' - Create an ephemeral container for demonstrating a bug. After' + @echo ' exiting the shell, a log of the commands used to illustrate the' + @echo ' problem will be written to the file "script.txt". This file can' + @echo ' be useful to developers to make a repeatable test for the' + @echo ' problem.' + @echo @echo 'LINTING' @echo @echo ' make testenv' @@ -87,17 +94,39 @@ test: fi .PHONY: testhost -testhost: - @if ! command -v "docker" >/dev/null 2>&1; then \ - echo "Sorry, this make target requires docker to be installed."; \ - false; \ - fi +testhost: require-docker @version=HEAD @rm -rf /tmp/testhost @git show $(version):yadm > /tmp/testhost @chmod a+x /tmp/testhost @echo Starting testhost version=\"$$version\" - @docker run -w /root --hostname testhost --rm -it -v "/tmp/testhost:/bin/yadm:ro" yadm/testbed:latest bash -l + @docker run \ + -w /root \ + --hostname testhost \ + --rm -it \ + -v "/tmp/testhost:/bin/yadm:ro" \ + yadm/testbed:latest \ + bash -l + +.PHONY: scripthost +scripthost: require-docker + @version=HEAD + @rm -rf /tmp/testhost + @git show $(version):yadm > /tmp/testhost + @chmod a+x /tmp/testhost + @echo Starting scripthost version=\"$$version\" \(recording script\) + @printf '' > script.gz + @docker run \ + -w /root \ + --hostname scripthost \ + --rm -it \ + -v "$$PWD/script.gz:/script.gz:rw" \ + -v "/tmp/testhost:/bin/yadm:ro" \ + yadm/testbed:latest \ + bash -c "script /tmp/script -q -c 'bash -l'; gzip < /tmp/script > /script.gz" + @echo + @echo "Script saved to $$PWD/script.gz" + .PHONY: testenv testenv: @@ -133,3 +162,10 @@ contrib: .PHONY: sync-clock sync-clock: docker run --rm --privileged alpine hwclock -s + +.PHONY: require-docker +require-docker: + @if ! command -v "docker" >/dev/null 2>&1; then \ + echo "Sorry, this make target requires docker to be installed."; \ + false; \ + fi