Skip to content

Commit 98a284a

Browse files
committed
better feedback
1 parent cd1979f commit 98a284a

File tree

3 files changed

+86
-45
lines changed

3 files changed

+86
-45
lines changed

README.md

Lines changed: 47 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* install Homebrew in native mode (without Rosetta 2) on a fresh Apple M1 Arm computer (MacOS Big Sur)
66
* run as: `curl -s https://raw.githubusercontent.com/pforret/macos_m1_cli/main/install_homebrew_native.sh | bash`
77

8-
## Using native Homebrew
8+
### Using native Homebrew
99

1010
* as long as Homebrew does not officially support Apple M1 ARM architecture,
1111
you will get the following warning every time you try to `brew install` a package
@@ -20,20 +20,58 @@
2020
any issues you experience while you are running this
2121
unsupported configuration.
2222

23-
* you can however install the package by using `brew1 install`,
24-
which is short for `brew --build-from-source install`
25-
* the installation will probably work, but it's not guaranteed.
26-
You are an early adopter, doing bleeding edge stuff, not for the faint of heart.
23+
* you can however install the package by using `brew install -s`,
24+
which is short for `brew install --build-from-source`
25+
* the installation will probably work, but it's not guaranteed.
26+
* every time brew stops with "You can try to install ...",
27+
do that first and then run the original brew install again.
28+
29+
30+
Error: [some package]: no bottle available!
31+
You can try to install from source with e.g.
32+
brew install --build-from-source ghostscript
33+
34+
* Remember: you are an early adopter, on the curring edge.
35+
You will tell your grand children about these days.
36+
37+
38+
### install_homebrew_native.sh from pforret/macos_m1_cli Ⓜ️ 1️⃣
39+
🍺 If you get a MacOS popup asking to install 'developer tools', please confirm
40+
🍺 Create a folder for Homebrew ...
41+
🍺 Download and install Homebrew from Github ...
42+
🍺 Adding [/opt/homebrew/bin] to your zsh startup config path
43+
🍺 Running brew a first time to trigger compilation
44+
Initialized empty Git repository in /opt/homebrew/.git/
45+
HEAD is now at 9db324ab7 Merge pull request #10045 from jonchang/remove-basic-autho
46+
==> make CC=clang CFLAGS= YACC=yacc -d
47+
🍺 /opt/homebrew/Cellar/awk/20180827: 7 files, 203.5KB, built in 3 seconds
48+
🍺 Homebrew was installed as native binary. Version will be > 2.6
49+
HOMEBREW_VERSION: 2.6.2-91-g9db324a
50+
#====================================
51+
🍺 Installation using 'brew install' will give a warning as long as Homebrew is not yet officially released for M1
52+
🍺 You can use 'brew install -s' to always build from source and skip that warning
53+
🍺 You might get build errors, but remember: you are an early adopter!
54+
#====================================
55+
🍺 Close this terminal and start a new one to make sure brew is in the path
56+
2757

2858
## `uninstall_homebrew_native.sh`
2959

3060
* if you prefer running in 'Rosetta 2' mode, you can uninstall the native mode Homebrew.
3161
* run as: `curl -s https://raw.githubusercontent.com/pforret/macos_m1_cli/main/uninstall_homebrew_native.sh | bash`
3262

63+
64+
### uninstall_homebrew_native.sh from pforret/macos_m1_cli Ⓜ️ 1️⃣
65+
🧽 Removing [/opt/homebrew/bin] from your zsh startup config path
66+
🧽 Deleting Homebrew from [/opt/homebrew]
67+
Password:
68+
🧽 Homebrew was uninstalled!
69+
3370
## My Homebrew configuration
3471

35-
This is my config (on Mac Mini M1):
72+
This is my current config (on Mac Mini M1, 17 Dec 2020):
3673

