new install-deinstall patch for bsd.port.mk
Sergey Matveychuk
sem at ciam.ru
Tue May 6 05:55:20 PDT 2003
Hello Kris!
This is my and Joe's patch I'v sent you but fixed for the new version of
bsd.port.mk.
Have you received a datailed description before?
----
Sem.
-------------- next part --------------
--- bsd.port.mk.orig Tue May 6 16:04:43 2003
+++ bsd.port.mk Tue May 6 16:44:49 2003
@@ -522,6 +522,7 @@
# reinstall - Install the results of a build, ignoring "already installed"
# flag.
# deinstall - Remove the installation.
+# deinstall-all - Remove all installations with the same PKGORIGIN.
# package - Create a package from an _installed_ port.
# describe - Try to generate a one-line description for each port for
# use in INDEX files and the like.
@@ -672,9 +673,9 @@
# by "%%") as defined in PLIST_SUB to generate ${TMPPLIST}. For
# instance, "OSREL=${OSREL}" in PLIST_SUB causes all occurrences of
# "%%OSREL%%" in ${PLIST} to be substituted by the value of OSREL.
-# ${TMPPLIST} is generated between the do-install and post-install
-# stages. If you are generating the packing list on-the-fly, make
-# sure it's generated by the end of do-install!
+# ${TMPPLIST} is generated before the do-install stage. If you are
+# generating the packing list on-the-fly, make sure it's generated before
+# do-install is called!
#
# For package:
#
@@ -737,6 +738,7 @@
CHGRP?= /usr/bin/chgrp
CHMOD?= /bin/chmod
CHOWN?= /usr/sbin/chown
+COMM?= /usr/bin/comm
CP?= /bin/cp
CUT?= /usr/bin/cut
DC?= /usr/bin/dc
@@ -2910,16 +2912,33 @@
.if !target(check-already-installed)
check-already-installed:
.if !defined(NO_PKG_REGISTER) && !defined(FORCE_PKG_REGISTER)
- @if [ -d ${PKG_DBDIR}/${PKGNAME} -o \
- "x`${PKG_INFO} -q -O ${PKGORIGIN} 2> /dev/null`" != "x" ]; then \
- ${ECHO_CMD} "===> ${PKGNAME} is already installed - perhaps an older version?"; \
- ${ECHO_CMD} " If so, you may wish to \`\`make deinstall'' and install"; \
- ${ECHO_CMD} " this port again by \`\`make reinstall'' to upgrade it properly."; \
- ${ECHO_CMD} " If you really wish to overwrite the old port of ${PKGNAME}"; \
- ${ECHO_CMD} " without deleting it first, set the variable \"FORCE_PKG_REGISTER\""; \
- ${ECHO_CMD} " in your environment or the \"make install\" command line."; \
- exit 1; \
- fi
+ @${ECHO_MSG} "===> Checking if ${PKGORIGIN} already installed"
+ @already_installed=`${PKG_INFO} -q -O ${PKGORIGIN} 2> /dev/null`; \
+ if [ -n "$${already_installed}" ]; then \
+ for p in $${already_installed}; do \
+ prfx=`${PKG_INFO} -q -p $${p} 2> /dev/null | ${SED} -e 's|^@cwd ||'`; \
+ if [ "x${PREFIX}" = "x$${prfx}" ]; then \
+ df=`${PKG_INFO} -q -f $${p} 2> /dev/null | ${GREP} -v "^@" | ${COMM} -12 - ${TMPPLIST}`; \
+ if [ -n "$${df}" ]; then \
+ found_package=$${p}; \
+ break; \
+ fi; \
+ fi; \
+ done; \
+ fi; \
+ if [ -d ${PKG_DBDIR}/${PKGNAME} -o -n "$${found_package}" ]; then \
+ if [ -d ${PKG_DBDIR}/${PKGNAME} ]; then \
+ ${ECHO_CMD} "===> ${PKGNAME} is already installed"; \
+ else \
+ ${ECHO_CMD} "===> An older version of ${PKGORIGIN} is already installed ($${found_package})"; \
+ fi; \
+ ${ECHO_CMD} " You may wish to \`\`make deinstall'' and install this port again"; \
+ ${ECHO_CMD} " by \`\`make reinstall'' to upgrade it properly."; \
+ ${ECHO_CMD} " If you really wish to overwrite the old port of ${PKGORIGIN}"; \
+ ${ECHO_CMD} " without deleting it first, set the variable \"FORCE_PKG_REGISTER\""; \
+ ${ECHO_CMD} " in your environment or the \"make install\" command line."; \
+ exit 1; \
+ fi
.else
@${DO_NADA}
.endif
@@ -3093,10 +3112,11 @@
_BUILD_SEQ= build-message pre-build pre-build-script do-build \
post-build post-build-script
_INSTALL_DEP= build
-_INSTALL_SEQ= install-message check-categories check-already-installed \
- check-conflicts check-umask run-depends lib-depends \
- install-mtree pre-install pre-install-script do-install \
- generate-plist post-install post-install-script compress-man \
+_INSTALL_SEQ= install-message check-categories check-conflicts \
+ check-umask run-depends lib-depends install-mtree \
+ pre-install pre-install-script generate-plist \
+ check-already-installed do-install \
+ post-install post-install-script compress-man \
run-ldconfig fake-pkg security-check
_PACKAGE_DEP= install
_PACKAGE_SEQ= package-message pre-package pre-package-script \
@@ -3263,17 +3283,48 @@
.if !target(deinstall)
deinstall:
- @deinstall_name=`${PKG_INFO} -q -O ${PKGORIGIN} 2> /dev/null`; \
- ${TEST} -z $${deinstall_name} && deinstall_name=${PKGNAME}; \
- ${ECHO_MSG} "===> Deinstalling for ${PKGORIGIN} ($${deinstall_name})"; \
- if ${PKG_INFO} -e $${deinstall_name}; then \
- ${PKG_DELETE} -f $${deinstall_name}; \
- else \
- ${ECHO_MSG} "===> ${PKGORIGIN} not installed, skipping"; \
- fi
+ @${ECHO_MSG} "===> Deinstalling for ${PKGORIGIN}"
+ @found_names=`${PKG_INFO} -q -O ${PKGORIGIN} 2> /dev/null`; \
+ for p in $${found_names}; do \
+ check_name=`${ECHO} $${p} | ${SED} -e 's/-[^-]*$$//'`; \
+ if [ "$${check_name}" = "${PKGBASE}" ]; then \
+ deinstall_name=$${p}; \
+ break; \
+ fi; \
+ done; \
+ if [ -n "$${deinstall_name}" ]; then \
+ prfx=`${PKG_INFO} -q -p $${p} 2> /dev/null | ${SED} -e 's|^@cwd ||'`; \
+ if [ "x${PREFIX}" != "x$${prfx}" ]; then \
+ ${ECHO_MSG} "===> $${p} has a different PREFIX: $${prfx}, skipping"; \
+ else \
+ ${ECHO_MSG} "===> Deinstalling $${deinstall_name}"; \
+ ${PKG_DELETE} -f $${deinstall_name}; \
+ fi; \
+ else \
+ ${ECHO_MSG} "===> ${PKGORIGIN} not installed, skipping"; \
+ fi
@${RM} -f ${INSTALL_COOKIE} ${PACKAGE_COOKIE}
.endif
+# Deinstall-all
+#
+# Special target to remove installation of all ports of the same origin
+
+.if !target(deinstall-all)
+deinstall-all:
+ @${ECHO_MSG} "===> Deinstalling for ${PKGORIGIN}"
+ @deinstall_names=`${PKG_INFO} -q -O ${PKGORIGIN} 2> /dev/null`; \
+ if [ -n "$${deinstall_names}" ]; then \
+ for d in $${deinstall_names}; do \
+ ${ECHO_MSG} "===> Deinstalling $${d}"; \
+ ${PKG_DELETE} -f $${d}; \
+ done; \
+ else \
+ ${ECHO_MSG} "===> ${PKGORIGIN} not installed, skipping"; \
+ fi
+ @${RM} -f ${INSTALL_COOKIE} ${PACKAGE_COOKIE}
+.endif
+
# Cleaning up
.if !target(do-clean)
More information about the freebsd-ports
mailing list