diff --git a/stx/dockerfiles/stx-pkgbuilder.Dockerfile b/stx/dockerfiles/stx-pkgbuilder.Dockerfile index 5f2f79079..ce60b809f 100644 --- a/stx/dockerfiles/stx-pkgbuilder.Dockerfile +++ b/stx/dockerfiles/stx-pkgbuilder.Dockerfile @@ -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", "--"] diff --git a/stx/toCOPY/pkgbuilder/app.py b/stx/toCOPY/pkgbuilder/app.py index f55718795..66fc67839 100644 --- a/stx/toCOPY/pkgbuilder/app.py +++ b/stx/toCOPY/pkgbuilder/app.py @@ -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)) diff --git a/stx/toCOPY/pkgbuilder/debbuilder.py b/stx/toCOPY/pkgbuilder/debbuilder.py index efbcc41c7..76b3cda07 100644 --- a/stx/toCOPY/pkgbuilder/debbuilder.py +++ b/stx/toCOPY/pkgbuilder/debbuilder.py @@ -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) diff --git a/stx/toCOPY/pkgbuilder/setup.sh b/stx/toCOPY/pkgbuilder/setup.sh new file mode 100755 index 000000000..6e16a433b --- /dev/null +++ b/stx/toCOPY/pkgbuilder/setup.sh @@ -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