はじめに
とりあえず M1 MacBook Air を使い出して、特に問題なく運用しています。2月5日に Homebrew が 3.0 になって Apple Silicon に正式対応したので、bootstrap スクリプトおよび Homebrew の Formula を見直してみます。また、せっかくなのでインストールアプリ一覧を「はてなブログの記事」から Notion データベースに引越して、こちらを公開しようと思います。
インストール一覧の引越
前回作成したインストールソフトウェア一覧の記事はここにあります(M1 MacBook Air インストールアプリケーション一覧 - M1 MacBook Air インストール覚書(番外編) - hkob’s blog)。 これはただのブログの記事なので、更新が面倒でその後ちゃんと更新していませんでした。 そんなわけで、現在利用中の Notion データベースに移行し、そのページを公開しようと思います。
まず、上記のページの表を全部選択して、クリップボードにコピーします。
Numbers に貼り付けます。
CSV に書き出します。
適当にファイル名を付けます。保存が終わったら、Numbers のファイルは必要ないので、削除します。
Notion で Import をクリックします。
CSV を選択します。
arch の部分は select になっていましたが、導入方法の部分は select になっていませんでした。ここも select にしておきます。
Share を押すとページを公開できます。
「Share to web」で Web に公開します。参考になるかわかりませんが、一応 template でも配布できるようにしておきます。
これが公開されたページになります。
bootstrap.sh の見直しと既存アプリのアンインストール
対応前は直接 tarball を展開していたので、その部分をインストーラに直してみます。
# M1 Mac では /opt/homebrew にネイティブ版をインストール if is_arm; then echo "Installing homebrew in /opt/homebrew for Arm ..." # 以前は対応していなかったので直接展開していたが、Homebrew 3.0 になって Apple Silicon に対応 # cd /opt # sudo mkdir homebrew # sudo chown $USER:admin homebrew # curl -L https://github.com/Homebrew/brew/tarball/master | tar xz --strip 1 -C homebrew /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" # M1 の場合には、Rosetta2 版の brew を brew_x86 という名前で実行できるようにしておく cd /usr/local/bin ln -s /usr/local/Homebrew/bin/brew brew_x86 # この順番でいくと、PATH は 「/opt/homebrew/bin:/usr/local/bin:それ以外」になることを期待している。これは実行してみないとわからない fi
また、bottle が対応していなかったため、これまで "build_from_source" でソースからコンパイルしていました。すでにかなりのパッケージが bottle 対応になっているので、これも全て直していきたいです。色々と混ざっていると面倒なので、一度インストールしたものを全てアンインストールして一つずつ確認していこうと思います。
とりあえず現在の brew list を示します。
hkob@hM1Air ~/dotfiles (master)> brew list (base) ansible icu4c node apr ilmbase nspr apr-util jansson nss autoconf jasper openjpeg automake jemalloc openssl@1.1 bdw-gc jpeg overmind bison jxrlib p11-kit c-ares krb5 pango cairo libatomic_ops pcre carthage libcerf pcre2 cask libev perl cmake libevent pixman doxygen libffi pkg-config emacs libidn2 plantuml-zulu11 fish libpng poppler fontconfig librsvg-arm64 postgresql foreman libssh2 protobuf freetype libtasn1 python@3.9 fribidi libtiff qt gd libtool qt-arm64 gdbm libunistring rbenv gdk-pixbuf libyaml readline gettext little-cms2 ruby-build ghostscript lua scons glib lz4 sphinx-doc gmp lzo sqlite gnu-sed mackup subversion gnuplot-arm64 meson swig gnutls mitmproxy tcl-tk gobject-introspection ncurses tmux graphite2 netpbm unbound graphviz-arm64 nettle utf8proc gts nghttp2 webp guile ninja xz harfbuzz nkf yarn 1password mactex-no-gui abyssoft-teleport microsoft-teams adobe-acrobat-reader miniforge alfred musescore appcleaner mysqlworkbench eclipse-java notion findergo omnigraffle firefox powershell font-hackgen rubymine google-chrome skim grandperspective slack-arm64 graphicconverter sourcetree iterm2 syncroom karabiner-elements visual-studio-code-insiders-arm64 latexit xquartz libreoffice zoom logisim-evolution zulu11-arm64
cask なども全部アンインストールするので、iTerm2 ではなくターミナル、Notion も Safari からブラウザベースでアクセスするように準備をします。fish もなくなるので、bash から以下のコマンドを実行します。
brew uninstall `brew list`
依存関係で削除できないものがあるので、再度実行すると全て削除できました。
次に intel 版の方の formula と cask も削除します。homebrew が古いせいか --formula を付けないとリストが出ませんでした。
arch -x86_64 bash brew_x86 uninstall `brew_x86 list --formula`
openssl@1.1 の一部のファイルがアンインストールされていないと出てきました。手動でアンインストールしておきます。
rm -rf /usr/local/etc/openssl\@1.1
とりあえず、arm_brew/Brewfile と rosetta2_brew/Brewfile を全てコメントアウトしておきます。
vi arm_brew/Brewfile rosetta2_brew/Brewfile
brew コマンドがあると Homebrew が更新されないので、brew を消しておきます。
rm /opt/homebrew/bin/brew /usr/local/bin/brew
Homebrew 本体のインストール
Homebrew 本体のインストール直後で「exit」を入れておいて、そこまでの動作を確認します。
hkob@hM1Air dotfiles % ./bootstrap.sh /Users/hkob/dotfiles already downloaded. Deploying dotfiles ... /Users/hkob/.gitignore -> /Users/hkob/dotfiles/.gitignore /Users/hkob/.gitignore~ -> /Users/hkob/dotfiles/.gitignore~ /Users/hkob/.mackup.cfg -> /Users/hkob/dotfiles/.mackup.cfg /Users/hkob/.vim -> /Users/hkob/dotfiles/.vim /Users/hkob/.vimrc -> /Users/hkob/dotfiles/.vimrc /Users/hkob/.vimrc.org -> /Users/hkob/dotfiles/.vimrc.org Installing homebrew in /usr/local for Intel or Rosetta2 ... Password: ==> This script will install: /usr/local/bin/brew /usr/local/share/doc/homebrew /usr/local/share/man/man1/brew.1 /usr/local/share/zsh/site-functions/_brew /usr/local/etc/bash_completion.d/brew /usr/local/Homebrew ==> The following existing directories will be made writable by user only: /usr/local/share/zsh /usr/local/share/zsh/site-functions ==> The Xcode Command Line Tools will be installed. Press RETURN to continue or any other key to abort ==> /usr/bin/sudo /bin/chmod u+rwx /usr/local/share/zsh /usr/local/share/zsh/site-functions ==> /usr/bin/sudo /bin/chmod 755 /usr/local/share/zsh /usr/local/share/zsh/site-functions ==> /usr/bin/sudo /usr/sbin/chown -R hkob:admin /usr/local/Homebrew ==> Searching online for the Command Line Tools ==> /usr/bin/sudo /usr/bin/touch /tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress ==> Installing Command Line Tools for Xcode-12.4 ==> /usr/bin/sudo /usr/sbin/softwareupdate -i Command\ Line\ Tools\ for\ Xcode-12.4 Software Update Tool Finding available software Downloading Command Line Tools for Xcode Downloaded Command Line Tools for Xcode Installing Command Line Tools for Xcode Done with Command Line Tools for Xcode Done. ==> /usr/bin/sudo /bin/rm -f /tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress ==> /usr/bin/sudo /usr/bin/xcode-select --switch /Library/Developer/CommandLineTools ==> Downloading and installing Homebrew... remote: Enumerating objects: 2997, done. remote: Counting objects: 100% (2997/2997), done. remote: Total 7840 (delta 2996), reused 2997 (delta 2996), pack-reused 4843 Receiving objects: 100% (7840/7840), 2.18 MiB | 1.94 MiB/s, done. Resolving deltas: 100% (6001/6001), completed with 796 local objects. From https://github.com/Homebrew/brew 993bf9587..320bccb38 master -> origin/master * [new branch] dependabot/bundler/Library/Homebrew/sorbet-0.5.6287 -> origin/dependabot/bundler/Library/Homebrew/sorbet-0.5.6287 * [new tag] 2.7.1 -> 2.7.1 * [new tag] 2.7.2 -> 2.7.2 * [new tag] 2.7.3 -> 2.7.3 * [new tag] 2.7.4 -> 2.7.4 * [new tag] 2.7.5 -> 2.7.5 * [new tag] 2.7.6 -> 2.7.6 * [new tag] 2.7.7 -> 2.7.7 * [new tag] 3.0.0 -> 3.0.0 * [new tag] 3.0.1 -> 3.0.1 HEAD is now at 320bccb38 Merge pull request #10594 from Bo98/consistent-alignment (中略) ==> Installation successful! ==> Homebrew has enabled anonymous aggregate formulae and cask analytics. Read the analytics documentation (and how to opt-out) here: https://docs.brew.sh/Analytics No analytics data has been sent yet (or will be during this `install` run). ==> Homebrew is run entirely by unpaid volunteers. Please consider donating: https://github.com/Homebrew/brew#donations ==> Next steps: - Run `brew help` to get started - Further documentation: https://docs.brew.sh Installing homebrew in /opt/homebrew for Arm ... Password: ==> This script will install: /opt/homebrew/bin/brew /opt/homebrew/share/doc/homebrew /opt/homebrew/share/man/man1/brew.1 /opt/homebrew/share/zsh/site-functions/_brew /opt/homebrew/etc/bash_completion.d/brew /opt/homebrew Press RETURN to continue or any other key to abort ==> /usr/bin/sudo /usr/sbin/chown -R hkob:admin /opt/homebrew ==> Downloading and installing Homebrew... remote: Enumerating objects: 14, done. remote: Counting objects: 100% (14/14), done. remote: Total 20 (delta 14), reused 14 (delta 14), pack-reused 6 Unpacking objects: 100% (20/20), done. From https://github.com/Homebrew/brew * [new branch] dependabot/bundler/Library/Homebrew/sorbet-0.5.6287 -> origin/dependabot/bundler/Library/Homebrew/sorbet-0.5.6287 HEAD is now at 320bccb38 Merge pull request #10594 from Bo98/consistent-alignment (中略) ==> Installation successful! ==> Homebrew has enabled anonymous aggregate formulae and cask analytics. Read the analytics documentation (and how to opt-out) here: https://docs.brew.sh/Analytics No analytics data has been sent yet (or will be during this `install` run). ==> Homebrew is run entirely by unpaid volunteers. Please consider donating: https://github.com/Homebrew/brew#donations ==> Next steps: - Add Homebrew to your PATH in /Users/hkob/.zprofile: echo 'eval $(/opt/homebrew/bin/brew shellenv)' >> /Users/hkob/.zprofile eval $(/opt/homebrew/bin/brew shellenv) - Run `brew help` to get started - Further documentation: https://docs.brew.sh
Homebrew 本体は無事にインストールできました。あとは、一つずつチェックしていきます。詳細は Notion の記事に掲載します。
とりあえず記事としてはここまで。
(2/15 追記) dotfiles 内の Brewfile 更新ごとに自動でアプリインストールが確認できるように chokidar を動かすと楽でした。
chokidar arm_brew/Brewfile -c ./bootstrap.sh