blob: a552478fcb7db1579b3171fe30e47044ff807da5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
|
# $NetBSD: replace.mk,v 1.3 2006/07/05 19:13:46 jlam Exp $
######################################################################
### replace-pkg (PRIVATE, pkgsrc/mk/install/replace.mk)
######################################################################
### replace-pkg updates a package in-place on the system.
###
_REPLACE_PKG_TARGETS+= replace-tarup
_REPLACE_PKG_TARGETS+= replace-names
_REPLACE_PKG_TARGETS+= replace-preserve-required-by
_REPLACE_PKG_TARGETS+= deinstall
_REPLACE_PKG_TARGETS+= install-clean
_REPLACE_PKG_TARGETS+= install
_REPLACE_PKG_TARGETS+= replace-fixup-required-by
replace-pkg: ${_REPLACE_PKG_TARGETS}
######################################################################
### undo-replace-pkg (PRIVATE, pkgsrc/mk/install/replace.mk)
######################################################################
### undo-replace-pkg undoes a "make replace".
###
_UNDO_REPLACE_PKG_TARGETS+= undo-replace-check
_UNDO_REPLACE_PKG_TARGETS+= undo-replace-names
_UNDO_REPLACE_PKG_TARGETS+= replace-preserve-required-by
_UNDO_REPLACE_PKG_TARGETS+= deinstall
_UNDO_REPLACE_PKG_TARGETS+= undo-replace-install
_UNDO_REPLACE_PKG_TARGETS+= replace-fixup-required-by
_UNDO_REPLACE_PKG_TARGETS+= replace-clean
undo-replace-pkg: ${_UNDO_REPLACE_PKG_TARGETS}
_REQUIRED_BY_FILE= ${PKG_DB_TMPDIR}/+REQUIRED_BY
_REPLACE_COOKIE= ${WRKDIR}/.replace_done
_REPLACE_OLDNAME_FILE= ${WRKDIR}/.replace_oldname
_REPLACE_NEWNAME_FILE= ${WRKDIR}/.replace_newname
######################################################################
### undo-replace-check (PRIVATE)
######################################################################
### undo-replace-check verifies that there was a previous "replace"
### action performed that can be undone.
###
.PHONY: undo-replace-check
undo-replace-check:
${_PKG_SILENT}${_PKG_DEBUG} \
${TEST} ! -f ${_REPLACE_COOKIE} || exit 0; \
${ERROR_MSG} "No replacment to undo!"; \
exit 1
######################################################################
### replace-tarup (PRIVATE)
######################################################################
### replace-tarup generates a binary package for the (older) installed
### package using pkg_tarup.
###
.PHONY: replace-tarup
replace-tarup:
${_PKG_SILENT}${_PKG_DEBUG} \
if ${TEST} ! -x ${_PKG_TARUP_CMD:Q}; then \
${ERROR_MSG} ${_PKG_TARUP_CMD:Q}" was not found."; \
exit 1; \
fi; \
${SETENV} PKG_DBDIR=${_PKG_DBDIR} PKG_SUFX=${PKG_SUFX} \
PKGREPOSITORY=${WRKDIR} \
${_PKG_TARUP_CMD} ${PKGBASE}
######################################################################
### undo-replace-install (PRIVATE)
######################################################################
### undo-replace-install re-installs the old package from the binary
### package saved from replace-tarup.
###
.PHONY: undo-replace-install
undo-replace-install:
@${PHASE_MSG} "Re-adding ${PKGNAME} from saved tar-up package."
${_PKG_SILENT}${_PKG_DEBUG} \
${TEST} -f ${_REPLACE_NEWNAME_FILE} || exit 0; \
newname=`${CAT} ${_REPLACE_NEWNAME_FILE}`; \
${ECHO} "Running ${PKG_ADD} ${WRKDIR}/$$newname${PKG_SUFX}"; \
${PKG_ADD} ${WRKDIR}/$$newname${PKG_SUFX}
######################################################################
### replace-names, undo-replace-names (PRIVATE)
######################################################################
### replace-names and undo-replace-names save the correct names of the
### installed and replacement packages into files queried by other
### targets.
###
.PHONY: replace-names
replace-names:
${_PKG_SILENT}${_PKG_DEBUG} \
${_PKG_BEST_EXISTS} ${PKGWILDCARD:Q} > ${_REPLACE_OLDNAME_FILE}
${_PKG_SILENT}${_PKG_DEBUG} \
${ECHO} ${PKGNAME} > ${_REPLACE_NEWNAME_FILE}
${_PKG_SILENT}${_PKG_DEBUG} \
${CP} -f ${_REPLACE_NEWNAME_FILE} ${_REPLACE_COOKIE}
.PHONY: undo-replace-names
undo-replace-names:
${_PKG_SILENT}${_PKG_DEBUG} \
${ECHO} ${PKGNAME} > ${_REPLACE_OLDNAME_FILE}
${_PKG_SILENT}${_PKG_DEBUG} \
${CP} -f ${_REPLACE_COOKIE} ${_REPLACE_NEWNAME_FILE}
######################################################################
### replace-preserve-required-by (PRIVATE)
######################################################################
### replace-preserve-required-by saves and removes the +REQUIRED_BY
### file from the installed package.
###
.PHONY: replace-preserve-required-by
replace-preserve-required-by:
${_PKG_SILENT}${_PKG_DEBUG} \
${TEST} -f ${_REPLACE_OLDNAME_FILE} || exit 0; \
${STEP_MSG} "Preserving existing +REQUIRED_BY file."; \
oldname=`${CAT} ${_REPLACE_OLDNAME_FILE}`; \
required_by="${_PKG_DBDIR}/$$oldname/+REQUIRED_BY"; \
${TEST} ! -f "$$required_by" || \
${MV} $$required_by ${_REQUIRED_BY_FILE}
######################################################################
### replace-fixup-required-by (PRIVATE)
######################################################################
### replace-fixup-required-by fixes the +CONTENTS files of dependent
### packages to refer to the replacement package.
###
.PHONY: replace-fixup-required-by
replace-fixup-required-by:
@${STEP_MSG} "Fixing @pkgdep entries in dependent packages."
${_PKG_SILENT}${_PKG_DEBUG} \
set -e; \
${TEST} -f ${_REPLACE_OLDNAME_FILE} || exit 0; \
${TEST} -f ${_REPLACE_NEWNAME_FILE} || exit 0; \
${TEST} -f ${_REQUIRED_BY_FILE} || exit 0; \
oldname=`${CAT} ${_REPLACE_OLDNAME_FILE}`; \
newname=`${CAT} ${_REPLACE_NEWNAME_FILE}`; \
${CAT} ${_REQUIRED_BY_FILE} | \
while read pkg; do \
case $$pkg in \
/*) pkgdir="$$pkg" ;; \
*) pkgdir="${_PKG_DBDIR}/$$pkg" ;; \
esac; \
contents="$$pkgdir/+CONTENTS"; \
newcontents="$$contents.$$$$"; \
${SETENV} OLDNAME="$$oldname" NEWNAME="$$newname" \
${AWK} '($$0 ~ "^@pkgdep " ENVIRON["OLDNAME"]) \
{ print "@pkgdep " ENVIRON["NEWNAME"]; next } \
{ print }' \
$$contents > $$newcontents; \
${MV} -f $$newcontents $$contents; \
done
######################################################################
### replace-clean (PRIVATE)
######################################################################
### replace-clean removes the state files for the "replace" target so
### that it may be re-invoked.
###
.PHONY: replace-clean
replace-clean:
${_PKG_SILENT}${_PKG_DEBUG} \
${TEST} -f ${_REPLACE_OLDNAME_FILE} || exit 0; \
oldname=`${CAT} ${_REPLACE_OLDNAME_FILE}`; \
${RM} -f ${WRKDIR}/$$oldname${PKG_SUFX}
${_PKG_SILENT}${_PKG_DEBUG} \
${TEST} -f ${_REPLACE_NEWNAME_FILE} || exit 0; \
newname=`${CAT} ${_REPLACE_NEWNAME_FILE}`; \
${RM} -f ${WRKDIR}/$$newname${PKG_SUFX}
${_PKG_SILENT}${_PKG_DEBUG} \
${RM} -f ${_REPLACE_OLDNAME_FILE} ${_REPLACE_NEWNAME_FILE} \
${_REPLACE_COOKIE}
|