Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix 'unknown digest type' error. #1

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
13 changes: 2 additions & 11 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,2 @@
.cproject
.project
cmake_install.cmake
CMakeCache.txt
CMakeFiles
Makefile
install_manifest.txt
output/
build/
tools/encrypt_privkey.sh
tools/update_web_files.sh
.idea
cmake-build-debug/
13 changes: 3 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
cmake_minimum_required(VERSION 3.0)
cmake_minimum_required(VERSION 2.8)
project(avalokita)
include(CheckFunctionExists)

check_function_exists(prctl SYSTEM_PRCTL_FOUND)
if(NOT SYSTEM_PRCTL_FOUND)
message(FATAL_ERROR "your os do not support prctl().")
endif()

set(CMAKE_C_FLAGS "-std=gnu89 -Wall -g")
set(VERSION_MAJOR 1)
set(VERSION_MINOR 0)
set(CMAKE_C_FLAGS "-D__RELATIVE_PATH__='\"$(subst ${CMAKE_SOURCE_DIR}/,,$(abspath $<))\"'")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu89 -Wall -Wextra -g")
configure_file(src/config.h.in ${PROJECT_BINARY_DIR}/src/config.h)
add_subdirectory(src)
7 changes: 0 additions & 7 deletions COMAKE

This file was deleted.

9 changes: 1 addition & 8 deletions avalokita.rpm.spec
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,17 @@ Summary: A supervise(daemon tools) enhancement
Name: avalokita
Version: #VERSION#
Release: 1
Source: %{name}.tgz
License: GPL
Packager: liugao02
Group: System Environment/Daemons
URL: https://github.com/ops-baidu/avalokita
BuildRoot: %{_builddir}/%{name}-root

%description
A supervise(daemon tools) enhancement, support daemonize and remote upgrade.

%prep
%setup -q

%build

%install
mkdir -p ${RPM_BUILD_ROOT}/opt/%{name}/bin
install -m 755 bin/%{name} ${RPM_BUILD_ROOT}/opt/%{name}/bin/%{name}
install -m 755 $RPM_BUILD_ROOT/../../../output/bin/%{name} ${RPM_BUILD_ROOT}/opt/%{name}/bin/%{name}

%files
%defattr(-,root,root,-)
Expand Down
81 changes: 27 additions & 54 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,66 +1,39 @@
#!/bin/sh

[ -z "${SCMPF_MODULE_VERSION}" ] && {
SCMPF_MODULE_VERSION=1.0.0.0
}

CMAKE_PATH="$(pwd)/../../noah/thirdparty/cmake/output"
LIBEV_PATH="$(pwd)/../../noah/thirdparty/libev/output"
LIBCURL_PATH="$(pwd)/../../noah/thirdparty/libcurl/output"
OPENSSL_PATH="$(pwd)/../../noah/thirdparty/openssl/output/usr"
ZLIB_PATH="$(pwd)/../../noah/thirdparty/zlib/output/usr"

PATH="$CMAKE_PATH/bin:$LIBEV_PATH/bin:$LIBCURL_PATH/bin:$OPENSSL_PATH/bin:$ZLIB_PATH/bin:$PATH"
export CMAKE_INCLUDE_PATH="$LIBEV_PATH/include:$LIBCURL_PATH/include:$OPENSSL_PATH/include:$ZLIB_PATH/include"
export CMAKE_LIBRARY_PATH="$LIBEV_PATH/lib:$LIBCURL_PATH/lib:$OPENSSL_PATH/lib:$ZLIB_PATH/lib"
set -eu

rm -rf build output && mkdir -p build output

cd thirdparty/curl-7.54.0
./configure --prefix=$(pwd)/../../output --disable-shared --disable-debug \
--without-ssl --without-winssl --without-darwinssl --without-gnutls \
--without-polarssl --without-mbedtls --without-cyassl --without-nss \
--without-axtls --without-libpsl --without-libmetalink \
--without-libssh2 --without-librtmp --without-winidn --without-libidn2 \
--without-nghttp2 --without-zsh-functions-dir --without-ldap-lib \
--without-lber-lib --without-gssapi --disable-rtsp
make -j 16
make install
cd -

rm -rf build output && mkdir -p build && cd build
cmake -DCMAKE_INSTALL_PREFIX=/ ..
cd thirdparty/libev-4.24
./configure --prefix=$(pwd)/../../output --disable-shared
make
make DESTDIR="$(pwd)/../output" install
make install
cd -

