17fc587d773f566faf11555346dd3d73e08985f2
[webi-installers/.git] / gitea / install.bash
1 # title: Gitea
2 # homepage: https://github.com/go-gitea/gitea
3 # tagline: Fast, multi-platform web server with automatic HTTPS
4 # description: |
5 # Caddy is an extensible server platform that uses TLS by default.
6 # examples: |
7 #   ```bash
8 #   gitea start
9 #   ```
10
11 set -e
12 set -u
13
14 pkg_common_opt="$HOME/.local"
15
16 # just a junk file so that the version check always fails for non-current versions
17 pkg_new_opt="$HOME/.local/opt/gitea-doesntexist111"
18
19 pkg_get_current_version() {
20     # 'gitea version' has output in this format:
21     #       v2.1.0 h1:pQSaIJGFluFvu8KDGDODV8u4/QRED/OPyIR+MWYYse8=
22     # This trims it down to just the version number:
23     #       2.0.0
24     echo "$(gitea --version 2>/dev/null | head -n 1 | cut -d' ' -f3)"
25 }
26
27 pkg_format_cmd_version() {
28     # 'gitea v2.1.0' is the canonical version format for gitea
29     my_version="$1"
30     echo "$pkg_cmd_name v$my_version"
31 }
32
33 pkg_link_new_version() {
34     # gitea is just a single file, no directory linking to do
35     true
36 }
37
38 pkg_pre_install() {
39     # if selected version is installed, quit
40     webi_check
41     # will save to ~/Downloads/$WEBI_PKG_FILE by default
42     webi_download
43     # supported formats (.xz, .tar.*, .zip) will be extracted to $WEBI_TMP
44     webi_extract
45 }
46
47 pkg_install() {
48     pushd "$WEBI_TMP" 2>&1 >/dev/null
49
50         # rename the entire extracted folder to the new location
51         # (this will be "$HOME/.local/bin/gitea" by default)
52         mkdir -p "$pkg_common_bin"
53         mv ./"$pkg_cmd_name"* "$pkg_common_cmd"
54
55     popd 2>&1 >/dev/null
56 }
57
58 pkg_post_install() {
59     # just in case we add something in the future
60     pkg_link_new_version
61
62     # web_path_add is defined in webi/template.bash at https://github.com/webinstall/packages
63     # Adds "$HOME/.local/bin" to PATH
64     webi_path_add "$pkg_common_bin"
65 }
66
67 pkg_post_install_message() {
68     echo "Installed 'gitea' as $pkg_common_cmd"
69 }