~dricottone/huttese-apk

907d9d4eb488aaed759dba26825bd2e0c102bcfc — Drew DeVault 5 years ago 6c92f98
libgit2: import, add CRLF patch
A sr.ht/libgit2/APKBUILD => sr.ht/libgit2/APKBUILD +68 -0
@@ 0,0 1,68 @@
# Contributor: Sergei Lukin <sergej.lukin@gmail.com>
# Contributor: Sören Tempel <soeren+alpine@soeren-tempel.net>
# Contributor: Pierre-Gilas MILLON <pgmillon@gmail.com>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
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"

A sr.ht/libgit2/build-both-static-dynamic.patch => sr.ht/libgit2/build-both-static-dynamic.patch +49 -0
@@ 0,0 1,49 @@
From: Jakub Jirutka <jakub@jirutka.cz>
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}

A sr.ht/libgit2/handle-crlf-in-parse_header_start.patch => sr.ht/libgit2/handle-crlf-in-parse_header_start.patch +57 -0
@@ 0,0 1,57 @@
From 5e88f13eaa8ca30439b496066f6c57e608e18c4e Mon Sep 17 00:00:00 2001
From: Drew DeVault <sir@cmpwn.com>
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);
+}