summaryrefslogtreecommitdiff
blob: 1a9d311208e2464cc4f0eb8a7c64481654a9cda6 (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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
# Copyright 1999-2023 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

# @ECLASS: dotnet-pkg-base.eclass
# @MAINTAINER:
# Gentoo Dotnet project <dotnet@gentoo.org>
# @AUTHOR:
# Anna Figueiredo Gomes <navi@vlhl.dev>
# Maciej Barć <xgqt@gentoo.org>
# @SUPPORTED_EAPIS: 8
# @PROVIDES: nuget
# @BLURB: common functions and variables for builds using .NET SDK
# @DESCRIPTION:
# This eclass is designed to provide required ebuild definitions for .NET
# packages. Beware that in addition to Gentoo-specific concepts also terms that
# should be known to people familiar with the .NET ecosystem are used through
# this one and similar eclasses.
#
# In ebuilds for software that only utilizes the .NET SDK, without special
# cases, the "dotnet-pkg.eclass" is probably better suited.
#
# This eclass does not export any phase functions, for that see
# the "dotnet-pkg" eclass.

case ${EAPI} in
	8) ;;
	*) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;;
esac

if [[ -z ${_DOTNET_PKG_BASE_ECLASS} ]] ; then
_DOTNET_PKG_BASE_ECLASS=1

inherit edo multiprocessing nuget

# @ECLASS_VARIABLE: DOTNET_PKG_COMPAT
# @REQUIRED
# @PRE_INHERIT
# @DESCRIPTION:
# Allows to choose a slot for dotnet.
#
# Most .NET packages will lock onto one supported .NET major version.
# DOTNET_PKG_COMPAT should specify which version was chosen by package upstream.
# In case multiple .NET versions are specified in the project, then the highest
# should be picked by the maintainer.

# @ECLASS_VARIABLE: DOTNET_PKG_RDEPS
# @OUTPUT_VARIABLE
# @DESCRIPTION:
# Populated with important dependencies on .NET ecosystem packages for running
# .NET packages.
#
# "DOTNET_PKG_RDEPS" should appear (or conditionally appear) in "RDEPEND".
DOTNET_PKG_RDEPS=""

# @ECLASS_VARIABLE: DOTNET_PKG_BDEPS
# @OUTPUT_VARIABLE
# @DESCRIPTION:
# Populated with important dependencies on .NET ecosystem packages for building
# .NET packages.
#
# "DOTNET_PKG_BDEPS" should appear (or conditionally appear) in "BDEPEND".
DOTNET_PKG_BDEPS=""

# Have this guard to be sure that *DEPS are not added to
# the "dev-dotnet/dotnet-runtime-nugets" package dependencies.
if [[ ${CATEGORY}/${PN} != dev-dotnet/dotnet-runtime-nugets ]] ; then
	if [[ -z ${DOTNET_PKG_COMPAT} ]] ; then
		die "${ECLASS}: DOTNET_PKG_COMPAT not set"
	fi

	DOTNET_PKG_RDEPS+=" virtual/dotnet-sdk:${DOTNET_PKG_COMPAT} "
	DOTNET_PKG_BDEPS+=" ${DOTNET_PKG_RDEPS} "

	# Special package "dev-dotnet/csharp-gentoodotnetinfo" used for information
	# gathering, example for usage see the "dotnet-pkg-base_info" function.
	if [[ ${CATEGORY}/${PN} != dev-dotnet/csharp-gentoodotnetinfo ]] ; then
		DOTNET_PKG_BDEPS+=" dev-dotnet/csharp-gentoodotnetinfo "
	fi

	IUSE+=" debug "
fi

# Needed otherwise the binaries may break.
RESTRICT+=" strip "

# Everything is built by "dotnet".
QA_PREBUILT=".*"

