add-apt-repository should return exit code and not adding wrong repositories

Bug #496879 reported by Narcis Garcia
42
This bug affects 6 people
Affects Status Importance Assigned to Milestone
software-properties (Ubuntu)
Triaged
Medium
Unassigned

Bug Description

(Ubuntu 9.10)
Running:

sudo add-apt-repository ppa:xxxxx
echo $?

In most cases zero error is shown, also when repository doesn't exist or there isn't network connection.

Additionally, on both error cases, the repository is added anyway.

Related branches

Revision history for this message
Philip Muškovac (yofel) wrote :

Thank you for taking the time to report this bug and helping to make Ubuntu better. This bug did not have a package associated with it, which is important for ensuring that it gets looked at by the proper developers. You can learn more about finding the right package at https://wiki.ubuntu.com/Bugs/FindRightPackage. I have classified this bug as a bug in python-software-properties.

When reporting bugs in the future please use apport, either via the appropriate application's "Help -> Report a Problem" menu or using 'ubuntu-bug' and the name of the package affected. You can learn more about this functionality at https://wiki.ubuntu.com/ReportingBugs. (you can find out what package a command belongs to with 'dpkg -S $(which <command>)' )

affects: ubuntu → software-properties (Ubuntu)
Revision history for this message
Philip Muškovac (yofel) wrote :

Confirmed. The exit code is not !=0 when an error occurs and even though you actually get an error message like
Error reading https://launchpad.net/api/beta/~bxlsjs/+archive/sds: HTTP Error 404: Not Found
is given, the file
/etc/apt/sources.list.d/bxlsjs-sds-lucid.list
is created anyway.

Changed in software-properties (Ubuntu):
status: New → Confirmed
Daniel T Chen (crimsun)
Changed in software-properties (Ubuntu):
importance: Undecided → Wishlist
status: Confirmed → Triaged
Revision history for this message
Philip Muškovac (yofel) wrote :

$ apt-cache policy python-software-properties
python-software-properties:
  Installed: 0.75.5
  Candidate: 0.75.5
  Version table:
 *** 0.75.5 0
        600 http://archive.ubuntu.com lucid/main Packages
        100 /var/lib/dpkg/status

Revision history for this message
C de-Avillez (hggdh2) wrote :

Resetting to Medium importance (from WishList) -- this is really a bug

Changed in software-properties (Ubuntu):
importance: Wishlist → Medium
Revision history for this message
Narcis Garcia (narcisgarcia) wrote :

I'll take care about the apt-query command the next time.
Thanks.

Revision history for this message
H.-Dirk Schmitt (dirk-computer42) wrote :

In the current state it can't be used in a reliable way by other scripts.

Revision history for this message
pode (autrelandes-ubuntu) wrote :

The reason of the bug is that :
1. In softwareproperties/SoftwareProperties.py, a thread is created

  def check_and_add_key_for_whitelisted_channels(self, srcline):
[...]
    if parsed_uri.netloc == 'ppa.launchpad.net':
      worker = AddPPASigningKeyThread(parsed_uri.path)
      worker.start()

2. When failing in method add_ppa_signing_key of AddPPASigningKeyThread class, it prints an error and return False :
[...]
        except URLError, e:
            print "Error reading %s: %s" % (lp_url, e)
            return False

3. But the return code generated by the thread is nowhere managed. In fact, two lines are inconditionnaly added in source file :
  def add_source_from_line(self, line):
[...]
    self.check_and_add_key_for_whitelisted_channels(deb_line)
    self.sourceslist.list.append(new_deb_entry)
    self.sourceslist.list.append(new_debsrc_entry)

Hope it helps...

Robert Roth (evfool)
Changed in software-properties (Ubuntu):
assignee: nobody → Robert Roth (evfool)
status: Triaged → In Progress
Robert Roth (evfool)
Changed in software-properties (Ubuntu):
status: In Progress → Triaged
assignee: Robert Roth (evfool) → nobody
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.