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