diff -Nru software-properties-0.93.2/add-apt-repository software-properties-0.94/add-apt-repository --- software-properties-0.93.2/add-apt-repository 2014-09-16 19:54:52.000000000 +0000 +++ software-properties-0.94/add-apt-repository 2014-09-24 09:49:25.000000000 +0000 @@ -142,7 +142,8 @@ if options.remove: try: - (line, file) = shortcut.expand(sp.distro.codename) + (line, file) = shortcut.expand( + sp.distro.codename, sp.distro.id.lower()) except ShortcutException as e: print(e) sys.exit(1) diff -Nru software-properties-0.93.2/debian/changelog software-properties-0.94/debian/changelog --- software-properties-0.93.2/debian/changelog 2014-09-16 20:03:43.000000000 +0000 +++ software-properties-0.94/debian/changelog 2014-09-24 09:50:45.000000000 +0000 @@ -1,3 +1,10 @@ +software-properties (0.94) utopic; urgency=medium + + * If adding a PPA from a foreign distribution, use that distribution's + current series as the codename. + + -- Colin Watson Sat, 20 Sep 2014 01:14:22 +0100 + software-properties (0.93.2) utopic; urgency=medium * Add pyflakes to autopkgtest dependencies. diff -Nru software-properties-0.93.2/softwareproperties/cloudarchive.py software-properties-0.94/softwareproperties/cloudarchive.py --- software-properties-0.93.2/softwareproperties/cloudarchive.py 2014-09-16 19:54:52.000000000 +0000 +++ software-properties-0.94/softwareproperties/cloudarchive.py 2014-09-24 09:49:25.000000000 +0000 @@ -94,7 +94,7 @@ def info(self): return self._info - def expand(self, codename): + def expand(self, codename, distro=None): if codename not in (MAP[self.caname]['release'], os.environ.get("CA_ALLOW_CODENAME")): raise ShortcutException( diff -Nru software-properties-0.93.2/softwareproperties/ppa.py software-properties-0.94/softwareproperties/ppa.py --- software-properties-0.93.2/softwareproperties/ppa.py 2014-09-16 19:54:52.000000000 +0000 +++ software-properties-0.94/softwareproperties/ppa.py 2014-09-24 09:49:25.000000000 +0000 @@ -51,6 +51,7 @@ LAUNCHPAD_PPA_API = 'https://launchpad.net/api/1.0/%s/+archive/%s' LAUNCHPAD_USER_API = 'https://launchpad.net/api/1.0/%s' LAUNCHPAD_USER_PPAS_API = 'https://launchpad.net/api/1.0/%s/ppas' +LAUNCHPAD_DISTRIBUTION_API = 'https://launchpad.net/api/1.0/%s' # Specify to use the system default SSL store; change to a different path # to test with custom certificates. LAUNCHPAD_PPA_CERT = "/etc/ssl/certs/ca-certificates.crt" @@ -89,6 +90,10 @@ lp_url = LAUNCHPAD_PPA_API % (owner_name, ppa) return get_info_from_lp(lp_url) +def get_current_series_from_lp(distribution): + lp_url = LAUNCHPAD_DISTRIBUTION_API % distribution + return os.path.basename(get_info_from_lp(lp_url)["current_series_link"]) + def _get_https_content_py3(lp_url): try: @@ -349,7 +354,11 @@ def info(self): return self._info - def expand(self, codename): + def expand(self, codename, distro=None): + if distro is not None and distro != self._info["distribution"]: + # The requested PPA is for a foreign distribution. Guess that + # the user wants that distribution's current series. + codename = get_current_series_from_lp(self._info["distribution"]) debline = "deb http://ppa.launchpad.net/%s/%s/%s %s main" % ( self._info["owner"][1:], self._info["name"], self._info["distribution"], codename) diff -Nru software-properties-0.93.2/softwareproperties/shortcuts.py software-properties-0.94/softwareproperties/shortcuts.py --- software-properties-0.93.2/softwareproperties/shortcuts.py 2014-09-16 19:54:52.000000000 +0000 +++ software-properties-0.94/softwareproperties/shortcuts.py 2014-09-24 09:49:25.000000000 +0000 @@ -33,7 +33,7 @@ def add_key(self, keyserver=None): return None - def expand(self, codename=None): + def expand(self, codename=None, distro=None): return (self.shortcut, None) def info(self): diff -Nru software-properties-0.93.2/softwareproperties/SoftwareProperties.py software-properties-0.94/softwareproperties/SoftwareProperties.py --- software-properties-0.93.2/softwareproperties/SoftwareProperties.py 2014-09-16 19:54:52.000000000 +0000 +++ software-properties-0.94/softwareproperties/SoftwareProperties.py 2014-09-24 09:49:25.000000000 +0000 @@ -674,7 +674,8 @@ keyring *if* the channel is in the whitelist /usr/share/app-install/channels or it is a public Launchpad PPA. """ - (srcline, _fname) = shortcut.expand(codename=self.distro.codename) + (srcline, _fname) = shortcut.expand( + codename=self.distro.codename, distro=self.distro.id.lower()) channel = self._is_line_in_whitelisted_channel(srcline) if channel: keyp = "%s/%s.key" % (self.CHANNEL_PATH, channel) @@ -724,7 +725,8 @@ site is in whitelist or the shortcut implementer adds it. """ - (deb_line, file) = shortcut.expand(codename=self.distro.codename) + (deb_line, file) = shortcut.expand( + codename=self.distro.codename, distro=self.distro.id.lower()) deb_line = self.expand_http_line(deb_line) debsrc_entry_type = 'deb-src' if enable_source_code else '# deb-src' debsrc_line = debsrc_entry_type + deb_line[3:] diff -Nru software-properties-0.93.2/tests/test_shortcuts.py software-properties-0.94/tests/test_shortcuts.py --- software-properties-0.93.2/tests/test_shortcuts.py 2014-09-16 19:54:52.000000000 +0000 +++ software-properties-0.94/tests/test_shortcuts.py 2014-09-24 09:49:25.000000000 +0000 @@ -22,7 +22,7 @@ def test_shortcut_none(self): line = "deb http://ubuntu.com/ubuntu trusty main" handler = shortcut_handler(line) - self.assertEqual((line, None), handler.expand(line)) + self.assertEqual((line, None), handler.expand()) def test_shortcut_ppa(self): line = "ppa:mvo" @@ -30,7 +30,7 @@ self.assertEqual( ('deb http://ppa.launchpad.net/mvo/ppa/ubuntu trusty main', '/etc/apt/sources.list.d/mvo-ubuntu-ppa-trusty.list'), - handler.expand("trusty")) + handler.expand("trusty", distro="ubuntu")) def test_shortcut_cloudarchive(self): line = "cloud-archive:folsom" @@ -39,7 +39,7 @@ ('deb http://ubuntu-cloud.archive.canonical.com/ubuntu '\ 'precise-updates/folsom main', '/etc/apt/sources.list.d/cloudarchive-folsom.list'), - handler.expand("precise")) + handler.expand("precise", distro="ubuntu")) if __name__ == "__main__":