OSLinux redhat4 2.6.9-78.ELsmp (i386)
RPM:(我使用的是Centosyum软件包)
centos-yumconf_4-4.3_noarch.rpm (i386)
python-sqlite_1.1.6-1_i386.rpm    (i386)   
sqlite_3.2.2-1_i386.rpm (i386)
python-elementtree_1.2.6-4_i386.rpm  (i386)
python-urlgrabber_2.9.6-2_noarch.rpm  (i386)
yum_2.4.0-1.centos4_noarch.rpm (i386)
createrepo-0.4.6-1.el4.rf.noarch.rpm (i386)
 
1.安装上面所有的软件包,会在/etc目录下有个三个文件: “yum”  “yum.conf “  “/etc/yum.repos.d”
 
2.  建立一个目录,用于存放本地源的仓库
#mkdir –p /mnt/localhost/RPMS
 
21 OS光盘中的所有的RPM软件,全部COPY/mnt/localhost/RPMS
 #cp –a /media/cdrom/RedHat/RPMS /mnt/localhost/RPMS
 
3.  生成 依赖性关系
 #createrepo /mnt/localhost/RPMS  (这个会时间比较长)
     注意,如果有新的软件加入到了这目录,那么就要重新执行一下这个命令。还有一点,如果是使用网络源,那么这条命令可以省略
 
4.  修改/etc/yum.repos.d/ CentOS-Base.repo
 
5.     #vi /etc/yum.repos.d/ CentOS-Base.repo

内容如下:
[base]
name=redhat4 - Base
baseurl=file:///mnt/localhost/RPMS/
enabled=1
gpgcheck=1
gpgkey=file:///mnt/localhost/RPMS/RPM-GPG-KEY-redhat-release
 
#released updates
[update]
name=redhat4- Updates
baseurl=file:///mnt/localhost/RPMS/
enabled=1(是否 开启源) 1:开启
gpgcheck=1(是否 验证,可不要) 1:需要
gpgkey=file:///mnt/localhost/RPMS/RPM-GPG-KEY-redhat-release (验证的密钥,可不要)
 
注意:gpgkey=file:///mnt/localhost/RPMS/RPM-GPG-KEY-redhat-release 这一段可以不要,如果要用也可以使用命令直接导入:rpm –import /mnt/localhost/RPMS/RPM-GPG-KEY
RPM-GPG-KEY 这个KEY在系统安装盘中有
 
6. 修改配置文件 /etc/yum.conf
#vi /etc/yum.conf
内容:
[base]
name=redhat4 - Base
baseurl=file:///mnt/localhost/RPMS/
enabled=1
gpgcheck=1
gpgkey=file:///mnt/localhost/RPMS/RPM-GPG-KEY-redhat-release
 
#released updates
[update]
name=redhat4- Updates
baseurl=file:///mnt/localhost/RPMS/
enabled=1
gpgcheck=1
gpgkey=file:///mnt/localhost/RPMS/RPM-GPG-KEY-redhat-release
 
注:也就是在现在的文件中加上一步在vi /etc/yum.repos.d/ CentOS-Base.repo 中的内容
 
7.基本完成!
 
8. 测试
# yum install uucp-1.07-8.RHEL4.i386.rpm
Repository base is listed more than once in the configuration
Repository update is listed more than once in the configuration
Setting up Install Process
Setting up repositories
base                      100% |=========================|  951 B    00:00
update                    100% |=========================|  951 B    00:00
Reading repository metadata in from local files
Parsing package install arguments
Examining uucp-1.07-8.RHEL4.i386.rpm: uucp - 1.07-8.RHEL4.i386
Marking uucp-1.07-8.RHEL4.i386.rpm to be installed
Resolving Dependencies
--> Populating transaction set with selected packages. Please wait.
---> Package uucp.i386 0:1.07-8.RHEL4 set to be updated
--> Running transaction check
 
Dependencies Resolved
 
=============================================================================
 Package                 Arch       Version          Repository        Size
=============================================================================
Installing:
 uucp                    i386       1.07-8.RHEL4     uucp-1.07-8.RHEL4.i386.rpm  5.2 M
 
Transaction Summary
=============================================================================
Install      1 Package(s)
Update       0 Package(s)
Remove       0 Package(s)
Total download size: 5.2 M
Is this ok [y/N]: y
Downloading Packages:
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing: uucp                         ######################### [1/1]
 
Installed: uucp.i386 0:1.07-8.RHEL4
Complete!
 
OK!