Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/pkg
Path: blob/main/tests/frontend/create-parsebin.sh
2645 views
1
#! /usr/bin/env atf-sh
2
3
. $(atf_get_srcdir)/test_environment.sh
4
5
tests_init \
6
create_from_bin
7
8
genmanifest() {
9
local PKG_NAME="$1"
10
shift
11
local PKG_FLATSIZE=0
12
local PKG_FILES=""
13
local PKG_SHA256=""
14
local NL="
15
"
16
local hide_provided="$1"
17
shift
18
19
bin_meta "$1"
20
while [ -n "$1" ]; do
21
local file1="${1%#*}"
22
local file1_base=$(basename ${file1})
23
local file1_size=$(wc -c < ${file1})
24
local file1_sha=$(openssl dgst -sha256 -hex ${file1} | sed -nE 's/.*=[[:space:]]*([[:xdigit:]]+)/\1/p')
25
cp -a ${file1} ${TMPDIR}/${file1_base}
26
file1_mtime=$(q_mtime ${TMPDIR}/${file1_base})
27
28
PKG_FILES="${PKG_FILES}/${file1_base}: {perm: 0644}${NL}"
29
PKG_SHA256="${PKG_SHA256}
30
/${file1_base} {
31
sum = \"1\$${file1_sha}\";
32
uname = \"root\";
33
gname = \"wheel\";
34
perm = \"0644\";
35
fflags = 0;
36
mtime = ${file1_mtime};
37
}"
38
39
PKG_FLATSIZE=$((${PKG_FLATSIZE}+${file1_size}))
40
shift
41
done
42
43
cat << EOF > ${PKG_NAME}.manifest
44
name: ${PKG_NAME}
45
origin: ${PKG_NAME}
46
version: 1
47
maintainer: test
48
categories: [test]
49
comment: a test
50
www: http://test
51
prefix: /
52
desc: <<EOD
53
Yet another test
54
EOD
55
files: {
56
${PKG_FILES}
57
}
58
EOF
59
60
cat << EOF > ${PKG_NAME}.expected
61
name = "${PKG_NAME}";
62
origin = "${PKG_NAME}";
63
version = "1";
64
comment = "a test";
65
maintainer = "test";
66
www = "http://test";
67
abi = "${XABI}";
68
arch = "${XALTABI}";
69
prefix = "/";
70
flatsize = ${PKG_FLATSIZE};
71
desc = "Yet another test";
72
categories [
73
"test",
74
]
75
EOF
76
if [ -n "${Xshlibs_required}" ]; then
77
echo "shlibs_required [" >> ${PKG_NAME}.expected
78
for i in ${Xshlibs_required}; do
79
echo ${NL}" "\"$i\", >> ${PKG_NAME}.expected
80
done
81
echo "]" >> ${PKG_NAME}.expected
82
fi
83
if [ -n "${Xshlibs_provided}" ]; then
84
if [ -n "${hide_provided}" ]; then
85
echo "shlibs_provided_ignore [" >> ${PKG_NAME}.expected
86
else
87
echo "shlibs_provided [" >> ${PKG_NAME}.expected
88
fi
89
for i in ${Xshlibs_provided}; do
90
echo ${NL}" "\"$i\", >> ${PKG_NAME}.expected
91
done
92
echo "]" >> ${PKG_NAME}.expected
93
fi
94
95
if [ -n "${XFreeBSD_version}" ]; then
96
cat << EOF >> ${PKG_NAME}.expected
97
annotations {
98
FreeBSD_version = "${XFreeBSD_version}";
99
}
100
EOF
101
fi
102
103
cat << EOF >> ${PKG_NAME}.expected
104
files {${PKG_SHA256}
105
}
106
EOF
107
}
108
109
do_check() {
110
local PKG_NAME=$1
111
local file1=$(atf_get_srcdir)/$2
112
local hide_provided=$3
113
114
genmanifest ${PKG_NAME} "${hide_provided}" ${file1}
115
116
# cat ${PKG_NAME}.manifest
117
atf_check \
118
-o empty \
119
-e empty \
120
-s exit:0 \
121
pkg -o IGNORE_OSMAJOR=1 -o ABI_FILE=${file1} $hide_provided \
122
create -M ./${PKG_NAME}.manifest -r ${TMPDIR}
123
124
# cat ${PKG_NAME}.expected
125
atf_check \
126
-o file:${PKG_NAME}.expected \
127
-e empty \
128
-s exit:0 \
129
pkg info -R --raw-format=ucl -F ${PKG_NAME}-1.pkg
130
}
131
132
create_from_bin_body() {
133
for bin in \
134
freebsd-aarch64.bin freebsd-amd64.bin freebsd-armv6.bin freebsd-armv7.bin \
135
freebsd-i386.bin freebsd-powerpc.bin freebsd-powerpc64.bin freebsd-powerpc64le.bin \
136
freebsd-riscv64.bin dfly.bin linux.bin \
137
macos.bin macos106.bin macos150.bin \
138
macosfat.bin "macosfat.bin#x86_64" "macosfat.bin#aarch64" \
139
macosfatlib.bin "macosfatlib.bin#x86_64" "macosfatlib.bin#aarch64"
140
do
141
do_check testbin $bin
142
do_check testbin $bin "-o SHLIB_PROVIDE_PATHS_NATIVE=/does/not/exist"
143
do_check testbin $bin "-o SHLIB_PROVIDE_IGNORE_GLOB=*"
144
done
145
}
146
147