generate Packages.gz event if --no-dput is given (#59604)

This commit is contained in:
Frédéric Péters 2021-12-12 16:02:36 +01:00
parent 26d0ce3d3a
commit d4debeef85
1 changed files with 32 additions and 31 deletions

View File

@ -353,7 +353,7 @@ def build_project(dist, arch, project, package, new):
touch(source_build) touch(source_build)
def send_packages(dist, arch, project, package, last_tag): def send_packages(dist, arch, project, package, last_tag, dput=True):
stamp_file = os.path.join( stamp_file = os.path.join(
project['lock_path'], project['lock_path'],
'%s_%s_%s_%s_%s.upload' '%s_%s_%s_%s_%s.upload'
@ -376,33 +376,37 @@ def send_packages(dist, arch, project, package, last_tag):
'apt-ftparchive packages . | gzip > Packages.gz', cwd=pbuilder_project_result, shell=True 'apt-ftparchive packages . | gzip > Packages.gz', cwd=pbuilder_project_result, shell=True
) )
print("+ Sending package...") if dput:
os.chdir(pbuilder_project_result) print("+ Sending package...")
call( os.chdir(pbuilder_project_result)
"dput -u %s %s_%s_%s.changes" call(
% (package['repository'], package['source_name'], package['version'].split(':', 1)[-1], arch) "dput -u %s %s_%s_%s.changes"
) % (package['repository'], package['source_name'], package['version'].split(':', 1)[-1], arch)
)
print("+ Updating repository ...") print("+ Updating repository ...")
call('ssh root@%s "/etc/cron.hourly/process-incoming"' % settings.REPOSITORY_URL) call('ssh root@%s "/etc/cron.hourly/process-incoming"' % settings.REPOSITORY_URL)
old_version = tuple(int(d) for d in last_tag.split('.')) old_version = tuple(int(d) for d in last_tag.split('.'))
new_version = tuple(int(d) for d in project['current_tag'].split('.')) new_version = tuple(int(d) for d in project['current_tag'].split('.'))
if new_version > old_version and project['current_tag'] == project['version']: if new_version > old_version and project['current_tag'] == project['version']:
print("New tag detected : %s" % project['current_tag']) print("New tag detected : %s" % project['current_tag'])
if package['source_name'] in settings.MANUAL_TESTING_REPOSITORIES: if package['source_name'] in settings.MANUAL_TESTING_REPOSITORIES:
package_repos = settings.MANUAL_TESTING_REPOSITORIES[package['source_name']] package_repos = settings.MANUAL_TESTING_REPOSITORIES[package['source_name']]
else: else:
package_repos = settings.DEFAULT_TESTING_REPOSITORIES package_repos = settings.DEFAULT_TESTING_REPOSITORIES
packages = package['names'] + [package['source_name']] packages = package['names'] + [package['source_name']]
packages = " ".join(packages) packages = " ".join(packages)
if dist in package_repos and package['copy_in_testing']: if dist in package_repos and package['copy_in_testing']:
for repo in package_repos[dist]: for repo in package_repos[dist]:
print("+ Copy %s packages to %s repository (%s)" % (package['source_name'], repo, dist)) print("+ Copy %s packages to %s repository (%s)" % (package['source_name'], repo, dist))
call( call(
'ssh root@%s "/usr/bin/reprepro -b /var/vhosts/deb.entrouvert.org copy %s %s %s"' 'ssh root@%s "/usr/bin/reprepro -b /var/vhosts/deb.entrouvert.org copy %s %s %s"'
% (settings.REPOSITORY_URL, repo, package['repository'], packages) % (settings.REPOSITORY_URL, repo, package['repository'], packages)
) )
call('ssh root@%s /usr/local/bin/update-deb-repo-html' % settings.REPOSITORY_URL) call('ssh root@%s /usr/local/bin/update-deb-repo-html' % settings.REPOSITORY_URL)
else:
print("+ Package not sent to repository (--no-dput used).")
return
open(stamp_file, 'w').close() open(stamp_file, 'w').close()
@ -552,10 +556,7 @@ def main():
if package: if package:
for arch in options.architectures: for arch in options.architectures:
build_project(dist, arch, project, package, new) build_project(dist, arch, project, package, new)
if options.dput: send_packages(dist, arch, project, package, last_tag, dput=options.dput)
send_packages(dist, arch, project, package, last_tag)
else:
print("+ Package not sent to repository (--no-dput used).")
print("+ Add a build file to lock new build for %s" % dist) print("+ Add a build file to lock new build for %s" % dist)
touch( touch(
os.path.join( os.path.join(