也許,Fedora 社群追求其促進自由和開源的軟體及內容的使命的最著名的方式就是開發 Fedora 軟體發行版了。因此,我們將很大一部分的社群資源用於此任務也就不足為奇了。這篇文章總結了這些軟體是如何“打包”的,以及使之成為可能的基礎工具,如 rpm
之類。
可供使用者選擇的“版本”和“風味版”(spins / labs / silverblue)其實非常相似。它們都是由各種軟體組成的,這些軟體經過混合和搭配,可以很好地協同工作。它們之間的不同之處在於放入其中的具體工具不同。這種選擇取決於它們所針對的用例。所有這些的“版本”和“風味版”基本組成單位都是 RPM 軟體包檔案。
RPM 檔案是類似於 ZIP 檔案或 tarball 的存檔檔案。實際上,它們使用了壓縮來減小存檔檔案的大小。但是,除了檔案之外,RPM 存檔中還包含有關軟體包的後設資料。可以使用 rpm
工具查詢:
$ rpm -q fpastefpaste-0.3.9.2-2.fc30.noarch$ rpm -qi fpasteName : fpasteVersion : 0.3.9.2Release : 2.fc30Architecture: noarchInstall Date: Tue 26 Mar 2019 08:49:10 GMTGroup : UnspecifiedSize : 64144License : GPLv3+Signature : RSA/SHA256, Thu 07 Feb 2019 15:46:11 GMT, Key ID ef3c111fcfc659b9Source RPM : fpaste-0.3.9.2-2.fc30.src.rpmBuild Date : Thu 31 Jan 2019 20:06:01 GMTBuild Host : buildhw-07.phx2.fedoraproject.orgRelocations : (not relocatable)Packager : Fedora ProjectVendor : Fedora ProjectURL : https://pagure.io/fpasteBug URL : https://bugz.fedoraproject.org/fpasteSummary : A simple tool for pasting info onto sticky notes instancesDescription :It is often useful to be able to easily paste text to the FedoraPastebin at http://paste.fedoraproject.org and this simple scriptwill do that and return the resulting URL so that people mayexamine the output. This can hopefully help folks who are forsome reason stuck without X, working remotely, or any otherreason they may be unable to paste something into the pastebin$ rpm -ql fpaste/usr/bin/fpaste/usr/share/doc/fpaste/usr/share/doc/fpaste/README.rst/usr/share/doc/fpaste/TODO/usr/share/licenses/fpaste/usr/share/licenses/fpaste/COPYING/usr/share/man/man1/fpaste.1.gz
安裝 RPM 軟體包後,rpm
工具可以知道具體哪些檔案被新增到了系統中。因此,刪除該軟體包也會刪除這些檔案,並使系統保持一致狀態。這就是為什麼要盡可能地使用 rpm
安裝軟體,而不是從原始碼安裝軟體的原因。
如今,完全獨立的軟體已經非常罕見。甚至 fpaste,連這樣一個簡單的單個檔案的 Python 指令碼,都需要安裝 Python 直譯器。因此,如果系統未安裝 Python(幾乎不可能,但有可能),則無法使用 fpaste
。用打包者的術語來說,“Python 是 fpaste
的執行時依賴項。”
構建 RPM 軟體包時(本文不討論構建 RPM 的過程),生成的歸檔檔案中包括了所有這些後設資料。這樣,與 RPM 軟體包歸檔檔案互動的工具就知道必須要安裝其它的什麼東西,以便 fpaste
可以正常工作:
$ rpm -q --requires fpaste/usr/bin/python3python3rpmlib(CompressedFileNames) <= 3.0.4-1rpmlib(FileDigests) <= 4.6.0-1rpmlib(PayloadFilesHavePrefix) <= 4.0-1rpmlib(PayloadIsXz) <= 5.2-1$ rpm -q --provides fpastefpaste = 0.3.9.2-2.fc30$ rpm -qi python3Name : python3Version : 3.7.3Release : 3.fc30Architecture: x86_64Install Date: Thu 16 May 2019 18:51:41 BSTGroup : UnspecifiedSize : 46139License : PythonSignature : RSA/SHA256, Sat 11 May 2019 17:02:44 BST, Key ID ef3c111fcfc659b9Source RPM : python3-3.7.3-3.fc30.src.rpmBuild Date : Sat 11 May 2019 01:47:35 BSTBuild Host : buildhw-05.phx2.fedoraproject.orgRelocations : (not relocatable)Packager : Fedora ProjectVendor : Fedora ProjectURL : https://www.python.org/Bug URL : https://bugz.fedoraproject.org/python3Summary : Interpreter of the Python programming languageDescription :Python is an accessible, high-level, dynamically typed, interpreted programminglanguage, designed with an emphasis on code readability.It includes an extensive standard library, and has a vast ecosystem ofthird-party libraries.The python3 package provides the "python3" executable: the referenceinterpreter for the Python language, version 3.The majority of its standard library is provided in the python3-libs package,which should be installed automatically along with python3.The remaining parts of the Python standard library are broken out into thepython3-tkinter and python3-test packages, which may need to be installedseparately.Documentation for Python is provided in the python3-docs package.Packages containing additional libraries for Python are generally named withthe "python3-" prefix.$ rpm -q --provides python3python(abi) = 3.7python3 = 3.7.3-3.fc30python3(x86-64) = 3.7.3-3.fc30python3.7 = 3.7.3-3.fc30python37 = 3.7.3-3.fc30
雖然 rpm
知道每個歸檔檔案所需的依賴關係,但不知道在哪裡找到它們。這是設計使然:rpm
僅適用於本地檔案,必須具體告知它們的位置。因此,如果你嘗試安裝單個 RPM 軟體包,則 rpm
找不到該軟體包的執行時依賴項時就會出錯。本範例嘗試安裝從 Fedora 軟體包集中下載的軟體包:
$ lspython3-elephant-0.6.2-3.fc30.noarch.rpm$ rpm -qpi python3-elephant-0.6.2-3.fc30.noarch.rpmName : python3-elephantVersion : 0.6.2Release : 3.fc30Architecture: noarchInstall Date: (not installed)Group : UnspecifiedSize : 2574456License : BSDSignature : (none)Source RPM : python-elephant-0.6.2-3.fc30.src.rpmBuild Date : Fri 14 Jun 2019 17:23:48 BSTBuild Host : buildhw-02.phx2.fedoraproject.orgRelocations : (not relocatable)Packager : Fedora ProjectVendor : Fedora ProjectURL : http://neuralensemble.org/elephantBug URL : https://bugz.fedoraproject.org/python-elephantSummary : Elephant is a package for analysis of electrophysiology data in PythonDescription :Elephant - Electrophysiology Analysis Toolkit Elephant is a package for theanalysis of neurophysiology data, based on Neo.$ rpm -qp --requires python3-elephant-0.6.2-3.fc30.noarch.rpmpython(abi) = 3.7python3.7dist(neo) >= 0.7.1python3.7dist(numpy) >= 1.8.2python3.7dist(quantities) >= 0.10.1python3.7dist(scipy) >= 0.14.0python3.7dist(six) >= 1.10.0rpmlib(CompressedFileNames) <= 3.0.4-1rpmlib(FileDigests) <= 4.6.0-1rpmlib(PartialHardlinkSets) <= 4.0.4-1rpmlib(PayloadFilesHavePrefix) <= 4.0-1rpmlib(PayloadIsXz) <= 5.2-1$ sudo rpm -i ./python3-elephant-0.6.2-3.fc30.noarch.rpmerror: Failed dependencies: python3.7dist(neo) >= 0.7.1 is needed by python3-elephant-0.6.2-3.fc30.noarch python3.7dist(quantities) >= 0.10.1 is needed by python3-elephant-0.6.2-3.fc30.noarch
理論上,你可以下載 python3-elephant
所需的所有軟體包,並告訴 rpm
它們都在哪裡,但這並不方便。如果 python3-neo
和 python3-quantities
還有其它的執行時要求怎麼辦?很快,這種“依賴鏈”就會變得相當複雜。
幸運的是,有了 dnf
和它的朋友們,可以幫助解決此問題。與 rpm
不同,dnf
能感知到儲存庫。儲存庫是程式包的集合,帶有告訴 dnf
這些儲存庫包含什麼內容的後設資料。所有 Fedora 系統都帶有預設啟用的預設 Fedora 儲存庫:
$ sudo dnf repolistrepo id repo name statusfedora Fedora 30 - x86_64 56,582fedora-modular Fedora Modular 30 - x86_64 135updates Fedora 30 - x86_64 - Updates 8,573updates-modular Fedora Modular 30 - x86_64 - Updates 138updates-testing Fedora 30 - x86_64 - Test Updates 8,458
在 Fedora 快速文件中有這些儲存庫以及如何管理它們的更多資訊。
dnf
可用於查詢儲存庫以獲取有關它們包含的軟體包資訊。它還可以在這些儲存庫中搜尋軟體,或從中安裝/解除安裝/升級軟體包:
$ sudo dnf search elephantLast metadata expiration check: 0:05:21 ago on Sun 23 Jun 2019 14:33:38 BST.============================================================================== Name & Summary Matched: elephant ==============================================================================python3-elephant.noarch : Elephant is a package for analysis of electrophysiology data in Pythonpython3-elephant.noarch : Elephant is a package for analysis of electrophysiology data in Python$ sudo dnf list \*elephant\*Last metadata expiration check: 0:05:26 ago on Sun 23 Jun 2019 14:33:38 BST.Available Packagespython3-elephant.noarch 0.6.2-3.fc30 updates-testingpython3-elephant.noarch 0.6.2-3.fc30 updates
現在使用 dnf
安裝軟體包時,它將解決所有必需的依賴項,然後呼叫 rpm
執行該事務操作:
$ sudo dnf install python3-elephantLast metadata expiration check: 0:06:17 ago on Sun 23 Jun 2019 14:33:38 BST.Dependencies resolved.============================================================================================================================================================================================== Package Architecture Version Repository Size==============================================================================================================================================================================================Installing: python3-elephant noarch 0.6.2-3.fc30 updates-testing 456 kInstalling dependencies: python3-neo noarch 0.8.0-0.1.20190215git49b6041.fc30 fedora 753 k python3-quantities noarch 0.12.2-4.fc30 fedora 163 kInstalling weak dependencies: python3-igor noarch 0.3-5.20150408git2c2a79d.fc30 fedora 63 kTransaction Summary==============================================================================================================================================================================================Install 4 PackagesTotal download size: 1.4 MInstalled size: 7.0 MIs this ok [y/N]: yDownloading Packages:(1/4): python3-igor-0.3-5.20150408git2c2a79d.fc30.noarch.rpm 222 kB/s | 63 kB 00:00(2/4): python3-elephant-0.6.2-3.fc30.noarch.rpm 681 kB/s | 456 kB 00:00(3/4): python3-quantities-0.12.2-4.fc30.noarch.rpm 421 kB/s | 163 kB 00:00(4/4): python3-neo-0.8.0-0.1.20190215git49b6041.fc30.noarch.rpm 840 kB/s | 753 kB 00:00----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------Total 884 kB/s | 1.4 MB 00:01Running transaction checkTransaction check succeeded.Running transaction testTransaction test succeeded.Running transaction Preparing : 1/1 Installing : python3-quantities-0.12.2-4.fc30.noarch 1/4 Installing : python3-igor-0.3-5.20150408git2c2a79d.fc30.noarch 2/4 Installing : python3-neo-0.8.0-0.1.20190215git49b6041.fc30.noarch 3/4 Installing : python3-elephant-0.6.2-3.fc30.noarch 4/4 Running scriptlet: python3-elephant-0.6.2-3.fc30.noarch 4/4 Verifying : python3-elephant-0.6.2-3.fc30.noarch 1/4 Verifying : python3-igor-0.3-5.20150408git2c2a79d.fc30.noarch 2/4 Verifying : python3-neo-0.8.0-0.1.20190215git49b6041.fc30.noarch 3/4 Verifying : python3-quantities-0.12.2-4.fc30.noarch 4/4Installed: python3-elephant-0.6.2-3.fc30.noarch python3-igor-0.3-5.20150408git2c2a79d.fc30.noarch python3-neo-0.8.0-0.1.20190215git49b6041.fc30.noarch python3-quantities-0.12.2-4.fc30.noarchComplete!
請注意,dnf
甚至還安裝了python3-igor
,而它不是 python3-elephant
的直接依賴項。
儘管技術使用者可能會發現 dnf
易於使用,但並非所有人都這樣認為。Dnfdragora 通過為 dnf
提供圖形化前端來解決此問題。
從上面可以看到,dnfdragora 似乎提供了 dnf
的所有主要功能。
Fedora 中還有其他工具也可以管理軟體包,GNOME 的“軟體”和“發現”就是其中兩個。GNOME “軟體”僅專注於圖形應用程式。你無法使用這個圖形化前端來安裝命令列或終端工具,例如 htop
或 weechat
。但是,GNOME “軟體”支援安裝 dnf
所不支援的 Flatpak 和 Snap 應用程式。它們是針對不同目標受眾的不同工具,因此提供了不同的功能。
這篇文章僅觸及到了 Fedora 軟體的生命週期的冰山一角。本文介紹了什麼是 RPM 軟體包,以及使用 rpm
和 dnf
的主要區別。
在以後的文章中,我們將詳細介紹: