广告广告
  加入我的最爱 设为首页 风格修改
首页 首尾
 手机版   订阅   地图  繁体 
您是第 6672 个阅读者
 
发表文章 发表投票 回覆文章
  可列印版   加为IE收藏   收藏主题   上一主题 | 下一主题   
love104 手机
个人头像
个人文章 个人相簿 个人日记 个人地图
小人物
级别: 小人物 该用户目前不上站
推文 x0 鲜花 x4
分享: 转寄此文章 Facebook Plurk Twitter 复制连结到剪贴簿 转换为繁体 转换为简体 载入图片
推文 x0
[Linux] 转贴-APT用法
# =================
# 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...edHat/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...CLE/i386 RedHat gaga freshrpms
rpm-src ftp://cle.linux.org...CLE/i386 RedHat gaga freshrpms

  这是内定的,若您知道有距离您更近的站有提供同样的服务时,可以依照您的
  需求更改或是增加您要的站台
  目前国内有提供 apt 服务的列表可参考底下网址:
http://cle.linux.org.tw/index.php?SCREEN...athway=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/f...lla/synaptic/

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



献花 x0 回到顶端 [楼 主] From:台湾数位联合 | Posted:2005-08-02 10:04 |
mnbmnb5266
个人文章 个人相簿 个人日记 个人地图
小有名气
级别: 小有名气 该用户目前不上站
推文 x5 鲜花 x46
分享: 转寄此文章 Facebook Plurk Twitter 复制连结到剪贴簿 转换为繁体 转换为简体 载入图片

谢谢您的提供,感觉很是详细啊


我的收藏
https://pan.baidu.com/s/1QUJ9lr_VzxXKRJAlBJgUQA
提取码:am2c
献花 x0 回到顶端 [1 楼] From:加拿大Rogers | Posted:2010-08-26 23:27 |

首页  发表文章 发表投票 回覆文章
Powered by PHPWind v1.3.6
Copyright © 2003-04 PHPWind
Processed in 0.015432 second(s),query:16 Gzip disabled
本站由 瀛睿律师事务所 担任常年法律顾问 | 免责声明 | 本网站已依台湾网站内容分级规定处理 | 连络我们 | 访客留言