2
* Copyright (c) 2003-2007 Tim Kientzle
3
* Copyright (c) 2009 Michihiro NAKAJIMA
6
* Redistribution and use in source and binary forms, with or without
7
* modification, are permitted provided that the following conditions
9
* 1. Redistributions of source code must retain the above copyright
10
* notice, this list of conditions and the following disclaimer.
11
* 2. Redistributions in binary form must reproduce the above copyright
12
* notice, this list of conditions and the following disclaimer in the
13
* documentation and/or other materials provided with the distribution.
15
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
16
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
19
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
Execute the following command to rebuild the data for this program:
30
tail -n +32 test_read_format_cpio_svr4_gzip_rpm.c | /bin/sh
32
F=test_read_format_cpio_svr4_gzip_rpm.rpm
36
mkdir -p ${TMPRPM}/BUILD
37
mkdir -p ${TMPRPM}/RPMS
38
mkdir -p ${TMPRPM}/SOURCES
39
mkdir -p ${TMPRPM}/SPECS
40
mkdir -p ${TMPRPM}/SRPMS
41
echo "hello" > ${TMPRPM}/BUILD/file1
42
echo "hello" > ${TMPRPM}/BUILD/file2
43
echo "hello" > ${TMPRPM}/BUILD/file3
44
cat > ${TMPRPM}/SPECS/${NAME}.spec <<END
46
%define _topdir ${TMPRPM}
47
%define _binary_payload w9.gzdio
49
Summary: Sample data of RPM filter of libarchive
54
URL: http://code.google.com/p/libarchive
56
BuildRoot: %{_tmppath}/%{name}-%{version}-root
59
rm -rf \$RPM_BUILD_ROOT
61
mkdir -p \$RPM_BUILD_ROOT%{_sysconfdir}
62
install -m 644 file1 \$RPM_BUILD_ROOT%{_sysconfdir}/file1
63
install -m 644 file2 \$RPM_BUILD_ROOT%{_sysconfdir}/file2
64
install -m 644 file3 \$RPM_BUILD_ROOT%{_sysconfdir}/file3
65
TZ=utc touch -afm -t 197001020000.01 \$RPM_BUILD_ROOT%{_sysconfdir}/file1
66
TZ=utc touch -afm -t 197001020000.01 \$RPM_BUILD_ROOT%{_sysconfdir}/file2
67
TZ=utc touch -afm -t 197001020000.01 \$RPM_BUILD_ROOT%{_sysconfdir}/file3
78
rpmbuild -bb ${TMPRPM}/SPECS/${NAME}.spec
79
uuencode ${F} < ${TMPRPM}/RPMS/noarch/${NAME}-1.0.0-1.noarch.rpm > ${F}.uu
85
DEFINE_TEST(test_read_format_cpio_svr4_gzip_rpm)
87
struct archive_entry *ae;
89
const char *name = "test_read_format_cpio_svr4_gzip_rpm.rpm";
92
assert((a = archive_read_new()) != NULL);
93
r = archive_read_support_compression_gzip(a);
94
if (r == ARCHIVE_WARN) {
95
skipping("gzip reading not fully supported on this platform");
96
assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
99
assertEqualIntA(a, ARCHIVE_OK, r);
100
assertEqualIntA(a, ARCHIVE_OK,
101
archive_read_support_compression_rpm(a));
102
assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
103
extract_reference_file(name);
104
assertEqualIntA(a, ARCHIVE_OK, archive_read_open_filename(a, name, 2));
106
assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
107
assertEqualString("./etc/file1", archive_entry_pathname(ae));
108
assertEqualInt(86401, archive_entry_mtime(ae));
109
assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
110
assertEqualString("./etc/file2", archive_entry_pathname(ae));
111
assertEqualInt(86401, archive_entry_mtime(ae));
112
assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
113
assertEqualString("./etc/file3", archive_entry_pathname(ae));
114
assertEqualInt(86401, archive_entry_mtime(ae));
116
/* Verify the end-of-archive. */
117
assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae));
119
/* Verify that the format detection worked. */
120
assertEqualInt(archive_compression(a), ARCHIVE_COMPRESSION_GZIP);
121
assertEqualString(archive_compression_name(a), "gzip");
122
assertEqualInt(archive_format(a), ARCHIVE_FORMAT_CPIO_SVR4_NOCRC);
124
assertEqualInt(ARCHIVE_OK, archive_read_close(a));
125
assertEqualInt(ARCHIVE_OK, archive_read_finish(a));