summaryrefslogtreecommitdiff
path: root/regress/plus_build_version/spec
blob: 03ebc00fcc4fa752f1dd71e78ec08b9a4de2b4d6 (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
#! /bin/sh
# $NetBSD: spec,v 1.3 2020/05/19 05:02:42 rillig Exp $

# This test demonstrates how the RCS Ids from the package files end up in
# the +BUILD_VERSION file of the binary package.
#
# There are several places in pkgsrc that make use of these RCS Ids:
#
# mk/checksum/checksum, search for "NetBSD":
#	When computing the SHA1 hash for a patch file (before it is applied
#	to the extracted distfile), the RCS Id lines are ignored.
#
# mk/checksum/distinfo.awk, function patchsum:
#	When generating the patches part of the distinfo file.
#	Same as in mk/checksum/checksum.
#
# mk/pkgformat/pkg/metadata.mk, search for "NetBSD":
#	The RCS Ids end up in the +BUILD_VERSION of the binary package.
#
# pkgtools/pbulk/files/pbulk/scripts/pkg-up-to-date, search for "NetBSD":
#	RCS Ids from the source package are extracted and then compared
#	to the RCS Ids from the binary package, to see whether the package
#	needs to be built again.
#
# pkgtools/pkglint/files/distinfo.go, function computePatchSha1Hex:
#	Same as mk/checksum/checksum.
#
# All these places must use the same patterns for extracting the RCS Ids.

set -u

tmpdir="${TMPDIR-/tmp}/plus-build-version"
actual="$tmpdir/.pkgdb/+BUILD_VERSION"

do_test() {
	rm -rf "$tmpdir"
	mkdir -p "$tmpdir/.pkgdb"
	$TEST_MAKE \
		PKGNAME="package-1.0" \
		WRKDIR="$tmpdir" \
		-f "../../mk/bsd.pkg.mk" \
		"$actual"
}

check_result() {
	# In files/expected, the $ characters are replaced with * to
	# prevent them from being expanded by CVS.
	tr '*' '$' < "files/expected" > "$tmpdir/expected"

	diff -u "$tmpdir/expected" "$actual" || regress_fail "differ"
}

do_cleanup() {
	rm -rf "$tmpdir"
}