scripts/addToolsVersion: properly handle .in vs. .in.2
While most components have their version in the .in file, some
have it in the .in.2 (eg. elf2flt).
Currently, to handle this case, we indiscriminately munge both files,
but this is wrong: in the elf2flt case, if we add a binutils version,
we do not want it to be added to elf2flt, and conversely.
So, for each tool, we need to explicitly know what file to munge.
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
6 my_name="$( basename "${0}" )"
11 ${my_name} <repos_dir> <M.m.p>
18 [ -n "${repos}" ] || { usage; exit 1; }
19 [ -d "${repos}" ] || { printf "${my_name}: ${repos}: no such file or directory\n"; exit 1; }
20 [ -n "${version}" ] || { usage; exit 1; }
23 HGPLAIN=1 hg --config progress.disabled=true "$@"
32 split($2,a,":"); rev=a[1];
34 $0~/^summary:[[:space:]]*[[:digit:]]+\.[[:digit:]]+: '"${msg}"'/ \
36 printf( "%d\n", rev ); found=1;
40 r2=$( _hg log -b "${branch}" \
41 |awk '$1=="changeset:" {
43 printf( "%d\n", a[1] );
48 r1_log=$((r1+log_offset))
49 if [ ${#r1_log} -gt ${#r2} ]; then
60 I'm pleased to announce the release of crosstool-NG ${version}!
62 As usual, there has been quite a number of improvements, new features,
63 and bug fixes all around. The most notable changes are listed below:
66 YEM: PUT YOUR MESSAGE HERE
69 This marks the beginning of the ${ver_M}.${ver_m} maintenance branch, and the end of
70 the previous maintenance branch. As always, comments and suggestions
73 The release can be found at the following URLs:
74 Changelog: http://crosstool-ng.org/download/crosstool-ng/crosstool-ng-${version}.changelog
75 Tarball: http://crosstool-ng.org/download/crosstool-ng/crosstool-ng-${version}.tar.bz2
76 Patches: http://crosstool-ng.org/download/crosstool-ng/01-fixes/${version}/
78 As a reminder, the home for crosstool-NG is:
79 http://crosstool-ng.org/
81 Crosstool-NG also has a Freshmeat page:
82 http://freshmeat.net/projects/crosstool-ng
86 print_intro_changelog_full_release() {
88 crosstool-NG ${version} -- ${date}
90 This is a feature-release. Significant changes are:
93 YEM: PUT YOUR MESSAGE HERE
98 print_intro_changelog_bug_fix() {
100 crosstool-NG ${version} -- ${date}
102 This is a bug-fix-only release.
106 print_author_stats() {
107 printf "\nMany thanks to the people who contributed to this release:\n\n"
109 template='{author|person}\n'
110 _hg log -b "${branch}" -r "${r1_log}:${r2}" \
111 --template "${template}" \
112 |sed -r -e 's/"//g;' \
117 for( author in nb ) {
118 printf( " %4d %s\n", nb[author], author );
124 print_author_shortlog() {
125 printf "\nHere is the per-author shortlog:\n"
127 template='{author|person}|{rev}|{branches}|{desc|firstline}\n'
128 _hg log -b "${branch}" -r "${r1_log}:${r2}" \
129 --template "${template}" \
132 printf( "%s", gensub("\"","","g",a[1]) );
133 printf( "|%0*d", '${rev_w}', a[2] );
135 printf( "|%s", a[i] );
141 author="$( echo "${line}" |cut -d \| -f 1 )"
142 rev="$( echo "${line}" |cut -d \| -f 2 )"
143 br="$( echo "${line}" |cut -d \| -f 3 )"
144 desc="$( echo "${line}" |cut -d \| -f 4- )"
154 *": close "*" branch"*) continue;;
155 # *\(merged\)) continue;;
158 author="$( echo "${author}" |sed -r -e 's/"//g;' )"
160 if [ ! "${prev_author}" = "${author}" ]; then
162 printf " ${author}:\n"
163 prev_author="${author}"
165 rev="$( echo "${rev}" |sed -r -e 's/^0*//;' )"
167 printf "%s\n" "${desc}" \
169 |(first=1; while read l; do
170 if [ -n "${first}" ]; then
171 printf " [%*d] %s\n" ${rev_w} ${rev} "${l}"
174 printf " %*.*s %s\n" ${rev_w} ${rev_w} '' "${l}"
181 printf "\nThe diffstat follows:\n\n"
182 _hg diff -r "${r1}:${r2}" --color=never \
183 |diffstat -r 2 -p 1 -w 10 \
185 |sed -r -e 's/^ */ /;'
187 _hg diff -r "${r1}:${r2}" --color=never \
188 |diffstat -f 1 -r 2 -p 1 -w 10 \
190 |while read file line; do
191 if [ ${#file} -gt 57 ]; then
192 file="$( echo "${file}" |sed -r -e 's/^(.{,24}).*(.{28})$/\1.....\2/;' )"
194 printf " %-57s %s\n" "${file}" "${line}"
198 print_short_diffstat() {
199 printf "\nThe short diffstat follows:\n\n"
202 _hg diff -r "${r1}:${r2}" --color=never "${i}" \
203 |diffstat -r 2 -p 1 -w 10 \
205 |sed -r -e 's/^[[:space:]]*[[:digit:]]+ files? changed(,[[:space:]]+|$)//;' \
206 -e 's/([[:digit:]]+)[^-\+]+\((-|\+)\)/\1/g;' \
207 -e 's/,//g; s/ /+/; s/^$/0/;'
209 printf " %-24.24s %5d(+/-)\n" "Total" ${total}
220 _hg diff -r "${r1}:${r2}" --color=never "${i}" \
221 |diffstat -r 2 -p 1 -w 10 \
223 |sed -r -e 's/^[[:space:]]*[[:digit:]]+ files? changed(,[[:space:]]+|$)//;' \
224 -e 's/([[:digit:]]+)[^-\+]+\((-|\+)\)/\1/g;' \
225 -e 's/,//g; s/ /+/; s/^$/0/;'
227 if [ ${val} -gt $((total/100)) ]; then
228 printf "%d %s\n" $(((1000*val)/total)) "${i}"
229 others=$((others-val))
231 done; printf "%d Others\n" $(((1000*others)/total)); } \
233 |{ while read v i; do
234 if [ "${i}" = "Others" ]; then
237 printf " %-24.24s %3d.%d%%\n" "${i}" $((v/10)) $((v%10))
239 done; printf " %-24.24s %3d.%d%%\n" "Others" $((others/10)) $((others%10)); }
242 ver_M="$( printf "${version}" |cut -d . -f 1 )"
243 ver_m="$( printf "${version}" |cut -d . -f 2 )"
244 ver_p="$( printf "${version}" |cut -d . -f 3 )"
246 sob_line="$( printf "Signed-off-by: "; _hg debugconfig ui.username )"
247 prefix="$(pwd)/crosstool-ng-${version}"
248 pushd "${repos}" >/dev/null 2>&1
250 printf "Checking for existing tag: "
251 if _hg tags |grep -E '^'"crosstool-ng-${version}"'\>' >/dev/null; then
252 printf "already tagged\n"
257 if [ ${ver_p} -eq 0 ]; then
259 print_intro_changelog="print_intro_changelog_full_release"
261 msg="create maintenance branch, (update|bump) version to [[:digit:]]+"'\'".[[:digit:]]+"'\'".0"'$'
266 print_intro_changelog="print_intro_changelog_bug_fix"
268 msg="(update|bump) version to ${ver_M}"'\'".${ver_m}"'\'".$((ver_p-1))"'\+hg$'
269 branch="${ver_M}.${ver_m}"
273 printf "Computing boundary revisions:"
275 printf " %d:%d\n" ${r1} ${r2}
277 printf "Tagging release:"
278 _hg up "${branch}" >/dev/null
279 if [ ${ver_p} -eq 0 ]; then
280 printf " update version"
281 _hg branch "${ver_M}.${ver_m}" >/dev/null
282 echo "${version}" >".version"
283 _msg="$( printf "%s.%s: create maintenance branch, update version to %s\n\n%s" \
284 "${ver_M}" "${ver_m}" "${version}" "${sob_line}"
288 printf " update version"
289 echo "${version}" >".version"
290 _msg="$( printf "%s.%s: update version to %s\n\n%s" \
291 "${ver_M}" "${ver_m}" "${version}" "${sob_line}"
297 _msg="$( printf "Tagging release %s\n\n%s" "${version}" "${sob_line}" )"
298 _hg tag -m "${_msg}" crosstool-ng-${version}
300 printf ", update version"
301 echo "${version}+hg" >".version"
302 _msg="$( printf "%s.%s: update version to %s+hg\n\n%s" \
303 "${ver_M}" "${ver_m}" "${version}" "${sob_line}"
308 date="$( _hg log -r crosstool-ng-${version} --template '{date|isodate}\n' \
309 |sed -r -e 's/-|://g; s/ /./; s/ //;' \
313 if [ ${ver_p} -eq 0 ]; then
314 printf "Generating release mail:"
316 print_intro_mail > "${prefix}.mail"
318 print_author_stats >>"${prefix}.mail"
320 print_author_shortlog >>"${prefix}.mail"
322 print_short_diffstat >>"${prefix}.mail"
326 printf "Generating release changelog:"
328 ${print_intro_changelog} > "${prefix}.changelog"
330 print_author_stats >>"${prefix}.changelog"
332 print_author_shortlog >>"${prefix}.changelog"
334 print_diffstat >>"${prefix}.changelog"
339 printf "Creating tarball:"
340 prefix="crosstool-ng-${version}"
342 date="$( _hg log -R "${repos}" -r "${prefix}" --template '{date|rfc822date}\n' )"
343 tmpdir="$( mktemp -d --tmpdir XXXXXX )"
344 _hg archive --cwd "${repos}" -r "${prefix}" -X '.hg*' --type files "${tmpdir}/${prefix}"
346 pushd "${tmpdir}/${prefix}" >/dev/null 2>&1
347 ./bootstrap >/dev/null
348 rm -rf autom4te.cache
351 tar cjf "$(pwd)/${prefix}.tar.bz2" -C "${tmpdir}" "${prefix}"
354 for s in md5 sha1 sha512; do
355 ${s}sum "${prefix}.tar.bz2" >"${prefix}.tar.bz2.${s}"
358 touch -d "${date}" "${prefix}"*
361 if [ ${ver_p} -eq 0 ]; then
362 printf "\nAn editor will be launched for you to edit the mail.\n"
363 read -p "Press enter when ready..." foo
364 cp "${prefix}.mail"{,.orig}
366 diff -du -U 1 "${prefix}.mail"{.orig,} |patch -p0 "${prefix}.changelog" >/dev/null
367 rm -f "${prefix}".{mail,changelog}.orig
370 printf "\nAn editor will be launched for you to review the changelog.\n"
371 read -p "Press enter when ready..." foo
372 vi "${prefix}.changelog"
374 printf "\nNow, you can push the changes with: hg push -R '${repos}'\n"