summaryrefslogtreecommitdiffstats
path: root/scripts/list-unreleased.sh
blob: 05ed06bcc9486cd92e5e9ae36f52c4e444fb257b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/bin/bash

# Script searches for packages with pending changes (UNRELEASED) and
# either lists them or displays the relevant changelog entry.

# Usage: list-unreleased [-cR]
#        -c : display pending changes
#        -R : don't recurse

# Copyright: Frans Pop <elendil@planet.nl>, 2007
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the Free
# Software Foundation; either version 2 of the License, or (at your option)
# any later version.

PATHS=""
DO_CL=""
RECURSE=1

while true; do
	case "$1" in
	    "")
		break ;;
	    -c)
		DO_CL=1
		;;
	    -R)
		RECURSE=
		;;
	    -*)
		echo "unrecognized argument '$1'"
		exit 1
		;;
	    *)
		PATHS="${PATHS:+$PATHS }$1"
		;;
	esac
	shift
done

[ "$PATHS" ] || PATHS=.

vcs_dirs='\(\.\(svn\|hg\|git\|bzr\)\|_darcs\|_MTN\|CVS\)'
get_list() {
	local path="$1"

	for dir in $(
		if [ "$RECURSE" ]; then
			find "$path" -type d ! -regex "$vcs_dirs"
		else
			find "$path" -maxdepth 1 -type d ! -regex "$vcs_dirs"
		fi
	); do
		changelog="$dir/debian/changelog"
		if [ -f "$changelog" ] ; then
			if head -n1 "$changelog" | grep -q UNRELEASED; then
				echo $dir
			fi
		fi
	done | sort
}

print_cl() {
	local package="$1"
	changelog="$package/debian/changelog"

	# Check if more than one UNRELEASED entry at top of changelog
	Ucount=$(grep "^[^ ]" $changelog | \
		 head -n2 | grep -c UNRELEASED)
	if [ $Ucount -eq 1 ]; then
		sed -n "1,/^ --/p" $changelog
	else
		echo "ERROR: changelog has more than one UNRELEASED entry!"
		# Second sed is to add back a blank line between entries
		sed -n "/^[^ ].*UNRELEASED/,/^ --/p" $changelog | \
			sed '2,$s/^\([^ ]\)/\n\1/'
	fi
}

first=""
for path in $PATHS; do
	if [ -z "$DO_CL" ]; then
		echo "$(get_list "$path" | sed "s:^\./::")"
	else
		for package in $(get_list "$path"); do
			[ -z "$first" ] || echo -e "\n====================\n"
			first=1

			print_cl "$package"
		done
	fi
done