温故知新,从VSCode安装了解Debian/Ubuntu下安装
<p><img src="https://img2022.cnblogs.com/blog/375390/202208/375390-20220818142756859-1460987581.png" alt="image" loading="lazy"></p><h2 id="谈安装">谈安装</h2>
<h3 id="原文">原文</h3>
<p>The easiest way to install Visual Studio Code for Debian/Ubuntu based distributions is to download and install the .deb package (64-bit), either through the graphical software center if it's available, or through the command line with:</p>
<p><em>为基于Debian/Ubuntu的发行版安装Visual Studio Code的最简单方法是下载并安装.deb包(64位),如果有的话,可以通过图形化软件中心,或者通过命令行来安装。</em></p>
<pre><code class="language-bash">sudo apt install ./<file>.deb
# If you're on an older Linux distribution, you will need to run this instead:
# sudo dpkg -i <file>.deb
# sudo apt-get install -f # Install dependencies
</code></pre>
<h3 id="解析">解析</h3>
<p>首先针对Debian/Ubuntu系统,VSCode给了一个64位的Deb包,名称是<code>code_1.70.2-1660629410_amd64.deb</code>,这里<code>code</code>是VSCode产品名称,<code>1.70.2</code>是程序版本号,<code>1660629410</code>估计是一个编译号,<code>amd64</code>代表<code>x86_x64</code>。</p>
<p>接下来,从安装命令来看,它优先推荐使用<code>apt</code>来安装。</p>
<p>并且备注如果使用较老版本的Linux分支,可以使用<code>dpkg</code>或者<code>apt-get</code>来替代。</p>
<p>说明,在最新的系统版本中,已经更推荐<code>apt</code>方式了。</p>
<h2 id="谈证书">谈证书</h2>
<h3 id="原文-1">原文</h3>
<p>Installing the .deb package will automatically install the apt repository and signing key to enable auto-updating using the system's package manager. Alternatively, the repository and key can also be installed manually with the following script:</p>
<p><em>安装.deb包会自动安装apt仓库和签名密钥,以便使用系统的软件包管理器实现自动更新。另外,仓库和密钥也可以用下面的脚本手动安装。</em></p>
<pre><code class="language-bash">sudo apt-get install wget gpg
wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > packages.microsoft.gpg
sudo install -D -o root -g root -m 644 packages.microsoft.gpg /etc/apt/keyrings/packages.microsoft.gpg
sudo sh -c 'echo "deb https://packages.microsoft.com/repos/code stable main" > /etc/apt/sources.list.d/vscode.list'
rm -f packages.microsoft.gpg
</code></pre>
<h3 id="解析-1">解析</h3>
<p>这一步,先引导安装<code>wget</code>和<code>gpg</code>这两个组件。</p>
<p>然后通过<code>wget</code>把微软的asc拉下来,并转成gpg,存储为<code>packages.microsoft.gpg</code>。</p>
<p>然后安装<code>packages.microsoft.gpg</code>到<code>/etc/apt/keyrings/packages.microsoft.gpg</code></p>
<p>接下来将一段签名配置写入到<code>/etc/apt/sources.list.d/vscode.list</code>这个配置中。</p>
<p>最后清理掉<code>packages.microsoft.gpg</code>。</p>
<h2 id="谈更新">谈更新</h2>
<h3 id="原文-2">原文</h3>
<p>Then update the package cache and install the package using:</p>
<p><em>然后更新软件包的缓存,并使用安装软件包。</em></p>
<pre><code class="language-bash">sudo apt install apt-transport-https
sudo apt update
sudo apt install code # or code-insiders
</code></pre>
<h3 id="解析-2">解析</h3>
<p>先安装<code>apt</code>对https的一个支持组件<code>apt-transport-https</code></p>
<p>然后更新一下<code>apt</code>的索引。</p>
<p>接着就是通过<code>apt</code>来安装代号为<code>code</code>的软件。</p>
<h2 id="参考">参考</h2>
<ul>
<li>Visual Studio Code on Linux</li>
</ul><br><br>
来源:https://www.cnblogs.com/taylorshi/p/16598601.html
頁:
[1]