在 Ubuntu 22.04 LTS 上安装 Visual Studio Code的脚本

作者:付汉杰 hankf@amd.com,本文转载自:博客园

Ubuntu 22.04 LTS上的软件仓库默认不包括Visual Studio Code。因此安装Visual Studio Code需要多个步骤。

为了简化操作,还是按老规矩,把所有命令写入一个脚本,一次性完成Visual Studio Code的安装。

echo "Install Visual Studio Code."
sudo apt update && sudo apt upgrade -y
sudo apt install software-properties-common apt-transport-https wget -y
#wget -O- https://packages.microsoft.com/keys/microsoft.asc | sudo gpg --dearmor | sudo tee /usr/share/keyrings/vscode.gpg
curl -sSL https://packages.microsoft.com/keys/microsoft.asc | sudo gpg --dearmor -o /usr/share/keyrings/vscode.gpg
echo deb [arch=amd64 signed-by=/usr/share/keyrings/vscode.gpg] https://packages.microsoft.com/repos/vscode stable main | sudo tee /etc/apt/sources.list.d/vscode.list
sudo apt update
sudo apt install code

# Test
echo "Run Visual Studio Code."
code &

执行记录如下

xilinx@xilinx-L5580:~/bin$ ./install_vscode.sh

Begin to run script: ./install_vscode.sh
Install Visual Studio Code
[sudo] password for xilinx:
Hit:1 http://security.ubuntu.com/ubuntu jammy-security InRelease
Hit:2 http://cn.archive.ubuntu.com/ubuntu jammy InRelease
Hit:3 http://cn.archive.ubuntu.com/ubuntu jammy-updates InRelease
Hit:4 http://mirrors.aliyun.com/ubuntu jammy InRelease
Hit:5 http://cn.archive.ubuntu.com/ubuntu jammy-backports InRelease
Hit:6 http://packages.ros.org/ros2/ubuntu jammy InRelease
Hit:7 http://mirrors.aliyun.com/ubuntu jammy-security InRelease
Hit:8 http://mirrors.aliyun.com/ubuntu jammy-updates InRelease
Hit:9 http://mirrors.aliyun.com/ubuntu jammy-proposed InRelease
Hit:10 http://mirrors.aliyun.com/ubuntu jammy-backports InRelease
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
3 packages can be upgraded. Run 'apt list --upgradable' to see them.
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Calculating upgrade... Done
The following packages have been kept back:
gnome-control-center gnome-control-center-data gnome-control-center-faces
0 upgraded, 0 newly installed, 0 to remove and 3 not upgraded.
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
wget is already the newest version (1.21.2-2ubuntu1).
software-properties-common is already the newest version (0.99.22.3).
apt-transport-https is already the newest version (2.4.7).
0 upgraded, 0 newly installed, 0 to remove and 3 not upgraded.
File '/usr/share/keyrings/vscode.gpg' exists. Overwrite? (y/N) y
deb [arch=amd64 signed-by=/usr/share/keyrings/vscode.gpg] https://packages.microsoft.com/repos/vscode stable main
Get:1 https://packages.microsoft.com/repos/vscode stable InRelease [3,959 B]
Get:2 https://packages.microsoft.com/repos/vscode stable/main amd64 Packages [318 kB]
Hit:3 http://mirrors.aliyun.com/ubuntu jammy InRelease
Hit:4 http://security.ubuntu.com/ubuntu jammy-security InRelease
Hit:5 http://cn.archive.ubuntu.com/ubuntu jammy InRelease
Hit:6 http://mirrors.aliyun.com/ubuntu jammy-security InRelease
Hit:7 http://packages.ros.org/ros2/ubuntu jammy InRelease
Hit:8 http://cn.archive.ubuntu.com/ubuntu jammy-updates InRelease
Hit:9 http://mirrors.aliyun.com/ubuntu jammy-updates InRelease
Hit:10 http://cn.archive.ubuntu.com/ubuntu jammy-backports InRelease
Hit:11 http://mirrors.aliyun.com/ubuntu jammy-proposed InRelease
Hit:12 http://mirrors.aliyun.com/ubuntu jammy-backports InRelease
Fetched 322 kB in 3s (124 kB/s)
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
3 packages can be upgraded. Run 'apt list --upgradable' to see them.
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following NEW packages will be installed:
code
0 upgraded, 1 newly installed, 0 to remove and 3 not upgraded.
Need to get 85.2 MB of archives.
After this operation, 359 MB of additional disk space will be used.
Get:1 https://packages.microsoft.com/repos/vscode stable/main amd64 code amd64 1.70.2-1660629410 [85.2 MB]
Fetched 85.2 MB in 52s (1,646 kB/s)
Selecting previously unselected package code.
(Reading database ... 348495 files and directories currently installed.)
Preparing to unpack .../code_1.70.2-1660629410_amd64.deb ...
Unpacking code (1.70.2-1660629410) ...
Setting up code (1.70.2-1660629410) ...
Processing triggers for gnome-menus (3.36.0-1ubuntu3) ...
Processing triggers for shared-mime-info (2.1-2) ...
Processing triggers for mailcap (3.70+nmu1ubuntu1) ...
Processing triggers for desktop-file-utils (0.26-1ubuntu3) ...

Run Visual Studio Code.
[1] 153425

最新文章

最新文章