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 or 3 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 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
109 created_new_changelog=true
113 tmpfile=`mktemp -q $changelog.vctmp.XXXXXX`
114 if [ $? -ne 0 ]; then
115 echo "$0: Can't create temp file, exiting..."
118 trap "rm -f \"$tmpfile\"" EXIT
123 if [ ! $just_edit ]; then
124 echo "-------------------------------------------------------------------"
125 echo "$date - $mailaddr"
128 if [ -n "$message" ]; then
131 elif [ -n "$content" ]; then
134 elif [ ! $just_edit ]; then
141 if [ -z "$message" ]; then
142 set -- `md5sum "$tmpfile"`
144 $EDITOR +4 "$tmpfile"
145 set -- `md5sum "$tmpfile"`
146 if [ -z "$content" -a "$chksum" == "$1" ]; then
147 echo "no changes made"
148 if [ "$created_new_changelog" = true ]; then
154 mode=`stat -c "%a" "$changelog"`
155 user=`stat -c "%u:%g" "$changelog"`
156 mv "$tmpfile" "$changelog"
157 chmod $mode "$changelog"
158 chown $user "$changelog"