scripts/mk-patch.sh
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Sun Mar 20 00:02:21 2011 +0100 (2011-03-20)
changeset 2339 730e2d63296b
parent 1888 b82375bb7acd
child 2403 ee2634bc3871
permissions -rwxr-xr-x
scripts: leave changelog in build dir, copy to install dir

Users tend to look for the build log in the current working directory,
rather than in the toolchain's installation dir. While bundling the build
log in the toolchain installation dir is nice for distribution and review,
it can be easier to have the build log readily available in the working
directory, as it is quicker to get to it.

So, the build log stays in the working directory until the toolchain is
completely and successfully built, and then a (compressed) copy is made.

Reported-by: Trevor Woerner <twoerner@gmail.com>
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
     1 #!/bin/sh
     2 
     3 repos="$1"
     4 pdir="$2"
     5 if [ -z "${repos}" -o ! -d "${repos}" -o -z "${pdir}" -o ! -d "${pdir}" ];then
     6     printf "Usage: ${0##*/} <repos_dir> <patch_dir>\n"
     7     exit 1
     8 fi
     9 
    10 pdir="$( cd "${pdir}"; pwd)"
    11 version="$( echo "${pdir}" |sed -r -e 's,.*/([^/]+)/*$,\1,' )"
    12 branch="${version%.*}"
    13 n=$( ls -1 "${pdir}" 2>/dev/null |wc -l )
    14 
    15 r1="$( hg -R "${repos}" log -b "${branch}"  \
    16        |awk '
    17             $1=="changeset:" {
    18                 prev=rev;
    19                 split($2,a,":");
    20                 rev=a[1];
    21             }
    22             $0~/^summary:[[:space:]]+'"${branch}: (bump|update) version to ${version}\+hg"'$/ {
    23                 printf( "%d\n", prev );
    24             }
    25             '
    26      )"
    27 
    28 i=0
    29 hg -R "${repos}" log -b "${branch}" -r "${r1}:tip" --template '{rev}\n'    \
    30 |while read rev; do
    31     p="$( printf "%03d" ${i} )"
    32     i=$((i+1))
    33     if [ $( ls -1 "${pdir}/${p}-"*.patch 2>/dev/null |wc -l ) -ne 0 ]; then
    34         continue
    35     fi
    36     plog=$( hg -R "${repos}" log -r ${rev} --template '{desc|firstline}\n'  \
    37             |sed -r -e 's,[/:,[:space:]],_,g; s/_+/_/g;'                    \
    38           )
    39     pname="${p}-${plog}.patch"
    40     printf "Revision '%d' --> '%s'\n" ${rev} "${pname}"
    41     hg -R "${repos}" diff -c ${rev} --color=never >"${pdir}/${pname}"
    42     pdate="$( hg -R "${repos}" log -r ${rev} --template '{date|isodate}\n' )"
    43     touch -d "${pdate}" "${pdir}/${pname}"
    44 done