From 6201727bd448ad3b326459b7ee76860127c0561d Mon Sep 17 00:00:00 2001 From: Yan Wang <68562925+yanw-bq@users.noreply.github.com> Date: Tue, 4 Apr 2023 12:01:10 -0700 Subject: [PATCH] Fix installer (#129) * fix minor version exceeding 255, remove lib folder for installer * remove setup lib from installer * add aws sdk component in wix * build aws sdk on release action * workflow dispatch * bundle aws sdk when doing cpack on mac and linux * fix mac installer aws dependencies --- .github/workflows/release.yml | 26 +++++++++++++++++++++++--- CMakeLists.txt | 23 ++++++++++++++++------- build_installer.ps1 | 21 ++++++++++++--------- wix/CMakeLists.txt | 6 ++++-- wix/cmake/getodbcversion.c | 2 +- wix/mysql_odbc_fragment.xml | 25 ------------------------- 6 files changed, 56 insertions(+), 47 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8602bc1c5..3a0cc9b98 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -2,9 +2,9 @@ name: Release Draft # This workflow is triggered on creating tags on: push: - workflow_dispatch: tags: - "*.*.*" + workflow_dispatch: env: BUILD_TYPE: Release @@ -40,7 +40,12 @@ jobs: brew unlink unixodbc brew install libiodbc mysql-client brew link --overwrite --force libiodbc - + + - name: Build and install AWS SDK C++ + working-directory: ./scripts + run: | + ./build_aws_sdk_unix.sh $BUILD_TYPE + - name: Create build environment run: cmake -E make_directory ${{ github.workspace }}/build @@ -51,6 +56,7 @@ jobs: -DMYSQLCLIENT_STATIC_LINKING=true -DODBC_INCLUDES=$ODBC_DM_INCLUDES -DCONNECTOR_PLATFORM=macos + -DBUNDLE_DEPENDENCIES=true - name: Build driver working-directory: ${{ github.workspace }}/build @@ -94,6 +100,11 @@ jobs: curl -L https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-${{ vars.MYSQL_VERSION }}-linux-glibc2.12-x86_64.tar.xz -o mysql.tar.gz tar xf mysql.tar.gz + - name: Build and install AWS SDK C++ + working-directory: ./scripts + run: | + ./build_aws_sdk_unix.sh $BUILD_TYPE + - name: Create build environment shell: bash run: cmake -E make_directory ${{ github.workspace }}/build @@ -107,6 +118,7 @@ jobs: -DWITH_UNIXODBC=1 -DCONNECTOR_PLATFORM=linux -DMYSQL_DIR=./mysql-${{ vars.MYSQL_VERSION }}-linux-glibc2.12-x86_64/ + -DBUNDLE_DEPENDENCIES=true # Build driver - name: Build driver @@ -142,12 +154,20 @@ jobs: curl -L https://cdn.mysql.com/archives/mysql-8.0/mysql-${{ vars.MYSQL_VERSION }}-winx64.zip -o mysql.zip unzip -d C:/ mysql.zip + - name: Add msbuild to PATH + uses: microsoft/setup-msbuild@v1.1 + + - name: Build and install AWS SDK C++ + working-directory: ./scripts + run: | + .\build_aws_sdk_win.ps1 x64 ${{ env.BUILD_TYPE}} ON "${{env.CMAKE_GENERATOR}}" + - name: Setup nmake uses: ilammy/msvc-dev-cmd@v1 - name: Run build installer script run: | - .\build_installer.ps1 x64 $BUILD_TYPE C:/mysql-${{ vars.MYSQL_VERSION }}-winx64 + .\build_installer.ps1 x64 ${{ env.BUILD_TYPE}} "${{env.CMAKE_GENERATOR}}" C:/mysql-${{ vars.MYSQL_VERSION }}-winx64 - name: Upload Windows installer as artifact if: success() diff --git a/CMakeLists.txt b/CMakeLists.txt index 52620a939..c4a338b50 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -796,10 +796,18 @@ endif() set(PLUGINS) # additional bundled dependencies of the client library +if(APPLE) + set(BUNDLED_LIBS + libssl libcrypto ssleay libeay + libaws-c-auth libaws-c-cal libaws-c-common libaws-c-compression libaws-c-event-stream libaws-c-http libaws-c-io + libaws-c-mqtt libaws-c-s3 libaws-c-sdkutils libaws-checksums libaws-cpp-sdk-core libaws-cpp-sdk-rds libaws-cpp-sdk-secretsmanager libaws-crt-cpp + ) +else(APPLE) + set(BUNDLED_LIBS + libssl libcrypto ssleay libeay ${AWSSDK_LINK_LIBRARIES} + ) +endif(APPLE) -set(BUNDLED_LIBS - libssl libcrypto ssleay libeay -) # List plugins and other libraries that can be found bundled with the server # but which are not relevant on client-side and can be safely ignored. @@ -867,10 +875,10 @@ function(bundle_lib lib) endfunction(bundle_lib) macro(copy_lib_for_wix lib) - - get_filename_component(lib_name ${lib} NAME) - configure_file(${lib} ${CMAKE_SOURCE_DIR}/wix/x64/${lib_name} COPYONLY) - + if(WIN32) + get_filename_component(lib_name ${lib} NAME) + configure_file(${lib} ${CMAKE_SOURCE_DIR}/wix/x64/${lib_name} COPYONLY) + endif(WIN32) endmacro(copy_lib_for_wix) # Bundle libraries listed in a list variable ${to_bundle}. @@ -894,6 +902,7 @@ macro(bundle_libs to_bundle ignored) file(GLOB _bundled "${MYSQL_LIB_DIR}/*${CMAKE_SHARED_LIBRARY_SUFFIX}*" "${MYSQL_LIB_DIR}/private/*${CMAKE_SHARED_LIBRARY_SUFFIX}*" + "${CMAKE_SOURCE_DIR}/aws_sdk/install/lib/*${CMAKE_SHARED_LIBRARY_SUFFIX}*" ) # On windows, libs are in bin directory diff --git a/build_installer.ps1 b/build_installer.ps1 index 086c61470..b166e66c6 100644 --- a/build_installer.ps1 +++ b/build_installer.ps1 @@ -45,7 +45,8 @@ Note that building the installer requires the following: $ARCHITECTURE = $args[0] $CONFIGURATION = $args[1] -$MYSQL_DIR = $args[2] +$GENERATOR = $args[2] +$MYSQL_DIR = $args[3] # Set default values if ($null -eq $CONFIGURATION) { @@ -56,20 +57,22 @@ if ($null -eq $MYSQL_DIR) { } # BUILD DRIVER -cmake -S . -G "Visual Studio 16 2019" -DMYSQL_DIR="$MYSQL_DIR" -DMYSQLCLIENT_STATIC_LINKING=TRUE -DCMAKE_BUILD_TYPE="$CONFIGURATION" -DBUNDLE_DEPENDENCIES=TRUE -cmake --build . --config "$CONFIGURATION" +cmake -S . -B ./build -G $GENERATOR -DMYSQL_DIR="$MYSQL_DIR" -DMYSQLCLIENT_STATIC_LINKING=TRUE -DCMAKE_BUILD_TYPE="$CONFIGURATION" -DBUNDLE_DEPENDENCIES=TRUE +cmake --build ./build --config "$CONFIGURATION" # CREATE INSTALLER # Copy dll, installer, and info files to wix folder New-Item -Path .\Wix\x64 -ItemType Directory -Force New-Item -Path .\Wix\x86 -ItemType Directory -Force New-Item -Path .\Wix\doc -ItemType Directory -Force -Copy-Item .\lib\$CONFIGURATION\awsmysqlodbc*.dll .\Wix\x64 -Copy-Item .\lib\$CONFIGURATION\awsmysqlodbc*.lib .\Wix\x64 -Copy-Item .\lib\$CONFIGURATION\awsmysqlodbc*.dll .\Wix\x86 -Copy-Item .\lib\$CONFIGURATION\awsmysqlodbc*.lib .\Wix\x86 -Copy-Item .\bin\$CONFIGURATION\myodbc-installer.exe .\Wix\x64 -Copy-Item .\bin\$CONFIGURATION\myodbc-installer.exe .\Wix\x86 +Copy-Item .\build\lib\$CONFIGURATION\awsmysqlodbc*.dll .\Wix\x64 +Copy-Item .\build\lib\$CONFIGURATION\awsmysqlodbc*.lib .\Wix\x64 +Copy-Item .\build\lib\$CONFIGURATION\aws-*.dll .\Wix\x64 +Copy-Item .\build\lib\$CONFIGURATION\awsmysqlodbc*.dll .\Wix\x86 +Copy-Item .\build\lib\$CONFIGURATION\awsmysqlodbc*.lib .\Wix\x86 +Copy-Item .\build\lib\$CONFIGURATION\aws-*.dll .\Wix\x86 +Copy-Item .\build\bin\$CONFIGURATION\myodbc-installer.exe .\Wix\x64 +Copy-Item .\build\bin\$CONFIGURATION\myodbc-installer.exe .\Wix\x86 Copy-Item .\INFO_BIN .\Wix\doc Copy-Item .\INFO_SRC .\Wix\doc Copy-Item .\ChangeLog .\Wix\doc diff --git a/wix/CMakeLists.txt b/wix/CMakeLists.txt index befea3f2f..2f3281412 100644 --- a/wix/CMakeLists.txt +++ b/wix/CMakeLists.txt @@ -146,7 +146,7 @@ IF(${MSI_64}) SET(XML_DEPS_GUID "BF941AF6-D40E-44AA-81D6-33A75F6FAE8A") ENDIF() -SET(EXCLUDED_FILES "myodbc8a.dll" "myodbc8w.dll" "myodbc8S.dll" +SET(EXCLUDED_FILES "awsmysqlodbca.dll" "awsmysqlodbcw.dll" "awsmysqlodbcS.dll" "libcrypto-1_1-x64.dll" "libcrypto-1_1.dll" "libssl-1_1-x64.dll" "libssl-1_1.dll" "myodbc-installer.exe") @@ -159,9 +159,11 @@ FOREACH(_MASK "*.dll" "*.exe") FOREACH(_DEP_FILE ${DEP_FILE_LIST}) get_filename_component(_DEP_FILE_RESULT ${_DEP_FILE} NAME) LIST(FIND EXCLUDED_FILES ${_DEP_FILE_RESULT} _INDEX_FOUND) + # Replace file name that has "-" with "_" since File Id does not allow "-" + STRING(REPLACE "-" "_" _DEP_FILE_RESULT_REPLACE ${_DEP_FILE_RESULT}) IF(_INDEX_FOUND EQUAL -1) # Add files not in the exclude list - FILE(APPEND "${XML_DEPENDENCIES}" "") + FILE(APPEND "${XML_DEPENDENCIES}" "") ENDIF() ENDFOREACH() ENDFOREACH() diff --git a/wix/cmake/getodbcversion.c b/wix/cmake/getodbcversion.c index bc7433475..a1890f323 100644 --- a/wix/cmake/getodbcversion.c +++ b/wix/cmake/getodbcversion.c @@ -48,7 +48,7 @@ int main(int argc, char *argv[]) fprintf(fp, "\n", v1, v2, v3); if (v3 == 0) { if (v2 == 0) - fprintf(fp, "\n", v1-1, 999, 999); + fprintf(fp, "\n", v1-1, 255, 999); else fprintf(fp, "\n", v1, v2-1, 999); } else { diff --git a/wix/mysql_odbc_fragment.xml b/wix/mysql_odbc_fragment.xml index c0546da5b..03ea1712c 100644 --- a/wix/mysql_odbc_fragment.xml +++ b/wix/mysql_odbc_fragment.xml @@ -53,15 +53,6 @@ - - - - - - - - - @@ -73,10 +64,6 @@ - - - - @@ -86,14 +73,6 @@ - - - - - - - - @@ -105,10 +84,6 @@ - - - -