Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 144 lines (128 sloc) 4.31 kb
53183b6 Use PHASE_MSG, STEP_MSG, WARNING_MSG, and ERROR_MSG in place of ECHO_MSG
jlam authored
1 # $NetBSD: bsd.pkg.update.mk,v 1.4 2006/06/05 22:49:44 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:
53183b6 Use PHASE_MSG, STEP_MSG, WARNING_MSG, and ERROR_MSG in place of ECHO_MSG
jlam authored
42 @${PHASE_MSG} "Resuming update for ${PKGNAME}"
5ca7ed6 First pass at implementing support for package system flavors other
jlam authored
43 . if ${REINSTALL} != "NO" && ${UPDATE_TARGET} != "replace"
44 ${_PKG_SILENT}${_PKG_DEBUG} \
42bdc0c Move definitions for UPDATE_TARGET and DEPENDS_TARGET closer to where
jlam authored
45 ${MAKE} ${MAKEFLAGS} deinstall _UPDATE_RUNNING=YES DEINSTALLDEPENDS=ALL
5ca7ed6 First pass at implementing support for package system flavors other
jlam authored
46 . endif
47 .else
48 RESUMEUPDATE?= NO
49 CLEAR_DIRLIST?= YES
50
51 update:
52 ${_PKG_SILENT}${_PKG_DEBUG}${MAKE} ${MAKEFLAGS} ${_DDIR}
53 . if ${UPDATE_TARGET} != "replace"
54 ${_PKG_SILENT}${_PKG_DEBUG}if ${PKG_INFO} -qe ${PKGBASE}; then \
42bdc0c Move definitions for UPDATE_TARGET and DEPENDS_TARGET closer to where
jlam authored
55 ${MAKE} ${MAKEFLAGS} deinstall _UPDATE_RUNNING=YES DEINSTALLDEPENDS=ALL \
5ca7ed6 First pass at implementing support for package system flavors other
jlam authored
56 || (${RM} ${_DDIR} && ${FALSE}); \
57 fi
58 . endif
59 .endif
60 ${_PKG_SILENT}${_PKG_DEBUG} \
61 ${MAKE} ${MAKEFLAGS} ${UPDATE_TARGET} KEEP_WRKDIR=YES \
62 DEPENDS_TARGET=${DEPENDS_TARGET:Q}
63 ${_PKG_SILENT}${_PKG_DEBUG} \
64 [ ! -s ${_DDIR} ] || for dep in `${CAT} ${_DDIR}` ; do \
65 (if cd ../.. && cd "$${dep}" ; then \
53183b6 Use PHASE_MSG, STEP_MSG, WARNING_MSG, and ERROR_MSG in place of ECHO_MSG
jlam authored
66 ${PHASE_MSG} "Installing in $${dep}" && \
5ca7ed6 First pass at implementing support for package system flavors other
jlam authored
67 if [ "(" "${RESUMEUPDATE}" = "NO" -o \
68 "${REINSTALL}" != "NO" ")" -a \
69 "${UPDATE_TARGET}" != "replace" ] ; then \
42bdc0c Move definitions for UPDATE_TARGET and DEPENDS_TARGET closer to where
jlam authored
70 ${MAKE} ${MAKEFLAGS} deinstall _UPDATE_RUNNING=YES; \
5ca7ed6 First pass at implementing support for package system flavors other
jlam authored
71 fi && \
72 ${MAKE} ${MAKEFLAGS} ${UPDATE_TARGET} \
73 DEPENDS_TARGET=${DEPENDS_TARGET:Q} ; \
74 else \
53183b6 Use PHASE_MSG, STEP_MSG, WARNING_MSG, and ERROR_MSG in place of ECHO_MSG
jlam authored
75 ${PHASE_MSG} "Skipping removed directory $${dep}"; \
5ca7ed6 First pass at implementing support for package system flavors other
jlam authored
76 fi) ; \
77 done
78 .if ${NOCLEAN} == "NO"
79 ${_PKG_SILENT}${_PKG_DEBUG} \
80 ${MAKE} ${MAKEFLAGS} clean-update CLEAR_DIRLIST=YES
81 .endif
82
83
84 .PHONY: clean-update
85 clean-update:
86 ${_PKG_SILENT}${_PKG_DEBUG}${MAKE} ${MAKEFLAGS} ${_DDIR}
87 ${_PKG_SILENT}${_PKG_DEBUG} \
88 if [ -s ${_DDIR} ] ; then \
89 for dep in `${CAT} ${_DDIR}` ; do \
90 (if cd ../.. && cd "$${dep}" ; then \
91 ${MAKE} ${MAKEFLAGS} clean ; \
92 else \
53183b6 Use PHASE_MSG, STEP_MSG, WARNING_MSG, and ERROR_MSG in place of ECHO_MSG
jlam authored
93 ${PHASE_MSG} "Skipping removed directory $${dep}";\
5ca7ed6 First pass at implementing support for package system flavors other
jlam authored
94 fi) ; \
95 done ; \
96 fi
97 .if ${CLEAR_DIRLIST} != "NO"
98 ${_PKG_SILENT}${_PKG_DEBUG}${MAKE} ${MAKEFLAGS} clean
99 .else
100 ${_PKG_SILENT}${_PKG_DEBUG} \
101 ${MAKE} ${MAKEFLAGS} clean update-dirlist \
102 DIRLIST="`${CAT} ${_DDIR}`" PKGLIST="`${CAT} ${_DLIST}`"
53183b6 Use PHASE_MSG, STEP_MSG, WARNING_MSG, and ERROR_MSG in place of ECHO_MSG
jlam authored
103 @${WARNING_MSG} "Warning: preserved leftover directory list. Your next"
104 @${WARNING_MSG} " \`\`${MAKE} update'' may fail. It is advised to use"
105 @${WARNING_MSG} " \`\`${MAKE} update REINSTALL=YES'' instead!"
5ca7ed6 First pass at implementing support for package system flavors other
jlam authored
106 .endif
107
108 .endif # !target(update)
109
110
111 .PHONY: update-dirlist
112 update-dirlist:
113 ${_PKG_SILENT}${_PKG_DEBUG}${MKDIR} -p ${WRKDIR}
114 .if defined(PKGLIST)
115 . for __tmp__ in ${PKGLIST}
116 ${_PKG_SILENT}${_PKG_DEBUG}${ECHO} >>${_DLIST} "${__tmp__}"
117 . endfor
118 .endif
119 .if defined(DIRLIST)
120 . for __tmp__ in ${DIRLIST}
121 ${_PKG_SILENT}${_PKG_DEBUG}${ECHO} >>${_DDIR} "${__tmp__}"
122 . endfor
123 .endif
124
125
126 ${_DDIR}: ${_DLIST}
127 ${_PKG_SILENT}${_PKG_DEBUG} \
128 ddir=`${SED} 's:-[^-]*$$::' ${_DLIST}`; \
129 ${ECHO} >${_DDIR}; \
130 for pkg in $${ddir} ; do \
131 if ${PKG_INFO} -b "$${pkg}" >/dev/null 2>&1 ; then \
132 ${PKG_INFO} -b "$${pkg}" | ${SED} -ne \
133 's,\([^/]*/[^/]*\)/Makefile:.*,\1,p' | \
134 ${HEAD} -1 >>${_DDIR}; \
135 fi ; \
136 done
137
138 ${_DLIST}: ${WRKDIR}
139 ${_PKG_SILENT}${_PKG_DEBUG} \
140 { ${PKG_DELETE} -n "${PKGWILDCARD}" 2>&1 | \
141 ${GREP} '^ ' | \
142 ${AWK} '{ l[NR]=$$0 } END { for (i=NR;i>0;--i) print l[i] }' \
143 || ${TRUE}; } > ${_DLIST}
Something went wrong with that request. Please try again.