Merge "pkgbuilder: Support 'jobs' option and tmpfs directory"

This commit is contained in:
Zuul 2022-01-15 05:14:01 +00:00 committed by Gerrit Code Review
commit dd8294b555
4 changed files with 25 additions and 2 deletions

View File

@ -53,6 +53,7 @@ RUN groupadd crontab
COPY stx/toCOPY/pkgbuilder/app.py /opt/
COPY stx/toCOPY/pkgbuilder/debbuilder.py /opt/
COPY stx/toCOPY/pkgbuilder/setup.sh /opt/
COPY stx/toCOPY/pkgbuilder/debbuilder.conf /etc/sbuild/sbuild.conf
ENTRYPOINT ["/usr/bin/tini", "--"]

View File

@ -104,6 +104,8 @@ def add_task():
'type': request.form['type'],
'run_tests': request.form['run_tests']
}
if 'jobs' in request.form:
task_info['jobs'] = request.form['jobs']
response = dbuilder.add_task(user, project, task_info)
log.info("Reply to add task, response=%s", str(response))

View File

@ -53,6 +53,7 @@ class Debbuilder:
self.ctlog = None
self.set_extra_repos()
self.set_environ_vars()
os.system('/opt/setup.sh')
@property
def state(self):
@ -152,7 +153,8 @@ class Debbuilder:
else:
chroot_suffix = '--chroot-suffix=-' + user
chroot_cmd = ' '.join(['sbuild-createchroot', chroot_suffix,
'--include=eatmydata', DEBDIST, user_chroot])
'--include=eatmydata', '--command-prefix=eatmydata',
DEBDIST, user_chroot])
if mirror:
chroot_cmd = ' '.join([chroot_cmd, mirror])
self.logger.debug("Command to creat chroot:%s" % chroot_cmd)
@ -228,7 +230,10 @@ class Debbuilder:
response['msg'] = dsc_target + ' does not exist'
return response
bcommand = ' '.join([BUILD_ENGINE, '-d', DEBDIST, '-c', chroot,
jobs = '-j4'
if 'jobs' in task_info:
jobs = '-j' + task_info['jobs']
bcommand = ' '.join([BUILD_ENGINE, jobs, '-d', DEBDIST, '-c', chroot,
'--build-dir', build_dir, dsc_target])
self.logger.debug("Build command: %s" % bcommand)

15
stx/toCOPY/pkgbuilder/setup.sh Executable file
View File

@ -0,0 +1,15 @@
#!/bin/bash
if [ -f "/etc/fstab" ]; then
speed_up=`cat /etc/fstab | grep 'speeding up sbuild'`
[ "x${speed_up}" != "x" ] && exit 0
fi
cat >>/etc/fstab << EOF
# For speeding up sbuild/schroot and prevent SSD wear-out
tmpfs /var/lib/schroot/session tmpfs uid=root,gid=root,mode=0755 0 0
tmpfs /var/lib/schroot/union/overlay tmpfs uid=root,gid=root,mode=0755 0 0
tmpfs /var/lib/sbuild/build tmpfs uid=sbuild,gid=sbuild,mode=2770 0 0
EOF
mount -a