Monday, April 29, 2024
 Popular · Latest · Hot · Upcoming
13
rated 0 times [  13] [ 0]  / answers: 1 / hits: 3898  / 1 Year ago, thu, march 16, 2023, 5:37:57

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.


More From » bash

 Answers
7

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.


[#26763] Friday, March 17, 2023, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
itteast

Total Points: 291
Total Questions: 123
Total Answers: 104

Location: Tuvalu
Member since Wed, Mar 29, 2023
1 Year ago
;