further speedup during load. positions of branches are saved (again)
4 set -e # abort on errors
5 shopt -s nullglob # file globs that don't match expand
9 # Check if $EDITOR is set, otherwise set to "vi".
14 # Check for -f option ()
16 if [ "$1" = -f ]; then
22 # Detect the name of the file to edit
33 FILE=$(package_name $1).changelog
38 if [ -z "$FILE" ]; then
39 for f in *.changelog; do
40 if [ -n "$FILE" ]; then
48 if [ -z "$FILE" ]; then
50 if [ -n "$FILE" ]; then
56 if [ -n "$FILE" ]; then
57 FILE=$(package_name $FILE).changelog
61 if [ -z "$FILE" ]; then
62 echo "usage: ${0##*/} [filename[.changelog]|path [file_with_comment]]"
63 echo "If no <filename> is given, exactly one *.changelog or"
64 echo "*.spec file has to be in the cwd or in <path>."
70 # Add domain to username (if it's me ;-)
73 if [ $user = "uwedr" ]; then
80 # Create the lockfile and temporary file.
82 lockfile=.${FILE##*/}.lock
83 if [ "${FILE/\//}" != "$FILE" ]; then
84 lockfile=${FILE%/*}/.$lockfile
87 if [ ! -w "$(dirname "$FILE")" ]; then
88 echo "Write access to directory $(dirname "$FILE") required" >&2
92 if [ -e "$FILE" -a ! -w "$FILE" ]; then
93 echo "Write access to file $FILE required" >&2
98 while ! echo $$@$(hostname -f) 2> /dev/null > $lockfile; do
99 if [ -z "$retry_lock" ]; then
100 echo "$lockfile: Lock by process $(cat $lockfile)" >&2
101 echo "Please remove stale lockfiles manually" >&2
104 echo "$lockfile: Waiting for process $(cat $lockfile) to release lock" >&2
109 tmpfile=$(mktemp /tmp/${0##*/}.XXXXXX)
110 trap "rm -f $lockfile $tmpfile" EXIT
113 # Prepare the working copy and start the editor
116 { timestamp=$(LC_ALL=POSIX TZ=Europe/Berlin date)
117 echo "-------------------------------------------------------------------"
118 echo "$timestamp - $user"
120 if [ -z "$COMMENT_FILE" ]; then
126 if [ -f "$FILE" ]; then
132 if [ -z "$COMMENT_FILE" ]; then
134 CHKSUM_BEFORE=$(md5sum $tmpfile | awk '{print $1}')
136 lines=$(wc -l $COMMENT_FILE | awk '{print $1}')
137 CHKSUM_BEFORE=has_changed
140 $EDITOR +$((3+lines)) $tmpfile
142 if [ "$CHKSUM_BEFORE" = "$(md5sum $tmpfile | awk '{print $1}')" ]; then