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