[Slackbuilds-users] RFC: Proposed mandb additions to doinst/douninst template
Duncan Roe
duncan_roe at optusnet.com.au
Mon Sep 16 02:42:36 UTC 2024
On Wed, Sep 11, 2024 at 08:31:55AM +0200, Nick Smallbone wrote:
> On Wed, 11 Sep 2024, at 8:15 AM, B. Watson wrote:
> > Someone on IRC pointed out that rewriting it to use awk would be less
> > ugly. I tend to reach for sed first due to familiarity, but I think in
> > this case you and him are right.
> >
> > Something like this, maybe?
> >
> > find usr/man -type f -a -name '*.gz' | \
> > awk '{ print "chroot . /usr/bin/mandb -f \"/"$1"\" &>/dev/null" }' \
> > >> install/doinst.sh
> >
> > It would be less ugly if we could assume man pages never have spaces
> > or shell metacharacters in them... I don't think the man command can
> > handle spaces in the man page filenames, and it would be bizarre to
> > have $ or * or such in the filename... But better to leave the quotes
> > there I suppose.
>
> I just learned that find has a -printf flag which can be used to format the output, avoiding the need for sed/awk altogether:
>
> find usr/man -type f -a -name '*.gz' \
> -printf "chroot . /usr/bin/mandb -f '/%p' &> /dev/null\n" \
> >> install/doinst.sh
>
> There's also a %P format specifier which prints the filename relative to the search root (e.g. man1/whatever.1.gz), hence the following variant which even works if run before the 'cd $PKG' command (but it still needs to come after 'mkdir $PKG/install' so perhaps not a useful improvement):
>
> find $PKG/usr/man -type f -a -name '*.gz' \
> -printf "chroot . /usr/bin/mandb -f /usr/man/%P &> /dev/null\n" \
> >> $PKG/install/doinst.sh
>
> Nick
I just thought of a simpler way. Append
[ ! -d usr/man ] || find usr/man -type f -a -name '*.gz' | xargs -r touch
to install/doinst.sh. The man pages are now modified at install time so the
daily mandb will process them.
Or am I missing something?
Cheers ... Duncan.
More information about the SlackBuilds-users
mailing list