diff --git a/Assets/PatchKit Patcher/Editor/PatcherManifestCreator.cs b/Assets/PatchKit Patcher/Editor/PatcherManifestCreator.cs index b7999af8..44d648e8 100644 --- a/Assets/PatchKit Patcher/Editor/PatcherManifestCreator.cs +++ b/Assets/PatchKit Patcher/Editor/PatcherManifestCreator.cs @@ -40,17 +40,35 @@ private static void PostProcessBuild(BuildTarget buildTarget, string buildPath) File.WriteAllText(manifestPath, manifestContent); } - private static Manifest WindowsManifest(string buildPath) - { - return CommonManifest(buildPath); - } - private static Manifest LinuxManifest(string buildPath) { - return CommonManifest(buildPath); + string patcherExe = Path.GetFileName(buildPath); + string launchScript = UnixLaunchScriptCreator.LaunchScriptName; + + return new Manifest { + ExeFileName = string.Format("\"{{exedir}}/{0}\"", patcherExe), + ExeArguments = "--installdir \"{installdir}\" --secret \"{secret}\"", + + Version = ManifestVersion, + Target = "sh", + Arguments = new Manifest.Argument[] { + new Manifest.Argument { Value = new string[] { + "{exedir}/" + launchScript + }}, + new Manifest.Argument { Value = new string[] { + "{exedir}", + patcherExe, + "{secret}", + "{installdir}" + }}, + new Manifest.Argument { Value = new string[] { + "{lockfile}" + }} + } + }; } - private static Manifest CommonManifest(string buildPath) + private static Manifest WindowsManifest(string buildPath) { string targetFile = Path.GetFileName(buildPath); return new Manifest { diff --git a/Assets/PatchKit Patcher/Editor/UnixLaunchScriptCreator.cs b/Assets/PatchKit Patcher/Editor/UnixLaunchScriptCreator.cs new file mode 100644 index 00000000..4746dd1d --- /dev/null +++ b/Assets/PatchKit Patcher/Editor/UnixLaunchScriptCreator.cs @@ -0,0 +1,34 @@ +using System.IO; +using JetBrains.Annotations; +using Newtonsoft.Json; +using UnityEditor; +using UnityEditor.Callbacks; + +namespace PatchKit.Unity.Editor +{ + public static class UnixLaunchScriptCreator + { + private const string LaunchScriptContentFile = "Assets/PatchKit Patcher/Editor/patcher.template.sh"; + public const string LaunchScriptName = "run.sh"; + + public static string LaunchScriptPath(string buildPath) + { + return Path.Combine(Path.GetDirectoryName(buildPath), LaunchScriptName); + } + + [PostProcessBuild, UsedImplicitly] + private static void PostProcessBuild(BuildTarget buildTarget, string buildPath) + { + if (buildTarget != BuildTarget.StandaloneLinux64 && + buildTarget != BuildTarget.StandaloneLinux && + buildTarget != BuildTarget.StandaloneLinuxUniversal) + { + return; + } + + string launchScriptPath = LaunchScriptPath(buildPath); + + File.Copy(LaunchScriptContentFile, launchScriptPath); + } + } +} \ No newline at end of file diff --git a/Assets/PatchKit Patcher/Editor/UnixLaunchScriptCreator.cs.meta b/Assets/PatchKit Patcher/Editor/UnixLaunchScriptCreator.cs.meta new file mode 100644 index 00000000..f5a6fdc5 --- /dev/null +++ b/Assets/PatchKit Patcher/Editor/UnixLaunchScriptCreator.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 5d3e8400c0d374f7b8ab256464ab130a +timeCreated: 1532511924 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/PatchKit Patcher/Editor/patcher.template.sh b/Assets/PatchKit Patcher/Editor/patcher.template.sh new file mode 100644 index 00000000..6a22ee5f --- /dev/null +++ b/Assets/PatchKit Patcher/Editor/patcher.template.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env sh + +EXEDIR=$1 +PATCHER_EXE=$2 +SECRET=$3 +INSTALLDIR=$4 +LOCKFILE=$5 + +LD_DIRS=`find $EXEDIR -name "x86_64" -printf "%p:"` +LD_DIRS=$LD_DIRS`find $EXEDIR -name "x86" -printf "%p:"` + +export LD_LIBRARY_PATH=$LD_DIRS + +if [ -n $LOCKFILE ] +then + $EXEDIR/$PATCHER_EXE --installdir $INSTALLDIR --secret $SECRET --lockfile $LOCKFILE +else + $EXEDIR/$PATCHER_EXE --installdir $INSTALLDIR --secret $SECRET +fi \ No newline at end of file diff --git a/Assets/PatchKit Patcher/Editor/patcher.template.sh.meta b/Assets/PatchKit Patcher/Editor/patcher.template.sh.meta new file mode 100644 index 00000000..c7b9eb13 --- /dev/null +++ b/Assets/PatchKit Patcher/Editor/patcher.template.sh.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 0dae67bed3a1246349e558cf3f16f036 +timeCreated: 1532513803 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/CHANGELOG.md b/CHANGELOG.md index b3393683..815f67cc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - Animated progress bar during initialization and connecting - New manifest format support - Sending 'patcher_started' event to Statistics Reporting Service +- A launch script on Linux platforms ### Changed - Update API servers configuration