Commit graph

204 commits

Author SHA1 Message Date
Robert Knight
da2614d427 Change the syntax of the backwards-compatible update scripts.
Instead of moving the whole <update> section to an embedded <update-v3>
node, just use a different name for the <install> section since older
clients will ignore the new <packages> section.

For older clients:

 * The <install> section lists the packages to download.  This will exist
   in addition to the <packages> section.
 * The real <install> section listing the files to install is renamed to
   <install-v3>
2011-08-25 12:23:04 +01:00
Robert Knight
78b3c14260 Print a more useful message when an std::exception is thrown whilst running a test. 2011-08-25 11:52:02 +01:00
Robert Knight
62bf142f06 Fix ProcessUtils compilation on Linux/Mac
* Only compile the Windows command-line conversion function on Windows
2011-08-25 11:38:12 +01:00
Robert Knight
9fa311ebaf Use the embedded application icon for the Update Dialog window 2011-08-24 16:49:47 +01:00
Robert Knight
13b280a4fd Use the correct path to the application icon in updater.rc 2011-08-24 16:38:43 +01:00
Robert Knight
2a1db3927d Add icon to updater executable. Currently this is just the Mendeley Desktop icon. Untested. 2011-08-24 16:34:46 +01:00
Robert Knight
04c9c7204b Make updater.exe a WIN32 GUI application instead of a console application on Windows
* Add WIN32 flag to add_executable() so that cmake generates a GUI application
 * Add WinMain() entry point which converts the unicode command line arguments to ANSI and then calls the standard main() entry point.

 The unit test continues to pass although I am not sure whether
 converting command-line args from Unicode to ANSI will cause problems
 with filenames passed on the command-line that contain non-ANSI
 characters.
2011-08-24 16:11:53 +01:00
Robert Knight
bae300a6a7 Report an error on update installation if the update script cannot be read. 2011-08-24 12:59:51 +01:00
Robert Knight
557dc1273e Update the GTK UI for install errors to match the Mac and Windows UIs
* Display the error details in a message box
 * Set the progress label text appropriately in the event of an error
2011-08-24 12:15:02 +01:00
Robert Knight
ddff071b8c Fix progress percentage calculation broken in recent commit
Multiply the fractional value by 100 instead of multiplying the denominator
of the division operation by 100.
2011-08-24 11:53:13 +01:00
Robert Knight
b4311d79a9 Rename Dir to DirIterator 2011-08-24 11:53:02 +01:00
Robert Knight
887619f239 Add missing variable initialization in Dir class 2011-08-24 11:48:36 +01:00
Robert Knight
a2ea1841b3 Merge branch 'master' of ssh://gitweb/git/desktop/standalone-updater 2011-08-24 11:45:05 +01:00
Robert Knight
3b1452cefe Build the updater with -Wconversion and fix several issues encountered in the process 2011-08-24 11:44:29 +01:00
Robert Knight
b0b3fc4eaa Fix compile errors reported by -Wall -Werror on Mac
Correct argument types and return a value from UpdateDialogCocoa::updateRetryCancel()
2011-08-24 11:30:06 +01:00
Robert Knight
1318576cea Fix comparison between pos and std::string::npos
std::string::npos is defined as the unsigned type size_t but given a value of -1,
resulting in a warning when trying to compare an unsigned int with a size_t.

Fix this by declaring pos as a size_t.
2011-08-24 11:28:32 +01:00
Robert Knight
d922fc3f7a Merge branch 'master' of ssh://gitweb/git/desktop/standalone-updater 2011-08-24 11:25:40 +01:00
Robert Knight
4897f2f8ed Merge branch 'master' of ssh://gitweb/git/desktop/standalone-updater 2011-08-24 11:25:25 +01:00
Robert Knight
f37d469078 Enable -Wall -Werror when building on Linux/Mac and fix several bugs discovered in the process.
* Fix ProcessUtils::runAsyncUnix() not returning a value
 * Fix UpdateDialogGtk::updateRetryCancel() not returning a value
 * Add missing includes in TestUpdaterOptions.cpp
 * Fix unsigned/signed int comparisons
