| 1 |
#!/bin/sh |
| 2 |
# |
| 3 |
# Copyright (C) 2012 Karel Zak <[email protected]> |
| 4 |
# |
| 5 |
# Usage: ko-release-gen [<directory> [<file>]] |
| 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 |
|
| 17 |
cd "$(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 |
|
| 25 |
VERSION=$(cat .version) |
| 26 |
VERSION_MAJOR=$(echo $VERSION | sed 's/-rc[0-9]//; s/\(.*\..*\)\..*/\1/') |
| 27 |
VERSION_DOCS=$(echo $VERSION | sed 's/-rc[0-9]//') |
| 28 |
DISTDIR=${1:-"kernel.org"}/v${VERSION_MAJOR} |
| 29 |
|
| 30 |
GPG_PROG=${GPG_PROG:-"gpg"} |
| 31 |
GPG_CMD="$GPG_PROG --use-agent --armor --detach-sign --quiet" |
| 32 |
|
| 33 |
die() { |
| 34 |
echo $1 |
| 35 |
exit 1 |
| 36 |
} |
| 37 |
|
| 38 |
add_file() { |
| 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 |
;; |
| 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 |
;; |
| 62 |
*) |
| 63 |
local sig="${name}.sign" |
| 64 |
cat $subdir/$name | $GPG_CMD --output $subdir/$sig |
| 65 |
;; |
| 66 |
esac |
| 67 |
echo " OK " |
| 68 |
} |
| 69 |
|
| 70 |
add_html_dir() { |
| 71 |
local src="$1" # source dir |
| 72 |
local tgt="$2" # target dir |
| 73 |
|
| 74 |
for fl in $(ls $src/*.html $src/*.css $src/*.png); do |
| 75 |
add_file $fl $tgt |
| 76 |
done |
| 77 |
} |
| 78 |
|
| 79 |
rm -rf $DISTDIR |
| 80 |
|
| 81 |
eval $(gpg-agent --daemon) |
| 82 |
|
| 83 |
# Add just specified files only |
| 84 |
if [ -f "$2" ]; then |
| 85 |
shift |
| 86 |
while (( "$#" )); do |
| 87 |
add_file "$1" |
| 88 |
shift |
| 89 |
done |
| 90 |
killall gpg-agent |
| 91 |
exit 0 |
| 92 |
fi |
| 93 |
|
| 94 |
add_file util-linux-${VERSION}.tar.xz |
| 95 |
add_file v${VERSION}-ChangeLog |
| 96 |
add_file Documentation/releases/v${VERSION_DOCS}-ReleaseNotes |
| 97 |
add_html_dir libmount/docs/html libmount-docs |
| 98 |
add_html_dir libblkid/docs/html libblkid-docs |
| 99 |
add_html_dir libsmartcols/docs/html libsmartcols-docs |
| 100 |
add_html_dir libfdisk/docs/html libfdisk-docs |
| 101 |
|
| 102 |
killall gpg-agent |
| 103 |
|