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