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