blob: 935644f7bb03611f8032e89a7578e4830dc0c4da (
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
|
#! /bin/sh
# $NetBSD: pkgformat-pkg-metadata.sh,v 1.2 2020/05/21 18:48:43 rillig Exp $
#
# Demonstrates how mk/pkgformat/pkg/metadata.mk creates the versioning
# information in +BUILD_VERSION.
#
# As of May 2020, several directories must be prefixed with ${.CURDIR},
# since otherwise +BUILD_VERSION ends up containing corrupt data.
#
set -eu
. './test.subr'
test_case_set_up() {
create_file 'setup.mk' <<-EOF
AWK= awk
CAT= cat
ECHO= echo
GREP= grep
MKDIR= mkdir -p
RM= rm
SED= sed
SORT= sort
TEST= test
RUN= @set -e;
INIT_SYSTEM= rc.d
WRKDIR= $PWD
WRKSRC= $PWD
PKGSRCDIR= $mocked_pkgsrcdir
EOF
}
if test_case_begin 'absolute paths'; then
wrkdir="$PWD"
pkgdir="$mocked_pkgsrcdir/category/package"
mkdir -p "$pkgdir"
cd "$pkgdir"
cvsid='$''NetBSD: marker ''$'
create_file 'Makefile' <<-EOF
# $cvsid
PKGDIR= \${.CURDIR}
FILESDIR= \${.CURDIR}/files
PATCHDIR= \${.CURDIR}/patches
DISTINFO_FILE= \${.CURDIR}/distinfo
.include "$wrkdir/setup.mk"
.include "$pkgsrcdir/mk/pkgformat/pkg/metadata.mk"
EOF
create_file_lines 'patches/patch-aa' \
"$cvsid"
create_file_lines 'files/README' \
"$cvsid"
run_bmake 'Makefile' "$wrkdir/.pkgdb/+BUILD_VERSION" \
1> "$tmpdir/output" 2>&1 \
&& exitcode=0 || exitcode=$?
assert_that "$exitcode" --equals '0'
assert_that "$tmpdir/output" --file-is-empty
assert_that "$wrkdir/.pkgdb/+BUILD_VERSION" --file-is-lines \
"category/package/Makefile: $cvsid" \
"category/package/files/README: $cvsid" \
"category/package/patches/patch-aa: $cvsid"
test_case_end
fi
if test_case_begin 'relative paths'; then
# Up to 2020-05-21, relative paths were stored wrong in the
# +BUILD_VERSION file.
wrkdir="$PWD"
pkgdir="$mocked_pkgsrcdir/category/package"
mkdir -p "$pkgdir"
cd "$pkgdir"
cvsid='$''NetBSD: marker ''$'
create_file 'Makefile' <<-EOF
# $cvsid
PKGDIR= .
FILESDIR= files
PATCHDIR= patches
DISTINFO_FILE= distinfo
.include "$wrkdir/setup.mk"
.include "$pkgsrcdir/mk/pkgformat/pkg/metadata.mk"
EOF
create_file_lines 'patches/patch-aa' \
"$cvsid"
create_file_lines 'files/README' \
"$cvsid"
run_bmake 'Makefile' "$wrkdir/.pkgdb/+BUILD_VERSION" \
1> "$tmpdir/output" 2>&1 \
&& exitcode=0 || exitcode=$?
assert_that "$exitcode" --equals '0'
assert_that "$tmpdir/output" --file-is-empty
assert_that "$wrkdir/.pkgdb/+BUILD_VERSION" --file-is-lines \
"category/package/Makefile: $cvsid" \
"category/package/files/README: $cvsid" \
"category/package/patches/patch-aa: $cvsid"
test_case_end
fi
|