Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

In Ubuntu one can add a repository to apt-get via the following command -

sudo add-apt-repository ppa:yannubuntu/boot-repair

As Ubuntu is based on Debian code base, I was expecting that the same would work in Debian too, but it doesn't.

  • What is the reason for this?
  • Is there some other shell command I can use to achieve the same?

Note: I already know I can edit /etc/apt-get/sources.list, but I want to achieve this from shell. I also want to know why the same command won't work when the code base is the same.

share|improve this question

4 Answers 4

up vote 21 down vote accepted

The program add-apt-repository is available in Debian. It's in the python-software-properties package:

sudo apt-get install python-software-properties

It was added to that package in version 0.75. The current version in Debian Stable ('squeeze") is 0.60, so it doesn't have it. The version currently in Debian Testing ("wheezy") is 0.82.7.1debian1, so it's available there.

share|improve this answer
1  
At least in sid, the add-apt-repository script seems to have moved to software-properties-common –  voltagex Jun 22 at 10:26

Assuming you're running a recent enough version of Debian (wheezy has it, I think squeeze does as well), you can just drop a file in /etc/apt/sources.list.d/

The format is the same as the main sources.list file.

The advantage is, especially if this is for some software you're distributing, you don't have to worry merging your changes into a possibly-edited /etc/apt/sources.list file (especially hard to deal with if your program is uninstalled). You can use dpkg conffile support to put the file in /etc/apt/sources.list.d/.

share|improve this answer
    
sources.list.d exists since etch, I think. –  Gilles Aug 20 '12 at 22:08
    
Yeah, but apt-add-repository takes care of things like translating "ppa:" to an http://ppa.launchpad... type, and to download and install the repository key so that packages are not treated as suspicious –  Ricardo Cárdenes Jul 27 at 11:24

Ubuntu is based on Debian but includes things Debian doesn't (and in turn are often incorporated into Debian later). The add-apt-repository command is an example which was included in Ubuntu first.

The add-apt-repository actually just executes a couple of commands to add the repository:

  • append the repository to /etc/apt/sources.list
  • add the repository key to the machine.

A script that sort of does the same can be found here.

share|improve this answer

add-apt-repository can now be found in the software-properties-common package.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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