cd output
cp -r ../tools .
rm -rf tools/.svn
mkdir avalokita-${SCMPF_MODULE_VERSION}
cp -r bin avalokita-${SCMPF_MODULE_VERSION}
tar --owner=0 --group=0 -czvf avalokita.tgz avalokita-${SCMPF_MODULE_VERSION}
ln avalokita.tgz avalokita-${SCMPF_MODULE_VERSION}.tgz
rm -rf avalokita-${SCMPF_MODULE_VERSION}
cd build
VER=$(git describe --tags --always --dirty | tr '-' '.')
export CMAKE_INCLUDE_PATH="$(pwd)/../output/include"
export CMAKE_LIBRARY_PATH="$(pwd)/../output/lib"
cmake -DCMAKE_INSTALL_PREFIX=/ -DVERSION="$VER" ..
make
make DESTDIR="$(pwd)/../output" install
cd -

mkdir -p rpmroot/{BUILD,RPMS,SOURCES,SPECS,SRPMS,TMP}
cp output/avalokita.tgz rpmroot/SOURCES
rm -rf rpmroot && mkdir -p rpmroot/{BUILD,RPMS,SPECS,TMP}
cp avalokita.rpm.spec rpmroot/SPECS/avalokita.spec
sed -i "s/#VERSION#/${SCMPF_MODULE_VERSION}/g" rpmroot/SPECS/avalokita.spec
sed -i "s/#VERSION#/${VER}/g" rpmroot/SPECS/avalokita.spec
rpmbuild --define "_topdir ${PWD}/rpmroot/" --define "_tmppath %{_topdir}/TMP" -bb rpmroot/SPECS/avalokita.spec
cp -r rpmroot/RPMS/ output
rm -rf rpmroot

mkdir -p debroot/control
echo 2.0 > debroot/debian-binary
cp avalokita.deb.control debroot/control/control
sed -i "s/#VERSION#/${SCMPF_MODULE_VERSION}/g" debroot/control/control

mkdir -p debroot/data/opt/avalokita/bin
install -m 755 output/bin/avalokita debroot/data/opt/avalokita/bin/

