summaryrefslogtreecommitdiff
path: root/indra/viewer_components
diff options
context:
space:
mode:
authorAndrew A. de Laix <alain@lindenlab.com>2010-11-10 14:30:20 -0800
committerAndrew A. de Laix <alain@lindenlab.com>2010-11-10 14:30:20 -0800
commita891cae876ad903e75c9e119584956e4ca4b29ef (patch)
treeee29e1a5386f6dd22a34d52c06a476a4d6e025b1 /indra/viewer_components
parent7eed962a6237f74ec980e06d53886259ef225c55 (diff)
parent41ec2e01ddf12c7d9fc57a115b1e6047560c7e5e (diff)
Automated merge with https://bitbucket.org/mani_linden/viewer-development/
Diffstat (limited to 'indra/viewer_components')
-rw-r--r--indra/viewer_components/updater/llupdateinstaller.cpp44
-rw-r--r--indra/viewer_components/updater/llupdateinstaller.h10
2 files changed, 50 insertions, 4 deletions
diff --git a/indra/viewer_components/updater/llupdateinstaller.cpp b/indra/viewer_components/updater/llupdateinstaller.cpp
index 1bb2101df1..52744b0479 100644
--- a/indra/viewer_components/updater/llupdateinstaller.cpp
+++ b/indra/viewer_components/updater/llupdateinstaller.cpp
@@ -24,15 +24,53 @@
*/
#include "linden_common.h"
+#include <apr_file_io.h>
+#include "llapr.h"
#include "llprocesslauncher.h"
#include "llupdateinstaller.h"
+#include "lldir.h"
-void ll_install_update(std::string const & script, std::string const & updatePath)
+namespace {
+ class RelocateError {};
+
+
+ std::string copy_to_temp(std::string const & path)
+ {
+ std::string scriptFile = gDirUtilp->getBaseFileName(path);
+ std::string newPath = gDirUtilp->getExpandedFilename(LL_PATH_TEMP, scriptFile);
+ apr_status_t status = apr_file_copy(path.c_str(), newPath.c_str(), APR_FILE_SOURCE_PERMS, gAPRPoolp);
+ if(status != APR_SUCCESS) throw RelocateError();
+
+ return newPath;
+ }
+}
+
+
+int ll_install_update(std::string const & script, std::string const & updatePath, LLInstallScriptMode mode)
{
+ std::string finalPath;
+ switch(mode) {
+ case LL_COPY_INSTALL_SCRIPT_TO_TEMP:
+ try {
+ finalPath = copy_to_temp(updatePath);
+ }
+ catch (RelocateError &) {
+ return -1;
+ }
+ break;
+ case LL_RUN_INSTALL_SCRIPT_IN_PLACE:
+ finalPath = updatePath;
+ break;
+ default:
+ llassert(!"unpossible copy mode");
+ }
+
LLProcessLauncher launcher;
launcher.setExecutable(script);
- launcher.addArgument(updatePath);
- launcher.launch();
+ launcher.addArgument(finalPath);
+ int result = launcher.launch();
launcher.orphan();
+
+ return result;
}
diff --git a/indra/viewer_components/updater/llupdateinstaller.h b/indra/viewer_components/updater/llupdateinstaller.h
index 991fe2afe1..310bfe4348 100644
--- a/indra/viewer_components/updater/llupdateinstaller.h
+++ b/indra/viewer_components/updater/llupdateinstaller.h
@@ -30,13 +30,21 @@
#include <string>
+enum LLInstallScriptMode {
+ LL_RUN_INSTALL_SCRIPT_IN_PLACE,
+ LL_COPY_INSTALL_SCRIPT_TO_TEMP
+};
+
//
// Launch the installation script.
//
// The updater will overwrite the current installation, so it is highly recommended
// that the current application terminate once this function is called.
//
-void ll_install_update(std::string const & script, std::string const & updatePath);
+int ll_install_update(
+ std::string const & script, // Script to execute.
+ std::string const & updatePath, // Path to update file.
+ LLInstallScriptMode mode=LL_COPY_INSTALL_SCRIPT_TO_TEMP); // Run in place or copy to temp?
#endif