Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 144 lines (127 sloc) 4.214 kB
4d383ea Use pkg_info -r if present and fall back to pkg_delete for pkg_install
joerg authored
1 # $NetBSD: bsd.pkg.update.mk,v 1.16 2009/03/05 23:07:15 joerg 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")
0d9f172 Prefer package-destdir as default for update with USE_DESTDIR.
joerg authored
19 . if ${_USE_DESTDIR} != "no"
20 UPDATE_TARGET= package-install
21 . elif make(package)
42bdc0c Move definitions for UPDATE_TARGET and DEPENDS_TARGET closer to where
jlam authored
22 UPDATE_TARGET= package
23 . else
24 UPDATE_TARGET= install
25 . endif
26 . else
27 UPDATE_TARGET= ${DEPENDS_TARGET}
28 . endif
29 .endif
30
5ca7ed6 First pass at implementing support for package system flavors other
jlam authored
31 # The 'update' target can be used to update a package and all
32 # currently installed packages that depend upon this package.
33
34 _DDIR= ${WRKDIR}/.DDIR
35 _DLIST= ${WRKDIR}/.DLIST
36
00901b8 Suppress the message that ".DDIR is up-to-date" by introducing a .PHONY
rillig authored
37 .PHONY: update-create-ddir
38 update-create-ddir: ${_DDIR}
39
5ca7ed6 First pass at implementing support for package system flavors other
jlam authored
40 .PHONY: update
41 .if !target(update)
42 .if exists(${_DDIR})
43 RESUMEUPDATE?= YES
44 CLEAR_DIRLIST?= NO
45
46 update:
53183b6 Use PHASE_MSG, STEP_MSG, WARNING_MSG, and ERROR_MSG in place of ECHO_MSG
jlam authored
47 @${PHASE_MSG} "Resuming update for ${PKGNAME}"
5ca7ed6 First pass at implementing support for package system flavors other
jlam authored
48 . if ${REINSTALL} != "NO" && ${UPDATE_TARGET} != "replace"
a887ebc Replaced ${_PKG_SILENT}${_PKG_DEBUG} with ${RUN}, since it is shorter.
rillig authored
49 ${RUN} ${RECURSIVE_MAKE} ${MAKEFLAGS} deinstall _UPDATE_RUNNING=YES DEINSTALLDEPENDS=ALL
5ca7ed6 First pass at implementing support for package system flavors other
jlam authored
50 . endif
51 .else
52 RESUMEUPDATE?= NO
53 CLEAR_DIRLIST?= YES
54
55 update:
a887ebc Replaced ${_PKG_SILENT}${_PKG_DEBUG} with ${RUN}, since it is shorter.
rillig authored
56 ${RUN} ${RECURSIVE_MAKE} ${MAKEFLAGS} update-create-ddir
5ca7ed6 First pass at implementing support for package system flavors other
jlam authored
57 . if ${UPDATE_TARGET} != "replace"
a887ebc Replaced ${_PKG_SILENT}${_PKG_DEBUG} with ${RUN}, since it is shorter.
rillig authored
58 ${RUN} if ${PKG_INFO} -qe ${PKGBASE}; then \
7ae0a03 Whenever we invoke a recursive make, we need to ensure that the proper
jlam authored
59 ${RECURSIVE_MAKE} ${MAKEFLAGS} deinstall _UPDATE_RUNNING=YES DEINSTALLDEPENDS=ALL \
5ca7ed6 First pass at implementing support for package system flavors other
jlam authored
60 || (${RM} ${_DDIR} && ${FALSE}); \
61 fi
62 . endif
63 .endif
a887ebc Replaced ${_PKG_SILENT}${_PKG_DEBUG} with ${RUN}, since it is shorter.
rillig authored
64 ${RUN} ${RECURSIVE_MAKE} ${MAKEFLAGS} ${UPDATE_TARGET} KEEP_WRKDIR=YES DEPENDS_TARGET=${DEPENDS_TARGET:Q}
e4d337a Replaced _PKG_SILENT and _PKG_DEBUG with RUN.
rillig authored
65 ${RUN} \
5ca7ed6 First pass at implementing support for package system flavors other
jlam authored
66 [ ! -s ${_DDIR} ] || for dep in `${CAT} ${_DDIR}` ; do \
67 (if cd ../.. && cd "$${dep}" ; then \
53183b6 Use PHASE_MSG, STEP_MSG, WARNING_MSG, and ERROR_MSG in place of ECHO_MSG
jlam authored
68 ${PHASE_MSG} "Installing in $${dep}" && \
5ca7ed6 First pass at implementing support for package system flavors other
jlam authored
69 if [ "(" "${RESUMEUPDATE}" = "NO" -o \
70 "${REINSTALL}" != "NO" ")" -a \
71 "${UPDATE_TARGET}" != "replace" ] ; then \
7ae0a03 Whenever we invoke a recursive make, we need to ensure that the proper
jlam authored
72 ${RECURSIVE_MAKE} ${MAKEFLAGS} deinstall _UPDATE_RUNNING=YES; \
5ca7ed6 First pass at implementing support for package system flavors other
jlam authored
73 fi && \
7ae0a03 Whenever we invoke a recursive make, we need to ensure that the proper
jlam authored
74 ${RECURSIVE_MAKE} ${MAKEFLAGS} ${UPDATE_TARGET} \
5ca7ed6 First pass at implementing support for package system flavors other
jlam authored
75 DEPENDS_TARGET=${DEPENDS_TARGET:Q} ; \
76 else \
53183b6 Use PHASE_MSG, STEP_MSG, WARNING_MSG, and ERROR_MSG in place of ECHO_MSG
jlam authored
77 ${PHASE_MSG} "Skipping removed directory $${dep}"; \
5ca7ed6 First pass at implementing support for package system flavors other
jlam authored
78 fi) ; \
79 done
80 .if ${NOCLEAN} == "NO"
a887ebc Replaced ${_PKG_SILENT}${_PKG_DEBUG} with ${RUN}, since it is shorter.
rillig authored
81 ${RUN} ${RECURSIVE_MAKE} ${MAKEFLAGS} clean-update CLEAR_DIRLIST=YES
5ca7ed6 First pass at implementing support for package system flavors other
jlam authored
82 .endif
83
84
85 .PHONY: clean-update
86 clean-update:
a887ebc Replaced ${_PKG_SILENT}${_PKG_DEBUG} with ${RUN}, since it is shorter.
rillig authored
87 ${RUN} ${RECURSIVE_MAKE} ${MAKEFLAGS} update-create-ddir
e4d337a Replaced _PKG_SILENT and _PKG_DEBUG with RUN.
rillig authored
88 ${RUN} \
5ca7ed6 First pass at implementing support for package system flavors other
jlam authored
89 if [ -s ${_DDIR} ] ; then \
90 for dep in `${CAT} ${_DDIR}` ; do \
91 (if cd ../.. && cd "$${dep}" ; then \
7ae0a03 Whenever we invoke a recursive make, we need to ensure that the proper
jlam authored
92 ${RECURSIVE_MAKE} ${MAKEFLAGS} clean ; \
5ca7ed6 First pass at implementing support for package system flavors other
jlam authored
93 else \
53183b6 Use PHASE_MSG, STEP_MSG, WARNING_MSG, and ERROR_MSG in place of ECHO_MSG
jlam authored
94 ${PHASE_MSG} "Skipping removed directory $${dep}";\
5ca7ed6 First pass at implementing support for package system flavors other
jlam authored
95 fi) ; \
96 done ; \
97 fi
98 .if ${CLEAR_DIRLIST} != "NO"
a887ebc Replaced ${_PKG_SILENT}${_PKG_DEBUG} with ${RUN}, since it is shorter.
rillig authored
99 ${RUN} ${RECURSIVE_MAKE} ${MAKEFLAGS} clean
5ca7ed6 First pass at implementing support for package system flavors other
jlam authored
100 .else
a887ebc Replaced ${_PKG_SILENT}${_PKG_DEBUG} with ${RUN}, since it is shorter.
rillig authored
101 ${RUN} ${RECURSIVE_MAKE} ${MAKEFLAGS} clean update-dirlist DIRLIST="`${CAT} ${_DDIR}`" PKGLIST="`${CAT} ${_DLIST}`"
7e8ae1a 1.) Remove all instances of '@${WARNING_MSG} "Warning: ...' which res…
tron authored
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!"
5ca7ed6 First pass at implementing support for package system flavors other
jlam authored
105 .endif
106
107 .endif # !target(update)
108
109
110 .PHONY: update-dirlist
111 update-dirlist:
a887ebc Replaced ${_PKG_SILENT}${_PKG_DEBUG} with ${RUN}, since it is shorter.
rillig authored
112 ${RUN} ${MKDIR} -p ${WRKDIR}
5ca7ed6 First pass at implementing support for package system flavors other
jlam authored
113 .if defined(PKGLIST)
114 . for __tmp__ in ${PKGLIST}
a887ebc Replaced ${_PKG_SILENT}${_PKG_DEBUG} with ${RUN}, since it is shorter.
rillig authored
115 ${RUN} ${ECHO} >>${_DLIST} "${__tmp__}"
5ca7ed6 First pass at implementing support for package system flavors other
jlam authored
116 . endfor
117 .endif
118 .if defined(DIRLIST)
119 . for __tmp__ in ${DIRLIST}
a887ebc Replaced ${_PKG_SILENT}${_PKG_DEBUG} with ${RUN}, since it is shorter.
rillig authored
120 ${RUN} ${ECHO} >>${_DDIR} "${__tmp__}"
5ca7ed6 First pass at implementing support for package system flavors other
jlam authored
121 . endfor
122 .endif
123
124
125 ${_DDIR}: ${_DLIST}
c28f839 Correct typo, really fixes PR 36940.
obache authored
126 ${RUN} pkgs=`${CAT} ${_DLIST}`; \
3492e1f pkg_info needs at least one package name. Fixes PR 36940.
rillig authored
127 if [ "$$pkgs" ]; then ${PKG_INFO} -Q PKGPATH $$pkgs; fi > ${_DDIR}
5ca7ed6 First pass at implementing support for package system flavors other
jlam authored
128
4d383ea Use pkg_info -r if present and fall back to pkg_delete for pkg_install
joerg authored
129 .if ${PKGTOOLS_VERSION} >= 20090302
130 ${_DLIST}: ${WRKDIR}
131 ${PKG_INFO} -qr "${PKGWILDCARD}" > ${_DLIST}
132 .elif ${PKGTOOLS_VERSION} >= 20090225
133 ${_DLIST}: ${WRKDIR}
134 ${RUN}echo "Please update to pkg_install-20090302 or later" 2>&1
135 ${RUN}exit 1
136 .else
5ca7ed6 First pass at implementing support for package system flavors other
jlam authored
137 ${_DLIST}: ${WRKDIR}
a887ebc Replaced ${_PKG_SILENT}${_PKG_DEBUG} with ${RUN}, since it is shorter.
rillig authored
138 ${RUN} \
139 ${PKG_DELETE} -n "${PKGWILDCARD}" 2>&1 \
140 | ${GREP} '^ ' \
141 | ${AWK} '{ l[NR]=$$0 } END { for (i=NR;i>0;--i) print l[i] }' \
142 > ${_DLIST}
4d383ea Use pkg_info -r if present and fall back to pkg_delete for pkg_install
joerg authored
143 .endif
Something went wrong with that request. Please try again.