Open h-sendai opened 3 years ago
yum update, yum-cron /etc/yum-cron.confの動作について
daqmw-rpm installの動作としては、
という手順になっている。
uninstallは 1.スクリプト内でDAQ-Middlewareセットアップの際依存物として入るであろうライブラリを列挙してあってそれをみてrpm -eでパッケージを消去
という動作。
commit 07230960e5ced814a8717d3e6e92109f23b05b47 でawkを使って実装してみたがsedでもいいかもしれない
grepでyum.confにexcludeがあったら
sed -e '/^exclude/ s/$/ omniORB*/' txt
消す方は
sed -e '/^exclude/ s/omniORB\*//' txt
と思ったが、消したあとexclude=だけになった場合はこの行を消しておきたい。sedでできるのか?
あんまりむずかしく考えすぎたか。
sed -e '/^exclude[[:space:]]*=/ s/omniORB//' -e '/^exclude[[:space:]]*=[[:space:]]*$/d' yum.conf
でできそうだ(regexで+を使いたい場合は-E (use extended regex)が必要だがここでは必要なかった)
sedでの実装
==> add-omniorb.grep-sed <==
#!/bin/sh
add_omniorb()
{
local conf_file
for i in $*; do
conf_file=$i
if grep -q '^exclude[[:space:]]*=' $conf_file; then
if grep -q '^exclude[[:space:]]*=.*omniORB.*' $conf_file; then
: # do nothing
else
sed -i.bak -e '/^exclude[[:space:]]*=/ s/$/ omniORB*/' $conf_file
fi
else
echo 'exclude = omniORB*' >> $conf_file
fi
done
}
add_omniorb yum.conf
==> remove-omniorb.grep-sed <==
#!/bin/sh
remove_omniorb()
{
local conf_file
for i in $*; do
conf_file=$i
if grep -q '^exclude[[:space:]]*=.*omniORB.*' $conf_file; then
# 1. remove omniORB*
# 2. remove exclude = if RHS is empty
# 3. remove trailing spaces such that 'exclude = kernel grub2_' (_ is a space)
sed -E -i.bak -e '/^exclude[[:space:]]*=/ s/omniORB\*//g' \
-e '/^exclude[[:space:]]*=[[:space:]]*$/d' \
-e '/^exclude[[:space:]]*=/ s/[[:space:]]+$//' \
$conf_file
fi
done
}
remove_omniorb yum.conf
/RE/d
で削除するときのREがちょっと短くなる。#!/bin/sh
remove_omniorb()
{
local conf_file
for i in $*; do
conf_file=$i
if egrep -q '^exclude[[:space:]]*=.*omniORB.*' $conf_file; then
# 1. remove omniORB*
# 2. remove trailing spaces such that 'exclude = kernel grub2__' (_ is a space)
# 3. remove the exclude line if the RHS is empty
sed -E -i.bak '
/^exclude[[:space:]]*=/ s/omniORB\*//g
/^exclude[[:space:]]*=/ s/[[:space:]]+$//
/^exclude[[:space:]]*=$/d
' $conf_file
fi
done
}
remove_omniorb yum.conf
CentOS/Scientific Linuxをセットしたときにsedとかawkとかがはいっているのかいう疑問があったので調査してみた。
現在のDAQ-MiddlewareはomniORB 4.1.7を依存ライブラリとしている。daqmw-rpm installを実行するとdaqmw.kek.jpからomniORBをダウンロードしてインストールする。DAQ-Middleware RPMパッケージではomniORBのバージョンを 4.1.x以下としてピンニングしている。 EPELにはomniORB 4.2.0があるがこれは使わない。一方EPELにはROOTパッケージがあるのでROOTのセットアップには
を実行後、yum install rootとするのが楽であるし確実である。
yumデフォルトの設定ではyum updateあるいはanacronを通じて実行されるyum-cron /etc/yum/yum-cron.confが実行されるとyumはomniORBの新しいバージョンのパッケージ4.2.0を発見しupdateを試みるが、DAQ-MiddlewareがomniORBは4.1.x、とピンニングしているのでyum updateあるいはyum-cron全体が失敗し異常終了する。
EPELが有効になっていてもyum updateあるいはyum-cron /etc/yum/yum-cron.confが正常終了するように設定ファイルにexclude=omniORB*を入れることを考える。