Changeset 717

Show
Ignore:
Timestamp:
12/21/09 22:43:57 (2 years ago)
Author:
sleipnir
Message:

A much improved version to find all possible breakages in pkgconfig files. Give it a try! ;-)

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • openmoko/trunk/tools/find-corrupt-pc-files

    r563 r717  
    77fi 
    88 
    9 for pkg in $(cd "/usr/${CHOST}/usr/lib/pkgconfig" && grep libdir= *.pc | grep -v 'libdir=${exec_prefix}/lib' | cut -d: -f1); do 
    10     echo -n "Corrupted pkg-config file found in package: " 
    11     ROOT="/usr/${CHOST}" qfile "${pkg}" 
     9PKGCONFDIR="/usr/${CHOST}/usr/lib/pkgconfig" 
     10 
     11echo -e "Checking pkgconfig files in \033[1;36m${PKGCONFDIR}\033[0m" 
     12 
     13# Change to target pkgconfig dir 
     14cd "${PKGCONFDIR}" 
     15 
     16# Find packages with invalid exec_prefix 
     17execpkgs=$(grep '^exec_prefix=/usr' *.pc | cut -d: -f1)  
     18 
     19# Find packages with corrupted libdir entry 
     20incpkgs=$(grep '^includedir=' *.pc | grep -v 'includedir=${prefix}/include' | cut -d: -f1) 
     21 
     22# Find packages with corrupted libdir entry 
     23libpkgs=$(grep '^libdir=' *.pc | grep -v 'libdir=${exec_prefix}/lib' | cut -d: -f1) 
     24 
     25# Unify the packages so we are sure that every package is printed only once 
     26pcfiles=$(echo "${execpkgs} ${incpkgs} ${libpkgs}" | tr ' ' '\n' | sort -u) 
     27 
     28# Find the corresponding packages and mark what's wrong with the pc files 
     29pkgs="" 
     30for f in ${pcfiles}; do 
     31    # Collect flags that denote in which way the pc file is wrong. 
     32    flags="" 
     33    if $(echo "$execpkgs" | grep -q "${f}"); then 
     34        flags="${flags}E" 
     35    else 
     36        flags="${flags}_" 
     37    fi 
     38    if $(echo "$incpkgs" | grep -q "${f}"); then 
     39        flags="${flags}I" 
     40    else 
     41        flags="${flags}_" 
     42    fi 
     43    if $(echo "$libpkgs" | grep -q "${f}"); then 
     44        flags="${flags}L" 
     45    else 
     46        flags="${flags}_" 
     47    fi 
     48 
     49    # Find the package that corresponds 
     50    pkgs="${pkgs}$(ROOT="/usr/${CHOST}" qfile "${f}" | sed -e "s%(.*/%(${PKGCONFDIR}/%g") [${flags}]:" 
    1251done 
     52 
     53# Beautify the output by sorting it 
     54pkgs=$(echo $pkgs | tr ':' '\n' | sort | tr ' ' ':') 
     55 
     56# Print the packages... 
     57for pkg in ${pkgs}; do 
     58    p=$(echo "${pkg}" | cut -d':' -f1) 
     59    f=$(echo "${pkg}" | cut -d':' -f2) 
     60    g=$(echo "${pkg}" | cut -d':' -f3) 
     61 
     62    # Print it babe! 
     63    echo "    Corrupted file found in package: ${g} ${p} ${f}" 
     64done