Why the software center doesn't allow multiple downloads?

I was wondering why the software center doesn't download all the requested apps and install one by one as they finish to download. Or instead why the software center doesn't download an app while the other is installing


Solution 1:

That is a good question. It is because it's based on the same package tools that apt-get and others use. These are designed in a way that expects you to provide all the packages to be installed, and then the rest is automatic. This is very good in most cases, but for the Software Center, it causes some issues. You would either need to first select the packages you want to install and then click a button to actually download and install them, or you have to queue applications and then download and install one by one. This provides a much better user experience if you're installing one application than having to use those extra clicks, but it is also annoying when you're "shopping".

It is possible to fix this, so I expect that in the future, this will be remedied, but it does mean recreating or rewriting existing tools, so I don't think it'll have very high priority.

Let me elaborate:

A package may depend on other packages. If these packages aren't available, then the package cannot be installed. So tools like apt-get will first download all the packages you ask for and all the packages they depend on, etc, and then install all of them. So you would then normally provide all the packages you wanted in one go, and they would first be downloaded and then installed.

When you choose to install an application in the software center, you'll usually want it to start downloading and installing immediately. But in order to ensure that everything is in order, only one installation can be done at any one time. That's why when you install an application, you have to wait until that application is completely downloaded and installed before the next download and install can begin.

This could be fixed by not using apt-get to install the packages, but instead downloading the packages manually and then using dpkg to install them once they're ready. You still wouldn't be able to install two packages simultaneously, but you would be able to start downloading new packages while the previously started installations were finishing. In some cases, that would save quite some time, so it is a good idea. But in most cases, it wouldn't really matter so the effort is better focused elsewhere.

Solution 2:

you can only install one package at the time with sudo apt-get install, but you can install several packages with one command. Like this:

  • sudo apt-get install ubuntu-desktop lubuntu-desktop

This will install both ubuntu-desktop and lubuntu-desktop and whatever dependencies they require, in the correct sequence.

Also when you update your system with sudo apt-get upgrade, you first download all the software and then install one package at the time.

The reason
Why you can't install several packages at once is that only one instance can use the apt-get privileges at the same time. This is because apt-get locks on the software sources and blocks any other command from using them.

An example
Let's say that you somehow starts 2 separate apt-get as @Rinzwind says, then you could in theory at least edit the source list at same time as you use it to find and install new software. This could lead to that a program that you've installed edits the source list and adds an unsafe repository at the same time as you are upgrading your system. This could be a security issue.

Another example
Also if you edit the source list at 2 separate commands then when you save you would replace the newest version, which will be the one that it's save last. Which means that command in the middle wouldn't have any effect, since you would save over an old version.


Windows behaves similarly using the "official" (MSI) installer

Even in Windows,multiple softwares can be installed simultaneously ... is there an advantage in this or why this is a necessity in linux/ubuntu,etc...

Packages that use the official Windows installer (MSI) WILL REFUSE to run more than one instance at a time. That's because the MSI installer database is similar to sources.list, dpkg info files, etc. -- you don't want more than one installer modifying/locking them at a time.

But a lot of Windows packages use third-party installers like Installshield, NSIS, etc. which will run alongside each other because they do not need to access/modify the MSI database. Similarly, in Linux/Ubuntu, no one's stopping you from running an apt-get, a tar -xzf and a perl/bash install script all at the same time :)

Solution 3:

First, let it be known that this answer is from what I've gleaned from my experiences with dpkg and apt. I haven't looked at the actual software center code to determine this.

It's a limit of the design of the underlying software.

Part of the dpkg system that Ubuntu uses for packages includes a feature that "locks" the /var/lib/dpkg/lock file to prevent multiple dpkg (apt-get and Ubuntu Software Center are front ends) from overwriting itself and other bad, evil things.

What happens when you install software? What happens is it starts sudo apt-get install chromium-browser (to use Chromium as an example).

And when that happens, a lock kicks in. Once you add more than one package to be installed, what happens next is it waits until the first one is done before it starts the next apt command.

Solution 4:

Some actions, like refreshing the menu's, indexing fonts and reconfiguring the libraries need to happen only once if all packages are installed at the same time. A second advantage hopefully shouldn't happen often, but if you want to install packages which exclude eachother you know it prior to downloading all of them.

A last advantage is mostly important when you install or upgrade many packages at once: if questions have to be answered, they will all come after eachother during the install progress. So you can keep working instead of being bugged every 5 minutes by a different question.

Solution 5:

The reason that two instances of apt-get cannot operate simultaneously is because the application is reading/writing several files critical for the system operation. Reading or writing a file by an apt-get operation, while another is performing the same operations on it will lead to problems of bad configuration and/or damage of the files. So when an apt-get operation occurs, it "locks" the files it needs so another operation cannot be executed simultaneously, a.k.a. it raises a flag that tells the other operations that the files are currently in use.

However, simultaneous downloads of the files needed by apt (or rather download from a number of sources) are possible with the command apt-fast

https://github.com/ilikenwf/apt-fast