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