廣告廣告
  加入我的最愛 設為首頁 風格修改
首頁 首尾
 手機版   訂閱   地圖  簡體 
您是第 6631 個閱讀者
 
發表文章 發表投票 回覆文章
  可列印版   加為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.019212 second(s),query:16 Gzip disabled
本站由 瀛睿律師事務所 擔任常年法律顧問 | 免責聲明 | 本網站已依台灣網站內容分級規定處理 | 連絡我們 | 訪客留言