# Special .NET SDK environment variables.
# Setting them either prevents annoying information from being generated
# or stops services that may interfere with a clean package build.
export DOTNET_CLI_TELEMETRY_OPTOUT=1
export DOTNET_NOLOGO=1
export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
export MSBUILDDISABLENODEREUSE=1
export POWERSHELL_TELEMETRY_OPTOUT=1
export POWERSHELL_UPDATECHECK=0
# Overwrite selected MSBuild properties ("-p:XYZ").
export UseSharedCompilation=false

# @ECLASS_VARIABLE: DOTNET_PKG_RUNTIME
# @DEFAULT_UNSET
# @OUTPUT_VARIABLE
# @DESCRIPTION:
# Sets the runtime used to build a package.
#
# This variable is set automatically by the "dotnet-pkg-base_setup" function.

# @ECLASS_VARIABLE: DOTNET_PKG_EXECUTABLE
# @DEFAULT_UNSET
# @OUTPUT_VARIABLE
# @DESCRIPTION:
# Sets path of a "dotnet" executable.
#
# This variable is set automatically by the "dotnet-pkg-base_setup" function.

# @ECLASS_VARIABLE: DOTNET_PKG_CONFIGURATION
# @DEFAULT_UNSET
# @OUTPUT_VARIABLE
# @DESCRIPTION:
# Configuration value passed to "dotnet" in the compile phase.
# Is either Debug or Release, depending on the "debug" USE flag.
#
# This variable is set automatically by the "dotnet-pkg-base_setup" function.

# @ECLASS_VARIABLE: DOTNET_PKG_OUTPUT
# @DEFAULT_UNSET
# @OUTPUT_VARIABLE
# @DESCRIPTION:
# Path of the output directory, where the package artifacts are placed during
# the building of packages with "dotnet-pkg-base_build" function.
#
# This variable is set automatically by the "dotnet-pkg-base_setup" function.

# @VARIABLE: _DOTNET_PKG_LAUNCHERDEST
# @INTERNAL
# @DESCRIPTION:
# Sets the path that .NET launchers are installed into by
# the "dotnet-pkg-base_dolauncher" function.
#
# The function "dotnet-pkg-base_launcherinto" is able to manipulate this
# variable.
#
# Defaults to "/usr/bin".
_DOTNET_PKG_LAUNCHERDEST=/usr/bin

# @VARIABLE: _DOTNET_PKG_LAUNCHERVARS
# @INTERNAL
# @DESCRIPTION:
# Sets additional variables for .NET launchers created by
# the "dotnet-pkg-base_dolauncher" function.
#
# The function "dotnet-pkg-base_append_launchervar" is able to manipulate this
# variable.
#
# Defaults to a empty array.
_DOTNET_PKG_LAUNCHERVARS=()

# @FUNCTION: dotnet-pkg-base_get-configuration
# @DESCRIPTION:
# Return .NET configuration type of the current package.
#
# It is advised to refer to the "DOTNET_PKG_CONFIGURATION" variable instead of
# calling this function if necessary.
#
# Used by "dotnet-pkg-base_setup".
dotnet-pkg-base_get-configuration() {
	if in_iuse debug && use debug ; then
		echo Debug
	else
		echo Release
	fi
}

# @FUNCTION: dotnet-pkg-base_get-output
# @USAGE: <name>
# @DESCRIPTION:
# Return a specially constructed name of a directory for output of
# "dotnet build" artifacts ("--output" flag, see "dotnet-pkg-base_build").
#
# It is very rare that a maintainer would use this function in an ebuild.
#
# This function is used inside "dotnet-pkg-base_setup".
dotnet-pkg-base_get-output() {
	debug-print-function "${FUNCNAME[0]}" "${@}"

	[[ -z ${DOTNET_PKG_CONFIGURATION} ]] &&
		die "${FUNCNAME[0]}: DOTNET_PKG_CONFIGURATION is not set."

	echo "${WORKDIR}/${1}_net${DOTNET_PKG_COMPAT}_${DOTNET_PKG_CONFIGURATION}"
}

