#!/bin/bash # Updates the timestamp and contents in a package's .project # if $1 is null, update pkgusr's pkg pkg="$1" if [ -z "${pkg}" ]; then 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 } \ /.*=>/ {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' ' ' } 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 echo "--------" >> ${pkgdir}/.projtmp list_package ${pkg} >> ${pkgdir}/.projtmp mv ${pkgdir}/.projtmp ${pkgdir}/.project # If we're root, chown the .project file [[ $(id -u) -eq 0 ]] && chown -v ${pkg}:${pkg} ${pkgdir}/.project