aboutsummaryrefslogtreecommitdiff
blob: 14b05172f5301fa4c93287c581e71e958adf05e8 (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
# Copyright 1999-2019 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=6

inherit gac nupkg

HOMEPAGE="https://lontivero.github.io/Open.NAT"
DESCRIPTION="Class library to use port forwarding in NAT devices with UPNP and/or PMP"
LICENSE="MIT"
SLOT="0"
KEYWORDS="~amd64"
IUSE="net45 +gac +nupkg +pkg-config debug developer"
USE_DOTNET="net45"

COMMON_DEPEND=">=dev-lang/mono-4.0.2.5
"

RDEPEND="${COMMON_DEPEND}
"

DEPEND="${COMMON_DEPEND}
	virtual/pkgconfig
"

NAME="Open.NAT"
REPOSITORY="https://github.com/ArsenShnurkov/${NAME}"
LICENSE_URL="${REPOSITORY}/blob/master/LICENSE"
ICONMETA="https://github.com/lontivero/Open.NAT/tree/gh-pages/images/logos"
ICON_URL="https://raw.githubusercontent.com/lontivero/Open.NAT/gh-pages/images/logos/256.jpg"

EGIT_BRANCH="gentoo-mono4"
EGIT_COMMIT="8b1120fa0f2d457fa2c703718bbf3ce079ac5aae"
SRC_URI="${REPOSITORY}/archive/${EGIT_BRANCH}/${EGIT_COMMIT}.zip -> ${PF}.zip
	mirror://gentoo/mono.snk.bz2"
#S="${WORKDIR}/${NAME}-${EGIT_COMMIT}"
S="${WORKDIR}/${NAME}-${EGIT_BRANCH}"

#METAFILETOBUILD="./Open.Nat.sln"
METAFILETOBUILD="./Open.Nat/Open.Nat.csproj"

OUTPUT_DIR=Open.Nat/bin
GAC_DLL_NAME=Open.Nat

NUSPEC_FILE="${S}/Open.Nat/Open.Nat.nuspec"
NUSPEC_VERSION="${PVR//-r/.}"

src_prepare() {
	enuget_restore "${METAFILETOBUILD}"

	patch_nuspec_file ${NUSPEC_FILE}

	eapply_user
}

src_configure() {
	:;
}

src_compile() {
	exbuild /p:SignAssembly=true "/p:AssemblyOriginatorKeyFile=${WORKDIR}/mono.snk" "${METAFILETOBUILD}"

	# run nuget_pack
	enuspec -Prop version=${NUSPEC_VERSION} ${NUSPEC_FILE}
}

src_install() {
	enupkg "${WORKDIR}/${NAME}.${NUSPEC_VERSION}.nupkg"

	egacinstall "${OUTPUT_DIR}/${DIR}/${GAC_DLL_NAME}.dll"

	einstall_pc_file "${PN}" "1.0" "${GAC_DLL_NAME}"
}

patch_nuspec_file()
{
	if use nupkg; then
		if use debug; then
			DIR="Debug"
		else
			DIR="Release"
		fi
		FILES_STRING=`sed 's/[\/&]/\\\\&/g' <<-EOF || die "escaping replacement string characters"
		  <files> <!-- https://docs.nuget.org/create/nuspec-reference -->
		    <file src="${OUTPUT_DIR}/${DIR}/*.dll" target="lib\net45\" />
		    <file src="${OUTPUT_DIR}/${DIR}/*.mdb" target="lib\net45\" />
		  </files>
		EOF
		`
		sed -i 's/<\/package>/'"${FILES_STRING//$'\n'/\\$'\n'}"'\n&/g' $1 || die "escaping line endings"
	fi
}