From 4d0b1d5d6c7b1033bd0dc5b04257f7b816c396d7 Mon Sep 17 00:00:00 2001 From: EnumDev Date: Thu, 4 Dec 2025 15:34:11 +0200 Subject: [PATCH] Initial commit --- .gitignore | 2 + check-version.sh | 15 ++++++ pkg.info | 23 ++++++++ source-files/event_sizeof_time_t.patch | 37 +++++++++++++ source-files/openssl-compat.patch | 74 ++++++++++++++++++++++++++ source.sh | 37 +++++++++++++ 6 files changed, 188 insertions(+) create mode 100644 .gitignore create mode 100644 check-version.sh create mode 100644 pkg.info create mode 100644 source-files/event_sizeof_time_t.patch create mode 100644 source-files/openssl-compat.patch create mode 100644 source.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3e58e5f --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +# Exclude bpm archives +*.bpm \ No newline at end of file diff --git a/check-version.sh b/check-version.sh new file mode 100644 index 0000000..a7c6f2c --- /dev/null +++ b/check-version.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +# Github repository +REPO="libevent/libevent" + +# Get tag name using Github Rest API +TAG_NAME=$(curl -s -L -H "X-GitHub-Api-Version: 2022-11-28" -H "Authorization: token ${GITHUB_API_TOKEN}" https://api.github.com/repos/"$REPO"/releases/latest | jq -r '.tag_name') + +# Trim prefix +VERSION=${TAG_NAME//release-/} + +# Trim suffix +VERSION=${VERSION//-stable/} + +echo "$VERSION" diff --git a/pkg.info b/pkg.info new file mode 100644 index 0000000..e5e8266 --- /dev/null +++ b/pkg.info @@ -0,0 +1,23 @@ +name: libevent +description: Event notification library +version: 2.1.12 +revision: 1 +url: https://libevent.org/ +license: BSD-3-Clause +architecture: any +type: source +depends: + - openssl +optional_depends: + - python3 +make_depends: + - cmake + - doxygen + - ninja + - python3 + - zlib +downloads: + - url: https://github.com/libevent/libevent/releases/download/release-${BPM_PKG_VERSION}-stable/libevent-${BPM_PKG_VERSION}-stable.tar.gz + extract_to: ${BPM_SOURCE} + extract_strip_components: 1 + checksum: 92e6de1be9ec176428fd2367677e61ceffc2ee1cb119035037a27d346b0403bb diff --git a/source-files/event_sizeof_time_t.patch b/source-files/event_sizeof_time_t.patch new file mode 100644 index 0000000..3008904 --- /dev/null +++ b/source-files/event_sizeof_time_t.patch @@ -0,0 +1,37 @@ +From f5ad737d73ed18b95ce63f1d8e933a89a26653e9 Mon Sep 17 00:00:00 2001 +From: Azat Khuzhin +Date: Sat, 9 Jul 2022 14:22:38 +0300 +Subject: [PATCH] Add -Wundef for cmake and fix EVENT__SIZEOF_TIME_T usage + +Note, autotools already supports it. +--- + CMakeLists.txt | 1 + + event-config.h.cmake | 3 +++ + 2 files changed, 4 insertions(+) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 5ee0df2f7..9237252c7 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -295,6 +295,7 @@ if (${GNUC}) + + list(APPEND __FLAGS + -Wall -Wextra -Wno-unused-parameter -Wstrict-aliasing -Wstrict-prototypes ++ -Wundef + + -fno-strict-aliasing # gcc 2.9.5+ + -Wmissing-prototypes +diff --git a/event-config.h.cmake b/event-config.h.cmake +index 9fff34877..4a6267017 100644 +--- a/event-config.h.cmake ++++ b/event-config.h.cmake +@@ -485,6 +485,9 @@ + /* The size of 'void *', as computer by sizeof */ + #define EVENT__SIZEOF_VOID_P @EVENT__SIZEOF_VOID_P@ + ++/* The size of 'time_t', as computer by sizeof */ ++#define EVENT__SIZEOF_TIME_T @EVENT__SIZEOF_TIME_T@ ++ + /* Define to `__inline__' or `__inline' if that's what the C compiler + calls it, or to nothing if 'inline' is not supported under any name. */ + #ifndef __cplusplus diff --git a/source-files/openssl-compat.patch b/source-files/openssl-compat.patch new file mode 100644 index 0000000..ba73930 --- /dev/null +++ b/source-files/openssl-compat.patch @@ -0,0 +1,74 @@ +commit 7f4684c0d362fefee8697ceed3f4f8642ed147ce +Author: William Marlow +Date: Sat Jun 18 21:43:31 2022 +0100 + + Initial OpenSSL 3.0 support + + * Don't use deprecated functions when building against OpenSSL 3.0. + * Recognise that OpenSSL 3.0 can signal a dirty shutdown as a protocol. + error in addition to the expected IO error produced by OpenSSL 1.1.1 + * Update regress_mbedtls.c for compatibility with OpenSSL 3 + + (cherry picked from commit 29c420c418aeb497e5e8b7abd45dee39194ca5fc) + + Conflicts: + bufferevent_openssl.c + sample/becat.c + test/regress_mbedtls.c + +diff --git a/bufferevent_openssl.c b/bufferevent_openssl.c +index b51b834b..520e2d6f 100644 +--- a/bufferevent_openssl.c ++++ b/bufferevent_openssl.c +@@ -514,7 +514,9 @@ conn_closed(struct bufferevent_openssl *bev_ssl, int when, int errcode, int ret) + put_error(bev_ssl, errcode); + break; + case SSL_ERROR_SSL: +- /* Protocol error. */ ++ /* Protocol error; possibly a dirty shutdown. */ ++ if (ret == 0 && SSL_is_init_finished(bev_ssl->ssl) == 0) ++ dirty_shutdown = 1; + put_error(bev_ssl, errcode); + break; + case SSL_ERROR_WANT_X509_LOOKUP: +diff --git a/sample/le-proxy.c b/sample/le-proxy.c +index 13e0e2ae..e9af3c68 100644 +--- a/sample/le-proxy.c ++++ b/sample/le-proxy.c +@@ -112,10 +112,15 @@ eventcb(struct bufferevent *bev, short what, void *ctx) + ERR_reason_error_string(err); + const char *lib = (const char*) + ERR_lib_error_string(err); ++#if OPENSSL_VERSION_MAJOR >= 3 ++ fprintf(stderr, ++ "%s in %s\n", msg, lib); ++#else + const char *func = (const char*) + ERR_func_error_string(err); + fprintf(stderr, + "%s in %s %s\n", msg, lib, func); ++#endif + } + if (errno) + perror("connection error"); +diff --git a/test/regress_ssl.c b/test/regress_ssl.c +index 37dc334d..490be9b2 100644 +--- a/test/regress_ssl.c ++++ b/test/regress_ssl.c +@@ -374,7 +374,16 @@ eventcb(struct bufferevent *bev, short what, void *ctx) + ++n_connected; + ssl = bufferevent_openssl_get_ssl(bev); + tt_assert(ssl); ++#if OPENSSL_VERSION_MAJOR >= 3 ++ /* SSL_get1_peer_certificate() means we want ++ * to increase the reference count on the cert ++ * and so we will need to free it ourselves later ++ * when we're done with it. The non-reference count ++ * increasing version is not available in OpenSSL 1.1.1. */ ++ peer_cert = SSL_get1_peer_certificate(ssl); ++#else + peer_cert = SSL_get_peer_certificate(ssl); ++#endif + if (type & REGRESS_OPENSSL_SERVER) { + tt_assert(peer_cert == NULL); + } else { diff --git a/source.sh b/source.sh new file mode 100644 index 0000000..81b0ccb --- /dev/null +++ b/source.sh @@ -0,0 +1,37 @@ +# This is the source.sh script. It is executed by BPM in a temporary directory when compiling a source package +# BPM Expects the source code to be extracted into the automatically created 'source' directory which can be accessed using $BPM_SOURCE +# BPM Expects the output files to be present in the automatically created 'output' directory which can be accessed using $BPM_OUTPUT + +# The prepare function is executed in the root of the temp directory +# This function is used for putting downloaded files to the correct location or applying patches +prepare() { + cd "$BPM_SOURCE" + # Fix openssl compatibility + patch -Np1 -i "$BPM_WORKDIR"/openssl-compat.patch + # Fix EVENT_SIZEOF_TIME_T usage + patch -Np1 -i "$BPM_WORKDIR"/event_sizeof_time_t.patch +} + +# The build function is executed in the source directory +# This function is used to compile the source code +build() { + cmake -B build -G Ninja \ + -DCMAKE_POLICY_VERSION_MINIMUM=3.5 \ + -DCMAKE_BUILD_TYPE=None \ + -DCMAKE_INSTALL_PREFIX=/usr \ + -DCMAKE_SKIP_INSTALL_RPATH=TRUE \ + -DEVENT__LIBRARY_TYPE=SHARED \ + -DEVENT__DISABLE_REGRESS=OFF \ + -DEVENT__DOXYGEN=ON + cmake --build build +} + + +# The package function is executed in the source directory +# This function is used to move the compiled files into the output directory +package() { + DESTDIR="$BPM_OUTPUT" cmake --install build + + # Install package license + install -Dm644 "$BPM_SOURCE"/LICENSE "$BPM_OUTPUT"/usr/share/licenses/libevent/LICENSE +}