Browse Source

removed elevator script, updateinstaller windows only wip

Krzysztof Krysiński 2 months ago
parent
commit
696dd2c4e5

+ 1 - 3
src/PixiEditor.MacOs/MacOsProcessUtility.cs

@@ -7,11 +7,9 @@ internal class MacOsProcessUtility : IProcessUtility
 {
 {
     public Process RunAsAdmin(string path, string args)
     public Process RunAsAdmin(string path, string args)
     {
     {
-        string assemblyDirectory = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) ?? string.Empty;
-        string elevatorScript = Path.Combine(assemblyDirectory, "elevator.sh");
         string script = $"""
         string script = $"""
 
 
-                                     do shell script "/bin/bash '{elevatorScript}' '{path}' {args}" with administrator privileges
+                                     do shell script "/bin/bash '{path}' {args}" with administrator privileges
                          """;
                          """;
         ProcessStartInfo startInfo = new ProcessStartInfo
         ProcessStartInfo startInfo = new ProcessStartInfo
         {
         {

+ 0 - 6
src/PixiEditor.MacOs/PixiEditor.MacOs.csproj

@@ -10,10 +10,4 @@
       <ProjectReference Include="..\PixiEditor.OperatingSystem\PixiEditor.OperatingSystem.csproj" />
       <ProjectReference Include="..\PixiEditor.OperatingSystem\PixiEditor.OperatingSystem.csproj" />
     </ItemGroup>
     </ItemGroup>
 
 
-    <ItemGroup>
-      <None Include="elevator.sh">
-        <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
-      </None>
-    </ItemGroup>
-
 </Project>
 </Project>

+ 0 - 32
src/PixiEditor.MacOs/elevator.sh

@@ -1,32 +0,0 @@
-#!/bin/bash
-
-# Get the real path to the updater
-EXECUTABLE="$1"
-shift
-
-# Variables for postExecute
-POST_EXECUTE=""
-
-# Rebuild the argument list without --postExecute and its argument
-ARGS=()
-while [[ $# -gt 0 ]]; do
-    case "$1" in
-        --postExecute)
-            shift
-            POST_EXECUTE="$1"
-            shift
-            ;;
-        *)
-            ARGS+=("$1")
-            shift
-            ;;
-    esac
-done
-
-# Run the updater
-"$EXECUTABLE" "${ARGS[@]}"
-
-# Run the postExecute command if set
-if [[ -n "$POST_EXECUTE" ]]; then
-    eval "$POST_EXECUTE"
-fi

+ 0 - 10
src/PixiEditor.UpdateInstaller.Exe/PixiEditor.UpdateInstaller.Exe.csproj

@@ -29,14 +29,4 @@
     <Move SourceFiles="$(PublishDir)PixiEditor.UpdateInstaller.Exe.exe" DestinationFiles="$(PublishDir)PixiEditor.UpdateInstaller.exe"/>
     <Move SourceFiles="$(PublishDir)PixiEditor.UpdateInstaller.Exe.exe" DestinationFiles="$(PublishDir)PixiEditor.UpdateInstaller.exe"/>
     <Message Text="Renamed published executable file." Importance="high"/>
     <Message Text="Renamed published executable file." Importance="high"/>
   </Target>
   </Target>
-
-  <Target Name="RenameBuildUnix" AfterTargets="AfterBuild" Condition="'$(RuntimeIdentifier)'!='win-x64' and '$(RuntimeIdentifier)'!='win-arm64'">
-    <Move SourceFiles="$(OutDir)PixiEditor.UpdateInstaller.Exe" DestinationFiles="$(OutDir)PixiEditor.UpdateInstaller"/>
-    <Message Text="Renamed build executable file." Importance="high"/>
-  </Target>
-
-  <Target Name="RenamePublishUnix" AfterTargets="Publish" Condition="'$(RuntimeIdentifier)'!='win-x64' and '$(RuntimeIdentifier)'!='win-arm64'">
-    <Move SourceFiles="$(PublishDir)PixiEditor.UpdateInstaller.Exe" DestinationFiles="$(PublishDir)PixiEditor.UpdateInstaller"/>
-    <Message Text="Renamed published executable file." Importance="high"/>
-  </Target>
 </Project>
 </Project>

+ 5 - 6
src/PixiEditor/ViewModels/SubViewModels/UpdateViewModel.cs

@@ -108,8 +108,8 @@ internal class UpdateViewModel : SubViewModel<ViewModelMain>
     {
     {
         get => _updateState == UpdateState.UpToDate;
         get => _updateState == UpdateState.UpToDate;
     }
     }
-    
-    public double CurrentProgress 
+
+    public double CurrentProgress
     {
     {
         get => currentProgress;
         get => currentProgress;
         set
         set
@@ -320,13 +320,14 @@ internal class UpdateViewModel : SubViewModel<ViewModelMain>
         {
         {
             if (Path.Exists(updaterPath))
             if (Path.Exists(updaterPath))
             {
             {
+                string updateLocation = Path.GetDirectoryName(Process.GetCurrentProcess().MainModule?.FileName);
+
                 File.Copy(updaterPath,
                 File.Copy(updaterPath,
                     Path.Join(UpdateDownloader.DownloadLocation, $"PixiEditor.UpdateInstaller" + BinaryExtension),
                     Path.Join(UpdateDownloader.DownloadLocation, $"PixiEditor.UpdateInstaller" + BinaryExtension),
                     true);
                     true);
                 updaterPath = Path.Join(UpdateDownloader.DownloadLocation,
                 updaterPath = Path.Join(UpdateDownloader.DownloadLocation,
                     $"PixiEditor.UpdateInstaller" + BinaryExtension);
                     $"PixiEditor.UpdateInstaller" + BinaryExtension);
-                File.WriteAllText(Path.Join(UpdateDownloader.DownloadLocation, "update-location.txt"),
-                    Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) ?? string.Empty);
+                File.WriteAllText(Path.Join(UpdateDownloader.DownloadLocation, "update-location.txt"), updateLocation);
             }
             }
         }
         }
         catch (IOException)
         catch (IOException)
@@ -397,8 +398,6 @@ internal class UpdateViewModel : SubViewModel<ViewModelMain>
             }
             }
             else
             else
             {
             {
-                // couldn't get Process.Start to work correctly with osascript environment
-                args = IOperatingSystem.Current.IsMacOs ? args + " --postExecute 'open -a PixiEditor'" : args;
                 var proc = IOperatingSystem.Current.ProcessUtility.RunAsAdmin(updateExeFile, args);
                 var proc = IOperatingSystem.Current.ProcessUtility.RunAsAdmin(updateExeFile, args);
                 if (IOperatingSystem.Current.IsMacOs)
                 if (IOperatingSystem.Current.IsMacOs)
                 {
                 {