Skip to contentSkip to conversation

build: add make dist target (v2)

PATCH In review Anthony Liguori 5 participants 6 messages Jul 17, 2012 – Jul 18, 2012 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 build: add make dist target (v2)

Let's stop screwing up releases by having a script do the work that Anthony's fat fingers can't seem to get right.

---
v1 -> v2
- include the scripts for real this time
- remove tar/tarbin from PHONY

---
 Makefile             |   19 ++++++++-----------
 scripts/make-release |   24 ++++++++++++++++++++++++
 2 files changed, 32 insertions(+), 11 deletions(-)
 create mode 100755 scripts/make-release
Makefile +8 -11
index 9707fa0..abf825d 100644
@@ -31,7 +31,7 @@ Makefile: ;
 configure: ;
 
 .PHONY: all clean cscope distclean dvi html info install install-doc \
-	pdf recurse-all speed tar tarbin test build-all
+	pdf recurse-all speed test build-all dist
 
 $(call set-vpath, $(SRC_PATH):$(SRC_PATH)/hw)
 
@@ -232,6 +232,13 @@ clean:
 	rm -f $$d/qemu-options.def; \
         done
 
+VERSION ?= $(shell cat VERSION)
+
+dist: qemu-$(VERSION).tar.bz2
+
+qemu-%.tar.bz2:
+	$(SRC_PATH)/scripts/make-release "$(SRC_PATH)" "$(patsubst qemu-%.tar.bz2,%,$@)"
+
 distclean: clean
 	rm -f config-host.mak config-host.h* config-host.ld $(DOCS) qemu-options.texi qemu-img-cmds.texi qemu-monitor.texi
 	rm -f config-all-devices.mak
@@ -390,15 +397,5 @@ qemu-doc.dvi qemu-doc.html qemu-doc.info qemu-doc.pdf: \
 	qemu-img.texi qemu-nbd.texi qemu-options.texi \
 	qemu-monitor.texi qemu-img-cmds.texi
 
-VERSION ?= $(shell cat VERSION)
-FILE = qemu-$(VERSION)
-
-# tar release (use 'make -k tar' on a checkouted tree)
-tar:
-	rm -rf /tmp/$(FILE)
-	cp -r . /tmp/$(FILE)
-	cd /tmp && tar zcvf ~/$(FILE).tar.gz $(FILE) --exclude CVS --exclude .git --exclude .svn
-	rm -rf /tmp/$(FILE)
-
 # Include automatically generated dependency files
 -include $(wildcard *.d audio/*.d slirp/*.d block/*.d net/*.d ui/*.d qapi/*.d qga/*.d)
scripts/make-release new file +24 -0
new file mode 100755
index 0000000..196c755
@@ -0,0 +1,24 @@
+#!/bin/bash -e
+#
+# QEMU Release Script
+#
+# Copyright IBM, Corp. 2012
+#
+# Authors:
+#  Anthony Liguori <[email protected]>
+#
+# This work is licensed under the terms of the GNU GPLv2 or later.
+# See the COPYING file in the top-level directory.
+
+src="$1"
+version="$2"
+destination=qemu-${version}
+
+git clone "${src}" ${destination}
+pushd ${destination}
+git checkout "v${version}"
+git submodule update --init
+rm -rf .git roms/*/.git
+popd
+tar cfj ${destination}.tar.bz2 ${destination}
+rm -rf ${destination}
Signature · 1 line
1.7.5.4
Reviewed-by on v1 1/1
#1 lore raw

scripts/make-release line 1

Quoted 9 lines · Anthony Liguori

Let's stop screwing up releases by having a script do the work that Anthony's fat fingers can't seem to get right.

---
+++ b/scripts/make-release

scripts/make-release new file +1 -0
@@ -0,0 +1,24 @@
+#!/bin/bash -e

Is it worth tightening this up to avoid bashisms like pushd, and use just POSIX sh?

scripts/make-release line 15

Quoted 6 lines
scripts/make-release new file +6 -0
+# This work is licensed under the terms of the GNU GPLv2 or later.
+# See the COPYING file in the top-level directory.
+
+src="$1"
+version="$2"
+destination=qemu-${version}

Inconsistent quoting. The fact that you quoted $2 when assigning to version makes me worry that you are trying to plan for someone calling this script where $2 contains whitespace, but then destination would contain whitespace. This is equivalent with minimal typing (regardless of whitespace, since variable assignment is not subject to word splitting):

src=$1
version=$2
destination=qemu-$version

or if you want to consistently use full quoting:

src="${1}"
version="${2}"
destination="qemu-${version}"

Review line 9

Quoted 2 lines
(quoted diff) +2 -0
+
+git clone "${src}" ${destination}

But here is a line where it matters if $destination contains whitespace because $2 contained whitespace.

scripts/make-release line 22

Quoted 5 lines
scripts/make-release new file +5 -0
+pushd ${destination}
+git checkout "v${version}"
+git submodule update --init
+rm -rf .git roms/*/.git
+popd

The POSIX spelling to avoid pushd would be:

(
cd $destination
git checkout v$version
git submodule update --init
rm -rf .git roms/*/.git
)

