linux-kbuild.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] kbuild: buildtar: fix tar error when CONFIG_MODULES is disabled
@ 2017-09-02  8:05 Masahiro Yamada
  2017-09-02  8:05 ` [PATCH 2/2] kbuild: buildtar: do not print successful message if tar returns error Masahiro Yamada
  0 siblings, 1 reply; 2+ messages in thread
From: Masahiro Yamada @ 2017-09-02  8:05 UTC (permalink / raw)
  To: linux-kbuild; +Cc: Masahiro Yamada, Michal Marek, linux-kernel

$tmpdir/lib is created by "make modules_install".  It does not exist
if CONFIG_MODULES is disabled, then tar reports the following messages:

tar: lib: Cannot stat: No such file or directory
tar: Exiting with failure status due to previous errors

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
---

 scripts/package/buildtar | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/scripts/package/buildtar b/scripts/package/buildtar
index 483ba00524d5..60dd836a0214 100755
--- a/scripts/package/buildtar
+++ b/scripts/package/buildtar
@@ -51,13 +51,14 @@ esac
 #
 rm -rf -- "${tmpdir}"
 mkdir -p -- "${tmpdir}/boot"
-
+dirs=boot
 
 #
 # Try to install modules
 #
 if grep -q '^CONFIG_MODULES=y' "${KCONFIG_CONFIG}"; then
 	make ARCH="${ARCH}" O="${objtree}" KBUILD_SRC= INSTALL_MOD_PATH="${tmpdir}" modules_install
+	dirs="$dirs lib"
 fi
 
 
@@ -129,7 +130,7 @@ esac
 	if tar --owner=root --group=root --help >/dev/null 2>&1; then
 		opts="--owner=root --group=root"
 	fi
-	tar cf - -C "$tmpdir" boot/ lib/ $opts | ${compress} > "${tarball}${file_ext}"
+	tar cf - -C "$tmpdir" $dirs $opts | ${compress} > "${tarball}${file_ext}"
 )
 
 echo "Tarball successfully created in ${tarball}${file_ext}"
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [PATCH 2/2] kbuild: buildtar: do not print successful message if tar returns error
  2017-09-02  8:05 [PATCH 1/2] kbuild: buildtar: fix tar error when CONFIG_MODULES is disabled Masahiro Yamada
@ 2017-09-02  8:05 ` Masahiro Yamada
  0 siblings, 0 replies; 2+ messages in thread
From: Masahiro Yamada @ 2017-09-02  8:05 UTC (permalink / raw)
  To: linux-kbuild; +Cc: Masahiro Yamada, Michal Marek, linux-kernel

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>
---

 scripts/package/buildtar | 29 +++++++++++++----------------
 1 file changed, 13 insertions(+), 16 deletions(-)

diff --git a/scripts/package/buildtar b/scripts/package/buildtar
index 60dd836a0214..51f947118256 100755
--- a/scripts/package/buildtar
+++ b/scripts/package/buildtar
@@ -24,20 +24,19 @@ tarball="${objtree}/linux-${KERNELRELEASE}-${ARCH}.tar"
 #
 case "${1}" in
 	tar-pkg)
-		compress="cat"
-		file_ext=""
+		opts=
 		;;
 	targz-pkg)
-		compress="gzip"
-		file_ext=".gz"
+		opts=--gzip
+		tarball=${tarball}.gz
 		;;
 	tarbz2-pkg)
-		compress="bzip2"
-		file_ext=".bz2"
+		opts=--bzip2
+		tarball=${tarball}.bz2
 		;;
 	tarxz-pkg)
-		compress="xz"
-		file_ext=".xz"
+		opts=--xz
+		tarball=${tarball}.xz
 		;;
 	*)
 		echo "Unknown tarball target \"${1}\" requested, please add it to ${0}." >&2
@@ -125,14 +124,12 @@ esac
 #
 # Create the tarball
 #
-(
-	opts=
-	if tar --owner=root --group=root --help >/dev/null 2>&1; then
-		opts="--owner=root --group=root"
-	fi
-	tar cf - -C "$tmpdir" $dirs $opts | ${compress} > "${tarball}${file_ext}"
-)
+if tar --owner=root --group=root --help >/dev/null 2>&1; then
+	opts="$opts --owner=root --group=root"
+fi
+
+tar cf $tarball -C $tmpdir $opts $dirs
 
-echo "Tarball successfully created in ${tarball}${file_ext}"
+echo "Tarball successfully created in $tarball"
 
 exit 0
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-09-02  8:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-02  8:05 [PATCH 1/2] kbuild: buildtar: fix tar error when CONFIG_MODULES is disabled Masahiro Yamada
2017-09-02  8:05 ` [PATCH 2/2] kbuild: buildtar: do not print successful message if tar returns error Masahiro Yamada

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).