From b958911c633b289601d4ddbbbcf67d2a94de871f Mon Sep 17 00:00:00 2001 From: Aparajita Fishman Date: Sat, 16 Jul 2011 21:36:26 +0300 Subject: [PATCH] Support for postinstall scripts --- Tools/capp/Generate.j | 15 +++++++++++++++ Tools/capp/capp.1 | 14 ++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/Tools/capp/Generate.j b/Tools/capp/Generate.j index a1cf01707..ad62f78de 100644 --- a/Tools/capp/Generate.j +++ b/Tools/capp/Generate.j @@ -189,6 +189,8 @@ function gen(/*va_args*/) { fail("The directory " + FILE.absolute(destinationProject) + " already exists."); } + + executePostInstallScript(destinationProject); } function createFrameworksInFile(/*Array*/ frameworks, /*String*/ aFile, /*Boolean*/ symlink, /*Boolean*/ build, /*Boolean*/ force) @@ -365,6 +367,19 @@ function listFrameworks() }); } +function executePostInstallScript(/*String*/ destinationProject) +{ + var path = FILE.join(destinationProject, "postinstall"); + + if (FILE.exists(path)) + { + stream.print(colorize("Executing postinstall script...", "cyan")); + + OS.system(["/bin/sh", path, destinationProject]); // Use sh in case it isn't marked executable + FILE.remove(path); + } +} + function colorize(message, color) { return "\0" + color + "(" + message + "\0)"; diff --git a/Tools/capp/capp.1 b/Tools/capp/capp.1 index cc8e4919e..9acb8e9c8 100644 --- a/Tools/capp/capp.1 +++ b/Tools/capp/capp.1 @@ -88,6 +88,20 @@ or This is a handy shortcut for .Sy --symlink --build. .El +.Ss Postinstall scripts +After copying the chosen template, replacing placeholders, and installing the frameworks, +if +.Nm +finds a file named "postinstall", it will be executed using +.Sy sh. +The script receives a single parameter which is the directory of the generated project. +Scripts should reference files in the project relative to that directory. +.Pp +After executing the +.Sy postinstall +script, +.Nm +deletes it from the generated project. .\"----------------------------------------------------------------------------------------- .Sh CONFIGURING .\"-----------------------------------------------------------------------------------------