当前位置:Linux教程 - 杂项工具 - 杂项工具 - apt server

杂项工具 - apt server

apt server
2004-04-23 15:18 pm
来自:Linux文档
现载:Www.8s8s.coM
地址:无名

前言
RPM 会有烦人的 Dependence 的问题...当然就会有人想办法来解决...在 Debian 中出了 apt 来解决这个问题...然后巴西的公司将其移植到 RPM 系统上 ...然后 cle 的 candyz 则是将它收入 cle 里...
个人在使用一段时间之后...发现实在很方便...一旦整个系统装好之后...把 APT Server on 起来...您的光驱就很少会再用到...因为所有的安装都交给 APT 来做...建议大家可以把 APT Server 装起来试试...超好用的…
准备
测试系统: Red Hat Linux 7.3
所需套件: apt-0.3.19cnc55-5.i386.rpm , apt-devel-0.3.19cnc55-5.i386.rpm
参考网站: http://cle.linux.org.tw/
Candyz 文件
底下是 Candyz 的发表文件...您也可以在其站上找到这篇...
#!/bin/bash
## Copyright (C) 2001-2002 Chung-Yen Chang <candyz at linux.org.tw>
##
## This program is free software; you can redistribute it and/or
## modify it under the terms of the GNU General Public License
## as published by the Free Software Foundation; either version 2
## of the License, or (at your option) any later version.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program; if not, write to the Free Software
## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
## 02111-1307, USA.
##
## Jun 26 2002
## Last modified by Chung-Yen Chang <candyz at linux.org.tw>
#
# =================
# APT Server 的架设
# =================
#
BASEDIR=/var/ftp/gaga
#
cd $BASEDIR
rm -rf SRPMS.gaga
ln -sf SRPMS SRPMS.gaga
#
cd RedHat
rm -rf RPMS.gaga
ln -sf RPMS RPMS.gaga
#
sh /usr/bin/genbasedir --topdir=/var/ftp/gaga --bloat --bz2only --progress RedHat gaga
#
# ================
# APT Clients 部份
# ================
#
关于 CLE 的升级系统我采用的是 APT 套件,这套在 debian 上相当著名的套件,不久前巴西的 Conectiva公司将其移植到 RPM 系统上,而我把它移植到 CLE 上来相信有用过 debian 或玩过 apt 的人,应该都不会太陌生才是
事实上在过年前我就已经在测试了,目前运作的状况还算可以接受目前仅供 RedHat 7.0 以上的系统进行升级我测试过的,全新安装一台英文版的 RedHat7 后,再以 apt 来升级,升级完成后,就跟 CLE 1.0 是一样的了,这样也不失为一个不错的升级管道目前我在升级新套件时,都已经是用 apt 在运作了...
** 注意 **本套件仍在发展阶段,因此,并不保证一定适合每个人的状况,所以,请要使用的人可以的话,最好先备份一下您的重要资料(而我已使用了一段时间了,一切都很正常)若您因为使用这个套件而造成损失,我将不负任何责任
所需套件:
至 CLE 网站下载以下两个套件
ftp://cle.linux.org.tw/pub/CLE/i386/RedHat/RPMS/
apt-0.3.19cnc55-5.i386.rpm
apt-devel-0.3.19cnc55-5.i386.rpm
下载回来后,以 rpm -ivh 将其安装起来
主要设定档:
1./etc/apt/sources.list
这是最重要的设定文件了,记载着 Server repository 的一些信息,内容如下:
# Package repository URLs
#
# CLE 1.1(gaga) Mirrors
#
rpm ftp://cle.linux.org.tw/pub/CLE/i386 RedHat gaga freshrpms
rpm-src ftp://cle.linux.org.tw/pub/CLE/i386 RedHat gaga freshrpms
这是内定的,若您知道有距离您更近的站有提供同样的服务时,可以依照您的需求更改或是增加您要的站台目前国内有提供 apt 服务的列表可参考底下网址:
http://cle.linux.org.tw/index.php?SCREEN=story_view&sid=&pathway=71&node=277
2.其它在 /etc/apt 目录下的一些设定文件 apt.conf rpmpriorities vendors.list使用内定的即可,若有需要变更,请 man 一下或是自行参考 apt 的说明文件
主要指令:
主要有 apt-cache apt-cdrom apt-config apt-get 这四个指令,一般使用者比较会用到的,应该就是 apt-get 指令了,其它更详细的说明请自行 man 或是参考相关的说明文件
=======
apt-get
=======
1.apt-get update
更新套件信息,要升级之前,最好都先执行一次本指令和 Server 端的信息同步一下

2.apt-get check
检查你系统上套件的相依性状况

3.apt-get dist-upgrade 和 apt-get upgrade
执行整个升级动作,建议用 apt-get dist-upgrade 比较好

