RPM / DNFを使用してパッケージをダウンロードまたはインストールする前に、コマンドを実行してください。

RPM / DNFを使用してパッケージをダウンロードまたはインストールする前に、コマンドを実行してください。

apt-getを使用すると、次のことができます。電話する前または後フック

電話する前、電話した後
dpkg(1) 呼び出しの前後に実行されるシェルコマンドのリストです。オプションと同様に、リスト表記で指定する必要があります。コマンドを順次呼び出すには、/bin/sh を使用します。 APTは失敗すると中断されます。

また、見ることができますスクリプトをapt-getにリンクします。

インストールの前後にコマンドを実行する同様の方法はありますか?すべてRPMまたはDNFを含むパッケージ?

もちろん、rpmやdnfコマンドを別のスクリプトにラップするのも1つの方法ですが、私はいくつかの設定オプションをしたいと思います。

ベストアンサー1

yum(RHEL / CentOS 7以下)の場合yum-plugin-pre-transaction-actionsyum-plugin-post-transaction-actionsパッケージがあります。使用方法の例事前取引そして取引後ただし、これはサンプルファイルでもあります。

#action_key:transaction_state:command
# action_key can be: pkgglob, /path/to/file (wildcards allowed)
# transaction_state can be: install,update,remove,any
# command can be: any shell command
#  the following variables are allowed to be passed to any command:
#   $name - package name
#   $arch - package arch
#   $ver - package version
#   $rel - package release
#   $epoch - package epoch
#   $repoid - package repository id
#   $state - text string of state of the package in the transaction set
#
# file matches cannot be used with removes b/c we don't have the info available

*:install:touch /tmp/$name-installed
zsh:remove:touch /tmp/zsh-removed
zsh:install:touch /tmp/zsh-installed-also
/bin/z*h:install:touch /tmp/bin-zsh-installed
z*h:any:touch /tmp/bin-zsh-any

# each action is expanded once for each matching package, and no action is
# executed twice per transaction, for example
*:install:echo $repoid >>/tmp/repos
# will write each repo only once to /tmp/repos, even if multiple packages from
# the same repo were installed

dnf(RHEL / CentOS 8以降)の場合、次の場所にプラグインがあります。https://github.com/rpm-software-management/dnf-plugins-core/blob/master/plugins/post-transaction-actions.py取引後は適用されますが、取引前には影響しません。https://bugzilla.redhat.com/show_bug.cgi?id=967264そしてhttps://bugzilla.redhat.com/show_bug.cgi?id=1788574より多くの情報があります。 RHEL 8.2にはトランザクション後機能が必要です。事前取引が本当に必要な場合は、取引後のコードを修正して独自の事前取引プラグインを作成し、それをPRに送信できます。

おすすめ記事