Skip to content

Commit 77780f7

Browse files
committed
kbuild: buildtar: do not print successful message if tar returns error
The previous commit spotted that "Tarball successfully created ..." is displayed even if the "tar" command returns error code because it is followed by "| ${compress}". Let the build fail instead of printing the successful message since if the "tar" command fails, the output may not be what users expect. Avoid the use of the pipe. While we are here, refactor the script removing the use of sub-shell, ${compress}, ${file_ext}. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
1 parent dd965f1 commit 77780f7

1 file changed

Lines changed: 13 additions & 16 deletions

File tree

‎scripts/package/buildtar‎

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,19 @@ tarball="${objtree}/linux-${KERNELRELEASE}-${ARCH}.tar"
2424
#
2525
case "${1}" in
2626
tar-pkg)
27-
compress="cat"
28-
file_ext=""
27+
opts=
2928
;;
3029
targz-pkg)
31-
compress="gzip"
32-
file_ext=".gz"
30+
opts=--gzip
31+
tarball=${tarball}.gz
3332
;;
3433
tarbz2-pkg)
35-
compress="bzip2"
36-
file_ext=".bz2"
34+
opts=--bzip2
35+
tarball=${tarball}.bz2
3736
;;
3837
tarxz-pkg)
39-
compress="xz"
40-
file_ext=".xz"
38+
opts=--xz
39+
tarball=${tarball}.xz
4140
;;
4241
*)
4342
echo "Unknown tarball target \"${1}\" requested, please add it to ${0}." >&2
@@ -125,14 +124,12 @@ esac
125124
#
126125
# Create the tarball
127126
#
128-
(
129-
opts=
130-
if tar --owner=root --group=root --help >/dev/null 2>&1; then
131-
opts="--owner=root --group=root"
132-
fi
133-
tar cf - -C "$tmpdir" $dirs $opts | ${compress} > "${tarball}${file_ext}"
134-
)
127+
if tar --owner=root --group=root --help >/dev/null 2>&1; then
128+
opts="$opts --owner=root --group=root"
129+
fi
130+
131+
tar cf $tarball -C $tmpdir $opts $dirs
135132

136-
echo "Tarball successfully created in ${tarball}${file_ext}"
133+
echo "Tarball successfully created in $tarball"
137134

138135
exit 0

0 commit comments

Comments
 (0)