Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 22 Sep 1999 19:27:50 +0200
From:      Christian Weisgerber <naddy@unix-ag.uni-kl.de>
To:        Satoshi - Ports Wraith - Asami <asami@freebsd.org>
Cc:        freebsd-ports@freebsd.org
Subject:   Re: Port Making Program
Message-ID:  <19990922192750.A96298@fettuccini.unix-ag.uni-kl.de>
In-Reply-To: <vqc1zbrmbkj.fsf@silvia.hip.berkeley.edu>; from Satoshi - Ports Wraith - Asami on Wed, Sep 22, 1999 at 04:26:35AM -0700
References:  <19990921133230.A43770@cichlids.cichlids.com> <7saaf3$5r5$1@bigeye.rhein-neckar.de> <vqc1zbrmbkj.fsf@silvia.hip.berkeley.edu>

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

--fUYQa+Pmc3FrFX/N
Content-Type: text/plain; charset=us-ascii

Satoshi - Ports Wraith - Asami:

>  * OpenBSD has a "plist" target in its bsd.port.mk. Rather than
>  * rewriting this facility from scratch, it could just be ported.
>  * I can take a look at this later today.
> 
> That will be great.  It's always nice to borrow something from the
> other *BSD's. :)

Here we go...

The modifications to bsd.port.mk are minor; an additional cookie
is introduced along with a "plist" target that calls Marc Espie's
make-plist Perl script. That script again required only small
changes. The main difference to OpenBSD is that they include the
man pages in the PLIST. We skip ${MANPREFIX}/man in the find.

A patch with the changes is appended. I tried it out with a couple
of ports. Some more people ought to bang on it. I do not claim to
have any understanding whatsoever of the bsd.port.mk internals. ;-)

Here's the relevant section from
<URL:http://www.openbsd.org/checklist.html>:

| 17. Create pkg/PLIST
| 
|     After the install is complete use the developer's command: 
| 
|     make plist 
| 
|     which makes the file PLIST-auto in the pkg directory. This
|     file is a candidate packing list. Beware: the files are found
|     by timestamp. This means it does NOT:
| 
|     o    list any files installed with `tar' as their timestamp
|          will not change and thus won't be found by `find'
| 
|     o    update the info/dir file if .info files are added.
|          You'll have to add that by hand. Also, be sure that
|          the info/dir is not part of the PLIST.
| 
|     o    try to do anything special with links or symbolic links.
|          A cursory test of tar shows it does the right thing
|          with links and symbolic links so I don't see why we
|          need to special case anything in the packing list. But
|          still...
| 
|     Peruse `PLIST-auto' and verify that everything was installed
|     and that it was installed in the proper locations. Anything
|     not installed can be added to a port Makefile `post-install'
|     rule.
| 
|     Copy `PLIST-auto' to `PLIST'

-- 
Christian "naddy" Weisgerber                     naddy@unix-ag.uni-kl.de

--fUYQa+Pmc3FrFX/N
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="plist.patch"

--- Mk/bsd.port.mk.orig	Wed Sep 22 06:12:55 1999
+++ Mk/bsd.port.mk	Wed Sep 22 19:05:21 1999
@@ -675,6 +675,7 @@
 # there is no way to refer to them cleanly from within the macro AFAIK.
 EXTRACT_COOKIE?=	${WRKDIR}/.extract_done
 CONFIGURE_COOKIE?=	${WRKDIR}/.configure_done
+INSTALL_PRE_COOKIE?=${WRKDIR}/.install_started
 INSTALL_COOKIE?=	${WRKDIR}/.install_done
 BUILD_COOKIE?=		${WRKDIR}/.build_done
 PATCH_COOKIE?=		${WRKDIR}/.patch_done
@@ -1771,7 +1772,8 @@
 .endif
 	@if [ -d ${PREFIX}/info -a ! -f ${PREFIX}/info/dir -a -f /usr/share/info/dir ]; then \
 	  ${SED} -ne '1,/Menu:/p' /usr/share/info/dir > ${PREFIX}/info/dir; \
-	 fi
+	fi
+	@touch ${INSTALL_PRE_COOKIE}
 .endif
 	@cd ${.CURDIR} && ${MAKE} ${__softMAKEFLAGS} ${.TARGET:S/^real-/pre-/}
 	@if [ -f ${SCRIPTDIR}/${.TARGET:S/^real-/pre-/} ]; then \
@@ -1947,7 +1949,7 @@
 
 .if !target(reinstall)
 reinstall:
-	@${RM} -f ${INSTALL_COOKIE} ${PACKAGE_COOKIE}
+	@${RM} -f ${INSTALL_PRE_COOKIE} ${INSTALL_COOKIE} ${PACKAGE_COOKIE}
 	@DEPENDS_TARGET="${DEPENDS_TARGET}" ${MAKE} install
 .endif
 
@@ -2117,6 +2119,18 @@
 			exit 1; \
 		  fi) ; \
 	fi
+.endif
+
+# Packing list utilities.  This generates a packing list from a recently
+# installed port.  Not perfect, but pretty close.  The generated file
+# will have to have some tweaks done by hand.
+#
+.if !target(plist)
+plist: install
+	@PREFIX=${PREFIX} LDCONFIG="${LDCONFIG}" MTREE_FILE=${MTREE_FILE} \
+	INSTALL_PRE_COOKIE=${INSTALL_PRE_COOKIE} \
+	SETENV="${SETENV}" MANPREFIX=${MANPREFIX} \
+	${PERL} ${PORTSDIR}/Tools/make-plist > ${PLIST}-auto
 .endif
 
 ################################################################
