Skip to content

Commit 37397b1

Browse files
committed
feat: add snap package manager for linux
1 parent aada2e3 commit 37397b1

File tree

1 file changed

+36
-13
lines changed

1 file changed

+36
-13
lines changed

setup-flutter

Lines changed: 36 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,38 +15,47 @@ if [ "$(uname)" == "Darwin" ]; then
1515
fi
1616
elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then
1717
# Linux
18-
if ! grep -q 'export PATH="/home/linuxbrew/.linuxbrew/bin:$PATH"' ~/.bashrc && ! grep -q 'export PATH="/home/linuxbrew/.linuxbrew/bin:$PATH"' ~/.zshrc; then
19-
if [ -n "$ZSH_VERSION" ]; then
20-
echo 'export PATH="/home/linuxbrew/.linuxbrew/bin:$PATH"' >> ~/.zshrc
21-
elif [ -n "$BASH_VERSION" ]; then
22-
echo 'export PATH="/home/linuxbrew/.linuxbrew/bin:$PATH"' >> ~/.bashrc
23-
fi
18+
if ! command -v snap &> /dev/null; then
19+
sudo apt-get update
20+
sudo apt-get install -y snapd
2421
fi
2522
fi
2623

27-
# Reload shell configuration to apply Homebrew PATH changes
24+
# Reload shell configuration to apply PATH changes
2825
if [ -n "$ZSH_VERSION" ]; then
2926
source ~/.zshrc
3027
elif [ -n "$BASH_VERSION" ]; then
3128
source ~/.bashrc
3229
fi
3330

3431
# Check if brew command is available
32+
# &> /dev/null: This is a redirection that redirects both
33+
# the standard output and standard error streams of the command to the null device, 4
34+
# discarding any output that the command may produce.
35+
# This is done to make the command run silently, without producing any output on the screen.
3536
if ! command brew -v &> /dev/null; then
3637
echo "Homebrew not found. Please check the Homebrew installation and PATH setup."
3738
exit 1
3839
fi
40+
x
41+
42+
if [ "$(uname)" == "Darwin" ]; then
43+
# Install Java if it's not already installed
44+
brew list --cask adoptopenjdk/openjdk/adoptopenjdk8 || brew install --cask adoptopenjdk/openjdk/adoptopenjdk8
45+
else
46+
sudo snap install openjdk
47+
fi
3948

40-
# Install Java if it's not already installed
41-
brew list --cask adoptopenjdk/openjdk/adoptopenjdk8 || brew install --cask adoptopenjdk/openjdk/adoptopenjdk8
4249

4350
# Install Android Studio if it's not already installed
4451
if [ "$(uname)" == "Darwin" ]; then
4552
if [ ! -d "/Applications/Android Studio.app" ]; then
4653
brew list --cask android-studio || brew install --cask android-studio
4754
fi
4855
else
49-
brew list --cask android-studio || brew install --cask android-studio
56+
if [ ! -d "/snap/bin/android-studio" ]; then
57+
sudo snap install android-studio --classic
58+
fi
5059
fi
5160

5261
# Install Visual Studio Code if it's not already installed
@@ -55,7 +64,9 @@ if [ "$(uname)" == "Darwin" ]; then
5564
brew list --cask visual-studio-code || brew install --cask visual-studio-code
5665
fi
5766
else
58-
brew list --cask visual-studio-code || brew install --cask visual-studio-code
67+
if [ ! -d "/snap/bin/code" ]; then
68+
sudo snap install --classic code
69+
fi
5970
fi
6071

6172
# Install FVM if it's not already installed
@@ -72,9 +83,21 @@ else
7283
fi
7384

7485
# Add FVM executable to the PATH in the shell configuration file
86+
if ! grep -q 'export PATH="$PATH":"$HOME/.pub-cache/bin"' $SHELL_CONFIG; then
87+
if [ "$(uname)" == "Linux" ]; then
88+
echo 'export PATH="$PATH":"$HOME/.pub-cache/bin"' >> $SHELL_CONFIG
89+
fi
90+
fi
91+
92+
93+
# Add flutter path to shell configuration
7594
if ! grep -q 'export PATH="$HOME/fvm/default/bin"' $SHELL_CONFIG; then
76-
sed -i '' '1i\
77-
export PATH="$HOME/fvm/default/bin:$PATH"' $SHELL_CONFIG
95+
if [ "$(uname)" == "Darwin" ]; then
96+
sed -i '' '1i\
97+
export PATH="$HOME/fvm/default/bin"' $SHELL_CONFIG
98+
else
99+
echo 'export PATH="$HOME/fvm/default/bin"' >> $SHELL_CONFIG
100+
fi
78101
fi
79102

80103
# Activate changes to shell configuration file

0 commit comments

Comments
 (0)