From 6277590bafd175bf39a3dbf006fb7c9643ab68d3 Mon Sep 17 00:00:00 2001 From: Ludwig Nussel Date: Fri, 17 Apr 2009 12:06:52 +0000 Subject: [PATCH] build: add vc command --- Makefile | 2 + vc | 130 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 132 insertions(+) create mode 100755 vc diff --git a/Makefile b/Makefile index 2ac06e8..354142c 100644 --- a/Makefile +++ b/Makefile @@ -26,6 +26,7 @@ install: $(DESTDIR)$(man1dir) install -m755 \ build \ + vc \ createrpmdeps \ order \ expanddeps \ @@ -49,6 +50,7 @@ install: install -m644 build.1 $(DESTDIR)$(man1dir) install -m755 unrpm $(DESTDIR)$(bindir) ln -sf $(pkglibdir)/build $(DESTDIR)$(bindir)/build + ln -sf $(pkglibdir)/build $(DESTDIR)$(bindir)/buildvc dist: ifeq ($(SCM),svn) diff --git a/vc b/vc new file mode 100755 index 0000000..45db3e9 --- /dev/null +++ b/vc @@ -0,0 +1,130 @@ +#!/bin/bash +# use this script to edit *.changes files +# +# based on changelog edit script from xqf +# +# Copyright (C) 2002 Ludwig Nussel +# Copyright (C) 2009 SUSE Linux Products GmbH, Nuernberg, Germany. +# +# 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. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + +shopt -s nullglob + +if [ -z "$mailaddr" ]; then + domain=`dnsdomainname` + [ -z "$domain" ] && domain=localhost + mailaddr="$USER@$domain" +fi + +EDITOR=${EDITOR:-vim} +date=`LC_ALL=POSIX TZ=Europe/Berlin date` + +if ! which mktemp > /dev/null 2>&1; then + echo "mktemp is required for this script to work" + exit 1 +fi + +while [ -n "$1" ]; do + case "$1" in + -m) + message="$2" + shift 2 + ;; + --help) + echo "Usage: $0 [filename[.changes]|path [file_with_comment]]" + echo + echo "Will use '$mailaddr' for changelog entries" + exit 0 + ;; + *) break ;; + esac +done + +changelog="$1" +content="$2" +pkgpath= +if [ -n "$changelog" -a -d "$changelog" ]; then + pkgpath="$changelog/" + changelog='' +fi + +if [ -n "$changelog" ]; then + if [ "${changelog%.changes}" = "$changelog" ]; then + changelog="$changelog.changes" + fi +else + changelog=($pkgpath*.changes) + if [ "${#changelog[@]}" -eq 1 ]; then + changelog="$changelog" + elif [ -n "$changelog" ]; then + echo "Choose one of ${changelog[@]}" + exit 1 + fi +fi + +if [ -z "$changelog" ]; then + changelog=($pkgpath*.spec) + if [ "${#changelog[@]}" -eq 1 ]; then + changelog=${changelog%.spec}.changes + elif [ -n "$changelog" ]; then + echo "Choose one of ${changelog[@]}" + exit 1 + fi +fi + +if [ -z "$changelog" ]; then + echo "no .changes and no .spec file found" + exit 1 +fi + +if [ ! -e "$changelog" ]; then + touch $changelog +fi + +tmpfile=`mktemp -q $changelog.XXXXXX` +if [ $? -ne 0 ]; then + echo "$0: Can't create temp file, exiting..." + exit 1 +fi +trap "rm -f \"$tmpfile\"" EXIT + +set +e + +{ + echo "-------------------------------------------------------------------" + echo "$date - $mailaddr" + echo + if [ -n "$message" ]; then + echo "- $message" + elif [ -n "$content" ]; then + cat "$content" + else + echo "- " + fi + echo + cat $changelog +} >> "$tmpfile" + +if [ -z "$message" ]; then + set -- `md5sum "$tmpfile"` + chksum="$1" + $EDITOR +4 "$tmpfile" + set -- `md5sum "$tmpfile"` + if [ -z "$content" -a "$chksum" == "$1" ]; then + echo "no changes made" + exit 0 + fi +fi +mv "$tmpfile" "$changelog" -- 2.7.4