make: Add snapshot target

Submitted by Cyrill Gorcunov on Oct. 5, 2017, 4:30 p.m.

Details

Message ID 1507221050-12696-1-git-send-email-gorcunov@openvz.org
State New
Series "make: Add snapshot target"
Headers show

Commit Message

Cyrill Gorcunov Oct. 5, 2017, 4:30 p.m.
From: Cyrill Gorcunov <gorcunov@virtuozzo.com>

Sometimes for debug sake we need to build criu from source,
and setting up git on the target machine is not an option,
or due to network slow connection it takes too much time
to upload the whole history. just pack current HEAD into
a tarball.

Signed-off-by: Cyrill Gorcunov <gorcunov@virtuozzo.com>
---
 Makefile | 9 +++++++++
 1 file changed, 9 insertions(+)

Patch hide | download patch | download mbox

diff --git a/Makefile b/Makefile
index 796cad874da2..0a465473fc72 100644
--- a/Makefile
+++ b/Makefile
@@ -310,6 +310,14 @@  tar-name := $(shell echo $(head-name) | sed -e 's/^v//g')
 dist tar: criu-$(tar-name).tar.bz2 ;
 .PHONY: dist tar
 
+ifeq ($(filter-out snapshot,$(MAKECMDGOALS)),)
+snapshot-prefix := $(shell git describe --always --long)
+snapshot-file := criu-$(snapshot-prefix).tar.bz2
+endif
+snapshot:
+	git archive --format tar --prefix 'criu-$(snapshot-prefix)/' HEAD | bzip2 > $(snapshot-file)
+.PHONY: snapshot
+
 TAGS_FILES_REGEXP := . -name '*.[hcS]' ! -path './.*' \( ! -path './test/*' -o -path './test/zdtm/lib/*' \)
 tags:
 	$(call msg-gen, $@)
@@ -356,6 +364,7 @@  TAGS_FILES_REGEXP := . -name '*.[hcS]' ! -path './.*' \( ! -path './test/*' -o -
 	@echo '      install         - Install CRIU (see INSTALL.md)'
 	@echo '      uninstall       - Uninstall CRIU'
 	@echo '      dist            - Create a source tarball'
+	@echo '      snapshot        - Create a source tarball for current HEAD'
 	@echo '      clean           - Clean most, but leave enough to navigate'
 	@echo '      mrproper        - Delete all compiled/generated files'
 	@echo '      tags            - Generate tags file (ctags)'

Comments

Andrey Vagin Oct. 6, 2017, 5:39 p.m.
On Thu, Oct 05, 2017 at 07:30:50PM +0300, Cyrill Gorcunov wrote:
> From: Cyrill Gorcunov <gorcunov@virtuozzo.com>
> 
> Sometimes for debug sake we need to build criu from source,
> and setting up git on the target machine is not an option,
> or due to network slow connection it takes too much time
> to upload the whole history. just pack current HEAD into
> a tarball.
> 
> Signed-off-by: Cyrill Gorcunov <gorcunov@virtuozzo.com>
> ---
>  Makefile | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/Makefile b/Makefile
> index 796cad874da2..0a465473fc72 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -310,6 +310,14 @@ tar-name := $(shell echo $(head-name) | sed -e 's/^v//g')
>  dist tar: criu-$(tar-name).tar.bz2 ;
>  .PHONY: dist tar
>  
> +ifeq ($(filter-out snapshot,$(MAKECMDGOALS)),)
> +snapshot-prefix := $(shell git describe --always --long)
> +snapshot-file := criu-$(snapshot-prefix).tar.bz2
> +endif
> +snapshot:

snapshot usually has another meaning when we are talking about criu, I
vote to rename this target to "tarball ".

> +	git archive --format tar --prefix 'criu-$(snapshot-prefix)/' HEAD | bzip2 > $(snapshot-file)
> +.PHONY: snapshot
> +
>  TAGS_FILES_REGEXP := . -name '*.[hcS]' ! -path './.*' \( ! -path './test/*' -o -path './test/zdtm/lib/*' \)
>  tags:
>  	$(call msg-gen, $@)
> @@ -356,6 +364,7 @@ TAGS_FILES_REGEXP := . -name '*.[hcS]' ! -path './.*' \( ! -path './test/*' -o -
>  	@echo '      install         - Install CRIU (see INSTALL.md)'
>  	@echo '      uninstall       - Uninstall CRIU'
>  	@echo '      dist            - Create a source tarball'
> +	@echo '      snapshot        - Create a source tarball for current HEAD'
>  	@echo '      clean           - Clean most, but leave enough to navigate'
>  	@echo '      mrproper        - Delete all compiled/generated files'
>  	@echo '      tags            - Generate tags file (ctags)'
> -- 
> 2.7.5
>
Cyrill Gorcunov Oct. 6, 2017, 6:25 p.m.
On Fri, Oct 06, 2017 at 10:39:54AM -0700, Andrey Vagin wrote:
> > +snapshot:
> 
> snapshot usually has another meaning when we are talking about criu, I
> vote to rename this target to "tarball ".

I don't mind. Will resend, thanks!