PATCH: detect.py: repos_URI referenced before assignment

Bug #104227 reported by Loye Young
2
Affects Status Importance Assigned to Milestone
EasyUbuntu
New
Undecided
Unassigned

Bug Description

Upon trying to install EasyUbuntu, first package install repeatedly failed. Below is description of symptoms, analysis of bug, and patch.

DESCRIPTION
Debug shows:

[snip a bunch of yada-yada-yada and apt-get stuff ]
Setting up libqt-perl (3.008-1.4) ...
Traceback (most recent call last):
  File "/usr/lib/easyubuntu/EasyUbuntu/qtfrontend.py", line 166, in okclicked
    replace_base(self.confdir,self.repos,self.reposxml)
  File "/usr/lib/easyubuntu/EasyUbuntu/detect.py", line 168, in replace_base
    baselist = makeRepos(repolist, repoxml)
  File "/usr/lib/easyubuntu/EasyUbuntu/detect.py", line 215, in makeRepos
    (localrepos,defrepos,defrepo_URI,repos_URI) = getLocalRepos(repoxml)
  File "/usr/lib/easyubuntu/EasyUbuntu/detect.py", line 207, in getLocalRepos
    return localrepos,defreposlist,defrepo_URI, repos_URI
UnboundLocalError: local variable 'repos_URI' referenced before assignment

ANALYSIS
I read detect.py ante line 207 and saw that it wanted to fiddle with the repository list. (For those of you who don't speak Texan, "to fiddle with" means approximately "to make changes to".) The variable 'repos_URI' is defined inside an "if" statement. The condition is never true in my repository list because I look to a local repository that already has "main restricted universe multiverse" for each source. Consequently, 'repos_URI' never gets defined.

PATCH
Insert immediately after line 192:
      repos_URI = ''
(That is two single quotes, not a double quote.)

Then when I ran EasyUbuntu like usual, it downloaded and installed the right packages from my local repository, just like it should.

After inserting the line, the function looks like this:
<code>
def getLocalRepos(repoxml):
    """
    Get the list of repositories already enabled on the computer
    """
    localrepos = []
    default = repoxml.getElementsByTagName("default")[0]
    defreposlist = default.getAttribute("id").encode().split(',')
    distroident = default.getAttribute("distroident").encode().strip()
    defrepo_URI = default.firstChild.data.encode().strip()
    repos_URI = ''

    sourcelist = open('/etc/apt/sources.list', 'r')
    for line in sourcelist:
        """
        deb http://archive.ubuntu.com/ubuntu/ dapper main restricted
        """
        if not "cdrom" in line and line.startswith("deb ") and \
                distroident in line and codename()+" " in line:
                # This is the official ubuntu repository, get the additional components enabled
                repos_URI = line.split()[1]
                for component in line.split()[3:]:
                    localrepos.append(component)
    sourcelist.close()
    return localrepos,defreposlist,defrepo_URI, repos_URI
</code>

RELATED SUGGESTIONS:
1. I note that "dapper" is hard-coded in the function. Perhaps it would be fruitful to create a variable that would load the appropriate release (dapper, edgy, feisty, etc.) and use a "for" statement to cycle through myRelease, myRelease-updates, myRelease-backports, myRelease-security, and myRelease-commercial.

2. I also note that ubuntu's US repository is migrating to http://ftp.us.debian.org/ubuntu. Perhaps a more general solution would be simply to look for the substring:
    myRelease main restricted
and append "universe multiverse" to the end. (Of course, you'd also have to make sure that they weren't already there.)

Happy Trails,

Loye Young
www.IYCC.net
Laredo, Texas

Revision history for this message
Loye Young (loyeyoung) wrote : UPDATE: PATCH: detect.py: repos_URI referenced before assignment

Hack only seems to work if the repository list is selected. It's easy enough to check the box, but it's not intuitive to check the box when you've already added the repositories by hand. I don't have time at the moment to figure out how to add the right logic to the script, but I am posting this bug so it doesn't get forgotten.

I'm wondering if that selection should even be an option. If the user wants the packages installed, they have to come from somewhere. The whole point of EasyUbuntu is to install the software that isn't in the out-of-the-box distribution.

Happy Trails,
Loye Young
www.IYCC.net
Laredo, Texas

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

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