Commit graph

203 commits

Author SHA1 Message Date
Liam Staskawicz
d44b0638bf UpdateDialogCocoa: fix compile error "Update-Installer/src/UpdateDialogCocoa.mm:54:33: error: format string is not a string literal (potentially insecure) [-Werror,-Wformat-security] informativeTextWithFormat: message];" 2013-06-25 11:28:07 -07:00
Robert Knight
4e2e5e9c68 Bump updater version to 0.15
MD-19088 #time 5m
Reviewed-by: Nicolas Esteves
2012-11-26 15:25:26 +00:00
Robert Knight
b60a7a7ba2 Respect the TMPDIR environment variable on Unix
On Mac, this is important as TMPDIR points to a user-specific temp dir
which avoids a potential problem where an app bundle created in the temp dir
running as User A cannot later be replaced by a copy of the updater running
as User B.

MD-19088 #time 30m
Reviewed-by: Nicolas Esteves
2012-11-26 15:25:13 +00:00
Robert Knight
16baf00ee6 Add a dummy file instead of a symlink on Windows
FileUtils.ln_s() is not supported on Windows and the updater
doesn't support symlinks on Windows either.

Create a dummy 'real' file to uninstall instead.

MD-19006
2012-11-06 12:46:04 +00:00
Robert Knight
80fdc5b048 Fix updater failing to uninstall broken symlinks
When checking whether a file exists before uninstalling it, FileUtils::fileExists()
checked whether the link target existed instead of the link itself.  Change fileExists()
to use lstat() instead of stat().

The updater uninstalls files in the order they are listed, if a file and a symlink to it
are both being uninstalled (eg. libMendeley.so.1.6.0 and the symlink libMendeley.so.1.6)
and the real file is removed first, uninstalling the symlink later failed due to the
above issue with uninstalling broken symlinks.

MD-19006
2012-11-06 12:31:41 +00:00
Robert Knight
92ef486dc6 Fix old/new helper binaries in unit tests failing to run on OS X 10.5 if built on OS X 10.7.
Apply the Leopard STL template symbol fix to the helper binaries.
Reviewed-by: Carles Pina
2012-10-29 14:03:51 +00:00
Robert Knight
2a59c6f888 Fix an issue where a build of the updater on OS X 10.7 failed to run under OS X 10.5
Copy the work-around for missing template symbols in the C++ runtime library
from Mendeley Desktop.

See the StackOverflow discussion referenced in the comment for more details.
Reviewed-by: Carles Pina
2012-10-29 12:55:47 +00:00
Robert Knight
0d1f285abb Update the v2_file_list.xml file to match the file_list.xml file
The UpdateScript test requires these files to list the same files
to install in the same order.
Reviewed-by: Carles Pina
2012-10-29 12:39:09 +00:00
Robert Knight
93365a2997 Do a more thorough check that install dir matches the package source dir after installing the update
Compare the package source dir and the post-update install dir recursively and check:

 * There are no unexpected files in the install dir

 * All files in the packaging dir were installed with the correct permissions and content

MD-18896
Reviewed-by: Carles Pina
2012-10-26 18:15:36 +01:00
Robert Knight
de8531c583 Bump updater version to 0.13
MD-18896
Reviewed-by: Carles Pina
2012-10-26 15:13:26 +01:00
Robert Knight
c54ecee1a9 Fix failure to install files in non-pre-existing nested directories during an update
If an update includes a new file 'dir1/dir2/file' where neither 'dir1' nor 'dir2'
already exist, the update fails as it attempts to create 'dir2' without first creating 'dir1'.

Use mkpath() instead of mkdir() to create the dest dir for a file.

MD-18896
Reviewed-by: Carles Pina
2012-10-26 15:12:38 +01:00
Robert Knight
9823b70c5a Fix build using gcc under OS X 10.8
* Change the default SDK from OS X 10.6 to 10.7.
   The 10.6 SDK is no longer bundled with the current version of XCode

 * Add explicit casts for permissions value

MD-18896
Reviewed-by: Carles Pina
2012-10-26 15:12:29 +01:00
Robert Knight
8a5bed77df Bump version number to 0.12 2011-12-01 13:56:16 +00:00
Robert Knight
66bafb317f Fix update failing to install if the system temporary directory path starts with a lower-case letter.
Fix FileUtils::isRelative() to check if the upper-case version of the first character
in the path is a letter.
2011-12-01 11:52:34 +00:00
Robert Knight
99815159b4 Bump version to 0.11 in trunk. 2011-10-19 11:36:59 +01:00
Robert Knight
02fa638261 Fix error creating directories during update when the app is installed to a drive other than C: on Windows.
FileUtils::dirname() did not include the drive letter under Windows and
the return value of dirname() was fed directly to mkpath().

When the drive letter is not specified, mkdir() assumes drive C: -
this either fails if the user does not have access rights to drive C:
or creates a directory in the wrong place.

This commit changes FileUtils::dirname() to include the drive letter
on Windows and adds a test.
2011-10-19 11:30:17 +01:00
Robert Knight
78c14868c6 Bump version number to 0.10 in trunk 2011-10-03 14:33:27 +01:00
Robert Knight
54afb7ca00 Bump version number to 0.9.1 2011-10-03 14:32:52 +01:00
Robert Knight
60357cada9 Allow the --version argument to be used when running updater.exe from a console under Windows
Attach to the parent process's console and re-open stdout/stderr
before attempting to print the version number.
2011-09-27 16:35:20 +01:00
Robert Knight
c9543e59f6 Bump the trunk version number to 0.8 2011-09-27 15:36:02 +01:00
Robert Knight
3319c4ad3e Fix failure to start application after install on Windows systems which do not have the required side-by-side libraries installed system-wide.
It appears that the previous fix was incorrect.  The issue was
not with the current directory used by the process but that
the executable path passed to CreateProcess() used forward
slashes instead of back slashes.  A runtime error in loading
the WinSxS DLLs (the C++ runtime library) resulted.

Although most Windows API functions both back and forward slashes,
this appears not to be the case for loading of side-by-side
DLLs from the application's directory under Windows XP.

This may be related to the LoadLibrary() function whose documentation
specifies that backslashes must be used instead of forward slashes.

This commit converts the executable path to use backslashes before passing
it to CreateProcess() and removes the previous change to alter the
current working directory before starting the main app binary.
2011-09-27 15:30:06 +01:00
Robert Knight
61e8c92550 Merge branch 'master' of ssh://gitweb/git/desktop/standalone-updater 2011-09-16 15:45:41 +01:00
Robert Knight
1898c7de69 Use the secure version of splitpath
Fixes VC++ warning about possible buffer overruns.
2011-09-16 15:43:07 +01:00
Robert Knight
773edb5d53 Reduce Visual C++ compiler warnings
* Disable warnings about unimplemented exception specifications -
   these are implemented by G++ but not VC++.
 * Remove unused variable.
2011-09-16 15:31:39 +01:00
Robert Knight
a0ba0b9a83 Bump trunk version number 2011-09-16 15:19:28 +01:00
Robert Knight
4d1dbe8059 Fix test for return value of GetCurrentDirectory() on Windows.
GetCurrentDirectory() returns zero on error or the length of
the path otherwise.
2011-09-16 15:01:02 +01:00
Robert Knight
61c717e6d6 Temporarily change the current directory to that of the main binary when re-launching the application.
This may be required on Windows so that the application can find libraries
that it depends upon.
2011-09-16 14:35:49 +01:00
Robert Knight
c848cbfe6b Fix Win32 compilation
* Remove accidentally added LOG() call which referenced the Unix-only EROFS constant
 * Rename 'errno' parameter to 'errorCode' so that it does not conflict with the macro of the same name.
2011-09-15 19:08:34 +01:00
Robert Knight
ef9ceb03f0 Add a friendly error message if installation fails due to lack of disk space. 2011-09-15 15:09:19 +01:00
Robert Knight
274b433120 Add an extra new-line in the error dialog that appears if the update cannot be installed. 2011-09-15 15:03:30 +01:00
Robert Knight
92993ea631 Add -d option to the updater test script to run the updater binary under GDB.
Running the updater binary under a debugger makes it easier to attach to the process
and set breakpoints in GDB than trying to start the ruby script itself under GDB and
follow forks until the updater executes.
2011-09-15 14:49:27 +01:00
Robert Knight
1bad51e3dc Display a more helpful message to the user if an update cannot be installed because the application was run from a read-only file system.
On Mac, this can happen if the user runs the app directly from a disk image.  On all platforms,
this can happen if the app is run from any kind of read-only media or network share.

 * Intercept IO errors during installation and try to find a more friendly alternative
   to the OS error string.

 * Catch any IO exceptions throw whilst reverting a partial update and log details.
2011-09-15 14:45:53 +01:00
Robert Knight
972811de23 Bump version number in trunk. 2011-09-15 12:26:34 +01:00
Robert Knight
8bb121daf0 Bump version number 2011-09-14 16:18:56 +01:00
Robert Knight
25ab59b361 Fix compile failure under Windows.
* The WAIT_FAILED error enum value in ProcessUtils.h conflicted
   with Win32 API #define names - use CapitalCase enum names
   instead.

 * Add dummy return value for Windows implementation of FileUtils::fileMode()
2011-09-14 15:57:36 +01:00
Robert Knight
9650a492a9 Fix app icon not being displayed when requesting administrator privleges on Mac.
Previously the application was run from outside a bundle and hence did not
have an app icon - so OS X displayed the generic 'terminal' icon in the elevation
dialog.  The app icon in the dock was set at runtime, but disappeared temporarily
on shutdown when the overridden app icon was replaced with the default icon.

