2019-09-04 17:15:50 -03:00
|
|
|
#!/usr/bin/python3
|
2010-04-13 23:22:32 +02:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
#
|
2010-12-27 18:24:21 +02:00
|
|
|
# Copyright (C) 2008-2010 Martin Pitt <martin.pitt@canonical.com>,
|
2011-01-31 19:01:10 +02:00
|
|
|
# 2010 Benjamin Drung <bdrung@ubuntu.com>,
|
|
|
|
# 2010-2011 Stefano Rivera <stefanor@ubuntu.com>
|
2010-04-13 23:22:32 +02:00
|
|
|
#
|
|
|
|
# ##################################################################
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or
|
|
|
|
# modify it under the terms of the GNU General Public License
|
|
|
|
# as published by the Free Software Foundation; version 3.
|
2010-12-03 00:06:43 +01:00
|
|
|
#
|
2010-04-13 23:22:32 +02:00
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# See file /usr/share/common-licenses/GPL-3 for more details.
|
|
|
|
#
|
|
|
|
# ##################################################################
|
2010-04-13 23:18:24 +02:00
|
|
|
|
2018-12-11 16:39:49 +00:00
|
|
|
import fnmatch
|
2018-10-12 18:54:07 -04:00
|
|
|
import logging
|
2010-05-10 00:05:22 +02:00
|
|
|
import optparse
|
|
|
|
import os
|
|
|
|
import shutil
|
2019-09-04 19:17:00 -03:00
|
|
|
import subprocess
|
2010-05-10 00:05:22 +02:00
|
|
|
import sys
|
2011-09-06 14:07:40 +02:00
|
|
|
import textwrap
|
2019-09-04 17:15:50 -03:00
|
|
|
import urllib.request
|
2010-04-13 23:18:24 +02:00
|
|
|
|
2011-08-16 16:30:10 +01:00
|
|
|
from lazr.restfulclient.errors import HTTPError
|
|
|
|
|
2023-01-30 19:45:36 +01:00
|
|
|
from ubuntutools.archive import DebianSourcePackage, UbuntuSourcePackage, DownloadError
|
2010-12-27 21:09:24 +02:00
|
|
|
from ubuntutools.config import UDTConfig, ubu_email
|
2010-05-10 00:05:22 +02:00
|
|
|
from ubuntutools.lp import udtexceptions
|
2023-01-30 19:45:36 +01:00
|
|
|
from ubuntutools.lp.lpapicache import (
|
|
|
|
Distribution,
|
|
|
|
Launchpad,
|
|
|
|
PersonTeam,
|
|
|
|
SourcePackagePublishingHistory,
|
|
|
|
)
|
2011-08-16 15:32:48 +01:00
|
|
|
from ubuntutools.misc import split_release_pocket
|
2011-08-16 19:39:07 +01:00
|
|
|
from ubuntutools.question import YesNoQuestion
|
2023-01-30 19:45:36 +01:00
|
|
|
from ubuntutools.requestsync.mail import get_debian_srcpkg as requestsync_mail_get_debian_srcpkg
|
2013-03-19 00:18:02 +01:00
|
|
|
from ubuntutools.requestsync.lp import get_debian_srcpkg, get_ubuntu_srcpkg
|
2014-04-15 13:01:16 +02:00
|
|
|
from ubuntutools.version import Version
|
2010-05-15 17:55:36 +02:00
|
|
|
|
2018-10-12 18:54:07 -04:00
|
|
|
from ubuntutools import getLogger
|
2023-01-30 19:45:36 +01:00
|
|
|
|
2021-02-01 18:26:13 -05:00
|
|
|
Logger = getLogger()
|
2018-10-12 18:54:07 -04:00
|
|
|
|
2010-05-15 17:55:36 +02:00
|
|
|
|
2010-12-22 23:53:09 +01:00
|
|
|
def remove_signature(dscname):
|
2023-01-30 19:45:36 +01:00
|
|
|
"""Removes the signature from a .dsc file if the .dsc file is signed."""
|
2010-10-30 18:45:14 +02:00
|
|
|
|
2023-01-30 19:45:36 +01:00
|
|
|
dsc_file = open(dscname, encoding="utf-8")
|
2010-12-27 15:20:49 +01:00
|
|
|
if dsc_file.readline().strip() == "-----BEGIN PGP SIGNED MESSAGE-----":
|
2010-10-30 18:45:14 +02:00
|
|
|
unsigned_file = []
|
|
|
|
# search until begin of body found
|
2010-12-27 15:20:49 +01:00
|
|
|
for line in dsc_file:
|
2010-12-22 23:53:09 +01:00
|
|
|
if line.strip() == "":
|
2010-10-30 18:45:14 +02:00
|
|
|
break
|
|
|
|
|
|
|
|
# search for end of body
|
2010-12-27 15:20:49 +01:00
|
|
|
for line in dsc_file:
|
2010-12-22 23:53:09 +01:00
|
|
|
if line.strip() == "":
|
2010-10-30 18:45:14 +02:00
|
|
|
break
|
2010-12-22 23:53:09 +01:00
|
|
|
unsigned_file.append(line)
|
2010-10-30 18:45:14 +02:00
|
|
|
|
2010-12-27 15:20:49 +01:00
|
|
|
dsc_file.close()
|
2023-01-30 19:45:36 +01:00
|
|
|
dsc_file = open(dscname, "w", encoding="utf-8")
|
2010-12-27 15:20:49 +01:00
|
|
|
dsc_file.writelines(unsigned_file)
|
|
|
|
dsc_file.close()
|
2010-05-10 00:05:22 +02:00
|
|
|
|
2011-12-07 00:14:00 +02:00
|
|
|
|
2010-12-27 15:20:49 +01:00
|
|
|
def add_fixed_bugs(changes, bugs):
|
2023-01-30 19:45:36 +01:00
|
|
|
"""Add additional Launchpad bugs to the list of fixed bugs in changes
|
|
|
|
file."""
|
2010-10-30 18:45:14 +02:00
|
|
|
|
2020-06-28 15:52:23 +02:00
|
|
|
changes = [line for line in changes.split("\n") if line.strip() != ""]
|
2010-10-30 18:45:14 +02:00
|
|
|
# Remove duplicates
|
2011-08-24 17:46:23 +02:00
|
|
|
bugs = set(str(bug) for bug in bugs)
|
2010-10-30 18:45:14 +02:00
|
|
|
|
2019-09-04 17:15:50 -03:00
|
|
|
for i in range(len(changes)):
|
2010-10-30 18:45:14 +02:00
|
|
|
if changes[i].startswith("Launchpad-Bugs-Fixed:"):
|
|
|
|
bugs.update(changes[i][22:].strip().split(" "))
|
|
|
|
changes[i] = "Launchpad-Bugs-Fixed: %s" % (" ".join(bugs))
|
|
|
|
break
|
|
|
|
elif i == len(changes) - 1:
|
|
|
|
# Launchpad-Bugs-Fixed entry does not exist in changes file
|
|
|
|
line = "Launchpad-Bugs-Fixed: %s" % (" ".join(bugs))
|
|
|
|
changes.append(line)
|
|
|
|
|
|
|
|
return "\n".join(changes + [""])
|
|
|
|
|
2011-12-07 00:14:00 +02:00
|
|
|
|
2023-01-30 19:45:36 +01:00
|
|
|
def sync_dsc(
|
|
|
|
src_pkg,
|
|
|
|
debian_dist,
|
|
|
|
release,
|
|
|
|
name,
|
|
|
|
email,
|
|
|
|
bugs,
|
|
|
|
ubuntu_mirror,
|
|
|
|
keyid=None,
|
|
|
|
simulate=False,
|
|
|
|
force=False,
|
|
|
|
fakesync=False,
|
|
|
|
):
|
|
|
|
"""Local sync, trying to emulate sync-source.py
|
2011-12-07 00:14:00 +02:00
|
|
|
Grabs a source package, replaces the .orig.tar with the one from Ubuntu,
|
|
|
|
if necessary, writes a sync-appropriate .changes file, and signs it.
|
2023-01-30 19:45:36 +01:00
|
|
|
"""
|
2011-12-07 00:14:00 +02:00
|
|
|
|
2010-10-30 18:45:14 +02:00
|
|
|
uploader = name + " <" + email + ">"
|
|
|
|
|
2010-12-30 17:16:58 +02:00
|
|
|
new_ver = Version(src_pkg.dsc["Version"])
|
2010-10-30 18:45:14 +02:00
|
|
|
|
|
|
|
try:
|
2012-10-30 09:41:56 +01:00
|
|
|
ubuntu_series, ubuntu_pocket = split_release_pocket(release)
|
2023-01-30 19:45:36 +01:00
|
|
|
ubuntu_source = get_ubuntu_srcpkg(src_pkg.source, ubuntu_series, ubuntu_pocket)
|
2010-10-30 18:45:14 +02:00
|
|
|
ubuntu_ver = Version(ubuntu_source.getVersion())
|
2023-01-30 19:45:36 +01:00
|
|
|
ubu_pkg = UbuntuSourcePackage(
|
|
|
|
src_pkg.source,
|
|
|
|
ubuntu_ver.full_version,
|
|
|
|
ubuntu_source.getComponent(),
|
|
|
|
mirrors=[ubuntu_mirror],
|
|
|
|
)
|
2011-01-15 15:50:07 +02:00
|
|
|
need_orig = ubuntu_ver.upstream_version != new_ver.upstream_version
|
2010-10-30 18:45:14 +02:00
|
|
|
except udtexceptions.PackageNotFoundException:
|
2023-01-30 19:45:36 +01:00
|
|
|
ubuntu_ver = Version("~")
|
2010-12-30 17:16:58 +02:00
|
|
|
ubu_pkg = None
|
2011-01-15 15:50:07 +02:00
|
|
|
need_orig = True
|
2023-01-30 19:45:36 +01:00
|
|
|
Logger.info("%s does not exist in Ubuntu.", name)
|
2010-10-30 18:45:14 +02:00
|
|
|
|
2023-01-30 19:45:36 +01:00
|
|
|
Logger.debug(
|
|
|
|
"Source %s: current version %s, new version %s", src_pkg.source, ubuntu_ver, new_ver
|
|
|
|
)
|
|
|
|
Logger.debug("Needs source tarball: %s", str(need_orig))
|
2010-10-30 18:45:14 +02:00
|
|
|
|
|
|
|
cur_ver = ubuntu_ver.get_related_debian_version()
|
|
|
|
if ubuntu_ver.is_modified_in_ubuntu():
|
2011-08-16 19:56:38 +01:00
|
|
|
if not force:
|
2023-01-30 19:45:36 +01:00
|
|
|
Logger.error("--force is required to discard Ubuntu changes.")
|
2011-08-16 19:56:38 +01:00
|
|
|
sys.exit(1)
|
|
|
|
|
2023-01-30 19:45:36 +01:00
|
|
|
Logger.warning(
|
|
|
|
"Overwriting modified Ubuntu version %s, setting current version to %s",
|
|
|
|
ubuntu_ver.full_version,
|
|
|
|
cur_ver.full_version,
|
|
|
|
)
|
2011-08-16 15:32:48 +01:00
|
|
|
if simulate:
|
|
|
|
return
|
2010-10-30 18:45:14 +02:00
|
|
|
|
2011-01-31 19:01:10 +02:00
|
|
|
try:
|
|
|
|
src_pkg.pull()
|
2019-09-04 17:15:50 -03:00
|
|
|
except DownloadError as e:
|
2023-01-30 19:45:36 +01:00
|
|
|
Logger.error("Failed to download: %s", str(e))
|
2011-01-31 19:01:10 +02:00
|
|
|
sys.exit(1)
|
2010-12-30 17:16:58 +02:00
|
|
|
src_pkg.unpack()
|
2010-10-30 18:45:14 +02:00
|
|
|
|
2011-10-26 22:21:23 +02:00
|
|
|
needs_fakesync = not (need_orig or ubu_pkg.verify_orig())
|
|
|
|
|
|
|
|
if needs_fakesync and fakesync:
|
2023-01-30 19:45:36 +01:00
|
|
|
Logger.warning("Performing a fakesync")
|
2011-10-26 22:21:23 +02:00
|
|
|
elif not needs_fakesync and fakesync:
|
2023-01-30 19:45:36 +01:00
|
|
|
Logger.error("Fakesync not required, aborting.")
|
2011-10-26 22:21:23 +02:00
|
|
|
sys.exit(1)
|
|
|
|
elif needs_fakesync and not fakesync:
|
2023-01-30 19:45:36 +01:00
|
|
|
Logger.error(
|
|
|
|
"The checksums of the Debian and Ubuntu packages "
|
|
|
|
"mismatch. A fake sync using --fakesync is required."
|
|
|
|
)
|
2011-10-26 22:21:23 +02:00
|
|
|
sys.exit(1)
|
2011-01-15 15:50:07 +02:00
|
|
|
|
|
|
|
if fakesync:
|
2010-10-30 18:45:14 +02:00
|
|
|
# Download Ubuntu files (override Debian source tarballs)
|
2011-01-31 19:01:10 +02:00
|
|
|
try:
|
|
|
|
ubu_pkg.pull()
|
2019-09-04 17:15:50 -03:00
|
|
|
except DownloadError as e:
|
2023-01-30 19:45:36 +01:00
|
|
|
Logger.error("Failed to download: %s", str(e))
|
2011-01-31 19:01:10 +02:00
|
|
|
sys.exit(1)
|
2010-10-30 18:45:14 +02:00
|
|
|
|
|
|
|
# change into package directory
|
2023-01-30 19:45:36 +01:00
|
|
|
directory = src_pkg.source + "-" + new_ver.upstream_version
|
|
|
|
Logger.debug("cd" + directory)
|
2010-10-30 18:45:14 +02:00
|
|
|
os.chdir(directory)
|
|
|
|
|
|
|
|
# read Debian distribution from debian/changelog if not specified
|
|
|
|
if debian_dist is None:
|
2023-01-30 19:45:36 +01:00
|
|
|
line = open("debian/changelog", encoding="utf-8").readline()
|
2010-10-30 18:45:14 +02:00
|
|
|
debian_dist = line.split(" ")[2].strip(";")
|
|
|
|
|
2011-01-15 15:50:07 +02:00
|
|
|
if not fakesync:
|
2010-10-30 18:45:14 +02:00
|
|
|
# create the changes file
|
2023-01-30 19:45:36 +01:00
|
|
|
changes_filename = "%s_%s_source.changes" % (src_pkg.source, new_ver.strip_epoch())
|
|
|
|
cmd = [
|
|
|
|
"dpkg-genchanges",
|
|
|
|
"-S",
|
|
|
|
"-v" + cur_ver.full_version,
|
|
|
|
"-DDistribution=" + release,
|
|
|
|
"-DOrigin=debian/" + debian_dist,
|
|
|
|
"-e" + uploader,
|
|
|
|
]
|
2010-10-30 18:45:14 +02:00
|
|
|
if need_orig:
|
|
|
|
cmd.append("-sa")
|
|
|
|
else:
|
|
|
|
cmd.append("-sd")
|
2018-10-12 18:54:07 -04:00
|
|
|
if not Logger.isEnabledFor(logging.DEBUG):
|
2010-10-30 18:45:14 +02:00
|
|
|
cmd += ["-q"]
|
2023-01-30 19:45:36 +01:00
|
|
|
Logger.debug(" ".join(cmd) + "> ../" + changes_filename)
|
|
|
|
changes = subprocess.check_output(cmd, encoding="utf-8")
|
2010-10-30 18:45:14 +02:00
|
|
|
|
|
|
|
# Add additional bug numbers
|
|
|
|
if len(bugs) > 0:
|
2010-12-27 15:20:49 +01:00
|
|
|
changes = add_fixed_bugs(changes, bugs)
|
2010-10-30 18:45:14 +02:00
|
|
|
|
|
|
|
# remove extracted (temporary) files
|
2023-01-30 19:45:36 +01:00
|
|
|
Logger.debug("cd ..")
|
|
|
|
os.chdir("..")
|
2010-10-30 18:45:14 +02:00
|
|
|
shutil.rmtree(directory, True)
|
|
|
|
|
|
|
|
# write changes file
|
2023-01-30 19:45:36 +01:00
|
|
|
changes_file = open(changes_filename, "w", encoding="utf-8")
|
2010-12-27 15:20:49 +01:00
|
|
|
changes_file.writelines(changes)
|
|
|
|
changes_file.close()
|
2010-10-30 18:45:14 +02:00
|
|
|
|
|
|
|
# remove signature and sign package
|
2010-12-30 17:16:58 +02:00
|
|
|
remove_signature(src_pkg.dsc_name)
|
2010-10-30 18:45:14 +02:00
|
|
|
if keyid is not False:
|
2010-12-27 15:20:49 +01:00
|
|
|
cmd = ["debsign", changes_filename]
|
2017-05-01 00:20:03 +02:00
|
|
|
if keyid is not None:
|
2010-10-30 18:45:14 +02:00
|
|
|
cmd.insert(1, "-k" + keyid)
|
2023-01-30 19:45:36 +01:00
|
|
|
Logger.debug(" ".join(cmd))
|
2010-10-30 18:45:14 +02:00
|
|
|
subprocess.check_call(cmd)
|
|
|
|
else:
|
|
|
|
# Create fakesync changelog entry
|
|
|
|
new_ver = Version(new_ver.full_version + "fakesync1")
|
2023-01-30 19:45:36 +01:00
|
|
|
changes_filename = "%s_%s_source.changes" % (src_pkg.source, new_ver.strip_epoch())
|
2010-10-30 18:45:14 +02:00
|
|
|
if len(bugs) > 0:
|
2023-01-30 19:45:36 +01:00
|
|
|
message = "Fake sync due to mismatching orig tarball (LP: %s)." % (
|
|
|
|
", ".join(["#" + str(b) for b in bugs])
|
|
|
|
)
|
2010-10-30 18:45:14 +02:00
|
|
|
else:
|
|
|
|
message = "Fake sync due to mismatching orig tarball."
|
2023-01-30 19:45:36 +01:00
|
|
|
cmd = ["dch", "-v", new_ver.full_version, "--force-distribution", "-D", release, message]
|
|
|
|
env = {"DEBFULLNAME": name, "DEBEMAIL": email}
|
|
|
|
Logger.debug(" ".join(cmd))
|
2010-10-30 18:45:14 +02:00
|
|
|
subprocess.check_call(cmd, env=env)
|
|
|
|
|
|
|
|
# update the Maintainer field
|
|
|
|
cmd = ["update-maintainer"]
|
2018-10-12 18:54:07 -04:00
|
|
|
if not Logger.isEnabledFor(logging.DEBUG):
|
2010-10-30 18:45:14 +02:00
|
|
|
cmd.append("-q")
|
2023-01-30 19:45:36 +01:00
|
|
|
Logger.debug(" ".join(cmd))
|
2010-10-30 18:45:14 +02:00
|
|
|
subprocess.check_call(cmd)
|
2010-12-03 00:06:43 +01:00
|
|
|
|
2010-10-30 18:45:14 +02:00
|
|
|
# Build source package
|
2023-01-30 19:45:36 +01:00
|
|
|
cmd = ["debuild", "--no-lintian", "-nc", "-S", "-v" + cur_ver.full_version]
|
2010-10-30 18:45:14 +02:00
|
|
|
if need_orig:
|
2023-01-30 19:45:36 +01:00
|
|
|
cmd += ["-sa"]
|
2010-10-30 18:45:14 +02:00
|
|
|
if keyid:
|
|
|
|
cmd += ["-k" + keyid]
|
2023-01-30 19:45:36 +01:00
|
|
|
Logger.debug(" ".join(cmd))
|
2010-12-30 17:16:58 +02:00
|
|
|
returncode = subprocess.call(cmd)
|
2010-10-30 20:36:42 +02:00
|
|
|
if returncode != 0:
|
2023-01-30 19:45:36 +01:00
|
|
|
Logger.error("Source-only build with debuild failed. Please check build log above.")
|
2010-10-30 20:36:42 +02:00
|
|
|
sys.exit(1)
|
2010-05-15 17:55:36 +02:00
|
|
|
|
2011-12-07 00:14:00 +02:00
|
|
|
|
2023-01-30 19:45:36 +01:00
|
|
|
def fetch_source_pkg(package, dist, version, component, ubuntu_release, mirror):
|
2010-12-28 15:35:15 +02:00
|
|
|
"""Download the specified source package.
|
|
|
|
dist, version, component, mirror can all be None.
|
|
|
|
"""
|
2011-08-17 03:03:01 +01:00
|
|
|
if mirror is None:
|
|
|
|
mirrors = []
|
|
|
|
else:
|
|
|
|
mirrors = [mirror]
|
|
|
|
|
2023-01-30 19:45:36 +01:00
|
|
|
if package.endswith(".dsc"):
|
2011-08-17 03:03:01 +01:00
|
|
|
return DebianSourcePackage(dscfile=package, mirrors=mirrors)
|
2010-12-30 17:16:58 +02:00
|
|
|
|
2010-10-30 18:45:14 +02:00
|
|
|
if dist is None:
|
2023-01-30 19:45:36 +01:00
|
|
|
dist = "unstable"
|
2012-05-06 10:15:54 +02:00
|
|
|
|
2010-12-28 15:35:15 +02:00
|
|
|
requested_version = version
|
2010-10-30 18:45:14 +02:00
|
|
|
if type(version) == str:
|
|
|
|
version = Version(version)
|
|
|
|
|
|
|
|
if version is None or component is None:
|
2011-01-01 19:51:03 +02:00
|
|
|
try:
|
2011-09-10 15:42:40 +02:00
|
|
|
debian_srcpkg = get_debian_srcpkg(package, dist)
|
2023-01-30 19:45:36 +01:00
|
|
|
except (
|
|
|
|
udtexceptions.PackageNotFoundException,
|
|
|
|
udtexceptions.SeriesNotFoundException,
|
|
|
|
) as e:
|
2011-01-01 19:51:03 +02:00
|
|
|
Logger.error(str(e))
|
|
|
|
sys.exit(1)
|
2010-12-28 15:35:15 +02:00
|
|
|
if version is None:
|
|
|
|
version = Version(debian_srcpkg.getVersion())
|
2010-10-30 18:45:14 +02:00
|
|
|
try:
|
2012-10-30 09:41:56 +01:00
|
|
|
ubuntu_series, ubuntu_pocket = split_release_pocket(ubuntu_release)
|
2023-01-30 19:45:36 +01:00
|
|
|
ubuntu_srcpkg = get_ubuntu_srcpkg(package, ubuntu_series, ubuntu_pocket)
|
2010-12-28 15:35:15 +02:00
|
|
|
ubuntu_version = Version(ubuntu_srcpkg.getVersion())
|
2010-10-30 18:45:14 +02:00
|
|
|
except udtexceptions.PackageNotFoundException:
|
2023-01-30 19:45:36 +01:00
|
|
|
ubuntu_version = Version("~")
|
2019-09-04 17:15:50 -03:00
|
|
|
except udtexceptions.SeriesNotFoundException as e:
|
2011-01-01 19:51:03 +02:00
|
|
|
Logger.error(str(e))
|
|
|
|
sys.exit(1)
|
2010-12-28 15:35:15 +02:00
|
|
|
if ubuntu_version >= version:
|
2010-10-30 18:45:14 +02:00
|
|
|
# The LP importer is maybe out of date
|
2011-09-10 15:42:40 +02:00
|
|
|
debian_srcpkg = requestsync_mail_get_debian_srcpkg(package, dist)
|
2010-12-28 15:35:15 +02:00
|
|
|
if requested_version is None:
|
|
|
|
version = Version(debian_srcpkg.getVersion())
|
|
|
|
if ubuntu_version >= version:
|
2023-01-30 19:45:36 +01:00
|
|
|
Logger.error(
|
|
|
|
"Version in Debian %s (%s) isn't newer than Ubuntu %s (%s)",
|
|
|
|
version,
|
|
|
|
dist,
|
|
|
|
ubuntu_version,
|
|
|
|
ubuntu_release,
|
|
|
|
)
|
2010-12-28 15:35:15 +02:00
|
|
|
sys.exit(1)
|
2010-10-30 18:45:14 +02:00
|
|
|
if component is None:
|
|
|
|
component = debian_srcpkg.getComponent()
|
|
|
|
|
2023-01-30 19:45:36 +01:00
|
|
|
assert component in ("main", "contrib", "non-free")
|
2010-10-30 18:45:14 +02:00
|
|
|
|
2023-01-30 19:45:36 +01:00
|
|
|
return DebianSourcePackage(package, version.full_version, component, mirrors=mirrors)
|
2010-05-10 00:05:22 +02:00
|
|
|
|
2011-12-07 00:14:00 +02:00
|
|
|
|
2011-12-07 00:23:22 +02:00
|
|
|
def copy(src_pkg, release, bugs, sponsoree=None, simulate=False, force=False):
|
2011-08-18 15:07:09 +01:00
|
|
|
"""Copy a source package from Debian to Ubuntu using the Launchpad API."""
|
2023-01-30 19:45:36 +01:00
|
|
|
ubuntu = Distribution("ubuntu")
|
|
|
|
debian_archive = Distribution("debian").getArchive()
|
2011-08-16 15:32:48 +01:00
|
|
|
ubuntu_archive = ubuntu.getArchive()
|
|
|
|
if release is None:
|
|
|
|
ubuntu_series = ubuntu.getDevelopmentSeries().name
|
2023-01-30 19:45:36 +01:00
|
|
|
ubuntu_pocket = "Release"
|
2011-08-16 15:32:48 +01:00
|
|
|
else:
|
|
|
|
ubuntu_series, ubuntu_pocket = split_release_pocket(release)
|
|
|
|
|
2011-08-17 03:03:01 +01:00
|
|
|
# Ensure that the provided Debian version actually exists.
|
2011-08-16 15:32:48 +01:00
|
|
|
try:
|
2011-08-24 17:46:23 +02:00
|
|
|
debian_spph = SourcePackagePublishingHistory(
|
2023-01-30 19:45:36 +01:00
|
|
|
debian_archive.getPublishedSources(
|
|
|
|
source_name=src_pkg.source, version=src_pkg.version.full_version, exact_match=True
|
|
|
|
)[0]
|
|
|
|
)
|
2011-08-17 03:03:01 +01:00
|
|
|
except IndexError:
|
2023-01-30 19:45:36 +01:00
|
|
|
Logger.error(
|
|
|
|
"Debian version %s has not been picked up by LP yet. Please try again later.",
|
|
|
|
src_pkg.version,
|
|
|
|
)
|
2011-08-17 03:03:01 +01:00
|
|
|
sys.exit(1)
|
2011-08-16 15:32:48 +01:00
|
|
|
|
2011-08-17 03:03:01 +01:00
|
|
|
try:
|
2023-01-30 19:45:36 +01:00
|
|
|
ubuntu_spph = get_ubuntu_srcpkg(src_pkg.source, ubuntu_series, ubuntu_pocket)
|
|
|
|
ubuntu_pkg = UbuntuSourcePackage(
|
|
|
|
src_pkg.source, ubuntu_spph.getVersion(), ubuntu_spph.getComponent(), mirrors=[]
|
|
|
|
)
|
|
|
|
|
|
|
|
Logger.info(
|
|
|
|
"Source %s -> %s/%s: current version %s, new version %s",
|
|
|
|
src_pkg.source,
|
|
|
|
ubuntu_series,
|
|
|
|
ubuntu_pocket,
|
|
|
|
ubuntu_pkg.version,
|
|
|
|
src_pkg.version,
|
|
|
|
)
|
2011-08-16 19:56:38 +01:00
|
|
|
|
2011-08-17 03:03:01 +01:00
|
|
|
ubuntu_version = Version(ubuntu_pkg.version.full_version)
|
2011-08-24 17:46:23 +02:00
|
|
|
base_version = ubuntu_version.get_related_debian_version()
|
2011-08-16 19:56:38 +01:00
|
|
|
if not force and ubuntu_version.is_modified_in_ubuntu():
|
2023-01-30 19:45:36 +01:00
|
|
|
Logger.error("--force is required to discard Ubuntu changes.")
|
2011-08-16 19:56:38 +01:00
|
|
|
sys.exit(1)
|
2011-08-17 03:03:01 +01:00
|
|
|
|
|
|
|
# Check whether a fakesync would be required.
|
2011-08-18 15:06:05 +01:00
|
|
|
if not src_pkg.dsc.compare_dsc(ubuntu_pkg.dsc):
|
2023-01-30 19:45:36 +01:00
|
|
|
Logger.error(
|
|
|
|
"The checksums of the Debian and Ubuntu packages "
|
|
|
|
"mismatch. A fake sync using --fakesync is required."
|
|
|
|
)
|
2011-08-18 15:06:05 +01:00
|
|
|
sys.exit(1)
|
2011-08-16 15:32:48 +01:00
|
|
|
except udtexceptions.PackageNotFoundException:
|
2023-01-30 19:45:36 +01:00
|
|
|
base_version = Version("~")
|
|
|
|
Logger.info(
|
|
|
|
"Source %s -> %s/%s: not in Ubuntu, new version %s",
|
|
|
|
src_pkg.source,
|
|
|
|
ubuntu_series,
|
|
|
|
ubuntu_pocket,
|
|
|
|
src_pkg.version,
|
|
|
|
)
|
2011-08-24 17:46:23 +02:00
|
|
|
|
2011-11-13 22:50:34 +02:00
|
|
|
changes = debian_spph.getChangelog(since_version=base_version)
|
2011-08-24 17:46:23 +02:00
|
|
|
if changes:
|
2011-10-14 22:28:57 +02:00
|
|
|
changes = changes.strip()
|
2018-10-12 18:54:07 -04:00
|
|
|
Logger.info("New changes:\n%s", changes)
|
2011-08-24 17:46:23 +02:00
|
|
|
|
2011-08-16 15:32:48 +01:00
|
|
|
if simulate:
|
|
|
|
return
|
|
|
|
|
2011-12-07 00:23:22 +02:00
|
|
|
if sponsoree:
|
2023-01-30 19:45:36 +01:00
|
|
|
Logger.info("Sponsoring this sync for %s (%s)", sponsoree.display_name, sponsoree.name)
|
2011-08-16 19:39:07 +01:00
|
|
|
answer = YesNoQuestion().ask("Sync this package", "no")
|
|
|
|
if answer != "yes":
|
2011-08-16 16:00:30 +01:00
|
|
|
return
|
|
|
|
|
2011-08-16 16:30:10 +01:00
|
|
|
try:
|
|
|
|
ubuntu_archive.copyPackage(
|
2011-08-17 03:03:01 +01:00
|
|
|
source_name=src_pkg.source,
|
2011-08-17 13:02:07 +01:00
|
|
|
version=src_pkg.version.full_version,
|
2011-08-16 18:07:58 +01:00
|
|
|
from_archive=debian_archive,
|
2011-08-16 16:30:10 +01:00
|
|
|
to_series=ubuntu_series,
|
|
|
|
to_pocket=ubuntu_pocket,
|
2011-12-07 00:23:22 +02:00
|
|
|
include_binaries=False,
|
2023-01-30 19:45:36 +01:00
|
|
|
sponsored=sponsoree,
|
|
|
|
)
|
2019-09-04 17:15:50 -03:00
|
|
|
except HTTPError as error:
|
2023-01-30 19:45:36 +01:00
|
|
|
Logger.error("HTTP Error %s: %s", error.response.status, error.response.reason)
|
2011-08-16 16:30:10 +01:00
|
|
|
Logger.error(error.content)
|
|
|
|
sys.exit(1)
|
|
|
|
|
2023-01-30 19:45:36 +01:00
|
|
|
Logger.info("Request succeeded; you should get an e-mail once it is processed.")
|
2011-09-03 20:49:35 +02:00
|
|
|
bugs = sorted(set(bugs))
|
|
|
|
if bugs:
|
2023-01-30 19:45:36 +01:00
|
|
|
Logger.info("Launchpad bugs to be closed: %s", ", ".join(str(bug) for bug in bugs))
|
|
|
|
Logger.info("Please wait for the sync to be successful before closing bugs.")
|
2011-09-03 22:39:04 +02:00
|
|
|
answer = YesNoQuestion().ask("Close bugs", "yes")
|
2011-09-03 20:49:35 +02:00
|
|
|
if answer == "yes":
|
2023-01-30 19:45:36 +01:00
|
|
|
close_bugs(bugs, src_pkg.source, src_pkg.version.full_version, changes, sponsoree)
|
2010-05-10 00:05:22 +02:00
|
|
|
|
2011-12-07 00:14:00 +02:00
|
|
|
|
2011-08-24 14:46:11 +02:00
|
|
|
def is_blacklisted(query):
|
2023-01-30 19:45:36 +01:00
|
|
|
"""Determine if package "query" is in the sync blacklist
|
2011-09-05 15:40:24 +02:00
|
|
|
Returns tuple of (blacklisted, comments)
|
|
|
|
blacklisted is one of False, 'CURRENT', 'ALWAYS'
|
2011-08-24 14:59:22 +02:00
|
|
|
"""
|
2023-01-30 19:45:36 +01:00
|
|
|
series = Launchpad.distributions["ubuntu"].current_series
|
2011-09-05 15:40:24 +02:00
|
|
|
lp_comments = series.getDifferenceComments(source_package_name=query)
|
|
|
|
blacklisted = False
|
2023-01-30 19:45:36 +01:00
|
|
|
comments = [
|
|
|
|
"%s\n -- %s %s"
|
|
|
|
% (
|
|
|
|
c.body_text,
|
|
|
|
c.comment_author.name,
|
|
|
|
c.comment_date.strftime("%a, %d %b %Y %H:%M:%S +0000"),
|
|
|
|
)
|
|
|
|
for c in lp_comments
|
|
|
|
]
|
2011-09-05 15:40:24 +02:00
|
|
|
|
2011-09-12 11:00:23 +02:00
|
|
|
for diff in series.getDifferencesTo(source_package_name_filter=query):
|
2023-01-30 19:45:36 +01:00
|
|
|
if diff.status == "Blacklisted current version" and blacklisted != "ALWAYS":
|
|
|
|
blacklisted = "CURRENT"
|
|
|
|
if diff.status == "Blacklisted always":
|
|
|
|
blacklisted = "ALWAYS"
|
2011-08-24 19:52:21 +02:00
|
|
|
|
|
|
|
# Old blacklist:
|
2023-01-30 19:45:36 +01:00
|
|
|
url = "http://people.canonical.com/~ubuntu-archive/sync-blacklist.txt"
|
2019-09-04 17:15:50 -03:00
|
|
|
with urllib.request.urlopen(url) as f:
|
2011-10-26 21:08:17 +02:00
|
|
|
applicable_lines = []
|
2011-08-24 14:46:11 +02:00
|
|
|
for line in f:
|
2023-01-30 19:45:36 +01:00
|
|
|
line = line.decode("utf-8")
|
2011-08-24 14:46:11 +02:00
|
|
|
if not line.strip():
|
2011-10-26 21:08:17 +02:00
|
|
|
applicable_lines = []
|
2011-08-24 14:46:11 +02:00
|
|
|
continue
|
2011-10-26 21:08:17 +02:00
|
|
|
applicable_lines.append(line)
|
2018-12-11 16:39:49 +00:00
|
|
|
try:
|
2023-01-30 19:45:36 +01:00
|
|
|
line = line[: line.index("#")]
|
2018-12-11 16:39:49 +00:00
|
|
|
except ValueError:
|
|
|
|
pass
|
|
|
|
source = line.strip()
|
|
|
|
if source and fnmatch.fnmatch(query, source):
|
2011-10-26 21:08:17 +02:00
|
|
|
comments += ["From sync-blacklist.txt:"] + applicable_lines
|
2023-01-30 19:45:36 +01:00
|
|
|
blacklisted = "ALWAYS"
|
2011-09-05 15:40:24 +02:00
|
|
|
break
|
|
|
|
|
|
|
|
return (blacklisted, comments)
|
2011-08-24 14:46:11 +02:00
|
|
|
|
2011-12-07 00:14:00 +02:00
|
|
|
|
2011-12-21 23:18:22 +02:00
|
|
|
def close_bugs(bugs, package, version, changes, sponsoree):
|
2011-08-24 19:38:16 +02:00
|
|
|
"""Close the correct task on all bugs, with changes"""
|
2023-01-30 19:45:36 +01:00
|
|
|
ubuntu = Launchpad.distributions["ubuntu"]
|
|
|
|
message = "This bug was fixed in the package %s - %s" % (package, version)
|
2011-12-21 23:18:22 +02:00
|
|
|
if sponsoree:
|
2023-01-30 19:45:36 +01:00
|
|
|
message += "\nSponsored for %s (%s)" % (sponsoree.display_name, sponsoree.name)
|
2011-10-14 22:28:57 +02:00
|
|
|
if changes:
|
|
|
|
message += "\n\n---------------\n" + changes
|
2011-08-24 19:38:16 +02:00
|
|
|
for bug in bugs:
|
|
|
|
bug = Launchpad.bugs[bug]
|
|
|
|
if bug.duplicate_of is not None:
|
|
|
|
bug = bug.duplicate_of
|
|
|
|
for task in bug.bug_tasks:
|
|
|
|
target = task.target
|
2023-01-30 19:45:36 +01:00
|
|
|
if target == ubuntu or (
|
|
|
|
target.name == package and getattr(target, "distribution", None) == ubuntu
|
|
|
|
):
|
|
|
|
if task.status != "Fix Released":
|
2018-10-12 18:54:07 -04:00
|
|
|
Logger.info("Closed bug %s", task.web_link)
|
2023-01-30 19:45:36 +01:00
|
|
|
task.status = "Fix Released"
|
2011-08-24 19:38:16 +02:00
|
|
|
task.lp_save()
|
|
|
|
bug.newMessage(content=message)
|
|
|
|
break
|
|
|
|
else:
|
2019-09-04 17:15:50 -03:00
|
|
|
Logger.error("Cannot find any tasks on LP: #%i to close.", bug.id)
|
2011-08-24 19:38:16 +02:00
|
|
|
|
2011-12-07 00:14:00 +02:00
|
|
|
|
2011-10-12 00:58:42 +02:00
|
|
|
def parse():
|
|
|
|
"""Parse given command-line parameters."""
|
|
|
|
|
2010-12-27 18:24:21 +02:00
|
|
|
usage = "%prog [options] <.dsc URL/path or package name>"
|
|
|
|
epilog = "See %s(1) for more info." % os.path.basename(sys.argv[0])
|
2010-10-30 18:45:14 +02:00
|
|
|
parser = optparse.OptionParser(usage=usage, epilog=epilog)
|
|
|
|
|
2023-01-30 19:45:36 +01:00
|
|
|
parser.add_option("-d", "--distribution", help="Debian distribution to sync from.")
|
|
|
|
parser.add_option("-r", "--release", help="Specify target Ubuntu release.")
|
|
|
|
parser.add_option("-V", "--debian-version", help="Specify the version to sync from.")
|
|
|
|
parser.add_option("-c", "--component", help="Specify the Debian component to sync from.")
|
|
|
|
parser.add_option(
|
|
|
|
"-b",
|
|
|
|
"--bug",
|
|
|
|
metavar="BUG",
|
|
|
|
dest="bugs",
|
|
|
|
action="append",
|
|
|
|
default=list(),
|
|
|
|
help="Mark Launchpad bug BUG as being fixed by this upload.",
|
|
|
|
)
|
|
|
|
parser.add_option(
|
|
|
|
"-s",
|
|
|
|
"--sponsor",
|
|
|
|
metavar="USERNAME",
|
|
|
|
dest="sponsoree",
|
|
|
|
default=None,
|
|
|
|
help="Sponsor the sync for USERNAME (a Launchpad username).",
|
|
|
|
)
|
|
|
|
parser.add_option(
|
|
|
|
"-v",
|
|
|
|
"--verbose",
|
|
|
|
action="store_true",
|
|
|
|
default=False,
|
|
|
|
help="Display more progress information.",
|
|
|
|
)
|
|
|
|
parser.add_option(
|
|
|
|
"-F",
|
|
|
|
"--fakesync",
|
|
|
|
action="store_true",
|
|
|
|
default=False,
|
|
|
|
help="Perform a fakesync (a sync where Debian and "
|
|
|
|
"Ubuntu have a .orig.tar mismatch). "
|
|
|
|
"This implies --no-lp and will leave a signed "
|
|
|
|
".changes file for you to upload.",
|
|
|
|
)
|
|
|
|
parser.add_option(
|
|
|
|
"-f",
|
|
|
|
"--force",
|
|
|
|
action="store_true",
|
|
|
|
default=False,
|
|
|
|
help="Force sync over the top of Ubuntu changes.",
|
|
|
|
)
|
|
|
|
parser.add_option(
|
|
|
|
"--no-conf",
|
|
|
|
default=False,
|
|
|
|
action="store_true",
|
|
|
|
help="Don't read config files or environment variables.",
|
|
|
|
)
|
|
|
|
parser.add_option(
|
|
|
|
"-l",
|
|
|
|
"--lpinstance",
|
|
|
|
metavar="INSTANCE",
|
|
|
|
help="Launchpad instance to connect to (default: production).",
|
|
|
|
)
|
|
|
|
parser.add_option(
|
|
|
|
"--simulate",
|
|
|
|
default=False,
|
|
|
|
action="store_true",
|
|
|
|
help="Show what would be done, but don't actually do it.",
|
|
|
|
)
|
2010-10-30 18:45:14 +02:00
|
|
|
|
2017-05-01 00:20:03 +02:00
|
|
|
no_lp = optparse.OptionGroup(
|
2023-01-30 19:45:36 +01:00
|
|
|
parser,
|
|
|
|
"Local sync preparation options",
|
2017-05-01 00:20:03 +02:00
|
|
|
"Options that only apply when using --no-lp. "
|
|
|
|
"WARNING: The use of --no-lp is not recommended for uploads "
|
|
|
|
"targeted at Ubuntu. "
|
2023-01-30 19:45:36 +01:00
|
|
|
"The archive-admins discourage its use, except for fakesyncs.",
|
|
|
|
)
|
|
|
|
no_lp.add_option(
|
|
|
|
"--no-lp",
|
|
|
|
dest="lp",
|
|
|
|
action="store_false",
|
|
|
|
default=True,
|
|
|
|
help="Construct sync locally, rather than letting "
|
|
|
|
"Launchpad copy the package directly. "
|
|
|
|
"It will leave a signed .changes file for you to "
|
|
|
|
"upload.",
|
|
|
|
)
|
|
|
|
no_lp.add_option(
|
|
|
|
"-n",
|
|
|
|
"--uploader-name",
|
|
|
|
help="Use UPLOADER_NAME as the name of the maintainer for this upload.",
|
|
|
|
)
|
|
|
|
no_lp.add_option(
|
|
|
|
"-e",
|
|
|
|
"--uploader-email",
|
|
|
|
help="Use UPLOADER_EMAIL as email address of the maintainer for this upload.",
|
|
|
|
)
|
|
|
|
no_lp.add_option(
|
|
|
|
"-k", "--key", dest="keyid", help="Specify the key ID to be used for signing."
|
|
|
|
)
|
|
|
|
no_lp.add_option(
|
|
|
|
"--dont-sign", dest="keyid", action="store_false", help="Do not sign the upload."
|
|
|
|
)
|
|
|
|
no_lp.add_option(
|
|
|
|
"-D",
|
|
|
|
"--debian-mirror",
|
|
|
|
metavar="DEBIAN_MIRROR",
|
|
|
|
help="Preferred Debian mirror (default: %s)" % UDTConfig.defaults["DEBIAN_MIRROR"],
|
|
|
|
)
|
|
|
|
no_lp.add_option(
|
|
|
|
"-U",
|
|
|
|
"--ubuntu-mirror",
|
|
|
|
metavar="UBUNTU_MIRROR",
|
|
|
|
help="Preferred Ubuntu mirror (default: %s)" % UDTConfig.defaults["UBUNTU_MIRROR"],
|
|
|
|
)
|
2011-12-06 23:37:25 +02:00
|
|
|
parser.add_option_group(no_lp)
|
|
|
|
|
2010-10-30 18:45:14 +02:00
|
|
|
(options, args) = parser.parse_args()
|
|
|
|
|
2011-10-26 22:21:23 +02:00
|
|
|
if options.fakesync:
|
|
|
|
options.lp = False
|
|
|
|
|
2010-10-30 18:45:14 +02:00
|
|
|
if len(args) == 0:
|
2023-01-30 19:45:36 +01:00
|
|
|
parser.error("No .dsc URL/path or package name specified.")
|
2010-12-27 18:24:21 +02:00
|
|
|
if len(args) > 1:
|
2023-01-30 19:45:36 +01:00
|
|
|
parser.error("Multiple .dsc URLs/paths or package names specified: " + ", ".join(args))
|
2010-10-30 18:45:14 +02:00
|
|
|
|
2011-08-24 17:46:23 +02:00
|
|
|
try:
|
2011-09-10 15:42:40 +02:00
|
|
|
options.bugs = [int(b) for b in options.bugs]
|
2011-08-24 19:38:16 +02:00
|
|
|
except TypeError:
|
2023-01-30 19:45:36 +01:00
|
|
|
parser.error("Invalid bug number(s) specified.")
|
2010-10-30 19:17:30 +02:00
|
|
|
|
2010-12-28 15:35:15 +02:00
|
|
|
if options.component not in (None, "main", "contrib", "non-free"):
|
2023-01-30 19:45:36 +01:00
|
|
|
parser.error(
|
|
|
|
"%s is not a valid Debian component. "
|
|
|
|
"It should be one of main, contrib, or non-free." % options.component
|
|
|
|
)
|
2010-12-27 21:09:24 +02:00
|
|
|
|
2011-08-16 15:32:48 +01:00
|
|
|
if options.lp and options.uploader_name:
|
2023-01-30 19:45:36 +01:00
|
|
|
parser.error("Uploader name can only be overridden using --no-lp.")
|
2011-08-16 15:32:48 +01:00
|
|
|
if options.lp and options.uploader_email:
|
2023-01-30 19:45:36 +01:00
|
|
|
parser.error("Uploader email address can only be overridden using --no-lp.")
|
2011-08-16 15:32:48 +01:00
|
|
|
# --key, --dont-sign, --debian-mirror, and --ubuntu-mirror are just
|
|
|
|
# ignored with options.lp, and do not require warnings.
|
|
|
|
|
2011-10-12 00:58:42 +02:00
|
|
|
if options.lp:
|
2023-01-30 19:45:36 +01:00
|
|
|
if args[0].endswith(".dsc"):
|
|
|
|
parser.error(".dsc files can only be synced using --no-lp.")
|
2011-10-12 00:58:42 +02:00
|
|
|
|
|
|
|
return (options, args[0])
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
2023-01-30 19:45:36 +01:00
|
|
|
"""Handle parameters and get the ball rolling"""
|
2011-10-12 00:58:42 +02:00
|
|
|
(options, package) = parse()
|
|
|
|
|
2018-10-12 18:54:07 -04:00
|
|
|
if options.verbose:
|
2023-01-30 19:45:36 +01:00
|
|
|
Logger.setLevel("DEBUG")
|
2010-12-28 15:35:15 +02:00
|
|
|
config = UDTConfig(options.no_conf)
|
|
|
|
if options.debian_mirror is None:
|
2023-01-30 19:45:36 +01:00
|
|
|
options.debian_mirror = config.get_value("DEBIAN_MIRROR")
|
2010-12-28 15:35:15 +02:00
|
|
|
if options.ubuntu_mirror is None:
|
2023-01-30 19:45:36 +01:00
|
|
|
options.ubuntu_mirror = config.get_value("UBUNTU_MIRROR")
|
2010-10-30 18:45:14 +02:00
|
|
|
|
2012-02-11 11:59:46 -08:00
|
|
|
if options.keyid is None:
|
2023-01-30 19:45:36 +01:00
|
|
|
options.keyid = config.get_value("KEYID")
|
2012-02-11 11:59:46 -08:00
|
|
|
|
2011-08-24 14:46:11 +02:00
|
|
|
if options.lpinstance is None:
|
2023-01-30 19:45:36 +01:00
|
|
|
options.lpinstance = config.get_value("LPINSTANCE")
|
2012-04-12 18:31:36 +02:00
|
|
|
|
2011-08-24 14:46:11 +02:00
|
|
|
try:
|
2011-11-13 22:50:34 +02:00
|
|
|
# devel for copyPackage and changelogUrl
|
2023-01-30 19:45:36 +01:00
|
|
|
kwargs = {"service": options.lpinstance, "api_version": "devel"}
|
2021-06-02 14:55:17 -04:00
|
|
|
if options.lp and not options.simulate:
|
2012-04-12 18:31:36 +02:00
|
|
|
Launchpad.login(**kwargs)
|
|
|
|
else:
|
|
|
|
Launchpad.login_anonymously(**kwargs)
|
2011-08-24 14:46:11 +02:00
|
|
|
except IOError:
|
|
|
|
sys.exit(1)
|
2011-08-16 15:32:48 +01:00
|
|
|
|
2011-08-24 14:46:11 +02:00
|
|
|
if options.release is None:
|
|
|
|
ubuntu = Launchpad.distributions["ubuntu"]
|
2012-10-25 16:58:10 +01:00
|
|
|
options.release = "%s-proposed" % ubuntu.current_series.name
|
2011-08-16 15:32:48 +01:00
|
|
|
|
2011-12-07 01:23:06 +02:00
|
|
|
if not options.fakesync and not options.lp:
|
2023-01-30 19:45:36 +01:00
|
|
|
Logger.warning(
|
|
|
|
"The use of --no-lp is not recommended for uploads "
|
|
|
|
"targeted at Ubuntu. "
|
|
|
|
"The archive-admins discourage its use, except for "
|
|
|
|
"fakesyncs."
|
|
|
|
)
|
2011-12-07 01:23:06 +02:00
|
|
|
|
2011-12-07 00:23:22 +02:00
|
|
|
sponsoree = None
|
|
|
|
if options.sponsoree:
|
|
|
|
try:
|
|
|
|
sponsoree = PersonTeam(options.sponsoree)
|
|
|
|
except KeyError:
|
2023-01-30 19:45:36 +01:00
|
|
|
Logger.error('Cannot find the username "%s" in Launchpad.', options.sponsoree)
|
2011-12-07 00:23:22 +02:00
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
if sponsoree and options.uploader_name is None:
|
|
|
|
options.uploader_name = sponsoree.display_name
|
|
|
|
elif options.uploader_name is None:
|
|
|
|
options.uploader_name = ubu_email(export=False)[0]
|
|
|
|
|
|
|
|
if sponsoree and options.uploader_email is None:
|
|
|
|
try:
|
|
|
|
options.uploader_email = sponsoree.preferred_email_address.email
|
|
|
|
except ValueError:
|
2011-12-07 01:18:24 +02:00
|
|
|
if not options.lp:
|
2023-01-30 19:45:36 +01:00
|
|
|
Logger.error(
|
|
|
|
"%s doesn't have a publicly visible e-mail "
|
|
|
|
"address in LP, please provide one "
|
|
|
|
"--uploader-email option",
|
|
|
|
sponsoree.display_name,
|
|
|
|
)
|
2011-12-07 01:18:24 +02:00
|
|
|
sys.exit(1)
|
2011-12-07 00:23:22 +02:00
|
|
|
elif options.uploader_email is None:
|
|
|
|
options.uploader_email = ubu_email(export=False)[1]
|
|
|
|
|
2023-01-30 19:45:36 +01:00
|
|
|
src_pkg = fetch_source_pkg(
|
|
|
|
package,
|
|
|
|
options.distribution,
|
|
|
|
options.debian_version,
|
|
|
|
options.component,
|
|
|
|
options.release,
|
|
|
|
options.debian_mirror,
|
|
|
|
)
|
2011-08-16 15:32:48 +01:00
|
|
|
|
2011-09-05 15:40:24 +02:00
|
|
|
blacklisted, comments = is_blacklisted(src_pkg.source)
|
2011-10-26 21:08:17 +02:00
|
|
|
blacklist_fail = False
|
2011-08-24 14:46:11 +02:00
|
|
|
if blacklisted:
|
2011-09-06 14:07:40 +02:00
|
|
|
messages = []
|
2011-09-05 15:40:24 +02:00
|
|
|
|
2023-01-30 19:45:36 +01:00
|
|
|
if blacklisted == "CURRENT":
|
|
|
|
Logger.debug(
|
|
|
|
"Source package %s is temporarily blacklisted "
|
|
|
|
"(blacklisted_current). "
|
|
|
|
"Ubuntu ignores these for now. "
|
|
|
|
"See also LP: #841372",
|
|
|
|
src_pkg.source,
|
|
|
|
)
|
2011-08-25 14:30:30 +02:00
|
|
|
else:
|
2011-10-26 22:21:23 +02:00
|
|
|
if options.fakesync:
|
|
|
|
messages += ["Doing a fakesync, overriding blacklist."]
|
2011-09-05 15:40:24 +02:00
|
|
|
else:
|
2011-10-26 21:08:17 +02:00
|
|
|
blacklist_fail = True
|
2023-01-30 19:45:36 +01:00
|
|
|
messages += [
|
|
|
|
"If this package needs a fakesync, use --fakesync",
|
|
|
|
"If you think this package shouldn't be "
|
|
|
|
"blacklisted, please file a bug explaining your "
|
|
|
|
"reasoning and subscribe ~ubuntu-archive.",
|
|
|
|
]
|
2011-09-06 13:24:57 +02:00
|
|
|
|
2011-10-26 21:08:17 +02:00
|
|
|
if blacklist_fail:
|
2019-09-04 17:15:50 -03:00
|
|
|
Logger.error("Source package %s is blacklisted.", src_pkg.source)
|
2023-01-30 19:45:36 +01:00
|
|
|
elif blacklisted == "ALWAYS":
|
|
|
|
Logger.info("Source package %s is blacklisted.", src_pkg.source)
|
2011-09-06 14:07:40 +02:00
|
|
|
if messages:
|
|
|
|
for message in messages:
|
|
|
|
for line in textwrap.wrap(message):
|
2018-10-12 18:54:07 -04:00
|
|
|
Logger.info(line)
|
2011-10-26 21:08:17 +02:00
|
|
|
|
|
|
|
if comments:
|
2018-10-12 18:54:07 -04:00
|
|
|
Logger.info("Blacklist Comments:")
|
2011-10-26 21:08:17 +02:00
|
|
|
for comment in comments:
|
|
|
|
for line in textwrap.wrap(comment):
|
2018-10-12 18:54:07 -04:00
|
|
|
Logger.info(" " + line)
|
2011-10-26 21:08:17 +02:00
|
|
|
|
|
|
|
if blacklist_fail:
|
|
|
|
sys.exit(1)
|
2011-08-16 15:32:48 +01:00
|
|
|
|
2011-08-24 14:46:11 +02:00
|
|
|
if options.lp:
|
2023-01-30 19:45:36 +01:00
|
|
|
copy(src_pkg, options.release, options.bugs, sponsoree, options.simulate, options.force)
|
2011-08-16 15:32:48 +01:00
|
|
|
else:
|
2023-01-30 19:45:36 +01:00
|
|
|
os.environ["DEB_VENDOR"] = "Ubuntu"
|
|
|
|
sync_dsc(
|
|
|
|
src_pkg,
|
|
|
|
options.distribution,
|
|
|
|
options.release,
|
|
|
|
options.uploader_name,
|
|
|
|
options.uploader_email,
|
|
|
|
options.bugs,
|
|
|
|
options.ubuntu_mirror,
|
|
|
|
options.keyid,
|
|
|
|
options.simulate,
|
|
|
|
options.force,
|
|
|
|
options.fakesync,
|
|
|
|
)
|
2011-12-07 00:14:00 +02:00
|
|
|
|
2010-12-27 15:20:49 +01:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2011-10-22 23:10:27 +02:00
|
|
|
try:
|
|
|
|
main()
|
|
|
|
except KeyboardInterrupt:
|
2023-01-30 19:45:36 +01:00
|
|
|
Logger.info("User abort.")
|