remove numpy from test, and fix compiling single binary mscp

This commit is contained in:
Ryo Nakamura
2023-03-10 22:06:46 +09:00
parent 2477647a3b
commit d22c02b793
8 changed files with 25 additions and 33 deletions

View File

@@ -32,6 +32,7 @@ if (BUILD_STATIC)
endif()
# add libssh static library
set(CMAKE_POLICY_DEFAULT_CMP0077 NEW)
set(WITH_SERVER OFF)
@@ -47,26 +48,30 @@ add_subdirectory(libssh EXCLUDE_FROM_ALL)
# setup mscp compile options
set(MSCP_COMPILE_OPTS -iquote ${CMAKE_CURRENT_BINARY_DIR}/libssh/include)
set(MSCP_BUILD_INCLUDE_DIRS
${mscp_SOURCE_DIR}/src
${CMAKE_CURRENT_BINARY_DIR}/libssh/include)
set(MSCP_LINK_LIBS ssh-static)
if(BUILD_CONAN)
find_package(ZLIB REQUIRED)
find_package(OpenSSL REQUIRED)
list(APPEND MSCP_LINK_LIBS ZLIB::ZLIB)
list(APPEND MSCP_LINK_LIBS OpenSSL::Crypto)
endif()
set(LIBMSCP_SRC src/mscp.c src/ssh.c src/path.c src/platform.c src/message.c)
# shared libmscp
# libmscp.so
add_library(mscp-shared SHARED ${LIBMSCP_SRC})
target_include_directories(mscp-shared
PUBLIC $<BUILD_INTERFACE:${mscp_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
PRIVATE ${MSCP_BUILD_INCLUDE_DIRS})
target_compile_options(mscp-shared PRIVATE ${MSCP_COMPILE_OPTS})
target_link_libraries(mscp-shared PRIVATE ssh-static)
target_link_libraries(mscp-shared PRIVATE ${MSCP_LINK_LIBS})
set_target_properties(mscp-shared
PROPERTIES
OUTPUT_NAME mscp
@@ -75,12 +80,12 @@ set_target_properties(mscp-shared
install(TARGETS mscp-shared)
# static libmscp
# libmscp.a
add_library(mscp-static STATIC ${LIBMSCP_SRC})
target_include_directories(mscp-static
PRIVATE ${MSCP_BUILD_INCLUDE_DIRS} ${mscp_SOURCE_DIR}/include)
target_compile_options(mscp-static PRIVATE ${MSCP_COMPILE_OPTS})
target_link_libraries(mscp-static PRIVATE ssh-static)
target_link_libraries(mscp-static PRIVATE ${MSCP_LINK_LIBS})
set_target_properties(mscp-static
PROPERTIES
OUTPUT_NAME mscp)
@@ -88,23 +93,12 @@ set_target_properties(mscp-static
install(TARGETS mscp-static)
set(MSCP_LINK_LIBS m pthread)
set(MSCP_LINK_DIRS "")
list(APPEND MSCP_LINK_LIBS ssh-static)
if(BUILD_CONAN)
find_package(ZLIB REQUIRED)
find_package(OpenSSL REQUIRED)
list(APPEND MSCP_LINK_LIBS ZLIB::ZLIB)
list(APPEND MSCP_LINK_LIBS OpenSSL::Crypto)
endif()
# mscp executable
list(APPEND MSCP_LINK_LIBS m pthread)
add_executable(mscp src/main.c)
target_include_directories(mscp
PRIVATE ${MSCP_BUILD_INCLUDE_DIRS} ${mscp_SOURCE_DIR}/include)
target_link_directories(mscp PRIVATE ${MSCP_LINK_DIRS})
target_link_libraries(mscp mscp-static ${MSCP_LINK_LIBS})
if (BUILD_STATIC)
target_link_options(mscp PRIVATE -static)

View File

@@ -10,7 +10,7 @@ RUN apk add --no-cache \
gcc make cmake python3 py3-pip perl linux-headers libc-dev \
openssh bash python3-dev g++
RUN pip3 install conan pytest numpy
RUN pip3 install conan pytest
# Build mscp as a single binary
RUN conan profile detect --force

View File

@@ -9,11 +9,11 @@ RUN cd /etc/yum.repos.d/
RUN sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-*
RUN sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-*
# install numpy and pytest, sshd for test, and rpm-build
# install pytest, sshd for test, and rpm-build
RUN set -ex && yum -y update && yum -y install \
python3 python3-pip openssh openssh-server openssh-clients rpm-build
RUN python3 -m pip install numpy pytest
RUN python3 -m pip install pytest
# preparation for sshd

View File

@@ -4,11 +4,11 @@ ARG mscpdir="/mscp"
COPY . ${mscpdir}
# install numpy and pytest, sshd for test, and rpm-build
# install pytest, sshd for test, and rpm-build
RUN set -ex && yum -y install \
python3 python3-pip openssh openssh-server openssh-clients rpm-build
RUN python3 -m pip install numpy pytest
RUN python3 -m pip install pytest
# preparation for sshd

View File

@@ -8,11 +8,11 @@ COPY . ${mscpdir}
RUN set -ex && apt-get update && apt-get install -y --no-install-recommends \
ca-certificates
# install numpy and pytest, and sshd for test
# install pytest, and sshd for test
RUN apt-get install -y --no-install-recommends \
python3 python3-pip openssh-server
RUN python3 -m pip install numpy pytest
RUN python3 -m pip install pytest
# preparation for sshd

View File

@@ -8,11 +8,11 @@ COPY . ${mscpdir}
RUN set -ex && apt-get update && apt-get install -y --no-install-recommends \
ca-certificates
# install numpy and pytest, and sshd for test
# install pytest, and sshd for test
RUN apt-get install -y --no-install-recommends \
python3 python3-pip openssh-server
RUN python3 -m pip install numpy pytest
RUN python3 -m pip install pytest
# preparation for sshd

View File

@@ -1,6 +1,5 @@
import pytest
import numpy
import hashlib
import os

View File

@@ -1,6 +1,5 @@
import hashlib
import numpy
import os
@@ -39,7 +38,7 @@ class File():
def make_content_random(self):
with open(self.path, "wb") as f:
f.write(numpy.random.bytes(self.size))
f.write(os.urandom(self.size))
def cleanup(self):
os.remove(self.path)