Skip to content

Instantly share code, notes, and snippets.

@ThinGuy
Last active May 5, 2024 10:00
Show Gist options
  • Save ThinGuy/21e7b3bb4b63404ad87541cd0ffebf09 to your computer and use it in GitHub Desktop.
Save ThinGuy/21e7b3bb4b63404ad87541cd0ffebf09 to your computer and use it in GitHub Desktop.
Fix apt architecture error messages: "...doesn't support architecture 'i386'"
# To prevent unsuppoorted architecture error messages from apt on Ubuntu 24.04 (Noble Numbat)
# with the new apt sources format
# Example error messages on `apt update` after a fresh install:
# N: Skipping acquire of configured file 'main/binary-i386/Packages' as repository 'https://packages.microsoft.com/repos/edge stable InRelease' doesn't support architecture 'i386'
# N: Skipping acquire of configured file 'main/binary-i386/Packages' as repository 'https://dl.google.com/linux/chrome/deb stable InRelease' doesn't support architecture 'i386'
#################################################
### SINGLE-ARCH (i.e. fix arch-related error) ###
#################################################
# Example for X86_64 (Keeping amd64, removing i386)
[[ $(dpkg --print-foreign-architectures) =~ i386 ]] && { sudo dpkg --remove-architecture i386; }
sudo sed -r -i '/^Arch/d;s/URIs:/Architectures: amd64\n&/g' /etc/apt/sources.list.d/*.sources
# Example for ARM64 (Keeping arm64, removing armhf)
[[ $(dpkg --print-foreign-architectures) =~ armhf ]] && { sudo dpkg --remove-architecture armhf; }
sudo sed -r -i '/^Arch/d;s/URIs:/Architectures: arm64\n&/g' /etc/apt/sources.list.d/*.sources
#################################################
### MULTI-ARCH (i.e. for cross compiling) ###
#################################################
# Supported Debian architecture names by Ubuntu release:
#
# Ubuntu 16.04 (Xenial Xerus): amd64, i386, arm64, armhf, powerpc, ppc64el, s390x
# Ubuntu 18.04 (Bionic Beaver): amd64, i386, arm64, armhf, ppc64el, s390x
# Ubuntu 20.04 (Focal Fossa): amd64, i386, arm64, armhf, ppc64el, riscv64, s390x
# Ubuntu 22.04 (Jammy Jellyfish): amd64, i386, arm64, armhf, ppc64el, riscv64, s390x
# Ubuntu 24.04 (Noble Numbat): amd64, i386, arm64, armhf, ppc64el, riscv64, s390x
# Ubuntu 24.10 (Oracular Oriole): amd64, arm64, i386, ppc64el, riscv64, s390x
# First add the architectures desired
for A in amd64 arm64 riscv64 do;
[[ $(dpkg --print-foreign-architectures) =~ ${A} ]] || { sudo dpkg --add-architecture ${A}; }
done
# NOTE: Use space-separated debian machine architecture names for multi arch
sudo sed -r -i '/^Arch/d;s/URIs:/Architectures:\x20amd64\x20arm64\x20riscv64\n&/g' /etc/apt/sources.list.d/*.sources
@ThinGuy
Copy link
Author

ThinGuy commented May 1, 2024

$ sudo apt update
Hit:1 https://packages.microsoft.com/repos/edge stable InRelease
Hit:2 http://security.ubuntu.com/ubuntu noble-security InRelease
Hit:3 https://esm.ubuntu.com/apps/ubuntu noble-apps-security InRelease
Hit:4 https://esm.ubuntu.com/apps/ubuntu noble-apps-updates InRelease
Hit:5 https://esm.ubuntu.com/infra/ubuntu noble-infra-security InRelease
Hit:6 https://esm.ubuntu.com/infra/ubuntu noble-infra-updates InRelease
Hit:7 https://dl.google.com/linux/chrome/deb stable InRelease
Hit:8 http://us.archive.ubuntu.com/ubuntu noble InRelease
Hit:9 http://us.archive.ubuntu.com/ubuntu noble-updates InRelease
Hit:10 http://us.archive.ubuntu.com/ubuntu noble-backports InRelease
Hit:11 http://us.archive.ubuntu.com/ubuntu noble-proposed InRelease
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
All packages are up to date.
N: Skipping acquire of configured file 'main/binary-i386/Packages' as repository 'https://packages.microsoft.com/repos/edge stable InRelease' doesn't support architecture 'i386'
N: Skipping acquire of configured file 'main/binary-i386/Packages' as repository 'https://dl.google.com/linux/chrome/deb stable InRelease' doesn't support architecture 'i386'

$ cat google-chrome.sources microsoft-edge.sources
Types: deb
URIs: https://dl.google.com/linux/chrome/deb/
Suites: stable
Components: main
Signed-By: ...

Types: deb
URIs: https://packages.microsoft.com/repos/edge/
Suites: stable
Components: main
Signed-By: ...

$ [[ $(dpkg --print-foreign-architectures) =~ i386 ]] && { sudo dpkg --remove-architecture i386; }
$ sudo sed -r -i '/^Arch/d;s/URIs:/Architectures: amd64\n&/g' /etc/apt/sources.list.d/*.sources

$ cat google-chrome.sources microsoft-edge.sources
Types: deb
Architectures: amd64
URIs: https://dl.google.com/linux/chrome/deb/
Suites: stable
Components: main
Signed-By: ...

Types: deb
Architectures: amd64
URIs: https://packages.microsoft.com/repos/edge/
Suites: stable
Components: main
Signed-By: ...

$ sudo apt update
Hit:1 http://us.archive.ubuntu.com/ubuntu noble InRelease
Hit:2 https://dl.google.com/linux/chrome/deb stable InRelease
Hit:3 https://packages.microsoft.com/repos/edge stable InRelease
Get:4 http://us.archive.ubuntu.com/ubuntu noble-updates InRelease [89.7 kB]
Hit:5 http://security.ubuntu.com/ubuntu noble-security InRelease
Hit:6 http://us.archive.ubuntu.com/ubuntu noble-backports InRelease
Get:7 https://esm.ubuntu.com/apps/ubuntu noble-apps-security InRelease [7,469 B]
Get:8 http://us.archive.ubuntu.com/ubuntu noble-proposed InRelease [256 kB]
Get:9 https://esm.ubuntu.com/apps/ubuntu noble-apps-updates InRelease [7,468 B]
Get:10 https://esm.ubuntu.com/infra/ubuntu noble-infra-security InRelease [7,462 B]
Get:11 https://esm.ubuntu.com/infra/ubuntu noble-infra-updates InRelease [7,461 B]
Fetched 375 kB in 1s (294 kB/s)
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
All packages are up to date.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment