Commit graph

275 commits

Author SHA1 Message Date
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
d5ff1b6bbb Update TODO file. 2011-09-14 11:53:47 +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
c9c19fad3b If no custom updater binary is specified in the arguments to create-packages.rb, use the copy from the install directory. 2011-09-13 11:21:59 +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
47d79bcc6c Add additional documentation on hosting and delivering updates. 2011-09-11 12:18:16 +01:00
Robert Knight
f16ee82f24 Add a LICENSE file.
The project is BSD licensed, but the Mendeley logo graphics / names
are trademarks of Mendeley Ltd. and will need to be replaced if this tool
is re-used in other projects.
2011-09-11 11:46:17 +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
38bb0e8787 Add --bzip2 option to create-packages.rb to use bzip2 compression instead of deflate when creating the .zip packages
This results in smaller packages but the package creation will be slower
and the system 'zip' tool must support bzip2 compression.
2011-09-05 16:33:28 +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
d0ca137fb6 Add bzip2 1.0.6 source from bzip.org and a pre-built libbz2 library for the Windows build.
On Linux and Mac, the system bzip2 library can be used.
2011-09-05 15:47:40 +01:00
build
cdbabeb179 Enable bzip2 decompression support
Build the minizip library with HAVE_BZIP2 and link to libbz2
2011-09-05 14:51:36 +01:00
Robert Knight
4f13ad97b7 Add a note that bzip2 compression with the 'zip' tool requires a recentish version of zip
Looking at some of my test systems:

 * Mac OS 10.5's 'zip' lacks bzip2
 * Mac OS 10.6's 'zip' supports bzip2
 * Debian Lenny's 'zip' lacks bzip2
 * On Windows it depends what version of cygwin is being used.  The version we are currently
   using on build-windows (zip 3.0) supports bzip2.
2011-09-05 10:05:06 +01:00
Robert Knight
39809d4713 Add a note to try using bzip2 instead of the standard compression.
In brief testing, this reduced the file size of an all-in-one zip package
by several MB.  Provided that the zip library can support bzip2 decompression
on all platforms, this would be an easy win to reduce download sizes.
2011-09-04 16:59:46 +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
95b39d66c7 Update the argument list in the --help banner for the create-packages.rb tool. 2011-09-04 12:27:47 +01:00
Robert Knight
29ba43be7c Update the README file.
* Re-organize the sections into a more logical order.
 * Tidy-up the wording of the introduction.
 * Add more details to the section on customizing the updater
2011-09-04 12:26:39 +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
Robert Knight
9c260bc114 Synchronize access to the log's output stream with a mutex and document the write() method as being thread-safe. 2011-09-02 23:32:45 +01:00
Robert Knight
e2d3acf850 Add a note about universal builds on Mac OS X 2011-09-02 14:16:47 +01:00
Robert Knight
2f89332824 Show a useful product name and description in the UAC prompt under Windows Vista/7
Add a VERSION_INFO section to the executable's resource file specifying
the product name and description.

The organization is currently set as 'Mendeley Ltd' - other projects
will want to customize this.

When the produced executable is digitally signed, the product name
and description are shown in the UAC prompt asking for admin
permissions.
2011-09-02 12:53:44 +01:00
Robert Knight
ea7fc49002 Add assert to check that the base path provided to FileUtils::makeAbsolute() is itself absolute. 2011-09-01 20:45:29 +01:00
Robert Knight
483ad4cee0 Fix UpdaterOptions test on Mac. On Mac /tmp is a symlink to /private/tmp 2011-09-01 20:39:56 +01:00
Robert Knight
6ca00a6449 If the --script argument passed to the updater is relative, interpret it as being relative to the package dir rather than the directory that the updater is run from.
Mendeley Desktop <= 1.0 clients pass a relative path for the script argument but
run the updater from the directory containing the main application binary instead
of the package dir.  The script argument, if relative, is therefore treated as
relative to the package directory.
2011-09-01 20:31:51 +01:00
Robert Knight
1fb6d03886 When a test comparison fails, print the actual and expected values that did not match instead of the expressions in the code.
This requires a specialization of TestUtils::toString() for each distinct type,
otherwise a generic message is used.
2011-09-01 19:54:58 +01:00
Robert Knight
b5edffc0b6 Interpret the CurrentDir=$DIR argument on the command line as being relative to the directory containing the main application binary
Mendeley Desktop <= 1.0 clients set CurrentDir to the directory containing the main
application binary rather than the root of the install directory.

Change the parsing in UpdaterOptions and adjust the test accordingly.
2011-09-01 19:53:15 +01:00
Robert Knight
e835036e41 Fix the package name of the original updater not being used when inserting a subtitute updater via the -u command line flag 2011-09-01 17:56:36 +01:00
Robert Knight
6c9c8696fb Fix symlinks to directories in the input directory not being included in the <install> section of the generated file_list.xml
Only exclude plain directories from update packages, not symlinks to directories.
2011-09-01 17:42:46 +01:00
Robert Knight
48084cfdb2 Special handling for the updater binary in the package creation script.
The updater binary is listed as a package on its own but is not
compressed.  The program downloading the update can then download
all packages for the new version including the updater executable
'package' (in reality, just the plain file) and then invoke that updater.

This also allows for substitution of the updater binary with a different
version via the -u parameter.
2011-09-01 17:37:50 +01:00
Robert Knight
9d088dff86 Robustness improvements to the package generator
* Abort if running the zip tool fails
 * Abort if multiple file path rules match a given file
 * Remove part of the special updater binary handling - this needs to be reworked
 * Sort the file paths before feeding them to the zip tool, so that multiple runs with
   with the same set of files will generate the same packages
2011-09-01 15:56:26 +01:00
Robert Knight
b39c71638a Add required --platform and --version arguments to the package creation script and allow the updater binary to be specified with a -u option
These specify the target version for the update and the platform and are embedded
in the <targetVersion> and <platform> elements of the generated file_list.xml file

Ordinarily the script will use the updater binary from the input files directory which
matches the path of the updater binary specified in the package config file.

However it may sometimes be necessary to use a different binary, which can be done
via a -u option.
2011-09-01 12:47:10 +01:00
Robert Knight
7cd04905df Add missing include for Windows builds 2011-08-31 15:52:14 +01:00
Robert Knight
f16b6e9933 Fix compile errors due to size_t -> int/double conversion warnings on 64bit Linux 2011-08-31 12:55:22 +01:00
Robert Knight
cc387031d7 Make the GTK development libraries a build requirement on Linux and remove the ENABLE_GTK #ifdefs in main.cpp 2011-08-31 12:44:03 +01:00
Robert Knight
cb412f4619 Change the documentation in the CMakeLists.txt file to reflect that the available Mac OS SDKs depend on the version of XCode installed as well as the version of Mac OS X
XCode 4 only ships with the 10.6 and 10.7 SDKs, so building for 10.5 requires
XCode 3.2.6, which fortunately is still available from Apple's website.
2011-08-30 18:24:48 +01:00
Robert Knight
8af95a2726 Update the documentation for the GenerateCppResourceFile module 2011-08-30 15:58:07 +01:00
Robert Knight
ea8fcb4e82 Merge branch 'master' of ssh://gitweb/git/desktop/standalone-updater 2011-08-30 15:55:29 +01:00