Gentoolkit
1.
介紹
什麼是 Gentoolkit?
Gentoo 是一套獨一無二的發行版,有著一些別的發行版所沒有的複雜度。當 gentoo 開發
者及貢獻者發現這些複雜度,他們會寫出工具程式來幫助使用者和管理者解決這些問題。
這些工具滿多貢獻給 Gentoo 專案,包括 app-portage/gentoolkit 這個套件裡。
注意:
在目前,gentoolkit 有兩個版本:app-portage/gentoolkit 和
app-portage/gentoolkit-dev。前者包含管理用的 script,而後者包含了協助開
發 Gentoo. 的 script。如果你是開發員,你可以連絡 Gentoolkit 維護人將你的 script
加入 gentoolkit-dev 中。這份文件只會討論 gentoolkit。
|
Gentoolkit 包含一大堆有用的套件來幫助管理 Portage 和 ebuild 架構。大部分
的使用者 -- 特別是那些時常更新系統的 -- 將得益於安裝 gentoolkit 之後。
安裝
就和其他的 Gentoo 套件一樣,安裝只要簡單的 emerge 就可以了。
原始碼 1.1: 安裝 gentoolkit |
# emerge gentoolkit
|
注意:
許多 gentoolkit 裡的工具透露關於你系統的重要訊息或是需要 root 權限。
因為這個原因(或是函式特性),有些程式只能由具有 root 權限的使用者執行。
|
尋找文件
程式所附的文件(不是使用手冊)會放在
/usr/share/doc/gentoolkit-[version]/[program-name]/下。
2.
equery
介紹
equery 工具包含了 epm 的部分功能(包括被淘汰的 qpkg),再加
上一些讓他更好用的功能。equery --help 會告訴你完整的可用選項。
equery 在之後的版本會被 etcat 取代。
注意:
不是所有列在 equery --help 的功能都被實做出來。還沒支援的功能都會清楚標
明。你也會看到每個命令都有一個較短的選項,例如說 b 代表 belongs。
|
注意:
注意 equery 目前會在輸出結果送到 pipe 時改變他的輸出格式。這種格式讓其他程式比
較好分析,但是這種作法比較不受到歡迎,因此未來可能會改變。如果你寫的 script 有
用到 equery,請注意這點。
|
找出檔案所屬的套件
equery 也提供尋找檔案屬於那個套件的功能,使用 belongs 指令(或是
b)。
原始碼 2.1: 找出安裝指定檔案的 ebuild |
# equery belongs /usr/bin/xmms
[ Searching for file(s) /usr/bin/xmms in *... ]
media-sound/xmms-1.2.10-r9 (/usr/bin/xmms)
|
-f 選項可以讓你搜尋所有符合正規表示式的檔案。-e 方便你在找到第一
個符合後就結束。
檢查套件內容
有時檢查套件的功能很有用。equery 可以檢查 md5 檢查碼及 timestamp 來檢查
套件是不是被污染,取代或移除。
原始碼 2.2: 套件內容正常 |
# equery check gentoolkit
[ Checking app-portage/gentoolkit-0.2.0 ]
* 54 out of 54 files good
|
注意如果你在安裝後改變他的設定檔,可能會回報 "not good"。
列出所有相依於 ... 的套件
equery 可以列出所有直接相依於某套件的套件。只要用 depends 就可以
使用這個功能,他也很容易使用。
原始碼 2.3: 搜尋相依於 pygtk 的套件 |
# equery depends pygtk
[ Searching for packages depending on pygtk... ]
app-office/dia-0.93
dev-python/gnome-python-2.0.0-r1
gnome-extra/gdesklets-core-0.26.2
media-gfx/gimp-2.0.4
x11-libs/vte-0.11.11-r1
|
相依關係圖
equery 可以給你指定套件的相依關係圖。裡面包含了套件直接和間接相依的套件
列表。
原始碼 2.4: cdrtools 相依關係圖 |
# equery depgraph cdrtools
Displaying dependencies for app-cdr/cdrtools-2.01_alpha37
`-- app-cdr/cdrtools-2.01_alpha37
`-- sys-libs/glibc-2.3.4.20040808 (virtual/libc)
`-- sys-kernel/linux-headers-2.4.22 (virtual/os-headers)
`-- sys-apps/baselayout-1.10.4
`-- sys-apps/sysvinit-2.85-r1
`-- sys-apps/gawk-3.1.3-r1
`-- sys-apps/util-linux-2.12-r4
`-- sys-apps/sed-4.0.9
`-- sys-libs/ncurses-5.4-r4
`-- sys-apps/pam-login-3.14
`-- sys-libs/pam-0.77-r1
`-- sys-libs/cracklib-2.7-r10
`-- sys-apps/miscfiles-1.3-r1
`-- app-arch/gzip-1.3.5-r1
`-- sys-apps/portage-2.0.50-r10
|
例如說,cdrtools 直接依賴於 glibc,而 linux-headers 則是間接的關係。注意他輸出
的資訊中會包含虛擬套件的資訊。在上面的例子中,cdrtools 實際上是相依於
virtual/libc,而不是 sys-libs/glibc,但是這個系統中是由 sys-libs/glibc 提供
virtual/libc。
顯示某個 Ebuild 包含的檔案
equery 可以列出某個已安裝 ebuild 所包含的檔案。如果你不知道 Gentoolkit
在系統中安裝哪些檔案,可以用 equery 列出來。
原始碼 2.5: 列出檔案 |
# equery files gentoolkit
[ Searching for packages matching gentoolkit... ]
app-portage/gentoolkit-0.2.0
* Contents of app-portage/gentoolkit-0.2.0:
/usr
/usr/bin
/usr/bin/equery
/usr/bin/etcat
/usr/bin/euse
/usr/bin/glsa-check
/usr/bin/qpkg
/usr/bin/revdep-rebuild
/usr/lib
/usr/lib/gentoolkit
/usr/lib/gentoolkit/pym
/usr/lib/gentoolkit/pym/gentoolkit
/usr/lib/gentoolkit/pym/gentoolkit/__init__.py
/usr/lib/gentoolkit/pym/gentoolkit/gentoolkit.py
/usr/lib/gentoolkit/pym/gentoolkit/pprinter.py
/usr/lib/gentoolkit/pym/glsa.py
/usr/sbin
/usr/share
/usr/share/doc
/usr/share/doc/gentoolkit-0.2.0_pre10
[...]
|
equery 的 files 指令提供一些改變輸出的指令。你可以在 equery
手冊頁中找到。
尋找使用特定 USE 設定的套件
如果你想要找出系統中使用特定 USE 設定的套件,equery 有 hasuse 功
能可以用:
原始碼 2.6: 搜尋使用 mozilla USE 設定的套件 |
# equery hasuse mozilla
[ Searching for USE flag mozilla in all categories among: ]
* installed packages
[I--] [ ] dev-java/blackdown-jre-1.4.2.01 (1.4.2)
[I--] [ ] mail-client/evolution-2.0.2 (2.0)
|
列出套件
equery 的強大功能就是列出系統上的所有套件,不管是 portage 還是 overlay
都可以。現在來試試看:
原始碼 2.7: 用 equery 列出套件 |
# equery list gentoolkit
[ Searching for package 'gentoolkit' in all categories among: ]
* installed packages
[I--] [ ] app-portage/gentoolkit-0.2.0 (0)
|
預設的搜尋會尋找系統上符合指定名稱,而且已安裝套件。如果找到的話,會顯示以下的
資訊:第一個中括號中會顯示套件的位置(I 代表已安裝,P 代表 Portage,O 是Overlay)
,第二個是放封鎖的狀況(~ 是關鍵字,- 是架構,M 是系統封鎖),然後是套件的分類和
完整的名稱,最後是套件所屬的 slot。
另一個例子中,我們加上只檢查 portage tree 及 overlay 的參數。
原始碼 2.8: 加上 equery 參數 |
# equery list -p -o vim
[ Searching for package 'vim' in all categories among: ]
* installed packages
[I--] [ ] app-editors/vim-6.3-r4 (0)
* Portage tree (/usr/portage)
[-P-] [M~] app-editors/vim-7.0_alpha20050126 (0)
[-P-] [M~] app-editors/vim-7.0_alpha20050201 (0)
[-P-] [ ] app-editors/vim-6.3-r2 (0)
[-P-] [M~] app-editors/vim-7.0_alpha20050122 (0)
[-P-] [M~] app-editors/vim-core-7.0_alpha20050126 (0)
[-P-] [ ] app-editors/vim-core-6.3-r3 (0)
[-P-] [M~] app-editors/vim-core-7.0_alpha20050122 (0)
[-P-] [M~] app-editors/vim-core-7.0_alpha20050201 (0)
[-P-] [ ] app-editors/vim-core-6.3-r4 (0)
* overlay tree (/opt/ebuilds)
|
顯示套件大小
曾經對套件佔用多少的硬碟空間感到好奇?因為套件的檔案可能遍佈在多個目錄中,一般
的 du -hc 可能不能正確的計算出來。別擔心,讓 equery 幫你搞定吧!
原始碼 2.9: 套件大小 |
# equery size openoffice-bin
* app-office/openoffice-bin-1.1.2
Total Files : 2908
Total Size : 223353.31 KiB
|
如你看到的,equery 列出套件總共多少 KB 以及他總共有多少檔案。
套件本身的 USE 設定
equery 可以給你套件使用哪些 USE 設定的相關資訊。他也會顯示目前討見使用哪
些 USE 設定,以及他支援哪些 USE 設定。
原始碼 2.10: 使用和未使用的 USE 設定 |
# equery uses ethereal
[ Colour Code : set unset ]
[ Legend : (U) Col 1 - Current USE flags ]
[ : (I) Col 2 - Installed With USE flags ]
U I [ Found these USE variables in : net-analyzer/ethereal-0.10.6 ]
- - adns : Adds support for the adns DNS client library
+ + gtk : Adds support for x11-libs/gtk+ (The GIMP Toolkit)
- - ipv6 : Adds support for IP version 6
- - snmp : Adds support for the Simple Network Management Protocol if available
+ + ssl : Adds support for Secure Socket Layer connections
+ + gtk2 : Use gtk+-2.0.0 over gtk+-1.2 in cases where a program supports both.
- - debug : Tells configure and the makefiles to build for debugging. Effects vary across packages,
but generally it will at least add -g to CFLAGS. Remember to set FEATURES=nostrip too
|
我在安裝時有開啟 gtk,ssl 及 gtk2 的支援,但是沒有 adns,ipv6,snmp 及 debug。
要瞭解更多關於 USE 設定的資訊,請參考 Gentoo 手冊中
的USE 參數 章節。
ebuild 在哪裡?
我們也可以用 equery 找出某個套件使用那個 ebuild。只要用
equery which 參數他就會列出 ebuild 的完整路徑。
原始碼 2.11: 顯示 ebuild 路徑 |
# equery which cdrtools
/usr/portage/app-cdr/cdrtools/cdrtools-2.01_alpha37.ebuild
|
3.
euse
介紹
警告:
euse 目前因為不能支援 cascading profile,所以是毀損的狀態。
|
euse 是查詢,設定,解除 USE 參數的工具。要瞭解更多關於 USE 設定的資訊,
請參考USE 參數 章節。
完整的選想說明可以在 euse -h 看到。
查詢,設定,解除 USE 參數
euse -a 指令讀取目前啟動的 USE 參數並顯示出來。
注意:
euse 現在使用5個"欄位"顯示參數有沒有啟動,以及設定的地方。各欄
位依序是 +/-,在環境變數設定,在 make.Conf 設定,在 make.Defaults 設定,在
make.Globals 設定。他輸出會像這樣 [+ECDG]。
|
原始碼 3.1: 顯示所有啟動的 USE 參數 |
# euse -a
X [+ CD ]
aalib [+ ]
acpi [+ C ]
alsa [+ C ]
apache2 [+ C ]
apm [+ D ]
avi [+ D ]
berkdb [+ D ]
bitmap-fonts [+ D ]
bonobo [+ ]
cdr [+ C ]
crypt [+ CD ]
cscope [+ C ]
cups [+ CD ]
curl [+ ]
emboss [+ D ]
encode [+ D ]
esd [+ ]
ethereal [+ C ]
fam [+ ]
fbcon [+ C ]
font-server [+ D ]
foomaticdb [+ D ]
fortran [+ D ]
gd [+ C ]
gdbm [+ D ]
gif [+ CD ]
gimpprint [+ C ]
gnome [+ CD ]
gphoto2 [+ ]
gpm [+ CD ]
gstreamer [+ C ]
gtk [+ D ]
gtk2 [+ CD ]
gtkhtml [+ C ]
guile [+ ]
imagemagick [+ ]
imlib [+ CD ]
imlib2 [+ ]
innodb [+ ]
ipv6 [+ D ]
javascript [+ C ]
jpeg [+ CD ]
kde [+ D ]
ldap [+ ]
libg++ [+ CD ]
libwww [+ CD ]
mad [+ CD ]
mbox [+ C ]
md5sum [+ C ]
mikmod [+ CD ]
mmx [+ C ]
motif [+ CD ]
mozilla [+ C ]
mp3 [+ ]
mpeg [+ CD ]
mpeg4 [+ C ]
mysql [+ C ]
ncurses [+ CD ]
nls [+ D ]
nvidia [+ C ]
odbc [+ ]
offensive [+ ]
oggvorbis [+ CD ]
opengl [+ CD ]
oss [+ D ]
pam [+ CD ]
pdflib [+ CD ]
perl [+ CD ]
png [+ CD ]
python [+ CD ]
qt [+ D ]
quicktime [+ CD ]
readline [+ CD ]
ruby [+ ]
sdl [+ CD ]
slang [+ D ]
spell [+ CD ]
sse [+ C ]
ssl [+ CD ]
svga [+ CD ]
tcltk [+ C ]
tcpd [+ D ]
tiff [+ C ]
truetype [+ CD ]
truetype-fonts [+ D ]
type1-fonts [+ D ]
usb [+ C ]
vanilla [+ C ]
x86 [+ C ]
xml [+ ]
xml2 [+ D ]
xmms [+ D ]
xosd [+ C ]
xv [+ CD ]
xvid [+ C ]
zlib [+ CD ]
|
同樣的,你可以用 euse -a -g 指令只顯示啟動的全域 USE 設定。
euse -a -l 則會顯示區域的設定。-g & -l 是 euse
的一個子選項,需要在前面有一個選項(像是 -a)才能正常運作。
原始碼 3.2: 顯示區域的 USE 設定 |
# euse -a -l
bitmap-fonts [+ D ]
font-server [+ D ]
fortran [+ D ]
gimpprint [+ C ]
imlib2 [+ ]
md5sum [+ C ]
mpeg4 [+ C ]
nvidia [+ C ]
offensive [+ ]
truetype [+ CD ]
truetype-fonts [+ D ]
type1-fonts [+ D ]
|
我們業可以用 euse 來啟動或關閉 use 設定。使用的指令是
euse -E flagname (啟動一個設定)及 euse -D flagname (關閉一個設定)。
警告:
當你單獨使用 euse -E 或 euse -D 指令(不加上任何設定)時,他會啟動/
關閉 /etc/make.conf 中所有的 USE 設定。雖然會有備份放在
/etc/make.conf.euse_backup,但是在用 euse -E 或
euse -D 時還是要小心。
|
原始碼 3.3: 啟動或關閉 USE 設定 |
# euse -E 3dfx
/etc/make.conf was modified, a backup copy has been placed at /etc/make.conf.euse_backup
USE="alsa acpi apache2 -arts cups cdr crypt cscope -doc ethereal fbcon gd \
gif gimpprint gnome gpm gstreamer gtk2 gtkhtml imlib imlib2 \
innodb -java javascript jpeg libg++ libwww mad mbox md5sum \
mikmod mmx motif mozilla mpeg mpeg4 mysql ncurses nvidia \
oggvorbis odbc offensive opengl pam pdflib perl png python \
quicktime readline sdl spell sse ssl svga tcltk tiff truetype usb \
vanilla X xml2 xmms xosd xv xvid x86 zlib 3dfx"
# euse -D 3dfx
/etc/make.conf was modified, a backup copy has been placed at /etc/make.conf.euse_backup
USE="alsa acpi apache2 -arts cups cdr crypt cscope -doc ethereal fbcon gd \
gif gimpprint gnome gpm gstreamer gtk2 gtkhtml imlib imlib2 \
innodb -java javascript jpeg libg++ libwww mad mbox md5sum \
mikmod mmx motif mozilla mpeg mpeg4 mysql ncurses nvidia \
oggvorbis odbc offensive opengl pam pdflib perl png python \
quicktime readline sdl spell sse ssl svga tcltk tiff truetype usb \
vanilla X xml2 xmms xosd xv xvid x86 zlib -3dfx"
|
注意:
euse 並不會實際上從 make.conf 移除設定。他只會在他前面加上 - (減號)來關
閉他。你可以手動清除掉來避免不必要的變數。
|
4.
其他工具
revdep-rebuild
這個工具是 Gentoo 的逆向相依性重建程式。他會掃瞄所有安裝的套件,找出因為依賴的
套件更新而毀損的套件。他可以幫你重新安裝這些套件,但是也有可能目前安裝的相依軟
體無法讓他在運作,如果是這種狀況,你需咬手動更新到新版。revdep-rebuild 會傳送
--pretend 參數給 emerge 讓你在繼續安裝前知道會動到那些軟體。
原始碼 4.1: 模擬模式執行 revdep-rebuild |
# revdep-rebuild -p
Checking reverse dependencies...
Packages containing binaries and libraries broken by any package update,
will be recompiled.
Collecting system binaries and libraries... done.
(/root/.revdep-rebuild.1_files)
Collecting complete LD_LIBRARY_PATH... done.
(/root/.revdep-rebuild.2_ldpath)
Checking dynamic linking consistency...
broken /usr/lib/ao/plugins-2/libarts.so (requires libartsc.so.0)
broken /usr/lib/kde3/libkpresenterpart.so (requires libartskde.so.1 libqtmcop.so.1
libsoundserver_idl.so.1 libkmedia2_idl.so.1 libartsflow.so.1 libartsflow_idl.so.1 libmcop.so.1)
broken /usr/lib/ruby/site_ruby/1.8/i686-linux/fox.so (requires libFOX-1.0.so.0)
broken /usr/lib/xine/plugins/1.0.0/xineplug_ao_out_arts.so (requires libartsc.so.0)
broken /usr/lib/perl5/vendor_perl/5.8.0/i686-linux/auto/SDL_perl/SDL_perl.so (requires libSDL_gfx.so.0)
broken /usr/lib/libloudmouth-1.so.0.0.0 (requires libgnutls.so.10)
broken /usr/bin/k3b (requires libartskde.so.1 libqtmcop.so.1 libsoundserver_idl.so.1 libkmedia2_idl.so.1
libartsflow.so.1 libartsflow_idl.so.1 libmcop.so.1)
broken /usr/bin/lua (requires libhistory.so.4)
broken /usr/bin/lyx (requires libAiksaurus-1.0.so.0)
broken /usr/bin/luac (requires libhistory.so.4)
broken /usr/bin/avidemux2 (requires libartsc.so.0)
broken /usr/bin/pptout (requires libxml++-0.1.so.11)
broken /usr/bin/xml2ps (requires libxml++-0.1.so.11)
done.
(/root/.revdep-rebuild.3_rebuild)
Assigning files to ebuilds... done.
(/root/.revdep-rebuild.4_ebuilds)
Evaluating package order... done.
(/root/.revdep-rebuild.5_order)
All prepared. Starting rebuild...
emerge --oneshot --nodeps -p =app-cdr/k3b-0.11.14 =app-office/koffice-1.3.2 =app-office/lyx-1.3.4 \
=app-office/passepartout-0.2 =dev-lang/lua-5.0.2 =dev-ruby/fxruby-1.0.29 =media-libs/libao-0.8.5 \
=media-libs/xine-lib-1_rc5-r3 =media-video/avidemux-2.0.26 =net-libs/loudmouth-0.16
These are the packages that I would merge, in order:
Calculating dependencies ...done!
[ebuild R ] app-cdr/k3b-0.11.14
[ebuild R ] app-office/koffice-1.3.2
[ebuild R ] app-office/lyx-1.3.4
[ebuild R ] app-office/passepartout-0.2
[ebuild R ] dev-lang/lua-5.0.2
[ebuild R ] dev-ruby/fxruby-1.0.29
[ebuild R ] media-libs/libao-0.8.5
[ebuild R ] media-libs/xine-lib-1_rc5-r3
[ebuild R ] media-video/avidemux-2.0.26
[ebuild R ] net-libs/loudmouth-0.16
Now you can remove -p (or --pretend) from arguments and re-run revdep-rebuild.
|
如果你要重新編譯一些套件,你可以不加 -p 參數執行 revdep-rebuild,
他會 emerge 列出來的套件。
glsa-check
glsa-check 只是一個測試中的工具,讓你追蹤 GLSA (Gentoo Linux Security Advisory)
的狀態。他最後會合並進 emerge 及 equery。更多資訊可以在 Portage GLSA Integration
Page看到。
|