]> git.pld-linux.org Git - packages/rpm-build-tools.git/blob - ci
- need civim
[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 cvs -z9 diff -u $SPECFILE | diffcol
52
53 echo -n "Proceed ? "
54 read ans
55 case "$ans" in
56 Y|y|O|o)
57         ;;
58 *)
59         exit
60         ;;
61 esac
62
63 sed '/^# AUTO: /d' -i "$SPEC"
64 SIMPLE_DIFF="$(cvs -z9 diff "$SPEC")"
65
66 ./adapter "$SPEC"
67
68 diff="$(cvs -z9 diff -u $SPEC)"
69
70 echo "$diff" | diffcol
71
72 ver=$(echo "$diff" | awk '
73         /^\+Version/ { ver = $2 }
74         /^\+%define[ \t]+[_a-zA-Z0-9]*ver/ { ver = $3 }
75         END { print ver }
76 ')
77 rel=$(echo "$diff" | awk '
78         /^\+Release/ { rel = $2 }
79         /^\+%define[ \t]+_?rel/ { rel = $3 }
80         END { print rel }
81 ')
82
83 add=$(echo "$diff" | awk '
84         function s( n ) { sub(/}/,"",n); return n; }
85         /^\+(%{[a-zA-Z0-9_]+:)?BuildRequires/ { add[ s( $2 ) ] = 1; };
86         /^-(%{[a-zA-Z0-9_]+:)?BuildRequires/ { del[ s( $2 ) ] = 1; };
87         END { for ( n in add ) { if ( !del[ n ] ) print n; } }' | 
88         perl -p -e 'chomp; push @a, $_; undef $_; END { print join ", ", sort @a }
89 ')
90
91 del=$(echo "$diff" | awk '
92         function s( n ) { sub(/}/,"",n); return n; }
93         /^\+(%{[a-zA-Z0-9_]+:)?BuildRequires/ { add[ s( $2 ) ] = 1; };
94         /^-(%{[a-zA-Z0-9_]+:)?BuildRequires/ { del[ s( $2 ) ] = 1; };
95         END { for ( n in del ) { if ( !add[ n ] ) print n; } }' |
96         perl -p -e 'chomp; push @a, $_; undef $_; END { print join ", ", sort @a }
97 ')
98
99 n="$(echo -e '\nn')"
100 n="${n%%n}"
101 msg=""
102 [ -n "$ver" ] && msg="$msg- updated to: $ver$n"
103 [ -n "$rel" ] && msg="$msg- release: $rel$n"
104 [ -n "$add" ] && msg="$msg- BR: $add$n"
105 [ -n "$del" ] && msg="$msg- dropped BR: $del$n"
106
107 echo
108 echo "Message:"
109 echo "$msg"
110 echo -n "Commit ? "
111 read ans
112 case "$ans" in
113 Y|y|O|o)
114         ;;
115 *)
116         exit
117         ;;
118 esac
119
120 export COMMIT_MESSAGE="$msg"
121 export COMMIT_PACKAGES="$SPECFILE"
122 export VISUAL="$PWD/civim"
123 cvs -z9 ci "$SPECFILE"
124
125 [ -n "$CLEANBUILDDIR" ] && rm -f $CLEANBUILDDIR/installed/$SPECFILE
This page took 0.03216 seconds and 4 git commands to generate.