Skip to content

Commit

Permalink
revert to a stabler state, undoing pkexec condense (#48)
Browse files Browse the repository at this point in the history
46 commits of BS just to revert. great
  • Loading branch information
oklopfer authored Jul 27, 2023
1 parent 498c0b9 commit 18c83f8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 28 deletions.
5 changes: 0 additions & 5 deletions src/package_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,6 @@ impl SimpleComponent for PackageManagerModel {
if self.install_flatpak {
commands.push("sudo apt-get install -y flatpak");
commands.push("flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo");
commands.push(
"sudo sed -i 's/distro.eol/datetime.datetime.now().date() + \
datetime.timedelta(days=3650)/g' \
/usr/lib/python3/dist-packages/softwareproperties/gtk/SoftwarePropertiesGtk.py",
);
}

if self.install_snap {
Expand Down
32 changes: 9 additions & 23 deletions src/progress.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,37 +138,20 @@ impl SimpleComponent for ProgressModel {
let commands = commands.values().flatten();
let mut commands_with_results = String::new();

// Function to append commands to the command string.
let append_command = |cmd: &str, cmd_str: &mut String| {
*cmd_str += &format!(
"{cmd} && {{ echo ---successful---; }} || {{ echo ---failed---; }}; "
);
};

// Aggregate all the commands.
for command in commands.clone() {
append_command(command, &mut commands_with_results);
commands_with_results += &format!(
"{command} && {{ echo ---successful---; }} || {{ echo ---failed---; }}; "
);
}

// Add the final removal command to the end.
append_command(
"sudo apt remove -yq rhino-setup",
&mut commands_with_results,
);

// Add the autostart file removal command.
append_command(
"sudo rm /home/$USER/.config/autostart/setup.desktop",
&mut commands_with_results,
);

tracing::debug!("{commands_with_results}");

// Spawn a process to execute the commands
let mut processor = Command::new("sh")
.args([
"-c",
&format!(r#"pkexec sh -c "{commands_with_results}" || echo ---failed---"#),
&format!(r#"pkexec sh -c "{commands_with_results}" || echo ---failed---"#,),
])
.stdout(Stdio::piped())
.stderr(Stdio::piped())
Expand All @@ -180,7 +163,7 @@ impl SimpleComponent for ProgressModel {
// Initialize the progress_bar now, as the commands are available.
self.progress_bar = Some(
ProgressBarModel::builder()
.launch((commands.count() + 2) as f64) // Add 2 for the removal commands
.launch(commands.count() as f64)
.detach(),
);

Expand Down Expand Up @@ -209,13 +192,16 @@ impl SimpleComponent for ProgressModel {

// Kill the processor to avoid any extra changes to the system.
processor.kill().unwrap();
break; // Exit the loop upon encountering an error.
}
}

if !error_occured {
sender.output(Self::Output::InstallationComplete).unwrap();
tracing::info!("Installation complete");
Command::new("pkexec")
.args(["sh", "-c", "sudo apt remove -yq rhino-setup"])
.status()
.unwrap();
}
});
},
Expand Down

0 comments on commit 18c83f8

Please sign in to comment.