aboutsummaryrefslogtreecommitdiff
blob: bc5138d16a768c5afcff6eb4c44e5c7ca83f0560 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# Copyright 1999-2019 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=6

KEYWORDS="~amd64 ~x86"
RESTRICT+=" mirror"

USE_DOTNET="net45"
IUSE="+${USE_DOTNET}"
EBUILD_FRAMEWORK="4.5"

inherit gac nupkg

DESCRIPTION="A C# PInvoke wrapper library for LibGit2 C library"

REPO_OWNER=libgit2
NAME=libgit2sharp
EGIT_COMMIT="8daef23223e1374141bf496e4b310ded9ae4639e"
HOMEPAGE="https://github.com/${REPO_OWNER}/${NAME}"
SRC_URI="https://api.github.com/repos/${REPO_OWNER}/${NAME}/tarball/${EGIT_COMMIT} -> ${PN}-${PV}.tar.gz"
S="${WORKDIR}/${REPO_OWNER}-${NAME}-8daef23"

LICENSE="MIT"
SLOT="0"

CDEPEND=">=dev-lang/mono-4.9.0.729-r2
	dev-libs/libgit2
"

DEPEND="${CDEPEND}
	dev-dotnet/nuget
"
RDEPEND="${CDEPEND}"

prefix=${PREFIX}/usr
exec_prefix=${prefix}
libdir=${exec_prefix}/lib/mono/${EBUILD_FRAMEWORK}

NUSPEC_FILE="nuget.package/LibGit2Sharp.nuspec"

src_unpack() {
	default
	# remove rogue binaries
	rm -rf "${S}/Lib/NuGet/" || die
	rm -rf "${S}/Lib/CustomBuildTasks/CustomBuildTasks.dll" || die
}

src_prepare() {
	eapply "${FILESDIR}/sln.patch"
	eapply "${FILESDIR}/csproj-remove-nuget-targets-check.patch"
	eapply "${FILESDIR}/packages-config-remove-xunit.patch"
	eapply "${FILESDIR}/remove-NativeBinaries-package-dependency.patch"
	eapply "${FILESDIR}/nuspec-file-list.patch"
	echo "/usr/lib64/libgit2.so" >"LibGit2Sharp/libgit2_filename.txt" || die
	enuget_restore "LibGit2Sharp.sln"
	sed -i 's=\$id\$=LibGit2Sharp=g' "${NUSPEC_FILE}" || die
	sed -i "s=\\\$version\\\$=$(get_version_component_range 1-2)=g" "${NUSPEC_FILE}" || die
	sed -i 's=\$author\$=nulltoken=g' "${NUSPEC_FILE}" || die
	sed -i "s=\\\$description\\\$=${DESCRIPTION}=g" "${NUSPEC_FILE}" || die
	if use debug; then
		DIR="Debug"
	else
		DIR="Release"
	fi
	sed -i "s=\\\$configuration\\\$=${DIR}=g" "${NUSPEC_FILE}" || die
	default
}

src_compile() {
	# recreate custom build tasks .dll
	sed -i "s#<OutputPath>.*</OutputPath>#<OutputPath>.</OutputPath>#g" "Lib/CustomBuildTasks/CustomBuildTasks.csproj" || die
	exbuild "Lib/CustomBuildTasks/CustomBuildTasks.csproj"

	# main compilation
	exbuild_strong "LibGit2Sharp.sln"

	enuspec "${NUSPEC_FILE}"
}

src_install() {
	insinto "${libdir}"
	if use debug; then
		DIR="Debug"
	else
		DIR="Release"
	fi
	doins "LibGit2Sharp/bin/${DIR}/LibGit2Sharp.dll"

	enupkg "${WORKDIR}/LibGit2Sharp.0.22.nupkg"
}

pkg_postinst() {
	if use gac; then
		einfo "adding to GAC"
		gacutil -i "${libdir}/LibGit2Sharp.dll" || die
	fi

	# cd "${WORKDIR}
	# nuget push -source "Local NuGet packages" LibGit2Sharp.0.22.nupkg
}

pkg_postrm() {
	if use gac; then
		einfo "removing from GAC"
		gacutil -u LibGit2Sharp
		# don't die, it there is no such assembly in GAC
	fi

	# yes | nuget delete -source "Local NuGet packages" LibGit2Sharp 0.22
}