Gerd Hoffmann | b7f4a76 | 2014-11-17 08:32:00 +0100 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | # |
| 3 | # Script to create seabios release and snapshot tarballs. |
| 4 | # Accepts conmmit (hash, tag, branch, ...) as first argument, |
| 5 | # uses HEAD if unspecified. |
| 6 | # |
| 7 | |
| 8 | commit="${1-HEAD}" |
| 9 | |
| 10 | # figure name for the tarball |
| 11 | reltag="$(git describe --tags --match 'rel-*' --exact $commit 2>/dev/null)" |
| 12 | if test "$reltag" != ""; then |
| 13 | # release |
| 14 | name="${reltag#rel-}" |
| 15 | else |
| 16 | # snapshot |
| 17 | reltag="$(git describe --tags --match 'rel-*' $commit 2>/dev/null)" |
| 18 | name="snap-${reltag#rel-}" |
| 19 | fi |
| 20 | |
| 21 | # export tarball archive from git |
| 22 | prefix="seabios-${name}/" |
| 23 | output="seabios-${name}.tar" |
| 24 | echo "# commit $commit -> tarball: ${output}.gz" |
| 25 | rm -f "$output" "${output}.gz" |
| 26 | git archive --format=tar --prefix="$prefix" "$commit" > "$output" |
| 27 | |
| 28 | # add .version file to tarball |
| 29 | dotver="$(mktemp dotver.XXXXXX)" |
| 30 | echo "$name" > "$dotver" |
| 31 | tar --append --file="$output" --owner=root --group=root --mode=0664 \ |
| 32 | --transform "s:${dotver}:${prefix}.version:" "$dotver" |
| 33 | rm -f "$dotver" |
| 34 | |
| 35 | # finally compress it |
| 36 | gzip "$output" |