1 # $NetBSD: bsd.pkg.update.mk,v 1.22 2010/07/03 04:24:14 darcy Exp $
3 # This Makefile fragment is included by bsd.pkg.mk and contains the targets
4 # and variables for "make update".
6 # There is no documentation on what "update" actually does. This is merely
7 # an attempt to separate the magic into a separate module that can be
11 NOCLEAN?
= NO
# don't clean up after update
12 REINSTALL?
= NO
# reinstall upon update
14 # UPDATE_TARGET is the target that is invoked when updating packages during
15 # a "make update". This variable is user-settable within /etc/mk.conf.
17 .if
!defined
(UPDATE_TARGET
)
18 . if defined
(DEPENDS_TARGET
) && (${DEPENDS_TARGET} == "update")
19 . if
${_USE_DESTDIR} != "no" || make
(package
) || make
(package-install
)
20 UPDATE_TARGET
= package-install
22 UPDATE_TARGET
= install
25 UPDATE_TARGET
= ${DEPENDS_TARGET}
29 # The 'update' target can be used to update a package and all
30 # currently installed packages that depend upon this package.
32 _DDIR
= ${WRKDIR}/.DDIR
33 _DLIST
= ${WRKDIR}/.DLIST
35 .PHONY
: update-create-ddir
36 update-create-ddir
: ${_DDIR}
45 @
${PHASE_MSG} "Resuming update for ${PKGNAME}"
46 . if
${REINSTALL} != "NO" && ${UPDATE_TARGET} != "replace"
47 ${RUN} ${RECURSIVE_MAKE} ${MAKEFLAGS} deinstall _UPDATE_RUNNING
=YES DEINSTALLDEPENDS
=ALL
54 ${RUN} ${RECURSIVE_MAKE} ${MAKEFLAGS} check-vulnerable
55 ${RUN} ${RECURSIVE_MAKE} ${MAKEFLAGS} update-create-ddir
56 . if
${UPDATE_TARGET} != "replace"
57 ${RUN} if
${PKG_INFO} -qe
${PKGBASE}; then \
58 ${RECURSIVE_MAKE} ${MAKEFLAGS} deinstall _UPDATE_RUNNING
=YES DEINSTALLDEPENDS
=ALL \
59 ||
(${RM} ${_DDIR} && ${FALSE}); \
63 ${RUN} ${RECURSIVE_MAKE} ${MAKEFLAGS} ${UPDATE_TARGET} KEEP_WRKDIR
=YES DEPENDS_TARGET
=${DEPENDS_TARGET
:Q
}
65 [ ! -s
${_DDIR} ] || for dep in
`${CAT} ${_DDIR}` ; do \
66 (if cd ..
/..
&& cd
"$${dep}" ; then \
67 ${PHASE_MSG} "Installing in $${dep}" && \
68 if
[ "(" "${RESUMEUPDATE}" = "NO" -o \
69 "${REINSTALL}" != "NO" ")" -a \
70 "${UPDATE_TARGET}" != "replace" ] ; then \
71 ${RECURSIVE_MAKE} ${MAKEFLAGS} deinstall _UPDATE_RUNNING
=YES
; \
73 ${RECURSIVE_MAKE} ${MAKEFLAGS} ${UPDATE_TARGET} \
74 _PKGSRC_UPDATE_CHECK
=yes \
75 DEPENDS_TARGET
=${DEPENDS_TARGET
:Q
} ; \
77 ${PHASE_MSG} "Skipping removed directory $${dep}"; \
80 .if
${NOCLEAN} == "NO"
81 ${RUN} ${RECURSIVE_MAKE} ${MAKEFLAGS} clean-update CLEAR_DIRLIST
=YES
87 ${RUN} ${RECURSIVE_MAKE} ${MAKEFLAGS} update-create-ddir
89 if
[ -s
${_DDIR} ] ; then \
90 for dep in
`${CAT} ${_DDIR}` ; do \
91 (if cd ..
/..
&& cd
"$${dep}" ; then \
92 ${RECURSIVE_MAKE} ${MAKEFLAGS} clean ; \
94 ${PHASE_MSG} "Skipping removed directory $${dep}";\
98 .if
${CLEAR_DIRLIST} != "NO"
99 ${RUN} ${RECURSIVE_MAKE} ${MAKEFLAGS} clean
101 ${RUN} ${RECURSIVE_MAKE} ${MAKEFLAGS} clean update-dirlist DIRLIST
="`${CAT} ${_DDIR}`" PKGLIST
="`${CAT} ${_DLIST}`"
102 @
${WARNING_MSG} "preserved leftover directory list. Your next"
103 @
${WARNING_MSG} "\`\`${MAKE} update'' may fail. It is advised to use"
104 @
${WARNING_MSG} "\`\`${MAKE} update REINSTALL=YES'' instead!"
107 .
endif # !target(update)
110 .PHONY
: update-dirlist
112 ${RUN} ${MKDIR} ${WRKDIR}
114 . for __tmp__ in
${PKGLIST}
115 ${RUN} ${ECHO} >>${_DLIST} "${__tmp__}"
119 . for __tmp__ in
${DIRLIST}
120 ${RUN} ${ECHO} >>${_DDIR} "${__tmp__}"
126 ${RUN} pkgs
=`${CAT} ${_DLIST}`; \
127 if
[ "$$pkgs" ]; then
${PKG_INFO} -Q PKGPATH
$$pkgs; fi
> ${_DDIR}
130 if
${PKG_INFO} -qe
"${PKGWILDCARD}"; then \
131 ${PKG_INFO} -qr
"${PKGWILDCARD}" > ${_DLIST}; \
133 ${TOUCH} ${_DLIST}; \