cleanup: shfmt, shellcheck, and whitespace
[webi-installers/.git] / pandoc / install.sh
1 {
2     set -e
3     set -u
4
5     ###################
6     # Install pandoc #
7     ###################
8
9     # Every package should define these 6 variables
10     pkg_cmd_name="pandoc"
11
12     pkg_dst_cmd="$HOME/.local/bin/pandoc"
13     pkg_dst="$pkg_dst_cmd"
14
15     pkg_src_cmd="$HOME/.local/opt/pandoc-v$WEBI_VERSION/bin/pandoc"
16     pkg_src_dir="$HOME/.local/opt/pandoc-v$WEBI_VERSION"
17     pkg_src="$pkg_src_cmd"
18
19     # pkg_install must be defined by every package
20     pkg_install() {
21         # ~/.local/opt/pandoc-v2.10.1/bin
22         mkdir -p "$(dirname $pkg_src_cmd)"
23
24         # mv ./pandoc-*/pandoc ~/.local/opt/pandoc-v2.10.1/bin/pandoc
25         mv ./pandoc-*/bin/pandoc "$pkg_src_cmd"
26     }
27
28     # pkg_get_current_version is recommended, but (soon) not required
29     pkg_get_current_version() {
30         # 'pandoc --version' has output in this format:
31         # pandoc 2.10.1
32         # Compiled with pandoc-types 1.21, texmath 0.12.0.3, skylighting 0.8.5
33         # Default user data directory: /home/sergi/.local/share/pandoc or /home/sergi/.pandoc
34         # Copyright (C) 2006-2020 John MacFarlane
35         # Web:  https://pandoc.org
36         # This is free software; see the source for copying conditions.
37         # There is no warranty, not even for merchantability or fitness
38         # for a particular purpose.
39         # This trims it down to just the version number:
40         #       2.10.1
41         echo $(pandoc --version 2> /dev/null | head -n 1 | cut -d ' ' -f 2)
42     }
43 }