Skip to content

Commit

Permalink
Moving to go1.21 with newer dependencies, updating build container
Browse files Browse the repository at this point in the history
Making sure libget2 is properly using new stdlib (http client)
Cleaning CMakeLists, old SQL library is not compatible with newer GLIBC
  • Loading branch information
rupor-github committed Nov 26, 2023
1 parent f1c6797 commit a6080cf
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 29 deletions.
9 changes: 6 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 6 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
Expand Down Expand Up @@ -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)

Expand All @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions cmake/FindMariaDB.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
14 changes: 7 additions & 7 deletions docker/Dockerfile.build
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down Expand Up @@ -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

Expand Down
15 changes: 6 additions & 9 deletions src/inpxcreator/cmd/libget2/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions src/inpxcreator/go.mod
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions src/inpxcreator/go.sum
Original file line number Diff line number Diff line change
@@ -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=

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/inpxcreator/vendor/modules.txt
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit a6080cf

Please sign in to comment.