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