blob: c701392d1b9dfd5b626833cc3f820bd776922ae9 (
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
|
#!/bin/sh
main()
{
run_test dir
run_test dir_slash
run_test pattern_and_links
}
t_dir()
{
mkdir foo.pkg
cat >foo.pkg/files <<-EOF
/usr/bin
EOF
mkdir -p tmp/dest/usr/bin
cd tmp
>dest/usr/bin/foo
OPK_PACKAGES='foo' ../../src/oh-installfiles
assert test_non_dir_nodes dest
assert test_nodes foo.data / /usr/ /usr/bin/ /usr/bin/foo
cd ..
rm -Rf foo.pkg tmp
}
t_dir_slash()
{
mkdir foo.pkg
cat >foo.pkg/files <<-EOF
/usr/bin/
EOF
mkdir -p tmp/dest/usr/bin
cd tmp
>dest/usr/bin/foo
OPK_PACKAGES='foo' ../../src/oh-installfiles
assert test_non_dir_nodes dest
assert test_nodes foo.data / /usr/ /usr/bin/ /usr/bin/foo
cd ..
rm -Rf foo.pkg tmp
}
t_pattern_and_links()
{
mkdir libfoo.1.pkg libfoo-dev.pkg
cat >libfoo.1.pkg/files <<-EOF
/usr/lib/*/libfoo.so.*
EOF
cat >libfoo-dev.pkg/files <<-EOF
/usr/lib/*/libfoo.so
EOF
mkdir -p tmp/dest/usr/lib/arch
cd tmp
>dest/usr/lib/arch/libfoo.so.1.0.0
ln -sf libfoo.so.1.0.0 dest/usr/lib/arch/libfoo.so.1
ln -sf libfoo.so.1 dest/usr/lib/arch/libfoo.so
OPK_PACKAGES='foo libfoo.1 libfoo-dev' ../../src/oh-installfiles
assert test_non_dir_nodes dest
assert test_nodes libfoo.1.data / /usr/ /usr/lib/ /usr/lib/arch/ \
/usr/lib/arch/libfoo.so.1.0.0 /usr/lib/arch/libfoo.so.1@
assert test_nodes libfoo-dev.data / /usr/ /usr/lib/ /usr/lib/arch/ \
/usr/lib/arch/libfoo.so@
cd ..
rm -Rf foo.pkg libfoo.1.pkg libfoo-dev.pkg tmp
}
t_foo()
{
mkdir foo.pkg libfoo.1.pkg libfoo-dev.pkg
cat >foo.pkg/files <<-EOF
/usr/bin
EOF
cat >libfoo.1.pkg/files <<-EOF
/usr/lib/*/libfoo.so.*
EOF
cat >libfoo-dev.pkg/files <<-EOF
/usr/lib/*/libfoo.so
/usr/include/
EOF
mkdir -p tmp/dest/usr/bin tmp/dest/usr/lib/arch tmp/dest/usr/include
cd tmp
>dest/usr/bin/foo
>dest/usr/lib/arch/libfoo.so.1.0.0
ln -sf libfoo.so.1.0.0 dest/usr/lib/arch/libfoo.so.1
ln -sf libfoo.so.1 dest/usr/lib/arch/libfoo.so
>dest/usr/include/foo.h
OPK_PACKAGES='foo libfoo.1 libfoo-dev' ../../src/oh-installfiles
assert [ -f foo.data/usr/bin/foo ]
assert [ -f libfoo.1.data/usr/lib/arch/libfoo.so.1.0.0 ]
assert [ -L libfoo.1.data/usr/lib/arch/libfoo.so.1 ]
assert [ -L libfoo-dev.data/usr/lib/arch/libfoo.so ]
assert [ -f libfoo-dev.data/usr/include/foo.h ]
cd ..
rm -Rf foo.pkg libfoo.1.pkg libfoo-dev.pkg tmp
}
run_test()
{
fail='false'
"t_${1}" >out 2>&1
if "${fail}"; then
printf 'FAIL: %s\n' "${1}"
cat out | sed 's/^/ /'
else
printf 'PASS: %s\n' "${1}"
fi
rm out
}
assert()
{
if ! out=$(eval 2>&1 "${@}"); then
printf 'Assertion failed: %s\n' "${*}"
printf '%s\n' "${out}" | sed 's/^/ /'
fail='true'
fi
}
test_nodes()
{
dir="${1}"
shift 1
if [ ${#} -gt 0 ]; then
printf "${dir}%s\n" "${@}" | sort >expected
else
>expected
fi
find "${dir}" -exec ls -dF '{}' ';' | sort >actual
diff -u expected actual
ret=${?}
rm -f expected actual
return ${ret}
}
test_non_dir_nodes()
{
dir="${1}"
shift 1
if [ ${#} -gt 0 ]; then
printf "${dir}%s\n" "${@}" | sort >expected
else
>expected
fi
find "${dir}" ! -type d | sort >actual
diff -u expected actual
ret=${?}
rm -f expected actual
return ${ret}
}
main "${@}"
|