fix golang version bad output direction
[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_dst="$HOME/.local"
16
17 # pkg_src isn't used in this script,
18 # just setting a junk value for completeness (and possibly debug output)
19 pkg_src="$HOME/Downloads/$WEBI_PKG_FILE"
20
21 pkg_get_current_version() {
22     # 'gitea version' has output in this format:
23     #       v2.1.0 h1:pQSaIJGFluFvu8KDGDODV8u4/QRED/OPyIR+MWYYse8=
24     # This trims it down to just the version number:
25     #       2.0.0
26     echo "$(gitea --version 2>/dev/null | head -n 1 | cut -d' ' -f3)"
27 }
28
29 pkg_format_cmd_version() {
30     # 'gitea v2.1.0' is the canonical version format for gitea
31     my_version="$1"
32     echo "$pkg_cmd_name v$my_version"
33 }
34
35 pkg_link_src_dst() {
36     # gitea is just a single file, no directory linking to do
37     true
38 }
39
40 pkg_pre_install() {
41     # if selected version is installed, quit
42     webi_check
43     # will save to ~/Downloads/$WEBI_PKG_FILE by default
44     webi_download
45     # supported formats (.xz, .tar.*, .zip) will be extracted to $WEBI_TMP
46     webi_extract
47 }
48
49 pkg_install() {
50     pushd "$WEBI_TMP" 2>&1 >/dev/null
51
52         # rename the entire extracted folder to the new location
53         # (this will be "$HOME/.local/bin/gitea" by default)
54         mkdir -p "$pkg_dst_bin"
55         mv ./"$pkg_cmd_name"* "$pkg_dst_cmd"
56         chmod a+x "$pkg_dst_cmd"
57
58     popd 2>&1 >/dev/null
59 }
60
61 pkg_post_install() {
62     # just in case we add something in the future
63     pkg_link_src_dst
64
65     # web_path_add is defined in webi/template.bash at https://github.com/webinstall/packages
66     # Adds "$HOME/.local/bin" to PATH
67     webi_path_add "$pkg_dst_bin"
68 }
69
70 pkg_post_install_message() {
71     echo "Installed 'gitea' v$WEBI_VERSION as $pkg_dst_cmd"
72 }