scripts/mk-patch.sh
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Thu Feb 24 22:31:15 2011 +0100 (2011-02-24)
changeset 2320 5f681a2a0a89
parent 1888 b82375bb7acd
child 2403 ee2634bc3871
permissions -rwxr-xr-x
docs: add an in-depth explanations of the build steps

The build process is quite complex: gcc is built three times, there are
two C library steps, there are those companion libraries...

People often wonder what all these steps do, and why they are needed.

Recently, someone proposed a tutorial on the crossgcc mailing list:
http://sourceware.org/ml/crossgcc/2011-01/msg00059.html

This meant that there was a need for such a tutorial, and explanations
on how a toolchain is built. So i decide to extend my answers:
http://sourceware.org/ml/crossgcc/2011-01/msg00060.html
http://sourceware.org/ml/crossgcc/2011-01/msg00125.html

into proper documentation in crosstool-NG.

Thanks go to Francesco for suggesting this. He has a fine tutorial
for beginners there:
http://fturco.org/wiki/doku.php?id=debian:cross-compiler

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