Skip to content

Commit

Permalink
Fix installer (#129)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
yanw-bq committed May 18, 2023
1 parent 65b890c commit a0edde2
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 47 deletions.
26 changes: 23 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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()
Expand Down
23 changes: 16 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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}.
Expand All @@ -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
Expand Down
21 changes: 12 additions & 9 deletions build_installer.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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
Expand Down
6 changes: 4 additions & 2 deletions wix/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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 Id='${_DEP_FILE_RESULT}' Name='${_DEP_FILE_RESULT}' DiskId='1' Source='${XML_FILE_SOURCE_ARCH}\\${_DEP_FILE_RESULT}' />")
FILE(APPEND "${XML_DEPENDENCIES}" "<File Id='${_DEP_FILE_RESULT_REPLACE}' Name='${_DEP_FILE_RESULT}' DiskId='1' Source='${XML_FILE_SOURCE_ARCH}\\${_DEP_FILE_RESULT}' />")
ENDIF()
ENDFOREACH()
ENDFOREACH()
Expand Down
2 changes: 1 addition & 1 deletion wix/cmake/getodbcversion.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ int main(int argc, char *argv[])
fprintf(fp, "<?define odbc_ver_long=\"%d.%d.%d\" ?>\n", v1, v2, v3);
if (v3 == 0) {
if (v2 == 0)
fprintf(fp, "<?define odbc_ver_prev=\"%d.%d.%d\" ?>\n", v1-1, 999, 999);
fprintf(fp, "<?define odbc_ver_prev=\"%d.%d.%d\" ?>\n", v1-1, 255, 999);
else
fprintf(fp, "<?define odbc_ver_prev=\"%d.%d.%d\" ?>\n", v1, v2-1, 999);
} else {
Expand Down
25 changes: 0 additions & 25 deletions wix/mysql_odbc_fragment.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,6 @@
<Directory Id="INSTALLDIR" Name=".">

<?if $(var.odbc_64bit) = 1 ?>

<Component Id="lib" Guid="5c83cc2b-ed0c-48b7-b265-4bc708f8c16d" SharedDllRefCount="yes" Win64="yes">
<File Id="awsmysqlodbca.lib" Name="awsmysqlodbca.lib" KeyPath="yes" DiskId="1" Source="x64\awsmysqlodbca.lib" />
<File Id="awsmysqlodbcw.lib" Name="awsmysqlodbcw.lib" DiskId="1" Source="x64\awsmysqlodbcw.lib" />
<?if $(var.odbc_pdb) = 1 ?>
<File Id="awsmysqlodbca.lib.pdb" Name="awsmysqlodbca.pdb" DiskId="1" Source="x64\awsmysqlodbca.pdb" />
<File Id="awsmysqlodbcw.lib.pdb" Name="awsmysqlodbcw.pdb" DiskId="1" Source="x64\awsmysqlodbcw.pdb" />
<?endif?>
</Component>
<Component Id="driver" Guid="a2c91917-2d05-45d1-a5dd-4bbea3036133" SharedDllRefCount="yes" Win64="yes">
<File Id="awsmysqlodbca.dll" Name="awsmysqlodbca.dll" Checksum="yes" KeyPath="yes" DiskId="1" Source="x64\awsmysqlodbca.dll"/>
<File Id="awsmysqlodbcw.dll" Name="awsmysqlodbcw.dll" Checksum="yes" DiskId="1" Source="x64\awsmysqlodbcw.dll"/>
Expand All @@ -73,10 +64,6 @@
</Component>
<Component Id="setup" Guid="e706b738-01f6-4a7c-bf4a-eb4599a4abb4" SharedDllRefCount="yes" Win64="yes">
<File Id="awsmysqlodbcS.dll" Name="awsmysqlodbcS.dll" KeyPath="yes" DiskId="1" Source="x64\awsmysqlodbcS.dll" />
<File Id="awsmysqlodbcS.lib" Name="awsmysqlodbcS.lib" DiskId="1" Source="x64\awsmysqlodbcS.lib"/>
<?if $(var.odbc_pdb) = 1 ?>
<File Id="awsmysqlodbcS.lib.pdb" Name="awsmysqlodbcS.pdb" DiskId="1" Source="x64\awsmysqlodbcS.pdb"/>
<?endif?>
</Component>
<Component Id="installer" Guid="4d743672-e573-45e2-8002-8d32866a5ae2" SharedDllRefCount="yes" Win64="yes">
<File Id="installer" Name="myodbc-installer.exe" KeyPath="yes" DiskId="1" Source="x64\myodbc-installer.exe" />
Expand All @@ -86,14 +73,6 @@
<File Id="libssl_1_1_x64.dll" Name="libssl-1_1-x64.dll" DiskId="1" Source="x64\libssl-1_1-x64.dll" />
</Component>
<?else ?>
<Component Id="lib" Guid="f35e60c3-0095-43ed-9414-4bfb2d0b9a60" SharedDllRefCount="yes">
<File Id="awsmysqlodbca.lib" Name="awsmysqlodbca.lib" KeyPath="yes" DiskId="1" Source="x86\awsmysqlodbca.lib" />
<File Id="awsmysqlodbcw.lib" Name="awsmysqlodbcw.lib" DiskId="1" Source="x86\awsmysqlodbcw.lib" />
<?if $(var.odbc_pdb) = 1 ?>
<File Id="awsmysqlodbca.lib.pdb" Name="awsmysqlodbca.pdb" DiskId="1" Source="x86\awsmysqlodbca.pdb" />
<File Id="awsmysqlodbcw.lib.pdb" Name="awsmysqlodbcw.pdb" DiskId="1" Source="x86\awsmysqlodbcw.pdb" />
<?endif?>
</Component>
<Component Id="driver" Guid="2d5f8fc4-4cc3-46b7-9221-f28a5f930ebf" SharedDllRefCount="yes">
<File Id="awsmysqlodbca.dll" Name="awsmysqlodbca.dll" Checksum="yes" KeyPath="yes" DiskId="1" Source="x86\awsmysqlodbca.dll"/>
<File Id="awsmysqlodbcw.dll" Name="awsmysqlodbcw.dll" Checksum="yes" DiskId="1" Source="x86\awsmysqlodbcw.dll"/>
Expand All @@ -105,10 +84,6 @@
</Component>
<Component Id="setup" Guid="80e53cdf-b4fc-4911-a9c2-17853a6c83a8" SharedDllRefCount="yes">
<File Id="awsmysqlodbcS.dll" Name="awsmysqlodbcS.dll" KeyPath="yes" DiskId="1" Source="x86\awsmysqlodbcS.dll" />
<File Id="awsmysqlodbcS.lib" Name="awsmysqlodbcS.lib" DiskId="1" Source="x86\awsmysqlodbcS.lib"/>
<?if $(var.odbc_pdb) = 1 ?>
<File Id="awsmysqlodbcS.lib.pdb" Name="awsmysqlodbcS.pdb" DiskId="1" Source="x86\awsmysqlodbcS.pdb"/>
<?endif?>
</Component>
<Component Id="installer" Guid="dcf4dd91-f481-4333-a276-a0a11cce51ca" SharedDllRefCount="yes">
<File Id="installer" Name="myodbc-installer.exe" KeyPath="yes" DiskId="1" Source="x86\myodbc-installer.exe" />
Expand Down

0 comments on commit a0edde2

Please sign in to comment.