mirror of
https://git.launchpad.net/ubuntu-dev-tools
synced 2025-03-12 15:41:09 +00:00
syncpackage: Require -f/--force option to overwrite Ubuntu changes.
This commit is contained in:
parent
87e1cadcb0
commit
0ef30ff665
1
debian/changelog
vendored
1
debian/changelog
vendored
@ -2,6 +2,7 @@ ubuntu-dev-tools (0.129) UNRELEASED; urgency=low
|
||||
|
||||
* syncpackage: Convert to new LP API, with --no-lp available for the old
|
||||
style of operation.
|
||||
* syncpackage: Require -f/--force option to overwrite Ubuntu changes.
|
||||
|
||||
-- Colin Watson <cjwatson@ubuntu.com> Tue, 16 Aug 2011 16:40:22 +0100
|
||||
|
||||
|
@ -67,6 +67,9 @@ Do not sign the upload.
|
||||
\fB\-b\fI BUG\fR, \fB\-\-bug\fR=\fIBUG\fR
|
||||
Mark a Launchpad bug as being fixed by this upload.
|
||||
.TP
|
||||
\fB\-f\fR, \fB\-\-force\fR
|
||||
Force sync over the top of Ubuntu changes.
|
||||
.TP
|
||||
.B \-d \fIDEBIAN_MIRROR\fR, \fB\-\-debian\-mirror\fR=\fIDEBIAN_MIRROR\fR
|
||||
Use the specified mirror.
|
||||
Should be in the form \fBhttp://ftp.debian.org/debian\fR.
|
||||
|
30
syncpackage
30
syncpackage
@ -116,7 +116,7 @@ def add_fixed_bugs(changes, bugs):
|
||||
return "\n".join(changes + [""])
|
||||
|
||||
def sync_dsc(src_pkg, debian_dist, release, name, email, bugs, ubuntu_mirror,
|
||||
keyid=None, simulate=False):
|
||||
keyid=None, simulate=False, force=False):
|
||||
uploader = name + " <" + email + ">"
|
||||
|
||||
src_pkg.pull_dsc()
|
||||
@ -142,6 +142,10 @@ def sync_dsc(src_pkg, debian_dist, release, name, email, bugs, ubuntu_mirror,
|
||||
|
||||
cur_ver = ubuntu_ver.get_related_debian_version()
|
||||
if ubuntu_ver.is_modified_in_ubuntu():
|
||||
if not force:
|
||||
Logger.error('--force is required to discard Ubuntu changes.')
|
||||
sys.exit(1)
|
||||
|
||||
Logger.warn('Overwriting modified Ubuntu version %s, '
|
||||
'setting current version to %s',
|
||||
ubuntu_ver.full_version, cur_ver.full_version)
|
||||
@ -300,7 +304,8 @@ def fetch_source_pkg(package, dist, version, component, ubuntu_release, mirror):
|
||||
return DebianSourcePackage(package, version.full_version, component,
|
||||
mirrors=[mirror])
|
||||
|
||||
def copy(src_pkg, debian_dist, debian_version, release, simulate=False):
|
||||
def copy(src_pkg, debian_dist, debian_version, release, simulate=False,
|
||||
force=False):
|
||||
debian = Distribution('debian')
|
||||
ubuntu = Distribution('ubuntu')
|
||||
debian_archive = debian.getArchive()
|
||||
@ -322,21 +327,25 @@ def copy(src_pkg, debian_dist, debian_version, release, simulate=False):
|
||||
ubuntu_version = ubuntu_archive.getSourcePackage(
|
||||
src_pkg, ubuntu_series, ubuntu_pocket).getVersion()
|
||||
|
||||
debian_version = Version(debian_version)
|
||||
ubuntu_version = Version(ubuntu_version)
|
||||
|
||||
Logger.normal('Source %s -> %s/%s: current version %s, new version %s',
|
||||
src_pkg, ubuntu_series, ubuntu_pocket,
|
||||
ubuntu_version, debian_version)
|
||||
if Version(debian_version) <= Version(ubuntu_version):
|
||||
if debian_version <= ubuntu_version:
|
||||
Logger.error('Debian version is <= Ubuntu version; nothing to do!')
|
||||
sys.exit(1)
|
||||
|
||||
if not force and ubuntu_version.is_modified_in_ubuntu():
|
||||
Logger.error('--force is required to discard Ubuntu changes.')
|
||||
sys.exit(1)
|
||||
except udtexceptions.PackageNotFoundException:
|
||||
Logger.normal('Source %s -> %s/%s: not in Ubuntu, new version %s',
|
||||
src_pkg, ubuntu_series, ubuntu_pocket, debian_version)
|
||||
if simulate:
|
||||
return
|
||||
|
||||
if 'ubuntu' in ubuntu_version:
|
||||
print "Ubuntu version had Ubuntu-specific modifications; check them " \
|
||||
"carefully!"
|
||||
answer = YesNoQuestion().ask("Sync this package", "no")
|
||||
if answer != "yes":
|
||||
return
|
||||
@ -344,7 +353,7 @@ def copy(src_pkg, debian_dist, debian_version, release, simulate=False):
|
||||
try:
|
||||
ubuntu_archive.copyPackage(
|
||||
source_name=src_pkg,
|
||||
version=debian_version,
|
||||
version=str(debian_version),
|
||||
from_archive=debian_archive,
|
||||
to_series=ubuntu_series,
|
||||
to_pocket=ubuntu_pocket,
|
||||
@ -405,6 +414,9 @@ def main():
|
||||
dest="bugs", action="append", default=list(),
|
||||
help="Mark Launchpad bug BUG as being fixed by this "
|
||||
"upload.")
|
||||
parser.add_option("-f", "--force",
|
||||
dest="force", action="store_true", default=False,
|
||||
help="Force sync over the top of Ubuntu changes.")
|
||||
parser.add_option('-D', '--debian-mirror', metavar='DEBIAN_MIRROR',
|
||||
dest='debian_mirror',
|
||||
help='Preferred Debian mirror '
|
||||
@ -473,7 +485,7 @@ def main():
|
||||
sys.exit(1)
|
||||
|
||||
copy(args[0], options.dist, options.debversion, options.release,
|
||||
options.simulate)
|
||||
options.simulate, options.force)
|
||||
else:
|
||||
Launchpad.login_anonymously()
|
||||
if options.release is None:
|
||||
@ -488,7 +500,7 @@ def main():
|
||||
|
||||
sync_dsc(src_pkg, options.dist, options.release, options.uploader_name,
|
||||
options.uploader_email, options.bugs, options.ubuntu_mirror,
|
||||
options.keyid, options.simulate)
|
||||
options.keyid, options.simulate, options.force)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
Loading…
x
Reference in New Issue
Block a user