From 2e531af58f8fd329c610bb84e16e6ff1bb13d0c4 Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Thu, 14 Dec 2017 14:42:09 +0100 Subject: [PATCH] build: force purging of sudo, ignore error message Fixes bb758d3f, spotted by @bubu: DEBUG: buildserver > DEBUG: > sudo apt-get -y purge sudo DEBUG: buildserver > Reading package lists... DEBUG: buildserver > Building dependency tree... DEBUG: buildserver > Reading state information... DEBUG: buildserver > The following packages will be REMOVED: DEBUG: buildserver > sudo* DEBUG: buildserver > 0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded. DEBUG: buildserver > After this operation, 2,391 kB disk space will be freed. (Reading database ... 68491 files and directories currently installed.) DEBUG: buildserver > Removing sudo (1.8.10p3-1+deb8u4) ... DEBUG: buildserver > You have asked that the sudo package be removed, DEBUG: buildserver > but no root password has been set. DEBUG: buildserver > Without sudo, you may not be able to gain administrative privileges. DEBUG: buildserver > DEBUG: buildserver > If you would prefer to access the root account with su(1) DEBUG: buildserver > or by logging in directly, DEBUG: buildserver > you must set a root password with "sudo passwd". DEBUG: buildserver > DEBUG: buildserver > If you have arranged other means to access the root account, DEBUG: buildserver > and you are sure this is what you want, DEBUG: buildserver > you may bypass this check by setting an environment variable DEBUG: buildserver > (export SUDO_FORCE_REMOVE=yes). DEBUG: buildserver > DEBUG: buildserver > Refusing to remove sudo. DEBUG: buildserver > dpkg: error processing package sudo (--purge): DEBUG: buildserver > subprocess installed pre-removal script returned error exit status 1 DEBUG: buildserver > Errors were encountered while processing: DEBUG: buildserver > sudo DEBUG: buildserver > E: Sub-process /usr/bin/dpkg returned an error code (1) --- fdroidserver/build.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/fdroidserver/build.py b/fdroidserver/build.py index e2866fbd..d4f50005 100644 --- a/fdroidserver/build.py +++ b/fdroidserver/build.py @@ -414,7 +414,12 @@ def build_local(app, build, vcs, build_dir, output_dir, log_dir, srclib_dir, ext raise BuildException("Error running sudo command for %s:%s" % (app.id, build.versionName), p.output) - p = FDroidPopen(['sudo', 'apt-get', '-y', 'purge', 'sudo']) + p = FDroidPopen(['sudo', 'passwd', '--lock', 'root']) + if p.returncode != 0: + raise BuildException("Error locking root account for %s:%s" % + (app.id, build.versionName), p.output) + + p = FDroidPopen(['sudo', 'SUDO_FORCE_REMOVE=yes', 'apt-get', '-y', 'purge', 'sudo']) if p.returncode != 0: raise BuildException("Error removing sudo for %s:%s" % (app.id, build.versionName), p.output)