[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Proposal: deprecate scripts/pre-*



Wow, never got so much feedback so fast over a ports tree proposal.
Are you guys on drugs ? :)

In any case, here's the actual bsd.port.mk patch.

Its size is deceptive: there are chunks of code moving around (of necessity),
so it looks more impressive than it is.

Details:
* the absence of a do-fetch target was triggering all the sub fetch 
files target.  This is unneeded, those sub fetch files target can always go
in.

* I've left real-configure depending on ${WRKBUILD}. I could
.if !defined(do-configure)
real-configure: ${WRKBUILD}
.else
real-configure:
.endif
but this looks over the top.

* the documentation is the most important change. Default behaviors are 
slightly less visible, hence the highly visible comments.


Actually, the resulting bsd.port.mk is smaller than the original... I'm more
and more convinced this is a good thing, as it becomes much easier to tailor
some specific targets (specifically, fetch internals can come pre-configured for
-j4 or higher)... 

Please test that everything in `normal' ports still does work... the few 
that Marco mention obviously need an overhaul.
I'll do that after checking in this (unless nasty surprises lurk) if nobody
beats me to it.

--- bsd.port.mk.orig	Fri Jan 14 09:38:04 2000
+++ bsd.port.mk	Fri Jan 21 01:29:00 2000
@@ -378,7 +378,8 @@
 # Please read the comments in the targets section below, you
 # should be able to use the pre-* or post-* targets/scripts
 # (which are available for every stage except checksum) or
-# override the do-* targets to do pretty much anything you want.
+# provide an overriding do-* target to do pretty much anything 
+# you want.
 #
 # NEVER override the "regular" targets unless you want to open
 # a major can of worms.
@@ -1123,7 +1124,8 @@
 
 ################################################################
 # The following hooks are used to create easy dummy targets for
-# disabling some bit of default target behavior you don't want.
+# disabling some bit of default target behavior you don't want,
+# and to perform ports build in the correct order.
 ################################################################
 
 # Disable checksum
@@ -1206,19 +1208,18 @@
 
 
 ################################################################
-# More standard targets start here.
-#
-# These are the body of the build/install framework.  If you are
-# not happy with the default actions, and you can't solve it by
-# adding pre-* or post-* targets/scripts, override these.
+# Support for standard targets start here.
 ################################################################
 
-# Fetch
 
-.if !target(do-fetch)
-do-fetch: ${ALLFILES:S_(_at_)_^@${FULLDISTDIR}/@}
+.if !target(fetch-all)
+fetch-all:
+	@cd ${.CURDIR} && make __FETCH_ALL=Yes real-fetch
+.endif
 
-.  for _F in ${_DISTFILES:S_(_at_)_^@${FULLDISTDIR}/@}
+# Separate target for each file fetch will retrieve
+
+.for _F in ${_DISTFILES:S_(_at_)_^@${FULLDISTDIR}/@}
 ${_F}:
 	@mkdir -p ${_F:H}
 	@cd ${_F:H}; \
@@ -1245,10 +1246,10 @@
 				exit 0; \
 		fi; \
 	done; exit 1
-.  endfor
+.endfor
 
-.  if defined(PATCHFILES)
-.    for _F in ${_PATCHFILES:S_(_at_)_^@${FULLDISTDIR}/@}
+.if defined(PATCHFILES)
+.  for _F in ${_PATCHFILES:S_(_at_)_^@${FULLDISTDIR}/@}
 ${_F}:
 	@mkdir -p ${_F:H}
 	@cd ${_F:H}; \
@@ -1275,11 +1276,9 @@
 				exit 0; \
 		fi; \
 	done; exit 1
-.    endfor
-
-.  endif	# defined(PATCHFILES)
+.  endfor
 
-.endif	# !target(do-fetch)
+.endif	# defined(PATCHFILES)
 
 # This is for the use of sites which store distfiles which others may
 # fetch - only fetch the distfile if it is allowed to be
@@ -1328,10 +1327,68 @@
 .  endif
 .endif
 
-# Extract
 
+${WRKBUILD}:
+	mkdir -p ${WRKBUILD}
+
+# Some support rules for do-package
+
+.if !target(package-links)
+package-links:
+	@make delete-package-links
+	@for cat in ${CATEGORIES}; do \
+		if [ ! -d ${PACKAGES}/$$cat ]; then \
+			if ! mkdir -p ${PACKAGES}/$$cat; then \
+				echo ">> Can't create directory ${PACKAGES}/$$cat."; \
+				exit 1; \
+			fi; \
+		fi; \
+		ln -s ../${PKGREPOSITORYSUBDIR}/${PKGNAME}${PKG_SUFX} ${PACKAGES}/$$cat; \
+	done;
+.endif
+
+.if !target(delete-package-links)
+delete-package-links:
+	@cd ${PACKAGES} && find . -type l -name ${PKGNAME}${PKG_SUFX}|xargs rm -f
+.endif
+
+.if !target(delete-package)
+delete-package:
+	@make delete-package-links
+	@rm -f ${PKGFILE}
+.endif
+
+################################################################
+# The real targets start here.
+# 
+# You shouldn't EVER change these. If possible, add a pre-* or
+# post-* hook.  
+# In the worst case, define a do-* target that will override
+# the main body of the target.
+################################################################
+
+
+real-fetch: fetch-depends
+.if target(pre-fetch)
+	@cd ${.CURDIR} && make pre-fetch
+.endif
+.if !target(do-fetch)
+# What FETCH normally does:
+	@cd ${.CURDIR} && make ${ALLFILES:S_(_at_)_^@${FULLDISTDIR}/@}
+# End of FETCH
+.endif
+.if target(post-fetch)
+	@cd ${.CURDIR} && make post-fetch
+.endif
+
+
+real-extract: build-depends lib-depends misc-depends
+	@${ECHO_MSG} "===>  Extracting for ${PKGNAME}"
+.if target(pre-extract)
+	@cd ${.CURDIR} && make pre-extract
+.endif
 .if !target(do-extract)
-do-extract:
+# What EXTRACT normally does:
 .  if !defined(NO_WRKDIR)
 .    if defined(WRKOBJDIR)
 	@rm -rf ${WRKOBJDIR}/${PORTSUBDIR}
@@ -1354,12 +1411,21 @@
 			exit 1; \
 		fi \
 	done
+# End of EXTRACT
+.endif
+.if target(post-extract)
+	@cd ${.CURDIR} && make post-extract
 .endif
 
-# Patch
 
+
+real-patch: 
+	@${ECHO_MSG} "===>  Patching for ${PKGNAME}"
+.if target(pre-patch)
+	@cd ${.CURDIR} && make pre-patch
+.endif
 .if !target(do-patch)
-do-patch:
+# What PATCH normally does:
 .  if defined(PATCHFILES)
 	@${ECHO_MSG} "===>  Applying distribution patches for ${PKGNAME}"
 	@cd ${FULLDISTDIR}; \
@@ -1405,12 +1471,20 @@
 		done;\
 		case $$error in 1) exit 1;; esac; \
 	fi
+# End of PATCH.
+.endif
+.if target(post-patch)
+	@cd ${.CURDIR} && make post-patch
 .endif
 
-# Configure
 
+real-configure: ${WRKBUILD}
+	@${ECHO_MSG} "===>  Configuring for ${PKGNAME}"
+.if target(pre-configure)
+	@cd ${.CURDIR) && make pre-configure
+.endif
 .if !target(do-configure)
-do-configure: ${WRKBUILD}
+# What CONFIGURE normally does
 	@if [ -f ${SCRIPTDIR}/configure ]; then \
 		cd ${.CURDIR} && ${SETENV} ${SCRIPTS_ENV} ${SH} \
 		  ${SCRIPTDIR}/configure; \
@@ -1427,96 +1501,76 @@
 .  if defined(USE_IMAKE)
 	@cd ${WRKSRC} && ${SETENV} ${MAKE_ENV} ${XMKMF}
 .  endif
+# End of CONFIGURE.
+.endif
+.if target(post-configure)
+	@cd ${.CURDIR} && make post-configure
 .endif
 
-${WRKBUILD}:
-	mkdir -p ${WRKBUILD}
 
-# Build
 
+real-build: 
+	@${ECHO_MSG} "===>  Building for ${PKGNAME}"
+.if target(pre-build)
+	@cd ${.CURDIR} && make pre-build
+.endif
 .if !target(do-build)
-do-build:
+# What BUILD normally does:
 	@cd ${WRKBUILD} && ${SETENV} ${MAKE_ENV} ${MAKE_PROGRAM} ${MAKE_FLAGS} ${MAKEFILE} ${ALL_TARGET}
+# End of BUILD
 .endif
-
-# Install
-
-.if !target(do-install)
-do-install:
-	@cd ${WRKBUILD} && ${SETENV} ${MAKE_ENV} ${MAKE_PROGRAM} ${MAKE_FLAGS} ${MAKEFILE} ${INSTALL_TARGET}
+.if target(post-build)
+	@cd ${.CURDIR} && make post-build
 .endif
 
-# Package
 
-.if !target(do-package)
-do-package:
-	@if [ -e ${PLIST} ]; then \
-		${ECHO_MSG} "===>  Building package for ${PKGNAME}"; \
-		if [ -d ${PACKAGES} ]; then \
-			if [ ! -d ${PKGREPOSITORY} ]; then \
-				if ! mkdir -p ${PKGREPOSITORY}; then \
-					echo ">> Can't create directory ${PKGREPOSITORY}."; \
-					exit 1; \
-				fi; \
-			fi; \
-		fi; \
-		if ${PKG_CMD} ${PKG_ARGS} ${PKGFILE}; then \
-			if [ -d ${PACKAGES} ]; then \
-				make package-links; \
-			fi; \
-		else \
-			make delete-package; \
-			exit 1; \
-		fi; \
+real-install: run-depends lib-depends 
+	@${ECHO_MSG} "===>  Installing for ${PKGNAME}"
+.if !defined(NO_PKG_REGISTER) && !defined(FORCE_PKG_REGISTER)
+	@if [ -d ${PKG_DBDIR}/${PKGNAME} -o "X$$(ls -d ${PKG_DBDIR}/${PKGNAME:C/-[0-9].*//g}-* 2> /dev/null)" != "X" ]; then \
+		echo "===>  ${PKGNAME} is already installed - perhaps an older version?"; \
+		echo "      If so, you may wish to \`\`make deinstall'' and install"; \
+		echo "      this port again by \`\`make reinstall'' to upgrade it properly."; \
+		echo "      If you really wish to overwrite the old port of ${PKGNAME}"; \
+		echo "      without deleting it first, set the variable \"FORCE_PKG_REGISTER\""; \
+		echo "      in your environment or the \"make install\" command line."; \
+		exit 1; \
 	fi
 .endif
-
-# Some support rules for do-package
-
-.if !target(package-links)
-package-links:
-	@make delete-package-links
-	@for cat in ${CATEGORIES}; do \
-		if [ ! -d ${PACKAGES}/$$cat ]; then \
-			if ! mkdir -p ${PACKAGES}/$$cat; then \
-				echo ">> Can't create directory ${PACKAGES}/$$cat."; \
-				exit 1; \
+	@if [ `${SH} -c umask` != ${DEF_UMASK} ]; then \
+		${ECHO_MSG} "===>  Warning: your umask is \"`${SH} -c umask`"\".; \
+		${ECHO_MSG} "      If this is not desired, set it to an appropriate value"; \
+		${ECHO_MSG} "      and install this port again by \`\`make reinstall''."; \
+	fi
+.if !defined(NO_MTREE)
+	@if [ `id -u` = 0 ]; then \
+		if [ ! -f ${MTREE_FILE} ]; then \
+			echo "Error: mtree file \"${MTREE_FILE}\" is missing."; \
+			echo "Copy it from a suitable location (e.g., /usr/src/etc/mtree) and try again."; \
+			exit 1; \
+		else \
+			if [ ! -d ${PREFIX} ]; then \
+				mkdir -p ${PREFIX}; \
 			fi; \
+			${MTREE_CMD} ${MTREE_ARGS} ${PREFIX}/; \
 		fi; \
-		ln -s ../${PKGREPOSITORYSUBDIR}/${PKGNAME}${PKG_SUFX} ${PACKAGES}/$$cat; \
-	done;
+	else \
+		${ECHO_MSG} "Warning: not superuser, can't run mtree."; \
+		${ECHO_MSG} "Become root and try again to ensure correct permissions."; \
+	fi
 .endif
-
-.if !target(delete-package-links)
-delete-package-links:
-	@cd ${PACKAGES} && find . -type l -name ${PKGNAME}${PKG_SUFX}|xargs rm -f
+	@${_MAKE_COOKIE} ${_INSTALL_PRE_COOKIE}
+.if defined(pre-install)
+	@cd ${.CURDIR} && make pre-install
 .endif
-
-.if !target(delete-package)
-delete-package:
-	@make delete-package-links
-	@rm -f ${PKGFILE}
+.if !defined(do-install)
+# What INSTALL normally does:
+	@cd ${WRKBUILD} && ${SETENV} ${MAKE_ENV} ${MAKE_PROGRAM} ${MAKE_FLAGS} ${MAKEFILE} ${INSTALL_TARGET}
+# End of INSTALL.
+.endif
+.if defined(post-install)
+	@cd ${.CURDIR} && make post-install
 .endif
-
-################################################################
-# This is the "generic" port target, actually a macro used from the
-# six main targets.  See below for more.
-################################################################
-
-_PORT_USE: .USE
-	@cd ${.CURDIR} && make ${.TARGET:S/^real-/pre-/}
-	@if [ -f ${SCRIPTDIR}/${.TARGET:S/^real-/pre-/} ]; then \
-		cd ${.CURDIR} && ${SETENV} ${SCRIPTS_ENV} ${SH} \
-			${SCRIPTDIR}/${.TARGET:S/^real-/pre-/}; \
-	fi
-	@cd ${.CURDIR} && make ${.TARGET:S/^real-/do-/}
-	@cd ${.CURDIR} && make ${.TARGET:S/^real-/post-/}
-	@if [ -f ${SCRIPTDIR}/${.TARGET:S/^real-/post-/} ]; then \
-		cd ${.CURDIR} && ${SETENV} ${SCRIPTS_ENV} ${SH} \
-			${SCRIPTDIR}/${.TARGET:S/^real-/post-/}; \
-	fi
-
-_POST_INSTALL: .USE
 .if defined(_MANPAGES) || defined(_CATPAGES)
 .  if defined(MANCOMPRESSED) && defined(NOMANCOMPRESS)
 	@${ECHO_MSG} "===>   Uncompressing manual pages for ${PKGNAME}"
@@ -1544,84 +1598,39 @@
 	@cd ${.CURDIR} && make fake-pkg
 .endif
 
-################################################################
-# Skeleton targets start here
-# 
-# You shouldn't have to change these.  Either add the pre-* or
-# post-* targets/scripts or redefine the do-* targets.  These
-# targets don't do anything other than checking for cookies and
-# call the necessary targets/scripts.
-################################################################
 
-.if !target(fetch-all)
-fetch-all:
-	@cd ${.CURDIR} && make __FETCH_ALL=Yes real-fetch
-.endif
-
-# And call the macros
 
-real-fetch: fetch-depends _PORT_USE
-real-extract: build-depends lib-depends misc-depends _PORT_USE
-	@${ECHO_MSG} "===>  Extracting for ${PKGNAME}"
-real-patch: _PORT_USE
-	@${ECHO_MSG} "===>  Patching for ${PKGNAME}"
-real-configure: _PORT_USE
-	@${ECHO_MSG} "===>  Configuring for ${PKGNAME}"
-real-build: _PORT_USE
-	@${ECHO_MSG} "===>  Building for ${PKGNAME}"
-real-install: run-depends lib-depends _PORT_USE _POST_INSTALL
-	@${ECHO_MSG} "===>  Installing for ${PKGNAME}"
-.if !defined(NO_PKG_REGISTER) && !defined(FORCE_PKG_REGISTER)
-	@if [ -d ${PKG_DBDIR}/${PKGNAME} -o "X$$(ls -d ${PKG_DBDIR}/${PKGNAME:C/-[0-9].*//g}-* 2> /dev/null)" != "X" ]; then \
-		echo "===>  ${PKGNAME} is already installed - perhaps an older version?"; \
-		echo "      If so, you may wish to \`\`make deinstall'' and install"; \
-		echo "      this port again by \`\`make reinstall'' to upgrade it properly."; \
-		echo "      If you really wish to overwrite the old port of ${PKGNAME}"; \
-		echo "      without deleting it first, set the variable \"FORCE_PKG_REGISTER\""; \
-		echo "      in your environment or the \"make install\" command line."; \
-		exit 1; \
-	fi
+real-package:
+.if defined(pre-package)
+	@cd ${.CURDIR} && make pre-package
 .endif
-	@if [ `${SH} -c umask` != ${DEF_UMASK} ]; then \
-		${ECHO_MSG} "===>  Warning: your umask is \"`${SH} -c umask`"\".; \
-		${ECHO_MSG} "      If this is not desired, set it to an appropriate value"; \
-		${ECHO_MSG} "      and install this port again by \`\`make reinstall''."; \
-	fi
-.if !defined(NO_MTREE)
-	@if [ `id -u` = 0 ]; then \
-		if [ ! -f ${MTREE_FILE} ]; then \
-			echo "Error: mtree file \"${MTREE_FILE}\" is missing."; \
-			echo "Copy it from a suitable location (e.g., /usr/src/etc/mtree) and try again."; \
-			exit 1; \
-		else \
-			if [ ! -d ${PREFIX} ]; then \
-				mkdir -p ${PREFIX}; \
+.if !defined(do-package)
+# What PACKAGE normally does:
+	@if [ -e ${PLIST} ]; then \
+		${ECHO_MSG} "===>  Building package for ${PKGNAME}"; \
+		if [ -d ${PACKAGES} ]; then \
+			if [ ! -d ${PKGREPOSITORY} ]; then \
+				if ! mkdir -p ${PKGREPOSITORY}; then \
+					echo ">> Can't create directory ${PKGREPOSITORY}."; \
+					exit 1; \
+				fi; \
 			fi; \
-			${MTREE_CMD} ${MTREE_ARGS} ${PREFIX}/; \
 		fi; \
-	else \
-		${ECHO_MSG} "Warning: not superuser, can't run mtree."; \
-		${ECHO_MSG} "Become root and try again to ensure correct permissions."; \
+		if ${PKG_CMD} ${PKG_ARGS} ${PKGFILE}; then \
+			if [ -d ${PACKAGES} ]; then \
+				make package-links; \
+			fi; \
+		else \
+			make delete-package; \
+			exit 1; \
+		fi; \
 	fi
+# End of PACKAGE.
+.endif
+.if defined(post-package)
+	@cd ${.CURDIR} && make post-package
 .endif
-	@${_MAKE_COOKIE} ${_INSTALL_PRE_COOKIE}
-
-real-package: _PORT_USE
-
-# Empty pre-* and post-* targets, note we can't use .if !target()
-# in the _PORT_USE macro
-
-.for name in fetch extract patch configure build install package
-
-.  if !target(pre-${name})
-pre-${name}:
-.  endif
-
-.  if !target(post-${name})
-post-${name}:
-.  endif
 
-.endfor
 
 # Checkpatch
 #

-- 
	Marc Espie		
|anime, sf, juggling, unicycle, acrobatics, comics...
|AmigaOS, OpenBSD, C++, perl, Icon, PostScript...
| `real programmers don't die, they just get out of beta'



Visit your host, monkey.org