2 # use this script to edit *.changes files
4 # based on changelog edit script from xqf
6 # Copyright (C) 2002 Ludwig Nussel
7 # Copyright (C) 2009 SUSE Linux Products GmbH, Nuernberg, Germany.
9 # This program is free software; you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation; either version 2 of the License, or
12 # (at your option) any later version.
14 # This program is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with this program; if not, write to the Free Software
21 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
25 if [ -z "$mailaddr" ]; then
26 domain=`dnsdomainname`
27 [ -z "$domain" ] && domain=localhost
28 mailaddr="$USER@$domain"
32 date=`LC_ALL=POSIX TZ=UTC date`
34 if ! which mktemp > /dev/null 2>&1; then
35 echo "mktemp is required for this script to work"
42 if [ $just_edit ]; then
43 echo "You cannot use -m and -e together!"
50 if [ -n "${message}" ]; then
51 echo "You cannot use -m and -e together!"
58 echo "Usage: $0 [-m MESSAGE|-e] [filename[.changes]|path [file_with_comment]]"
60 echo "Will use '$mailaddr' for changelog entries"
63 echo " -m MESSAGE add MESSAGE to changes (not open an editor)"
64 echo " -e just open changes (cannot be used with -m)"
74 if [ -n "$changelog" -a -d "$changelog" ]; then
79 if [ -n "$changelog" ]; then
80 if [ "${changelog%.changes}" = "$changelog" ]; then
81 changelog="$changelog.changes"
84 changelog=($pkgpath*.changes)
85 if [ "${#changelog[@]}" -eq 1 ]; then
86 changelog="$changelog"
87 elif [ -n "$changelog" ]; then
88 echo "Choose one of ${changelog[@]}"
93 if [ -z "$changelog" ]; then
94 changelog=($pkgpath*.spec)
95 if [ "${#changelog[@]}" -eq 1 ]; then
96 changelog=${changelog%.spec}.changes
97 elif [ -n "$changelog" ]; then
98 echo "Choose one of ${changelog[@]}"
103 if [ -z "$changelog" ]; then
104 echo "no .changes and no .spec file found"
108 if [ ! -e "$changelog" ]; then
112 tmpfile=`mktemp -q $changelog.vctmp.XXXXXX`
113 if [ $? -ne 0 ]; then
114 echo "$0: Can't create temp file, exiting..."
117 trap "rm -f \"$tmpfile\"" EXIT
122 if [ ! $just_edit ]; then
123 echo "-------------------------------------------------------------------"
124 echo "$date - $mailaddr"
127 if [ -n "$message" ]; then
130 elif [ -n "$content" ]; then
133 elif [ ! $just_edit ]; then
140 if [ -z "$message" ]; then
141 set -- `md5sum "$tmpfile"`
143 $EDITOR +4 "$tmpfile"
144 set -- `md5sum "$tmpfile"`
145 if [ -z "$content" -a "$chksum" == "$1" ]; then
146 echo "no changes made"
150 mode=`stat -c "%a" "$changelog"`
151 mv "$tmpfile" "$changelog"
152 chmod $mode "$changelog"