[Tomoyo-dev 284] Re: レポジトリの作成について

Back to archive index

Tetsuo Handa from-****@I-lov*****
2007年 7月 16日 (月) 15:53:06 JST


 熊猫です。

> > rpm ファイルを要求されたら HTTP 302 を返すように指定すれば yum は追いかけてくれるのかな?
> うーん。そういう変な挙動に依存するのは止めといた方がいいと思いますねぇ・・・。
 一応試してみました。
CentOS 4.5 で試したところ、 yum は HTTP 302 を追いかけてくれました。以下が手順です。


パッケージ名を ccs-kernel にしてバイナリパッケージを作成する。

[root @ tomoyo ~]# cat > test.spec << EOF
Summary: ccs-kernel test
Name: ccs-kernel
Group: System Environment/Kernel
License: GPLv2
Version: 1
Release: 0
ExclusiveArch: i586
ExclusiveOS: Linux

%description
ccs-kernel install test

%files

%changelog
EOF
[root @ tomoyo ~]# rpmbuild -bb --target i586 test.spec

yum のレポジトリを作成する。

[root @ tomoyo ~]# createrepo /usr/src/redhat/RPMS/i586/

レポジトリを Web サーバからアクセスできる場所に移動する。

[root @ tomoyo ~]# mv /usr/src/redhat/RPMS/i586/* /var/www/html/repos/

移動後のファイル一覧は以下の通り。

[root @ tomoyo ~]# find /var/www/html/repos/
/var/www/html/repos/
/var/www/html/repos/repodata
/var/www/html/repos/repodata/repomd.xml
/var/www/html/repos/repodata/primary.xml.gz
/var/www/html/repos/repodata/filelists.xml.gz
/var/www/html/repos/repodata/other.xml.gz
/var/www/html/repos/ccs-kernel-1-0.i586.rpm

ここで、 /var/www/html/repos/ccs-kernel-1-0.i586.rpm を別サーバに移動させ、
代わりに HTTP 302 を返すための cgi を作成する。

[root @ tomoyo ~]# cat /var/www/html/repos/ccs-kernel-1-0.i586.rpm
#! /usr/bin/perl
print "Location: http://I-love.sakura.ne.jp/test/ccs-kernel-1-0.i586.rpm\n\n";

ccs-kernel-1-0.i586.rpm を CGI として実行するための設定を追加する。

[root @ tomoyo ~]# tail -4 /etc/httpd/conf/httpd.conf
<Directory "/var/www/html/repos/">
    Options ExecCGI
    AddHandler cgi-script .rpm
</Directory>

Apache を再起動すればサーバ側の設定は完了。

クライアント側で、 yum のレポジトリの場所を指定する。

[root @ tomoyo ~]# tail -4 /etc/yum.repos.d/CentOS-Base.repo
[ccs-kernel]
name=ccs-kernel
baseurl=http://localhost/repos/
gpgcheck=0

インストールは以下のようにコマンドを実行する。

[root @ tomoyo ~]# yum -y install ccs-kernel

yum が http://localhost/repos/repoata/ を解釈して
http://localhost/repos/ccs-kernel-1-0.i586.rpm を要求するが、
Apache が http://I-love.sakura.ne.jp/test/ccs-kernel-1-0.i586.rpm にあると返事するために
yum は http://I-love.sakura.ne.jp/test/ccs-kernel-1-0.i586.rpm を取得してインストールする。

createrepo の実行後に rpm の実体を perl の cgi に置き換える必要がある点がちょっと面倒ですね。




tomoyo-dev メーリングリストの案内
Back to archive index