From 1bde8d27b02f314b1d4828e8c96c4ffc265d2a74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20P=C3=B6hn?= Date: Thu, 6 Jun 2024 11:50:16 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=B9=20remove=20sudo=20code=20from=20bu?= =?UTF-8?q?ild=5Flocal=5Fprepare?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fdroidserver/build_local_prepare.py | 78 ++--------------------------- 1 file changed, 4 insertions(+), 74 deletions(-) diff --git a/fdroidserver/build_local_prepare.py b/fdroidserver/build_local_prepare.py index a495d0a8..7ac01631 100644 --- a/fdroidserver/build_local_prepare.py +++ b/fdroidserver/build_local_prepare.py @@ -19,58 +19,13 @@ import os import pathlib -import logging +# import logging import argparse from fdroidserver import _ import fdroidserver.common -def sudo_run(app, build): - # before doing anything, run the sudo commands to setup the VM - if build.sudo: - logging.info("Running 'sudo' commands in %s" % os.getcwd()) - - p = fdroidserver.common.FDroidPopen( - [ - 'sudo', - 'DEBIAN_FRONTEND=noninteractive', - 'bash', - '-e', - '-u', - '-o', - 'pipefail', - '-x', - '-c', - '; '.join(build.sudo), - ] - ) - if p.returncode != 0: - raise BuildException( - "Error running sudo command for %s:%s" % (app.id, build.versionName), - p.output, - ) - - -def sudo_lock_root(app, build): - p = fdroidserver.common.FDroidPopen(['sudo', 'passwd', '--lock', 'root']) - if p.returncode != 0: - raise BuildException( - "Error locking root account for %s:%s" % (app.id, build.versionName), - p.output, - ) - - -def sudo_uninstall(app, build): - p = fdroidserver.common.FDroidPopen( - ['sudo', 'SUDO_FORCE_REMOVE=yes', 'dpkg', '--purge', 'sudo'] - ) - if p.returncode != 0: - raise BuildException( - "Error removing sudo for %s:%s" % (app.id, build.versionName), p.output - ) - - def log_tools_version(app, build, log_dir): log_path = os.path.join( log_dir, fdroidserver.common.get_toolsversion_logname(app, build) @@ -86,24 +41,6 @@ def main(): "for one specific build" ), ) - parser.add_argument( - "--sudo-run", - action="store_true", - default=False, - help=_("run commands listed in sudo-metadata"), - ) - parser.add_argument( - "--sudo-uninstall", - action="store_true", - default=False, - help=_("uninstall sudo executing sudo-metadata"), - ) - parser.add_argument( - "--sudo-lock-root", - action="store_true", - default=False, - help=_("lock root user account"), - ) parser.add_argument( "APP_VERSION", help=_("app id and version code tuple 'APPID:VERCODE'"), @@ -114,6 +51,8 @@ def main(): options = fdroidserver.common.parse_args(parser) config = fdroidserver.common.get_config() + config # silence pyflakes + package_name, version_code = fdroidserver.common.split_pkg_arg(options.APP_VERSION) app, build = fdroidserver.metadata.read_build_metadata(package_name, version_code) @@ -126,17 +65,8 @@ def main(): for d in (srclib_dir, extlib_dir, log_dir, output_dir): d.mkdir(exist_ok=True, parents=True) - # run sudo stuff - fdroidserver.common.set_FDroidPopen_env(build) - if options.sudo_run: - sudo_run(app, build) - if options.sudo_lock_root: - sudo_lock_root(app, build) - if options.sudo_uninstall: - sudo_uninstall(app, build) - # TODO: in the past this was only logged when running as 'fdroid build - # --onserver' is this this output still valuable or can we remove it? + # --onserver', is this output still valuable or can we remove it? log_tools_version(app, build, log_dir) # do git/vcs checkout