]> git.pld-linux.org Git - packages/rpm-build-tools.git/blobdiff - ci
Fallback to /tmp.
[packages/rpm-build-tools.git] / ci
diff --git a/ci b/ci
old mode 100644 (file)
new mode 100755 (executable)
index 5e9eb89..a90fc60
--- a/ci
+++ b/ci
@@ -1,16 +1,23 @@
 #!/bin/sh
 
-SPECFILE="$1"
-SPECFILE="${SPECFILE%%/*}"
-SPECFILE="$(basename $SPECFILE .spec)"
-SPEC="$SPECFILE/$SPECFILE.spec"
+SPEC=$(basename "$1" .spec).spec
+PACKAGE=$(basename "$SPEC" .spec)
+TOPDIR=$(rpm -E %_topdir)
+PACKAGEDIR=$TOPDIR/$PACKAGE
+SPECFILE="$TOPDIR/$PACKAGE/$SPEC"
 CLEANBUILDDIR="$HOME/PLD"
+CIVIM=$PWD/civim
 
-if [ $# -ne 1 -o ! -d "$SPECFILE" -o ! -f "$SPEC" ]; then
+if [ $# -ne 1 -o ! -d "$PACKAGEDIR" -o ! -f "$SPECFILE" ]; then
        echo "spec file missing"
        exit 1
 fi
 
+if [ ! -x "$CIVIM" ]; then
+       echo "civim missing"
+       exit 1
+fi
+
 diffcol()
 {
        # vim like diff colourization
@@ -43,50 +50,70 @@ LC_ALL=en_US.UTF-8 gawk ' {
 ' "$@"
 }
 
-cvs -z9 diff -u $SPECFILE | diffcol
+pause()
+{
+       echo "$*"
+       echo -n "[Press ENTER to continue, ^C to abort] "
+       read ans
+}
+
+cd $PACKAGEDIR
 
-echo -n "Proceed ? "
-read ans
+git diff --color=auto $SPEC
 
-if [ "$ans" != "y" ]; then
-       exit
-fi
+pause "Proceed ?"
 
-sed '/^# AUTO: /d' -i "$SPEC"
-SIMPLE_DIFF="$(cvs -z9 diff "$SPEC")"
+sed '/^# AUTO: /d' -i "$SPECFILE"
+SIMPLE_DIFF="$(cd $PACKAGEDIR && git diff "$SPEC")"
 
-./adapter "$SPEC"
+./adapter "$SPECFILE"
 
-diff="$(cvs -z9 diff -u $SPEC)"
+diff=$(git diff $SPEC)
+git diff --color=auto $SPEC
 
-echo "$diff" | diffcol
+ver=$(echo "$diff" | awk '
+       /^\+Version/ { ver = $2 }
+       /^\+%define[ \t]+[_a-zA-Z0-9]*ver/ { ver = $3 }
+       END { print ver }
+')
+rel=$(echo "$diff" | awk '
+       /^\+Release/ { rel = $2 }
+       /^\+%define[ \t]+_?rel/ { rel = $3 }
+       END { print rel }
+')
 
-add=$(echo "$diff" | awk '/^\+BuildRequires/ { add[ $2 ] = 1; }; /^-BuildRequires/ { del[ $2 ] = 1; };
+add=$(echo "$diff" | awk '
+       function s( n ) { sub(/}/,"",n); return n; }
+       /^\+(%{[a-zA-Z0-9_]+:)?BuildRequires/ { add[ s( $2 ) ] = 1; };
+       /^-(%{[a-zA-Z0-9_]+:)?BuildRequires/ { del[ s( $2 ) ] = 1; };
        END { for ( n in add ) { if ( !del[ n ] ) print n; } }' | 
-       perl -p -e 'chomp; push @a, $_; undef $_; END { print join ", ", sort @a }')
+       perl -p -e 'chomp; push @a, $_; undef $_; END { print join ", ", sort @a }
+')
 
-del=$(echo "$diff" | awk '/^\+BuildRequires/ { add[ $2 ] = 1; }; /^-BuildRequires/ { del[ $2 ] = 1; };
+del=$(echo "$diff" | awk '
+       function s( n ) { sub(/}/,"",n); return n; }
+       /^\+(%{[a-zA-Z0-9_]+:)?BuildRequires/ { add[ s( $2 ) ] = 1; };
+       /^-(%{[a-zA-Z0-9_]+:)?BuildRequires/ { del[ s( $2 ) ] = 1; };
        END { for ( n in del ) { if ( !add[ n ] ) print n; } }' |
-       perl -p -e 'chomp; push @a, $_; undef $_; END { print join ", ", sort @a }')
+       perl -p -e 'chomp; push @a, $_; undef $_; END { print join ", ", sort @a }
+')
 
 n="$(echo -e '\nn')"
 n="${n%%n}"
 msg=""
+[ -n "$ver" ] && msg="$msg- up to $ver$n"
+[ -n "$rel" -a "$rel" != "1" ] && msg="$msg- release $rel$n"
 [ -n "$add" ] && msg="$msg- BR: $add$n"
 [ -n "$del" ] && msg="$msg- dropped BR: $del$n"
 
 echo
 echo "Message:"
 echo "$msg"
-echo -n "Commit ? "
-read ans
-if [ "$ans" != "y" ]; then
-       exit
-fi
+pause "Commit ?"
 
 export COMMIT_MESSAGE="$msg"
 export COMMIT_PACKAGES="$SPECFILE"
-export VISUAL="$PWD/civim"
-cvs -z9 ci "$SPECFILE"
+export VISUAL="$CIVIM"
+git ci "$SPECFILE"
 
-[ -n "$CLEANBUILDDIR" ] && rm -f $CLEANBUILDDIR/installed/$SPECFILE
+[ -n "$CLEANBUILDDIR" ] && rm -f $CLEANBUILDDIR/installed/$SPEC
This page took 0.134994 seconds and 4 git commands to generate.