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