Skip to content

Commit

Permalink
Add a variable for the temp directory
Browse files Browse the repository at this point in the history
  • Loading branch information
martinthomson committed Nov 4, 2023
1 parent 372b10c commit 9d21876
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 5 deletions.
4 changes: 2 additions & 2 deletions archive.mk
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ $(archive_script) $(1)
endef
else
define archive_issues
old_archive=$$(mktemp /tmp/archive-old.XXXXXX); \
old_archive=$$(mktemp $(TMPDIR)/tmp/archive-old.XXXXXX); \
trap 'rm -f $$old_archive' EXIT; \
git show $(ARCHIVE_BRANCH):$(1) > $$old_archive || true; \
echo $(archive_script) $(1) --reference $$old_archive; \
Expand Down Expand Up @@ -55,7 +55,7 @@ archive.json: fetch-archive $(drafts_source) $(DEPS_FILES)
fi; \
$(call archive_issues,$@)

ARCHIVE_ROOT := /tmp/gharchive$(PID)
ARCHIVE_ROOT := $(TMPDIR)/gharchive$(PID)
$(ARCHIVE_ROOT): fetch-archive
@git show-ref refs/heads/$(ARCHIVE_BRANCH) >/dev/null 2>&1 || \
(git show-ref refs/remotes/origin/$(ARCHIVE_BRANCH) >/dev/null 2>&1 && \
Expand Down
3 changes: 2 additions & 1 deletion build-index.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ repo="${6:-<repo>}"
default_branch="${DEFAULT_BRANCH:-$("$(dirname "$0")/default-branch.py")}"
branch="${3:-$default_branch}"
libdir="${LIBDIR:-"$(realpath "$(dirname "$0")")"}"
TMPDIR="${TMPDIR:-/tmp}"
[[ -n "$VENV" ]] && python="${python:-"${VENV}/python"}"
python="${python:-python3}"
shift 6
Expand Down Expand Up @@ -249,7 +250,7 @@ function list_dir() {
[[ -n "${src##*:}" ]] || \
src="origin/${branch}:$(git ls-tree --name-only "origin/$branch" -- "$file".md "$file".xml 2>/dev/null | head -1)"
if [[ -n "${src##*:}" ]]; then
tmp="$(mktemp "/tmp/build-index$$-XXXXXX").${src##*.}"
tmp="$(mktemp "${TMPDIR}/build-index$$-XXXXXX").${src##*.}"
tmpfiles+=("$tmp")
git show "$src" >"$tmp"
src="$tmp"
Expand Down
3 changes: 3 additions & 0 deletions config.mk
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ trace := $(LIBDIR)/trace.sh
# Where versioned copies are stored.
VERSIONED ?= versioned

# We can blame this one on some weird configuration.
TMPDIR ?= /tmp

# Set this to "true" to disable caching where possible.
DISABLE_CACHE ?= false
ifeq (true,$(DISABLE_CACHE))
Expand Down
2 changes: 1 addition & 1 deletion ghpages.mk
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ endif
fetch-ghpages:
git fetch -qf origin ${PAGES_BRANCH}:${PAGES_BRANCH}

GHPAGES_ROOT := /tmp/ghpages$(PID)
GHPAGES_ROOT := $(TMPDIR)/ghpages$(PID)
ghpages: $(GHPAGES_ROOT)
$(GHPAGES_ROOT): fetch-ghpages
@git show-ref refs/heads/${PAGES_BRANCH} >/dev/null 2>&1 || \
Expand Down
3 changes: 2 additions & 1 deletion setup-branch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ set -e
hash realpath 2>/dev/null || function realpath() { cd "$1"; pwd -P; }

branch="$1"
TMPDIR="${TMPDIR:-/tmp}"
shift

# Fetch here, but don't abort on failure.
Expand All @@ -14,7 +15,7 @@ if git show-ref -s "$branch" >/dev/null 2>&1; then
exit
fi

tmp=$(mktemp -d /tmp/init-branch-"$branch"-XXXXX)
tmp=$(mktemp -d "${TMPDIR}/init-branch-${branch}-XXXXX")
function cleanup() {
rm -rf "$tmp"
}
Expand Down

0 comments on commit 9d21876

Please sign in to comment.