4.apt-get install 套件名称
安装某一个套件及其相关的套件如 apt-get install xcin 这样就会帮您安装好 xcin 了,连 libtabe 也会一并帮您安装好

5.apt-get remove 套件名称
移除某套件,和 rpm -e 功能一样,同时还会帮您把相关的套件一并移除

6.apt-get source 套件名称
抓回 source rpm
例: apt-get source --compile zhcon
抓回 source rpm 并编译成 binary rpm
--compile 参数就如同 rpm -ba 一般
7.apt-get clean
删除下载回来的档案

=========
apt-cdrom
=========
在您安装好系统后,可以使用 apt-cdrom 来把这三片光盘加入 apt 的 sources.list 中用法如下:
$ apt-cdrom add
Using CD-ROM mount point /mnt/cdrom/
Unmounting CD-ROM
Please insert a Disc in the drive and press enter
Mounting CD-ROM
Identifying.. [af0e7c988f7ae057a4a3bccc8008134d-2]
Scanning Disc for index files.. Found 1 package indexes and 0 source indexes.
Please provide a name for this Disc, such as 'MyDistro 6.0 Disk 1':
Gaga V1.1 disc1
This Disc is called:
'Gaga V1.1 disc1'
Reading Indexes... Done
Writing new source list
Source List entries for this Disc are:
rpm cdrom:[Gaga V1.1 disc1]/ RedHat gaga
Repeat this process for the rest of the CDs in your set.
$ apt-cdrom add
Using CD-ROM mount point /mnt/cdrom/
Unmounting CD-ROM
Please insert a Disc in the drive and press enter
Mounting CD-ROM
Identifying.. [de0703cd627985ce5ea8d9647abc3e4a-2]
Scanning Disc for index files.. Found 1 package indexes and 0 source indexes.
Please provide a name for this Disc, such as 'MyDistro 6.0 Disk 1':
Gaga V1.1 disc2
This Disc is called:
'Gaga V1.1 disc2'
Reading Indexes... Done
Writing new source list
Source List entries for this Disc are:
rpm cdrom:[Gaga V1.1 disc2]/ RedHat gaga
Repeat this process for the rest of the CDs in your set.
$ apt-cdrom add
Using CD-ROM mount point /mnt/cdrom/
Unmounting CD-ROM
Please insert a Disc in the drive and press enter
Mounting CD-ROM
Identifying.. [0daa110860c40f563b2179487f11fdcf-2]
Scanning Disc for index files.. Found 1 package indexes and 0 source indexes.
Please provide a name for this Disc, such as 'MyDistro 6.0 Disk 1':
Gaga V1.1 disc3
This Disc is called:
'Gaga V1.1 disc3'
Reading Indexes... Done
Writing new source list
Source List entries for this Disc are:
rpm cdrom:[Gaga V1.1 disc3]/ RedHat gaga
Repeat this process for the rest of the CDs in your set.
在加完三片光盘后,您应该可以在您的 /etc/apt/sources.list 里看到如下三行:
rpm cdrom:[Gaga V1.1 disc3]/ RedHat gaga
rpm cdrom:[Gaga V1.1 disc2]/ RedHat gaga
rpm cdrom:[Gaga V1.1 disc1]/ RedHat gaga
这样以后就可以使用 apt-get 来安装之前未安装的套件了
范例如下:
若您并没有连上网络,请修改您的 /etc/apt/sources.list
把其它各行都删除或是批注起来,只留下底下这三行
rpm cdrom:[Gaga V1.1 disc3]/ RedHat gaga
rpm cdrom:[Gaga V1.1 disc2]/ RedHat gaga
rpm cdrom:[Gaga V1.1 disc1]/ RedHat gaga
$ apt-get update
Ign cdrom://Gaga V1.1 disc3 RedHat release.gaga
Ign cdrom://Gaga V1.1 disc2 RedHat release.gaga
Ign cdrom://Gaga V1.1 disc1 RedHat release.gaga
Ign cdrom://Gaga V1.1 disc3 RedHat/base/mirrors
Ign cdrom://Gaga V1.1 disc2 RedHat/base/mirrors
Ign cdrom://Gaga V1.1 disc1 RedHat/base/mirrors
Processing File Dependencies... Done
Reading Package Lists... Done
Building Dependency Tree... Done
W: cdrom:[Gaga V1.1 disc3]/ will not be authenticated.
W: cdrom:[Gaga V1.1 disc2]/ will not be authenticated.
W: cdrom:[Gaga V1.1 disc1]/ will not be authenticated.
$ apt-get install zhcon
Processing File Dependencies... Done
Reading Package Lists... Done
Building Dependency Tree... Done
The following NEW packages will be installed:
zhcon
0 packages upgraded, 1 newly installed, 0 to remove(replace) and 0 not
upgraded.
Need to get 0B/3098kB of archives. After unpacking 5466kB will be used.
Media Change: Please insert the disc labeled 'Gaga V1.1 disc3' in the drive
'/mnt/cdrom/' and press enter
Get:1 cdrom://Gaga V1.1 disc3 RedHat/gaga zhcon 0.14-6 [3098kB]
Fetched 3098kB in 4m35s (11.3kB/s)
Executing RPM (-U)...
Preparing... ########################################### [100%]
1:zhcon ########################################### [100%]

