|
|
|
@ -38,6 +38,14 @@ class Processor:
|
|
|
|
|
logger.info("processing the following commands: \n%s" %
|
|
|
|
|
'\n'.join(commands))
|
|
|
|
|
|
|
|
|
|
# connection check
|
|
|
|
|
cn = subprocess.run(["wget", "-q", "--spider", "cloudflare.com"],
|
|
|
|
|
stdout=subprocess.DEVNULL,
|
|
|
|
|
stderr=subprocess.DEVNULL)
|
|
|
|
|
if cn.returncode != 0:
|
|
|
|
|
logger.critical("No internet connection")
|
|
|
|
|
return False, "No internet connection."
|
|
|
|
|
|
|
|
|
|
# nextBoot commands are collected in ~/.local/org.vanillaos.FirstSetup.nextBoot
|
|
|
|
|
# and executed at the next boot by a desktop entry
|
|
|
|
|
for command in commands:
|
|
|
|
@ -103,34 +111,32 @@ class Processor:
|
|
|
|
|
|
|
|
|
|
# fake the process if VANILLA_FAKE is set
|
|
|
|
|
if "VANILLA_FAKE" in os.environ:
|
|
|
|
|
return True
|
|
|
|
|
return True, ""
|
|
|
|
|
|
|
|
|
|
cmd = ["pkexec", "sh", f.name]
|
|
|
|
|
if abroot_bin := shutil.which("abroot"):
|
|
|
|
|
cmd = ["pkexec", abroot_bin, "exec", "--assume-yes", "sh", f.name]
|
|
|
|
|
|
|
|
|
|
proc = subprocess.run(
|
|
|
|
|
cmd,
|
|
|
|
|
check=True,
|
|
|
|
|
stdout=subprocess.PIPE,
|
|
|
|
|
stderr=subprocess.STDOUT
|
|
|
|
|
)
|
|
|
|
|
#proc = subprocess.run(cmd)
|
|
|
|
|
# the above is wrong, we need to show the output in the console but also capture it
|
|
|
|
|
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
|
|
|
|
out = proc.communicate()[0].decode("utf-8")
|
|
|
|
|
|
|
|
|
|
# write the output to the log file so the packager can see what
|
|
|
|
|
# happened during the installation process
|
|
|
|
|
try:
|
|
|
|
|
with open(log_path, 'a') as log:
|
|
|
|
|
log.write(proc.stdout.decode('utf-8'))
|
|
|
|
|
log.write(out)
|
|
|
|
|
log.flush()
|
|
|
|
|
except Exception as e:
|
|
|
|
|
logger.warning("failed to write to the log file: %s" % e)
|
|
|
|
|
logger.warning("the output of the commands is: %s" %
|
|
|
|
|
proc.stdout.decode('utf-8'))
|
|
|
|
|
out)
|
|
|
|
|
|
|
|
|
|
if proc.returncode != 0:
|
|
|
|
|
logger.critical(
|
|
|
|
|
"Error while processing commands, see log for details.")
|
|
|
|
|
return False
|
|
|
|
|
return False, out
|
|
|
|
|
|
|
|
|
|
autostart_file = os.path.expanduser(
|
|
|
|
|
"~/.config/autostart/org.vanillaos.FirstSetup.desktop")
|
|
|
|
@ -142,4 +148,4 @@ class Processor:
|
|
|
|
|
logger.info("running outRun commands: \n%s" % out_run)
|
|
|
|
|
subprocess.run(out_run, shell=True)
|
|
|
|
|
|
|
|
|
|
return True
|
|
|
|
|
return True, ""
|
|
|
|
|