# @FUNCTION: dotnet-pkg-base_get-runtime
# @DESCRIPTION:
# Return the .NET runtime used for the current package.
#
# Used by "dotnet-pkg-base_setup".
dotnet-pkg-base_get-runtime() {
	local libc
	libc="$(usex elibc_musl "-musl" "")"

	if use amd64 ; then
		echo "linux${libc}-x64"
	elif use x86 ; then
		echo "linux${libc}-x86"
	elif use arm ; then
		echo "linux${libc}-arm"
	elif use arm64 ; then
		echo "linux${libc}-arm64"
	else
		die "${FUNCNAME[0]}: Unsupported architecture: ${ARCH}"
	fi
}

# @FUNCTION: dotnet-pkg-base_setup
# @DESCRIPTION:
# Sets up "DOTNET_PKG_EXECUTABLE" variable for later use in "edotnet".
# Also sets up "DOTNET_PKG_CONFIGURATION" and "DOTNET_PKG_OUTPUT"
# for "dotnet-pkg_src_configure" and "dotnet-pkg_src_compile".
#
# This functions should be called by "pkg_setup".
#
# Used by "dotnet-pkg_pkg_setup" from the "dotnet-pkg" eclass.
dotnet-pkg-base_setup() {
	local dotnet_compat_impl
	local dotnet_compat_impl_path
	for dotnet_compat_impl in dotnet{,-bin}-${DOTNET_PKG_COMPAT} ; do
		dotnet_compat_impl_path="$(type -P "${dotnet_compat_impl}")"

		if [[ -n ${dotnet_compat_impl_path} ]] ; then
			DOTNET_PKG_EXECUTABLE="${dotnet_compat_impl}"
			break
		fi
	done

	# Link "DOTNET_PKG_EXECUTABLE" to "dotnet" only for the package build.
	local dotnet_spoof_path="${T}/dotnet_spoof/${DOTNET_PKG_COMPAT}"
	mkdir -p "${dotnet_spoof_path}" || die
	ln -s "${dotnet_compat_impl_path}" "${dotnet_spoof_path}/dotnet" || die
	export PATH="${dotnet_spoof_path}:${PATH}"

	einfo "Using dotnet SDK \"${DOTNET_PKG_EXECUTABLE}\" from \"${dotnet_compat_impl_path}\"."

	# The picked "DOTNET_PKG_EXECUTABLE" should set "DOTNET_ROOT" internally
	# and not rely upon this environment variable.
	unset DOTNET_ROOT

	DOTNET_PKG_RUNTIME="$(dotnet-pkg-base_get-runtime)"
	DOTNET_PKG_CONFIGURATION="$(dotnet-pkg-base_get-configuration)"
	DOTNET_PKG_OUTPUT="$(dotnet-pkg-base_get-output "${P}")"
}

# @FUNCTION: dotnet-pkg-base_remove-global-json
# @USAGE: [directory]
# @DESCRIPTION:
# Remove the "global.json" if it exists.
# The file in question might lock target package to a specified .NET
# version, which might be unnecessary (as it is in most cases).
#
# Optional "directory" argument defaults to the current directory path.
#
# Used by "dotnet-pkg_src_prepare" from the "dotnet-pkg" eclass.
dotnet-pkg-base_remove-global-json() {
	debug-print-function "${FUNCNAME[0]}" "${@}"

	local file="${1:-.}"/global.json

	if [[ -f "${file}" ]] ; then
		ebegin "Removing the global.json file"
		rm "${file}"
		eend ${?} || die "${FUNCNAME[0]}: failed to remove ${file}"
	fi
}

# @FUNCTION: edotnet
# @USAGE: <command> [args...]
# @DESCRIPTION:
# Call dotnet, passing the supplied arguments.
edotnet() {
	debug-print-function "${FUNCNAME[0]}" "${@}"

	if [[ -z ${DOTNET_PKG_EXECUTABLE} ]] ; then
	   die "${FUNCNAME[0]}: DOTNET_PKG_EXECUTABLE not set. Was dotnet-pkg-base_setup called?"
	fi

	edo "${DOTNET_PKG_EXECUTABLE}" "${@}"
}

