Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(bundler): add post/pre install/remove scripts for linux deb and rpm packages #9209

Merged
merged 6 commits into from
Mar 28, 2024

Conversation

vlabo
Copy link
Contributor

@vlabo vlabo commented Mar 18, 2024

New configuration options:

"bundle": {
    "linux": {
      "deb": {
        "scripts": {
          "preInstall": "./preinst_script.sh",
          "postInstall": "./postinst_script.sh",
          "preRemove": "./prerm_script.sh",
          "postRemove": "./postrm_script.sh"
        }
      },
      "rpm": {
        "scripts": {
          "preInstall": "./preinst_script.sh",
          "postInstall": "./postinst_script.sh",
          "preRemove": "./prerm_script.sh",
          "postRemove": "./postrm_script.sh"
        }
      }
    }
  }

I fallowed the official implementation for debian packages:
https://www.debian.org/doc/debian-policy/ch-maintainerscripts.html

For rpm package I used the already available functions from the rpm crate:
https://docs.rs/rpm/0.14.0/rpm/struct.PackageBuilder.html#method.pre_install_script
https://docs.rs/rpm/0.14.0/rpm/struct.PackageBuilder.html#method.post_install_script
https://docs.rs/rpm/0.14.0/rpm/struct.PackageBuilder.html#method.pre_uninstall_script
https://docs.rs/rpm/0.14.0/rpm/struct.PackageBuilder.html#method.post_uninstall_script

closes #9192
closes #8993

@vlabo vlabo requested a review from a team as a code owner March 18, 2024 09:23
@naman-crabnebula
Copy link
Contributor

Hi there!

I ( not sure of others ) would prefer having the script options under the DebianSettings and RpmSettings itself, and should not create a separate DebScripts or Rpmscripts struct for that.

@FabianLars
Copy link
Member

So you mean like this?

{
  "deb":
    "pre_install": "",
    "post_install": "",
    ...
}

I could see that working too but i'd also like to hear the others' opionions. That said, if we do keep a struct (which imo is fine too) then i think we should have one generic struct and reuse it in both deb and rpm.

@vlabo
Copy link
Contributor Author

vlabo commented Mar 21, 2024

Im fine with both solutions. With or without struct.
But I think it will be good to keep them separate. A generic struct will work for this settings but they are still separate formats.

In rpm there is a lot more settings related to the scripts compared to deb packages.
For reference: https://docs.fedoraproject.org/en-US/packaging-guidelines/Scriptlets/#ordering

@FabianLars
Copy link
Member

Right, i meant to re-use the same struct declaration but keep the respective deb/rpm configs, similar to HookCommand for beforeXCommand

@vlabo
Copy link
Contributor Author

vlabo commented Mar 26, 2024

I removed the script structs now the config looks like this:

"bundle": {
      "linux": {
          "deb": {
              "preInstallScript": "./preinst_script.sh",
              "postInstallScript": "./postinst_script.sh",
              "preRemoveScript": "./prerm_script.sh",
              "postRemoveScript": "./postrm_script.sh"
          },
          "rpm": {
              "preInstallScript": "./preinst_script.sh",
              "postInstallScript": "./postinst_script.sh",
              "preRemoveScript": "./prerm_script.sh",
              "postRemoveScript": "./postrm_script.sh"
          }
     }
}

It seem like the cleaner solution to me. But the maintainers opinions is more important.
Please let me know if you want me to change anything before this can be merged.

@amrbashir amrbashir changed the title feat(cli/add): add post/pre install/remove scripts for linux deb and rpm packages feat(bundler): add post/pre install/remove scripts for linux deb and rpm packages Mar 28, 2024
@amrbashir amrbashir merged commit 259d845 into tauri-apps:dev Mar 28, 2024
32 of 33 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants