-
Notifications
You must be signed in to change notification settings - Fork 3
/
new
executable file
·70 lines (58 loc) · 2.11 KB
/
new
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/env sh
if [ -n "${CI}" ]; then
printf "This script should not be used on CI\n"
exit 1
fi
if [ -e Makefile ]; then
printf "A Makefile already exists! Refusing to clobber\n"
exit 1
fi
# Ensure there's an EMACS_VERSION
if [ -z "${EMACS_VERSION}" ]; then
printf "Please set EMACS_VERSION in your ~/.profile or similar\n"
printf "and then re-run this script.\n\n"
printf "Example:\n\n"
printf " echo 'EMACS_VERSION=26.1' >> ~/.profile\n\n"
printf "You can determine your Emacs version with \`emacs --version'.\n"
exit 1
fi
# Retrieve the package basename
if [ -z "${PACKAGE_BASENAME}" ]; then
read -p "Package basename: " PACKAGE_BASENAME
if [ -z "${PACKAGE_BASENAME}" ]; then
printf "Quit\n"
exit 1
fi
else
printf "Using PACKAGE_BASENAME=${PACKAGE_BASENAME}\n"
fi
# Determine most recent SHA1 and download that Makefile
printf "Determining latest version of EMake..."
EMAKE_SHA1=$(curl -fsSL "https://api.github.com/repos/vermiculus/emake.el/git/refs/heads/master" \
| grep -oE '"sha"\s*:\s*"([[:alnum:]]+)"' \
| cut -d\" -f4)
EMAKE_SHA1_SHORT=$(echo ${EMAKE_SHA1} | cut -c1-7)
printf "${EMAKE_SHA1_SHORT}\n"
printf "Downloading EMake..."
curl -fsSLO "https://raw.githubusercontent.com/vermiculus/emake.el/${EMAKE_SHA1}/emake.mk"
printf "done\n"
# Finish up
printf "Generating Makefile..."
cat <<EOF > Makefile
EMAKE_SHA1 ?= ${EMAKE_SHA1}
PACKAGE_BASENAME := ${PACKAGE_BASENAME}
PACKAGE_ARCHIVES := gnu melpa
include emake.mk
.DEFAULT_GOAL: help
emake.mk: ## download EMake's default driver
curl -fsSkL "https://raw.githubusercontent.com/vermiculus/emake.el/\$(EMAKE_SHA1)/emake.mk"
clean: ## clean compiled lisp and EMake files
rm -rf \$(EMAKE_WORKDIR)
rm -f \$(PACKAGE_LISP:.el=.elc)
EOF
printf "done\n"
printf "\nYou now have EMake version ${EMAKE_SHA1_SHORT}!\n"
printf "This is the most recent stable version.\n"
printf "Run \`make help' now to test your installation and to see what you've got!\n"
printf "\nIf you need to install Emacs on CI services, see the manual on GitHub\n"
printf "for a convenient one-liner.\n"