2

Suppose I install a package on a debian based system via sudo aptitude install mypackage. Suppose the package is big and it takes long to download and install it.

When I notice that I want to install another package after invoking that command I have to wait until the first package is completely installed.

Is it possible to make aptitude to start automatically installing the second package, after the first one is finished?

student
  • 18,305

1 Answers1

4

You can list multiple packages to install at once:

aptitude install package1 package2

If you truly care about the order in which they are installed (you almost definitely don't, as aptitude takes into account dependencies and other subtleties automatically), or are looking for a more general solution, do something like the following:

aptitude install package1 && aptitude install package2

The logical AND (&&) operator will only perform the second command if the one preceding it succeeded (returned exit status 0).

If you are asking how to do this even after you initially did the command, try this another terminal:

aptitude-after() {
    printf '%s\n' "Waiting for current aptitude operations to finish"
    while pgrep -x aptitude >/dev/null 2>&1; do
        sleep 10
    done
    printf '%s\n' "Done, running new instance of aptitude."
    aptitude "$@"
}

Run it as aptitude-after install mypackage2. It will wait for all current instances of aptitude to finish.

Chris Down
  • 125,559
  • 25
  • 270
  • 266
  • Yes, that's clear. My problem is how to do it, when the install process of the first package is already running. Then I could wait until it is finished and start the installation of the second package. But is there a way to make aptitude install the package automatically after the first one is finished? – student Nov 09 '12 at 17:06
  • 1
    @student Ah, okay. I updated my answer. – Chris Down Nov 09 '12 at 17:08