Let’s say that I have a computer that I installed Ubuntu 14.04 x86-64 also known as amd64. I want to download a package, but I want to download the package and its dependencies from a different architecture instead of amd64. In this scenario, I want to download a package from arm64 architecture.

Enable Another Architecture to Download

First, we will add a new architecture to be able to select when installing or downloading any package. Instead of arm64, you can substitute any architecture abbreviated name in the following command.

sudo dpkg --add-architecture arm64

Update sources.list

To get access to arm64 packages, we need to add additional sources to our sources.list where apt-get finds its packages.

sudo vi /etc/apt/sources.list

Add the following URLs to the file. Note that I am using Ubuntu 14.04, which is code named: trusty. You will use a different code name at the end of the URLs if you have a different version of Ubuntu.

# source urls for arm64
deb http://ports.ubuntu.com/ubuntu-ports/ trusty main restricted
deb-src http://ports.ubuntu.com/ubuntu-ports/ trusty main restricted
deb http://ports.ubuntu.com/ubuntu-ports/ trusty-updates main restricted
deb-src http://ports.ubuntu.com/ubuntu-ports/ trusty-updates main restricted
deb http://ports.ubuntu.com/ubuntu-ports/ trusty universe
deb-src http://ports.ubuntu.com/ubuntu-ports/ trusty universe
deb http://ports.ubuntu.com/ubuntu-ports/ trusty-updates universe
deb-src http://ports.ubuntu.com/ubuntu-ports/ trusty-updates universe
deb http://ports.ubuntu.com/ubuntu-ports/ trusty multiverse
deb-src http://ports.ubuntu.com/ubuntu-ports/ trusty multiverse
deb http://ports.ubuntu.com/ubuntu-ports/ trusty-updates multiverse
deb-src http://ports.ubuntu.com/ubuntu-ports/ trusty-updates multiverse

We need to update our sources list with the new URLs so that we can download packages for arm64.

sudo apt-get update

How to Download Ubuntu Packages and Dependencies Locally

Afterwards, we should make a directory to store the packages that we want to download.

mkdir arm64-packages

Now, we download the package inside that directory. For instance, let’s say that we wanted to download vim and not install it. To download arm64 architecture packages, you have to place :arm64 after the package name. If you don’t put the architecture name after the package, then the default architecture in my case amd64 will be downloaded.

Where vim:arm64 is, you can replace with the name of any package available through apt-get followed by :arm64.

cd arm64-packages
for i in $(apt-cache depends vim:arm64 | grep -E 'Depends|Recommends|Suggests' | cut -d ':' -f 2,3 | sed -e s/'<'/''/ -e s/'>'/''/); do sudo apt-get download $i 2>>no32.txt; done

Any errors will be outputted inside no32.txt. If you ls, then you should see all of the deb packages and dependencies for arm64.