74+
$ brew config
3775
HOMEBREW_VERSION: 2.6.2-91-g9db324a
3876
ORIGIN: https://github.com/Homebrew/brew
3977
HEAD: 9db324ab7a28446debcb407859c9ac184594a772
@@ -54,3 +92,6 @@ This is my config (on Mac Mini M1):
5492
CLT: 12.3.0.0.1.1607026830
5593
Xcode: N/A
5694
Rosetta 2: false
95+
96+
## More info
97+
* [Workarounds for ARM-based Apple-Silicon Mac](https://github.com/mikelxc/Workarounds-for-ARM-mac)

install_homebrew_native.sh

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
11
#!/bin/bash
22
set -uo pipefail
3-
echo "### $0 from pforret/macos_m1_cli"
3+
echo "### $(basename $0) from pforret/macos_m1_cli Ⓜ️ 1️⃣ "
44

55
die(){
6-
echo "$1" >&2
6+
echo "🟥 $1" >&2
77
tput bel
88
echo "Quitting script!" >&2
99
exit 1
1010
}
1111

12+
progress(){
13+
echo "🍺 $1"
14+
sleep 1
15+
}
16+
1217
if [[ -x "/opt/homebrew/bin/brew" ]] ; then
1318
/opt/homebrew/bin/brew update > /dev/null
1419
/opt/homebrew/bin/brew config | grep VERSION
@@ -21,53 +26,54 @@ fi
2126
[[ $UID -eq 0 ]] && die "You should not be root to run this script"
2227

2328
# first run git to initiate download of developer tools
24-
echo "* If you get a MacOS popup asking to install 'developer tools', please confirm"
25-
git version
29+
progress "If you get a MacOS popup asking to install 'developer tools', please confirm"
30+
git version > /dev/null
2631

27-
echo "* Create a folder for Homebrew ..."
32+
progress "Create a folder for Homebrew ..."
2833
cd /opt && sudo mkdir homebrew
2934
[[ -d "/opt/homebrew" ]] || die "Folder [/opt/homebrew] could not be created"
3035

3136
sudo chown -R "$(whoami)" /opt/homebrew
3237

33-
echo "* Download and install Homebrew from Github ..."
38+
progress "Download and install Homebrew from Github ..."
3439
# cf https://docs.brew.sh/Installation.
35-
curl -L "https://github.com/Homebrew/brew/tarball/master" | tar xz --strip 1 -C homebrew
40+
curl -s -L "https://github.com/Homebrew/brew/tarball/master" | tar xz --strip 1 -C homebrew
3641

3742
[[ -x "/opt/homebrew/bin/brew" ]] || die "Executable [/opt/homebrew/bin/brew] not found"
3843

3944
startup_config(){
4045
comment="#M1HBnat"
41-
echo "## /opt/homebrew is homebrew for native Apple ARM M1 mode $comment"
42-
echo "export PATH=/opt/homebrew/bin:\$PATH $comment"
43-
echo "alias brew1 \"brew --build-from-source\" $comment"
46+
echo "## /opt/homebrew contains homebrew for native Apple ARM M1 mode $comment"
47+
echo "export PATH=\"/opt/homebrew/bin:\$PATH\" $comment"
4448
}
4549

4650
case $(basename "$SHELL") in
4751
zsh)
48-
echo "* Adding [/opt/homebrew/bin] to your zsh startup config path"
52+
progress "Adding [/opt/homebrew/bin] to your zsh startup config path"
4953
startup_config >> ~/.zshrc
5054
;;
5155

5256
bash)
53-
echo "* Adding [/opt/homebrew/bin] to your bash startup config path"
57+
progress "Adding [/opt/homebrew/bin] to your bash startup config path"
5458
startup_config >> ~/.bashrc
5559
;;
5660

5761
*)
58-
echo "Add the following to your shell startup script, could not be done automatically" >&2
62+
progress "Add the following to your shell startup script, could not be done automatically"
5963
echo "#####"
6064
startup_config
6165
echo "#####"
6266
esac
6367

64-
echo "* Running brew a first time to trigger compilation"
68+
progress "Running brew a first time to trigger compilation"
6569
/opt/homebrew/bin/brew install --build-from-source -q awk 2> /dev/null
6670

67-
echo "* Homebrew was installed as native binary. Version will be > 2.6"
71+
progress "Homebrew was installed as native binary. Version will be > 2.6"
6872
/opt/homebrew/bin/brew config | grep VERSION
69-
echo "* Installation using 'brew install' will give a warning as long as Homebrew is not yet officially released for M1"
70-
echo "* You can use 'brew1 install' to always build from source and skip that warning"
71-
echo "* You might get build errors, but remember: you are now doing bleeding edge CLI Terminal!"
73+
echo "#===================================="
74+
progress "Installation using 'brew install' will give a warning as long as Homebrew is not yet officially released for M1"
75+
progress "You can use 'brew install -s' to always build from source and skip that warning"
76+
progress "You might get build errors, but remember: you are an early adopter!"
77+
echo "#===================================="
7278

73-
echo "> Close this Terminal and start a new one to make sure brew is in the path"
79+
progress "Close this terminal and start a new one to make sure brew is in the path"

uninstall_homebrew_native.sh

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,23 @@
11
#!/bin/bash
22
set -uo pipefail
3-
echo "### $0 from pforret/macos_m1_cli"
3+
echo "### $(basename $0) from pforret/macos_m1_cli Ⓜ️ 1️⃣ "
44

55
die(){
6-
echo "$1" >&2
6+
echo "🟥 $1" >&2
77
tput bel
88
echo "Quitting script!" >&2
99
exit 1
1010
}
1111

12+
progress(){
13+
echo "🧽 $1"
14+
sleep 1
15+
}
1216
[[ -x "/opt/homebrew/bin/brew" ]] || die "Homebrew is not installed on [/opt/homebrew]"
1317

1418
# Sanity check, only run on MacOs in native mode
1519
[[ $(uname) == "Darwin" ]] || die "This script should only be run on a MacOS machine"
1620
[[ $(uname -m) == "arm64" ]] || die "This script should only be run in native mode, not with Rosetta 2"
17-
[[ $UID -eq 0 ]] && die "You should not be root to run this script"
18-
19-
echo "* Create a folder for Homebrew ..."
20-
cd /opt && sudo mkdir homebrew
21-
[[ -d "/opt/homebrew" ]] || die "Folder [/opt/homebrew] could not be created"
22-
23-
sudo chown -R "$(whoami)" /opt/homebrew
24-
25-
echo "* Download and install Homebrew from Github ..."
26-
# cf https://docs.brew.sh/Installation.
27-
curl -L "https://github.com/Homebrew/brew/tarball/master" | tar xz --strip 1 -C homebrew
28-
29-
[[ -x "/opt/homebrew/bin/brew" ]] || die "Executable [/opt/homebrew/bin/brew] not found"
3021

3122
remove_from_config(){
3223
comment="#M1HBnat"
@@ -38,19 +29,22 @@ remove_from_config(){
3829

3930
case $(basename "$SHELL") in
4031
zsh)
41-
echo "* Removing [/opt/homebrew/bin] from your zsh startup config path"
32+
progress "Removing [/opt/homebrew/bin] from your zsh startup config path"
4233
remove_from_config ~/.zshrc
4334
;;
4435

4536
bash)
46-
echo "* Removing [/opt/homebrew/bin] from your bash startup config path"
37+
progress "Removing [/opt/homebrew/bin] from your bash startup config path"
4738
remove_from_config ~/.bashrc
4839
;;
4940

5041
*)
51-
echo "* Remove all lines mentioning /opt/homebrew from your startup scripts: " >&2
42+
progress "Remove all lines mentioning /opt/homebrew from your startup scripts: " >&2
5243
sleep 1
5344
esac
5445

55-
echo "* Deleting Homebrew from [/opt/homebrew]"
56-
sudo rm -fr /opt/homebrew
46+
progress "Deleting Homebrew from [/opt/homebrew]"
47+
sudo rm -fr /opt/homebrew
48+
49+
[[ -d "/opt/homebrew" ]] && die "Could not remove [/opt/homebrew]"
50+
progress "Homebrew was uninstalled!"

0 commit comments

Comments
 (0)