[again, I did minimal typing; you may prefer the "v${version}" style instead of minimalism]

scripts/make-release line 23

Quoted 1 line
scripts/make-release new file +1 -0
+tar cfj ${destination}.tar.bz2 ${destination}

'j' is a GNU tar extension. Are you okay hard-coding this script to only run on machines with GNU tar? Or should you split this into 'tar c ... | bzip2 ...'?

scripts/make-release line 24

Quoted 2 lines
scripts/make-release new file +1 -0
+rm -rf ${destination}

For the record, I think releases are done so seldom, and on a controlled-enough environment where extra tools can be relied on, that this script probably does not have to be super-portable. Therefore, since what you have works for your environment, then even though I raked it over the portability coals above I'm okay if you use it as-is rather than posting a v3. Hence, I give my:

Signature · 2 lines
Eric Blake   [email protected]    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
Tested-by on v1 1/1
#2 lore raw
In reply to Anthony Liguori
Quoted 5 lines · Anthony Liguori

Let's stop screwing up releases by having a script do the work that Anthony's fat fingers can't seem to get right.

Breaks if there's no tag corresponding with the contents of VERSION, but that might be considered a feature (an alternative might be to assume it's a development release, use current HEAD for master, and append the short git hash to the version). Works well as far as I can tell though, and I made a special point to confirm it did indeed output a bz2 :)

Quoted 86 lines

---
v1 -> v2
- include the scripts for real this time
- remove tar/tarbin from PHONY

---
 Makefile             |   19 ++++++++-----------
 scripts/make-release |   24 ++++++++++++++++++++++++
 2 files changed, 32 insertions(+), 11 deletions(-)
 create mode 100755 scripts/make-release
Makefile +8 -11
index 9707fa0..abf825d 100644
@@ -31,7 +31,7 @@ Makefile: ;
 configure: ;
 
 .PHONY: all clean cscope distclean dvi html info install install-doc \
-	pdf recurse-all speed tar tarbin test build-all
+	pdf recurse-all speed test build-all dist
 
 $(call set-vpath, $(SRC_PATH):$(SRC_PATH)/hw)
 
@@ -232,6 +232,13 @@ clean:
 	rm -f $$d/qemu-options.def; \
         done
 
+VERSION ?= $(shell cat VERSION)
+
+dist: qemu-$(VERSION).tar.bz2
+
+qemu-%.tar.bz2:
+	$(SRC_PATH)/scripts/make-release "$(SRC_PATH)" "$(patsubst qemu-%.tar.bz2,%,$@)"
+
 distclean: clean
 	rm -f config-host.mak config-host.h* config-host.ld $(DOCS) qemu-options.texi qemu-img-cmds.texi qemu-monitor.texi
 	rm -f config-all-devices.mak
@@ -390,15 +397,5 @@ qemu-doc.dvi qemu-doc.html qemu-doc.info qemu-doc.pdf: \
 	qemu-img.texi qemu-nbd.texi qemu-options.texi \
 	qemu-monitor.texi qemu-img-cmds.texi
 
-VERSION ?= $(shell cat VERSION)
-FILE = qemu-$(VERSION)
-
-# tar release (use 'make -k tar' on a checkouted tree)
-tar:
-	rm -rf /tmp/$(FILE)
-	cp -r . /tmp/$(FILE)
-	cd /tmp && tar zcvf ~/$(FILE).tar.gz $(FILE) --exclude CVS --exclude .git --exclude .svn
-	rm -rf /tmp/$(FILE)
-
 # Include automatically generated dependency files
 -include $(wildcard *.d audio/*.d slirp/*.d block/*.d net/*.d ui/*.d qapi/*.d qga/*.d)
scripts/make-release new file +24 -0
new file mode 100755
index 0000000..196c755
@@ -0,0 +1,24 @@
+#!/bin/bash -e
+#
+# QEMU Release Script
+#
+# Copyright IBM, Corp. 2012
+#
+# Authors:
+#  Anthony Liguori <[email protected]>
+#
+# This work is licensed under the terms of the GNU GPLv2 or later.
+# See the COPYING file in the top-level directory.
+
+src="$1"
+version="$2"
+destination=qemu-${version}
+
+git clone "${src}" ${destination}
+pushd ${destination}
+git checkout "v${version}"
+git submodule update --init
+rm -rf .git roms/*/.git
+popd
+tar cfj ${destination}.tar.bz2 ${destination}
+rm -rf ${destination}
Signature · 1 line
1.7.5.4
#3 lore raw
Quoted 4 lines · Michael Roth
Quoted 3 lines · Anthony Liguori

Let's stop screwing up releases by having a script do the work that Anthony's fat fingers can't seem to get right.

Quoted 8 lines
Quoted 2 lines

Breaks if there's no tag corresponding with the contents of VERSION, but that might be considered a feature (an alternative might be to assume it's a development release, use current HEAD for master, and append the short git hash to the version). Works well as far as I can tell though, and I made a special point to confirm it did indeed output a bz2 :)

