3 # Updates the timestamp and contents in a package's .project
4 # if $1 is null, update pkgusr's pkg
8 if [ -z "${pkg}" ]; then
12 pkgdir=/usr/src/${pkg}
16 for file in $(forall_direntries_from $pkg -type f -executable -readable); do
17 if readelf -d $file &>/dev/null && ldd $file &>/dev/null; then
18 (readelf -d $file ; ldd $file ) |
19 awk '/NEEDED/ { lib=substr($5,2,length($5)-2); LIBS[lib]=$5 } \
20 /.*=>/ {if ( $1 in LIBS ) LIBS[$1]=$3 } END \
21 { for (lib in LIBS) print LIBS[lib] }' |
22 xargs stat --printf "%U:%G\n"
24 done|sort -u|tr -s '\n' ' '
27 # Update deps and date
30 DEPS=${DEPS% } # trailing whitespace begone!
31 sed -i -e "s/\(Last_Updated: \).*$/\1${TIMESTAMP}/" \
32 -e s/"\(Deps: \).*$"/"\1${DEPS}"/ ${pkgdir}/.project
34 # Clear out old file list
35 awk '/^CONTENTS:/ { print; exit; } {print}' \
36 ${pkgdir}/.project > ${pkgdir}/.projtmp
37 echo "--------" >> ${pkgdir}/.projtmp
39 # Add up to date file list
40 list_package ${pkg} >> ${pkgdir}/.projtmp
41 mv ${pkgdir}/.projtmp ${pkgdir}/.project
43 # If we're root, chown the .project file
44 [[ $(id -u) -eq 0 ]] && chown -v ${pkg}:${pkg} ${pkgdir}/.project