]> git.pld-linux.org Git - packages/rpm-build-tools.git/blame - ci
- detect version and release changes
[packages/rpm-build-tools.git] / ci
CommitLineData
38573414 1#!/bin/sh
2
3SPECFILE="$1"
4SPECFILE="${SPECFILE%%/*}"
5SPECFILE="$(basename $SPECFILE .spec)"
6SPEC="$SPECFILE/$SPECFILE.spec"
7CLEANBUILDDIR="$HOME/PLD"
8
9if [ $# -ne 1 -o ! -d "$SPECFILE" -o ! -f "$SPEC" ]; then
10 echo "spec file missing"
11 exit 1
12fi
13
14diffcol()
15{
16 # vim like diff colourization
17LC_ALL=en_US.UTF-8 gawk ' {
18 split( $0, S, /\t/ );
19 $0 = S[ 1 ];
20 for ( i = 2; i in S; i++ ) {
21 spaces = 7 - ( (length( $0 ) - 1) % 8 );
22 $0 = $0 "\xE2\x9E\x94";
23 for ( y = 0; y < spaces; y++ )
24 $0 = $0 "\xE2\x87\xBE";
25 $0 = $0 S[ i ];
26 }
27 gsub( /\033/, "\033[44m^[\033[49m" );
28 cmd = "";
29 if ( sub( /^ /, "" ) )
30 cmd = " ";
31 sub( /(\xE2\x9E\x94(\xE2\x87\xBE)*| )+$/, "\033[31;41m&\033[39;49m" );
32 gsub( /\xE2\x9E\x94(\xE2\x87\xBE)*/, "\033[7m&\033[27m" );
33 gsub( /\xE2\x87\xBE/, " " );
34 $0 = cmd $0;
35 gsub( /\007/, "\033[44m^G\033[49m" );
36 gsub( /\r/, "\033[44m^M\033[49m" );
37}
38/^(Index:|diff|---|\+\+\+) / { $0 = "\033[32m" $0 }
39/^@@ / { $0 = "\033[33m" $0 }
40/^-/ { $0 = "\033[35m" $0 }
41/^+/ { $0 = "\033[36m" $0 }
42{ $0 = $0 "\033[0m"; print }
43' "$@"
44}
45
46cvs -z9 diff -u $SPECFILE | diffcol
47
48echo -n "Proceed ? "
49read ans
50
51if [ "$ans" != "y" ]; then
52 exit
53fi
54
55sed '/^# AUTO: /d' -i "$SPEC"
56SIMPLE_DIFF="$(cvs -z9 diff "$SPEC")"
57
58./adapter "$SPEC"
59
60diff="$(cvs -z9 diff -u $SPEC)"
61
62echo "$diff" | diffcol
63
e5661ec7 64ver=$(echo "$diff" | awk '/^\+Version/ { ver = $2 } /^\+%define[ \t]+[_a-zA-Z0-9]*ver/ { ver = $3 }
65 END { print ver }')
66rel=$(echo "$diff" | awk '/^\+Release/ { rel = $2 } /^\+%define[ \t]+_?rel/ { rel = $3 }
67 END { print rel }')
68
38573414 69add=$(echo "$diff" | awk '/^\+BuildRequires/ { add[ $2 ] = 1; }; /^-BuildRequires/ { del[ $2 ] = 1; };
70 END { for ( n in add ) { if ( !del[ n ] ) print n; } }' |
71 perl -p -e 'chomp; push @a, $_; undef $_; END { print join ", ", sort @a }')
72
73del=$(echo "$diff" | awk '/^\+BuildRequires/ { add[ $2 ] = 1; }; /^-BuildRequires/ { del[ $2 ] = 1; };
74 END { for ( n in del ) { if ( !add[ n ] ) print n; } }' |
75 perl -p -e 'chomp; push @a, $_; undef $_; END { print join ", ", sort @a }')
76
77n="$(echo -e '\nn')"
78n="${n%%n}"
79msg=""
e5661ec7 80[ -n "$ver" ] && msg="$msg- updated to: $ver$n"
81[ -n "$rel" ] && msg="$msg- release: $rel$n"
38573414 82[ -n "$add" ] && msg="$msg- BR: $add$n"
83[ -n "$del" ] && msg="$msg- dropped BR: $del$n"
84
85echo
86echo "Message:"
87echo "$msg"
88echo -n "Commit ? "
89read ans
90if [ "$ans" != "y" ]; then
91 exit
92fi
93
94export COMMIT_MESSAGE="$msg"
95export COMMIT_PACKAGES="$SPECFILE"
96export VISUAL="$PWD/civim"
97cvs -z9 ci "$SPECFILE"
98
99[ -n "$CLEANBUILDDIR" ] && rm -f $CLEANBUILDDIR/installed/$SPECFILE
This page took 0.043372 seconds and 4 git commands to generate.