www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

commit cea641936af9ef99b7b9a85573e1cfa73bb1087d
parent f16410b718b87dda7fbf4296986969df8b39838b
Author: Georges Dupéron <georges.duperon@gmail.com>
Date:   Fri, 20 Jul 2018 15:41:09 +0200

mktemp: behaviour is too different between mac and linux, factored out workarounds to a separate .sh

Diffstat:
Mtest/bochs.sh | 4++--
Mtest/virtualbox.sh | 4++--
Mutils/ansi-screenshots/ansi_screenshot.sh | 2+-
Mutils/ansi-screenshots/to_ansi.sh | 16++++++++--------
Mutils/auto-push.sh | 2+-
Mutils/gui-wrapper.sh | 8++++----
Mutils/make-travis-key.sh | 2+-
Autils/mktemp.sh | 36++++++++++++++++++++++++++++++++++++
8 files changed, 55 insertions(+), 19 deletions(-)

diff --git a/test/bochs.sh b/test/bochs.sh @@ -6,14 +6,14 @@ if test $# -ne 1 || test "$1" = '-h' -o "$1" = '--help'; then fi os_filename="$1" -bochsrc="$(mktemp)" +bochsrc="$(./utils/mktemp.sh)" cat > "$bochsrc" <<EOF floppya: 1_44=${os_filename}, status=inserted boot: floppy display_library: sdl EOF -bochscontinue="$(mktemp)" +bochscontinue="$(./utils/mktemp.sh)" echo "continue" > "$bochscontinue" bochs -qf "$bochsrc" < "$bochscontinue" & diff --git a/test/virtualbox.sh b/test/virtualbox.sh @@ -6,8 +6,8 @@ if test $# -ne 1 || test "$1" = '-h' -o "$1" = '--help'; then fi os_filename="$1" -img_file="$(mktemp tmp.XXXXXXXXXX.img)" -vbox_dir="$(mktemp -d tmp.XXXXXXXXXX_vbox)" +img_file="$(./utils/mktemp.sh .img)" +vbox_dir="$(./utils/mktemp.sh -d .vbox)" vmname="automatic-os-test-$(date +%s)-$$" ln -sf "$(readlink -f "$os_filename")" "$img_file" diff --git a/utils/ansi-screenshots/ansi_screenshot.sh b/utils/ansi-screenshots/ansi_screenshot.sh @@ -2,7 +2,7 @@ set -e -screenshot="$(mktemp tmp.XXXXXXXXXX.png)" +screenshot="$("$(dirname "$0")/../mktemp.sh" .png)" scrot "$screenshot" "$(dirname "$0")/to_ansi.sh" "$screenshot" 128 diff --git a/utils/ansi-screenshots/to_ansi.sh b/utils/ansi-screenshots/to_ansi.sh @@ -5,14 +5,14 @@ set -e file="$1" width="$2" -mini_png="$(mktemp tmp.XXXXXXXXXX.png)" -colors_gif="$(mktemp tmp.XXXXXXXXXX.gif)" -indexed_gif="$(mktemp tmp.XXXXXXXXXX.gif)" -indexed_pgm="$(mktemp tmp.XXXXXXXXXX.pgm)" -odd_lines="$(mktemp tmp.XXXXXXXXXX.odd)" -even_lines="$(mktemp tmp.XXXXXXXXXX.even)" -odd_lines_px="$(mktemp tmp.XXXXXXXXXX.odd.px)" -even_lines_px="$(mktemp tmp.XXXXXXXXXX.even.px)" +mini_png="$("$(dirname "$0")/../mktemp.sh" .png)" +colors_gif="$("$(dirname "$0")/../mktemp.sh" .gif)" +indexed_gif="$("$(dirname "$0")/../mktemp.sh" .gif)" +indexed_pgm="$("$(dirname "$0")/../mktemp.sh" .pgm)" +odd_lines="$("$(dirname "$0")/../mktemp.sh" .odd)" +even_lines="$("$(dirname "$0")/../mktemp.sh" .even)" +odd_lines_px="$("$(dirname "$0")/../mktemp.sh" .odd.px)" +even_lines_px="$("$(dirname "$0")/../mktemp.sh" .even.px)" colors=(78,78,78 255,108,96 0,170,0 288,288,182 150,203,254 255,115,253 85,255,255 238,238,238 124,124,124 255,155,147 177,253,121 255,255,145 181,220,254 255,156,254 85,255,255 255,255,255) args=() diff --git a/utils/auto-push.sh b/utils/auto-push.sh @@ -65,7 +65,7 @@ else ssh-add ~/.ssh/travis-deploy-key-id_rsa # TODO: all the config should be in a separate folder, instead of using ~/.ssh for the id_rsa. - known_hosts_d="$(UMASK=077 mktemp -d)" + known_hosts_d="$(UMASK=077 "$(dirname "$0")/mktemp.sh" -d)" touch ${known_hosts_d}/known_hosts chmod 600 ${known_hosts_d}/known_hosts echo "github.com ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==" >> "${known_hosts_d}/known_hosts" diff --git a/utils/gui-wrapper.sh b/utils/gui-wrapper.sh @@ -5,10 +5,10 @@ set -e resolution="$1" # e.g. 800x600x24 (width x height x bits_per_pixel) shift # the following arguments are the program to execute and its arguments -bg="$(mktemp tmp.XXXXXXXXXX.xbm)" -twm_cfg="$(mktemp tmp.XXXXXXXXXX_twm.cfg)" -twm_session_dir="$(mktemp -d)" -anim="$(mktemp -d)" +bg="$(./utils/mktemp.sh .xbm)" +twm_cfg="$(./utils/mktemp.sh .twm.cfg)" +twm_session_dir="$(./utils/mktemp.sh -d)" +anim="$(./utils/mktemp.sh -d)" # Create checkerboard background # Use +level-colors 'gray(192),gray(128)' to choose directly the colors. diff --git a/utils/make-travis-key.sh b/utils/make-travis-key.sh @@ -36,7 +36,7 @@ if ! which travis > /dev/null; then gem install travis || echo "Notice: you need the following packages or their equivalent: ruby ruby-dev" fi -ssh_dir="$(mktemp -d tmp.XXXXXXXXXX_travis-deploy-ssh-keygen)" +ssh_dir="$("$(dirname "$0")/mktemp.sh" -d tmp.XXXXXXXXXX_travis-deploy-ssh-keygen)" mkdir -m 700 "${ssh_dir}/permissions/" ssh-keygen -N '' -f "${ssh_dir}/permissions/travis-deploy-key-id_rsa" diff --git a/utils/mktemp.sh b/utils/mktemp.sh @@ -0,0 +1,36 @@ +#!/bin/sh + +set -e + +the_tmp_dir="${_CS_DARWIN_USER_TEMP_DIR:-"${TMPDIR:-"/tmp"}"}/" + +if test $# -ge 1 && test "$1" = "-d"; then + shift + mkdir_opt='-d' +else + mkdir_opt='' +fi + +if test $# -gt 1; then + echo "Usage: $0 [-d] .suffix" >&2 + exit 1 +elif test $# -eq 1; then + suffix="$1" +else + suffix='' +fi + +result="$(mktemp $mkdir_opt "${the_tmp_dir}tmp.XXXXXXXXXX$suffix")" + +# Sanity checks: + +# Something went wrong while creating the file or directory: +if ! test -e "$result"; then echo "MKTEMP_SH_ERROR"; exit 1; fi +# This could result in a very bad rm invocation: +if ! test "$result" != "/"; then echo "MKTEMP_SH_ERROR"; exit 1; fi +# Something went wrong while creating the file: +if test "x$mkdir_opt" = "x" && ! test -f "$result"; then echo "MKTEMP_SH_ERROR"; exit 1; fi +# Something went wrong while creating the directory: +if test "x$mkdir_opt" = "x-d" && ! test -d "$result"; then echo "MKTEMP_SH_ERROR"; exit 1; fi + +echo "$result"