yumはYUM0環境変数を選択しません。

yumはYUM0環境変数を選択しません。

私の(docker)centos環境に環境変数を設定しました。

[arman@7b33ffd8619e ~]$ echo $YUM0
yumrepo.myhost.com

echoこれはコマンドの前にsudo

~によるとセントース文書;

$おいしい0-9これは、同じ名前のシェル環境変数の値に置き換えられます。シェル環境変数が存在しない場合、構成ファイル変数は置き換えられません。

yumただし、コンテナから何かをインストールしようとすると、環境変数が選択されていないことを示すエラーメッセージが表示されますyum

[arman@7b33ffd8619e ~]$ sudo yum install less
Loaded plugins: fastestmirror
http://$YUM0/x86_64/centos/7.2.1511/base/repodata/repomd.xml: [Errno 14] curl#6 - "Could not resolve host: $YUM0; Name or service not known"
Trying other mirror.


 One of the configured repositories failed (centos),
 and yum doesn't have enough cached data to continue. At this point the only
 safe thing yum can do is fail. There are a few ways to work "fix" this:

     1. Contact the upstream for the repository and get them to fix the problem.

     2. Reconfigure the baseurl/etc. for the repository, to point to a working
        upstream. This is most often useful if you are using a newer
        distribution release than is supported by the repository (and the
        packages for the previous distribution release still work).

     3. Disable the repository, so yum won't use it by default. Yum will then
        just ignore the repository until you permanently enable it again or use
        --enablerepo for temporary usage:

            yum-config-manager --disable centos

     4. Configure the failing repository to be skipped, if it is unavailable.
        Note that yum will try to contact the repo. when it runs most commands,
        so will have to try and fail each time (and thus. yum will be be much
        slower). If it is a very temporary problem though, this is often a nice
        compromise:

            yum-config-manager --save --setopt=centos.skip_if_unavailable=true

failure: repodata/repomd.xml from centos: [Errno 256] No more mirrors to try.
http://$YUM0/x86_64/centos/7.2.1511/base/repodata/repomd.xml: [Errno 14] curl#6 - "Could not resolve host: $YUM0; Name or service not known"

次のバージョンを実行しています。

[arman.schwarz@7b33ffd8619e ~]$ cat /etc/centos-release
CentOS Linux release 7.2.1511 (Core)
[arman.schwarz@7b33ffd8619e ~]$ yum --version
3.4.3

環境変数に依存するのではなく、リポジトリ名を使用するように自分の.repoファイルを手動で変更すると、インストールに問題は発生せず、これはリポジトリ自体に問題がないことを証明します。/etc/yum.repos.dyum

実行しexport YUM0=yumrepo.myhost.comても効果はありません。

YUM0環境変数を有効にする方法はyum

ベストアンサー1

基本的に、sudoリセット環境実行されるコマンドについて。 YUM0変数も設定しない限り、これにはYUM0変数が含まれますenv_keep

sudo を使用してコマンドを実行するには、次のように実行します。

sudo YUM0=yumrepo.myhost.com yum ...rest of the command...

sudo の実行時に変数の値が設定されます。

あるいは、sudoルールで許可されている場合は、残りのコマンドを呼び出す前にシェルを起動して変数を設定できます。

sudo sh -c "YUM0=$YUM0; yum ... rest of the command ..."

二重引用符を使用すると、内部YUM0変数を外部(現在の)シェルのYUM0値に設定できるためです。

おすすめ記事