Fixup fromcvs/togit conversion
[minix-pkgsrc.git] / mk / bsd.pkg.update.mk
blob7162f7d28dee0a9e7c783640e088c5851aa73678
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
8 # reimplemented later.
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
21 . else
22 UPDATE_TARGET= install
23 . endif
24 . else
25 UPDATE_TARGET= ${DEPENDS_TARGET}
26 . endif
27 .endif
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}
38 .PHONY: update
39 .if !target(update)
40 .if exists(${_DDIR})
41 RESUMEUPDATE?= YES
42 CLEAR_DIRLIST?= NO
44 update:
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
48 . endif
49 .else
50 RESUMEUPDATE?= NO
51 CLEAR_DIRLIST?= YES
53 update:
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}); \
61 . endif
62 .endif
63 ${RUN} ${RECURSIVE_MAKE} ${MAKEFLAGS} ${UPDATE_TARGET} KEEP_WRKDIR=YES DEPENDS_TARGET=${DEPENDS_TARGET:Q}
64 ${RUN} \
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; \
72 fi && \
73 ${RECURSIVE_MAKE} ${MAKEFLAGS} ${UPDATE_TARGET} \
74 _PKGSRC_UPDATE_CHECK=yes \
75 DEPENDS_TARGET=${DEPENDS_TARGET:Q} ; \
76 else \
77 ${PHASE_MSG} "Skipping removed directory $${dep}"; \
78 fi) ; \
79 done
80 .if ${NOCLEAN} == "NO"
81 ${RUN} ${RECURSIVE_MAKE} ${MAKEFLAGS} clean-update CLEAR_DIRLIST=YES
82 .endif
85 .PHONY: clean-update
86 clean-update:
87 ${RUN} ${RECURSIVE_MAKE} ${MAKEFLAGS} update-create-ddir
88 ${RUN} \
89 if [ -s ${_DDIR} ] ; then \
90 for dep in `${CAT} ${_DDIR}` ; do \
91 (if cd ../.. && cd "$${dep}" ; then \
92 ${RECURSIVE_MAKE} ${MAKEFLAGS} clean ; \
93 else \
94 ${PHASE_MSG} "Skipping removed directory $${dep}";\
95 fi) ; \
96 done ; \
98 .if ${CLEAR_DIRLIST} != "NO"
99 ${RUN} ${RECURSIVE_MAKE} ${MAKEFLAGS} clean
100 .else
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!"
105 .endif
107 .endif # !target(update)
110 .PHONY: update-dirlist
111 update-dirlist:
112 ${RUN} ${MKDIR} ${WRKDIR}
113 .if defined(PKGLIST)
114 . for __tmp__ in ${PKGLIST}
115 ${RUN} ${ECHO} >>${_DLIST} "${__tmp__}"
116 . endfor
117 .endif
118 .if defined(DIRLIST)
119 . for __tmp__ in ${DIRLIST}
120 ${RUN} ${ECHO} >>${_DDIR} "${__tmp__}"
121 . endfor
122 .endif
125 ${_DDIR}: ${_DLIST}
126 ${RUN} pkgs=`${CAT} ${_DLIST}`; \
127 if [ "$$pkgs" ]; then ${PKG_INFO} -Q PKGPATH $$pkgs; fi > ${_DDIR}
129 ${_DLIST}: ${WRKDIR}
130 if ${PKG_INFO} -qe "${PKGWILDCARD}"; then \
131 ${PKG_INFO} -qr "${PKGWILDCARD}" > ${_DLIST}; \
132 else \
133 ${TOUCH} ${_DLIST}; \