From 38160860e395a99337285f3a888349ecd2137f58 Mon Sep 17 00:00:00 2001 From: Steve Youngs Date: Thu, 13 Mar 2014 10:52:41 +1000 Subject: [PATCH] Prevent update-pkg-project from needlessly spamming stderr * usr/lib/pkgusr/update-pkg-project (upd_pkg_deps): Prevent stderr getting spammed. (TIMESTAMP,DEPS): New. Signed-off-by: Steve Youngs --- usr/lib/pkgusr/update-pkg-project | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/usr/lib/pkgusr/update-pkg-project b/usr/lib/pkgusr/update-pkg-project index cdd1a07..feef549 100755 --- a/usr/lib/pkgusr/update-pkg-project +++ b/usr/lib/pkgusr/update-pkg-project @@ -6,27 +6,37 @@ pkg="$1" if [ -z "${pkg}" ]; then - pkg=$(whoami) + pkg=$(whoami) fi pkgdir=/usr/src/${pkg} upd_pkg_deps() { - for file in $(forall_direntries_from $pkg -type f -executable -readable); do - (readelf -d $file ; ldd $file ) | - awk '/NEEDED/ { lib=substr($5,2,length($5)-2); LIBS[lib]=$5 } \ + for file in $(forall_direntries_from $pkg -type f -executable -readable); do + if readelf -d $file &>/dev/null && ldd $file &>/dev/null; then + (readelf -d $file ; ldd $file ) | + awk '/NEEDED/ { lib=substr($5,2,length($5)-2); LIBS[lib]=$5 } \ /.*=>/ {if ( $1 in LIBS ) LIBS[$1]=$3 } END \ { for (lib in LIBS) print LIBS[lib] }' | - xargs stat --printf "%U:%G\n" - done|sort -u|tr -s '\n' ' ' + xargs stat --printf "%U:%G\n" + fi + done|sort -u|tr -s '\n' ' ' } +# Update deps and date +TIMESTAMP=$(date +%c) +DEPS=$(upd_pkg_deps) +DEPS=${DEPS% } # trailing whitespace begone! +sed -i -e "s/\(Last_Updated: \).*$/\1${TIMESTAMP}/" \ + -e s/"\(Deps: \).*$"/"\1${DEPS}"/ ${pkgdir}/.project -sed -i "s/\(Last_Updated: \).*$/\1$(date +%c)/" ${pkgdir}/.project -sed -i s/"\(Deps: \).*$"/"\1$(upd_pkg_deps)"/ ${pkgdir}/.project -awk '/^CONTENTS:/ { print; exit; } {print}' ${pkgdir}/.project > ${pkgdir}/.projtmp +# Clear out old file list +awk '/^CONTENTS:/ { print; exit; } {print}' \ + ${pkgdir}/.project > ${pkgdir}/.projtmp echo "--------" >> ${pkgdir}/.projtmp + +# Add up to date file list list_package ${pkg} >> ${pkgdir}/.projtmp mv ${pkgdir}/.projtmp ${pkgdir}/.project -- 2.25.1