Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 03 Oct 2005 11:55:28 -0500
From:      Eric Schuele <e.schuele@computer.org>
To:        FreeBSD Questions <freebsd-questions@freebsd.org>
Subject:   Determining what a port will install... (more than pretty-print-*) [Soln]
Message-ID:  <43416280.80403@computer.org>

next in thread | raw e-mail | index | archive | help
Hello,

Some time back I posted a question regarding how to determine what
ports/packages would need to be installed on my machine when I install a 
new (new to the local machine) port.

For example, if I do not presently have openoffice installed... what
will get installed when I 'make install clean' it?  Note that I want the
differences between what is needed to build/run the port and what is
already present on the machine.

At the time no one responded with a clear way to do this... so I finally
had a few minutes to write a script to do it for me.  I thought someone
else might find it useful... So I'm posting it here for comments and
thoughts (be gentle, I'm new to awk).

I find it useful, especially for laptops... which may have a small HDD
and little memory.  I generally try to install the minimum necessary to
do my work.

#! /bin/sh

# Script to determine the differences between what is necessary for
# a port, and what is already present on the local machine.

make pretty-print-build-depends-list | \
  awk '{
         count = 0
         pkgs = ""
         for(i=5; i<=NF-2; i++) {
	  pkg = $i
	
	  if (index(pkg, "\"") == 1)
	    {pkg = substr(pkg, 2, length(pkg)-1)}
	  if (index(pkg, "\"") > 1)
             {pkg = substr(pkg, 1, length(pkg)-1)}
		
           if ( system("pkg_info -e " pkg) == 1) {
             pkgs = pkgs " " pkg
             count++
           }
         }

         if ( count ) {
           print "You need the following (build) perequisites:"
           print pkgs
         }
         else {
           print "All (build) prerequisites are present."
         }

       }'

make pretty-print-run-depends-list | \
  awk '{
         count = 0
         pkgs = ""
         for(i=5; i<=NF-2; i++) {
	  pkg = $i
	
	  if (index(pkg, "\"") == 1)
	    {pkg = substr(pkg, 2, length(pkg)-1)}
	  if (index(pkg, "\"") > 1)
             {pkg = substr(pkg, 1, length(pkg)-1)}
		
           if ( system("pkg_info -e " pkg) == 1) {
             pkgs = pkgs " " pkg
             count++
           }
         }

         if ( count ) {
           print "You need the following (run) perequisites:"
           print pkgs
         }
         else {
           print "All (run) prerequisites are present."
         }

       }'

-- 
Regards,
Eric



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?43416280.80403>