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>

+13 -16
+13 -16
scripts/package/buildtar
··· 24 24 # 25 25 case "${1}" in 26 26 tar-pkg) 27 - compress="cat" 28 - file_ext="" 27 + opts= 29 28 ;; 30 29 targz-pkg) 31 - compress="gzip" 32 - file_ext=".gz" 30 + opts=--gzip 31 + tarball=${tarball}.gz 33 32 ;; 34 33 tarbz2-pkg) 35 - compress="bzip2" 36 - file_ext=".bz2" 34 + opts=--bzip2 35 + tarball=${tarball}.bz2 37 36 ;; 38 37 tarxz-pkg) 39 - compress="xz" 40 - file_ext=".xz" 38 + opts=--xz 39 + tarball=${tarball}.xz 41 40 ;; 42 41 *) 43 42 echo "Unknown tarball target \"${1}\" requested, please add it to ${0}." >&2 ··· 124 125 # 125 126 # Create the tarball 126 127 # 127 - ( 128 - opts= 129 - if tar --owner=root --group=root --help >/dev/null 2>&1; then 130 - opts="--owner=root --group=root" 131 - fi 132 - tar cf - -C "$tmpdir" $dirs $opts | ${compress} > "${tarball}${file_ext}" 133 - ) 128 + if tar --owner=root --group=root --help >/dev/null 2>&1; then 129 + opts="$opts --owner=root --group=root" 130 + fi 134 131 135 - echo "Tarball successfully created in ${tarball}${file_ext}" 132 + tar cf $tarball -C $tmpdir $opts $dirs 133 + 134 + echo "Tarball successfully created in $tarball" 136 135 137 136 exit 0