]>
Commit | Line | Data |
---|---|---|
98993cb3 | 1 | #!/bin/ksh -e |
7a88b39b | 2 | |
3 | # Usage: | |
b24498fc | 4 | # Just run this script in your rpm/packages/rpm-build-tools directory with |
5 | # no arguments to release new version of rpm-build-tools. | |
6 | # Run "update.sh clean" to clean all local modifications. | |
7a88b39b | 7 | |
98993cb3 | 8 | # Note: |
0c6df2b5 | 9 | # shebang is /bin/ksh, because arrays are non-posix bash/ksh extension. |
98993cb3 | 10 | |
7a88b39b | 11 | die() { |
12 | >&2 printf '*** '${1:+"$@\n"} | |
13 | return 1 | |
14 | } | |
15 | ||
16 | msg() { | |
17 | printf ' '${1:+"$@\n"} | |
18 | } | |
19 | ||
20 | [ -f "/etc/shrc.d/rpm-build.sh" ] || die "Install rpm-build-macros package" | |
21 | . /etc/shrc.d/rpm-build.sh | |
22 | ||
23 | src[0]=adapter | |
24 | src[1]=adapter.awk | |
25 | src[2]=builder | |
26 | src[3]=pldnotify.awk | |
27 | src[4]=rpm-build-tools.spec | |
28 | ||
29 | dst[0]=adapter.sh | |
30 | dst[1]=${src[1]} | |
31 | dst[2]=builder.sh | |
32 | dst[3]=${src[3]} | |
98993cb3 | 33 | dst[4]=${src[4]} |
7a88b39b | 34 | |
b24498fc | 35 | # |
36 | # parse args | |
37 | # | |
38 | ||
39 | if [ "$1" = "clean" ]; then | |
40 | rm ${dst[@]} | |
41 | cvs up ${dst[@]} | |
42 | exit 0 | |
43 | fi | |
44 | ||
7a88b39b | 45 | # |
46 | # Checkout on involved files and check for local modifications. | |
47 | # | |
48 | ||
49 | for I in 0 1 2 3; do | |
50 | msg "Checking out packages/rpm-build-tools/${dst[$I]} file." | |
51 | rs=$(cvs up ${dst[$I]}) | |
52 | case "$rs" in | |
53 | "M "*) die "You have local modifications in packages/rpm-build-tools/${dst[$I]} file.\nCommit it first." ;; | |
54 | esac | |
55 | done | |
56 | cd ..; | |
57 | for I in 0 1 2 3; do | |
58 | msg "Checking out packages/${src[$I]} file." | |
59 | rs=$(cvs up ${src[$I]}) | |
60 | case "$rs" in | |
61 | "M "*) die "You have local modifications in packages/${src[$I]} file.\nCommit it first." ;; | |
62 | esac | |
63 | done | |
64 | ||
65 | # | |
66 | # Check working revisions of src files | |
67 | # | |
68 | ||
69 | msg "Checking revisions." | |
70 | for I in 0 1 2 3; do | |
71 | rev[$I]=$(cvs stat ${src[$I]} \ | |
72 | | sed -ne 's/^[[:blank:]]*Working revision:[[:blank:]]*\([[:digit:]]\.[[:digit:]]\+\).*/\1/p') | |
73 | done | |
74 | ||
75 | >/dev/null cd - | |
76 | ||
77 | # | |
78 | # Check wich dst files need updating, update them and prepare msglog | |
79 | # | |
80 | ||
81 | LOG="" | |
82 | msg "Checking wich files need update." | |
83 | for I in 0 1 2 3; do | |
682b31a4 | 84 | if [ "$(diff -I'$Id[:] ' -I'$Revision[:] ' ../${src[$I]} ${dst[$I]})" ]; then |
7a88b39b | 85 | cat ../${src[$I]} > ${dst[$I]} |
86 | LOG="$LOG- ${dst[$I]} up to ${rev[$I]}\n" | |
87 | fi | |
88 | done | |
89 | ||
90 | [ "$LOG" ] || die "Nothing to update!" | |
91 | ||
92 | minor_ver=$(sed -n 's/^\Version:.*\.\([[:digit:]]\+\)/\1/p' rpm-build-tools.spec) | |
93 | minor_ver=$(($minor_ver + 1)) | |
94 | sed -i 's/^\(Version:.*\.\)\([[:digit:]]\+\)$/\1'$minor_ver'/' rpm-build-tools.spec | |
95 | sed -i 's/^Release:.*$/Release: 1/' rpm-build-tools.spec | |
96 | ver=$(sed -n 's/^\Version:[[:blank:]]\(.*\)$/\1/p' rpm-build-tools.spec) | |
97 | LOG="- up to $ver\n$LOG" | |
98 | ||
99 | # | |
100 | # Show changes and ask user for confirmation. | |
101 | # | |
102 | ||
1df75c29 | 103 | cvs di -u ${dst[@]} | diffcol | ${PAGER:-'less -r'} |
7a88b39b | 104 | |
105 | printf "Commit log:\n$LOG\nCommit (Yes, No)? " | |
106 | read ans | |
107 | case "$ans" in | |
108 | [yY]) | |
1df75c29 | 109 | cvs ci -m "$(printf "$LOG")" ${dst[@]} ;; |
7a88b39b | 110 | *) |
111 | msg ":(" ;; | |
112 | esac | |
113 | ||
114 | # vim: tabstop=2 |