From a6080cf855c38db85405bdfaf0c6612b5d7cfb99 Mon Sep 17 00:00:00 2001 From: rupor-github Date: Sat, 25 Nov 2023 19:28:29 -0500 Subject: [PATCH] Moving to go1.21 with newer dependencies, updating build container Making sure libget2 is properly using new stdlib (http client) Cleaning CMakeLists, old SQL library is not compatible with newer GLIBC --- .gitignore | 9 ++++++--- CMakeLists.txt | 7 ++++++- cmake/FindMariaDB.cmake | 4 ++-- docker/Dockerfile.build | 14 +++++++------- src/inpxcreator/cmd/libget2/main.go | 15 ++++++--------- src/inpxcreator/go.mod | 6 ++++-- src/inpxcreator/go.sum | 4 ++-- .../golang.org/x/net/internal/socks/socks.go | 2 +- src/inpxcreator/vendor/modules.txt | 4 ++-- 9 files changed, 36 insertions(+), 29 deletions(-) diff --git a/.gitignore b/.gitignore index dd37414..7f99aaf 100644 --- a/.gitignore +++ b/.gitignore @@ -25,13 +25,16 @@ build/ [Dd]ebug*/ [Rr]elease*/ -mariadb-??.?.*-linux-glibc_*-x86_64.tar.gz lib2inpx-*.tar.xz +mariadb-??.?.*-linux-systemd-x86_64.tar.gz +mariadb-??.?.*-linux-systemd-x86_64/** +mariadb-??.?.*-linux-systemd-x86.tar.gz +mariadb-??.?.*-linux-systemd-x86/** mariadb-??.?.*-linux-glibc_*-x86_64.tar.gz mariadb-??.?.*-linux-glibc_*-x86_64/** -mariadb-??.?.*-linux-glibc_*-i686.tar.gz -mariadb-??.?.*-linux-glibc_*-i686i/** +mariadb-??.?.*-linux-glibc_*-x86.tar.gz +mariadb-??.?.*-linux-glibc_*-x86/** mariadb-??.?.*-win32.zip mariadb-??.?.*-win32/** mariadb-??.?.*-winx64.zip diff --git a/CMakeLists.txt b/CMakeLists.txt index 11b6a38..ea6ca5e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,7 +13,7 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake) # Project version number set(PRJ_VERSION_MAJOR 9) -set(PRJ_VERSION_MINOR 47) +set(PRJ_VERSION_MINOR 48) if(WIN32 AND NOT DEFINED ENV{MSYSTEM}) message(FATAL_ERROR "Currently unsuppored environment. Use MINGW for Windows builds. CMake willl exit now.") @@ -100,6 +100,10 @@ find_package(Iconv REQUIRED) get_filename_component(MYSQL_NAME ${MYSQL_LIBRARIES} NAME_WE) +if(Threads_FOUND AND "${CMAKE_THREAD_LIBS_INIT}" STREQUAL "") + message(FATAL_ERROR "We are using old version of database library which requires libpthread - not compatible with newer GLIBC") +endif() + # Prepare history file execute_process(COMMAND ${CMAKE_COMMAND} -E env ${GIT_EXECUTABLE} changelog --final-tag ${PRJ_VERSION_MAJOR}.${PRJ_VERSION_MINOR} --stdout OUTPUT_FILE ${PROJECT_BINARY_DIR}/history.txt ERROR_QUIET) @@ -119,6 +123,7 @@ add_executable(lib2inpx ${SRCS_LIB2INPX}) add_dependencies(lib2inpx gen_git_ver) if(UNIX) set(ADD_LIBS "${CMAKE_THREAD_LIBS_INIT} -lm -lrt -ldl -lcrypt -laio") + string(STRIP ${ADD_LIBS} ADD_LIBS) if(ICONV_LIBRARIES MATCHES "libc") target_link_libraries(lib2inpx minizip ${Boost_LIBRARIES} ${MYSQL_LIBRARIES} ${ZLIB_LIBRARIES} ${EXPAT_LIBRARIES} ${ADD_LIBS}) else() diff --git a/cmake/FindMariaDB.cmake b/cmake/FindMariaDB.cmake index f3dc278..8b07326 100644 --- a/cmake/FindMariaDB.cmake +++ b/cmake/FindMariaDB.cmake @@ -10,8 +10,8 @@ if(CMAKE_CROSSCOMPILING OR WIN32) file(GLOB SEARCH_LIBS LIST_DIRECTORIES true "$ENV{MYSQL_DIR}/lib") endif() else() - file(GLOB SEARCH_INCLUDES LIST_DIRECTORIES true "$ENV{HOME}/mariadb-*-linux-glibc*/include/mysql" "${CMAKE_SOURCE_DIR}/mariadb-*-linux-glibc*/include/mysql" "$ENV{MYSQL_DIR}/include") - file(GLOB SEARCH_LIBS LIST_DIRECTORIES true "$ENV{HOME}/mariadb-*-linux-glibc*/lib" "${CMAKE_SOURCE_DIR}/mariadb-*-linux-glibc*/lib" "$ENV{MYSQL_DIR}/lib") + file(GLOB SEARCH_INCLUDES LIST_DIRECTORIES true "$ENV{HOME}/mariadb-*-linux-*/include/mysql" "${CMAKE_SOURCE_DIR}/mariadb-*-linux-*/include/mysql" "$ENV{MYSQL_DIR}/include") + file(GLOB SEARCH_LIBS LIST_DIRECTORIES true "$ENV{HOME}/mariadb-*-linux-*/lib" "${CMAKE_SOURCE_DIR}/mariadb-*-linux-*/lib" "$ENV{MYSQL_DIR}/lib") endif() if(CMAKE_CROSSCOMPILING OR WIN32) diff --git a/docker/Dockerfile.build b/docker/Dockerfile.build index 6e0f3aa..bc366c4 100644 --- a/docker/Dockerfile.build +++ b/docker/Dockerfile.build @@ -8,13 +8,13 @@ apt-get -qqy install tzdata wget curl build-essential git git-extras automake pk WORKDIR /root/ # ---------- We either patch cmake to support up to date boost (/usr/share/cmake-3.5/Modules/FindBoost.cmake) or build fresh one -RUN curl -LO https://cmake.org/files/v3.25/cmake-3.25.3.tar.gz \ - && tar -xvf cmake-3.25.3.tar.gz \ - && cd cmake-3.25.3 \ +RUN curl -LO https://cmake.org/files/v3.27/cmake-3.27.8.tar.gz \ + && tar -xvf cmake-3.27.8.tar.gz \ + && cd cmake-3.27.8 \ && ./bootstrap --system-curl \ && make install \ && cd .. \ - && rm -rf cmake-3.25.3.tar.gz cmake-3.25.3 + && rm -rf cmake-3.27.8.tar.gz cmake-3.27.8 # ---------- mingw does not have expat RUN git clone https://github.com/libexpat/libexpat.git \ @@ -66,9 +66,9 @@ COPY get-maria.sh . RUN ./get-maria.sh # ---------- download golang -RUN curl -LO https://go.dev/dl/go1.20.4.linux-amd64.tar.gz \ - && tar -xvf go1.20.4.linux-amd64.tar.gz \ - && rm go1.20.4.linux-amd64.tar.gz \ +RUN curl -LO https://go.dev/dl/go1.21.4.linux-amd64.tar.gz \ + && tar -xvf go1.21.4.linux-amd64.tar.gz \ + && rm go1.21.4.linux-amd64.tar.gz \ && sed -i -e '$a export PATH=$PATH:/root/go/bin' .bashrc \ && sed -i -e '$a export GOROOT=/root/go' .bashrc diff --git a/src/inpxcreator/cmd/libget2/main.go b/src/inpxcreator/cmd/libget2/main.go index e9b17f1..2c56e6c 100644 --- a/src/inpxcreator/cmd/libget2/main.go +++ b/src/inpxcreator/cmd/libget2/main.go @@ -119,20 +119,17 @@ func httpReq(hostAddr, verb string, start int64) (*http.Response, *time.Timer, e var redirect = func(req *http.Request, via []*http.Request) error { - if len(via) >= 10 { - return errors.New("httpReq: stopped after 10 redirects") + if len(via) >= 5 { + return errors.New("httpReq: stopped after 5 redirects") } if verbose { - fmt.Printf("Detected redirect from \"%s\" to \"%s\"", hostURL.Host, req.URL.Host) + fmt.Printf("Detected redirect from \"%s\" to \"%s\" ", hostURL.String(), req.URL.String()) } if noRedirect { if verbose { - fmt.Printf("\t...Ignoring") + fmt.Printf(" ..Ignoring ") } - req.URL.Host = hostURL.Host - } - if verbose { - fmt.Println() + return http.ErrUseLastResponse } return nil } @@ -313,7 +310,7 @@ func fetchFile(url, tmpIn string, start int64) (tmpOut string, size int64, err e err = fmt.Errorf("fetchFile: %w", err) return } - _, err = out.Seek(start, os.SEEK_SET) + _, err = out.Seek(start, io.SeekStart) if err != nil { err = fmt.Errorf("fetchFile: %w", err) return diff --git a/src/inpxcreator/go.mod b/src/inpxcreator/go.mod index d245fa0..63a97b2 100644 --- a/src/inpxcreator/go.mod +++ b/src/inpxcreator/go.mod @@ -1,5 +1,7 @@ module inpxcreator -go 1.20 +go 1.21 -require golang.org/x/net v0.8.0 +toolchain go1.21.4 + +require golang.org/x/net v0.18.0 diff --git a/src/inpxcreator/go.sum b/src/inpxcreator/go.sum index 6c4f79e..ee9cb73 100644 --- a/src/inpxcreator/go.sum +++ b/src/inpxcreator/go.sum @@ -1,2 +1,2 @@ -golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ= -golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= +golang.org/x/net v0.18.0 h1:mIYleuAkSbHh0tCv7RvjL3F6ZVbLjq4+R7zbOn3Kokg= +golang.org/x/net v0.18.0/go.mod h1:/czyP5RqHAH4odGYxBJ1qz0+CE5WZ+2j1YgoEo8F2jQ= diff --git a/src/inpxcreator/vendor/golang.org/x/net/internal/socks/socks.go b/src/inpxcreator/vendor/golang.org/x/net/internal/socks/socks.go index 97db234..84fcc32 100644 --- a/src/inpxcreator/vendor/golang.org/x/net/internal/socks/socks.go +++ b/src/inpxcreator/vendor/golang.org/x/net/internal/socks/socks.go @@ -289,7 +289,7 @@ func (up *UsernamePassword) Authenticate(ctx context.Context, rw io.ReadWriter, case AuthMethodNotRequired: return nil case AuthMethodUsernamePassword: - if len(up.Username) == 0 || len(up.Username) > 255 || len(up.Password) == 0 || len(up.Password) > 255 { + if len(up.Username) == 0 || len(up.Username) > 255 || len(up.Password) > 255 { return errors.New("invalid username/password") } b := []byte{authUsernamePasswordVersion} diff --git a/src/inpxcreator/vendor/modules.txt b/src/inpxcreator/vendor/modules.txt index e411ebe..899e5d0 100644 --- a/src/inpxcreator/vendor/modules.txt +++ b/src/inpxcreator/vendor/modules.txt @@ -1,4 +1,4 @@ -# golang.org/x/net v0.8.0 -## explicit; go 1.17 +# golang.org/x/net v0.18.0 +## explicit; go 1.18 golang.org/x/net/internal/socks golang.org/x/net/proxy