From 907d9d4eb488aaed759dba26825bd2e0c102bcfc Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Thu, 4 Apr 2019 10:41:44 -0400 Subject: [PATCH] libgit2: import, add CRLF patch --- sr.ht/libgit2/APKBUILD | 68 +++++++++++++++++++ sr.ht/libgit2/build-both-static-dynamic.patch | 49 +++++++++++++ .../handle-crlf-in-parse_header_start.patch | 57 ++++++++++++++++ 3 files changed, 174 insertions(+) create mode 100644 sr.ht/libgit2/APKBUILD create mode 100644 sr.ht/libgit2/build-both-static-dynamic.patch create mode 100644 sr.ht/libgit2/handle-crlf-in-parse_header_start.patch diff --git a/sr.ht/libgit2/APKBUILD b/sr.ht/libgit2/APKBUILD new file mode 100644 index 0000000..b87ceb3 --- /dev/null +++ b/sr.ht/libgit2/APKBUILD @@ -0,0 +1,68 @@ +# Contributor: Sergei Lukin +# Contributor: Sören Tempel +# Contributor: Pierre-Gilas MILLON +# Maintainer: Natanael Copa +pkgname=libgit2 +pkgver=0.27.7 +pkgrel=1 +pkgdesc="A linkable library for Git" +url="https://libgit2.org/" +arch="all" +license="GPL-2.0-only-WITH-GCC-exception-2.0" +depends_dev="curl-dev libssh2-dev" +makedepends="$depends_dev python2 cmake zlib-dev openssl-dev" +subpackages="$pkgname-dev $pkgname-tests::noarch" +provides="$pkgname-libs" # for backward compatibility with v3.4 +replaces="$pkgname-libs" # for backward compatibility with v3.4 +source="$pkgname-$pkgver.tar.gz::https://github.com/$pkgname/$pkgname/archive/v$pkgver.tar.gz + build-both-static-dynamic.patch + handle-crlf-in-parse_header_start.patch + " +options="!check" # FIXME some tests fails +builddir="$srcdir/$pkgname-$pkgver" + +# secfixes: +# 0.27.4-r0: +# - CVE-2018-15501 +# 0.27.3-r0: +# - CVE-2018-10887 +# - CVE-2018-10888 +# 0.25.1-r0: +# - CVE-2016-10128 +# - CVE-2016-10129 +# - CVE-2016-10130 +# 0.24.3-r0: +# - CVE-2016-8568 +# - CVE-2016-8569 + +build() { + mkdir -p "$builddir"/build + cd "$builddir"/build + + cmake .. \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_INSTALL_PREFIX=/usr \ + -DCMAKE_C_FLAGS="$CFLAGS" + make +} + +check() { + cd "$builddir"/build + make test +} + +package() { + cd "$builddir"/build + make DESTDIR="$pkgdir" install +} + +tests() { + pkgdesc="$pkgdesc (tests)" + + mkdir -p "$subpkgdir"/usr/src/$pkgname/ + cp -a "$builddir"/tests "$subpkgdir"/usr/src/$pkgname/ +} + +sha512sums="de2e266939bd40bc580603539e1156906b97299523336ddc6a66c3bec26729495bef2daa2d240b83b7e011e93852381e95a4407132b0440a5aa1e1b7642c0011 libgit2-0.27.7.tar.gz +268e24554282666900a2179a368dc2569cb3bce60ffea187fd53de1bc119a85abc02cddd8be2ab607d44db793c4807acdbb49fc5d1badfc08bf382fa511d7b3e build-both-static-dynamic.patch +c55455c9548c01cda77641ce4c0b328c9cb8fc1b5b6dd8401b50ee7665034c8382cd651db27272931f169b898de36d1cb1b6d0266369cd63664505d881e25317 handle-crlf-in-parse_header_start.patch" diff --git a/sr.ht/libgit2/build-both-static-dynamic.patch b/sr.ht/libgit2/build-both-static-dynamic.patch new file mode 100644 index 0000000..9912727 --- /dev/null +++ b/sr.ht/libgit2/build-both-static-dynamic.patch @@ -0,0 +1,49 @@ +From: Jakub Jirutka +Date: Mon, 11 Apr 2017 3:23:00 +0200 +Subject: [PATCH] Build both static and dynamic library + +This is very hack-ish, it makes option BUILD_SHARED_LIBS unusable. +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -39,7 +39,6 @@ + # Build options + # + OPTION( SONAME "Set the (SO)VERSION of the target" ON ) +-OPTION( BUILD_SHARED_LIBS "Build Shared Library (OFF for Static)" ON ) + OPTION( THREADSAFE "Build libgit2 as threadsafe" ON ) + OPTION( BUILD_CLAR "Build Tests using the Clar suite" ON ) + OPTION( BUILD_EXAMPLES "Build library usage example apps" OFF ) +@@ -58,6 +57,8 @@ + OPTION( DEBUG_POOL "Enable debug pool allocator" OFF ) + OPTION( ENABLE_WERROR "Enable compilation with -Werror" OFF ) + OPTION( USE_BUNDLED_ZLIB "Use the bundled version of zlib" OFF ) ++ ++SET( BUILD_SHARED_LIBS ON ) + + IF (UNIX AND NOT APPLE) + OPTION( ENABLE_REPRODUCIBLE_BUILDS "Enable reproducible builds" OFF ) +--- a/src/CMakeLists.txt ++++ b/src/CMakeLists.txt +@@ -407,9 +407,12 @@ + ENDIF() + + # Compile and link libgit2 +-ADD_LIBRARY(git2 ${WIN_RC} ${LIBGIT2_OBJECTS}) ++ADD_LIBRARY(git2 SHARED ${WIN_RC} ${LIBGIT2_OBJECTS}) + TARGET_LINK_LIBRARIES(git2 ${LIBGIT2_LIBS}) + ++ADD_LIBRARY(git2_static STATIC ${WIN_RC} ${LIBGIT2_OBJECTS}) ++SET_TARGET_PROPERTIES(git2_static PROPERTIES OUTPUT_NAME git2 CLEAN_DIRECT_OUTPUT 1) ++ + SET_TARGET_PROPERTIES(git2 PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${libgit2_BINARY_DIR}) + SET_TARGET_PROPERTIES(git2 PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${libgit2_BINARY_DIR}) + SET_TARGET_PROPERTIES(git2 PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${libgit2_BINARY_DIR}) +@@ -445,7 +448,7 @@ + ENDIF () + + # Install +-INSTALL(TARGETS git2 ++INSTALL(TARGETS git2 git2_static + RUNTIME DESTINATION ${BIN_INSTALL_DIR} + LIBRARY DESTINATION ${LIB_INSTALL_DIR} + ARCHIVE DESTINATION ${LIB_INSTALL_DIR} diff --git a/sr.ht/libgit2/handle-crlf-in-parse_header_start.patch b/sr.ht/libgit2/handle-crlf-in-parse_header_start.patch new file mode 100644 index 0000000..bfb64df --- /dev/null +++ b/sr.ht/libgit2/handle-crlf-in-parse_header_start.patch @@ -0,0 +1,57 @@ +From 5e88f13eaa8ca30439b496066f6c57e608e18c4e Mon Sep 17 00:00:00 2001 +From: Drew DeVault +Date: Fri, 22 Mar 2019 23:56:10 -0400 +Subject: [PATCH] patch_parse.c: Handle CRLF in parse_header_start + +--- + src/patch_parse.c | 3 ++- + tests/diff/parse.c | 25 +++++++++++++++++++++++++ + 2 files changed, 27 insertions(+), 1 deletion(-) + +diff --git a/src/patch_parse.c b/src/patch_parse.c +index 647929fd5f..1182f19884 100644 +--- a/src/patch_parse.c ++++ b/src/patch_parse.c +@@ -328,7 +328,8 @@ static int parse_header_start(git_patch_parsed *patch, git_patch_parse_ctx *ctx) + * proceeed here. We then hope for the "---" and "+++" lines to fix that + * for us. + */ +- if (!git_parse_ctx_contains(&ctx->parse_ctx, "\n", 1)) { ++ if (!git_parse_ctx_contains(&ctx->parse_ctx, "\n", 1) ++ && !git_parse_ctx_contains(&ctx->parse_ctx, "\r\n", 2)) { + git_parse_advance_chars(&ctx->parse_ctx, ctx->parse_ctx.line_len - 1); + + git__free(patch->header_old_path); +diff --git a/tests/diff/parse.c b/tests/diff/parse.c +index 9cdaa92fbc..927ee90d80 100644 +--- a/tests/diff/parse.c ++++ b/tests/diff/parse.c +@@ -359,3 +359,28 @@ void test_diff_parse__lineinfo(void) + git_patch_free(patch); + git_diff_free(diff); + } ++ ++void test_diff_parse__crlf(void) ++{ ++ const char *text = "diff --git a/test-file b/test-file\r\n" ++ "new file mode 100644\r\n" ++ "index 0000000..af431f2 100644\r\n" ++ "--- /dev/null\r\n" ++ "+++ b/test-file\r\n" ++ "@@ -0,0 +1 @@\r\n" ++ "+a contents\r\n"; ++ ++ git_diff *diff; ++ git_patch *patch; ++ const git_diff_delta *delta; ++ ++ cl_git_pass(git_diff_from_buffer(&diff, text, strlen(text))); ++ cl_git_pass(git_patch_from_diff(&patch, diff, 0)); ++ delta = git_patch_get_delta(patch); ++ ++ cl_assert_equal_s(delta->old_file.path, "test-file"); ++ cl_assert_equal_s(delta->new_file.path, "test-file"); ++ ++ git_patch_free(patch); ++ git_diff_free(diff); ++} -- 2.45.2