C/C++教程

m1芯片的macbook ubuntu apt换源失败的解决方法

本文主要是介绍m1芯片的macbook ubuntu apt换源失败的解决方法,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

先上结论

m1芯片的mac应使用以下源(适用20.04版本):

deb http://mirrors.aliyun.com/ubuntu-ports/ focal main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu-ports/ focal-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu-ports/ focal-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu-ports/ focal-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu-ports/ focal-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu-ports/ focal main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu-ports/ focal-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu-ports/ focal-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu-ports/ focal-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu-ports/ focal-backports main restricted universe multiverse

再讲原因

因为架构的原因,在x86和arm下ubuntu所使用的源是不同的,两者无法混用

在Intel或Amd处理器下,通过Docker安装的ubuntu自带的源为

deb http://archive.ubuntu.com/ubuntu/ focal-backports main restricted universe multiverse

而在m1芯片下则为

deb http://ports.ubuntu.com/ubuntu/ focal-backports main restricted universe multiverse

区别就在于前面的archiveports

以阿里云的镜像源为例,在阿里云镜像的官方网站上为ubuntu 20.04提供的源为

deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse

不难看出,只需将域名后的ubuntu改为ubuntu-ports即可。

此外,再提供一个可以直接在命令行中使用的换源命令

cd /etc/apt && mv sources.list sources.list.bk && echo -e " deb http://mirrors.aliyun.com/ubuntu-ports/ focal main restricted universe multiverse\n deb http://mirrors.aliyun.com/ubuntu-ports/ focal-security main restricted universe multiverse\n deb http://mirrors.aliyun.com/ubuntu-ports/ focal-updates main restricted universe multiverse\n deb http://mirrors.aliyun.com/ubuntu-ports/ focal-proposed main restricted universe multiverse\n deb http://mirrors.aliyun.com/ubuntu-ports/ focal-backports main restricted universe multiverse\n deb-src http://mirrors.aliyun.com/ubuntu-ports/ focal main restricted universe multiverse\n deb-src http://mirrors.aliyun.com/ubuntu-ports/ focal-security main restricted universe multiverse\n deb-src http://mirrors.aliyun.com/ubuntu-ports/ focal-updates main restricted universe multiverse\n deb-src http://mirrors.aliyun.com/ubuntu-ports/ focal-proposed main restricted universe multiverse\n deb-src http://mirrors.aliyun.com/ubuntu-ports/ focal-backports main restricted universe multiverse" > sources.list
这篇关于m1芯片的macbook ubuntu apt换源失败的解决方法的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!