mirror of
https://github.com/upa/mscp.git
synced 2026-03-15 04:50:55 +08:00
remove numpy from test, and fix compiling single binary mscp
This commit is contained in:
@@ -32,6 +32,7 @@ if (BUILD_STATIC)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# add libssh static library
|
# add libssh static library
|
||||||
set(CMAKE_POLICY_DEFAULT_CMP0077 NEW)
|
set(CMAKE_POLICY_DEFAULT_CMP0077 NEW)
|
||||||
set(WITH_SERVER OFF)
|
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_COMPILE_OPTS -iquote ${CMAKE_CURRENT_BINARY_DIR}/libssh/include)
|
||||||
set(MSCP_BUILD_INCLUDE_DIRS
|
set(MSCP_BUILD_INCLUDE_DIRS
|
||||||
${mscp_SOURCE_DIR}/src
|
${mscp_SOURCE_DIR}/src
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/libssh/include)
|
${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)
|
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})
|
add_library(mscp-shared SHARED ${LIBMSCP_SRC})
|
||||||
target_include_directories(mscp-shared
|
target_include_directories(mscp-shared
|
||||||
PUBLIC $<BUILD_INTERFACE:${mscp_SOURCE_DIR}/include>
|
PUBLIC $<BUILD_INTERFACE:${mscp_SOURCE_DIR}/include>
|
||||||
$<INSTALL_INTERFACE:include>
|
$<INSTALL_INTERFACE:include>
|
||||||
PRIVATE ${MSCP_BUILD_INCLUDE_DIRS})
|
PRIVATE ${MSCP_BUILD_INCLUDE_DIRS})
|
||||||
target_compile_options(mscp-shared PRIVATE ${MSCP_COMPILE_OPTS})
|
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
|
set_target_properties(mscp-shared
|
||||||
PROPERTIES
|
PROPERTIES
|
||||||
OUTPUT_NAME mscp
|
OUTPUT_NAME mscp
|
||||||
@@ -75,12 +80,12 @@ set_target_properties(mscp-shared
|
|||||||
install(TARGETS mscp-shared)
|
install(TARGETS mscp-shared)
|
||||||
|
|
||||||
|
|
||||||
# static libmscp
|
# libmscp.a
|
||||||
add_library(mscp-static STATIC ${LIBMSCP_SRC})
|
add_library(mscp-static STATIC ${LIBMSCP_SRC})
|
||||||
target_include_directories(mscp-static
|
target_include_directories(mscp-static
|
||||||
PRIVATE ${MSCP_BUILD_INCLUDE_DIRS} ${mscp_SOURCE_DIR}/include)
|
PRIVATE ${MSCP_BUILD_INCLUDE_DIRS} ${mscp_SOURCE_DIR}/include)
|
||||||
target_compile_options(mscp-static PRIVATE ${MSCP_COMPILE_OPTS})
|
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
|
set_target_properties(mscp-static
|
||||||
PROPERTIES
|
PROPERTIES
|
||||||
OUTPUT_NAME mscp)
|
OUTPUT_NAME mscp)
|
||||||
@@ -88,23 +93,12 @@ set_target_properties(mscp-static
|
|||||||
install(TARGETS 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
|
# mscp executable
|
||||||
|
list(APPEND MSCP_LINK_LIBS m pthread)
|
||||||
|
|
||||||
add_executable(mscp src/main.c)
|
add_executable(mscp src/main.c)
|
||||||
target_include_directories(mscp
|
target_include_directories(mscp
|
||||||
PRIVATE ${MSCP_BUILD_INCLUDE_DIRS} ${mscp_SOURCE_DIR}/include)
|
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})
|
target_link_libraries(mscp mscp-static ${MSCP_LINK_LIBS})
|
||||||
if (BUILD_STATIC)
|
if (BUILD_STATIC)
|
||||||
target_link_options(mscp PRIVATE -static)
|
target_link_options(mscp PRIVATE -static)
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ RUN apk add --no-cache \
|
|||||||
gcc make cmake python3 py3-pip perl linux-headers libc-dev \
|
gcc make cmake python3 py3-pip perl linux-headers libc-dev \
|
||||||
openssh bash python3-dev g++
|
openssh bash python3-dev g++
|
||||||
|
|
||||||
RUN pip3 install conan pytest numpy
|
RUN pip3 install conan pytest
|
||||||
|
|
||||||
# Build mscp as a single binary
|
# Build mscp as a single binary
|
||||||
RUN conan profile detect --force
|
RUN conan profile detect --force
|
||||||
|
|||||||
@@ -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/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-*
|
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 \
|
RUN set -ex && yum -y update && yum -y install \
|
||||||
python3 python3-pip openssh openssh-server openssh-clients rpm-build
|
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
|
# preparation for sshd
|
||||||
|
|||||||
@@ -4,11 +4,11 @@ ARG mscpdir="/mscp"
|
|||||||
|
|
||||||
COPY . ${mscpdir}
|
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 \
|
RUN set -ex && yum -y install \
|
||||||
python3 python3-pip openssh openssh-server openssh-clients rpm-build
|
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
|
# preparation for sshd
|
||||||
|
|||||||
@@ -8,11 +8,11 @@ COPY . ${mscpdir}
|
|||||||
RUN set -ex && apt-get update && apt-get install -y --no-install-recommends \
|
RUN set -ex && apt-get update && apt-get install -y --no-install-recommends \
|
||||||
ca-certificates
|
ca-certificates
|
||||||
|
|
||||||
# install numpy and pytest, and sshd for test
|
# install pytest, and sshd for test
|
||||||
RUN apt-get install -y --no-install-recommends \
|
RUN apt-get install -y --no-install-recommends \
|
||||||
python3 python3-pip openssh-server
|
python3 python3-pip openssh-server
|
||||||
|
|
||||||
RUN python3 -m pip install numpy pytest
|
RUN python3 -m pip install pytest
|
||||||
|
|
||||||
|
|
||||||
# preparation for sshd
|
# preparation for sshd
|
||||||
|
|||||||
@@ -8,11 +8,11 @@ COPY . ${mscpdir}
|
|||||||
RUN set -ex && apt-get update && apt-get install -y --no-install-recommends \
|
RUN set -ex && apt-get update && apt-get install -y --no-install-recommends \
|
||||||
ca-certificates
|
ca-certificates
|
||||||
|
|
||||||
# install numpy and pytest, and sshd for test
|
# install pytest, and sshd for test
|
||||||
RUN apt-get install -y --no-install-recommends \
|
RUN apt-get install -y --no-install-recommends \
|
||||||
python3 python3-pip openssh-server
|
python3 python3-pip openssh-server
|
||||||
|
|
||||||
RUN python3 -m pip install numpy pytest
|
RUN python3 -m pip install pytest
|
||||||
|
|
||||||
|
|
||||||
# preparation for sshd
|
# preparation for sshd
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
import numpy
|
|
||||||
import hashlib
|
import hashlib
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
|
|
||||||
import hashlib
|
import hashlib
|
||||||
import numpy
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
|
||||||
@@ -39,7 +38,7 @@ class File():
|
|||||||
|
|
||||||
def make_content_random(self):
|
def make_content_random(self):
|
||||||
with open(self.path, "wb") as f:
|
with open(self.path, "wb") as f:
|
||||||
f.write(numpy.random.bytes(self.size))
|
f.write(os.urandom(self.size))
|
||||||
|
|
||||||
def cleanup(self):
|
def cleanup(self):
|
||||||
os.remove(self.path)
|
os.remove(self.path)
|
||||||
|
|||||||
Reference in New Issue
Block a user