Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 25 additions & 7 deletions Assets/PatchKit Patcher/Editor/PatcherManifestCreator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
}},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why there are four arguments bundled in one structure?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first argument:
"{exedir}" + launchScript is the shell script itself, I figured it'd be fitting to put it in a separate structure.

These four arguments are the required script arguments.

And below that there's also the optional lockfile argument.

It's basically a stylistic choice

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, if it works then it's all right.

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 {
Expand Down
34 changes: 34 additions & 0 deletions Assets/PatchKit Patcher/Editor/UnixLaunchScriptCreator.cs
Original file line number Diff line number Diff line change
@@ -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);
}
}
}
12 changes: 12 additions & 0 deletions Assets/PatchKit Patcher/Editor/UnixLaunchScriptCreator.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions Assets/PatchKit Patcher/Editor/patcher.template.sh
Original file line number Diff line number Diff line change
@@ -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
8 changes: 8 additions & 0 deletions Assets/PatchKit Patcher/Editor/patcher.template.sh.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down