diff mbox series

[v6,06/12] kbuild: deb-pkg: make .orig tarball a hard link if possible

Message ID 20230215012034.403356-6-masahiroy@kernel.org (mailing list archive)
State New, archived
Headers show
Series [v6,01/12] kbuild: add a tool to list files ignored by git | expand

Commit Message

Masahiro Yamada Feb. 15, 2023, 1:20 a.m. UTC
If '..' belongs to the same filesystem, create a hard link instead of
a copy. In most cases, you can save disk space.

I do not want to use 'mv' because keeping linux.tar.gz is useful to
avoid unneeded rebuilding of the tarball.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---

Changes in v6:
  - New patch

 scripts/Makefile.package | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Comments

Nicolas Schier Feb. 24, 2023, 10:37 p.m. UTC | #1
On Wed, Feb 15, 2023 at 10:20:28AM +0900 Masahiro Yamada wrote:
> If '..' belongs to the same filesystem, create a hard link instead of
> a copy. In most cases, you can save disk space.
> 
> I do not want to use 'mv' because keeping linux.tar.gz is useful to
> avoid unneeded rebuilding of the tarball.
> 
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> ---
> 
> Changes in v6:
>   - New patch
> 
>  scripts/Makefile.package | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/scripts/Makefile.package b/scripts/Makefile.package
> index c207f4ec47ac..80a96eb61426 100644
> --- a/scripts/Makefile.package
> +++ b/scripts/Makefile.package
> @@ -96,7 +96,11 @@ debian-orig: private source = $(shell dpkg-parsechangelog -S Source)
>  debian-orig: private version = $(shell dpkg-parsechangelog -S Version | sed 's/-[^-]*$$//')
>  debian-orig: private orig-name = $(source)_$(version).orig.tar.gz
>  debian-orig: linux.tar.gz debian
> -	$(Q)cp $< ../$(orig-name)
> +	$(Q)if [ "$(df  --output=target .. 2>/dev/null)" = "$(df --output=target $< 2>/dev/null)" ]; then \
> +		ln -f $< ../$(orig-name); \
> +	else \
> +		cp $< ../$(orig-name); \
> +	fi
>  
>  PHONY += deb-pkg
>  deb-pkg: debian-orig
> -- 
> 2.34.1

Reviewed-by: Nicolas Schier <nicolas@fjasle.eu>
diff mbox series

Patch

diff --git a/scripts/Makefile.package b/scripts/Makefile.package
index c207f4ec47ac..80a96eb61426 100644
--- a/scripts/Makefile.package
+++ b/scripts/Makefile.package
@@ -96,7 +96,11 @@  debian-orig: private source = $(shell dpkg-parsechangelog -S Source)
 debian-orig: private version = $(shell dpkg-parsechangelog -S Version | sed 's/-[^-]*$$//')
 debian-orig: private orig-name = $(source)_$(version).orig.tar.gz
 debian-orig: linux.tar.gz debian
-	$(Q)cp $< ../$(orig-name)
+	$(Q)if [ "$(df  --output=target .. 2>/dev/null)" = "$(df --output=target $< 2>/dev/null)" ]; then \
+		ln -f $< ../$(orig-name); \
+	else \
+		cp $< ../$(orig-name); \
+	fi
 
 PHONY += deb-pkg
 deb-pkg: debian-orig