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