2 # Copyright © 2010 - 2021 Steve Youngs. All rights reserved.
3 # SPDX-License-Identifier: BSD-3-Clause
5 # Author: Steve Youngs <steve@sxemacs.org>
6 # Maintainer: Steve Youngs <steve@sxemacs.org>
7 # Created: <2010-12-01>
8 # Time-stamp: <Sunday 16 May 2021 20:05:12 (steve)>
9 # Homepage: https://git.sxemacs.org/pkgusr
10 # Keywords: pkgusr package-management tools
12 ## This file is part of pkgusr
16 # Updates the timestamp and contents in a package's .project
17 # $1 -- package to update, if null current pkgusr
18 # $2 -- '--subgroups' optional. Use if the package is split into
21 # All the work is done in list_package (see: list_package --help)
27 # Allow for 'update-pkg-project --subgroups' invocation
28 # Hint: if it is not a pkgusr doing this the resulting error message
29 # from list_package will set you straight. :)
30 if [[ ${pkg} =~ ^--?subgroups$ ]]; then
35 # Allow for no cmdline opts
36 if [ -z "${pkg}" ]; then
40 pkgdir=/usr/src/${pkg}
41 pkgawk=/usr/lib/pkgusr/pkgdeps.awk
43 # Clear out old file list
44 sed -i -n 1,/CONTENTS:/p ${pkgdir}/.project
45 echo "--------" >> ${pkgdir}/.project
47 # Update the mandb so we get up to date results
48 # See /usr/lib/pkgusr/mandb and /etc/sudoers.d/99-pkgusr
51 # Re-populate .project (source'd to get at $AEXEC)
52 source list_package ${pkg} ${subgrps} >> ${pkgdir}/.project
57 # $AEXEC comes from list_package
58 for file in ${AEXEC[@]}; do
59 if readelf -d $file &>/dev/null && ldd $file &>/dev/null; then
60 (readelf -d $file ; ldd $file ) |
61 awk -f ${pkgawk} | xargs -r stat --printf "%U:%G\n"
63 done | sort -u | tr -s '\n' ' '
69 sed -i "s/\(Last_Updated: \).*$/\1${TIMESTAMP}/" ${pkgdir}/.project
71 # Update Deps (a wee bit ugly in my eyes, sorry)
73 DEPS="Deps: ${DEPS% }" # trailing whitespace begone!
74 sed -i -e /Deps:/d -e "/Web_Site/a ${DEPS}" ${pkgdir}/.project
75 fmt -p Deps: ${pkgdir}/.project > ${pkgdir}/.project.fmt
76 sed -i 's/^Deps:/ &/' ${pkgdir}/.project.fmt
77 mv ${pkgdir}/.project{.fmt,}
79 # If we're root, chown the .project file
80 [[ $(id -u) -eq 0 ]] && chown -v ${pkg}:${pkg} ${pkgdir}/.project