This commit fixes the problem by detecting whether the executable is being
run from within a bundle and if not, creating a minimal app bundle in /tmp
and re-launching the updater from there.
2011-09-14 15:43:57 +01:00
Robert Knight
3fe67e9824 Update the permissions of the destination file to match the source file on Unix with FileUtils::copyFile()
This is necessary so that copied executables can be subsequently run.

This commit also adds a utility function for writing a buffer of data to a file.
2011-09-14 14:44:32 +01:00
Robert Knight
0cad59a19b Fix launching of elevated launcher processes in non-KDE environments.
* Use WEXITSTATUS() to correctly extract the exit status from the 'status'
   value returned by waitpid().  ProcessUtils::runSync() returns a signed value
   so an exit code of -1 would be returned rather than 255.

 * If ProcessUtils::runSync() cannot launch the child process (eg. because the binary
   does not exist), return an exit status that does not conflict with the exit statuses
   used by the sudo front-ends to indicate failed or canceled authentication.

   This alloes runElevatedLinux() to fall back to the next sudo binary only if starting
   the sudo front-end failed.

 * Add documentation on the different behaviors of kdesudo and gksudo with
   respect to exit codes if elevation fails.

 * Improve the description of the task that appears in the GTK sudo front-end.  The application
   is now described just as 'Mendeley Updater' instead of showing the whole command.

 * Only try to use kdesudo in KDE environments, use gksudo otherwise.
2011-09-14 11:31:10 +01:00
Robert Knight
4258ab452d Add --force-elevated option to updater test script to force the updater to request admin privileges.
This is useful when testing the application in cases where elevation
is required and in cases where it is not.
2011-09-14 10:06:34 +01:00
Robert Knight
aa3282b582 Show a more friendly message when requesting elevation under Linux
Under Linux we have control over how the process requesting elevation
describes itself - use this to refer to the updater as 'Mendeley Updater'
rather than 'updater'.
2011-09-13 18:40:34 +01:00
Robert Knight
1768e4525f Add --force-elevated option that causes the updater to request elevation whether it can write to the app install directory or not.
This is useful for testing elevation.
2011-09-13 18:33:14 +01:00
Robert Knight
7bc98f75a6 Add support for installing uncompressed files during update installation.
* In addition to creating symlinks and installing files from .zip packages, support
   copying uncompressed files from the root of the package directory to the installation
   path.

   This is required for installing new versions of the updater itself which is downloaded
   uncompressed to the package installation directory.

 * Replace use of File.absolute_path with File.expand_path for compatibility with Ruby 1.8.7

 * Modify updater test to test installation of the updater binary to the install directory.
2011-09-13 17:24:48 +01:00
Robert Knight
724e91b216 Fix child updater processes receiving the wrong install directory on Windows of the path of the install directory contains spaces.
* Use the same argument quoting logic when launching both elevated
   and non-elevated processes under Windows
 * Include the executable name in the command-line when launching
   a non-elevated process.  Previously the child updater.exe process
   was receiving the '--install-dir' option name in argv[0] and ignoring
   it because it was only looking in argv[1..N-1]
 * Change the install path in the updater test to include a space.

TEST: Ran test-update.rb with space in test install directory
      under elevated/non-elevated cases.
2011-09-13 15:49:39 +01:00
Robert Knight
635fecbd67 Add --version flag to print out the current version of the application. 2011-09-13 10:54:58 +01:00
Robert Knight
31be2336fb Add SIGN_UPDATER build option to automatically sign updater.exe during the build on Windows
This requires a script called sign-updater.bat to be present in PATH
or the build directory for updater.exe to perform the signing.
2011-09-05 16:47:07 +01:00
Robert Knight
c3dee80640 Fix warning about undefined ZIP_FLAGS constant if the zip tool does not support bzip2 2011-09-05 16:17:34 +01:00
Robert Knight
b8e1561155 Use a better test for availability of bzip2
The version of zip on Mac OS 10.6 is >= 3.0 but was not
compiled with bzip2 support.

This test tries to create an empty zip archive with bzip2 compression
and then checks the error message reported.
2011-09-05 16:14:26 +01:00
Robert Knight
364443be24 Use bzip2 in the updater test if the zip tool supports it.
On platforms where the zip tool does not support bzip2, the updater
will still support decompression of bzip2 .zip files because
the updater uses a separate library for zip decompression.
2011-09-05 16:03:08 +01:00
Robert Knight
09b3b2f43a Switch to using Unix chmod values for file permissions instead of values from Qt's QFile::Permission enum
The use of QFile::Permission flag values is a legacy from the old Qt-based updater.
Unix chmod values are used by the native system calls so it makes more sense
to use them instead.

 * Update the test examples and the test update script.
 * Update the package building tool to populate the permissions field with octal chmod values.
2011-09-04 14:53:51 +01:00
Robert Knight
e9c94e99ad Add a note about the assumptions made by Log::writeToStream() with respect to multiple logging processes' clobbering each other's output. 2011-09-02 23:41:02 +01:00