xref: /illumos-kvm-cmd/kvm/scripts/make-release (revision 68396ea9)
1#!/bin/bash -e
2
3usage() {
4    echo "usage: $0 [--upload] [--formal] commit [name] [tarball] [user]"
5    exit 1
6}
7
8[[ -f ~/.kvmreleaserc ]] && . ~/.kvmreleaserc
9
10upload=
11formal=
12
13releasedir=~/sf-release
14[[ -z "$TMP" ]] && TMP="/tmp"
15tmpdir=`mktemp -d "$TMP/qemu-kvm-make-release.XXXXXXXXXX"`
16while [[ "$1" = -* ]]; do
17    opt="$1"
18    shift
19    case "$opt" in
20	--upload)
21	    upload="yes"
22	    ;;
23	--formal)
24	    formal="yes"
25	    ;;
26	*)
27	    usage
28	    ;;
29    esac
30done
31
32commit="$1"
33name="$2"
34
35if [[ -z "$commit" ]]; then
36    usage
37fi
38
39if [[ -z "$name" ]]; then
40    name="$commit"
41fi
42
43tarball="$3"
44if [[ -z "$tarball" ]]; then
45    tarball="$releasedir/$name.tar.gz"
46fi
47#strip trailing .gz if any
48tarball=${tarball/%.gz/}
49
50cd "$(dirname "$0")"/../..
51mkdir -p "$(dirname "$tarball")"
52git archive --prefix="$name/" --format=tar "$commit" > "$tarball"
53
54mtime=`git show --pretty=format:%ct "$commit""^{commit}" -- | head -n 1`
55tarargs="--owner=root --group=root"
56
57mkdir -p "$tmpdir/$name"
58git cat-file -p "${commit}:roms" | awk ' { print $4, $3 } ' \
59    > "$tmpdir/$name/EXTERNAL_DEPENDENCIES"
60touch -d "@$mtime" "$tmpdir/$name/EXTERNAL_DEPENDENCIES"
61tar -rf "$tarball" -C "$tmpdir" \
62    $tarargs \
63    "$name/EXTERNAL_DEPENDENCIES"
64rm -rf "$tmpdir"
65
66if [[ -n "$formal" ]]; then
67    mkdir -p "$tmpdir/$name"
68    echo "$name" > "$tmpdir/$name/KVM_VERSION"
69    touch -d "@$mtime" "$tmpdir/$name/KVM_VERSION"
70    tar -rf "$tarball" -C "$tmpdir" "$name/KVM_VERSION" \
71        $tarargs
72    rm -rf "$tmpdir"
73fi
74
75rm -f "$tarball.gz"
76gzip -9 "$tarball"
77tarball="$tarball.gz"
78
79if [[ -n "$upload" ]]; then
80    rsync --progress -h "$tarball" avik@frs.sourceforge.net:uploads/
81fi
82