Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 4 Jan 2001 01:46:58 +0100
From:      Ernst de Haan <ernst@jollem.com>
To:        ports@freebsd.org
Cc:        Sebastiaan van Erk <sebster@sebster.com>
Subject:   Script to automate pkg-plist creation
Message-ID:  <20010104014658.A21439@c187104187.telekabel.chello.nl>

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

--/04w6evG8XlLl3ft
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

Hi,

While creating some ports, I found the instructions for generating a pkg-plist
file (at http://www.freebsd.org/porters-handbook/porting-autoplist.html) very
useful. However, I would like to suggest some improvements along with a shell
script to automate the process.

Suggestions:

   * Use the directory /tmp/<portname> instead of /var/tmp/<portname> as /tmp
     usually links to the location where the administrator would like the
     temporary files to go (at least that's my understanding, correct me if I
     am wrong, but I link it to /usr/tmp to avoid overloading my root fs.)

   * Add an instruction to create the directory to place the temporary
     installation of the port in. Something like "mkdir /tmp/<portname>" (or
     "mkdir /var/tmp/<portname>" if using /var/tmp)

   * Use find -d when searching for the newly created directories, as this
     will create the correct order for the directories (depth-first). Doing
     this will break the script, because it uses comm(1).

I have created a shell script that takes the name of the port as the argument
and does the things suggested in the porting-autoplist.html pages, with my
suggestions applied.

Here's an example, based on a "jpda" port I am working on:

   heinz# build-plist jpda
   [1/10] Deinstalling port (if installed).
   [2/10] Creating directory /tmp/jpda... [ DONE ]
   [3/10] Creating new set of directories to simulate /usr/local/... [ DONE ]
   [4/10] Installing dependencies.
   ===>   jpda-1.0 depends on executable: unzip - found
   ===>   jpda-1.0 depends on file: /usr/local/jdk1.2.2/bin/java - found
   [5/10] Storing clean directory structure... [ DONE ]
   [6/10] Installing port...
   ===>  Installing for jpda-1.0
   ===>   jpda-1.0 depends on file: /usr/local/jdk1.2.2/bin/java - found
   ===>   Generating temporary packing list
   Java Platform Debugger Architecture has been installed.
   Binaries, examples and docs are in /tmp/jpda/share/java/jpda-1.0/.
   The JAR file is in /tmp/jpda/share/java/classes/jpda-1.0/.
   ===>   Registering installation for jpda-1.0
   [7/10] Finding all installed files... [ DONE ]
   [8/10] Finding all installed directories... [ DONE ]
   [9/10] Deinstalling port
   ===>  Deinstalling for jpda-1.0
   pkg_delete: couldn't open dependency file `/var/db/pkg/XFree86-3.3.6_6/+REQUIRED_BY'
   [10/10] Removing /tmp/jpda... [ DONE ]
   The pkg-plist file has been created.

Since I don't have XFree86 3.3.6_6 but XFree86-4.0.2_3, I always get that
error you are seeing. It doesn't hurt.

I have attached the script, with a small Perl file that is used instead of
comm(1). Thanks to Sebastiaan van Erk, my local Perl hero ;)

IMHO the script will be very useful for port writers/maintainers. In fact I
think we should make this a target in the Makefile for ports, but I would have
to look into that.

Any comments and suggestions are welcome! :)


--
Ernst

--/04w6evG8XlLl3ft
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=build-plist

#!/bin/sh

if [ "$1a" = "a" ]
then
	echo "No argument specified. Please specify the name of the port."
	exit 1
fi

if [ ! "$2a" = "a" ]
then
	echo "More then one argument specified. Please only specify the name of the port."
	exit 1
fi

# The directory we will temporarily install the port into
TMPDIR=/tmp/$1

# The directory we were executed from
EXECDIR=`dirname $0`

# Empty the pkg-plist file
rm -f pkg-plist
touch pkg-plist

# Make sure the port is not installed.
echo "[1/10] Deinstalling port (if installed)."
make deinstall > /dev/null

# Make the directory we will install the port into
echo -n "[2/10] Creating directory ${TMPDIR}..."
rm -rf ${TMPDIR}
mkdir ${TMPDIR}
echo " [ DONE ]"

# Create a new set of directories in which your port can be installed
echo -n "[3/10] Creating new set of directories to simulate /usr/local/..."
mtree -U -f /etc/mtree/BSD.local.dist -d -e -p ${TMPDIR} > /dev/null
echo " [ DONE ]"

# Install any dependencies
echo "[4/10] Installing dependencies."
make depends PREFIX=${TMPDIR}

# Store the directory structure in a new file "OLD-DIRS"
echo -n "[5/10] Storing clean directory structure..."
(cd ${TMPDIR} && find -d * -type d) > OLD-DIRS
echo " [ DONE ]"

# Install the port in the temporary directory
echo "[6/10] Installing port..."
make install PREFIX=${TMPDIR}

# Find all normal files
echo -n "[7/10] Finding all installed files..."
(cd ${TMPDIR} && find * \! -type d) > pkg-plist
echo " [ DONE ]"

# Find all directories
echo -n "[8/10] Finding all installed directories..."
(cd ${TMPDIR} && find -d * -type d) | ${EXECDIR}/purge.pl OLD-DIRS | sed -e 's#^#@dirrm #' >> pkg-plist
echo " [ DONE ]"

# Deinstall port
echo "[9/10] Deinstalling port"
make deinstall

echo -n "[10/10] Removing ${TMPDIR}..."
rm -rf ${TMPDIR}
echo " [ DONE ]"

echo "The pkg-plist file has been created."

--/04w6evG8XlLl3ft
Content-Type: application/x-perl
Content-Disposition: attachment; filename="purge.pl"

#!/usr/bin/perl
 
die "usage: $0 <purge file>\n" unless $ARGV[0];
 
open(OLDFILES, $ARGV[0]) || die "$0: failed to open $ARGV[0]\n";
@purge = (<OLDFILES>);
close(OLDFILES);
 
while ($in = <STDIN>) {
   print $in unless scalar grep { $in eq $_ } @purge;
}

--/04w6evG8XlLl3ft--


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-ports" in the body of the message




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