6a4d5868b930dbecadb6eedf7593df74c77b4c8a
[webi-installers/.git] / gitea / install.sh
1 set -e
2 set -u
3
4 pkg_cmd_name="gitea"
5 pkg_src_cmd="$HOME/.local/opt/gitea-v$WEBI_VERSION/gitea"
6 pkg_dst_cmd="$HOME/.local/opt/gitea/gitea"
7
8 pkg_get_current_version() {
9     # 'gitea version' has output in this format:
10     #       v2.1.0 h1:pQSaIJGFluFvu8KDGDODV8u4/QRED/OPyIR+MWYYse8=
11     # This trims it down to just the version number:
12     #       2.0.0
13     echo "$(gitea --version 2>/dev/null | head -n 1 | cut -d' ' -f3)"
14 }
15
16 pkg_link() {
17     # although gitea is a single command it must be put in its own directory
18     # because it will always resolve its working path to its location,
19     # regardless of where it was started, where its config file lives, etc.
20     rm -rf "$pkg_dst_cmd"
21     mkdir -p "$pkg_dst_bin/custom"
22     chmod a+x "$pkg_src_cmd"
23     ln -s "$pkg_src_cmd" "$pkg_dst_cmd"
24 }
25
26 # For installing from the extracted package tmp directory
27 pkg_install() {
28     # remove the versioned folder, just in case it's there with junk
29     rm -rf "$pkg_src_bin"
30     mkdir -p "$pkg_src_bin"
31
32     # rename the entire extracted folder to the new location
33     # (this will be "$HOME/.local/opt/xmpl-v$WEBI_VERSION" by default)
34     mv ./"$pkg_cmd_name"* "$pkg_src_cmd"
35 }