Tuesday, June 21, 2016

Adding a PPA through a proxy server

PPA stands for Personal Package Archive and it is a special software repository for uploading source packages to be built and published as an APT repository by Launchpad.
Simply PPAs are for non standard software or updates. We can find latest software or updates that doesn't normally provided by Ubuntu software center. So people add these PPAs to system in order to use latest softwares. Some times there might be risks of adding PPA.

On the command line you can add a PPA using apt-add-repository,
e.g.: sudo apt-add-repository ppa:strukturag/libde265 

If you are connected to Internet through a proxy server above command will give an error.
e.g.:
Cannot add PPA: 'ppa:strukturag/libde265'. 
Please check that the PPA name or format is correct.


This happens because root user is not aware of the proxy settings that a normal user has. Lets see how to fix that.

Adding PPA through a proxy server.

  1. First thing is exporting the proxy environment variable using following commands.
    export http_proxy=http://host:port/
    export https_proxy=https://host:port/

    e.g.:
    export http_proxy=http://cachex.pdn.ac.lk:3128/
    export https_proxy=https://cachex.pdn.ac.lk:3128/

  2. Now we have to export these environmental variables to root user. For that Whenever you use sudo command, use sudo -E to export the environment variables of the user you are currently using.
    e.g.:
    sudo -E apt-add-repository ppa:strukturag/libde265
There is another method to export proxy settings to root user
  1. First type sudo visudo in terminal.
  2. Then add Defaults env_keep="https_proxy" to the end of the file.
  3. Press  Ctrl+x to save and exit.
Note:
This may happen even if you have added your proxy using System Settings -> Network -> Network proxy or in /etc/apt/apt.conf or even in /home/$USER/.bashrc

No comments:

Post a Comment

Optimize you working enviorenment : Single command to create & move to a directory in linux (C Shell, Bash)

Usually move to a directory just after creating is bit of a anxious task specially if the directory name is too long. mkdir long-name-of...