core: Fix abroot exec not being called properly

also add support for the !noSudo bang
main
Mirko Brombin 2 years ago
parent 177151a2ff
commit 8078b7a56b

@ -0,0 +1,2 @@
misc:Depends=dconf-gsettings-backend | gsettings-backend
misc:Pre-Depends=

@ -3,12 +3,12 @@
"distro_name": "Vanilla OS", "distro_name": "Vanilla OS",
"distro_logo": "io.github.vanilla-os.FirstSetup", "distro_logo": "io.github.vanilla-os.FirstSetup",
"pre_run": [ "pre_run": [
"sudo apt update", "apt update",
"sudo apt install -f" "apt install -f"
], ],
"post_run": [ "post_run": [
"sudo apt update", "apt update",
"sudo apt install -f" "apt install -f"
], ],
"tour": { "tour": {
"abroot": { "abroot": {
@ -45,7 +45,7 @@
"if": "warp::immutability", "if": "warp::immutability",
"type": "command", "type": "command",
"commands": [ "commands": [
"sudo apt remove -y gnome-software" "apt remove -y gnome-software"
] ]
} }
] ]
@ -74,8 +74,8 @@
"if": "flatpak", "if": "flatpak",
"type": "command", "type": "command",
"commands": [ "commands": [
"sudo apt install -y flatpak gnome-software-plugin-flatpak", "apt install -y flatpak gnome-software-plugin-flatpak",
"flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo", "!noSudo flatpak remote-add --user --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo",
"gsettings set org.gnome.software packaging-format-preference '[\"flatpak\", \"snap\", \"deb\"]'" "gsettings set org.gnome.software packaging-format-preference '[\"flatpak\", \"snap\", \"deb\"]'"
] ]
}, },
@ -83,14 +83,14 @@
"if": "snap", "if": "snap",
"type": "command", "type": "command",
"commands": [ "commands": [
"sudo apt install -y snapd", "apt install -y snapd",
"gsettings set org.gnome.software packaging-format-preference '[\"flatpak\", \"snap\", \"deb\"]'" "gsettings set org.gnome.software packaging-format-preference '[\"flatpak\", \"snap\", \"deb\"]'"
] ]
}, },
{ {
"if": "appimage", "if": "appimage",
"type": "command", "type": "command",
"commands": ["sudo apt install -y fuse2 libfuse2"] "commands": ["apt install -y fuse2 libfuse2"]
} }
] ]
}, },
@ -115,7 +115,7 @@
{ {
"if": "nvidia", "if": "nvidia",
"type": "command", "type": "command",
"commands": ["sudo _ubuntu-drivers install --recommended"] "commands": ["_ubuntu-drivers install --recommended"]
} }
] ]
}, },
@ -140,7 +140,7 @@
{ {
"if": "vm", "if": "vm",
"type": "command", "type": "command",
"commands": ["sudo apt install -y open-vm-tools"] "commands": ["apt install -y open-vm-tools"]
} }
] ]
}, },
@ -162,7 +162,7 @@
{ {
"if": "codecs", "if": "codecs",
"type": "command", "type": "command",
"commands": ["sudo apt install -y ubuntu-restricted-addons ubuntu-restricted-extras"] "commands": ["apt install -y ubuntu-restricted-addons ubuntu-restricted-extras"]
} }
] ]
}, },
@ -183,7 +183,7 @@
"if": "apport", "if": "apport",
"type": "command", "type": "command",
"commands": [ "commands": [
"sudo apt install -y apport", "apt install -y apport",
"systemctl enable apport.service || true" "systemctl enable apport.service || true"
] ]
}, },
@ -192,7 +192,7 @@
"condition": false, "condition": false,
"type": "command", "type": "command",
"commands": [ "commands": [
"sudo apt remove -y apport", "apt remove -y apport",
"systemctl disable apport.service || true" "systemctl disable apport.service || true"
] ]
} }

@ -41,14 +41,11 @@ class Processor:
f.write("# This file was created by FirstSetup\n") f.write("# This file was created by FirstSetup\n")
f.write("# Do not edit this file manually\n\n") f.write("# Do not edit this file manually\n\n")
if abroot_bin := shutil.which("abroot"):
f.write("abroot exec --assume-yes <<EOF\n")
for command in commands: for command in commands:
f.write(f"{command}\n") if command.startswith("!noSudo"):
command = command.replace("!noSudo", "sudo -u $USER")
if abroot_bin := shutil.which("abroot"): f.write(f"{command}\n")
f.write("EOF\n")
f.flush() f.flush()
f.close() f.close()
@ -60,8 +57,12 @@ class Processor:
if "VANILLA_FAKE" in os.environ: 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( proc = subprocess.run(
["pkexec", "sh", f.name], cmd,
check=True, check=True,
stdout=subprocess.PIPE, stdout=subprocess.PIPE,
stderr=subprocess.STDOUT stderr=subprocess.STDOUT

Loading…
Cancel
Save