Skip to content

Commit

Permalink
fixup! Handle file install failures more gracefully
Browse files Browse the repository at this point in the history
  • Loading branch information
pmatilai committed Feb 15, 2021
1 parent 775ca00 commit 0c0845c
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 32 deletions.
4 changes: 4 additions & 0 deletions tests/data/SPECS/hlinktest.spec
@@ -1,6 +1,7 @@
%bcond_with unpackaged_dirs
%bcond_with unpackaged_files
%bcond_with unpackaged_excludes
%bcond_with owned_dir

Summary: Testing hard link behavior
Name: hlinktest
Expand Down Expand Up @@ -43,6 +44,9 @@ touch $RPM_BUILD_ROOT/teet

%files
%defattr(-,root,root)
%if %{with owned_dir}
%dir /foo
%endif
/foo/*
%if %{with unpackaged_excludes}
%exclude /teet
Expand Down
32 changes: 0 additions & 32 deletions tests/rpmbuild.at
Expand Up @@ -253,38 +253,6 @@ drwxrwxrwx zoot zoot /j/dir
[])
AT_CLEANUP

# ------------------------------
# hardlink tests
AT_SETUP([rpmbuild hardlink])
AT_KEYWORDS([build])
RPMDB_INIT
AT_CHECK([
RPMDB_INIT

runroot rpmbuild \
-bb --quiet /data/SPECS/hlinktest.spec

runroot rpm -i /build/RPMS/noarch/hlinktest-1.0-1.noarch.rpm

runroot rpm -q --qf "[[%{filenlinks} %{filenames}\n]]%{longsize}\n" hlinktest
runroot rpm -V --nouser --nogroup hlinktest
ls -i "${RPMTEST}"/foo/hello* | awk {'print $1'} | sort -u | wc -l

],
[0],
[2 /foo/aaaa
1 /foo/copyllo
4 /foo/hello
4 /foo/hello-bar
4 /foo/hello-foo
4 /foo/hello-world
2 /foo/zzzz
87
1
],
[])
AT_CLEANUP

AT_SETUP([rpmbuild unpackaged files])
AT_KEYWORDS([build])
RPMDB_INIT
Expand Down
69 changes: 69 additions & 0 deletions tests/rpmi.at
Expand Up @@ -722,3 +722,72 @@ runroot rpm -V --nouser --nogroup suicidal
[],
[])
AT_CLEANUP

# ------------------------------
# hardlink tests
AT_SETUP([rpm -i hardlinks])
AT_KEYWORDS([build install])
RPMDB_INIT

runroot rpmbuild \
--define "_binary_payload w.ufdio" \
--with owned_dir \
-bb --quiet /data/SPECS/hlinktest.spec

pkg="/build/RPMS/noarch/hlinktest-1.0-1.noarch.rpm"

cp "${RPMTEST}/${pkg}" "${RPMTEST}/tmp/1.rpm"
dd if=/dev/zero of="${RPMTEST}/tmp/1.rpm" \
conv=notrunc bs=1 seek=8180 count=6 2> /dev/null

cp "${RPMTEST}/${pkg}" "${RPMTEST}/tmp/2.rpm"
dd if=/dev/zero of="${RPMTEST}/tmp/2.rpm" \
conv=notrunc bs=1 seek=8170 count=6 2> /dev/null

AT_CHECK([
RPMDB_INIT
runroot rpm -i --noverify /tmp/1.rpm
# test that nothing of the contents remains after failure
test -d "${RPMTEST}/foo"
],
[1],
[],
[error: unpacking of archive failed: cpio: Archive file not in header
error: hlinktest-1.0-1.noarch: install failed
])

AT_CHECK([
RPMDB_INIT
runroot rpm -i --noverify /tmp/2.rpm
# test that nothing of the contents remains after failure
test -d "${RPMTEST}/foo"
],
[1],
[],
[error: unpacking of archive failed: cpio: Bad/unreadable header
error: hlinktest-1.0-1.noarch: install failed
])

AT_CHECK([
RPMDB_INIT
runroot rpm -i /build/RPMS/noarch/hlinktest-1.0-1.noarch.rpm
runroot rpm -q --qf "[[%{filenlinks} %{filenames}\n]]%{longsize}\n" hlinktest
ls -i "${RPMTEST}"/foo/hello* | awk {'print $1'} | sort -u | wc -l
runroot rpm -e hlinktest

],
[0],
[1 /foo
2 /foo/aaaa
1 /foo/copyllo
4 /foo/hello
4 /foo/hello-bar
4 /foo/hello-foo
4 /foo/hello-world
2 /foo/zzzz
87
1
],
[])
AT_CLEANUP

0 comments on commit 0c0845c

Please sign in to comment.