refactor: finish moving ssh-* scripts to own installers
[webi-installers/.git] / flutter / install.sh
1 #!/bin/bash
2
3 set -e
4 set -u
5
6 # NOTE: pkg_* variables can be defined here
7 #       pkg_cmd_name
8 #       pkg_src, pkg_src_bin, pkg_src_cmd
9 #       pkg_dst, pkg_dst_bin, pkg_dst_cmd
10 #
11 # Their defaults are defined in _webi/template.sh at https://github.com/webinstall/packages
12
13 # Every package should define these 6 variables
14 pkg_cmd_name="flutter"
15
16 pkg_dst_cmd="$HOME/.local/opt/flutter/bin/flutter"
17 pkg_dst_dir="$HOME/.local/opt/flutter"
18 pkg_dst="$pkg_dst_dir"
19
20 pkg_src_cmd="$HOME/.local/opt/flutter-v$WEBI_VERSION/bin/flutter"
21 pkg_src_dir="$HOME/.local/opt/flutter-v$WEBI_VERSION"
22 pkg_src="$pkg_src_dir"
23
24 function pkg_get_current_version() {
25     # 'flutter --version' outputs a lot of information:
26     #       Flutter 1.19.0-4.1.pre • channel beta • https://github.com/flutter/flutter.git
27     #       Framework • revision f994b76974 (4 days ago) • 2020-06-09 15:53:13 -0700
28     #       Engine • revision 9a28c3bcf4
29     #       Tools • Dart 2.9.0 (build 2.9.0-14.1.beta)
30     # This trims it down to just the version number:
31     #       1.19.0-4.1.pre
32     echo "$(flutter --version 2> /dev/null | head -n 1 | cut -d' ' -f2)"
33 }
34
35 function pkg_format_cmd_version() {
36     # 'flutter 1.19.0' is the canonical version format for flutter
37     my_version="$1"
38     echo "$pkg_cmd_name $my_version"
39 }