Skip to content
Newer
Older
100644 146 lines (130 sloc) 4.37 KB
42bdc0c Move definitions for UPDATE_TARGET and DEPENDS_TARGET closer to where
jlam authored
1 # $NetBSD: bsd.pkg.update.mk,v 1.3 2006/06/05 17:21:54 jlam Exp $
5ca7ed6 First pass at implementing support for package system flavors other
jlam authored
2 #
3 # This Makefile fragment is included by bsd.pkg.mk and contains the targets
4 # and variables for "make update".
5 #
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.
9 #
10
792b2ee Move some "update"-only variables from bsd.pkg.mk to bsd.pkg.update.mk.
jlam authored
11 NOCLEAN?= NO # don't clean up after update
12 REINSTALL?= NO # reinstall upon update
13
42bdc0c Move definitions for UPDATE_TARGET and DEPENDS_TARGET closer to where
jlam authored
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.
16 #
17 .if !defined(UPDATE_TARGET)
18 . if defined(DEPENDS_TARGET) && (${DEPENDS_TARGET} == "update")
19 . if make(package)
20 UPDATE_TARGET= package
21 . else
22 UPDATE_TARGET= install
23 . endif
24 . else
25 UPDATE_TARGET= ${DEPENDS_TARGET}
26 . endif
27 .endif
28
5ca7ed6 First pass at implementing support for package system flavors other
jlam authored
29 # The 'update' target can be used to update a package and all
30 # currently installed packages that depend upon this package.
31
32 _DDIR= ${WRKDIR}/.DDIR
33 _DLIST= ${WRKDIR}/.DLIST
34
35 .PHONY: update
36 .if !target(update)
37 .if exists(${_DDIR})
38 RESUMEUPDATE?= YES
39 CLEAR_DIRLIST?= NO
40
41 update:
42 ${_PKG_SILENT}${_PKG_DEBUG}${ECHO_MSG} \
43 "${_PKGSRC_IN}> Resuming update for ${PKGNAME}"
44 . if ${REINSTALL} != "NO" && ${UPDATE_TARGET} != "replace"
45 ${_PKG_SILENT}${_PKG_DEBUG} \
42bdc0c Move definitions for UPDATE_TARGET and DEPENDS_TARGET closer to where
jlam authored
46 ${MAKE} ${MAKEFLAGS} deinstall _UPDATE_RUNNING=YES DEINSTALLDEPENDS=ALL
5ca7ed6 First pass at implementing support for package system flavors other
jlam authored
47 . endif
48 .else
49 RESUMEUPDATE?= NO
50 CLEAR_DIRLIST?= YES
51
52 update:
53 ${_PKG_SILENT}${_PKG_DEBUG}${MAKE} ${MAKEFLAGS} ${_DDIR}
54 . if ${UPDATE_TARGET} != "replace"
55 ${_PKG_SILENT}${_PKG_DEBUG}if ${PKG_INFO} -qe ${PKGBASE}; then \
42bdc0c Move definitions for UPDATE_TARGET and DEPENDS_TARGET closer to where
jlam authored
56 ${MAKE} ${MAKEFLAGS} deinstall _UPDATE_RUNNING=YES DEINSTALLDEPENDS=ALL \
5ca7ed6 First pass at implementing support for package system flavors other
jlam authored
57 || (${RM} ${_DDIR} && ${FALSE}); \
58 fi
59 . endif
60 .endif
61 ${_PKG_SILENT}${_PKG_DEBUG} \
62 ${MAKE} ${MAKEFLAGS} ${UPDATE_TARGET} KEEP_WRKDIR=YES \
63 DEPENDS_TARGET=${DEPENDS_TARGET:Q}
64 ${_PKG_SILENT}${_PKG_DEBUG} \
65 [ ! -s ${_DDIR} ] || for dep in `${CAT} ${_DDIR}` ; do \
66 (if cd ../.. && cd "$${dep}" ; then \
67 ${ECHO_MSG} "${_PKGSRC_IN}> Installing in $${dep}" && \
68 if [ "(" "${RESUMEUPDATE}" = "NO" -o \
69 "${REINSTALL}" != "NO" ")" -a \
70 "${UPDATE_TARGET}" != "replace" ] ; then \
42bdc0c Move definitions for UPDATE_TARGET and DEPENDS_TARGET closer to where
jlam authored
71 ${MAKE} ${MAKEFLAGS} deinstall _UPDATE_RUNNING=YES; \
5ca7ed6 First pass at implementing support for package system flavors other
jlam authored
72 fi && \
73 ${MAKE} ${MAKEFLAGS} ${UPDATE_TARGET} \
74 DEPENDS_TARGET=${DEPENDS_TARGET:Q} ; \
75 else \
76 ${ECHO_MSG} "${_PKGSRC_IN}> Skipping removed directory $${dep}"; \
77 fi) ; \
78 done
79 .if ${NOCLEAN} == "NO"
80 ${_PKG_SILENT}${_PKG_DEBUG} \
81 ${MAKE} ${MAKEFLAGS} clean-update CLEAR_DIRLIST=YES
82 .endif
83
84
85 .PHONY: clean-update
86 clean-update:
87 ${_PKG_SILENT}${_PKG_DEBUG}${MAKE} ${MAKEFLAGS} ${_DDIR}
88 ${_PKG_SILENT}${_PKG_DEBUG} \
89 if [ -s ${_DDIR} ] ; then \
90 for dep in `${CAT} ${_DDIR}` ; do \
91 (if cd ../.. && cd "$${dep}" ; then \
92 ${MAKE} ${MAKEFLAGS} clean ; \
93 else \
94 ${ECHO_MSG} "${_PKGSRC_IN}> Skipping removed directory $${dep}";\
95 fi) ; \
96 done ; \
97 fi
98 .if ${CLEAR_DIRLIST} != "NO"
99 ${_PKG_SILENT}${_PKG_DEBUG}${MAKE} ${MAKEFLAGS} clean
100 .else
101 ${_PKG_SILENT}${_PKG_DEBUG} \
102 ${MAKE} ${MAKEFLAGS} clean update-dirlist \
103 DIRLIST="`${CAT} ${_DDIR}`" PKGLIST="`${CAT} ${_DLIST}`"
104 ${_PKG_SILENT}${_PKG_DEBUG}${ECHO_MSG} \
105 "${_PKGSRC_IN}> Warning: preserved leftover directory list. Your next";\
106 ${ECHO_MSG} "${_PKGSRC_IN}> \`\`${MAKE} update'' may fail. It is advised to use";\
107 ${ECHO_MSG} "${_PKGSRC_IN}> \`\`${MAKE} update REINSTALL=YES'' instead!"
108 .endif
109
110 .endif # !target(update)
111
112
113 .PHONY: update-dirlist
114 update-dirlist:
115 ${_PKG_SILENT}${_PKG_DEBUG}${MKDIR} -p ${WRKDIR}
116 .if defined(PKGLIST)
117 . for __tmp__ in ${PKGLIST}
118 ${_PKG_SILENT}${_PKG_DEBUG}${ECHO} >>${_DLIST} "${__tmp__}"
119 . endfor
120 .endif
121 .if defined(DIRLIST)
122 . for __tmp__ in ${DIRLIST}
123 ${_PKG_SILENT}${_PKG_DEBUG}${ECHO} >>${_DDIR} "${__tmp__}"
124 . endfor
125 .endif
126
127
128 ${_DDIR}: ${_DLIST}
129 ${_PKG_SILENT}${_PKG_DEBUG} \
130 ddir=`${SED} 's:-[^-]*$$::' ${_DLIST}`; \
131 ${ECHO} >${_DDIR}; \
132 for pkg in $${ddir} ; do \
133 if ${PKG_INFO} -b "$${pkg}" >/dev/null 2>&1 ; then \
134 ${PKG_INFO} -b "$${pkg}" | ${SED} -ne \
135 's,\([^/]*/[^/]*\)/Makefile:.*,\1,p' | \
136 ${HEAD} -1 >>${_DDIR}; \
137 fi ; \
138 done
139
140 ${_DLIST}: ${WRKDIR}
141 ${_PKG_SILENT}${_PKG_DEBUG} \
142 { ${PKG_DELETE} -n "${PKGWILDCARD}" 2>&1 | \
143 ${GREP} '^ ' | \
144 ${AWK} '{ l[NR]=$$0 } END { for (i=NR;i>0;--i) print l[i] }' \
145 || ${TRUE}; } > ${_DLIST}
Something went wrong with that request. Please try again.