h-sendai / daqmw-rpm

0 stars 0 forks source link

EPELリポジトリを有効にしている場合の対処 #1

Open h-sendai opened 3 years ago

h-sendai commented 3 years ago

現在の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 epel-release

を実行後、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*を入れることを考える。

h-sendai commented 3 years ago

yum update, yum-cron /etc/yum-cron.confの動作について

h-sendai commented 3 years ago

daqmw-rpm installの動作としては、

  1. まずdo_distcleanを実行してきれいな状態にする
  2. daqmw用repoファイルをrpmコマンドで入れる
  3. daqmw用repoファイルを有効にしてyum install DAQ-Middlewareを実行

という手順になっている。

uninstallは 1.スクリプト内でDAQ-Middlewareセットアップの際依存物として入るであろうライブラリを列挙してあってそれをみてrpm -eでパッケージを消去

という動作。

h-sendai commented 3 years ago

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)が必要だがここでは必要なかった)

h-sendai commented 3 years ago

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
h-sendai commented 3 years ago
#!/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
h-sendai commented 3 years ago

CentOS/Scientific Linuxをセットしたときにsedとかawkとかがはいっているのかいう疑問があったので調査してみた。