# @FUNCTION: dotnet-pkg-base_info
# @DESCRIPTION:
# Show information about current .NET SDK that is being used.
#
# Depends upon the "gentoo-dotnet-info" program installed by
# the "dev-dotnet/csharp-gentoodotnetinfo" package.
#
# Used by "dotnet-pkg_src_configure" from the "dotnet-pkg" eclass.
dotnet-pkg-base_info() {
	if [[ ${CATEGORY}/${PN} == dev-dotnet/csharp-gentoodotnetinfo ]] ; then
		debug-print-function "${FUNCNAME[0]}: ${P} is a special package, skipping dotnet-pkg-base_info"
	elif command -v gentoo-dotnet-info >/dev/null ; then
		gentoo-dotnet-info || die "${FUNCNAME[0]}: failed to execute gentoo-dotnet-info"
	else
		ewarn "${FUNCNAME[0]}: gentoo-dotnet-info not available"
	fi
}

# @FUNCTION: dotnet-pkg-base_foreach-solution
# @USAGE: <directory> <args> ...
# @DESCRIPTION:
# Execute a function for each solution file (.sln) in a specified directory.
# This function may yield no real results because solutions are discovered
# automatically.
#
# Used by "dotnet-pkg_src_configure" and "dotnet-pkg_src_test" from
# the "dotnet-pkg" eclass.
dotnet-pkg-base_foreach-solution() {
	debug-print-function "${FUNCNAME[0]}" "${@}"

	local directory="${1}"
	shift

	local dotnet_solution
	local dotnet_solution_name
	while read -r dotnet_solution ; do
		dotnet_solution_name="$(basename "${dotnet_solution}")"

		ebegin "Running \"${@}\" for solution: \"${dotnet_solution_name}\""
		"${@}" "${dotnet_solution}"
		eend $? "${FUNCNAME[0]}: failed for solution: \"${dotnet_solution}\"" || die
	done < <(find "${directory}" -maxdepth 1 -type f -name "*.sln")
}

# @FUNCTION: dotnet-pkg-base_restore
# @USAGE: [args] ...
# @DESCRIPTION:
# Restore the package using "dotnet restore".
# Restore is performed in current directory unless a different directory is
# passed via "args".
#
# Additionally any number of "args" maybe be given, they are appended to
# the "dotnet" command invocation.
#
# Used by "dotnet-pkg_src_configure" from the "dotnet-pkg" eclass.
dotnet-pkg-base_restore() {
	debug-print-function "${FUNCNAME[0]}" "${@}"

	local -a restore_args=(
		--runtime "${DOTNET_PKG_RUNTIME}"
		--source "${NUGET_PACKAGES}"
		-maxCpuCount:$(makeopts_jobs)
		"${@}"
	)

	edotnet restore "${restore_args[@]}"
}

# @FUNCTION: dotnet-pkg-base_restore_tools
# @USAGE: [config-file] [args] ...
# @DESCRIPTION:
# Restore dotnet tools for a project in the current directory.
#
# Optional "config-file" argument is used to specify a file for the
# "--configfile" option which records what tools should be restored.
#
# Additionally any number of "args" maybe be given, they are appended to
# the "dotnet" command invocation.
dotnet-pkg-base_restore_tools() {
	debug-print-function "${FUNCNAME[0]}" "${@}"

	local -a tool_restore_args=(
		--add-source "${NUGET_PACKAGES}"
	)

	if [[ -n "${1}" ]] ; then
		tool_restore_args+=( --configfile "${1}" )
		shift
	fi

	tool_restore_args+=( "${@}" )

	edotnet tool restore "${tool_restore_args[@]}"
}

