mirror of
https://git.launchpad.net/ubuntu-dev-tools
synced 2025-03-26 18:31:10 +00:00
pull-pkg: change UCA source pkg class to subclass of PPA source pkg class
The UCA source pkg class was its own specific class, but with the addition of the generic PPA source pkg class, the UCA class is just a specific case of PPA. Changing it to a subclass of the PPA class simplifies code.
This commit is contained in:
parent
7084bfc8bc
commit
b11b83f0e2
@ -751,60 +751,38 @@ class PersonalPackageArchiveSourcePackage(UbuntuSourcePackage):
|
|||||||
'+files', filename)
|
'+files', filename)
|
||||||
|
|
||||||
|
|
||||||
class UbuntuCloudArchiveSourcePackage(UbuntuSourcePackage):
|
class UbuntuCloudArchiveSourcePackage(PersonalPackageArchiveSourcePackage):
|
||||||
"Download / unpack an Ubuntu Cloud Archive source package"
|
"Download / unpack an Ubuntu Cloud Archive source package"
|
||||||
_ppas = None
|
_ppateam = 'ubuntu-cloud-archive'
|
||||||
_ppa_names = None
|
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
|
series = kwargs.get('series') or UbuntuCloudArchiveSourcePackage.getDevelSeries()
|
||||||
|
kwargs.pop('series', None)
|
||||||
|
kwargs['ppa'] = ('%s/%s-staging' %
|
||||||
|
(UbuntuCloudArchiveSourcePackage._ppateam, series))
|
||||||
super(UbuntuCloudArchiveSourcePackage, self).__init__(*args, **kwargs)
|
super(UbuntuCloudArchiveSourcePackage, self).__init__(*args, **kwargs)
|
||||||
self._use_series = False # UCA doesn't really use distro series
|
self._use_series = False # each UCA series is for a single Ubuntu series
|
||||||
self._uca_release = self._series
|
self.uca_release = series
|
||||||
self._series = None
|
|
||||||
self.masters = ["http://ubuntu-cloud.archive.canonical.com/ubuntu/"]
|
self.masters = ["http://ubuntu-cloud.archive.canonical.com/ubuntu/"]
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def getArchives(cls):
|
def getDevelSeries(cls):
|
||||||
if cls._ppas is None:
|
ppas = PersonTeam.fetch(cls._ppateam).getPPAs()
|
||||||
cls._ppas = []
|
for key in sorted(ppas.keys(), reverse=True):
|
||||||
ppas = PersonTeam.fetch('ubuntu-cloud-archive').getPPAs()
|
|
||||||
for key in ppas.keys():
|
|
||||||
if key.endswith('-staging'):
|
if key.endswith('-staging'):
|
||||||
cls._ppas.append(ppas[key])
|
return key.rsplit('-', 1)[0]
|
||||||
return cls._ppas
|
raise SeriesNotFoundException('Internal Error: No UCA devel series found...?')
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def getReleaseNames(cls):
|
def isValidRelease(cls, release):
|
||||||
if not cls._ppa_names:
|
return ('%s-staging' % release) in PersonTeam.fetch(cls._ppateam).getPPAs()
|
||||||
cls._ppa_names = [p.name.split('-', 1)[0] for p in cls.getArchives()]
|
|
||||||
return cls._ppa_names
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def getDevelopmentRelease(cls):
|
|
||||||
return sorted(cls.getReleaseNames(), reverse=True)[0]
|
|
||||||
|
|
||||||
@property
|
|
||||||
def uca_release(self):
|
|
||||||
if not self._uca_release:
|
|
||||||
self._uca_release = self.getDevelopmentRelease()
|
|
||||||
Logger.normal('Using UCA release %s', self._uca_release)
|
|
||||||
return self._uca_release
|
|
||||||
|
|
||||||
def getArchive(self):
|
def getArchive(self):
|
||||||
ppas = {p.name: p for p in self.getArchives()}
|
try:
|
||||||
release = '{}-staging'.format(self.uca_release)
|
return super(UbuntuCloudArchiveSourcePackage, self).getArchive()
|
||||||
if release in ppas:
|
except ValueError:
|
||||||
Logger.debug('UCA release {} at {}'.format(self.uca_release,
|
|
||||||
ppas[release]()))
|
|
||||||
return ppas[release]
|
|
||||||
raise SeriesNotFoundException('UCA release {} not found.'.format(self.uca_release))
|
raise SeriesNotFoundException('UCA release {} not found.'.format(self.uca_release))
|
||||||
|
|
||||||
def _lp_url(self, filename):
|
|
||||||
"Build a source package URL on Launchpad"
|
|
||||||
return os.path.join('https://launchpad.net', "~ubuntu-cloud-archive",
|
|
||||||
'+archive', ("%s-staging" % self.uca_release),
|
|
||||||
'+files', filename)
|
|
||||||
|
|
||||||
|
|
||||||
class _WebJSON(object):
|
class _WebJSON(object):
|
||||||
def getHostUrl(self):
|
def getHostUrl(self):
|
||||||
|
@ -211,7 +211,7 @@ class PullPkg(object):
|
|||||||
# archives always correspond to only one UBUNTURELEASE, and UCA archives
|
# archives always correspond to only one UBUNTURELEASE, and UCA archives
|
||||||
# have only the Release pocket, so only UCARELEASE matters to us.
|
# have only the Release pocket, so only UCARELEASE matters to us.
|
||||||
for r in release.split('-'):
|
for r in release.split('-'):
|
||||||
if r in UbuntuCloudArchiveSourcePackage.getReleaseNames():
|
if UbuntuCloudArchiveSourcePackage.isValidRelease(r):
|
||||||
Logger.debug("Using UCA release '%s'", r)
|
Logger.debug("Using UCA release '%s'", r)
|
||||||
return (r, None)
|
return (r, None)
|
||||||
raise SeriesNotFoundException('UCA release {} not found.'.format(release))
|
raise SeriesNotFoundException('UCA release {} not found.'.format(release))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user