#!/bin/bash if [ -z "$1" ]; then CHOST=armv4tl-softfloat-linux-gnueabi else CHOST="$1" fi PKGCONFDIR="/usr/${CHOST}/usr/lib/pkgconfig" echo -e "Checking pkgconfig files in \033[1;36m${PKGCONFDIR}\033[0m" # Change to target pkgconfig dir cd "${PKGCONFDIR}" # Find packages with invalid exec_prefix execpkgs=$(grep '^exec_prefix=/usr' *.pc | cut -d: -f1) # Find packages with corrupted libdir entry incpkgs=$(grep '^includedir=' *.pc | grep -v 'includedir=${prefix}/include' | cut -d: -f1) # Find packages with corrupted libdir entry libpkgs=$(grep '^libdir=' *.pc | grep -v 'libdir=${exec_prefix}/lib' | cut -d: -f1) # Unify the packages so we are sure that every package is printed only once pcfiles=$(echo "${execpkgs} ${incpkgs} ${libpkgs}" | tr ' ' '\n' | sort -u) # Find the corresponding packages and mark what's wrong with the pc files pkgs="" for f in ${pcfiles}; do # Collect flags that denote in which way the pc file is wrong. flags="" if $(echo "$execpkgs" | grep -q "${f}"); then flags="${flags}E" else flags="${flags}_" fi if $(echo "$incpkgs" | grep -q "${f}"); then flags="${flags}I" else flags="${flags}_" fi if $(echo "$libpkgs" | grep -q "${f}"); then flags="${flags}L" else flags="${flags}_" fi # Find the package that corresponds pkgs="${pkgs}$(ROOT="/usr/${CHOST}" qfile "${f}" | sed -e "s%(.*/%(${PKGCONFDIR}/%g") [${flags}]:" done # Beautify the output by sorting it pkgs=$(echo $pkgs | tr ':' '\n' | sort | tr ' ' ':') # Print the packages... for pkg in ${pkgs}; do p=$(echo "${pkg}" | cut -d':' -f1) f=$(echo "${pkg}" | cut -d':' -f2) g=$(echo "${pkg}" | cut -d':' -f3) # Print it babe! echo " Corrupted file found in package: ${g} ${p} ${f}" done