]> git.ipfire.org Git - thirdparty/util-linux.git/blame - tools/ko-release-gen
tools: make ko-release-gen usable with gpg2
[thirdparty/util-linux.git] / tools / ko-release-gen
CommitLineData
a3f22567
KZ
1#!/bin/sh
2#
3# Copyright (C) 2012 Karel Zak <kzak@redhat.com>
4#
5# Usage: ko-release-gen [<directory>]
6#
7# This script prepares a new release for publishing on kernel.org. The
8# hierarchy of release files is created in the <directory> (default directory
9# is "kernel.org"). Use case:
10#
11# make distcheck
12# make changelog
13# tools/ko-release-gen
14# tools/ko-release-push
15#
16
17cd "$(git rev-parse --show-toplevel)" || {
18 echo "error: failed to chdir to git root"
19 exit 1
20}
21
22[ -f ".version" ] || \
23 echo "error: cannot found version file (call make distcheck)"
24
25VERSION=$(cat .version)
916a7438
KZ
26VERSION_MAJOR=$(echo $VERSION | sed 's/-rc[0-9]//; s/\(.*\..*\)\..*/\1/')
27VERSION_DOCS=$(echo $VERSION | sed 's/-rc[0-9]//')
a3f22567
KZ
28DISTDIR=${1:-"kernel.org"}/v${VERSION_MAJOR}
29
b5a58919
KZ
30GPG_PROG=${GPG_PROG:-"gpg"}
31GPG_CMD="$GPG_PROG --use-agent --armor --detach-sign --quiet"
a3f22567 32
7e08b7d3 33die() {
a3f22567
KZ
34 echo $1
35 exit 1
36}
37
7e08b7d3 38add_file() {
a3f22567
KZ
39 local src="$1"
40 local name=$(basename $1)
41 local subdir=$DISTDIR/${2:-""}
42
43 mkdir -p $subdir
44 cp $src $subdir || die "$src: copy failed"
45
46 [ -f $subdir/$name ] || die "$name not found"
47 echo -n " $subdir/$name ..."
48
49 case "$name" in
50 *.tar.xz)
51 local sig=$(echo "$name" | sed 's/\.tar\.xz/.tar.sign/')
52 xz -d -c $subdir/$name | $GPG_CMD --output $subdir/$sig
53 ;;
abbc7b4a
KZ
54 *.tar.gz)
55 local sig=$(echo "$name" | sed 's/\.tar\.gz/.tar.sign/')
56 gzip -d -c $subdir/$name | $GPG_CMD --output $subdir/$sig
57 ;;
58 *.tar.bz2)
59 local sig=$(echo "$name" | sed 's/\.tar\.bz2/.tar.sign/')
60 bzip2 -d -c $subdir/$name | $GPG_CMD --output $subdir/$sig
61 ;;
a3f22567
KZ
62 *)
63 local sig="${name}.sign"
64 cat $subdir/$name | $GPG_CMD --output $subdir/$sig
65 ;;
66 esac
67 echo " OK "
68}
69
7e08b7d3 70add_html_dir() {
a3f22567
KZ
71 local src="$1" # source dir
72 local tgt="$2" # target dir
73
7e08b7d3 74 for fl in $(ls $src/*.html $src/*.css $src/*.png); do
a3f22567
KZ
75 add_file $fl $tgt
76 done
77}
78
79rm -rf $DISTDIR
80
0892d88d
KZ
81eval $(gpg-agent --daemon)
82
a3f22567
KZ
83add_file util-linux-${VERSION}.tar.xz
84add_file v${VERSION}-ChangeLog
916a7438 85add_file Documentation/releases/v${VERSION_DOCS}-ReleaseNotes
a3f22567
KZ
86add_html_dir libmount/docs/html libmount-docs
87add_html_dir libblkid/docs/html libblkid-docs
ae2f2f56 88add_html_dir libsmartcols/docs/html libsmartcols-docs
94652218 89add_html_dir libfdisk/docs/html libfdisk-docs
a3f22567 90
0892d88d
KZ
91killall gpg-agent
92