trivial: apply black
This commit is contained in:
parent
f3ad730d9e
commit
d37357188d
35
eobuildall
35
eobuildall
|
@ -9,17 +9,26 @@ import time
|
||||||
|
|
||||||
from eobuilder import settings, init as eobuilder_init
|
from eobuilder import settings, init as eobuilder_init
|
||||||
|
|
||||||
|
|
||||||
def init():
|
def init():
|
||||||
eobuilder_init()
|
eobuilder_init()
|
||||||
gitolite_admin_path = os.path.join(settings.GIT_PATH, 'gitolite-admin')
|
gitolite_admin_path = os.path.join(settings.GIT_PATH, 'gitolite-admin')
|
||||||
if not os.path.exists(gitolite_admin_path):
|
if not os.path.exists(gitolite_admin_path):
|
||||||
p = subprocess.Popen(['git', 'clone', 'git@repos.entrouvert.org:gitolite-admin.git'],
|
p = subprocess.Popen(
|
||||||
close_fds=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE,
|
['git', 'clone', 'git@repos.entrouvert.org:gitolite-admin.git'],
|
||||||
cwd=settings.GIT_PATH)
|
close_fds=True,
|
||||||
|
stdin=subprocess.PIPE,
|
||||||
|
stdout=subprocess.PIPE,
|
||||||
|
cwd=settings.GIT_PATH,
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
p = subprocess.Popen(['git', 'pull'],
|
p = subprocess.Popen(
|
||||||
close_fds=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE,
|
['git', 'pull'],
|
||||||
cwd=gitolite_admin_path)
|
close_fds=True,
|
||||||
|
stdin=subprocess.PIPE,
|
||||||
|
stdout=subprocess.PIPE,
|
||||||
|
cwd=gitolite_admin_path,
|
||||||
|
)
|
||||||
stdout, stderr = p.communicate()
|
stdout, stderr = p.communicate()
|
||||||
if p.returncode != 0:
|
if p.returncode != 0:
|
||||||
# abort if there's an error in this git call, we could try going on
|
# abort if there's an error in this git call, we could try going on
|
||||||
|
@ -36,18 +45,17 @@ def get_modules():
|
||||||
modules.append(line.split()[-1])
|
modules.append(line.split()[-1])
|
||||||
return modules
|
return modules
|
||||||
|
|
||||||
|
|
||||||
def build_module(config, module):
|
def build_module(config, module):
|
||||||
try:
|
try:
|
||||||
dists = config.get('dists', module)
|
dists = config.get('dists', module)
|
||||||
except (ConfigParser.NoSectionError, ConfigParser.NoOptionError):
|
except (ConfigParser.NoSectionError, ConfigParser.NoOptionError):
|
||||||
dists = 'jessie,stretch,buster'
|
dists = 'jessie,stretch,buster'
|
||||||
rc = os.system('/usr/local/bin/eobuilder -d %(dists)s %(module)s' % {
|
rc = os.system('/usr/local/bin/eobuilder -d %(dists)s %(module)s' % {'dists': dists, 'module': module})
|
||||||
'dists': dists,
|
|
||||||
'module': module})
|
|
||||||
if rc == 0:
|
if rc == 0:
|
||||||
return 'ok'
|
return 'ok'
|
||||||
elif rc % 256 != 0:
|
elif rc % 256 != 0:
|
||||||
return 'fail' # killed by a signal
|
return 'fail' # killed by a signal
|
||||||
else:
|
else:
|
||||||
exit_code = rc / 256
|
exit_code = rc / 256
|
||||||
if exit_code == 2:
|
if exit_code == 2:
|
||||||
|
@ -55,6 +63,7 @@ def build_module(config, module):
|
||||||
else:
|
else:
|
||||||
return 'fail'
|
return 'fail'
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
init()
|
init()
|
||||||
cfg_file = os.path.expanduser('~/.config/eobuilder')
|
cfg_file = os.path.expanduser('~/.config/eobuilder')
|
||||||
|
@ -77,13 +86,13 @@ if __name__ == '__main__':
|
||||||
if blacklisted:
|
if blacklisted:
|
||||||
continue
|
continue
|
||||||
t0 = time.time()
|
t0 = time.time()
|
||||||
print('='*60)
|
print('=' * 60)
|
||||||
print(module)
|
print(module)
|
||||||
print('='*60)
|
print('=' * 60)
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
results[module] = build_module(config, module)
|
results[module] = build_module(config, module)
|
||||||
print('\n')
|
print('\n')
|
||||||
print('(%1.2f seconds)' % (time.time()-t0))
|
print('(%1.2f seconds)' % (time.time() - t0))
|
||||||
print('\n')
|
print('\n')
|
||||||
|
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
|
|
330
eobuilder-ctl
330
eobuilder-ctl
|
@ -20,6 +20,7 @@ from eobuilder.cmdline import parse_cmdline, error, cat, touch, call, output, se
|
||||||
if 'git+ssh' not in urllib.parse.uses_relative:
|
if 'git+ssh' not in urllib.parse.uses_relative:
|
||||||
urllib.parse.uses_relative.append('git+ssh')
|
urllib.parse.uses_relative.append('git+ssh')
|
||||||
|
|
||||||
|
|
||||||
def rm_recursive(path):
|
def rm_recursive(path):
|
||||||
if os.path.exists(path):
|
if os.path.exists(path):
|
||||||
shutil.rmtree(path)
|
shutil.rmtree(path)
|
||||||
|
@ -37,12 +38,12 @@ def smart_cleaning(files_path):
|
||||||
for project in project_files.iterkeys():
|
for project in project_files.iterkeys():
|
||||||
nb_versions = len(project_files[project])
|
nb_versions = len(project_files[project])
|
||||||
if nb_versions > settings.MIN_PACKAGE_VERSIONS:
|
if nb_versions > settings.MIN_PACKAGE_VERSIONS:
|
||||||
project_files[project] = \
|
project_files[project] = sorted(project_files[project], key=lambda x: os.stat(x).st_mtime)
|
||||||
sorted(project_files[project],
|
|
||||||
key=lambda x: os.stat(x).st_mtime)
|
|
||||||
for filename in project_files[project]:
|
for filename in project_files[project]:
|
||||||
if nb_versions > settings.MIN_PACKAGE_VERSIONS and \
|
if (
|
||||||
os.stat(filename).st_mtime < now - settings.MIN_AGE * 86400:
|
nb_versions > settings.MIN_PACKAGE_VERSIONS
|
||||||
|
and os.stat(filename).st_mtime < now - settings.MIN_AGE * 86400
|
||||||
|
):
|
||||||
os.remove(filename)
|
os.remove(filename)
|
||||||
nb_versions -= 1
|
nb_versions -= 1
|
||||||
|
|
||||||
|
@ -64,8 +65,7 @@ def clean(method):
|
||||||
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) \
|
origin_files = [os.path.join(settings.ORIGIN_PATH, f) for f in os.listdir(settings.ORIGIN_PATH)]
|
||||||
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):
|
||||||
for fname in files:
|
for fname in files:
|
||||||
results_files.append(os.path.join(root, fname))
|
results_files.append(os.path.join(root, fname))
|
||||||
|
@ -76,26 +76,25 @@ 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 \
|
if ext == "build" and os.stat(fname).st_mtime < now - 365 * 86400:
|
||||||
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)
|
||||||
|
|
||||||
|
|
||||||
def get_project_infos(git_project_path, cmd_options):
|
def get_project_infos(git_project_path, cmd_options):
|
||||||
""" return a dict with project informations
|
"""return a dict with project informations"""
|
||||||
"""
|
|
||||||
os.chdir(git_project_path)
|
os.chdir(git_project_path)
|
||||||
results = {
|
results = {
|
||||||
'name': '',
|
'name': '',
|
||||||
'version': '',
|
'version': '',
|
||||||
'fullname': '',
|
'fullname': '',
|
||||||
'ac_version': '',
|
'ac_version': '',
|
||||||
'build_dir': '',
|
'build_dir': '',
|
||||||
'build_branch': cmd_options.branch,
|
'build_branch': cmd_options.branch,
|
||||||
'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")
|
||||||
|
@ -105,12 +104,8 @@ def get_project_infos(git_project_path, cmd_options):
|
||||||
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(
|
results['name'] = output("./configure --version | head -n1 | sed 's/ configure.*//'")[:-1]
|
||||||
"./configure --version | head -n1 | sed 's/ configure.*//'"
|
results['ac_version'] = output("./configure --version | head -n1 | sed 's/.* configure //'")[:-1]
|
||||||
)[:-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"):
|
||||||
|
@ -121,15 +116,12 @@ def get_project_infos(git_project_path, cmd_options):
|
||||||
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['lock_path'] = os.path.join(settings.LOCK_PATH, results['name'])
|
||||||
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:
|
||||||
|
@ -143,12 +135,12 @@ def prepare_build(dist, project, cmd_options, new):
|
||||||
Create origin archive, update git and Debian changelog
|
Create origin archive, update git and Debian changelog
|
||||||
"""
|
"""
|
||||||
package = {
|
package = {
|
||||||
'repository': settings.DEFAULT_UNSTABLE_REPOSITORIES[dist],
|
'repository': settings.DEFAULT_UNSTABLE_REPOSITORIES[dist],
|
||||||
'copy_in_testing': True,
|
'copy_in_testing': True,
|
||||||
'version': '',
|
'version': '',
|
||||||
'source_name': '',
|
'source_name': '',
|
||||||
'names': []
|
'names': [],
|
||||||
}
|
}
|
||||||
if cmd_options.hotfix:
|
if cmd_options.hotfix:
|
||||||
package['repository'] = settings.HOTFIX_REPOSITORIES[dist]
|
package['repository'] = settings.HOTFIX_REPOSITORIES[dist]
|
||||||
os.chdir(project['git_path'])
|
os.chdir(project['git_path'])
|
||||||
|
@ -183,14 +175,12 @@ def prepare_build(dist, project, cmd_options, new):
|
||||||
# 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",
|
package['source_name'] = re.search(r"^Source\s*:\s*(.*?)\n", cat(control_file), re.MULTILINE).group(1)
|
||||||
cat(control_file),
|
|
||||||
re.MULTILINE
|
|
||||||
).group(1)
|
|
||||||
|
|
||||||
# build tarball
|
# build tarball
|
||||||
origin_archive = os.path.join(settings.ORIGIN_PATH,
|
origin_archive = os.path.join(
|
||||||
"%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'])
|
||||||
|
@ -201,27 +191,24 @@ def prepare_build(dist, project, cmd_options, new):
|
||||||
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" % \
|
shutil.move("%s-%s.tar.bz2" % (project['name'], project['ac_version']), origin_archive)
|
||||||
(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(project['lock_path'],
|
last_version_file = os.path.join(
|
||||||
"%s_%s_%s.last_version" % (project['name'],
|
project['lock_path'],
|
||||||
package['repository'],
|
"%s_%s_%s.last_version" % (project['name'], package['repository'], build_branch.replace('/', '_')),
|
||||||
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(r"^Version:\s(.*?)$",
|
last_debian_package_version = re.search(
|
||||||
output("dpkg-parsechangelog -l%s" % debian_changelog),
|
r"^Version:\s(.*?)$", output("dpkg-parsechangelog -l%s" % debian_changelog), re.MULTILINE
|
||||||
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
|
||||||
|
|
||||||
|
@ -230,28 +217,32 @@ 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 \
|
if last_version == project['version'] and new and "~eob" in last_debian_package_version:
|
||||||
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,
|
version_suffix = "%s~eob%s+%s" % (debian_revision_number, settings.DEBIAN_VERSIONS[dist], new_inc)
|
||||||
settings.DEBIAN_VERSIONS[dist],
|
|
||||||
new_inc)
|
|
||||||
else:
|
else:
|
||||||
version_suffix = "%s~eob%s+1" % (debian_revision_number,
|
version_suffix = "%s~eob%s+1" % (debian_revision_number, settings.DEBIAN_VERSIONS[dist])
|
||||||
settings.DEBIAN_VERSIONS[dist])
|
|
||||||
call("git checkout --quiet %s" % build_branch)
|
call("git checkout --quiet %s" % build_branch)
|
||||||
changelog = '\n'.join(changelog_from_git(package['source_name'],
|
changelog = '\n'.join(
|
||||||
version_suffix, project['git_path'], package['repository'],
|
changelog_from_git(
|
||||||
epoch=cmd_options.epoch))
|
package['source_name'],
|
||||||
|
version_suffix,
|
||||||
|
project['git_path'],
|
||||||
|
package['repository'],
|
||||||
|
epoch=cmd_options.epoch,
|
||||||
|
)
|
||||||
|
)
|
||||||
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(r"^Version:\s(.*?)$",
|
package['version'] = re.search(
|
||||||
output("dpkg-parsechangelog -l%s" % debian_generated_changelog_filename),
|
r"^Version:\s(.*?)$",
|
||||||
re.MULTILINE).group(1)
|
output("dpkg-parsechangelog -l%s" % debian_generated_changelog_filename),
|
||||||
|
re.MULTILINE,
|
||||||
|
).group(1)
|
||||||
os.unlink(debian_generated_changelog_filename)
|
os.unlink(debian_generated_changelog_filename)
|
||||||
else:
|
else:
|
||||||
# changelog couldn't be generated, this happens with checkouts from
|
# changelog couldn't be generated, this happens with checkouts from
|
||||||
|
@ -269,11 +260,17 @@ def prepare_build(dist, project, cmd_options, new):
|
||||||
# wrong version number, in that case we add an arbitrary new entry
|
# wrong version number, in that case we add an arbitrary new entry
|
||||||
# to the existing changelog
|
# to the existing changelog
|
||||||
package['version'] = '%s%s' % (project['version'], version_suffix)
|
package['version'] = '%s%s' % (project['version'], version_suffix)
|
||||||
call('dch "Eobuilder version" -v %s --distribution %s \
|
call(
|
||||||
--force-bad-version --force-distribution --changelog %s' % \
|
'dch "Eobuilder version" -v %s --distribution %s \
|
||||||
('%s:%s' % (cmd_options.epoch, package['version']) if cmd_options.epoch else package['version'],
|
--force-bad-version --force-distribution --changelog %s'
|
||||||
package["repository"],
|
% (
|
||||||
debian_changelog))
|
'%s:%s' % (cmd_options.epoch, package['version'])
|
||||||
|
if cmd_options.epoch
|
||||||
|
else package['version'],
|
||||||
|
package["repository"],
|
||||||
|
debian_changelog,
|
||||||
|
)
|
||||||
|
)
|
||||||
good_changelog_contents = open(debian_changelog).read()
|
good_changelog_contents = open(debian_changelog).read()
|
||||||
|
|
||||||
if cmd_options.hotfix:
|
if cmd_options.hotfix:
|
||||||
|
@ -281,12 +278,11 @@ def prepare_build(dist, project, cmd_options, new):
|
||||||
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(project['lock_path'],
|
build_file = os.path.join(
|
||||||
"%s_%s_%s_%s.build" % (project['name'],
|
project['lock_path'],
|
||||||
package['version'],
|
"%s_%s_%s_%s.build"
|
||||||
package['repository'],
|
% (project['name'], package['version'], package['repository'], build_branch.replace('/', '_')),
|
||||||
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
|
||||||
|
@ -295,44 +291,47 @@ def prepare_build(dist, project, cmd_options, new):
|
||||||
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'],
|
project_build_path = os.path.join(project['build_dir'], "%s-%s" % (project['name'], project['version']))
|
||||||
"%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' % \
|
tar = tarfile.open('%s_%s.orig.tar.bz2' % (package['source_name'], project['version']), 'r: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),
|
shutil.copytree(os.path.join(project['git_path'], debian_folder), "%s/debian" % project_build_path)
|
||||||
"%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
|
||||||
|
|
||||||
|
|
||||||
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,
|
pbuilder_project_result = os.path.join(settings.PBUILDER_RESULT, '%s-%s' % (dist, arch))
|
||||||
'%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(project['lock_path'],
|
source_build = os.path.join(
|
||||||
"%s_%s_%s_%s_source.build" % (project['name'],
|
project['lock_path'],
|
||||||
project['version'],
|
"%s_%s_%s_%s_source.build"
|
||||||
package['repository'],
|
% (
|
||||||
project['build_branch'].replace('/', '_'))
|
project['name'],
|
||||||
)
|
project['version'],
|
||||||
bin_build = os.path.join(project['lock_path'],
|
package['repository'],
|
||||||
"%s_%s_%s_%s_%s.build" % (project['name'],
|
project['build_branch'].replace('/', '_'),
|
||||||
package['version'],
|
),
|
||||||
package['repository'],
|
)
|
||||||
project['build_branch'].replace('/', '_'),
|
bin_build = os.path.join(
|
||||||
arch)
|
project['lock_path'],
|
||||||
)
|
"%s_%s_%s_%s_%s.build"
|
||||||
|
% (
|
||||||
|
project['name'],
|
||||||
|
package['version'],
|
||||||
|
package['repository'],
|
||||||
|
project['build_branch'].replace('/', '_'),
|
||||||
|
arch,
|
||||||
|
),
|
||||||
|
)
|
||||||
print('SOURCE_BUILD:', source_build)
|
print('SOURCE_BUILD:', source_build)
|
||||||
if os.path.exists(source_build):
|
if os.path.exists(source_build):
|
||||||
source_opt = '-b'
|
source_opt = '-b'
|
||||||
|
@ -342,46 +341,53 @@ def build_project(dist, arch, project, package, new):
|
||||||
print("+ Already build !")
|
print("+ Already build !")
|
||||||
return
|
return
|
||||||
os.chdir(project_build_path)
|
os.chdir(project_build_path)
|
||||||
print("+ Building %s %s %s %s" % \
|
print("+ Building %s %s %s %s" % (project['name'], project['version'], dist, arch))
|
||||||
(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)
|
||||||
|
|
||||||
|
|
||||||
def send_packages(dist, arch, project, package, last_tag):
|
def send_packages(dist, arch, project, package, last_tag):
|
||||||
stamp_file = os.path.join(project['lock_path'], '%s_%s_%s_%s_%s.upload' % (
|
stamp_file = os.path.join(
|
||||||
project['name'], package['version'],
|
project['lock_path'],
|
||||||
package['repository'], arch, project['build_branch'].replace('/', '_')))
|
'%s_%s_%s_%s_%s.upload'
|
||||||
|
% (
|
||||||
|
project['name'],
|
||||||
|
package['version'],
|
||||||
|
package['repository'],
|
||||||
|
arch,
|
||||||
|
project['build_branch'].replace('/', '_'),
|
||||||
|
),
|
||||||
|
)
|
||||||
if os.path.exists(stamp_file):
|
if os.path.exists(stamp_file):
|
||||||
print('+ Already uploaded')
|
print('+ Already uploaded')
|
||||||
return
|
return
|
||||||
|
|
||||||
pbuilder_project_result = os.path.join(settings.PBUILDER_RESULT,
|
pbuilder_project_result = os.path.join(settings.PBUILDER_RESULT, '%s-%s' % (dist, arch))
|
||||||
'%s-%s' % (dist, arch))
|
|
||||||
|
|
||||||
print("+ Updating local repository...")
|
print("+ Updating local repository...")
|
||||||
subprocess.check_call('apt-ftparchive packages . | gzip > Packages.gz', cwd=pbuilder_project_result, shell=True)
|
subprocess.check_call(
|
||||||
|
'apt-ftparchive packages . | gzip > Packages.gz', cwd=pbuilder_project_result, shell=True
|
||||||
|
)
|
||||||
|
|
||||||
print("+ Sending package...")
|
print("+ Sending package...")
|
||||||
os.chdir(pbuilder_project_result)
|
os.chdir(pbuilder_project_result)
|
||||||
call("dput -u %s %s_%s_%s.changes" % \
|
call(
|
||||||
(package['repository'],
|
"dput -u %s %s_%s_%s.changes"
|
||||||
package['source_name'],
|
% (package['repository'], package['source_name'], package['version'].split(':', 1)[-1], arch)
|
||||||
package['version'].split(':', 1)[-1],
|
)
|
||||||
arch)
|
|
||||||
)
|
|
||||||
|
|
||||||
print("+ Updating repository ...")
|
print("+ Updating repository ...")
|
||||||
call('ssh root@%s "/etc/cron.hourly/process-incoming"' % \
|
call('ssh root@%s "/etc/cron.hourly/process-incoming"' % settings.REPOSITORY_URL)
|
||||||
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 \
|
if new_version > old_version and project['current_tag'] == project['version']:
|
||||||
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']]
|
||||||
|
@ -392,23 +398,21 @@ def send_packages(dist, arch, project, package, last_tag):
|
||||||
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('ssh root@%s "/usr/bin/reprepro -b /var/vhosts/deb.entrouvert.org copy %s %s %s"'\
|
call(
|
||||||
% (settings.REPOSITORY_URL, repo,
|
'ssh root@%s "/usr/bin/reprepro -b /var/vhosts/deb.entrouvert.org copy %s %s %s"'
|
||||||
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)
|
||||||
|
|
||||||
open(stamp_file, 'w').close()
|
open(stamp_file, 'w').close()
|
||||||
|
|
||||||
|
|
||||||
def clean_git_on_exit(git_project_path):
|
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(
|
changelog_tmp = os.path.join(git_project_path, "debian", "changelog.git")
|
||||||
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)
|
||||||
|
|
||||||
|
@ -428,10 +432,12 @@ def get_git_branch_name(project_reference):
|
||||||
git_project_path = get_git_project_path(project_reference)
|
git_project_path = get_git_project_path(project_reference)
|
||||||
for branch_name in ('main', 'master'):
|
for branch_name in ('main', 'master'):
|
||||||
try:
|
try:
|
||||||
subprocess.check_call(['git', 'rev-parse', branch_name],
|
subprocess.check_call(
|
||||||
stdout=subprocess.DEVNULL,
|
['git', 'rev-parse', branch_name],
|
||||||
stderr=subprocess.DEVNULL,
|
stdout=subprocess.DEVNULL,
|
||||||
cwd=git_project_path)
|
stderr=subprocess.DEVNULL,
|
||||||
|
cwd=git_project_path,
|
||||||
|
)
|
||||||
except subprocess.CalledProcessError:
|
except subprocess.CalledProcessError:
|
||||||
continue
|
continue
|
||||||
return branch_name
|
return branch_name
|
||||||
|
@ -449,10 +455,8 @@ def setup_git_tree(project_reference, options):
|
||||||
branch_name = options.branch or get_git_branch_name(project_reference)
|
branch_name = options.branch or get_git_branch_name(project_reference)
|
||||||
try:
|
try:
|
||||||
subprocess.check_call(['git', 'fetch'], cwd=git_project_path)
|
subprocess.check_call(['git', 'fetch'], cwd=git_project_path)
|
||||||
subprocess.check_call(['git', 'checkout', '--quiet', branch_name],
|
subprocess.check_call(['git', 'checkout', '--quiet', branch_name], cwd=git_project_path)
|
||||||
cwd=git_project_path)
|
subprocess.check_call(['git', 'reset', '--hard', 'origin/%s' % branch_name], cwd=git_project_path)
|
||||||
subprocess.check_call(['git', 'reset', '--hard', 'origin/%s' % branch_name],
|
|
||||||
cwd=git_project_path)
|
|
||||||
except subprocess.CalledProcessError as e:
|
except subprocess.CalledProcessError as e:
|
||||||
print(e, file=sys.stderr)
|
print(e, file=sys.stderr)
|
||||||
shutil.rmtree(git_project_path)
|
shutil.rmtree(git_project_path)
|
||||||
|
@ -470,8 +474,7 @@ def setup_git_tree(project_reference, options):
|
||||||
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],
|
subprocess.check_call(['git', 'checkout', '--quiet', options.branch], cwd=git_project_path)
|
||||||
cwd=git_project_path)
|
|
||||||
branch_name = get_git_branch_name(project_reference)
|
branch_name = get_git_branch_name(project_reference)
|
||||||
|
|
||||||
if not options.branch:
|
if not options.branch:
|
||||||
|
@ -505,12 +508,11 @@ def main():
|
||||||
atexit.register(clean_git_on_exit, git_project_path)
|
atexit.register(clean_git_on_exit, git_project_path)
|
||||||
if options.branch and options.branch.startswith('origin/'):
|
if options.branch and options.branch.startswith('origin/'):
|
||||||
# normalize without origin/
|
# normalize without origin/
|
||||||
options.branch = options.branch[len('origin/'):]
|
options.branch = options.branch[len('origin/') :]
|
||||||
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*",
|
last_tag = output("git describe --abbrev=0 --tags --match=v*", exit_on_error=False)
|
||||||
exit_on_error=False)
|
|
||||||
if last_tag:
|
if last_tag:
|
||||||
last_tag = last_tag[1:-1]
|
last_tag = last_tag[1:-1]
|
||||||
else:
|
else:
|
||||||
|
@ -528,10 +530,8 @@ def main():
|
||||||
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'],
|
project['lock_path'], "%s_%s.last_revision" % (project['name'], branch_name.replace('/', '_'))
|
||||||
"%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:
|
||||||
last_branch_revision = f.read().strip()
|
last_branch_revision = f.read().strip()
|
||||||
|
@ -557,18 +557,24 @@ def main():
|
||||||
else:
|
else:
|
||||||
print("+ Package not sent to repository (--no-dput used).")
|
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(os.path.join(project['lock_path'],
|
touch(
|
||||||
"%s_%s_%s_%s.build" % (project['name'],
|
os.path.join(
|
||||||
package['version'],
|
project['lock_path'],
|
||||||
package['repository'],
|
"%s_%s_%s_%s.build"
|
||||||
branch_name.replace('/', '_'))
|
% (
|
||||||
))
|
project['name'],
|
||||||
|
package['version'],
|
||||||
|
package['repository'],
|
||||||
|
branch_name.replace('/', '_'),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
last_version_file = os.path.join(project['lock_path'],
|
last_version_file = os.path.join(
|
||||||
"%s_%s_%s.last_version" % (project['name'],
|
project['lock_path'],
|
||||||
package['repository'],
|
"%s_%s_%s.last_version"
|
||||||
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:
|
||||||
f.write(package['version'])
|
f.write(package['version'])
|
||||||
|
|
||||||
|
@ -576,6 +582,6 @@ def main():
|
||||||
with open(last_branch_revision_file_path, 'w+') as f:
|
with open(last_branch_revision_file_path, 'w+') as f:
|
||||||
f.write(current_revision)
|
f.write(current_revision)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@ import os
|
||||||
|
|
||||||
VERSION = '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):
|
||||||
|
|
|
@ -13,6 +13,7 @@ from git.objects.commit import Commit
|
||||||
|
|
||||||
from . import cmdline
|
from . import cmdline
|
||||||
|
|
||||||
|
|
||||||
def get_commit_from_tag(repo, tag_ref):
|
def get_commit_from_tag(repo, tag_ref):
|
||||||
ref = repo.tags[tag_ref]
|
ref = repo.tags[tag_ref]
|
||||||
while ref.object.type == 'tag':
|
while ref.object.type == 'tag':
|
||||||
|
@ -35,11 +36,15 @@ def is_pep0440_project(path):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def changelog_from_git(project, version_suffix, path,
|
def changelog_from_git(
|
||||||
repository='eobuilder',
|
project,
|
||||||
maintainer_name='eobuilder',
|
version_suffix,
|
||||||
maintainer_email='eobuilder@entrouvert.com',
|
path,
|
||||||
epoch=''):
|
repository='eobuilder',
|
||||||
|
maintainer_name='eobuilder',
|
||||||
|
maintainer_email='eobuilder@entrouvert.com',
|
||||||
|
epoch='',
|
||||||
|
):
|
||||||
repo = git.repo.Repo(path)
|
repo = git.repo.Repo(path)
|
||||||
is_pep0440 = is_pep0440_project(path)
|
is_pep0440 = is_pep0440_project(path)
|
||||||
|
|
||||||
|
@ -56,7 +61,7 @@ def changelog_from_git(project, version_suffix, path,
|
||||||
versions.append((last_tag, get_commit_from_tag(repo, last_tag)))
|
versions.append((last_tag, get_commit_from_tag(repo, last_tag)))
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
last_tag = repo.git.describe(last_tag+'~', abbrev=0)
|
last_tag = repo.git.describe(last_tag + '~', abbrev=0)
|
||||||
except GitCommandError:
|
except GitCommandError:
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
|
@ -64,12 +69,14 @@ def changelog_from_git(project, version_suffix, path,
|
||||||
n = len(versions)
|
n = len(versions)
|
||||||
for i in range(n):
|
for i in range(n):
|
||||||
name, commit = versions[i]
|
name, commit = versions[i]
|
||||||
if i == n-1:
|
if i == n - 1:
|
||||||
logs = [commit] + list(commit.iter_parents())
|
logs = [commit] + list(commit.iter_parents())
|
||||||
else:
|
else:
|
||||||
|
|
||||||
def encode_hex(value):
|
def encode_hex(value):
|
||||||
return codecs.encode(value, 'hex').decode('ascii')
|
return codecs.encode(value, 'hex').decode('ascii')
|
||||||
reflog = '%s..%s' % (encode_hex(versions[i+1][1].binsha), encode_hex(commit.binsha))
|
|
||||||
|
reflog = '%s..%s' % (encode_hex(versions[i + 1][1].binsha), encode_hex(commit.binsha))
|
||||||
logs = list(Commit.iter_items(repo, reflog))
|
logs = list(Commit.iter_items(repo, reflog))
|
||||||
if not logs:
|
if not logs:
|
||||||
continue
|
continue
|
||||||
|
@ -89,15 +96,20 @@ def changelog_from_git(project, version_suffix, path,
|
||||||
except LookupError as e:
|
except LookupError as e:
|
||||||
t = '(%s) %s' % (l.hexsha[:6], e)
|
t = '(%s) %s' % (l.hexsha[:6], e)
|
||||||
lines = textwrap.wrap(t, 80)
|
lines = textwrap.wrap(t, 80)
|
||||||
for prefix, suffix in zip([' * '] + [' ']*(len(lines)-1), lines):
|
for prefix, suffix in zip([' * '] + [' '] * (len(lines) - 1), lines):
|
||||||
yield (prefix + suffix)
|
yield (prefix + suffix)
|
||||||
paris = pytz.timezone('Europe/Paris')
|
paris = pytz.timezone('Europe/Paris')
|
||||||
date = datetime.datetime.fromtimestamp(logs[0].committed_date + logs[0].committer_tz_offset).replace(
|
date = (
|
||||||
tzinfo=pytz.UTC).astimezone(paris).strftime('%a, %d %b %Y %H:%M:%S %z')
|
datetime.datetime.fromtimestamp(logs[0].committed_date + logs[0].committer_tz_offset)
|
||||||
|
.replace(tzinfo=pytz.UTC)
|
||||||
|
.astimezone(paris)
|
||||||
|
.strftime('%a, %d %b %Y %H:%M:%S %z')
|
||||||
|
)
|
||||||
yield ''
|
yield ''
|
||||||
yield ' -- %s <%s> %s' % (maintainer_name, maintainer_email, date)
|
yield ' -- %s <%s> %s' % (maintainer_name, maintainer_email, date)
|
||||||
yield ''
|
yield ''
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
project = sys.argv[1]
|
project = sys.argv[1]
|
||||||
version_suffix = sys.argv[2]
|
version_suffix = sys.argv[2]
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
|
@ -7,6 +6,7 @@ import sys
|
||||||
from optparse import OptionParser
|
from optparse import OptionParser
|
||||||
from optparse import Option
|
from optparse import Option
|
||||||
|
|
||||||
|
|
||||||
class MultipleOption(Option):
|
class MultipleOption(Option):
|
||||||
|
|
||||||
ACTIONS = Option.ACTIONS + ("extend",)
|
ACTIONS = Option.ACTIONS + ("extend",)
|
||||||
|
@ -21,58 +21,98 @@ class MultipleOption(Option):
|
||||||
if not lvalue in values_list:
|
if not lvalue in values_list:
|
||||||
values_list.append(lvalue)
|
values_list.append(lvalue)
|
||||||
else:
|
else:
|
||||||
Option.take_action(
|
Option.take_action(self, action, dest, opt, value, values, parser)
|
||||||
self, action, dest, opt, value, values, parser)
|
|
||||||
|
|
||||||
|
|
||||||
def parse_cmdline():
|
def parse_cmdline():
|
||||||
parser = OptionParser(option_class=MultipleOption,
|
parser = OptionParser(
|
||||||
usage='usage: %prog [OPTIONS] -d [buster|,stretch|,jessie|,wheezy|,squeeze] GIT_REPOSITORY_NAME')
|
option_class=MultipleOption,
|
||||||
parser.add_option("-a", "--architectures",
|
usage='usage: %prog [OPTIONS] -d [buster|,stretch|,jessie|,wheezy|,squeeze] GIT_REPOSITORY_NAME',
|
||||||
action="extend", type="string",
|
)
|
||||||
dest="architectures", metavar='ARCHITECTURES',
|
parser.add_option(
|
||||||
default=[],
|
"-a",
|
||||||
help="ARCHITECTURES: amd64 and / or i368 (Default: amd64)")
|
"--architectures",
|
||||||
parser.add_option("-d", "--distribution",
|
action="extend",
|
||||||
action="extend", type="string",
|
type="string",
|
||||||
dest="distrib", metavar='DISTRIBUTIONS',
|
dest="architectures",
|
||||||
default=[],
|
metavar='ARCHITECTURES',
|
||||||
help="DISTRIBUTIONS: buster, stretch, jessie, wheezy and / or squeeze")
|
default=[],
|
||||||
parser.add_option("-f", "--force", action="store_true",
|
help="ARCHITECTURES: amd64 and / or i368 (Default: amd64)",
|
||||||
dest="force", default=False,
|
)
|
||||||
help="force a new build")
|
parser.add_option(
|
||||||
parser.add_option("-n", "--native", action="store_true",
|
"-d",
|
||||||
dest="native", default=False,
|
"--distribution",
|
||||||
help="build native package")
|
action="extend",
|
||||||
parser.add_option("-b", "--branch",
|
type="string",
|
||||||
action="store", type="string",
|
dest="distrib",
|
||||||
dest="branch", metavar='NAME',
|
metavar='DISTRIBUTIONS',
|
||||||
help="branch to build (Default: main, or master)")
|
default=[],
|
||||||
parser.add_option("--epoch",
|
help="DISTRIBUTIONS: buster, stretch, jessie, wheezy and / or squeeze",
|
||||||
action="store", type="string",
|
)
|
||||||
dest="epoch", metavar='EPOCH',
|
parser.add_option(
|
||||||
default="",
|
"-f", "--force", action="store_true", dest="force", default=False, help="force a new build"
|
||||||
help="version number epoch (default: none)")
|
)
|
||||||
parser.add_option("-D", "--debian-folder",
|
parser.add_option(
|
||||||
action="store", type="string",
|
"-n", "--native", action="store_true", dest="native", default=False, help="build native package"
|
||||||
dest="debian_folder", metavar='NAME',
|
)
|
||||||
default="debian",
|
parser.add_option(
|
||||||
help="debian folder to use for build (Default: debian-DIST or debian)")
|
"-b",
|
||||||
parser.add_option("-c", "--clean",
|
"--branch",
|
||||||
action="extend", type="string",
|
action="store",
|
||||||
dest="cleaning", metavar='CLEANING_METHODS',
|
type="string",
|
||||||
default=[],
|
dest="branch",
|
||||||
help="CLEANING_METHODS: git, deb, archives, smart and / or all")
|
metavar='NAME',
|
||||||
parser.add_option("--hotfix", action="store_true",
|
help="branch to build (Default: main, or master)",
|
||||||
dest="hotfix", default=False,
|
)
|
||||||
help="upload to hotfix repository")
|
parser.add_option(
|
||||||
parser.add_option("-r", "--repository",
|
"--epoch",
|
||||||
action="extend", type="string",
|
action="store",
|
||||||
default=[],
|
type="string",
|
||||||
dest="repositories", metavar='DISTRIBUTION:REPOSITORY, DISTRIBUTION:REPOSITORY',
|
dest="epoch",
|
||||||
help="DISTRIBUTION:REPOSITORY: strech:stretch-eobuilder, jessie:jessie-eobuilder, wheezy:wheezy-eobuilder")
|
metavar='EPOCH',
|
||||||
parser.add_option("--no-dput", dest='dput', action="store_false", default=True,
|
default="",
|
||||||
help='do not send package to repository with dput')
|
help="version number epoch (default: none)",
|
||||||
|
)
|
||||||
|
parser.add_option(
|
||||||
|
"-D",
|
||||||
|
"--debian-folder",
|
||||||
|
action="store",
|
||||||
|
type="string",
|
||||||
|
dest="debian_folder",
|
||||||
|
metavar='NAME',
|
||||||
|
default="debian",
|
||||||
|
help="debian folder to use for build (Default: debian-DIST or debian)",
|
||||||
|
)
|
||||||
|
parser.add_option(
|
||||||
|
"-c",
|
||||||
|
"--clean",
|
||||||
|
action="extend",
|
||||||
|
type="string",
|
||||||
|
dest="cleaning",
|
||||||
|
metavar='CLEANING_METHODS',
|
||||||
|
default=[],
|
||||||
|
help="CLEANING_METHODS: git, deb, archives, smart and / or all",
|
||||||
|
)
|
||||||
|
parser.add_option(
|
||||||
|
"--hotfix", action="store_true", dest="hotfix", default=False, help="upload to hotfix repository"
|
||||||
|
)
|
||||||
|
parser.add_option(
|
||||||
|
"-r",
|
||||||
|
"--repository",
|
||||||
|
action="extend",
|
||||||
|
type="string",
|
||||||
|
default=[],
|
||||||
|
dest="repositories",
|
||||||
|
metavar='DISTRIBUTION:REPOSITORY, DISTRIBUTION:REPOSITORY',
|
||||||
|
help="DISTRIBUTION:REPOSITORY: strech:stretch-eobuilder, jessie:jessie-eobuilder, wheezy:wheezy-eobuilder",
|
||||||
|
)
|
||||||
|
parser.add_option(
|
||||||
|
"--no-dput",
|
||||||
|
dest='dput',
|
||||||
|
action="store_false",
|
||||||
|
default=True,
|
||||||
|
help='do not send package to repository with dput',
|
||||||
|
)
|
||||||
|
|
||||||
(options, args) = parser.parse_args()
|
(options, args) = parser.parse_args()
|
||||||
|
|
||||||
|
@ -94,40 +134,42 @@ def parse_cmdline():
|
||||||
options.architectures = ["amd64"]
|
options.architectures = ["amd64"]
|
||||||
return options, args
|
return options, args
|
||||||
|
|
||||||
|
|
||||||
def cat(file_path):
|
def cat(file_path):
|
||||||
with open(file_path, 'r') as f:
|
with open(file_path, 'r') as f:
|
||||||
content = f.read()
|
content = f.read()
|
||||||
return content
|
return content
|
||||||
|
|
||||||
|
|
||||||
def touch(fname):
|
def touch(fname):
|
||||||
print('TOUCH:', fname)
|
print('TOUCH:', fname)
|
||||||
with open(fname, 'a'):
|
with open(fname, 'a'):
|
||||||
os.utime(fname, None)
|
os.utime(fname, None)
|
||||||
|
|
||||||
|
|
||||||
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)
|
||||||
|
|
||||||
|
|
||||||
def call(cmd):
|
def call(cmd):
|
||||||
""" cmd: command line
|
"""cmd: command line"""
|
||||||
"""
|
|
||||||
print('CALL:', cmd)
|
print('CALL:', cmd)
|
||||||
rcode = subprocess.call(cmd, shell=True)
|
rcode = subprocess.call(cmd, shell=True)
|
||||||
if rcode != 0:
|
if rcode != 0:
|
||||||
error(cmd)
|
error(cmd)
|
||||||
|
|
||||||
|
|
||||||
def output(cmd, print_output=False, exit_on_error=True):
|
def output(cmd, print_output=False, exit_on_error=True):
|
||||||
""" cmd: command line
|
"""cmd: command line
|
||||||
print_output: print stdout and stderr
|
print_output: print stdout and stderr
|
||||||
return outputs (stderr + stdout) as byte string
|
return outputs (stderr + stdout) as byte string
|
||||||
"""
|
"""
|
||||||
output = None
|
output = None
|
||||||
try:
|
try:
|
||||||
output = subprocess.check_output(cmd,
|
output = subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True)
|
||||||
stderr=subprocess.STDOUT,
|
|
||||||
shell=True)
|
|
||||||
except subprocess.CalledProcessError as e:
|
except subprocess.CalledProcessError as e:
|
||||||
if e.output:
|
if e.output:
|
||||||
sys.stderr.write(e.output.decode('utf-8'))
|
sys.stderr.write(e.output.decode('utf-8'))
|
||||||
|
|
|
@ -15,32 +15,32 @@ DEBIAN_VERSIONS = {
|
||||||
"jessie": "80",
|
"jessie": "80",
|
||||||
"wheezy": "70",
|
"wheezy": "70",
|
||||||
"squeeze": "60",
|
"squeeze": "60",
|
||||||
"lenny": "50"
|
"lenny": "50",
|
||||||
}
|
}
|
||||||
|
|
||||||
DEFAULT_UNSTABLE_REPOSITORIES = {
|
DEFAULT_UNSTABLE_REPOSITORIES = {
|
||||||
"buster" : "buster-eobuilder",
|
"buster": "buster-eobuilder",
|
||||||
"stretch" : "stretch-eobuilder",
|
"stretch": "stretch-eobuilder",
|
||||||
"jessie" : "jessie-eobuilder",
|
"jessie": "jessie-eobuilder",
|
||||||
"wheezy" : "wheezy-eobuilder",
|
"wheezy": "wheezy-eobuilder",
|
||||||
"squeeze": "squeeze-eobuilder"
|
"squeeze": "squeeze-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 = {
|
||||||
"buster": ["buster-testing"],
|
"buster": ["buster-testing"],
|
||||||
"stretch": ["stretch-testing"],
|
"stretch": ["stretch-testing"],
|
||||||
"jessie": ["jessie-testing"],
|
"jessie": ["jessie-testing"],
|
||||||
"wheezy": ["wheezy-testing"],
|
"wheezy": ["wheezy-testing"],
|
||||||
"squeeze": ["squeeze-testing"]
|
"squeeze": ["squeeze-testing"],
|
||||||
}
|
}
|
||||||
|
|
||||||
# Hotfix repositories
|
# Hotfix repositories
|
||||||
HOTFIX_REPOSITORIES = {
|
HOTFIX_REPOSITORIES = {
|
||||||
"buster": "buster-hotfix",
|
"buster": "buster-hotfix",
|
||||||
"stretch": "stretch-hotfix",
|
"stretch": "stretch-hotfix",
|
||||||
"jessie": "jessie-hotfix",
|
"jessie": "jessie-hotfix",
|
||||||
}
|
}
|
||||||
|
|
||||||
# Specify the testing repository by source package name
|
# Specify the testing repository by source package name
|
||||||
|
@ -53,7 +53,8 @@ MIN_PACKAGE_VERSIONS = 10
|
||||||
MIN_AGE = 60
|
MIN_AGE = 60
|
||||||
|
|
||||||
|
|
||||||
local_settings_file = os.environ.get('EOBUILDER_SETTINGS_FILE',
|
local_settings_file = os.environ.get(
|
||||||
os.path.join(os.path.dirname(__file__), 'local_settings.py'))
|
'EOBUILDER_SETTINGS_FILE', os.path.join(os.path.dirname(__file__), 'local_settings.py')
|
||||||
|
)
|
||||||
if os.path.exists(local_settings_file):
|
if os.path.exists(local_settings_file):
|
||||||
exec(open(local_settings_file).read())
|
exec(open(local_settings_file).read())
|
||||||
|
|
36
setup.py
36
setup.py
|
@ -21,9 +21,9 @@ class eo_sdist(sdist):
|
||||||
|
|
||||||
|
|
||||||
def get_version():
|
def get_version():
|
||||||
'''Use the VERSION, if absent generates a version with git describe, if not
|
"""Use the VERSION, if absent generates a version with git describe, if not
|
||||||
tag exists, take 0.0- and add the length of the commit log.
|
tag exists, take 0.0- and add the length of the commit log.
|
||||||
'''
|
"""
|
||||||
if os.path.exists('VERSION'):
|
if os.path.exists('VERSION'):
|
||||||
with open('VERSION', 'r') as v:
|
with open('VERSION', 'r') as v:
|
||||||
return v.read()
|
return v.read()
|
||||||
|
@ -47,17 +47,19 @@ def get_version():
|
||||||
return '0.0'
|
return '0.0'
|
||||||
|
|
||||||
|
|
||||||
setup(name="eobuilder",
|
setup(
|
||||||
version=get_version(),
|
name="eobuilder",
|
||||||
license="AGPLv3 or later",
|
version=get_version(),
|
||||||
description="Entr'ouvert Package Builder",
|
license="AGPLv3 or later",
|
||||||
author="Entr'ouvert",
|
description="Entr'ouvert Package Builder",
|
||||||
author_email="info@entrouvert.org",
|
author="Entr'ouvert",
|
||||||
maintainer="Jerome Schneider",
|
author_email="info@entrouvert.org",
|
||||||
maintainer_email="info@entrouvert.com",
|
maintainer="Jerome Schneider",
|
||||||
install_requires=['pytz', 'GitPython'],
|
maintainer_email="info@entrouvert.com",
|
||||||
include_package_data=True,
|
install_requires=['pytz', 'GitPython'],
|
||||||
url='https://dev.entrouvert.org/projects/eobuilder',
|
include_package_data=True,
|
||||||
packages=find_packages(),
|
url='https://dev.entrouvert.org/projects/eobuilder',
|
||||||
scripts=('eobuilder-ctl', 'eobuildall'),
|
packages=find_packages(),
|
||||||
cmdclass={'sdist': eo_sdist})
|
scripts=('eobuilder-ctl', 'eobuildall'),
|
||||||
|
cmdclass={'sdist': eo_sdist},
|
||||||
|
)
|
||||||
|
|
Loading…
Reference in New Issue