# @FUNCTION: dotnet-pkg-base_build
# @USAGE: [args] ...
# @DESCRIPTION:
# Build the package using "dotnet build" in a specified directory.
# Build is performed in current directory unless a different directory is
# passed via "args".
#
# Additionally any number of "args" maybe be given, they are appended to
# the "dotnet" command invocation.
#
# Used by "dotnet-pkg_src_compile" from the "dotnet-pkg" eclass.
dotnet-pkg-base_build() {
	debug-print-function "${FUNCNAME[0]}" "${@}"

	local -a build_args=(
		--configuration "${DOTNET_PKG_CONFIGURATION}"
		--no-restore
		--no-self-contained
		--output "${DOTNET_PKG_OUTPUT}"
		--runtime "${DOTNET_PKG_RUNTIME}"
		-maxCpuCount:$(makeopts_jobs)
	)

	if ! use debug ; then
		build_args+=(
			-p:StripSymbols=true
			-p:NativeDebugSymbols=false
		)
	fi

	# And append "args" at the end.
	build_args+=(
		"${@}"
	)

	edotnet build "${build_args[@]}"
}

# @FUNCTION: dotnet-pkg-base_test
# @USAGE: [directory] [args] ...
# @DESCRIPTION:
# Test the package using "dotnet test" in a specified directory.
#
# Optional "directory" argument defaults to the current directory path.
#
# Additionally any number of "args" maybe be given, they are appended to
# the "dotnet" command invocation.
#
# Used by "dotnet-pkg_src_test" from the "dotnet-pkg" eclass.
dotnet-pkg-base_test() {
	debug-print-function "${FUNCNAME[0]}" "${@}"

	local directory
	if [[ -n "${1}" ]] ; then
		directory="${1}"
		shift
	else
		directory="$(pwd)"
	fi

	local -a test_args=(
		--configuration "${DOTNET_PKG_CONFIGURATION}"
		--no-restore
		-maxCpuCount:$(makeopts_jobs)
		"${@}"
	)

	edotnet test "${test_args[@]}" "${directory}"
}

