Ubuntu – Can a ppa repository be added to /etc/apt/source.list

aptpackage-managementppa

By sudo add-apt-repository '<deb url codename component>', a repository is added to the /etc/apt/source.list file.

By sudo add-apt-repository ppa:<user>/<ppa-name>, I saw that all the ppa repositories are added to /etc/apt/source.list.d dir:

$ ls /etc/apt/sources.list.d/
ferramroberto-sopcast-precise.list
ferramroberto-sopcast-precise.list.save
google-talkplugin.list
google-talkplugin.list.save
kalakris-okular-precise.list
kalakris-okular-precise.list.save
linrunner-thinkpad-extras-precise.list
linrunner-thinkpad-extras-precise.list.save
precise-partner.list
precise-partner.list.save
staticfloat-julia-deps-precise.list
staticfloat-juliareleases-precise.list
staticfloat-juliareleases-precise.list.save
telepathy-ppa-precise.list
telepathy-ppa-precise.list.save
ubuntu-wine-ppa-precise.list
ubuntu-wine-ppa-precise.list.save
venerix-blug-precise.list
venerix-blug-precise.list.save
  1. Can a ppa repositories be added to the end of /etc/apt/source.list file, instead?

  2. Why are ppa repositories are treated differently from non-ppa ones?

  3. Are there other non-ppa repositories treated similarly as ppa ones?

  4. Will sudo add-apt-repository '<deb url codename component>' add a ppa repository to /etc/apt/source.list, or to some files under /etc/apt/source.list.d?

Best Answer

  1. Yes, PPA's can be added to /etc/apt/source.list, in similar way to debian (deb) repositories.

    deb http://ppa.launchpad.net/<ppa-name>/ppa/ubuntu <release-code-name> main 
    deb-src http://ppa.launchpad.net/<ppa-name>/ppa/ubuntu <release-code-name> main
    

    An example for WineHq: ppa debian repository link

  2. Thought just matter of keeping things somehow easily managed, leaving /etc/apt/source.list only for official release repositories. All additional repositories goes to /etc/apt/source.list.d/. Easy to:

    1. add (creating file then editing existing one, a partial solution to avoid duplicates too)
    2. remove (with parsing a /etc/apt/source.list looking to related line)
    3. backup/restore (using compressed archive of /etc/apt/source.list.d/ folder)
    4. avoid breaking things with much edits targeting /etc/apt/source.list
  3. PPA are always added to /etc/apt/source.list.d/ folder if wrote it in ppa:<user>/<ppa-name> form.

    Reference: man add-apt-repository

    REPOSITORY STRING
           REPOSITORY can  be  either  a  line  that  can  be  added  directly  to
           sources.list(5),  in the form ppa:<user>/<ppa-name> for adding Personal
           Package Archives, or a distribution component to enable.
    
           In  the   first   form,   REPOSITORY   will   just   be   appended   to
           /etc/apt/sources.list.
    
           In  the second form, ppa:<user>/<ppa-name> will be expanded to the full
           deb  line  of  the  PPA  and   added   into   a   new   file   in   the
           /etc/apt/sources.list.d/  directory.   The  GPG public key of the newly
           added PPA will also be downloaded and added to apt's keyring.
    
           In the third form, the given distribution component will be enabled for
           all sources.
    
  4. Well, it seems only PPA's as shortcut goes to /etc/apt/sources.list.d/. add-apt-repository or apt-add-repository is a Ubuntu specific tool. All I can think of is just Ubuntu decision to keep personal PPA's out.

    However you can modify it to use only /etc/apt/sources.list. It's a python3 script. Modify /usr/bin/add-apt-repository line:

    shortcut = shortcut_handler(line)
    

    replace it with this one below to resolve ppa shortcut form to a deb line form:

    shortcut = shortcut_handler(shortcut_handler(line).expand(sp.distro.codename)[0])
    
Related Question