Or just use 'git describe --long' to figure what the version is. This way you can easily build a tarball for any git commit, and a release tarball is just 'git checkout v$version; make dist'.

cheers,
Gerd

#4 lore raw
Quoted 14 lines · Gerd Hoffmann
Quoted 4 lines · Michael Roth
Quoted 3 lines · Anthony Liguori

Let's stop screwing up releases by having a script do the work that Anthony's fat fingers can't seem to get right.

Quoted 8 lines
Quoted 2 lines

Breaks if there's no tag corresponding with the contents of VERSION, but that might be considered a feature (an alternative might be to assume it's a development release, use current HEAD for master, and append the short git hash to the version). Works well as far as I can tell though, and I made a special point to confirm it did indeed output a bz2 :)

Quoted 3 lines

Or just use 'git describe --long' to figure what the version is. This way you can easily build a tarball for any git commit, and a release tarball is just 'git checkout v$version; make dist'.

As long as it doesn't break release tarballs, I'm very open to patches to make this more generally useful.

Regards,

Anthony Liguori

Quoted 3 lines

cheers,
Gerd

#5 lore raw
In reply to Anthony Liguori
Quoted 78 lines · Anthony Liguori

Let's stop screwing up releases by having a script do the work that Anthony's fat fingers can't seem to get right.

---
v1 -> v2
- include the scripts for real this time
- remove tar/tarbin from PHONY

---
 Makefile             |   19 ++++++++-----------
 scripts/make-release |   24 ++++++++++++++++++++++++
 2 files changed, 32 insertions(+), 11 deletions(-)
 create mode 100755 scripts/make-release
Makefile +8 -11
index 9707fa0..abf825d 100644
@@ -31,7 +31,7 @@ Makefile: ;
 configure: ;
 
 .PHONY: all clean cscope distclean dvi html info install install-doc \
-	pdf recurse-all speed tar tarbin test build-all
+	pdf recurse-all speed test build-all dist
 
 $(call set-vpath, $(SRC_PATH):$(SRC_PATH)/hw)
 
@@ -232,6 +232,13 @@ clean:
 	rm -f $$d/qemu-options.def; \
         done
 
+VERSION ?= $(shell cat VERSION)
+
+dist: qemu-$(VERSION).tar.bz2
+
+qemu-%.tar.bz2:
+	$(SRC_PATH)/scripts/make-release "$(SRC_PATH)" "$(patsubst qemu-%.tar.bz2,%,$@)"
+
 distclean: clean
 	rm -f config-host.mak config-host.h* config-host.ld $(DOCS) qemu-options.texi qemu-img-cmds.texi qemu-monitor.texi
 	rm -f config-all-devices.mak
@@ -390,15 +397,5 @@ qemu-doc.dvi qemu-doc.html qemu-doc.info qemu-doc.pdf: \
 	qemu-img.texi qemu-nbd.texi qemu-options.texi \
 	qemu-monitor.texi qemu-img-cmds.texi
 
-VERSION ?= $(shell cat VERSION)
-FILE = qemu-$(VERSION)
-
-# tar release (use 'make -k tar' on a checkouted tree)
-tar:
-	rm -rf /tmp/$(FILE)
-	cp -r . /tmp/$(FILE)
-	cd /tmp && tar zcvf ~/$(FILE).tar.gz $(FILE) --exclude CVS --exclude .git --exclude .svn
-	rm -rf /tmp/$(FILE)
-
 # Include automatically generated dependency files
 -include $(wildcard *.d audio/*.d slirp/*.d block/*.d net/*.d ui/*.d qapi/*.d qga/*.d)
scripts/make-release new file +14 -0
new file mode 100755
index 0000000..196c755
@@ -0,0 +1,24 @@
+#!/bin/bash -e
+#
+# QEMU Release Script
+#
+# Copyright IBM, Corp. 2012
+#
+# Authors:
+#  Anthony Liguori <[email protected]>
+#
+# This work is licensed under the terms of the GNU GPLv2 or later.
+# See the COPYING file in the top-level directory.
+
+src="$1"
+version="$2"

scripts/make-release line 24

Quoted 10 lines
scripts/make-release new file +10 -0
+destination=qemu-${version}
+
+git clone "${src}" ${destination}
+pushd ${destination}
+git checkout "v${version}"
+git submodule update --init
+rm -rf .git roms/*/.git
+popd
+tar cfj ${destination}.tar.bz2 ${destination}
+rm -rf ${destination}

Fancy providing an XZ compressed archive, in addition to the bz2 one? It is almost 20% smaller with XZ with default compression levels...

$ ls -ahl qemu-1.1.1-1.tar*
-rw-rw-r--. 1 berrange berrange 9.2M Jul 17 19:20 qemu-1.1.1-1.tar.bz2
-rw-rw-r--. 1 berrange berrange 7.6M Jul 18 15:03 qemu-1.1.1-1.tar.xz

You can get it down to 7.3M if you use xz --best

Regards,
Daniel

Signature · 4 lines
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|