根据指示放入 'Gaga V1.1 disc3' 第三片光盘即可
也可免除要新增套件时,不知道该套件到底是放在哪一片光盘片上而要找半天的麻烦

如何把 iso檔加入 sources.list 用 apt-get 来安装之前未安装的套件?
$ mount -o loop gaga-20020625-1.iso /mnt/cdrom/
$ apt-cdrom add -m -d /mnt/cdrom
Using CD-ROM mount point /mnt/cdrom/
Identifying.. [af0e7c988f7ae057a4a3bccc8008134d-2]
Scanning Disc for index files.. Found 1 package indexes and 0 source indexes.
Please provide a name for this Disc, such as 'MyDistro 6.0 Disk 1':
Gaga V1.1 disc1
This Disc is called:
'Gaga V1.1 disc1'
Reading Indexes... Done
Writing new source list
Source List entries for this Disc are:
rpm cdrom:[Gaga V1.1 disc1]/ RedHat gaga
Repeat this process for the rest of the CDs in your set.
===========================================================
-m 参数表示我们自己已经 mount CDROM 了,不用再 mount 一次
-d /mnt/cdrom 用来指定我们的挂载点
重复此步骤把三个 iso 檔都加入 sources.list 中
接下来
$ apt-get update
Ign cdrom://Gaga V1.1 disc3 RedHat release.gaga
Ign cdrom://Gaga V1.1 disc2 RedHat release.gaga
Ign cdrom://Gaga V1.1 disc1 RedHat release.gaga
Ign cdrom://Gaga V1.1 disc3 RedHat/base/mirrors
Ign cdrom://Gaga V1.1 disc2 RedHat/base/mirrors
Ign cdrom://Gaga V1.1 disc1 RedHat/base/mirrors
Processing File Dependencies... Done
Reading Package Lists... Done
Building Dependency Tree... Done
W: cdrom:[Gaga V1.1 disc3]/ will not be authenticated.
W: cdrom:[Gaga V1.1 disc2]/ will not be authenticated.
W: cdrom:[Gaga V1.1 disc1]/ will not be authenticated.
$ apt-get install zhcon
Processing File Dependencies... Done
Reading Package Lists... Done
Building Dependency Tree... Done
The following NEW packages will be installed:
zhcon
0 packages upgraded, 1 newly installed, 0 to remove(replace) and 0 not
upgraded.
Need to get 0B/3098kB of archives. After unpacking 5466kB will be used.
Media Change: Please insert the disc labeled 'Gaga V1.1 disc3' in the drive
'/mnt/cdrom/' and press enter
此时再开个窗口手动把 disc3 iso 挂载到 /mnt/cdrom 下即可

=========
apt-cache
=========
1.apt-cache showpkg
显示套件信息
例: apt-cache showpkg zhcon
2.apt-cache stats
显示相关的统计信息
3.apt-cache dump
颢示 cache 中每个套件的简短信息
4.apt-cache unmet
检查所有未符合相依性的相关信息
5.apt-cache show
显示套件信息,同 rpm -qi 一般
6.apt-cache search
寻找档案
例: apt-cache search zhcon
7.apt-cache depends
显示套件的相依性
例: apt-cache depends zhcon
8.apt-cache pkgnames
寻找符合的套件名称
例: $ apt-cache pkgnames openss
openssh-askpass
openssl096
openssl-perl
openssl095a
openssl-python
openssh-clients
openssl-devel
openssh-askpass-gnome
openssh
openssl
openssh-server

==========
apt-config
==========
1.apt-config dump
显示目前的设定状态
===========================================================
以上这些是比较常用到的指令

基本上,若要升级,只要定期执行 apt-get update 和 apt-get dist-upgrade 就
可以维持和 CLE 最新的套件同步的状况了...

另外我也写了一个选单式的 script,您可以直接执行 apt ,然后选择您要的指令即可
其它还有几个不错的 apt 前端程序,选单模式的 aptitude 及图形接口的 synaptic,
aptitude 已纳入 gaga 中,而 synaptic 则可以在底下网站下载到:
ftp://cle.linux.org.tw/mirror/freshrpms/valhalla/synaptic/

注意:
在升级一些特殊的套件时,尤其像是 kernel 和 glibc 等,升级的先后顺序也很重要
请您还是先download回来后,再用 rpm -Uvh 去升级比较保险
至于其它的套件,就比较没关系了,放心的用 apt 去升级
若遇到无法用 apt 升级时,那就改用 rpm 先去升级该套件吧