# @FUNCTION: dotnet-pkg-base_install
# @USAGE: [directory]
# @DESCRIPTION:
# Install the contents of "DOTNET_PKG_OUTPUT" into a directory, defaults to
# "/usr/share/${P}".
#
# Installation directory is relative to "ED".
dotnet-pkg-base_install() {
	debug-print-function "${FUNCNAME[0]}" "${@}"

	local installation_directory="${1:-/usr/share/${P}}"

	dodir "${installation_directory}"
	cp -r "${DOTNET_PKG_OUTPUT}"/* "${ED}/${installation_directory}/" || die
}

# @FUNCTION: dotnet-pkg-base_launcherinto
# @USAGE: <directory>
# @DESCRIPTION:
# Changes the path .NET launchers are installed into via subsequent
# "dotnet-pkg-base_dolauncher" calls.
#
# For more info see the "_DOTNET_PKG_LAUNCHERDEST" variable.
dotnet-pkg-base_launcherinto() {
	debug-print-function "${FUNCNAME[0]}" "${@}"

	[[ -z ${1} ]] && die "${FUNCNAME[0]}: no directory specified"

	_DOTNET_PKG_LAUNCHERDEST="${1}"
}

# @FUNCTION: dotnet-pkg-base_append_launchervar
# @USAGE: <variable-setting>
# @DESCRIPTION:
# Appends a given variable setting to the "_DOTNET_PKG_LAUNCHERVARS".
#
# WARNING: This functions modifies a global variable permanently!
# This means that all launchers created in subsequent
# "dotnet-pkg-base_dolauncher" calls of a given package will have
# the given variable set.
#
# Example:
# @CODE
# dotnet-pkg-base_append_launchervar "DOTNET_EnableAlternateStackCheck=1"
# @CODE
#
# For more info see the "_DOTNET_PKG_LAUNCHERVARS" variable.
dotnet-pkg-base_append_launchervar() {
	debug-print-function "${FUNCNAME[0]}" "${@}"

	[[ -z ${1} ]] && die "${FUNCNAME[0]}: no variable setting specified"

	_DOTNET_PKG_LAUNCHERVARS+=( "${1}" )
}

# @FUNCTION: dotnet-pkg-base_dolauncher
# @USAGE: <executable-path> [filename]
# @DESCRIPTION:
# Make a wrapper script to launch an executable built from a .NET package.
#
# If no file name is given, the `basename` of the executable is used.
#
# Parameters:
# ${1} - path of the executable to launch,
# ${2} - filename of launcher to create (optional).
#
# Example:
# @CODE
# dotnet-pkg-base_install
# dotnet-pkg-base_dolauncher /usr/share/${P}/${PN^}
# @CODE
#
# The path is prepended by "EPREFIX".
dotnet-pkg-base_dolauncher() {
	debug-print-function "${FUNCNAME[0]}" "${@}"

	local executable_path executable_name

	if [[ -n "${1}" ]] ; then
		local executable_path="${1}"
		shift
	else
		die "${FUNCNAME[0]}: No executable path given."
	fi

	if [[ ${#} -eq 0 ]] ; then
		executable_name="$(basename "${executable_path}")"
	else
		executable_name="${1}"
		shift
	fi

	local executable_target="${T}/${executable_name}"

	cat <<-EOF > "${executable_target}" || die
	#!/bin/sh

	# Launcher script for ${executable_path} (${executable_name}),
	# created from package "${CATEGORY}/${P}",
	# compatible with dotnet version ${DOTNET_PKG_COMPAT}.

	for __dotnet_root in \\
		"${EPREFIX}/usr/$(get_libdir)/dotnet-sdk-${DOTNET_PKG_COMPAT}" \\
		"${EPREFIX}/opt/dotnet-sdk-bin-${DOTNET_PKG_COMPAT}" ; do
		[ -d "\${__dotnet_root}" ] && break
	done

	DOTNET_ROOT="\${__dotnet_root}"
	export DOTNET_ROOT

	$(for var in "${_DOTNET_PKG_LAUNCHERVARS[@]}" ; do
		echo "${var}"
		echo "export ${var%%=*}"
	done)

	exec "${EPREFIX}${executable_path}" "\${@}"
	EOF

	exeinto "${_DOTNET_PKG_LAUNCHERDEST}"
	doexe "${executable_target}"
}

# @FUNCTION: dotnet-pkg-base_dolauncher_portable
# @USAGE: <dll-path> <filename>
# @DESCRIPTION:
# Make a wrapper script to launch a .NET DLL file built from a .NET package.
#
# Parameters:
# ${1} - path of the DLL to launch,
# ${2} - filename of launcher to create.
#
# Example:
# @CODE
# dotnet-pkg-base_dolauncher_portable \
#     /usr/share/${P}/GentooDotnetInfo.dll gentoo-dotnet-info
# @CODE
#
# The path is prepended by "EPREFIX".
dotnet-pkg-base_dolauncher_portable() {
	debug-print-function "${FUNCNAME[0]}" "${@}"

	local dll_path="${1}"
	local executable_name="${2}"
	local executable_target="${T}/${executable_name}"

	cat <<-EOF > "${executable_target}" || die
	#!/bin/sh

	# Launcher script for ${dll_path} (${executable_name}),
	# created from package "${CATEGORY}/${P}",
	# compatible with any dotnet version, built on ${DOTNET_PKG_COMPAT}.

	$(for var in "${_DOTNET_PKG_LAUNCHERVARS[@]}" ; do
		echo "${var}"
		echo "export ${var%%=*}"
	done)

	exec dotnet exec "${EPREFIX}${dll_path}" "\${@}"
	EOF

	exeinto "${_DOTNET_PKG_LAUNCHERDEST}"
	doexe "${executable_target}"
}

fi