24

I am currently in a architecture amd64, so when I try apt-get download vlc, it downloaded the appropriate architecture for my system, but how can I download the i386 version via apt?

It's for export to another system that doesn't have internet connection, also is there is any way to download any dependencies that follow?

1
  • Do you want to install it?
    – Braiam
    Feb 15, 2014 at 0:56

5 Answers 5

22

Yes you can, just append :i386 to the download command, like this:

sudo apt-get download <package>:i386  

So for you:

sudo apt-get download vlc:i386  

I am unaware of any way of automatically downloading a packages dependencies, besides build-dep but that won't work in your case.

After poking in the manpage a bit more, I have found that you can, in fact, use build-dep to an extent like this:

sudo apt-get build-dep --download-only vlc:i386  

Which will then download the required packages into the current directory. Note however, that build-dep is looking at compiling the package from source, not installing it from a .deb so it will suggest things like build-essential and gcc which may be needed to compile vlc, but not necessarily install from a .deb.

It may be easier to list vlc's main dependencies with apt-cache:

apt-cache depends vlc:i386  

If you want to filter by just depends use:

apt-cache depends vlc:i386 | grep 'Depends'  

Note that some packages, like libc6 come by default in Ubuntu, so you won't need to download those. If you just want to download all the dependencies and deal with whether you need them or not later you can use this script:

for i in $(apt-cache depends vlc:i386 | 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  

This will download all the dependent, recommended, and suggested packages and reroute any errors to no32.txt. You should take a look in there when you're done, because some needed packages that don't have i386 versions (i.e. they aren't binaries) will be in there.

Just apt-get download those.

Note that this script isn't very smart, it doesn't take a lot of things into account, so you may get some silly errors, it should work in general however.

7
  • And what about build-dep package:i386?
    – enedil
    Feb 15, 2014 at 1:19
  • @enedil build-dep downloads and installs, so this would install a bunch of i386 packages on his machine, which is not what he wants. See man apt-get for details.
    – Seth
    Feb 15, 2014 at 1:22
  • There is also an aptitude download command. Not sure if it is multiarch enabled though. Feb 18, 2014 at 21:05
  • @FaheemMitha Yes, aptitude can do just about everything apt-get can.
    – Seth
    Feb 18, 2014 at 21:07
  • 1
    @saterHater I believe Ubuntu stopped building i386 packages with 19.10 or 20.04 (discourse.ubuntu.com/t/…). If that's not what you meant then please further elaborate.
    – Seth
    Jul 18, 2020 at 23:11
4

I figured out if you just want to download a package and all the dependencies as a specific architecture, there is a sneaky way to do it that shouldn't permanently impact your system. For bonus points/isolation you can do this in a Docker container to really avoid messing with your host system at all other than a folder shared in to save the deb packages in.

# You can supply a space separated list or just one package
DESIRED_PACKAGES="dnsmasq-base"

# You need to tell dpkg about a new "foreign" architecture
sudo dpkg --add-architecture arm64

# Now we update the package lists and tell it to ONLY get the architecture we want
sudo apt update -o APT::Architecture="arm64" -o APT::Architectures="arm64"

# Now call install, but with download-only, because it will fetch the dependencies where apt-get download only grabs a single package
sudo apt-get install --download-only -o Dir::Cache="./" -o Dir::Cache::archives="./" dnsmasq-base -y

If you aren't just doing i386 on an amd64 system (semi-compatible), then on the system where you actually want to install these packages, you will probably need to sudo dpkg -i *.deb in the folder you save them, because the newer sudo apt install ./some-package.deb gets confused by the dependency resolution and won't behave nicely.

Docker version

docker run -it --rm -v $(pwd):/work -w /work debian:buster

Then run the same script from above, but you won't need sudo because the container runs as root by default. Once you have run the commands and downloaded the files, you can type exit to get out of the container, and then you will need to sudo chown $USER: *.deb to allow your host user to access the deb files to move/copy/delete.

2

With the help of the answers posted by others here (and there) I came up with the following script that might save someone's time:

docker run --name arm64-packages --rm -dit ubuntu:20.04 bash
docker exec arm64-packages dpkg --add-architecture arm64
docker exec -i arm64-packages bash <<EOF
cat > /etc/apt/sources.list.d/arm64.list <<LIST
deb [arch=arm64] http://ports.ubuntu.com/ focal main restricted
deb [arch=arm64] http://ports.ubuntu.com/ focal-updates main restricted
deb [arch=arm64] http://ports.ubuntu.com/ focal universe
deb [arch=arm64] http://ports.ubuntu.com/ focal-updates universe
deb [arch=arm64] http://ports.ubuntu.com/ focal multiverse
deb [arch=arm64] http://ports.ubuntu.com/ focal-updates multiverse
deb [arch=arm64] http://ports.ubuntu.com/ focal-backports main restricted universe multiverse
LIST
EOF
docker exec arm64-packages apt-get update || : # Is expected to return error.
docker exec arm64-packages apt-get download libc6:arm64
package_path=$(docker exec arm64-packages ls / | grep libc6)
docker cp arm64-packages:$package_path ./libc6_arm64.deb
1
0

One way you can do this is by using chroot or proot on the host system to create an isolated filesystem of the appropriate architecture. You can then run apt in that emulated environment to install the architecture specific packages just as if you were on a machine of that architecture. It does run a bit slower since it is emulating the architecture, but you then have a rootfs that you can deploy to your other device of a different architecture.

0

You could try parsing the output of apt install --simulate and then run apt download for each package.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .