|
|
@@ -297,31 +297,27 @@ fn render_install_sh(
|
|
|
) -> String {
|
|
|
let args = versions
|
|
|
.iter()
|
|
|
- .map(|(k, v)| format!(" --build-arg {}={}\n", shq(k), shq(v)))
|
|
|
+ .map(|(k, v)| format!(" --build-arg {}={} \\\n", shq(k), shq(v)))
|
|
|
.collect::<String>();
|
|
|
- let gid = gist_id.unwrap_or("' '");
|
|
|
+ let gid = gist_id
|
|
|
+ .map(shq)
|
|
|
+ .unwrap_or_else(|| "' '".to_string());
|
|
|
+ let image_q = shq(image);
|
|
|
format!(
|
|
|
"#!/usr/bin/env bash\n\
|
|
|
# Build {image}. Run from this folder, or set GIST_ID and run from\n\
|
|
|
# anywhere to clone the published gist into /tmp first.\n\
|
|
|
# Usage: curl -fsSL <raw-url>/install.sh | bash (after publishing as a gist)\n\
|
|
|
set -euo pipefail\n\n\
|
|
|
- GIST_ID={} # fill in after `sm121 publish --gist`\n\
|
|
|
+ GIST_ID={gid} # filled in by `sm121 publish --gist`\n\
|
|
|
DIR=/tmp/{recipe_name}-build\n\
|
|
|
- IMAGE={}\n\n\
|
|
|
+ IMAGE={image_q}\n\n\
|
|
|
HERE=\"$(cd \"$(dirname \"$0\")\" && pwd)\"\n\
|
|
|
if [ -f \"$HERE/Dockerfile\" ]; then\n SRC=\"$HERE\"\n\
|
|
|
else\n rm -rf \"$DIR\"; git clone -q \"https://gist.github.com/${{GIST_ID}}.git\" \"$DIR\"; SRC=\"$DIR\"\n\
|
|
|
fi\n\n\
|
|
|
- docker build -t \"$IMAGE\" \\\n{}\"$SRC\"\n\
|
|
|
+ docker build -t \"$IMAGE\" \\\n{args}\"$SRC\"\n\
|
|
|
echo \"built: $IMAGE — see run.sh\"\n",
|
|
|
- shq(image),
|
|
|
- gid,
|
|
|
- if args.is_empty() {
|
|
|
- String::new()
|
|
|
- } else {
|
|
|
- format!(" \\\n{args}")
|
|
|
- },
|
|
|
)
|
|
|
}
|
|
|
|