9

I want to add these four ppa's to my machine.

sudo add-apt-repository ppa:noobslab/malys-themes
sudo add-apt-repository ppa:alecive/antigone
sudo add-apt-repository ppa:nitrux/nitrux-artwork
sudo add-apt-repository ppa:upubuntu-com/themes

Instead of adding them one-at-a-time, I thought I would list them one after another - like we do when installing apps.

sudo add-apt-repository ppa:noobslab/malys-themes ppa:alecive/antigone ppa:nitrux/nitrux-artwork ppa:upubuntu-com/themes

But it returned an error: Error: need a repository as argument

I searched around and saw this question How to install multiple PPAs and applications at once? but it proposes a bash script as a solution.

Is there a way to add multiple ppa's at once without using a script?


EDIT
Am just curious, why doesn't

sudo add-apt-repository ppa:noobslab/malys-themes ppa:alecive/antigone ppa:nitrux/nitrux-artwork ppa:upubuntu-com/themes

work but

sudo apt-get install moka-icon-theme moka-icon-theme-blue moka-icon-theme-dark malys-deda awoken-icon-theme nitrux-icon-theme nouvegnomegray

works?

EDIT 2
Is there any workaround where

sudo add-apt-repository ppa:noobslab/malys-themes ppa:alecive/antigone ppa:nitrux/nitrux-artwork ppa:upubuntu-com/themes

can be made to work?
And I totally understand the risks here.

2
  • 4
    Through the add-apt-repository command, you can be able to add only one PPA at a time. Mar 6 '14 at 14:15
  • You could always just select those sudo add-apt lines and paste them directly into your terminal. That will cause them to be added sequentially but with a single click from you.
    – terdon
    Mar 7 '14 at 17:58
11
+50

It doesn't work because who wrote the original script (you can look at it, it's a python script) didn't think that could be useful.

The rationale may be that adding a repository is a thing that is better done slowly. You should check the signature for example --- and double check you really want it.

So it's basically a design decision. You could probably easily modify the script if you want it, or repeating the command on the command line...

for i in ppa:noobslab/malys-themes ppa:alecive/antigone ppa:nitrux/nitrux-artwork ppa:upubuntu-com/themes; do sudo add-apt-repository $i; done

(is that a script or not? A rose is a rose under another name?)

Don't do this, but... unix is famous for letting user shooting themselves in the foot,so...

If you really want your "multiple add-apt-repository"(1) work, do this:

1) find where add-apt-repository is.

(0)samsung-romano:~% which add-apt-repository
/usr/bin/apt-add-repository

2) rename it

(0)samsung-romano:~% sudo mv /usr/bin/add-apt-repository /usr/bin/add-apt-repository.real

3) replace it with a simple script:

(0)samsung-romano:~% sudo gedit /usr/bin/add-apt-repository 

with the contents:

#! /bin/bash
# 
for i in "$@"; do
   /usr/bin/add-apt-repository.real "$i"
done

4) make it executable:

(0)samsung-romano:~% chmod a+rx /usr/bin/add-apt-repository

5) and now you can use your command:

(0)samsung-romano:~% sudo add-apt-repository ppa:noobslab/malys-themes ppa:alecive/antigone ppa:nitrux/nitrux-artwork ppa:upubuntu-com/themes

Why you should not do it? Because next time there will be an update to the package that contains the original apt-add-repository, problems will arise. Like having your script overwritten or (worst) not having the package updated.

It is in effect much better to avoid touching the system program and simply put the script in your ~/bin with another name, like my_aptadd. You are now safe and happy.

Or if you are really fond of the original name, you can create a directory in your home folder like ~/override, prepend it to your PATH in .profile (like export PATH=$HOME/override:$PATH), and save the script there --- obviously with the full path, original /usr/bin/add-apt-repository in it to avoid an infinite loop. You will then regret it when someone will drop a file called "ls" in it with content exe rm $*(2), but hey...

So why I wrote it here? Because this is really a useful technique sometime to "fix" programs that otherwise will not run. For example, I have this to add environment variables to programs that otherwise will misbehave, and that are called by other programs that I can't or won't modify.


Footnotes:

(1) I never noticed before but in my system exists even apt-add-repository, which is a symlink to add-apt-repository. I can understand why, but it's a call for a mess waiting to happen...

(2) it's wrong. On purpose.

0
4

I've been over this before when talking about how to backup installed PPAs. The following takes a file where all your PPAs are listed and installs them:

<~/ppa-backup.txt xargs -I % sudo add-apt-repository %

It's fairly trivial to tune that to take a list:

xargs -I % sudo add-apt-repository % <<EOF
  ppa:noobslab/malys-themes
  ppa:alecive/antigone
  ppa:nitrux/nitrux-artwork
  ppa:upubuntu-com/themes
EOF

Why does apt-get install ... accept multiple arguments and add-apt-repository not?

Simply because they're different commands, written for different purposes by different people. Why don't less and rm take the same arguments? They're different things.

Adding a bunch of repos is really an edge case. It's not like wanting to install more than one package at a time. It also complicates the syntax. add-apt-repository takes a few different formats already, some that include spaces. Parsing that sanely is hard work to get right.

Is there any workaround to make your line work?

Sure. You either write a wrapper for add-apt-repository and prioritise it or edit the original... Is that a sane thing to do? No, not at all. You'll be breaking the existing add-apt-repository (see above) in a non-standard way, for what? To save keystrokes on something you run once?

There are multiple one-command methods of splitting this out, as multiple people are telling you. Don't fight the system, use it.

1

Try to put something like this:

sudo add-apt-repository ppa:noobslab/malys-themes && sudo add-apt-repository ppa:alecive/antigone && ...

or

sudo add-apt-repository ppa:noobslab/malys-themes; sudo add-apt-repository ppa:alecive/antigone; ...

if the ppa is trusted and needs to be installed any way then -y can be added as well to force install

sudo add-apt-repository ppa:noobslab/malys-themes -y; sudo add-apt-repository ppa:alecive/antigone -y; ...

So in this format:

command && next_command && next_command

or

command; next_command; next_command

It might work.

3
  • 6
    Separating with && or ; could be a better option than separating with &
    – Wilf
    Feb 28 '14 at 14:09
  • 2
    @Wilf --- much better. As proposed wont't (reliably) work; the first & launch the first add-apt... in background, it will tale the lock on the repository file, and the others would fail (depending on the speed of the machine, the scheduler, and the phase of the moon)
    – Rmano
    Feb 28 '14 at 15:24
  • 1
    Please do not upvote this answer until the OP fixes it --- it's plain wrong, see my comment before. & launch a process in background; ; or && are the only valid command separators here.
    – Rmano
    Mar 7 '14 at 16:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.