scripts/mk-patch.sh
author Remy Bohmer <linux@bohmer.net>
Thu May 27 23:18:19 2010 +0200 (2010-05-27)
changeset 2060 51e4597b07fc
child 2075 edc7c7958e80
permissions -rwxr-xr-x
scripts: add option to strip all toolchain executables

To reduce filesizes of the toolchain and even improve build times
of projects to be build with this toolchain it is usefull to strip
the delivered toolchain executables. Since it is not likely that we
will debug the toolchain executables itself we do not need the
debug information inside the executables itself.

Signed-off-by: Remy Bohmer <linux@bohmer.net>
     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,[/ :]+,_,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