Unverified Commit c232e09e authored by Yt's avatar Yt Committed by GitHub
Browse files

cargo-tauri: only install .app bundles on Darwin (#499908)

parents d5dcf11d 15a3604e
Loading
Loading
Loading
Loading
+12 −2
Original line number Diff line number Diff line
@@ -48,8 +48,18 @@ makeSetupHook {
    installScript =
      {
        darwin = ''
          mkdir -p $out
          mv "$targetDir"/bundle/macos $out/Applications
          mkdir -p "$out/Applications"

          shopt -s nullglob
          appBundles=("$targetDir"/bundle/macos/*.app)
          shopt -u nullglob

          if [ "''${#appBundles[@]}" -eq 0 ]; then
            echo "cargo-tauri.hook: no .app bundles found in $targetDir/bundle/macos" >&2
            exit 1
          fi

          mv -- "''${appBundles[@]}" "$out/Applications/"
        '';

        linux = ''
+30 −0
Original line number Diff line number Diff line
@@ -64,10 +64,40 @@ stdenv.mkDerivation (finalAttrs: {
  preBuild = ''
    pnpm --filter '@tauri-apps/api' build
  '';
  postBuild = lib.optionalString stdenv.hostPlatform.isDarwin ''
    bundleDir="target/${stdenv.hostPlatform.rust.cargoShortTarget}/''${cargoBuildType:-release}/bundle/macos"
    touch "$bundleDir/.test-hidden-entry"
    touch "$bundleDir/test-visible-entry"
  '';

  # No one should be actually running this, so lets save some time
  buildType = "debug";
  doCheck = false;
  doInstallCheck = stdenv.hostPlatform.isDarwin;
  installCheckPhase = lib.optionalString stdenv.hostPlatform.isDarwin ''
    runHook preInstallCheck

    test -d "$out/Applications"

    shopt -s nullglob dotglob
    appBundles=("$out"/Applications/*.app)
    nonAppEntries=("$out"/Applications/*)
    shopt -u nullglob dotglob

    test "''${#appBundles[@]}" -gt 0

    for entry in "''${nonAppEntries[@]}"; do
      case "$entry" in
        *.app) ;;
        *)
          echo "unexpected non-.app entry in Applications: $entry" >&2
          exit 1
          ;;
      esac
    done

    runHook postInstallCheck
  '';

  meta = {
    inherit (cargo-tauri.hook.meta) platforms;