Finding depends-on ports

Beeblebrox zaphod at berentweb.com
Mon Jun 5 11:41:39 UTC 2017


Hello & thanks for your help!

Your code snip worked very nicely, with an exception when the INDEX filed has an empty string due to
a) port has no depends, so empty field
b) depends field is moved over by one (-f 8) as in the case for archivers/arj. I aready had mine from "make index", so it could be a problem thta only I'm seeing.
The empty field causes the whole ports list to be printed out as depends.
Final code below, although it most likely could be made much more elegant than what I wrote.

Regards...

#!/bin/sh
pkglst="ins.lst"
outfile="tmp.lst"
offender="some/port"

mi () {
  pn="$@|"
  
  # make sure dependents field not empty
  cf=9
  dcheck=$(grep ${pn} /usr/ports/INDEX-12 | cut -f9 -d\|)
  if [ -z "$dcheck" ]; then
    cf=8
    dcheck=$(grep ${pn} /usr/ports/INDEX-12 | cut -f8 -d\|)
    if [ -z "$dcheck" ]; then
      return 0
    fi
  fi

  deplst=$(egrep "^($(fgrep ${pn} /usr/ports/INDEX-12 | cut -f "$cf" -d\| | tr ' ' '|'))" /usr/ports/INDEX-12 | cut -f2 -d\|)
  case "$deplst" in
    *"$offender"* ) printf "%s\n" $pn >> "$outfile"
  esac
}

while read port; do
  mi "$port"
done < "$pkglst"


-- 
FreeBSD_amd64_12-Current_RadeonKMS
Please CC my email when responding, mail from list is not delivered.


More information about the freebsd-ports mailing list