<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Ubuntu &#8211; 寂静花园</title>
	<atom:link href="https://www.addesp.com/archives/tag/ubuntu/feed" rel="self" type="application/rss+xml" />
	<link>https://www.addesp.com</link>
	<description>寂静中交织着热情</description>
	<lastBuildDate>Mon, 25 Oct 2021 14:35:42 +0000</lastBuildDate>
	<language>zh-Hans</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.1.2</generator>
	<item>
		<title>apt 软件源格式解析</title>
		<link>https://www.addesp.com/archives/3406</link>
					<comments>https://www.addesp.com/archives/3406#respond</comments>
		
		<dc:creator><![CDATA[ADD-SP]]></dc:creator>
		<pubDate>Tue, 26 Jan 2021 20:13:57 +0000</pubDate>
				<category><![CDATA[随笔]]></category>
		<category><![CDATA[apt]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<guid isPermaLink="false">https://www.addesp.com/?p=3406</guid>

					<description><![CDATA[总之就是一篇看了也没什么用的文章，了解一下而已。]]></description>
										<content:encoded><![CDATA[
<h2 class="wp-block-heading">写在前面</h2>



<p class="wp-block-paragraph">每次安装完 Ubuntu 的第一件事情就是给 <code>apt</code> 换源，而换源过程基本就是复制粘贴，今天突然发现自己复制粘贴这么久也不知道粘贴了什么，于是了解了一下并分享出来。总之就是一篇看了也没什么用的文章，了解一下而已。</p>



<h2 class="wp-block-heading">正文</h2>



<p class="wp-block-paragraph">Linux 上有问题就先 <code>man</code> 一下，于是我 <code>man apt</code>，然后发现没有说关于 <code>source.list</code> 的格式，不过在手册的末尾最后发现有专门的文档讲解文件格式，于是 <code>man source.list</code>。</p>



<p class="wp-block-paragraph">其实 <code>apt</code> 源文件并不只有 <code>source.list</code>，也有一个叫 <code>source.sources</code>。两者的区别是格式不同。前者使用的格式称为 <code>ONE-LINE-STYLE</code>，也就是网上常见的一行一个的那种。后者使用的格式叫做 <code>DEB822-STYLE</code>，这种格式在网上应该比较少见。</p>



<h3 class="wp-block-heading">ONE-LINE-STYLE</h3>



<p class="wp-block-paragraph">这种格式是最常见的了，通常从网上复制粘贴来的就是这个格式。下面是 Ubuntu 20.04 LTS 的默认源。</p>



<pre class="wp-block-code"><code># See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://archive.ubuntu.com/ubuntu/ focal main restricted
# deb-src http://archive.ubuntu.com/ubuntu/ focal main restricted

## Major bug fix updates produced after the final release of the
## distribution.
deb http://archive.ubuntu.com/ubuntu/ focal-updates main restricted
# deb-src http://archive.ubuntu.com/ubuntu/ focal-updates main restricted

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team. Also, please note that software in universe WILL NOT receive any
## review or updates from the Ubuntu security team.
deb http://archive.ubuntu.com/ubuntu/ focal universe
# deb-src http://archive.ubuntu.com/ubuntu/ focal universe
deb http://archive.ubuntu.com/ubuntu/ focal-updates universe
# deb-src http://archive.ubuntu.com/ubuntu/ focal-updates universe

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team, and may not be under a free licence. Please satisfy yourself as to
## your rights to use the software. Also, please note that software in
## multiverse WILL NOT receive any review or updates from the Ubuntu
## security team.
deb http://archive.ubuntu.com/ubuntu/ focal multiverse
# deb-src http://archive.ubuntu.com/ubuntu/ focal multiverse
deb http://archive.ubuntu.com/ubuntu/ focal-updates multiverse
# deb-src http://archive.ubuntu.com/ubuntu/ focal-updates multiverse

## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
## Also, please note that software in backports WILL NOT receive any review
## or updates from the Ubuntu security team.
deb http://archive.ubuntu.com/ubuntu/ focal-backports main restricted universe multiverse
# deb-src http://archive.ubuntu.com/ubuntu/ focal-backports main restricted universe multiverse

## Uncomment the following two lines to add software from Canonical's
## 'partner' repository.
## This software is not part of Ubuntu, but is offered by Canonical and the
## respective vendors as a service to Ubuntu users.
# deb http://archive.canonical.com/ubuntu focal partner
# deb-src http://archive.canonical.com/ubuntu focal partner

deb http://security.ubuntu.com/ubuntu/ focal-security main restricted
# deb-src http://security.ubuntu.com/ubuntu/ focal-security main restricted
deb http://security.ubuntu.com/ubuntu/ focal-security universe
# deb-src http://security.ubuntu.com/ubuntu/ focal-security universe
deb http://security.ubuntu.com/ubuntu/ focal-security multiverse
# deb-src http://security.ubuntu.com/ubuntu/ focal-security multiverse</code></pre>



<p class="wp-block-paragraph">下面是此风格的基本格式。</p>



<pre class="wp-block-code"><code>deb &#91; option1=value1 option2=value2 ] uri suite &#91;component1] &#91;component2] &#91;...]
deb-src &#91; option1=value1 option2=value2 ] uri suite &#91;component1] &#91;component2] &#91;...]</code></pre>



<ul class="wp-block-list"><li>deb：表示从这里可以找到二进制程序，即包含已经编译好的程序。</li><li>deb-src：表示从这里找到源码。</li><li>option：表示额外的选项，比如 <code>arch</code> 表示体系结构，<code>amd64</code> 啥的。语法上不仅支持 <code>option=value1</code> 也支持 <code>option=value1,value2</code>  、<code>option-=value</code> 和 <code>option+=value</code>。<code>+=</code> 和 <code>-=</code> 仅支持那些可能有多个值的选项。</li><li>uri：就是源的网址，比如腾讯的 apt 源的网址就是 <a href="http://mirrors.cloud.tencent.com/ubuntu/" target="_blank" rel="noreferrer noopener">http://mirrors.cloud.tencent.com/ubuntu/</a>。</li><li>suite：代表发行版的类型如 <code>stable</code>。也可以代表发行版的代号比如 Ubutnu 20.24 LTS 的代号就是 <code>focal</code>。<a href="#参考资料"><sup>[3]</sup></a>所以说如果你用的是 Ubutnu 18.04，那么你应该写 <code>bionic</code>，因为这个版本的代号就叫 <code>bionic</code>。<a href="https://www.addesp.com/wp-admin/post.php?post=3406&amp;action=edit#%E5%8F%82%E8%80%83%E8%B5%84%E6%96%99"><sup>[3]</sup></a>不过版本代号后面可能还会跟着如 <code>-backports</code> 这样的后缀，相关信息见 <a href="https://help.ubuntu.com/community/UbuntuUpdates" target="_blank" rel="noreferrer noopener">UbuntuUpdates &#8211; Community Help Wiki</a>。</li><li>component：表示软件包的分类，不同的 Linux 发行版有不同的分类。对于 Ubuntu 来说有下面的几种。<ul><li>main：由 <a href="https://baike.baidu.com/item/Canonical" target="_blank" rel="noreferrer noopener">Canonical</a> 支持的自由和开源软件。<a href="#参考资料" rel="nofollow"><sup>[1]</sup></a></li><li>universe：由社区维护的自由和开源软件。<a href="#参考资料" title="#参考资料"><sup>[1]</sup></a></li><li>restricted：设备驱动程序。<a href="#参考资料" title="#参考资料"><sup>[1]</sup></a></li><li>multiverse：受版权或法律问题限制的软件。<a href="#参考资料" title="#参考资料"><sup>[1]</sup></a></li></ul></li></ul>



<h3 class="wp-block-heading">DEB822-STYLE</h3>



<p class="wp-block-paragraph">此格式从 <code>apt 1.1</code> 开始支持，文件必须以 <code>.sources</code> 结尾。下面是它的基本格式。</p>



<pre class="wp-block-code"><code>Types: deb deb-src
URIs: uri
Suites: suite
Components: &#91;component1] &#91;component2] &#91;...]
option1: value1
option2: value2

Types: deb deb-src
URIs: uri
Suites: suite
Components: &#91;component1] &#91;component2] &#91;...]
option1: value1
option2: value2</code></pre>



<p class="wp-block-paragraph">同一条目中的每个字段各占一行，不同的条目间用一行空行分隔。各个字段的含义与 <code>ONE-LINE-STYLE</code> 中的完全相同。你也可以通过添加一行 <code>Enabled: no</code> 来禁用某一个条目。如果一个字段有多个值则每个值之间用空格分隔。</p>



<h3 class="wp-block-heading">例子</h3>



<p class="wp-block-paragraph">下面的两种格式的源配置是等效的。</p>



<pre class="wp-block-code"><code>deb http://us.archive.ubuntu.com/ubuntu focal main restricted
deb http://security.ubuntu.com/ubuntu focal-security main restricted
deb http://us.archive.ubuntu.com/ubuntu focal-updates main restricted</code></pre>



<pre class="wp-block-code"><code>Types: deb
URIs: http://us.archive.ubuntu.com/ubuntu
Suites: focal focal-updates
Components: main restricted

Types: deb
URIs: http://security.ubuntu.com/ubuntu
Suites: focal-security
Components: main restricted</code></pre>



<h2 class="wp-block-heading" id="参考资料">参考资料</h2>



<ul class="wp-block-list"><li>[1] <a href="https://help.ubuntu.com/community/Repositories/Ubuntu" target="_blank" rel="noreferrer noopener">Repositories/Ubuntu &#8211; Community Help Wiki</a></li><li>[2] <a href="https://help.ubuntu.com/community/UbuntuUpdates" target="_blank" rel="noreferrer noopener">UbuntuUpdates &#8211; Community Help Wiki</a></li><li>[3] <a href="https://wiki.ubuntu.com/DevelopmentCodeNames" target="_blank" rel="noreferrer noopener">DevelopmentCodeNames &#8211; Ubuntu Wiki</a></li></ul>
]]></content:encoded>
					
					<wfw:commentRss>https://www.addesp.com/archives/3406/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
