大体功能就是对指定目录下的rpm文件进行检索,把每个rpm文件的信息存储到指定的索引文件中,这样方便远程yum命令在安装更新时进行检索。
看下createrepo支持的几个参数:
=================================
-u --baseurl <url>
-c --cachedir <path>
-p --pretty
createrepo生成四个文件:
repodata/filelists.xml.gz
关于这几个文件的描述是:
- repomd.xml this is the file that describes theother metadata files. It is like an index file to point to theother files. It contains timestamps and checksums for the otherfiles. This lets a client download this one, small file and know ifanything else has changed. This also means that cryptographically(ex: gpg) signing this one file can ensure repositoryintegrity.
- primary.xml.[gz] this file stores the primarymetadata information. This includes information such as:
- name, epoch, version, release, architecture
- file size, file location, description, summary, format,checksums header byte-ranges, etc.
- dependencies, provides, conflicts, obsoletes, suggests,recommends
- file lists for the package for CERTAIN files - specificallyfiles matching: /etc*, *bin/*, /usr/lib/sendmail [1]
- filelists.xml.[gz] this file stores thecomplete file and directory listings for the packages. The packageis identified by: name, epoch, version, release, architecture andpackage checksum id.
- other.xml.[gz] this file currently onlystores the changelog data from packages. However, this file couldbe used for any other additional metadata that could be useful forclients.
- groups.xml.[gz] this file is tentativelydescribed. The intention is for a common package-groupsspecification as well. There is still some sections for this formatthat need to be fleshed out.
其实我们需要记住的就是primary.xml.gz存储的是包列表,而filelist.xml存储的是所有包的目录和文件列表。
也就是说如果createrepo成功创建索引后,包的信息和每个包的文件信息都会存储在这两个文件中。
当然,如果你在执行createrepo时添加了-d 参数的话,createrepo会对
filelist.xml.gz,primary.xml.gz和other.xml.gz各自生成一个sqlite的文件(或者压缩文件)。
其中用sqlite格式存储了对应xml文件中的信息。
然后当你在客户端执行 yum clean all ,yum list 之后,这些索引文件就会下载到客户端。
默认的cache目录是:/var/cache/yum,里面按照不同的repo再分目录了,比如 rhel,test等等。
createrepo默认会生成的文件有:
filelists.xml.gz
经过索引下载后,在客户端的cache中会生成索引文件:
cachecookie
如果采用了 -d 参数的话,createrepo会生成的文件有:
filelists.sqlite.bz2
客户端更新后,索引文件有:
cachecookie
我们可以看到,如果采用sqlite的db来存储的话,yum会把filelist,primary和other文件的信息都存储到
Sqlite的db文件primary.sqlite中。
查看primary.sqlite文件:
sqlite3 /var/cache/yum/ops.5Server.x86_64/primary.sqlite
运行 ".table"命令,查看表列表:
sqlite> .table
conflicts
可以看到包的所有信息都存储在这几个表当中了。
我们可以做个测试,查询下packages表中的信息:
select * from packages where name ='tops-cmos' and version ='1.1.0';
输出如下:
155|ece7d2540f36adec0b098c22
继续以packages表为例,能够看到这个表的字段有:
.schema packages
CREATE TABLE packages (
看到了这个表的所有字段,这些字段描述了一个rpm文件的主要信息。然后你就可以根据这些字段做条件查询了。
.schema files
CREATE TABLE files (
也能够看到file与pkg的关联关系,有个外键是pkgKey.
.schema conflicts
CREATE TABLE conflicts (
conflicts表的信息.
CREATE TABLE obsoletes (
包废除表的信息.
.schema provides
CREATE TABLE provides (
CREATE INDEX pkgprovides on provides (pkgKey);
CREATE INDEX providesname ON provides (name);
provides表的信息。
.schema requires
CREATE TABLE requires (
CREATE INDEX pkgrequires on requires (pkgKey);
CREATE INDEX requiresname ON requires (name);
requires表的信息。
其余这几个表都是以packages表为基础,来补充存储rpm包的信息,比如prides,require,obsolete等信息。
如果你做一个程序,能够生成同样的数据文件,基本上就实现了createrepo在带-d参数时的效果。
知道了这些信息,当你的yum服务出现问题时,比如包不能更新,版本不对等问题时,就能通过这些文件来查找问题的原因。