--- /dev/null	Wed Sep 22 19:07:42 1999
+++ Tools/make-plist	Wed Sep 22 19:00:03 1999
@@ -0,0 +1,163 @@
+#!/usr/bin/perl -w
+
+# $FreeBSD$
+# $OpenBSD: make-plist,v 1.2 1999/07/29 14:01:12 espie Exp $
+
+#  Copyright (c) 1999 Marc Espie
+# 
+#  Redistribution and use in source and binary forms, with or without
+#  modification, are permitted provided that the following conditions
+#  are met:
+#  1. Redistributions of source code must retain the above copyright
+#     notice, this list of conditions and the following disclaimer.
+#  2. Redistributions in binary form must reproduce the above copyright
+#     notice, this list of conditions and the following disclaimer in the
+#     documentation and/or other materials provided with the distribution.
+#  3. All advertising materials mentioning features or use of this software
+#     must display the following acknowledgement:
+# 	This product includes software developed by the OpenBSD project
+#
+#  4. Neither the name of the OpenBSD project nor the names of its contributors
+#     may be used to endorse or promote products derived from this software
+#     without specific prior written permission.
+# 
+#  THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND
+#  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+#  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+#  ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE
+#  FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+#  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+#  OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+#  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+#  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+#  OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+#  SUCH DAMAGE.
+# 
+
+
+use strict;
+
+
+use File::Find;
+
+my (%newdir, %occupied, %ldconfig, %infodir, @files);
+
+# compare all files against this date
+my $date = (stat $ENV{INSTALL_PRE_COOKIE})[10];
+
+# prefix to remove from everything
+my $base = $ENV{PREFIX};
+
+# skip man pages
+my $manprefix = "$ENV{MANPREFIX}/man";
+
+
+# read an mtree file, and produce the corresponding directory hierarchy
+sub parse_mtree {
+	# start under current PREFIX, usually
+	my $current = shift;
+	local(*FILE);
+	my %mtree;
+	open FILE, $ENV{MTREE_FILE};
+	while(<FILE>) {
+		chomp;
+		s/^\s*//;
+		next if /^\#/ || /^\//;
+		s/\s.*$//;
+		next if /^$/;
+		if ($_ eq '..') {
+			$current =~ s|/[^/]*$||;
+			next;
+		} else {
+			$current.="/$_";
+		}
+		$_ = $current;
+		while (s|/\./|/|)	{}
+		$mtree{$_} = 1;
+	}
+	close FILE;
+	return \%mtree;
+}
+
+sub strip {
+	local($_) = shift;
+	s|^\Q$base\E/||;
+	return $_;
+}
+
+sub add_info {
+	my ($header, $infodir) = @_;
+	for my $d (sort (keys %$infodir) ) {
+		for my $f (sort @{$infodir->{$d}}) {
+			my $d2 = strip($d);
+			print "$header --info-dir=\%D/$d2 \%D/$d2/$f\n";
+		}
+	}
+}
+
+
+# recursive traversal: mark specific `info' dirs, `ldconfig' dirs,
+# and potentially modified dirs
+
+find(
+	sub {
+		if ($File::Find::dir eq $manprefix) {
+			$File::Find::prune = 1;
+			return;
+		}
+		my $cdate = (lstat $_)[10];
+		if ($cdate >= $date) {
+			if (-d _) {
+				$newdir{$File::Find::name} = 1;
+			} else {
+				push(@files, $File::Find::name);
+				if (/\.so\.\d+(\.\d+)?$/) {
+					$ldconfig{$File::Find::dir} = 1;
+				}
+				if (/\.info$/) {
+					my $d = $File::Find::dir;
+					$infodir{$d} = [] unless defined $infodir{$d};
+					push(@{$infodir{$d}}, $_);
+				}
+			}
+		} else {
+			$occupied{$File::Find::dir} = 1;
+		}
+	}, $base);
+
+
+# occupied marks a dir that was already there... 
+# so all parents had to be around too
+for my $d (keys %occupied) {
+	while ($d ne '') {
+		undef $newdir{$d} if defined $newdir{$d};
+		$d =~ s|/.*?/?$||;
+	}
+}
+
+# make sure mtree is removed 
+my $mtree = parse_mtree($base);
+for my $d (keys %$mtree) {
+	undef $newdir{$d}
+}
+
+add_info('@unexec install-info --delete', \%infodir);
+
+for my $f (sort @files) {
+	print strip($f), "\n" unless ($f =~ m|/dir$|) && (defined $infodir{$`});
+}
+
+for my $d (sort { $b cmp $a } (grep { $newdir{$_} } (keys %newdir) ) ) {
+	print "\@dirrm ",strip($d), "\n";
+}
+	
+my $setenv = $ENV{SETENV};
+my $ldconfig = $ENV{LDCONFIG};
+
+for my $d (sort (keys %ldconfig)) {
+	print "\@exec $setenv OBJFORMAT=%%PORTOBJFORMAT%% $ldconfig -m %D/", strip($d), "\n";
+	print "\@unexec $setenv OBJFORMAT=%%PORTOBJFORMAT%% $ldconfig -R\n";
+}
+	
+add_info('@exec install-info', \%infodir);
+

--fUYQa+Pmc3FrFX/N--


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?19990922192750.A96298>