Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 7 Oct 1999 16:37:45 +0200 (CEST)
From:      Christian Weisgerber <naddy@unix-ag.uni-kl.de>
To:        FreeBSD-gnats-submit@freebsd.org
Subject:   ports/14182: Patch: bsd.port.mk: add plist target
Message-ID:  <199910071437.QAA25375@fettuccini.unix-ag.uni-kl.de>

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

>Number:         14182
>Category:       ports
>Synopsis:       Patch: bsd.port.mk: add plist target
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Thu Oct  7 07:50:00 PDT 1999
>Closed-Date:
>Last-Modified:
>Originator:     Christian Weisgerber
>Release:        FreeBSD 4.0-CURRENT i386
>Organization:
Unix-AG, Uni Kaiserslautern
>Environment:

n/a

>Description:

The appended patch adds support for a target "plist" to bsd.port.mk.
"make plist" will assist in creating the pkg/PLIST file for a new
port. A manual perusal of the generated file is still required.

This patch carries over work done by Marc Espie <espie@openbsd.org>
on the OpenBSD port system.

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.

>How-To-Repeat:

n/a

>Fix:

--- 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);
+

>Release-Note:
>Audit-Trail:
>Unformatted:


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?199910071437.QAA25375>