diff options
author | Forkk <forkk@forkk.net> | 2014-01-02 13:38:20 -0600 |
---|---|---|
committer | Forkk <forkk@forkk.net> | 2014-01-02 13:38:20 -0600 |
commit | 17f1864a71b69b9df14d8e06ed48a65e678d09c9 (patch) | |
tree | 4d98a2b3493a26017150d6ba8c5ae0419de3de7d /mmc_updater | |
parent | 4495e20cd7f7f2ab062f3b60f19ac4b79f32c350 (diff) | |
parent | aa5f2c8120cc23de0d57c9f0280512adb9a531b3 (diff) | |
download | MultiMC-17f1864a71b69b9df14d8e06ed48a65e678d09c9.tar MultiMC-17f1864a71b69b9df14d8e06ed48a65e678d09c9.tar.gz MultiMC-17f1864a71b69b9df14d8e06ed48a65e678d09c9.tar.lz MultiMC-17f1864a71b69b9df14d8e06ed48a65e678d09c9.tar.xz MultiMC-17f1864a71b69b9df14d8e06ed48a65e678d09c9.zip |
Merge branch 'develop' of github.com:MultiMC/MultiMC5 into feature_news
Conflicts:
CMakeLists.txt
gui/MainWindow.h
Diffstat (limited to 'mmc_updater')
-rw-r--r-- | mmc_updater/CMakeLists.txt | 8 | ||||
-rw-r--r-- | mmc_updater/src/FileUtils.cpp | 44 | ||||
-rw-r--r-- | mmc_updater/src/Platform.h | 4 | ||||
-rw-r--r-- | mmc_updater/src/UpdateDialogWin32.cpp | 4 | ||||
-rw-r--r-- | mmc_updater/src/UpdateScript.h | 4 | ||||
-rw-r--r-- | mmc_updater/src/UpdaterOptions.cpp | 3 | ||||
-rw-r--r-- | mmc_updater/src/resources/updater.manifest | 27 | ||||
-rw-r--r-- | mmc_updater/src/resources/updater.rc | 30 | ||||
-rw-r--r-- | mmc_updater/src/tests/CMakeLists.txt | 47 | ||||
-rw-r--r-- | mmc_updater/src/tests/TestFileUtils.cpp | 33 | ||||
-rw-r--r-- | mmc_updater/src/tests/TestParseScript.cpp | 24 | ||||
-rw-r--r-- | mmc_updater/src/tests/TestParseScript.h | 8 | ||||
-rw-r--r-- | mmc_updater/src/tests/TestUpdateScript.cpp | 27 | ||||
-rw-r--r-- | mmc_updater/src/tests/TestUpdateScript.h | 8 | ||||
-rw-r--r-- | mmc_updater/src/tests/file_list.xml | 15 | ||||
-rwxr-xr-x | mmc_updater/src/tests/test-update.rb | 218 | ||||
-rw-r--r-- | mmc_updater/src/tests/test.manifest | 27 | ||||
-rw-r--r-- | mmc_updater/src/tests/test.rc | 28 | ||||
-rw-r--r-- | mmc_updater/src/tests/v2_file_list.xml | 67 |
19 files changed, 200 insertions, 426 deletions
diff --git a/mmc_updater/CMakeLists.txt b/mmc_updater/CMakeLists.txt index 61c8cd09..971ac153 100644 --- a/mmc_updater/CMakeLists.txt +++ b/mmc_updater/CMakeLists.txt @@ -9,6 +9,14 @@ include_directories(depends) if (WIN32) include_directories(depends/win32cpp) + # static all the things. The updater must have no dependencies, or it will fail. + if (MINGW) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -static-libgcc -static") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libgcc -static-libstdc++ -static") +#set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "${CMAKE_SHARED_LIBRARY_LINK_C_FLAGS} -static-libgcc -s") +#set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "${CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS} -static-libgcc -static-libstdc++ -s") + endif() + if(MSVC) # - Link the updater binary statically with the Visual C++ runtime # so that the executable can function standalone. diff --git a/mmc_updater/src/FileUtils.cpp b/mmc_updater/src/FileUtils.cpp index 10435e49..712c0c5d 100644 --- a/mmc_updater/src/FileUtils.cpp +++ b/mmc_updater/src/FileUtils.cpp @@ -10,6 +10,8 @@ #include <string.h> #include <fstream> #include <iostream> +// this actually works with mingw32, which we use. +#include <libgen.h> #ifdef PLATFORM_UNIX #include <unistd.h> @@ -19,7 +21,6 @@ #include <sys/time.h> #include <sys/stat.h> #include <errno.h> -#include <libgen.h> #endif FileUtils::IOException::IOException(const std::string& error) @@ -249,59 +250,18 @@ void FileUtils::removeFile(const char* src) throw (IOException) std::string FileUtils::fileName(const char* path) { -#ifdef PLATFORM_UNIX char* pathCopy = strdup(path); std::string basename = ::basename(pathCopy); free(pathCopy); return basename; -#else - char baseName[MAX_PATH]; - char extension[MAX_PATH]; - _splitpath_s(path, - 0, /* drive */ - 0, /* drive length */ - 0, /* dir */ - 0, /* dir length */ - baseName, - MAX_PATH, /* baseName length */ - extension, - MAX_PATH /* extension length */ - ); - return std::string(baseName) + std::string(extension); -#endif } std::string FileUtils::dirname(const char* path) { -#ifdef PLATFORM_UNIX char* pathCopy = strdup(path); std::string dirname = ::dirname(pathCopy); free(pathCopy); return dirname; -#else - char drive[3]; - char dir[MAX_PATH]; - - _splitpath_s(path, - drive, /* drive */ - 3, /* drive length */ - dir, - MAX_PATH, /* dir length */ - 0, /* filename */ - 0, /* filename length */ - 0, /* extension */ - 0 /* extension length */ - ); - - std::string result; - if (drive[0]) - { - result += std::string(drive); - } - result += dir; - - return result; -#endif } void FileUtils::touch(const char* path) throw (IOException) diff --git a/mmc_updater/src/Platform.h b/mmc_updater/src/Platform.h index 6d9afdfb..97867d6a 100644 --- a/mmc_updater/src/Platform.h +++ b/mmc_updater/src/Platform.h @@ -13,7 +13,9 @@ // disable warnings about exception specifications, // which are not implemented in Visual C++ - #pragma warning(disable:4290) + #ifdef MSVC + #pragma warning(disable:4290) + #endif #endif #ifdef __APPLE__ diff --git a/mmc_updater/src/UpdateDialogWin32.cpp b/mmc_updater/src/UpdateDialogWin32.cpp index bdc25437..8b38bed2 100644 --- a/mmc_updater/src/UpdateDialogWin32.cpp +++ b/mmc_updater/src/UpdateDialogWin32.cpp @@ -85,8 +85,8 @@ UpdateDialogWin32::~UpdateDialogWin32() void UpdateDialogWin32::init(int /* argc */, char** /* argv */) { - int width = 300; - int height = 130; + int width = 400; + int height = 150; DWORD style = WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX; m_window.CreateEx(0 /* dwExStyle */, diff --git a/mmc_updater/src/UpdateScript.h b/mmc_updater/src/UpdateScript.h index c825e35d..5c863ff4 100644 --- a/mmc_updater/src/UpdateScript.h +++ b/mmc_updater/src/UpdateScript.h @@ -56,9 +56,7 @@ class UpdateScriptFile } }; -/** Stores information about the packages and files included - * in an update, parsed from an XML file. - */ +/** Stores information about the files included in an update, parsed from an XML file. */ class UpdateScript { public: diff --git a/mmc_updater/src/UpdaterOptions.cpp b/mmc_updater/src/UpdaterOptions.cpp index ae34562d..0945431b 100644 --- a/mmc_updater/src/UpdaterOptions.cpp +++ b/mmc_updater/src/UpdaterOptions.cpp @@ -142,7 +142,7 @@ void UpdaterOptions::parse(int argc, char** argv) showVersion = parser.getFlag("version"); forceElevated = parser.getFlag("force-elevated"); autoClose = parser.getFlag("auto-close"); - + if (installDir.empty()) { // if no --install-dir argument is present, try parsing @@ -152,3 +152,4 @@ void UpdaterOptions::parse(int argc, char** argv) } } + diff --git a/mmc_updater/src/resources/updater.manifest b/mmc_updater/src/resources/updater.manifest new file mode 100644 index 00000000..cafc47d3 --- /dev/null +++ b/mmc_updater/src/resources/updater.manifest @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes"?> +<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3"> + <assemblyIdentity name="MultiMC.Updater.1" type="win32" version="1.0.0.0" /> + <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3"> + <security> + <requestedPrivileges> + <requestedExecutionLevel level="asInvoker" uiAccess="false"/> + </requestedPrivileges> + </security> + </trustInfo> + <dependency> + <dependentAssembly> + <assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="x86" publicKeyToken="6595b64144ccf1df" language="*"/> + </dependentAssembly> + </dependency> + <description>Software updater for MultiMC.</description> + <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1"> + <application> + <!--The ID below indicates app support for Windows Vista --> + <supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/> + <!--The ID below indicates app support for Windows 7 --> + <supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/> + <!--The ID below indicates app support for Windows Developer Preview / Windows 8 --> + <supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/> + </application> + </compatibility> +</assembly>
\ No newline at end of file diff --git a/mmc_updater/src/resources/updater.rc b/mmc_updater/src/resources/updater.rc index 550970a8..9c7c5711 100644 --- a/mmc_updater/src/resources/updater.rc +++ b/mmc_updater/src/resources/updater.rc @@ -1,30 +1,30 @@ +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN +#endif +#include <windows.h> + IDI_APPICON ICON DISCARDABLE "updater.ico" -1 VERSIONINFO -FILEVERSION 0,0,1,0 -PRODUCTVERSION 1,0,1,0 -FILEFLAGSMASK 0X3FL -FILEFLAGS 0X8L -FILEOS 0X40004L -FILETYPE 0X1 -FILESUBTYPE 0 +1 RT_MANIFEST "updater.manifest" + +VS_VERSION_INFO VERSIONINFO +FILEVERSION 1,0,0,0 +FILEOS VOS_NT_WINDOWS32 +FILETYPE VFT_APP BEGIN BLOCK "StringFileInfo" BEGIN BLOCK "000004b0" BEGIN - VALUE "FileVersion", "0.0.1.0" - VALUE "ProductVersion", "1.0.1.0" - VALUE "OriginalFilename", "updater.exe" - VALUE "InternalName", "updater.exe" - VALUE "FileDescription", "Software Update Tool" VALUE "CompanyName", "MultiMC Contributors" + VALUE "FileDescription", "Software Update Tool" + VALUE "FileVersion", "1.0.0.0" VALUE "ProductName", "MultiMC Software Updater" - VALUE "PrivateBuild", "Built by BuildBot" + VALUE "ProductVersion", "1.0" END END BLOCK "VarFileInfo" BEGIN - VALUE "Translation", 0x0000, 0x04b0 + VALUE "Translation", 0x0000, 0x04b0 // Unicode END END
\ No newline at end of file diff --git a/mmc_updater/src/tests/CMakeLists.txt b/mmc_updater/src/tests/CMakeLists.txt index 5de9d096..79402245 100644 --- a/mmc_updater/src/tests/CMakeLists.txt +++ b/mmc_updater/src/tests/CMakeLists.txt @@ -5,21 +5,19 @@ if (APPLE) set(HELPER_SHARED_SOURCES ../StlSymbolsLeopard.cpp) endif() -# Create helper binaries for unit tests -add_executable(oldapp - old_app.cpp - ${HELPER_SHARED_SOURCES} -) -add_executable(newapp - new_app.cpp - ${HELPER_SHARED_SOURCES} -) +# # Create helper binaries for unit tests +# add_executable(oldapp +# old_app.cpp +# ${HELPER_SHARED_SOURCES} +# ) +# add_executable(newapp +# new_app.cpp +# ${HELPER_SHARED_SOURCES} +# ) # Install data files required by unit tests set(TEST_FILES file_list.xml - v2_file_list.xml - test-update.rb ) foreach(TEST_FILE ${TEST_FILES}) @@ -31,21 +29,20 @@ endforeach() # Add unit test binaries macro(ADD_UPDATER_TEST CLASS) - set(TEST_TARGET updater_${CLASS}) - add_executable(${TEST_TARGET} ${CLASS}.cpp) - target_link_libraries(${TEST_TARGET} updatershared) - add_test(NAME ${TEST_TARGET} COMMAND ${TEST_TARGET}) - if (APPLE) - set_target_properties(${TEST_TARGET} PROPERTIES LINK_FLAGS "-framework Security -framework Cocoa") - endif() + set(TEST_TARGET updater_${CLASS}) + unset(srcs) + list(APPEND srcs ${CLASS}.cpp) + if (WIN32) + list(APPEND srcs ${CMAKE_CURRENT_SOURCE_DIR}/test.rc) + endif() + add_executable(${TEST_TARGET} ${srcs}) + target_link_libraries(${TEST_TARGET} updatershared) + add_test(NAME ${TEST_TARGET} COMMAND ${TEST_TARGET}) + if (APPLE) + set_target_properties(${TEST_TARGET} PROPERTIES LINK_FLAGS "-framework Security -framework Cocoa") + endif() endmacro() -add_updater_test(TestUpdateScript) +add_updater_test(TestParseScript) add_updater_test(TestUpdaterOptions) add_updater_test(TestFileUtils) - -# Add updater that that performs a complete update install -# and checks the result -find_program(RUBY_BIN ruby) -add_test(updater_TestUpdateInstall ${RUBY_BIN} test-update.rb) - diff --git a/mmc_updater/src/tests/TestFileUtils.cpp b/mmc_updater/src/tests/TestFileUtils.cpp index 709acc5c..f8535a28 100644 --- a/mmc_updater/src/tests/TestFileUtils.cpp +++ b/mmc_updater/src/tests/TestFileUtils.cpp @@ -5,10 +5,39 @@ void TestFileUtils::testDirName() { + std::string dirName; + std::string fileName; + #ifdef PLATFORM_WINDOWS - std::string dirName = FileUtils::dirname("E:/Some Dir/App.exe"); - TEST_COMPARE(dirName,"E:/Some Dir/"); + // absolute paths + dirName = FileUtils::dirname("E:/Some Dir/App.exe"); + TEST_COMPARE(dirName,"E:/Some Dir"); + fileName = FileUtils::fileName("E:/Some Dir/App.exe"); + TEST_COMPARE(fileName,"App.exe"); + + dirName = FileUtils::dirname("C:/Users/kitteh/AppData/Local/Temp/MultiMC5-yidaaa/MultiMC.exe"); + TEST_COMPARE(dirName,"C:/Users/kitteh/AppData/Local/Temp/MultiMC5-yidaaa"); + fileName = FileUtils::fileName("C:/Users/kitteh/AppData/Local/Temp/MultiMC5-yidaaa/MultiMC.exe"); + TEST_COMPARE(fileName,"MultiMC.exe"); + +#else + // absolute paths + dirName = FileUtils::dirname("/home/tester/foo bar/baz"); + TEST_COMPARE(dirName,"/home/tester/foo bar"); + fileName = FileUtils::fileName("/home/tester/foo bar/baz"); + TEST_COMPARE(fileName,"baz"); #endif + // current directory + dirName = FileUtils::dirname("App.exe"); + TEST_COMPARE(dirName,"."); + fileName = FileUtils::fileName("App.exe"); + TEST_COMPARE(fileName,"App.exe"); + + // relative paths + dirName = FileUtils::dirname("Foo/App.exe"); + TEST_COMPARE(dirName,"Foo"); + fileName = FileUtils::fileName("Foo/App.exe"); + TEST_COMPARE(fileName,"App.exe"); } void TestFileUtils::testIsRelative() diff --git a/mmc_updater/src/tests/TestParseScript.cpp b/mmc_updater/src/tests/TestParseScript.cpp new file mode 100644 index 00000000..f4453957 --- /dev/null +++ b/mmc_updater/src/tests/TestParseScript.cpp @@ -0,0 +1,24 @@ +#include "TestParseScript.h" + +#include "TestUtils.h" +#include "UpdateScript.h" + +#include <iostream> +#include <algorithm> + +void TestParseScript::testParse() +{ + UpdateScript script; + + script.parse("file_list.xml"); + + TEST_COMPARE(script.isValid(),true); +} + +int main(int,char**) +{ + TestList<TestParseScript> tests; + tests.addTest(&TestParseScript::testParse); + return TestUtils::runTest(tests); +} + diff --git a/mmc_updater/src/tests/TestParseScript.h b/mmc_updater/src/tests/TestParseScript.h new file mode 100644 index 00000000..528e97a8 --- /dev/null +++ b/mmc_updater/src/tests/TestParseScript.h @@ -0,0 +1,8 @@ +#pragma once + +class TestParseScript +{ + public: + void testParse(); +}; + diff --git a/mmc_updater/src/tests/TestUpdateScript.cpp b/mmc_updater/src/tests/TestUpdateScript.cpp deleted file mode 100644 index 30a7572a..00000000 --- a/mmc_updater/src/tests/TestUpdateScript.cpp +++ /dev/null @@ -1,27 +0,0 @@ -#include "TestUpdateScript.h" - -#include "TestUtils.h" -#include "UpdateScript.h" - -#include <iostream> -#include <algorithm> - -void TestUpdateScript::testV2Script() -{ - UpdateScript newFormat; - UpdateScript oldFormat; - - newFormat.parse("file_list.xml"); - oldFormat.parse("v2_file_list.xml"); - - TEST_COMPARE(newFormat.filesToInstall(),oldFormat.filesToInstall()); - TEST_COMPARE(newFormat.filesToUninstall(),oldFormat.filesToUninstall()); -} - -int main(int,char**) -{ - TestList<TestUpdateScript> tests; - tests.addTest(&TestUpdateScript::testV2Script); - return TestUtils::runTest(tests); -} - diff --git a/mmc_updater/src/tests/TestUpdateScript.h b/mmc_updater/src/tests/TestUpdateScript.h deleted file mode 100644 index 513513d5..00000000 --- a/mmc_updater/src/tests/TestUpdateScript.h +++ /dev/null @@ -1,8 +0,0 @@ -#pragma once - -class TestUpdateScript -{ - public: - void testV2Script(); -}; - diff --git a/mmc_updater/src/tests/file_list.xml b/mmc_updater/src/tests/file_list.xml index dff4b54f..06ba501d 100644 --- a/mmc_updater/src/tests/file_list.xml +++ b/mmc_updater/src/tests/file_list.xml @@ -1,20 +1,5 @@ <?xml version="1.0"?> <update version="3"> - <targetVersion>2.0</targetVersion> - <platform>Test</platform> - <dependencies> - <!-- The new updater is standalone and has no dependencies, - except for standard system libraries. - !--> - </dependencies> - <packages> - <package> - <name>app-pkg</name> - <hash>$APP_PACKAGE_HASH</hash> - <size>$APP_PACKAGE_SIZE</size> - <source>http://some/dummy/URL</source> - </package> - </packages> <install> <file> <name>$APP_FILENAME</name> diff --git a/mmc_updater/src/tests/test-update.rb b/mmc_updater/src/tests/test-update.rb deleted file mode 100755 index 82965cf4..00000000 --- a/mmc_updater/src/tests/test-update.rb +++ /dev/null @@ -1,218 +0,0 @@ -#!/usr/bin/ruby - -require 'fileutils.rb' -require 'find' -require 'rbconfig' -require 'optparse' - -# Install directory - this contains a space to check -# for correct escaping of paths when passing comamnd -# line arguments under Windows -INSTALL_DIR = File.expand_path("install dir/") -PACKAGE_DIR = File.expand_path("package-dir/") -PACKAGE_SRC_DIR = File.expand_path("package-src-dir/") -IS_WINDOWS = RbConfig::CONFIG['host_os'] =~ /mswin|mingw/ - -if IS_WINDOWS - OLDAPP_NAME = "oldapp.exe" - NEWAPP_NAME = "newapp.exe" - APP_NAME = "app.exe" - UPDATER_NAME = "updater.exe" - ZIP_TOOL = File.expand_path("../zip-tool.exe") -else - OLDAPP_NAME = "oldapp" - NEWAPP_NAME = "newapp" - APP_NAME = "app" - UPDATER_NAME = "updater" - ZIP_TOOL = File.expand_path("../zip-tool") -end - -file_list_vars = { - "APP_FILENAME" => APP_NAME, - "UPDATER_FILENAME" => UPDATER_NAME -} - -def replace_vars(src_file,dest_file,vars) - content = File.read(src_file) - vars.each do |key,value| - content.gsub! "$#{key}",value - end - File.open(dest_file,'w') do |file| - file.print content - end -end - -# Returns true if |src_file| and |dest_file| have the same contents, type -# and permissions or false otherwise -def compare_files(src_file, dest_file) - if File.ftype(src_file) != File.ftype(dest_file) - $stderr.puts "Type of file #{src_file} and #{dest_file} differ" - return false - end - - if File.file?(src_file) && !FileUtils.identical?(src_file, dest_file) - $stderr.puts "Contents of file #{src_file} and #{dest_file} differ" - return false - end - - src_stat = File.stat(src_file) - dest_stat = File.stat(dest_file) - - if src_stat.mode != dest_stat.mode - $stderr.puts "Permissions of #{src_file} and #{dest_file} differ" - return false - end - - return true -end - -# Compares the contents of two directories and returns a map of (file path => change type) -# for files and directories which differ between the two -def compare_dirs(src_dir, dest_dir) - src_dir += '/' if !src_dir.end_with?('/') - dest_dir += '/' if !dest_dir.end_with?('/') - - src_file_map = {} - Find.find(src_dir) do |src_file| - src_file = src_file[src_dir.length..-1] - src_file_map[src_file] = nil - end - - change_map = {} - Find.find(dest_dir) do |dest_file| - dest_file = dest_file[dest_dir.length..-1] - - if !src_file_map.include?(dest_file) - change_map[dest_file] = :deleted - elsif !compare_files("#{src_dir}/#{dest_file}", "#{dest_dir}/#{dest_file}") - change_map[dest_file] = :updated - end - - src_file_map.delete(dest_file) - end - - src_file_map.each do |file| - change_map[file] = :added - end - - return change_map -end - -def create_test_file(name, content) - File.open(name, 'w') do |file| - file.puts content - end - return name -end - -force_elevation = false -run_in_debugger = false - -OptionParser.new do |parser| - parser.on("-f","--force-elevated","Force the updater to elevate itself") do - force_elevation = true - end - parser.on("-d","--debug","Run the updater under GDB") do - run_in_debugger = true - end -end.parse! - -# copy 'src' to 'dest', preserving the attributes -# of 'src' -def copy_file(src, dest) - FileUtils.cp src, dest, :preserve => true -end - -# Remove the install and package dirs if they -# already exist -FileUtils.rm_rf(INSTALL_DIR) -FileUtils.rm_rf(PACKAGE_DIR) -FileUtils.rm_rf(PACKAGE_SRC_DIR) - -# Create the install directory with the old app -Dir.mkdir(INSTALL_DIR) -copy_file OLDAPP_NAME, "#{INSTALL_DIR}/#{APP_NAME}" - -# Create a dummy file to uninstall -uninstall_test_file = create_test_file("#{INSTALL_DIR}/file-to-uninstall.txt", "this file should be removed after the update") -uninstall_test_symlink = if not IS_WINDOWS - FileUtils.ln_s("#{INSTALL_DIR}/file-to-uninstall.txt", "#{INSTALL_DIR}/symlink-to-file-to-uninstall.txt") -else - create_test_file("#{INSTALL_DIR}/symlink-to-file-to-uninstall.txt", "dummy file. this is a symlink on Unix") -end - -# Populate package source dir with files to install -Dir.mkdir(PACKAGE_SRC_DIR) -nested_dir_path = "#{PACKAGE_SRC_DIR}/new-dir/new-dir2" -FileUtils.mkdir_p(nested_dir_path) -FileUtils::chmod 0755, "#{PACKAGE_SRC_DIR}/new-dir" -FileUtils::chmod 0755, "#{PACKAGE_SRC_DIR}/new-dir/new-dir2" -nested_dir_test_file = "#{nested_dir_path}/new-file.txt" -File.open(nested_dir_test_file,'w') do |file| - file.puts "this is a new file in a new nested dir" -end -FileUtils::chmod 0644, nested_dir_test_file -copy_file NEWAPP_NAME, "#{PACKAGE_SRC_DIR}/#{APP_NAME}" -FileUtils::chmod 0755, "#{PACKAGE_SRC_DIR}/#{APP_NAME}" - -# Create .zip packages from source files -Dir.mkdir(PACKAGE_DIR) -Dir.chdir(PACKAGE_SRC_DIR) do - if !system("#{ZIP_TOOL} #{PACKAGE_DIR}/app-pkg.zip .") - raise "Unable to create update package" - end -end - -# Copy the install script and updater to the target -# directory -replace_vars("file_list.xml","#{PACKAGE_DIR}/file_list.xml",file_list_vars) -copy_file "../#{UPDATER_NAME}", "#{PACKAGE_DIR}/#{UPDATER_NAME}" - -# Run the updater using the new syntax -# -# Run the application from the install directory to -# make sure that it looks in the correct directory for -# the file_list.xml file and packages -# -install_path = File.expand_path(INSTALL_DIR) -Dir.chdir(INSTALL_DIR) do - flags = "--force-elevated" if force_elevation - debug_flags = "gdb --args" if run_in_debugger - cmd = "#{debug_flags} #{PACKAGE_DIR}/#{UPDATER_NAME} #{flags} --install-dir \"#{install_path}\" --package-dir \"#{PACKAGE_DIR}\" --script file_list.xml --auto-close" - puts "Running '#{cmd}'" - system(cmd) -end - -# TODO - Correctly wait until updater has finished -sleep(1) - -# Check that the app was updated -app_path = "#{INSTALL_DIR}/#{APP_NAME}" -output = `"#{app_path}"` -if (output.strip != "new app starting") - throw "Updated app produced unexpected output: #{output}" -end - -# Check that the packaged dir and install dir match -dir_diff = compare_dirs(PACKAGE_SRC_DIR, INSTALL_DIR) -ignored_files = ["test-dir", "test-dir/app-symlink", UPDATER_NAME] -have_unexpected_change = false -dir_diff.each do |path, change_type| - if !ignored_files.include?(path) - case change_type - when :added - $stderr.puts "File #{path} was not installed" - when :changed - $stderr.puts "File #{path} differs between install and package dir" - when :deleted - $stderr.puts "File #{path} was not uninstalled" - end - have_unexpected_change = true - end -end - -if have_unexpected_change - throw "Unexpected differences between packaging and update dir" -end - -puts "Test passed" diff --git a/mmc_updater/src/tests/test.manifest b/mmc_updater/src/tests/test.manifest new file mode 100644 index 00000000..8b4dbb98 --- /dev/null +++ b/mmc_updater/src/tests/test.manifest @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes"?> +<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3"> + <assemblyIdentity name="MultiMC.Test.0" type="win32" version="5.0.0.0" /> + <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3"> + <security> + <requestedPrivileges> + <requestedExecutionLevel level="asInvoker" uiAccess="false"/> + </requestedPrivileges> + </security> + </trustInfo> + <dependency> + <dependentAssembly> + <assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="x86" publicKeyToken="6595b64144ccf1df" language="*"/> + </dependentAssembly> + </dependency> + <description>Custom Minecraft launcher for managing multiple installs.</description> + <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1"> + <application> + <!--The ID below indicates app support for Windows Vista --> + <supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/> + <!--The ID below indicates app support for Windows 7 --> + <supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/> + <!--The ID below indicates app support for Windows Developer Preview / Windows 8 --> + <supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/> + </application> + </compatibility> +</assembly>
\ No newline at end of file diff --git a/mmc_updater/src/tests/test.rc b/mmc_updater/src/tests/test.rc new file mode 100644 index 00000000..a288dba6 --- /dev/null +++ b/mmc_updater/src/tests/test.rc @@ -0,0 +1,28 @@ +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN +#endif +#include <windows.h> + +1 RT_MANIFEST "test.manifest" + +VS_VERSION_INFO VERSIONINFO +FILEVERSION 1,0,0,0 +FILEOS VOS_NT_WINDOWS32 +FILETYPE VFT_APP +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "000004b0" + BEGIN + VALUE "CompanyName", "MultiMC Contributors" + VALUE "FileDescription", "Testcase" + VALUE "FileVersion", "1.0.0.0" + VALUE "ProductName", "MultiMC Testcase" + VALUE "ProductVersion", "5" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x0000, 0x04b0 // Unicode + END +END diff --git a/mmc_updater/src/tests/v2_file_list.xml b/mmc_updater/src/tests/v2_file_list.xml deleted file mode 100644 index 202e5bbe..00000000 --- a/mmc_updater/src/tests/v2_file_list.xml +++ /dev/null @@ -1,67 +0,0 @@ -<?xml version="1.0"?> - -<!-- The v2-compatible attribute lets the update script parser - know that it is dealing with a script structured for backwards - compatibility with the MD <= 1.0 updater. -!--> -<update version="3" v2-compatible="true"> - <targetVersion>2.0</targetVersion> - <platform>Test</platform> - <dependencies> - <!-- The new updater is standalone and has no dependencies, - except for standard system libraries and itself. - !--> - </dependencies> - <packages> - <package> - <name>app-pkg</name> - <hash>$APP_PACKAGE_HASH</hash> - <size>$APP_PACKAGE_SIZE</size> - <source>http://some/dummy/URL</source> - </package> - </packages> - - <!-- For compatibility with the update download in MD <= 1.0, - an <install> section lists the packages to download and - the real list of files to install is in the <install-v3> - section. !--> - <install> - <!-- A duplicate of the <packages> section should appear here, - except that each package is listed using the same structure - as files in the install-v3/files section. - !--> - </install> - <install-v3> - <file> - <name>$APP_FILENAME</name> - <hash>$UPDATED_APP_HASH</hash> - <size>$UPDATED_APP_SIZE</size> - <permissions>0755</permissions> - <package>app-pkg</package> - <is-main-binary>true</is-main-binary> - </file> - <file> - <name>$UPDATER_FILENAME</name> - <hash>$UPDATER_HASH</hash> - <size>$UPDATER_SIZE</size> - <permissions>0755</permissions> - </file> - <!-- Test symlink !--> - <file> - <name>test-dir/app-symlink</name> - <target>../app</target> - </file> - <file> - <name>new-dir/new-dir2/new-file.txt</name> - <hash>$TEST_FILENAME</hash> - <size>$TEST_SIZE</size> - <package>app-pkg</package> - <permissions>0644</permissions> - </file> - </install-v3> - <uninstall> - <!-- TODO - List some files to uninstall here !--> - <file>file-to-uninstall.txt</file> - <file>symlink-to-file-to-uninstall.txt</file> - </uninstall> -</update> |