misc: apply double-quote-string-fixer (#79788)

This commit is contained in:
Valentin Deniaud 2023-08-16 11:52:32 +02:00
parent ec5581eb62
commit 04e1269061
5 changed files with 178 additions and 178 deletions

View File

@ -49,21 +49,21 @@ def smart_cleaning(files_path):
def clean(method): def clean(method):
print("+ Cleanning %s" % method) print('+ Cleanning %s' % method)
if method == "all": if method == 'all':
shutil.rmtree(settings.ORIGIN_PATH) shutil.rmtree(settings.ORIGIN_PATH)
shutil.rmtree(settings.PBUILDER_RESULT) shutil.rmtree(settings.PBUILDER_RESULT)
shutil.rmtree(settings.GIT_PATH) shutil.rmtree(settings.GIT_PATH)
shutil.rmtree(settings.LOCK_PATH) shutil.rmtree(settings.LOCK_PATH)
elif method == "git": elif method == 'git':
shutil.rmtree(settings.GIT_PATH) shutil.rmtree(settings.GIT_PATH)
elif method == "deb": elif method == 'deb':
shutil.rmtree(settings.PBUILDER_RESULT) shutil.rmtree(settings.PBUILDER_RESULT)
elif method == "archives": elif method == 'archives':
shutil.rmtree(settings.ORIGIN_PATH) shutil.rmtree(settings.ORIGIN_PATH)
elif method == "locks": elif method == 'locks':
shutil.rmtree(settings.LOCK_PATH) shutil.rmtree(settings.LOCK_PATH)
elif method == "smart": elif method == 'smart':
results_files = [] results_files = []
origin_files = [os.path.join(settings.ORIGIN_PATH, f) for f in os.listdir(settings.ORIGIN_PATH)] origin_files = [os.path.join(settings.ORIGIN_PATH, f) for f in os.listdir(settings.ORIGIN_PATH)]
for root, dirs, files in os.walk(settings.PBUILDER_RESULT): for root, dirs, files in os.walk(settings.PBUILDER_RESULT):
@ -76,7 +76,7 @@ def clean(method):
for fname in files: for fname in files:
fname = os.path.join(root, fname) fname = os.path.join(root, fname)
ext = os.path.splitext(fname) ext = os.path.splitext(fname)
if ext == "build" and os.stat(fname).st_mtime < now - 365 * 86400: if ext == 'build' and os.stat(fname).st_mtime < now - 365 * 86400:
os.remove(fname) os.remove(fname)
else: else:
error("Cleanning: unknow '%s' option" % method) error("Cleanning: unknow '%s' option" % method)
@ -95,37 +95,37 @@ def get_project_infos(git_project_path, cmd_options):
'commit_number': '', 'commit_number': '',
'git_path': git_project_path, 'git_path': git_project_path,
} }
if os.path.exists("setup.py"): if os.path.exists('setup.py'):
# Hack to support setup_requires # Hack to support setup_requires
setup_py("--help") setup_py('--help')
results['name'] = setup_py("--name 2> /dev/null")[:-1] results['name'] = setup_py('--name 2> /dev/null')[:-1]
results['version'] = setup_py("--version 2> /dev/null")[:-1] results['version'] = setup_py('--version 2> /dev/null')[:-1]
results['fullname'] = setup_py("--fullname 2> /dev/null")[:-1] results['fullname'] = setup_py('--fullname 2> /dev/null')[:-1]
elif os.path.exists("configure.ac"): elif os.path.exists('configure.ac'):
call("./autogen.sh") call('./autogen.sh')
call('make all') call('make all')
results['name'] = output("./configure --version | head -n1 | sed 's/ configure.*//'")[:-1] results['name'] = output("./configure --version | head -n1 | sed 's/ configure.*//'")[:-1]
results['ac_version'] = output("./configure --version | head -n1 | sed 's/.* configure //'")[:-1] results['ac_version'] = output("./configure --version | head -n1 | sed 's/.* configure //'")[:-1]
results['version'] = results['ac_version'].replace('-', '.') results['version'] = results['ac_version'].replace('-', '.')
results['fullname'] = results['name'] results['fullname'] = results['name']
elif os.path.exists("Makefile"): elif os.path.exists('Makefile'):
results['name'] = output("make name")[:-1] results['name'] = output('make name')[:-1]
results['version'] = output("make version")[:-1] results['version'] = output('make version')[:-1]
results['fullname'] = output("make fullname")[:-1] results['fullname'] = output('make fullname')[:-1]
else: else:
error("Unsupported project type", exit_code=2) error('Unsupported project type', exit_code=2)
results['build_dir'] = os.path.join( results['build_dir'] = os.path.join(
settings.EOBUILDER_TMP, '%s-%d' % (results['name'], random.randint(0, 1000000)) settings.EOBUILDER_TMP, '%s-%d' % (results['name'], random.randint(0, 1000000))
) )
atexit.register(rm_recursive, results['build_dir']) atexit.register(rm_recursive, results['build_dir'])
results['commit_number'] = output("git rev-parse HEAD")[:-1] results['commit_number'] = output('git rev-parse HEAD')[:-1]
results['lock_path'] = os.path.join(settings.LOCK_PATH, results['name']) results['lock_path'] = os.path.join(settings.LOCK_PATH, results['name'])
current_tag = output("git describe --abbrev=0 --tags --match=v*", exit_on_error=False) current_tag = output('git describe --abbrev=0 --tags --match=v*', exit_on_error=False)
if current_tag: if current_tag:
results['current_tag'] = current_tag[1:-1] results['current_tag'] = current_tag[1:-1]
else: else:
results['current_tag'] = "0.0" results['current_tag'] = '0.0'
return results return results
@ -145,67 +145,67 @@ def prepare_build(dist, project, cmd_options, new):
os.chdir(project['git_path']) os.chdir(project['git_path'])
build_branch = cmd_options.branch build_branch = cmd_options.branch
if cmd_options.hotfix and not build_branch.startswith('hotfix/'): if cmd_options.hotfix and not build_branch.startswith('hotfix/'):
return error("Invalid name for hotfix branch (must start with hotfix/)", exit_code=2) return error('Invalid name for hotfix branch (must start with hotfix/)', exit_code=2)
debian_folder = cmd_options.debian_folder debian_folder = cmd_options.debian_folder
if os.path.isdir('debian-' + dist) and debian_folder == 'debian': if os.path.isdir('debian-' + dist) and debian_folder == 'debian':
debian_folder = 'debian-' + dist debian_folder = 'debian-' + dist
debian_branch = None debian_branch = None
if not os.path.isdir(debian_folder): if not os.path.isdir(debian_folder):
debian_branch = "debian" debian_branch = 'debian'
debian_folder = "debian" debian_folder = 'debian'
branches = output("git branch -r -l") branches = output('git branch -r -l')
if debian_branch == "debian" and "debian-%s" % dist in branches: if debian_branch == 'debian' and 'debian-%s' % dist in branches:
debian_branch = "debian-" + dist debian_branch = 'debian-' + dist
if not 'origin/%s' % debian_branch in output("git branch -r -l"): if not 'origin/%s' % debian_branch in output('git branch -r -l'):
print('!!! WARNING: cannot build for dist %s, no debian directory found' % dist) print('!!! WARNING: cannot build for dist %s, no debian directory found' % dist)
return return
print("!!! WARNING obsolete: using a branch for debian/ packaging") print('!!! WARNING obsolete: using a branch for debian/ packaging')
print("+ Updating Debian branch for %s" % dist) print('+ Updating Debian branch for %s' % dist)
call("git checkout --quiet %s" % debian_branch) call('git checkout --quiet %s' % debian_branch)
call("git pull") call('git pull')
else: else:
print("+ Building from %s debian folder" % debian_folder) print('+ Building from %s debian folder' % debian_folder)
for r in cmd_options.repositories: for r in cmd_options.repositories:
repo = r.split(':') repo = r.split(':')
if repo[0] == dist: if repo[0] == dist:
package["repository"] = repo[1] package['repository'] = repo[1]
# get package source name # get package source name
control_file = os.path.join(debian_folder, 'control') control_file = os.path.join(debian_folder, 'control')
package['names'] = re.findall(r"Package\s*:\s*(.*?)\n", cat(control_file)) package['names'] = re.findall(r'Package\s*:\s*(.*?)\n', cat(control_file))
package['source_name'] = re.search(r"^Source\s*:\s*(.*?)\n", cat(control_file), re.MULTILINE).group(1) package['source_name'] = re.search(r'^Source\s*:\s*(.*?)\n', cat(control_file), re.MULTILINE).group(1)
# build tarball # build tarball
origin_archive = os.path.join( origin_archive = os.path.join(
settings.ORIGIN_PATH, "%s_%s.orig.tar.bz2" % (package['source_name'], project['version']) settings.ORIGIN_PATH, '%s_%s.orig.tar.bz2' % (package['source_name'], project['version'])
) )
if not os.path.exists(origin_archive): if not os.path.exists(origin_archive):
print("+ Generating origin tarball ...") print('+ Generating origin tarball ...')
os.chdir(project['git_path']) os.chdir(project['git_path'])
call("git checkout --quiet %s" % build_branch) call('git checkout --quiet %s' % build_branch)
if os.path.exists('setup.py'): if os.path.exists('setup.py'):
setup_py("clean --all") setup_py('clean --all')
setup_py("sdist --formats=bztar") setup_py('sdist --formats=bztar')
shutil.move("dist/%s.tar.bz2" % project['fullname'], origin_archive) shutil.move('dist/%s.tar.bz2' % project['fullname'], origin_archive)
elif os.path.exists('./configure.ac'): elif os.path.exists('./configure.ac'):
call("make dist-bzip2") call('make dist-bzip2')
shutil.move("%s-%s.tar.bz2" % (project['name'], project['ac_version']), origin_archive) shutil.move('%s-%s.tar.bz2' % (project['name'], project['ac_version']), origin_archive)
elif os.path.exists('Makefile'): elif os.path.exists('Makefile'):
call("make dist-bzip2") call('make dist-bzip2')
shutil.move("sdist/%s.tar.bz2" % project['fullname'], origin_archive) shutil.move('sdist/%s.tar.bz2' % project['fullname'], origin_archive)
else: else:
error('Unsupported project type', project['build_dir'], exit_code=2) error('Unsupported project type', project['build_dir'], exit_code=2)
last_version_file = os.path.join( last_version_file = os.path.join(
project['lock_path'], project['lock_path'],
"%s_%s_%s.last_version" % (project['name'], package['repository'], build_branch.replace('/', '_')), '%s_%s_%s.last_version' % (project['name'], package['repository'], build_branch.replace('/', '_')),
) )
debian_changelog = os.path.join(debian_folder, 'changelog') debian_changelog = os.path.join(debian_folder, 'changelog')
if os.path.exists(last_version_file): if os.path.exists(last_version_file):
last_debian_package_version = cat(last_version_file) last_debian_package_version = cat(last_version_file)
else: else:
last_debian_package_version = re.search( last_debian_package_version = re.search(
r"^Version:\s(.*?)$", output("dpkg-parsechangelog -l%s" % debian_changelog), re.MULTILINE r'^Version:\s(.*?)$', output('dpkg-parsechangelog -l%s' % debian_changelog), re.MULTILINE
).group(1) ).group(1)
last_version = last_debian_package_version.split('-')[0] last_version = last_debian_package_version.split('-')[0]
package['version'] = last_debian_package_version package['version'] = last_debian_package_version
@ -215,12 +215,12 @@ def prepare_build(dist, project, cmd_options, new):
else: else:
debian_revision_number = '-1' debian_revision_number = '-1'
if last_version == project['version'] and new and "~eob" in last_debian_package_version: if last_version == project['version'] and new and '~eob' in last_debian_package_version:
new_inc = int(last_debian_package_version.rsplit('+', 1)[-1]) + 1 new_inc = int(last_debian_package_version.rsplit('+', 1)[-1]) + 1
version_suffix = "%s~eob%s+%s" % (debian_revision_number, settings.DEBIAN_VERSIONS[dist], new_inc) version_suffix = '%s~eob%s+%s' % (debian_revision_number, settings.DEBIAN_VERSIONS[dist], new_inc)
else: else:
version_suffix = "%s~eob%s+1" % (debian_revision_number, settings.DEBIAN_VERSIONS[dist]) version_suffix = '%s~eob%s+1' % (debian_revision_number, settings.DEBIAN_VERSIONS[dist])
call("git checkout --quiet %s" % build_branch) call('git checkout --quiet %s' % build_branch)
changelog = '\n'.join( changelog = '\n'.join(
changelog_from_git( changelog_from_git(
package['source_name'], package['source_name'],
@ -232,13 +232,13 @@ def prepare_build(dist, project, cmd_options, new):
) )
if changelog: if changelog:
if not os.path.isdir(debian_folder): if not os.path.isdir(debian_folder):
call("git checkout --quiet %s" % debian_branch) call('git checkout --quiet %s' % debian_branch)
debian_generated_changelog_filename = debian_changelog + '.generated' debian_generated_changelog_filename = debian_changelog + '.generated'
with open(debian_generated_changelog_filename, 'w+') as f: with open(debian_generated_changelog_filename, 'w+') as f:
f.write(changelog) f.write(changelog)
package['version'] = re.search( package['version'] = re.search(
r"^Version:\s(.*?)$", r'^Version:\s(.*?)$',
output("dpkg-parsechangelog -l%s" % debian_generated_changelog_filename), output('dpkg-parsechangelog -l%s' % debian_generated_changelog_filename),
re.MULTILINE, re.MULTILINE,
).group(1) ).group(1)
os.unlink(debian_generated_changelog_filename) os.unlink(debian_generated_changelog_filename)
@ -265,7 +265,7 @@ def prepare_build(dist, project, cmd_options, new):
'%s:%s' % (cmd_options.epoch, package['version']) '%s:%s' % (cmd_options.epoch, package['version'])
if cmd_options.epoch if cmd_options.epoch
else package['version'], else package['version'],
package["repository"], package['repository'],
debian_changelog, debian_changelog,
) )
) )
@ -274,30 +274,30 @@ def prepare_build(dist, project, cmd_options, new):
if cmd_options.hotfix: if cmd_options.hotfix:
version_part = build_branch.split('/', 1)[1].lstrip('v') version_part = build_branch.split('/', 1)[1].lstrip('v')
if not project['version'].startswith(version_part): if not project['version'].startswith(version_part):
return error("Invalid name for hotfix branch (must start with version number)", exit_code=2) return error('Invalid name for hotfix branch (must start with version number)', exit_code=2)
build_file = os.path.join( build_file = os.path.join(
project['lock_path'], project['lock_path'],
"%s_%s_%s_%s.build" '%s_%s_%s_%s.build'
% (project['name'], package['version'], package['repository'], build_branch.replace('/', '_')), % (project['name'], package['version'], package['repository'], build_branch.replace('/', '_')),
) )
if os.path.exists(build_file): if os.path.exists(build_file):
print("+ Already built for %s !" % dist) print('+ Already built for %s !' % dist)
return package return package
print("+ Preparing Debian build (%s %s) ..." % (package['source_name'], package['version'])) print('+ Preparing Debian build (%s %s) ...' % (package['source_name'], package['version']))
if debian_branch: if debian_branch:
call("git checkout --quiet %s" % debian_branch) call('git checkout --quiet %s' % debian_branch)
os.chdir(project['build_dir']) os.chdir(project['build_dir'])
project_build_path = os.path.join(project['build_dir'], "%s-%s" % (project['name'], project['version'])) project_build_path = os.path.join(project['build_dir'], '%s-%s' % (project['name'], project['version']))
shutil.copy(origin_archive, project['build_dir']) shutil.copy(origin_archive, project['build_dir'])
tar = tarfile.open('%s_%s.orig.tar.bz2' % (package['source_name'], project['version']), 'r:bz2') tar = tarfile.open('%s_%s.orig.tar.bz2' % (package['source_name'], project['version']), 'r:bz2')
tar.extractall() tar.extractall()
tar.close() tar.close()
if os.path.exists("%s/debian" % project_build_path): if os.path.exists('%s/debian' % project_build_path):
shutil.rmtree("%s/debian" % project_build_path) shutil.rmtree('%s/debian' % project_build_path)
shutil.copytree(os.path.join(project['git_path'], debian_folder), "%s/debian" % project_build_path) shutil.copytree(os.path.join(project['git_path'], debian_folder), '%s/debian' % project_build_path)
with open(os.path.join(project_build_path, 'debian', 'changelog'), 'w') as f: with open(os.path.join(project_build_path, 'debian', 'changelog'), 'w') as f:
f.write(good_changelog_contents) f.write(good_changelog_contents)
return package return package
@ -305,13 +305,13 @@ def prepare_build(dist, project, cmd_options, new):
def build_project(dist, arch, project, package, new): def build_project(dist, arch, project, package, new):
pbuilder_project_result = os.path.join(settings.PBUILDER_RESULT, '%s-%s' % (dist, arch)) pbuilder_project_result = os.path.join(settings.PBUILDER_RESULT, '%s-%s' % (dist, arch))
project_build_path = os.path.join(project['build_dir'], "%s-%s" % (project['name'], project['version'])) project_build_path = os.path.join(project['build_dir'], '%s-%s' % (project['name'], project['version']))
if not os.path.exists(pbuilder_project_result): if not os.path.exists(pbuilder_project_result):
os.makedirs(pbuilder_project_result, 0o755) os.makedirs(pbuilder_project_result, 0o755)
os.chdir(project['lock_path']) os.chdir(project['lock_path'])
source_build = os.path.join( source_build = os.path.join(
project['lock_path'], project['lock_path'],
"%s_%s_%s_%s_source.build" '%s_%s_%s_%s_source.build'
% ( % (
project['name'], project['name'],
project['version'], project['version'],
@ -321,7 +321,7 @@ def build_project(dist, arch, project, package, new):
) )
bin_build = os.path.join( bin_build = os.path.join(
project['lock_path'], project['lock_path'],
"%s_%s_%s_%s_%s.build" '%s_%s_%s_%s_%s.build'
% ( % (
project['name'], project['name'],
package['version'], package['version'],
@ -336,16 +336,16 @@ def build_project(dist, arch, project, package, new):
else: else:
source_opt = '-sa' source_opt = '-sa'
if new == 0 and os.path.exists(bin_build): if new == 0 and os.path.exists(bin_build):
print("+ Already build !") print('+ Already build !')
return return
os.chdir(project_build_path) os.chdir(project_build_path)
print("+ Building %s %s %s %s" % (project['name'], project['version'], dist, arch)) print('+ Building %s %s %s %s' % (project['name'], project['version'], dist, arch))
call( call(
'DIST=%s ARCH=%s pdebuild --use-pdebuild-internal --architecture %s --debbuildopts "%s"' 'DIST=%s ARCH=%s pdebuild --use-pdebuild-internal --architecture %s --debbuildopts "%s"'
% (dist, arch, arch, source_opt) % (dist, arch, arch, source_opt)
) )
print("+ Lock build") print('+ Lock build')
touch(bin_build) touch(bin_build)
if not os.path.exists(source_build): if not os.path.exists(source_build):
touch(source_build) touch(source_build)
@ -369,20 +369,20 @@ def send_packages(dist, arch, project, package, last_tag, dput=True):
pbuilder_project_result = os.path.join(settings.PBUILDER_RESULT, '%s-%s' % (dist, arch)) pbuilder_project_result = os.path.join(settings.PBUILDER_RESULT, '%s-%s' % (dist, arch))
print("+ Updating local repository...") print('+ Updating local repository...')
subprocess.check_call( subprocess.check_call(
'apt-ftparchive packages . | gzip > Packages.gz', cwd=pbuilder_project_result, shell=True 'apt-ftparchive packages . | gzip > Packages.gz', cwd=pbuilder_project_result, shell=True
) )
if dput: if dput:
print("+ Sending package...") print('+ Sending package...')
os.chdir(pbuilder_project_result) os.chdir(pbuilder_project_result)
call( call(
"dput -u %s %s_%s_%s.changes" 'dput -u %s %s_%s_%s.changes'
% (package['repository'], package['source_name'], package['version'].split(':', 1)[-1], arch) % (package['repository'], package['source_name'], package['version'].split(':', 1)[-1], arch)
) )
else: else:
print("+ Package not sent to repository (--no-dput used).") print('+ Package not sent to repository (--no-dput used).')
return return
open(stamp_file, 'w').close() open(stamp_file, 'w').close()
@ -392,8 +392,8 @@ def clean_git_on_exit(git_project_path):
if not os.path.exists(git_project_path): if not os.path.exists(git_project_path):
return return
os.chdir(git_project_path) os.chdir(git_project_path)
call("git stash --quiet") call('git stash --quiet')
changelog_tmp = os.path.join(git_project_path, "debian", "changelog.git") changelog_tmp = os.path.join(git_project_path, 'debian', 'changelog.git')
if os.path.exists(changelog_tmp): if os.path.exists(changelog_tmp):
os.remove(changelog_tmp) os.remove(changelog_tmp)
@ -446,14 +446,14 @@ def setup_git_tree(project_reference, options):
existing_tree = False existing_tree = False
os.chdir(settings.GIT_PATH) os.chdir(settings.GIT_PATH)
if project_reference.startswith('/'): if project_reference.startswith('/'):
call("git clone %s" % project_reference) call('git clone %s' % project_reference)
else: else:
parsed = urllib.parse.urlparse(project_reference) parsed = urllib.parse.urlparse(project_reference)
if not parsed.netloc: if not parsed.netloc:
project_url = urllib.parse.urljoin(settings.GIT_REPOSITORY_URL, project_reference) + '.git' project_url = urllib.parse.urljoin(settings.GIT_REPOSITORY_URL, project_reference) + '.git'
else: else:
project_url = project_reference project_url = project_reference
call("git clone %s" % project_url) call('git clone %s' % project_url)
if options.branch: if options.branch:
subprocess.check_call(['git', 'checkout', '--quiet', options.branch], cwd=git_project_path) subprocess.check_call(['git', 'checkout', '--quiet', options.branch], cwd=git_project_path)
branch_name = get_git_branch_name(project_reference) branch_name = get_git_branch_name(project_reference)
@ -493,13 +493,13 @@ def main():
existing_tree = os.path.exists(git_project_path) existing_tree = os.path.exists(git_project_path)
if existing_tree: if existing_tree:
os.chdir(git_project_path) os.chdir(git_project_path)
last_tag = output("git describe --abbrev=0 --tags --match=v*", exit_on_error=False) last_tag = output('git describe --abbrev=0 --tags --match=v*', exit_on_error=False)
if last_tag: if last_tag:
last_tag = last_tag[1:-1] last_tag = last_tag[1:-1]
else: else:
last_tag = "0.0" last_tag = '0.0'
else: else:
last_tag = "0.0" last_tag = '0.0'
setup_git_tree(project_reference, options) setup_git_tree(project_reference, options)
project = get_project_infos(git_project_path, options) project = get_project_infos(git_project_path, options)
@ -508,10 +508,10 @@ def main():
# compare revision between last build and now to determine if something is really new # compare revision between last build and now to determine if something is really new
new = 1 new = 1
current_revision = output("git rev-parse HEAD", True).strip() current_revision = output('git rev-parse HEAD', True).strip()
branch_name = get_git_branch_name(project_reference) branch_name = get_git_branch_name(project_reference)
last_branch_revision_file_path = os.path.join( last_branch_revision_file_path = os.path.join(
project['lock_path'], "%s_%s.last_revision" % (project['name'], branch_name.replace('/', '_')) project['lock_path'], '%s_%s.last_revision' % (project['name'], branch_name.replace('/', '_'))
) )
try: try:
with open(last_branch_revision_file_path) as f: with open(last_branch_revision_file_path) as f:
@ -523,22 +523,22 @@ def main():
new = 0 new = 0
if options.force and not new: if options.force and not new:
print("+ Warning force a new build") print('+ Warning force a new build')
new = 1 new = 1
for dist in options.distrib: for dist in options.distrib:
os.chdir(git_project_path) os.chdir(git_project_path)
call("git checkout --quiet %s" % branch_name) call('git checkout --quiet %s' % branch_name)
package = prepare_build(dist, project, options, new) package = prepare_build(dist, project, options, new)
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)
send_packages(dist, arch, project, package, last_tag, dput=options.dput) send_packages(dist, arch, project, package, last_tag, dput=options.dput)
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(
project['lock_path'], project['lock_path'],
"%s_%s_%s_%s.build" '%s_%s_%s_%s.build'
% ( % (
project['name'], project['name'],
package['version'], package['version'],
@ -550,7 +550,7 @@ def main():
last_version_file = os.path.join( last_version_file = os.path.join(
project['lock_path'], project['lock_path'],
"%s_%s_%s.last_version" '%s_%s_%s.last_version'
% (project['name'], package['repository'], branch_name.replace('/', '_')), % (project['name'], package['repository'], branch_name.replace('/', '_')),
) )
with open(last_version_file, 'w+') as f: with open(last_version_file, 'w+') as f:
@ -561,5 +561,5 @@ def main():
f.write(current_revision) f.write(current_revision)
if __name__ == "__main__": if __name__ == '__main__':
main() main()

View File

@ -4,7 +4,7 @@ VERSION = '7'
def init(): def init():
print("+ Init EO Builder") print('+ Init EO Builder')
if not os.path.exists(settings.GIT_PATH): if not os.path.exists(settings.GIT_PATH):
os.makedirs(settings.GIT_PATH, 0o755) os.makedirs(settings.GIT_PATH, 0o755)
if not os.path.exists(settings.ORIGIN_PATH): if not os.path.exists(settings.ORIGIN_PATH):

View File

@ -9,13 +9,13 @@ from optparse import Option
class MultipleOption(Option): class MultipleOption(Option):
ACTIONS = Option.ACTIONS + ("extend",) ACTIONS = Option.ACTIONS + ('extend',)
STORE_ACTIONS = Option.STORE_ACTIONS + ("extend",) STORE_ACTIONS = Option.STORE_ACTIONS + ('extend',)
TYPED_ACTIONS = Option.TYPED_ACTIONS + ("extend",) TYPED_ACTIONS = Option.TYPED_ACTIONS + ('extend',)
ALWAYS_TYPED_ACTIONS = Option.ALWAYS_TYPED_ACTIONS + ("extend",) ALWAYS_TYPED_ACTIONS = Option.ALWAYS_TYPED_ACTIONS + ('extend',)
def take_action(self, action, dest, opt, value, values, parser): def take_action(self, action, dest, opt, value, values, parser):
if action == "extend": if action == 'extend':
values_list = values.ensure_value(dest, []) values_list = values.ensure_value(dest, [])
for lvalue in value.split(','): for lvalue in value.split(','):
if not lvalue in values_list: if not lvalue in values_list:
@ -30,86 +30,86 @@ def parse_cmdline():
usage='usage: %prog [OPTIONS] -d [bullseye|,bookworm] GIT_REPOSITORY_NAME', usage='usage: %prog [OPTIONS] -d [bullseye|,bookworm] GIT_REPOSITORY_NAME',
) )
parser.add_option( parser.add_option(
"-a", '-a',
"--architectures", '--architectures',
action="extend", action='extend',
type="string", type='string',
dest="architectures", dest='architectures',
metavar='ARCHITECTURES', metavar='ARCHITECTURES',
default=[], default=[],
help="ARCHITECTURES: amd64", help='ARCHITECTURES: amd64',
) )
parser.add_option( parser.add_option(
"-d", '-d',
"--distribution", '--distribution',
action="extend", action='extend',
type="string", type='string',
dest="distrib", dest='distrib',
metavar='DISTRIBUTIONS', metavar='DISTRIBUTIONS',
default=[], default=[],
help="DISTRIBUTIONS: bullseye and/or bookworm", help='DISTRIBUTIONS: bullseye and/or bookworm',
) )
parser.add_option( parser.add_option(
"-f", "--force", action="store_true", dest="force", default=False, help="force a new build" '-f', '--force', action='store_true', dest='force', default=False, help='force a new build'
) )
parser.add_option( parser.add_option(
"-n", "--native", action="store_true", dest="native", default=False, help="build native package" '-n', '--native', action='store_true', dest='native', default=False, help='build native package'
) )
parser.add_option( parser.add_option(
"-b", '-b',
"--branch", '--branch',
action="store", action='store',
type="string", type='string',
dest="branch", dest='branch',
metavar='NAME', metavar='NAME',
help="branch to build (Default: main, or master)", help='branch to build (Default: main, or master)',
) )
parser.add_option( parser.add_option(
"--epoch", '--epoch',
action="store", action='store',
type="string", type='string',
dest="epoch", dest='epoch',
metavar='EPOCH', metavar='EPOCH',
default="", default='',
help="version number epoch (default: none)", help='version number epoch (default: none)',
) )
parser.add_option( parser.add_option(
"-D", '-D',
"--debian-folder", '--debian-folder',
action="store", action='store',
type="string", type='string',
dest="debian_folder", dest='debian_folder',
metavar='NAME', metavar='NAME',
default="debian", default='debian',
help="debian folder to use for build (Default: debian-DIST or debian)", help='debian folder to use for build (Default: debian-DIST or debian)',
) )
parser.add_option( parser.add_option(
"-c", '-c',
"--clean", '--clean',
action="extend", action='extend',
type="string", type='string',
dest="cleaning", dest='cleaning',
metavar='CLEANING_METHODS', metavar='CLEANING_METHODS',
default=[], default=[],
help="CLEANING_METHODS: git, deb, archives, smart and / or all", help='CLEANING_METHODS: git, deb, archives, smart and / or all',
) )
parser.add_option( parser.add_option(
"--hotfix", action="store_true", dest="hotfix", default=False, help="upload to hotfix repository" '--hotfix', action='store_true', dest='hotfix', default=False, help='upload to hotfix repository'
) )
parser.add_option( parser.add_option(
"-r", '-r',
"--repository", '--repository',
action="extend", action='extend',
type="string", type='string',
default=[], default=[],
dest="repositories", dest='repositories',
metavar='DISTRIBUTION:REPOSITORY, DISTRIBUTION:REPOSITORY', metavar='DISTRIBUTION:REPOSITORY, DISTRIBUTION:REPOSITORY',
help="DISTRIBUTION:REPOSITORY: bullseye:bullseye-eobuilder, bookworm:bookworm-eobuilder", help='DISTRIBUTION:REPOSITORY: bullseye:bullseye-eobuilder, bookworm:bookworm-eobuilder',
) )
parser.add_option( parser.add_option(
"--no-dput", '--no-dput',
dest='dput', dest='dput',
action="store_false", action='store_false',
default=True, default=True,
help='do not send package to repository with dput', help='do not send package to repository with dput',
) )
@ -117,7 +117,7 @@ def parse_cmdline():
(options, args) = parser.parse_args() (options, args) = parser.parse_args()
if len(args) != 1 and not options.cleaning: if len(args) != 1 and not options.cleaning:
parser.error("you should select one GIT_REPOSITORY_NAME") parser.error('you should select one GIT_REPOSITORY_NAME')
if len(args) and options.cleaning: if len(args) and options.cleaning:
parser.error("you shouldn't use argument when cleaning") parser.error("you shouldn't use argument when cleaning")
@ -127,11 +127,11 @@ def parse_cmdline():
if options.repositories: if options.repositories:
for r in options.repositories: for r in options.repositories:
if not ":" in r: if not ':' in r:
parser.error("you must enter DISTRIBUTION:REPOSITORY in repository option") parser.error('you must enter DISTRIBUTION:REPOSITORY in repository option')
if not options.architectures: if not options.architectures:
options.architectures = ["amd64"] options.architectures = ['amd64']
return options, args return options, args
@ -150,7 +150,7 @@ def touch(fname):
def error(msg, build_dir=None, exit_code=1): def error(msg, build_dir=None, exit_code=1):
if build_dir and os.path.exists(build_dir): if build_dir and os.path.exists(build_dir):
shutil.rmtree(build_dir) shutil.rmtree(build_dir)
sys.stderr.write("ERROR: %s\n" % msg) sys.stderr.write('ERROR: %s\n' % msg)
sys.exit(exit_code) sys.exit(exit_code)

View File

@ -2,41 +2,41 @@ import os
BASE_DIR = os.path.dirname(os.path.dirname(__file__)) BASE_DIR = os.path.dirname(os.path.dirname(__file__))
GIT_PATH = "/var/lib/eobuilder/git" GIT_PATH = '/var/lib/eobuilder/git'
ORIGIN_PATH = "/var/lib/eobuilder/origin" ORIGIN_PATH = '/var/lib/eobuilder/origin'
LOCK_PATH = "/var/lib/eobuilder/lock" LOCK_PATH = '/var/lib/eobuilder/lock'
PBUILDER_RESULT = "/var/lib/eobuilder/results" PBUILDER_RESULT = '/var/lib/eobuilder/results'
EOBUILDER_TMP = "/var/tmp/eobuilder" EOBUILDER_TMP = '/var/tmp/eobuilder'
GIT_REPOSITORY_URL = "git+ssh://git@repos.entrouvert.org" GIT_REPOSITORY_URL = 'git+ssh://git@repos.entrouvert.org'
DEBIAN_VERSIONS = { DEBIAN_VERSIONS = {
"bookworm": "120", 'bookworm': '120',
"bullseye": "110", 'bullseye': '110',
"buster": "100", 'buster': '100',
"stretch": "90", 'stretch': '90',
} }
DEFAULT_UNSTABLE_REPOSITORIES = { DEFAULT_UNSTABLE_REPOSITORIES = {
"bookworm": "bookworm-eobuilder", 'bookworm': 'bookworm-eobuilder',
"bullseye": "bullseye-eobuilder", 'bullseye': 'bullseye-eobuilder',
"buster": "buster-eobuilder", 'buster': 'buster-eobuilder',
"stretch": "stretch-eobuilder", 'stretch': 'stretch-eobuilder',
} }
# Paste new tag into repositories # Paste new tag into repositories
# Automatically add new tag in this repositories # Automatically add new tag in this repositories
DEFAULT_TESTING_REPOSITORIES = { DEFAULT_TESTING_REPOSITORIES = {
"bookworm": ["bookworm-testing"], 'bookworm': ['bookworm-testing'],
"bullseye": ["bullseye-testing"], 'bullseye': ['bullseye-testing'],
"buster": ["buster-testing"], 'buster': ['buster-testing'],
"stretch": ["stretch-testing"], 'stretch': ['stretch-testing'],
} }
# Hotfix repositories # Hotfix repositories
HOTFIX_REPOSITORIES = { HOTFIX_REPOSITORIES = {
"bookworm": "bookworm-hotfix", 'bookworm': 'bookworm-hotfix',
"bullseye": "bullseye-hotfix", 'bullseye': 'bullseye-hotfix',
"buster": "buster-hotfix", 'buster': 'buster-hotfix',
"stretch": "stretch-hotfix", 'stretch': 'stretch-hotfix',
} }
# Specify the testing repository by source package name # Specify the testing repository by source package name

View File

@ -48,14 +48,14 @@ def get_version():
setup( setup(
name="eobuilder", name='eobuilder',
version=get_version(), version=get_version(),
license="AGPLv3 or later", license='AGPLv3 or later',
description="Entr'ouvert Package Builder", description="Entr'ouvert Package Builder",
author="Entr'ouvert", author="Entr'ouvert",
author_email="info@entrouvert.org", author_email='info@entrouvert.org',
maintainer="Jerome Schneider", maintainer='Jerome Schneider',
maintainer_email="info@entrouvert.com", maintainer_email='info@entrouvert.com',
install_requires=['pytz', 'GitPython'], install_requires=['pytz', 'GitPython'],
include_package_data=True, include_package_data=True,
url='https://dev.entrouvert.org/projects/eobuilder', url='https://dev.entrouvert.org/projects/eobuilder',