cd debroot
find data -type f | xargs md5sum | sed 's/ data\// /g' > control/md5sums
chmod 0644 control/*

cd control
tar --owner=0 --group=0 -czvf ../control.tar.gz *
cd -

cd data
tar --owner=0 --group=0 -czvf ../data.tar.gz *
cd -

ar r avalokita_${SCMPF_MODULE_VERSION}-1_amd64.deb debian-binary control.tar.gz data.tar.gz
mkdir -p ../output/DEBS
cp avalokita_${SCMPF_MODULE_VERSION}-1_amd64.deb ../output/DEBS

cd ..
rm -rf debroot
64 changes: 35 additions & 29 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,39 +1,45 @@
find_path(LIBEV_H NAMES ev.h)
find_library(LIBEV_LIB NAMES ev)
ADD_EXECUTABLE(avalokita main.c)
INSTALL(TARGETS avalokita RUNTIME DESTINATION bin)

if(NOT LIBEV_H OR NOT LIBEV_LIB)
message(FATAL_ERROR "libev not found.")
endif()
if($ENV{CLION_IDE})
INCLUDE_DIRECTORIES(BEFORE ${PROJECT_BINARY_DIR}/src)
TARGET_LINK_LIBRARIES(avalokita m rt dl)
else()
include(CheckFunctionExists)

find_path(CURL_H NAMES curl/curl.h)
find_library(CURL_LIB NAMES curl)
check_function_exists(prctl SYSTEM_PRCTL_FOUND)
if(NOT SYSTEM_PRCTL_FOUND)
message(FATAL_ERROR "your os do not support prctl().")
endif()

if(NOT CURL_H OR NOT CURL_LIB)
message(FATAL_ERROR "libcurl not found.")
endif()
find_path(LIBEV_H NAMES ev.h)
find_library(LIBEV_LIB NAMES libev.a ev)

find_path(SSL_H NAMES openssl/ssl.h)
find_library(SSL_LIB NAMES ssl)
if(NOT LIBEV_H OR NOT LIBEV_LIB)
message(FATAL_ERROR "libev not found.")
endif()

if(NOT SSL_H OR NOT SSL_LIB)
message(FATAL_ERROR "libssl not found.")
endif()
find_path(CURL_H NAMES curl/curl.h)
find_library(CURL_LIB NAMES libcurl.a curl)

find_path(CRYPTO_H NAMES openssl/crypto.h)
find_library(CRYPTO_LIB NAMES crypto)
if(NOT CURL_H OR NOT CURL_LIB)
message(FATAL_ERROR "libcurl not found.")
endif()

if(NOT CRYPTO_H OR NOT CRYPTO_LIB)
message(FATAL_ERROR "libcrypto not found.")
endif()
find_path(CRYPTO_H NAMES openssl/crypto.h)
find_library(CRYPTO_LIB NAMES libcrypto.a crypto)

find_path(Z_H NAMES zlib.h)
find_library(Z_LIB NAMES z)
if(NOT CRYPTO_H OR NOT CRYPTO_LIB)
message(FATAL_ERROR "libcrypto not found.")
endif()

if(NOT Z_H OR NOT Z_LIB)
message(FATAL_ERROR "zlib not found.")
endif()
find_path(Z_H NAMES zlib.h)
find_library(Z_LIB NAMES libz.a z)

ADD_EXECUTABLE(avalokita main.c)
INCLUDE_DIRECTORIES(BEFORE ${PROJECT_BINARY_DIR}/src ${CURL_H} ${LIBEV_H} ${SSL_H} ${CRYPTO_H} ${Z_H})
TARGET_LINK_LIBRARIES(avalokita ${LIBEV_LIB} ${CURL_LIB} ${SSL_LIB} ${CRYPTO_LIB} ${Z_LIB} m rt dl)
INSTALL(TARGETS avalokita RUNTIME DESTINATION bin)
if(NOT Z_H OR NOT Z_LIB)
message(FATAL_ERROR "libz not found.")
endif()

INCLUDE_DIRECTORIES(BEFORE ${PROJECT_BINARY_DIR}/src ${CURL_H} ${LIBEV_H} ${CRYPTO_H} ${Z_H})
TARGET_LINK_LIBRARIES(avalokita ${LIBEV_LIB} ${CURL_LIB} ${CRYPTO_LIB} ${Z_LIB} m dl rt)
endif()
3 changes: 1 addition & 2 deletions src/config.h.in
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
#define VERSION_MAJOR @VERSION_MAJOR@
#define VERSION_MINOR @VERSION_MINOR@
#define VERSION "@VERSION@"
43 changes: 25 additions & 18 deletions src/macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@
#ifndef MACROS_H_
#define MACROS_H_

#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <execinfo.h>
#ifdef __RELATIVE_PATH__
#define __SOURCE__ __RELATIVE_PATH__
#else
#define __SOURCE__ __FILE__
#endif

#include <stddef.h>

#undef offsetof
Expand All @@ -26,37 +28,42 @@
const typeof( ((type *)0)->member ) *__mptr = (ptr); \
(type *)( (char *)__mptr - offsetof(type,member) );})

#define ERROR(fmt, args...) \
do \
{ \
fprintf(stderr, "\033[33m[%s:%d %s()] ERROR: " fmt "\033[0m\n", __FILE__, __LINE__, \
__FUNCTION__, ##args); \
} \
while (0)
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <execinfo.h>

#define ERROR_LIBC(fmt, args...) \
#define INFO(fmt, args...) \
do \
{ \
fprintf(stderr, "\033[33m[%s:%d %s()] ERROR: " fmt ": %s\033[0m\n", __FILE__, __LINE__, \
__FUNCTION__, ##args, strerror(errno)); \
dprintf(1, fmt " \e[36m[%s:%d %s()]\033[0m\n", \
##args, __SOURCE__, __LINE__, __FUNCTION__); \
} \
while (0)

#define INFO(fmt, args...) \
#define ERROR(fmt, args...) \
do \
{ \
fprintf(stdout, "[%s:%d %s()] " fmt "\n", __FILE__, __LINE__, __FUNCTION__, ##args); \
dprintf(2, "\e[33mERROR: " fmt "\033[0m \e[36m[%s:%d %s()]\033[0m\n", \
##args, __SOURCE__, __LINE__, __FUNCTION__); \
} \
while (0)

#define ERROR_LIBC_ERRNO(no, fmt, args...) \
ERROR("libc " fmt ": %s", ##args, strerror(no))

#define ERROR_LIBC(fmt, args...) ERROR_LIBC_ERRNO(errno, fmt, ##args)

#define PRINT_BACK_TRACE() \
do \
{ \
int i = 0, ret = -1; void * back_trace_buffer[64]; \
ret = backtrace(back_trace_buffer, 64); \
fprintf(stderr, "BACK TRACE:\n"); \
fprintf(stderr, "BACK TRACE BEGIN:\n"); \
for (i = 0; i < ret; i++) fprintf(stderr, "%p\n", back_trace_buffer[i]); \
fprintf(stderr, "BACK TRACE END:\n"); \
} \
while (0)

#endif /* LOG_MACROS_H_ */
#endif //MACROS_H_
Loading