4 # homepage: https://flutter.dev
5 # tagline: UI Toolkit for mobile, web, and desktop
7 # Flutter is Google’s UI toolkit for building beautiful, natively compiled applications for mobile, web, and desktop from a single codebase.
11 # flutter create my_app
21 # The command name may be different from the package name
22 # (i.e. golang => go, rustlang => cargo, ripgrep => rg)
23 # Note: $HOME may contain special characters and should alway be quoted
24 pkg_cmd_name="flutter"
25 #pkg_cmd_name_formatted="flutter $WEBI_VERSION"
27 # Some of these directories may be the same
28 pkg_common_opt="$HOME/.local/opt/flutter"
29 pkg_common_bin="$HOME/.local/opt/flutter/bin"
30 pkg_common_cmd="$HOME/.local/opt/flutter/bin/flutter"
31 pkg_new_opt="$HOME/.local/opt/flutter-v$WEBI_VERSION"
32 pkg_new_bin="$HOME/.local/opt/flutter-v$WEBI_VERSION/bin"
33 pkg_new_cmd="$HOME/.local/opt/flutter-v$WEBI_VERSION/bin/flutter"
36 # The version info should be reduced to a sortable version, without any leading characters
37 # (i.e. v12.8.0 => 12.8.0, go1.14 => 1.14, 1.12.13+hotfix => 1.12.13+hotfix)
38 pkg_get_current_version() {
39 echo "$(flutter --version 2>/dev/null | head -n 1 | cut -d' ' -f2)"
42 # Any version-related directories should be unlinked and relinked to the correct version
43 # (for example: 'go' is special and needs both $HOME/go and $HOME/.local/opt/go)
44 # (others like 'rg', 'hugo', and 'caddy' are single files that just get replaced)
45 pkg_switch_version() {
46 rm -rf "$pkg_common_opt"
47 ln -s "$pkg_new_opt" "$pkg_common_opt"
50 # Different packages represent the version in different ways
51 # ex: node v12.8.0 (leading 'v')
52 # ex: go1.14 (no space, nor trailing '.0's)
53 # ex: flutter 1.17.2 (plain)
54 pkg_format_cmd_version() {
56 echo "$pkg_cmd_name $my_version"
60 pushd "$WEBI_TMP" 2>&1 >/dev/null
62 # simpler for single-binary commands
63 #mv ./example*/bin/example "$HOME/.local/bin"
65 # best for packages and toolchains
66 if [ -n "$(command -v rsync 2>/dev/null | grep rsync)" ]; then
67 rsync -Krl ./flutter*/ "$pkg_new_opt/" 2>/dev/null
69 cp -Hr ./flutter*/* "$pkg_new_opt/" 2>/dev/null
70 cp -Hr ./flutter*/.* "$pkg_new_opt/" 2>/dev/null
77 webi_path_add "$pkg_common_bin"
81 # The webi_* functions are defined in webi/template.bash at https://github.com/webinstall/packages
84 # for packages that can have multiple versions
86 # for packages that can be downloaded via links in ./releases.js
88 # for single files or packaged directories (compressed or uncompressed)
89 # supported formats: .xz, .tar.*, and .zip
92 echo "Installing '$pkg_cmd_name' v$WEBI_VERSION as $pkg_new_cmd"
94 # for installing the tool
96 # for updating paths and installing companion tools
98 # for re-linking to a previously installed version
101 echo "Installed '$pkg_cmd_name' v$WEBI_VERSION as $pkg_new_cmd"