2011-08-24 11:23:48 +01:00
Robert Knight
a6a94f7b10 Merge branch 'master' of ssh://files/git/desktop/standalone-updater 2011-08-24 11:19:29 +01:00
Robert Knight
22d0bd0939 Display details of any update failure in a message box instead of in the progress label on Mac.
This matches the Windows UI and a message box provides more space for text details than
a progress label.
2011-08-24 11:14:39 +01:00
Robert Knight
121b1c9126 Fix crash in Update Dialog on Mac if update installation fails due to use of uninitialized string variable. 2011-08-24 11:02:26 +01:00
Robert Knight
a42e9475b5 Disable the window close button in the update dialog on Mac.
This prevents the dialog being closed part-way through update installation,
leaving the user unable to restart the application afterwards by clicking
the 'Finish' button.
2011-08-24 10:56:08 +01:00
Robert Knight
91f402afa2 Fix warnings about conversion from string literal to char*
UpdaterOptions::parse() will probably not have a need to modify its
arguments but for consistency with the declaration of main() it takes a char*,
so strdup() the strings.
2011-08-24 10:52:07 +01:00
Robert Knight
4c574bde87 Merge branch 'master' of ssh://gitweb/git/desktop/standalone-updater 2011-08-24 10:46:17 +01:00
Robert Knight
3a7b636f42 Fix possible out-of-bounds array access if an empty command-line argument is passed to ProcessUtils::runElevated() on Windows 2011-08-24 10:30:06 +01:00
Robert Knight
61e7561615 Refactor similar UpdateDialogGtk::Message and UpdateDialogWin32::Message class into a single shared UpdateMessage class. 2011-08-24 10:17:57 +01:00
Robert Knight
0ca5928f08 Merge branch 'master' of ssh://gitweb/git/desktop/standalone-updater 2011-08-24 09:38:38 +01:00
Robert Knight
f4199ed706 Remove logging spam 2011-08-23 23:59:09 +01:00
Robert Knight
4f00c51c8f Write log output to a file instead of just stderr
* Log output to a file (currently update-log.txt in the updater's current directory)
 * Use correct stream type for Log::m_output
2011-08-23 23:54:37 +01:00
Robert Knight
a5bf5becad Aesthetic tweaks to the GTK version of the update dialog
* Make the window non-resizable
 * Left-align the label
 * Right-align the 'Finish' button
 * Center the window
2011-08-23 23:46:49 +01:00
Robert Knight
a8dcab1f00 Add handling in the UI for failed update installation under Windows.
In the event of a failed update, display the details in a message
 box and allow the user to restart the old application once the
 update has been reverted.

 Details of the problem will also be written to the log file.
2011-08-23 20:15:57 +01:00
Robert Knight
3a7d41e630 Avoid closing the updater dialog when the window close button is clicked.
This prevents the user closing the dialog whilst the update is in
progress.  Once the update has been installed, the user can click
the 'Finish' button to close the dialog and restart the application.
2011-08-23 20:03:55 +01:00
Robert Knight
448d43c5e0 Remove extra new line 2011-08-23 20:00:06 +01:00
Robert Knight
5cd7d22192 Add Windows implementation of updater dialog
The Windows implementation uses Win++, a thin header-only wrapper
 around the Windows API
2011-08-23 19:53:03 +01:00
Robert Knight
e294c35965 Rename UpdaterOptions::script to UpdaterOptions::scriptPath for clarity 2011-08-23 16:34:34 +01:00
Robert Knight
214f2273b9 Fix warning about object being leaked from update installer thread due to a missing autorelease pool
Allocate an NSAutoreleasePool in the updater thread and release it just
before the thread exits.
2011-08-23 16:30:17 +01:00
Robert Knight
ff21b77ec1 Add a Cocoa UI for the updater on Mac
* Link the updater application with the Cocoa framework on Mac

 * Construct a UI in code and display it when running the main install process.

   Usually UIs on Mac are contained in a .nib file created with Interface Builder
   but in this case the UI is created directly in code to meet the single-binary requirement,
   although it may be possible to bundle the .nib into the binary itself.
2011-08-23 16:20:23 +01:00
Robert Knight
eeeafb2c1a Implement restart of main application once the update is installed.
* Add support for entries in the update script being marked with
   a boolean <is-main-binary> attribute which is set to true for the main binary.
 * In UpdateInstaller::restartMainApp(), look for the file marked with <is-main-binary>
   and restart it after installation.  With the current structure, this requires that
   the main binary is included in the update, which has always been the case up till now.

   If we find that we want to do updates that do not affect the main binary, the
   <is-main-binary> attribute could be replaced with a <main-binary> string value
   at the top of the XML file.
2011-08-23 12:59:04 +01:00
Robert Knight
96b76b0443 Fix incorrect signature for button clicked slot.
The first argument to the slot is the sender widget.
2011-08-23 12:51:35 +01:00
Robert Knight
85c4c58dc9 Add a basic GTK update installation dialog and a stub function in UpdateInstaller to restart the main app after the update is complete.
* Add optional GTK mode to the updater build.  This pulls in a large number of extra dependencies,
   but dependencies which should be fairly ubiquitous on Linux systems.  If these dependencies prove
   to be a problem we could look at providing an alternative, more basic UI and loading the appropriate
   UI dynamically.
 * Implement update progress dialog for GTK.  The dialog needs visual polish but is functional.
2011-08-23 12:29:47 +01:00
Robert Knight
f1367671b6 Use Windows/Unix versions of test binary names in test-update.rb depending on the host OS 2011-08-23 10:31:35 +01:00
Robert Knight
b43d9f33bf Add missing <string.h> include 2011-08-23 09:40:41 +01:00
Robert Knight
e02e0b21c9 Implement process elevation on Windows using code from existing updater 2011-08-22 19:32:01 +01:00
Robert Knight
25e5a1c66c Make FileOps::createSymLink() a no-op which logs a warning under Windows instead of reporting an error.
This allows the cross-platform unit test to pass on Windows, since it includes creation of a symlink.
2011-08-22 19:21:29 +01:00
Robert Knight
7c62b4c7af Fix argv[0] not being correctly set to binary path under Windows
Add the executable to the start of the command line for the new process in ProcessUtils::runAsync()
2011-08-22 19:17:35 +01:00
Robert Knight
66a6afcb01 Fix typo in FileOps::extractFromZip()
Use the correct parameter in the exception message.
2011-08-22 19:08:28 +01:00
Robert Knight
a056e631e4 Adjust the filename of the main app binary to app.exe in the test file_list.xml on Windows 2011-08-22 19:05:31 +01:00
Robert Knight
f35d935eab Add error code from GetLastError() to IOException::what() message 2011-08-22 18:57:03 +01:00
Robert Knight
50a21f004d Implement waiting for parent updater process to finish.
* Set the --wait argument when launching new updater processes with the ID of the process to wait for.
 * Add ProcessUtils::currentProcessId() utility method and PLATFORM_PID define
2011-08-22 18:46:03 +01:00
Robert Knight
57e13d941b Fix dir iteration on Windows
Instead of passing the directory to FindFirstFile(), a wildcard
of the form C:\Path\To\Dir\* needs to be passed.
2011-08-22 18:28:42 +01:00
Robert Knight
66dc8d4720 Catch any file I/O exceptions reported whilst cleaning up the updater directory in UpdateInstaller::cleanup() 2011-08-22 18:04:52 +01:00
Robert Knight
7893fe500a On Windows, look for the zip tool as part of the Cygwin installation instead of relying on it being in the current path.
This is specific to the configuration of build-windows.
2011-08-22 18:03:53 +01:00
Robert Knight
c0d1807252 Implement several FileOps functions under Win32 2011-08-22 18:03:27 +01:00
Robert Knight
2b772611ff Print details of any exceptions that escape UpdateInstaller::run() 2011-08-22 18:02:51 +01:00
Robert Knight
d7ecf3722a Implement ProcessUtils::runAsync() and ProcessUtils::currentProcessPath() on Win32 2011-08-22 18:02:18 +01:00
Robert Knight
b57696aa18 Use the correct binary names in the updater test on Win32.
Binary names on Windows end with '.exe'
2011-08-22 17:02:09 +01:00
Robert Knight
cf606b0cfe Catch IO exceptions when trying to remove the existing write-access test file. 2011-08-22 17:00:15 +01:00
Robert Knight
f8d7cb3b4a Implement FileOps::touch() and FileOps::removeFile() for Win32 2011-08-22 16:59:23 +01:00
Robert Knight
e11cc9193a Fix MSVC++ compile error due to non-const array dimension values. 2011-08-22 16:36:39 +01:00
Robert Knight
b5adf1eb37 Skip compiling the FileOps::toUnixPermissions() helper method on Win32 2011-08-22 15:52:06 +01:00
Robert Knight
48c6a7d5d1 Avoid trying to link against the pthreads library when building on Win32 2011-08-22 15:51:50 +01:00
Robert Knight
fc6101a9ec Add ProcessUtils::runSync() stub for Windows and fix compilation of waitForProcess() 2011-08-22 15:51:15 +01:00
Robert Knight
9530256732 Get Log and UpdaterOptions classes compiling under Win32 2011-08-22 15:50:39 +01:00
Robert Knight
f4c6f1c1d7 Dir iterator implementation for Win32 - Untested 2011-08-22 15:50:15 +01:00
Robert Knight
28b9d50f0a Update the TODO file after Mac testing and make a note that elevation on Mac only works when running the app directly on the Mac (as opposed to over an SSH session). 2011-08-22 14:55:31 +01:00
Robert Knight
8149afd091 Implement ProcessUtils::currentProcessPath() on Mac
This allows the basic updater unit test to pass.
2011-08-22 14:44:16 +01:00
Robert Knight
4d7ddc91d9 Merge branch 'master' of ssh://gitweb/git/desktop/standalone-updater 2011-08-22 14:39:17 +01:00
Robert Knight
07ed391080 Fix incorrect buffer size calculation in ProcessUtils::runAsyncUnix()
The buffer needs one entry for the executable path, args.size()
  args for the supplied arguments and one further entry for the null
  terminator.
2011-08-22 14:37:39 +01:00
Robert Knight
9516887d48 Fix ProcessUtils compilation on Mac
* Enable the Security framework
 * Fix variable names in ProcessUtils::runElevatedMac()
2011-08-22 14:20:26 +01:00
Robert Knight
ced6b097b4 Remove unnecessary <malloc.h> include which is not found on Mac 2011-08-22 14:02:28 +01:00
Robert Knight
5360d05867 Remove dependency on Boost::Thread and use the TinyThread library instead.
This saves the need to install Boost::Thread on each of the build systems.
2011-08-22 14:00:00 +01:00
Robert Knight
d295b0323c Add support for the old-format updater command-line syntax.
The old syntax uses a series of Key=Value pairs, instead of
the more standard "--key value" syntax.

This is required so that the old Mendeley Desktop versions can
launch the new updater.
2011-08-22 12:59:08 +01:00
Robert Knight
a280b5d3d1 Support parsing update scripts structured for backwards compatibility with Mendeley Desktop clients <= 1.0
* Support XML scripts where the V3 script is wrapped in an <update-v3> element.
 * Add some basic unit testing facilities - if we find that something more sophisticated is needed,
   we can look at using cppunit, googletest or similar.
 * Add a test that parsing the same script with both the old and the new structure
   yields equivalent UpdateScript instances.
2011-08-22 12:06:48 +01:00
Robert Knight
c1a5cce3da Convert Qt permission flags (from QFile::Permissions) to Unix mode_t flags.
This fixes the permissions set on files by the updater.
2011-08-22 10:01:25 +01:00
Robert Knight
9a0bee0358 Implement elevation under Linux using one of kdesudo, gksudo or gksu
* Add FileOps::fileName() to get the base name for a file
 * Add ProcessUtils::runSync() to run a process, wait for it to exit and then
   return the status code from that process.
 * Change ProcessUtils::runAsyncUnix() to use execvp() in order to search PATH
   for the specified binary if the filename is not absolute.
2011-08-22 00:32:33 +01:00
Robert Knight
8773a7a622 Fix file uninstallation and add a test
Prepend the install directory to the file path specified in the
<uninstall> section of the XML file to get the path of the file
to remove.

If the file cannot be uninstalled because it does not exist,
log a warning and continue.
2011-08-21 23:41:57 +01:00
Robert Knight
dc303201fa Avoid checking for existence of package when installing symlinks
Only check for the existence of the package for regular files
2011-08-21 23:31:54 +01:00
Robert Knight
be8d6cbc87 Remove temporary updater files after update installation completes.
The cleanup is currently run in another process - on Windows for this to
work the updater will need to be run from outside the temporary installation
directory.  Running the cleanup from the updater binary in the temporary
directory will fail since the binary to be removed will then be in use.

On Linux, Mac the cleanup could just be run from the main update installation
process.
2011-08-21 23:05:25 +01:00
Robert Knight
7c7428a4af Log process ID of child processes launched by ProcessUtils::runAsync() 2011-08-21 23:03:49 +01:00
Robert Knight
1ce064a686 Fix update installer being run twice in each process. 2011-08-21 23:02:59 +01:00
Robert Knight
93274ed348 Use fstream to open and write to log file and include process ID in log entries. 2011-08-21 22:56:33 +01:00
Robert Knight
214814dbbc Add a basic test of the updater for the non-elevated case under Linux
This test compiles two 'versions' of an application,
then runs a script which creates an install directory containing
the 'old' app and a directory containing a file_list.xml update script,
a copy of the updater and a zip file containing the 'new' app.
The script then runs the updater, then runs the installed app
and checks that it is the new version.
2011-08-21 22:07:46 +01:00
Robert Knight
1fdec35cdd Log details of the arguments to each updater process invocation in main() 2011-08-21 21:54:35 +01:00
Robert Knight
5f3745351f Get launching of the main update installer process working in the case where elevation is not required.
* Add ProcessUtils::currentProcessPath() to get the path to the current application
   and add a Linux implementation.
 * Implement ProcessUtils::runAsync() on Unix using fork/execve.
 * Setup updater to run the main installation phase with the correct arguments.
 * Add '.zip' to the package name to get the path of the package file.
2011-08-21 21:51:29 +01:00
Robert Knight
55ebb233cb Add FileOps method to get the canonical path for a file and the Unix implementation. 2011-08-21 21:50:20 +01:00
Robert Knight
b49332eaab Add a log entry if an unrecognized updater mode string is encountered. 2011-08-21 21:49:51 +01:00
Robert Knight
2e285f11a8 Add methods to UpdateScript to retrieve the path which the script was parsed from 2011-08-21 21:48:13 +01:00
Robert Knight
3548f36e8c Add entry type information at the start of each log file entry. 2011-08-21 21:47:33 +01:00
Robert Knight
2efb4fcaf3 Use boost threads to run the update installation on a background thread. 2011-08-20 12:52:47 +01:00
Robert Knight
8e47110231 Add code to launch applications with elevated priviledges on Mac from the old updater. 2011-08-20 12:52:22 +01:00
Robert Knight
44c1937d96 Implement temp package directory removal on Unix. Untested. 2011-08-20 12:11:05 +01:00
Robert Knight
8a29ffd55b Add more detailed logging in the body of UpdateInstaller::run() 2011-08-20 01:01:32 +01:00
Robert Knight
96793d262b Fix FileOps::touch()
creat() returns -1 on error or an fd otherwise which should be closed.
2011-08-20 00:58:09 +01:00
Robert Knight
8df91a76eb Display a more helpful error message if waitpid() fails in ProcessUtils::waitForProcess() 2011-08-20 00:49:41 +01:00
Robert Knight
ceb3b7d6a0 Add more detailed information to any file I/O errors and return true from FileOps::removeFile() if the file does not exist. 2011-08-20 00:46:07 +01:00
Robert Knight
71f197deb7 Add minizip library and use it to implement extraction of files from zip archives. 2011-08-20 00:38:05 +01:00
Robert Knight
fec68e523b Implement Unix version of dirname() 2011-08-19 21:23:55 +01:00
Robert Knight
8fea6c4202 Start implementing the Unix versions of functions in FileOps 2011-08-19 21:20:38 +01:00
Robert Knight
0a6630bc8c Add the core logic for installing and uninstalling files in UpdateInstaller 2011-08-19 21:03:10 +01:00
Robert Knight
e3cec64375 Implement ProcessUtils::waitForProcess() using code from Qt updater
Also fix a typo in UpdateInstaller::run()
2011-08-19 20:08:42 +01:00
Robert Knight
e8e25e7c1c Move intToStr() utility method to StringUtils header 2011-08-19 20:08:15 +01:00
Robert Knight
650e966bfe Set platform defines correctly in Platform.h 2011-08-19 20:07:49 +01:00
Robert Knight
66ade327db WIP - Standalone update installer with no dependency on Qt 2011-08-19 19:59:21 +01:00