-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathv1
More file actions
executable file
·45 lines (36 loc) · 1.46 KB
/
v1
File metadata and controls
executable file
·45 lines (36 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/env bash
set -euo pipefail
# MF_PROJECT_ROOT must always be defined.
export MF_PROJECT_ROOT="${MF_PROJECT_ROOT:-$(pwd)}"
# MF_BRANCH is the branch of the makefiles repository that is downloaded. This
# is intended for testing purposes only and should be left set to the default of
# "v1" for general use.
export MF_BRANCH="${MF_BRANCH:-v1}"
# Check if we've already got the makefiles.
if [[ ! -d ".makefiles" ]]; then
if [[ $MAKEFLAGS =~ (^|[^[:alnum:]_])j([^[:alnum:]_]|$) ]]; then
echo 'Run "make makefiles" before running make -j'
exit 1
fi
tmpdir="$(mktemp -d)"
trap "rm -rf '$tmpdir'" EXIT
nonce=$(head /dev/urandom | cksum | cut -d ' ' -f1)
# Download the makefiles.
curl \
--fail \
--silent \
--show-error \
--location \
--create-dirs \
--output "$tmpdir/archive.zip" \
"https://github.com/make-files/makefiles/archive/${MF_BRANCH}.zip?nonce=${nonce}"
# Unpack the archive from the subdirectory that GitHub adds into the .makefiles directory.
unzip -q "$tmpdir/archive.zip" -d "$tmpdir"
mv "$tmpdir/makefiles"-* ".makefiles"
# Run the install command for the core library. Because it is already in the
# correct location this will simply run the install hooks.
.makefiles/lib/core/bin/install-lib core
fi
# Finally, invoke the build-resource command to produce the actual resource that
# was requested.
.makefiles/lib/core/bin/build-resource "$1"