mirror of
https://git.launchpad.net/ubuntu-dev-tools
synced 2025-05-09 07:51:28 +00:00
make better use of ubuntutools.archive, allowing us to detect when fakesyncs are required in LP mode
This commit is contained in:
parent
d26a7521b0
commit
5eb960dd3f
89
syncpackage
89
syncpackage
@ -260,8 +260,13 @@ def fetch_source_pkg(package, dist, version, component, ubuntu_release, mirror):
|
|||||||
"""Download the specified source package.
|
"""Download the specified source package.
|
||||||
dist, version, component, mirror can all be None.
|
dist, version, component, mirror can all be None.
|
||||||
"""
|
"""
|
||||||
|
if mirror is None:
|
||||||
|
mirrors = []
|
||||||
|
else:
|
||||||
|
mirrors = [mirror]
|
||||||
|
|
||||||
if package.endswith('.dsc'):
|
if package.endswith('.dsc'):
|
||||||
return DebianSourcePackage(dscfile=package, mirrors=[mirror])
|
return DebianSourcePackage(dscfile=package, mirrors=mirrors)
|
||||||
|
|
||||||
if dist is None:
|
if dist is None:
|
||||||
dist = "unstable"
|
dist = "unstable"
|
||||||
@ -302,10 +307,9 @@ def fetch_source_pkg(package, dist, version, component, ubuntu_release, mirror):
|
|||||||
assert component in ('main', 'contrib', 'non-free')
|
assert component in ('main', 'contrib', 'non-free')
|
||||||
|
|
||||||
return DebianSourcePackage(package, version.full_version, component,
|
return DebianSourcePackage(package, version.full_version, component,
|
||||||
mirrors=[mirror])
|
mirrors=mirrors)
|
||||||
|
|
||||||
def copy(src_pkg, debian_dist, debian_version, release, simulate=False,
|
def copy(src_pkg, debian_dist, release, simulate=False, force=False):
|
||||||
force=False):
|
|
||||||
debian = Distribution('debian')
|
debian = Distribution('debian')
|
||||||
ubuntu = Distribution('ubuntu')
|
ubuntu = Distribution('ubuntu')
|
||||||
debian_archive = debian.getArchive()
|
debian_archive = debian.getArchive()
|
||||||
@ -316,42 +320,58 @@ def copy(src_pkg, debian_dist, debian_version, release, simulate=False,
|
|||||||
else:
|
else:
|
||||||
ubuntu_series, ubuntu_pocket = split_release_pocket(release)
|
ubuntu_series, ubuntu_pocket = split_release_pocket(release)
|
||||||
|
|
||||||
if debian_version is None:
|
|
||||||
if debian_dist is None:
|
|
||||||
debian_dist = 'unstable'
|
|
||||||
debian_info = DebianDistroInfo()
|
|
||||||
debian_dist = debian_info.codename(debian_dist, default=debian_dist)
|
|
||||||
debian_version = debian_archive.getSourcePackage(
|
|
||||||
src_pkg, debian_dist).getVersion()
|
|
||||||
else:
|
|
||||||
# Ensure that the provided Debian version actually exists.
|
# Ensure that the provided Debian version actually exists.
|
||||||
debian_sources = debian_archive.getPublishedSources(
|
|
||||||
source_name=src_pkg,
|
|
||||||
version=debian_version,
|
|
||||||
exact_match=True)
|
|
||||||
if not debian_sources:
|
|
||||||
Logger.error('Debian version %s does not exist!', debian_version)
|
|
||||||
sys.exit(1)
|
|
||||||
try:
|
try:
|
||||||
ubuntu_version = ubuntu_archive.getSourcePackage(
|
debian_spph = src_pkg.lp_spph()
|
||||||
src_pkg, ubuntu_series, ubuntu_pocket).getVersion()
|
except IndexError:
|
||||||
|
Logger.error('Debian version %s does not exist!', src_pkg.version)
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
debian_version = Version(debian_version)
|
try:
|
||||||
ubuntu_version = Version(ubuntu_version)
|
ubuntu_spph = getUbuntuSrcPkg(src_pkg.source,
|
||||||
|
ubuntu_series, ubuntu_pocket)
|
||||||
|
ubuntu_pkg = UbuntuSourcePackage(src_pkg.source,
|
||||||
|
ubuntu_spph.getVersion(),
|
||||||
|
ubuntu_spph.getComponent(),
|
||||||
|
mirrors=[])
|
||||||
|
|
||||||
Logger.normal('Source %s -> %s/%s: current version %s, new version %s',
|
Logger.normal('Source %s -> %s/%s: current version %s, new version %s',
|
||||||
src_pkg, ubuntu_series, ubuntu_pocket,
|
src_pkg.source, ubuntu_series, ubuntu_pocket,
|
||||||
ubuntu_version, debian_version)
|
ubuntu_pkg.version, src_pkg.version)
|
||||||
if debian_version <= ubuntu_version:
|
|
||||||
Logger.error('Debian version is <= Ubuntu version; nothing to do!')
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
|
ubuntu_version = Version(ubuntu_pkg.version.full_version)
|
||||||
if not force and ubuntu_version.is_modified_in_ubuntu():
|
if not force and ubuntu_version.is_modified_in_ubuntu():
|
||||||
Logger.error('--force is required to discard Ubuntu changes.')
|
Logger.error('--force is required to discard Ubuntu changes.')
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
# Check whether a fakesync would be required.
|
||||||
|
src_pkg.pull_dsc(quiet=not Logger.verbose)
|
||||||
|
ubuntu_pkg.pull_dsc(quiet=not Logger.verbose)
|
||||||
|
for field, key in (('Checksums-Sha256', 'sha256'),
|
||||||
|
('Checksums-Sha1', 'sha1'),
|
||||||
|
('Files', 'md5sum')):
|
||||||
|
if field not in src_pkg.dsc or field not in ubuntu_pkg.dsc:
|
||||||
|
continue
|
||||||
|
debian_checksums = \
|
||||||
|
dict((entry['name'], (int(entry['size']), entry[key]))
|
||||||
|
for entry in src_pkg.dsc[field])
|
||||||
|
ubuntu_checksums = \
|
||||||
|
dict((entry['name'], (int(entry['size']), entry[key]))
|
||||||
|
for entry in ubuntu_pkg.dsc[field])
|
||||||
|
for name, (size, checksum) in debian_checksums.iteritems():
|
||||||
|
if name not in ubuntu_checksums:
|
||||||
|
# new file
|
||||||
|
continue
|
||||||
|
if (size != ubuntu_checksums[name][0] or
|
||||||
|
checksum != ubuntu_checksums[name][1]):
|
||||||
|
Logger.error('The checksums of the Debian and Ubuntu '
|
||||||
|
'packages mismatch. A fake sync is required.')
|
||||||
|
sys.exit(1)
|
||||||
|
break # one checksum is good enough
|
||||||
except udtexceptions.PackageNotFoundException:
|
except udtexceptions.PackageNotFoundException:
|
||||||
Logger.normal('Source %s -> %s/%s: not in Ubuntu, new version %s',
|
Logger.normal('Source %s -> %s/%s: not in Ubuntu, new version %s',
|
||||||
src_pkg, ubuntu_series, ubuntu_pocket, debian_version)
|
src_pkg.source, ubuntu_series, ubuntu_pocket,
|
||||||
|
src_pkg.version)
|
||||||
if simulate:
|
if simulate:
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -361,8 +381,8 @@ def copy(src_pkg, debian_dist, debian_version, release, simulate=False,
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
ubuntu_archive.copyPackage(
|
ubuntu_archive.copyPackage(
|
||||||
source_name=src_pkg,
|
source_name=src_pkg.source,
|
||||||
version=str(debian_version),
|
version=str(src_pkg.version),
|
||||||
from_archive=debian_archive,
|
from_archive=debian_archive,
|
||||||
to_series=ubuntu_series,
|
to_series=ubuntu_series,
|
||||||
to_pocket=ubuntu_pocket,
|
to_pocket=ubuntu_pocket,
|
||||||
@ -493,8 +513,11 @@ def main():
|
|||||||
except IOError:
|
except IOError:
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
copy(args[0], options.dist, options.debversion, options.release,
|
src_pkg = fetch_source_pkg(args[0], options.dist, options.debversion,
|
||||||
options.simulate, options.force)
|
options.component, options.release, None)
|
||||||
|
|
||||||
|
copy(src_pkg, options.dist, options.release, options.simulate,
|
||||||
|
options.force)
|
||||||
else:
|
else:
|
||||||
Launchpad.login_anonymously()
|
Launchpad.login_anonymously()
|
||||||
if options.release is None:
|
if options.release is None:
|
||||||
|
@ -34,11 +34,11 @@ def getDebianSrcPkg(name, release):
|
|||||||
|
|
||||||
return debian_archive.getSourcePackage(name, release)
|
return debian_archive.getSourcePackage(name, release)
|
||||||
|
|
||||||
def getUbuntuSrcPkg(name, release):
|
def getUbuntuSrcPkg(name, release, pocket = 'Release'):
|
||||||
ubuntu = Distribution('ubuntu')
|
ubuntu = Distribution('ubuntu')
|
||||||
ubuntu_archive = ubuntu.getArchive()
|
ubuntu_archive = ubuntu.getArchive()
|
||||||
|
|
||||||
return ubuntu_archive.getSourcePackage(name, release)
|
return ubuntu_archive.getSourcePackage(name, release, pocket)
|
||||||
|
|
||||||
def needSponsorship(name, component, release):
|
def needSponsorship(name, component, release):
|
||||||
'''
|
'''
|
||||||
|
Loading…
x
Reference in New Issue
Block a user