summaryrefslogtreecommitdiff
path: root/mk/flavor/pkg/install.mk
blob: b2ead7eb6d45f0b83e59f58eb5388f03581994e1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# $NetBSD: install.mk,v 1.5 2006/06/07 17:21:23 jlam Exp $

######################################################################
### install-check-conflicts (PRIVATE, pkgsrc/mk/install/install.mk)
######################################################################
### install-check-conflicts checks for conflicts between the package
### and and installed packages.
###
.PHONY: install-check-conflicts
install-check-conflicts:
	${_PKG_SILENT}${_PKG_DEBUG}${RM} -f ${WRKDIR}/.CONFLICTS
.for _conflict_ in ${CONFLICTS}
	${_PKG_SILENT}${_PKG_DEBUG}					\
	found="`${_PKG_BEST_EXISTS} ${_conflict_:Q} || ${TRUE}`";	\
	case "$$found" in						\
	"")	;;							\
	*)	${ECHO} "$$found" >> ${WRKDIR}/.CONFLICTS ;;		\
	esac
.endfor
	${_PKG_SILENT}${_PKG_DEBUG}					\
	${TEST} -f ${WRKDIR}/.CONFLICTS || exit 0;			\
	${ERROR_MSG} "${PKGNAME} conflicts with installed package(s):";	\
	${CAT} ${WRKDIR}/.CONFLICTS | ${SED} -e "s|^|    |" | ${ERROR_CAT}; \
	${ERROR_MSG} "They install the same files into the same place."; \
	${ERROR_MSG} "Please remove conflicts first with pkg_delete(1)."; \
	${RM} -f ${WRKDIR}/.CONFLICTS;					\
	exit 1

######################################################################
### install-check-installed (PRIVATE, pkgsrc/mk/install/install.mk)
######################################################################
### install-check-installed checks if the package (perhaps an older
### version) is already installed on the system.
###
.PHONY: install-check-installed
install-check-installed:
	${_PKG_SILENT}${_PKG_DEBUG}					\
	found="`${_PKG_BEST_EXISTS} ${PKGWILDCARD:Q} || ${TRUE}`";	\
	case "$$found" in						\
	"")	;;							\
	*)	${ERROR_MSG} "$$found is already installed - perhaps an older version?"; \
		${ERROR_MSG} "If so, you may use either of:";	\
		${ERROR_MSG} "    - \"pkg_delete $$found\" and \"${MAKE} reinstall\""; \
		${ERROR_MSG} "      to upgrade properly"; \
		${ERROR_MSG} "    - \"${MAKE} update\" to rebuild the package and all"; \
		${ERROR_MSG} "      of its dependencies"; \
		${ERROR_MSG} "    - \"${MAKE} replace\" to replace only the package without"; \
		${ERROR_MSG} "      re-linking dependencies, risking various problems."; \
		exit 1;							\
		;;							\
	esac

######################################################################
### register-pkg (PRIVATE, pkgsrc/mk/install/install.mk)
######################################################################
### register-pkg populates the package database with the appropriate
### entries to register the package as being installed on the system.
###
_REGISTER_DEPENDENCIES=							\
	${SETENV} PKG_DBDIR=${_PKG_DBDIR:Q}				\
		AWK=${TOOLS_AWK:Q}					\
		PKG_ADMIN=${PKG_ADMIN_CMD:Q}				\
	${SH} ${PKGSRCDIR}/mk/flavor/pkg/register-dependencies

.PHONY: register-pkg
register-pkg: generate-metadata ${_DEPENDS_COOKIE}
	@${PHASE_MSG} "Registering installation for ${PKGNAME}"
	${_PKG_SILENT}${_PKG_DEBUG}${RM} -fr ${_PKG_DBDIR}/${PKGNAME}
	${_PKG_SILENT}${_PKG_DEBUG}${MKDIR} ${_PKG_DBDIR}/${PKGNAME}
	${_PKG_SILENT}${_PKG_DEBUG}${CP} ${PKG_DB_TMPDIR}/* ${_PKG_DBDIR}/${PKGNAME}
	${_PKG_SILENT}${_PKG_DEBUG}${PKG_ADMIN} add ${PKGNAME}
	${_PKG_SILENT}${_PKG_DEBUG}					\
	case ${_AUTOMATIC:Q}"" in					\
	[yY][eE][sS])	${PKG_ADMIN} set automatic=yes ${PKGNAME} ;;	\
	esac
	${_PKG_SILENT}${_PKG_DEBUG}${_DEPENDS_PATTERNS_CMD} |		\
		${SORT} -u | ${_REGISTER_DEPENDENCIES} ${PKGNAME}