Linuxメモ : Rust製のtopgradeでシステムを最新状態にアップデート
topgrade
Rust製のtopgradeはシステムにインストールされているパッケージなどを自動で判定してアップデートしてくれるコマンドラインツール。
アップデート対象はStep listに記述がある。

インストール
README.mdのインストール方法によるとcargoやバイナリのダウンロードなどでインストールできる。
$ cargo install topgrade
ヘルプメッセージ。
$ topgrade --help
Topgrade 4.3.1
Command line arguments
USAGE:
topgrade [FLAGS] [OPTIONS]
FLAGS:
-c, --cleanup Cleanup temporary or old files
--disable-predefined-git-repos Don't pull the predefined git repos
-n, --dry-run Print what would be done
--edit-config Edit the configuration file
-h, --help Prints help information
-k, --keep Prompt for a key before exiting
--no-retry Do not ask to retry failed steps
-t, --tmux Run inside tmux
-V, --version Prints version information
-v, --verbose Output logs
-y, --yes Say yes to package manager's prompt (experimental)
OPTIONS:
--disable <disable>... Do not perform upgrades for the given steps [possible values: system,
package_managers, git_repos, vim, emacs, gem,
node, composer, sdkman, remotes, rustup,
cargo, flutter, go, shell, opam, vcpkg,
pipx, stack, tlmgr, myrepos, pearl, jetpack,
atom, firmware, restarts, tldr]
--only <only>... Perform only the specified steps (experimental) [possible values: system,
package_managers, git_repos, vim, emacs, gem,
node, composer, sdkman, remotes, rustup,
cargo, flutter, go, shell, opam, vcpkg,
pipx, stack, tlmgr, myrepos, pearl, jetpack,
atom, firmware, restarts, tldr]
使い方
topgradeコマンドを実行するとアップデートが開始されるので、まずは-nまたは--dry-runオプションでドライランしてみるとよい。
環境に応じて結果は異なるが、表示されたアップデートコマンドが順次実行されていく。
$ topgrade -n ―― 00:12:55 - System update ―――――――――――――――――――――――――――――――――――――――――――――――――――― Dry running: /usr/bin/sudo /usr/bin/yum upgrade ―― 00:12:55 - rustup ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― Dry running: /home/vagrant/.cargo/bin/rustup self update Dry running: /home/vagrant/.cargo/bin/rustup update ―― 00:12:55 - Neovim (Plug) ―――――――――――――――――――――――――――――――――――――――――――――――――――― Dry running: /usr/local/bin/nvim -N -u /home/vagrant/.config/nvim/init.vim -c PlugUpgrade | PlugUpdate -c quitall -e -s -V1 ―― 00:12:56 - Yarn ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― Dry running: /usr/bin/yarn global upgrade -s ―― 00:12:56 - RubyGems ――――――――――――――――――――――――――――――――――――――――――――――――――――――――― Dry running: /home/vagrant/.rbenv/shims/gem update --user-install ―― 00:12:56 - Summary ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― System update: OK rustup: OK Neovim: OK yarn: OK gem: OK
アップデートしたくない対象があれば、--onlyオプションでアップデート対象を指定するか、
$ topgrade -n --only system ―― 00:17:31 - System update ―――――――――――――――――――――――――――――――――――――――――――――――――――― Dry running: /usr/bin/sudo /usr/bin/yum upgrade ―― 00:17:31 - Summary ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― System update: OK
--disableオプションでアップデートしたくない対象を指定するとよい。
$ topgrade -n --disable gem node rustup ―― 00:20:39 - System update ―――――――――――――――――――――――――――――――――――――――――――――――――――― Dry running: /usr/bin/sudo /usr/bin/yum upgrade ―― 00:20:39 - Neovim (Plug) ―――――――――――――――――――――――――――――――――――――――――――――――――――― Dry running: /usr/local/bin/nvim -N -u /home/vagrant/.config/nvim/init.vim -c PlugUpgrade | PlugUpdate -c quitall -e -s -V1 ―― 00:20:39 - Summary ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― System update: OK Neovim: OK
設定
設定を変更したい場合はtopgrade --edit-configを実行する。
設定ファイルの例はGitHubを参照。
例えば、--onlyオプションのアップデート対象を以下のように指定できる。
# Run specific steps - same options as the command line flag only = ["system", "vim"]