Add support for using USE_DESTDIR=yes and replace together. Based on the patch send to tech-pkg in 2008, but less intrusive.diff -r1.6 -r1.7 pkgsrc/mk/flavor/README
(joerg)
@@ -1,68 +1,69 @@ | @@ -1,68 +1,69 @@ | |||
1 | $NetBSD: README,v 1.6 2007/10/01 10:08:20 rillig Exp $ | 1 | $NetBSD: README,v 1.7 2009/06/09 08:40:27 joerg Exp $ | |
2 | 2 | |||
3 | = Introduction = | 3 | = Introduction = | |
4 | 4 | |||
5 | A package flavor is a packaging system that is supported by pkgsrc. | 5 | A package flavor is a packaging system that is supported by pkgsrc. | |
6 | Currently, there is only one (the native pkgsrc tools), but maybe we can | 6 | Currently, there is only one (the native pkgsrc tools), but maybe we can | |
7 | support RPM, dpkg or the Solaris native packages someday. It can also be | 7 | support RPM, dpkg or the Solaris native packages someday. It can also be | |
8 | used to test new variants of the packaging tools. | 8 | used to test new variants of the packaging tools. | |
9 | 9 | |||
10 | = Interface = | 10 | = Interface = | |
11 | 11 | |||
12 | == Variables usable at load-time == | 12 | == Variables usable at load-time == | |
13 | 13 | |||
14 | A package system flavor must define the following variables so that they | 14 | A package system flavor must define the following variables so that they | |
15 | can be used when loading Makefiles. (That is, no references to undefined | 15 | can be used when loading Makefiles. (That is, no references to undefined | |
16 | variables.) | 16 | variables.) | |
17 | 17 | |||
18 | === Legacy === | 18 | === Legacy === | |
19 | 19 | |||
20 | * PKG_DBDIR (TODO: Make the other parts of pkgsrc independent of that | 20 | * PKG_DBDIR (TODO: Make the other parts of pkgsrc independent of that | |
21 | variable; this should go away.) | 21 | variable; this should go away.) | |
22 | 22 | |||
23 | === Packaging commands === | 23 | === Packaging commands === | |
24 | 24 | |||
25 | The following variables all refer to shell commands, which must accept | 25 | The following variables all refer to shell commands, which must accept | |
26 | some command line options that are detailed in the respective man pages. | 26 | some command line options that are detailed in the respective man pages. | |
27 | (TODO: Find out which command line options are really used and which | 27 | (TODO: Find out which command line options are really used and which | |
28 | ones are useful. Document them.) | 28 | ones are useful. Document them.) | |
29 | 29 | |||
30 | * PKG_ADD | 30 | * PKG_ADD | |
31 | * PKG_ADMIN | 31 | * PKG_ADMIN | |
32 | * PKG_CREATE | 32 | * PKG_CREATE | |
33 | * PKG_DELETE | 33 | * PKG_DELETE | |
34 | * PKG_INFO | 34 | * PKG_INFO | |
35 | * PKG_VIEW | 35 | * PKG_VIEW | |
36 | * LINKFARM | 36 | * LINKFARM | |
37 | * PKG_BEST_EXISTS | 37 | * PKG_BEST_EXISTS | |
38 | 38 | |||
39 | The following variables must be defined so that they can be used in | 39 | The following variables must be defined so that they can be used in | |
40 | shell commands. They may contain references to all other variables. | 40 | shell commands. They may contain references to all other variables. | |
41 | 41 | |||
42 | * PKG_FILELIST_CMD | 42 | * PKG_FILELIST_CMD | |
43 | 43 | |||
44 | XXX: Why isn't this variable in the previous list? | 44 | XXX: Why isn't this variable in the previous list? | |
45 | 45 | |||
46 | == Make targets == | 46 | == Make targets == | |
47 | 47 | |||
48 | The following make targets must be implemented: | 48 | The following make targets must be implemented: | |
49 | 49 | |||
50 | * _flavor-check-vulnerable | 50 | * _flavor-check-vulnerable | |
51 | * _flavor-deinstall | 51 | * _flavor-deinstall | |
52 | * _flavor-show-depends | 52 | * _flavor-show-depends | |
53 | * _flavor-install-dependencies | 53 | * _flavor-install-dependencies | |
54 | * bootstrap-depends | 54 | * bootstrap-depends | |
55 | * _flavor-register | 55 | * _flavor-register | |
56 | * tarup (XXX: This doesn't sound like a target that should be defined | 56 | * tarup (XXX: This doesn't sound like a target that should be defined | |
57 | here.) | 57 | here.) | |
58 | * tarup-pkg | 58 | * tarup-pkg | |
59 | * package-install | 59 | * package-install | |
60 | * _flavor-replace | 60 | * _flavor-replace | |
61 | * _flavor-destdir-replace | |||
61 | * _flavor-undo-replace | 62 | * _flavor-undo-replace | |
62 | 63 | |||
63 | = Bugs = | 64 | = Bugs = | |
64 | 65 | |||
65 | The name "flavor" is badly chosen, especially since flavor is such a | 66 | The name "flavor" is badly chosen, especially since flavor is such a | |
66 | broad term that OpenBSD ports collection has chosen to implement | 67 | broad term that OpenBSD ports collection has chosen to implement | |
67 | something entirely different using the same name. (This has happended | 68 | something entirely different using the same name. (This has happended | |
68 | before pkgsrc has chosen to use this word, though, so no blame on them.) | 69 | before pkgsrc has chosen to use this word, though, so no blame on them.) |
@@ -1,174 +1,196 @@ | @@ -1,174 +1,196 @@ | |||
1 | # $NetBSD: replace.mk,v 1.24 2008/01/23 14:48:50 gdt Exp $ | 1 | # $NetBSD: replace.mk,v 1.25 2009/06/09 08:40:27 joerg Exp $ | |
2 | # | 2 | # | |
3 | 3 | |||
4 | # _flavor-replace: | 4 | # _flavor-replace: | |
5 | # Updates a package in-place on the system. | 5 | # Updates a package in-place on the system (USE_DESTDIR=yes). | |
6 | # | |||
7 | # _flavor-destdir-replace: | |||
8 | # Updates a package in-place on the system (USE_DESTDIR=yes). | |||
6 | # | 9 | # | |
7 | # See also: | 10 | # See also: | |
8 | # replace | 11 | # replace | |
9 | # | 12 | # | |
10 | # XXX: The whole replacement, from deinstalling the old package up | 13 | # XXX: The whole replacement, from deinstalling the old package up | |
11 | # to installing the new package, should be one transaction. It | 14 | # to installing the new package, should be one transaction. It | |
12 | # currently isn't, and the check-files target for other packages | 15 | # currently isn't, and the check-files target for other packages | |
13 | # can be confused when a +REQUIRED_BY files suddenly disappears. | 16 | # can be confused when a +REQUIRED_BY files suddenly disappears. | |
14 | # | 17 | # | |
15 | _flavor-replace: \ | 18 | _flavor-replace: \ | |
16 | replace-names \ | 19 | replace-names \ | |
17 | replace-tarup \ | 20 | replace-tarup \ | |
18 | replace-preserve-installed-info \ | 21 | replace-preserve-installed-info \ | |
19 | replace-preserve-required-by \ | 22 | replace-preserve-required-by \ | |
20 | deinstall \ | 23 | deinstall \ | |
21 | install-clean \ | 24 | install-clean \ | |
22 | install \ | 25 | install \ | |
23 | replace-fixup-required-by \ | 26 | replace-fixup-required-by \ | |
24 | replace-fixup-installed-info \ | 27 | replace-fixup-installed-info \ | |
25 | .PHONY | 28 | .PHONY | |
26 | 29 | |||
30 | _flavor-destdir-replace: \ | |||
31 | replace-names \ | |||
32 | replace-destdir \ | |||
33 | replace-fixup-required-by \ | |||
34 | replace-fixup-installed-info \ | |||
35 | .PHONY | |||
36 | ||||
27 | # _flavor-undo-replace: | 37 | # _flavor-undo-replace: | |
28 | # Undoes the actions from a previous _flavor-replace. | 38 | # Undoes the actions from a previous _flavor-replace. | |
29 | # | 39 | # | |
30 | # See also: | 40 | # See also: | |
31 | # undo-replace | 41 | # undo-replace | |
32 | # | 42 | # | |
33 | _flavor-undo-replace: \ | 43 | _flavor-undo-replace: \ | |
34 | undo-replace-check \ | 44 | undo-replace-check \ | |
35 | replace-preserve-installed-info \ | 45 | replace-preserve-installed-info \ | |
36 | replace-preserve-required-by \ | 46 | replace-preserve-required-by \ | |
37 | deinstall \ | 47 | deinstall \ | |
38 | undo-replace-install \ | 48 | undo-replace-install \ | |
39 | replace-fixup-required-by \ | 49 | replace-fixup-required-by \ | |
40 | replace-clean \ | 50 | replace-clean \ | |
41 | .PHONY | 51 | .PHONY | |
42 | 52 | |||
43 | _INSTALLED_INFO_FILE= ${WRKDIR}/.replace-+INSTALLED_INFO | 53 | _INSTALLED_INFO_FILE= ${WRKDIR}/.replace-+INSTALLED_INFO | |
44 | _REQUIRED_BY_FILE= ${WRKDIR}/.replace-+REQUIRED_BY | 54 | _REQUIRED_BY_FILE= ${WRKDIR}/.replace-+REQUIRED_BY | |
45 | 55 | |||
46 | _COOKIE.replace= ${WRKDIR}/.replace_done | 56 | _COOKIE.replace= ${WRKDIR}/.replace_done | |
47 | _REPLACE_OLDNAME_FILE= ${WRKDIR}/.replace_oldname | 57 | _REPLACE_OLDNAME_FILE= ${WRKDIR}/.replace_oldname | |
48 | _REPLACE_NEWNAME_FILE= ${WRKDIR}/.replace_newname | 58 | _REPLACE_NEWNAME_FILE= ${WRKDIR}/.replace_newname | |
49 | 59 | |||
50 | _REPLACE_OLDNAME_CMD= \ | 60 | _REPLACE_OLDNAME_CMD= \ | |
51 | [ -f ${_REPLACE_OLDNAME_FILE} ] \ | 61 | [ -f ${_REPLACE_OLDNAME_FILE} ] \ | |
52 | || ${FAIL_MSG} "[${.TARGET}] ${_REPLACE_OLDNAME_FILE}: File not found"; \ | 62 | || ${FAIL_MSG} "[${.TARGET}] ${_REPLACE_OLDNAME_FILE}: File not found"; \ | |
53 | oldname=`${CAT} ${_REPLACE_OLDNAME_FILE}` | 63 | oldname=`${CAT} ${_REPLACE_OLDNAME_FILE}` | |
54 | 64 | |||
55 | _REPLACE_NEWNAME_CMD= \ | 65 | _REPLACE_NEWNAME_CMD= \ | |
56 | [ -f ${_REPLACE_NEWNAME_FILE} ] \ | 66 | [ -f ${_REPLACE_NEWNAME_FILE} ] \ | |
57 | || ${FAIL_MSG} "[${.TARGET}] ${_REPLACE_NEWNAME_FILE}: File not found"; \ | 67 | || ${FAIL_MSG} "[${.TARGET}] ${_REPLACE_NEWNAME_FILE}: File not found"; \ | |
58 | newname=`${CAT} ${_REPLACE_NEWNAME_FILE}` | 68 | newname=`${CAT} ${_REPLACE_NEWNAME_FILE}` | |
59 | 69 | |||
60 | # Verifies that there was a previous "replace" action performed that can be undone. | 70 | # Verifies that there was a previous "replace" action performed that can be undone. | |
61 | # | 71 | # | |
62 | undo-replace-check: .PHONY | 72 | undo-replace-check: .PHONY | |
63 | ${RUN} [ -f ${_COOKIE.replace} ] \ | 73 | ${RUN} [ -f ${_COOKIE.replace} ] \ | |
64 | || ${FAIL_MSG} "No replacement to undo!" | 74 | || ${FAIL_MSG} "No replacement to undo!" | |
65 | 75 | |||
66 | # Generates a binary package for the (older) installed package using pkg_tarup. | 76 | # Generates a binary package for the (older) installed package using pkg_tarup. | |
67 | # | 77 | # | |
68 | replace-tarup: .PHONY | 78 | replace-tarup: .PHONY | |
69 | ${RUN} [ -x ${_PKG_TARUP_CMD:Q} ] \ | 79 | ${RUN} [ -x ${_PKG_TARUP_CMD:Q} ] \ | |
70 | || ${FAIL_MSG} ${_PKG_TARUP_CMD:Q}" was not found."; \ | 80 | || ${FAIL_MSG} ${_PKG_TARUP_CMD:Q}" was not found."; \ | |
71 | ${_REPLACE_OLDNAME_CMD}; \ | 81 | ${_REPLACE_OLDNAME_CMD}; \ | |
72 | ${SETENV} PKG_DBDIR=${_PKG_DBDIR} PKG_SUFX=${PKG_SUFX} \ | 82 | ${SETENV} PKG_DBDIR=${_PKG_DBDIR} PKG_SUFX=${PKG_SUFX} \ | |
73 | PKGREPOSITORY=${WRKDIR} \ | 83 | PKGREPOSITORY=${WRKDIR} \ | |
74 | ${_PKG_TARUP_CMD} $${oldname} || \ | 84 | ${_PKG_TARUP_CMD} $${oldname} || \ | |
75 | ${FAIL_MSG} "Could not pkg_tarup $${oldname}". | 85 | ${FAIL_MSG} "Could not pkg_tarup $${oldname}". | |
76 | 86 | |||
77 | # Re-installs the old package that has been saved by replace-tarup. | 87 | # Re-installs the old package that has been saved by replace-tarup. | |
78 | # | 88 | # | |
79 | undo-replace-install: .PHONY | 89 | undo-replace-install: .PHONY | |
80 | @${PHASE_MSG} "Re-adding ${PKGNAME} from saved tar-up package." | 90 | @${PHASE_MSG} "Re-adding ${PKGNAME} from saved tar-up package." | |
81 | ${RUN} ${_REPLACE_OLDNAME_CMD}; \ | 91 | ${RUN} ${_REPLACE_OLDNAME_CMD}; \ | |
82 | ${ECHO} "Installing saved package ${WRKDIR}/$${oldname}${PKG_SUFX}"; \ | 92 | ${ECHO} "Installing saved package ${WRKDIR}/$${oldname}${PKG_SUFX}"; \ | |
83 | ${PKG_ADD} ${WRKDIR}/$${oldname}${PKG_SUFX} | 93 | ${PKG_ADD} ${WRKDIR}/$${oldname}${PKG_SUFX} | |
84 | 94 | |||
85 | # Computes and saves the full names of the installed package to be replaced | 95 | # Computes and saves the full names of the installed package to be replaced | |
86 | # (oldname) and the package that will be installed (newname), so that these | 96 | # (oldname) and the package that will be installed (newname), so that these | |
87 | # names are available later. | 97 | # names are available later. | |
88 | # | 98 | # | |
89 | replace-names: .PHONY | 99 | replace-names: .PHONY | |
90 | ${RUN} if [ x"${OLDNAME}" = x ]; then \ | 100 | ${RUN} if [ x"${OLDNAME}" = x ]; then \ | |
91 | wildcard=${PKGWILDCARD:Q}; \ | 101 | wildcard=${PKGWILDCARD:Q}; \ | |
92 | else \ | 102 | else \ | |
93 | wildcard="${OLDNAME}-[0-9]*"; \ | 103 | wildcard="${OLDNAME}-[0-9]*"; \ | |
94 | fi; \ | 104 | fi; \ | |
95 | ${_PKG_BEST_EXISTS} "$${wildcard}" > ${_REPLACE_OLDNAME_FILE} | 105 | ${_PKG_BEST_EXISTS} "$${wildcard}" > ${_REPLACE_OLDNAME_FILE} | |
96 | ${RUN} ${ECHO} ${PKGNAME} > ${_REPLACE_NEWNAME_FILE} | 106 | ${RUN} ${ECHO} ${PKGNAME} > ${_REPLACE_NEWNAME_FILE} | |
97 | ${RUN} ${CP} -f ${_REPLACE_NEWNAME_FILE} ${_COOKIE.replace} | 107 | ${RUN} ${CP} -f ${_REPLACE_NEWNAME_FILE} ${_COOKIE.replace} | |
98 | 108 | |||
99 | # Saves and removes the +INSTALLED_INFO file from the installed package. | 109 | # Saves and removes the +INSTALLED_INFO file from the installed package. | |
100 | # | 110 | # | |
101 | replace-preserve-installed-info: .PHONY | 111 | replace-preserve-installed-info: .PHONY | |
102 | @${STEP_MSG} "Preserving existing +INSTALLED_INFO file." | 112 | @${STEP_MSG} "Preserving existing +INSTALLED_INFO file." | |
103 | ${RUN} ${_REPLACE_OLDNAME_CMD}; \ | 113 | ${RUN} ${_REPLACE_OLDNAME_CMD}; \ | |
104 | installed_info="${_PKG_DBDIR}/$$oldname/+INSTALLED_INFO"; \ | 114 | installed_info="${_PKG_DBDIR}/$$oldname/+INSTALLED_INFO"; \ | |
105 | ${TEST} ! -f "$$installed_info" || \ | 115 | ${TEST} ! -f "$$installed_info" || \ | |
106 | ${MV} $$installed_info ${_INSTALLED_INFO_FILE} | 116 | ${MV} $$installed_info ${_INSTALLED_INFO_FILE} | |
107 | 117 | |||
108 | # Saves and removes the +REQUIRED_BY file from the installed package. | 118 | # Saves and removes the +REQUIRED_BY file from the installed package. | |
109 | # | 119 | # | |
110 | replace-preserve-required-by: .PHONY | 120 | replace-preserve-required-by: .PHONY | |
111 | @${STEP_MSG} "Preserving existing +REQUIRED_BY file." | 121 | @${STEP_MSG} "Preserving existing +REQUIRED_BY file." | |
112 | ${RUN} ${_REPLACE_OLDNAME_CMD}; \ | 122 | ${RUN} ${_REPLACE_OLDNAME_CMD}; \ | |
113 | required_by="${_PKG_DBDIR}/$$oldname/+REQUIRED_BY"; \ | 123 | required_by="${_PKG_DBDIR}/$$oldname/+REQUIRED_BY"; \ | |
114 | ${TEST} ! -f "$$required_by" || \ | 124 | ${TEST} ! -f "$$required_by" || \ | |
115 | ${MV} $$required_by ${_REQUIRED_BY_FILE} | 125 | ${MV} $$required_by ${_REQUIRED_BY_FILE} | |
116 | 126 | |||
117 | # Fixes the +CONTENTS files of dependent packages to refer to the | 127 | # Fixes the +CONTENTS files of dependent packages to refer to the | |
118 | # replacement package, and puts the +REQUIRED_BY file back into place. | 128 | # replacement package, and puts the +REQUIRED_BY file back into place. | |
119 | # It also sets the unsafe_depends_strict tag on each dependent package, | 129 | # It also sets the unsafe_depends_strict tag on each dependent package, | |
120 | # and sets the unsafe_depends tag if the replaced package has a different | 130 | # and sets the unsafe_depends tag if the replaced package has a different | |
121 | # version. | 131 | # version. | |
122 | # | 132 | # | |
123 | # XXX Only set unsafe_depends if there is an ABI change. | 133 | # XXX Only set unsafe_depends if there is an ABI change. | |
124 | # | 134 | # | |
125 | replace-fixup-required-by: .PHONY | 135 | replace-fixup-required-by: .PHONY | |
126 | @${STEP_MSG} "Fixing @pkgdep entries in dependent packages." | 136 | @${STEP_MSG} "Fixing @pkgdep entries in dependent packages." | |
127 | ${RUN} ${_REPLACE_OLDNAME_CMD}; \ | 137 | ${RUN} ${_REPLACE_OLDNAME_CMD}; \ | |
128 | ${_REPLACE_NEWNAME_CMD}; \ | 138 | ${_REPLACE_NEWNAME_CMD}; \ | |
129 | ${TEST} -f ${_REQUIRED_BY_FILE} || exit 0; \ | 139 | ${TEST} -f ${_REQUIRED_BY_FILE} || exit 0; \ | |
130 | ${CAT} ${_REQUIRED_BY_FILE} | \ | 140 | ${CAT} ${_REQUIRED_BY_FILE} | \ | |
131 | while read pkg; do \ | 141 | while read pkg; do \ | |
132 | case $$pkg in \ | 142 | case $$pkg in \ | |
133 | "") continue ;; \ | 143 | "") continue ;; \ | |
134 | /*) pkgdir="$$pkg" ;; \ | 144 | /*) pkgdir="$$pkg" ;; \ | |
135 | *) pkgdir="${_PKG_DBDIR}/$$pkg" ;; \ | 145 | *) pkgdir="${_PKG_DBDIR}/$$pkg" ;; \ | |
136 | esac; \ | 146 | esac; \ | |
137 | contents="$$pkgdir/+CONTENTS"; \ | 147 | contents="$$pkgdir/+CONTENTS"; \ | |
138 | newcontents="$$contents.$$$$"; \ | 148 | newcontents="$$contents.$$$$"; \ | |
139 | ${SETENV} OLDNAME="$$oldname" NEWNAME="$$newname" \ | 149 | ${SETENV} OLDNAME="$$oldname" NEWNAME="$$newname" \ | |
140 | ${AWK} '($$0 ~ "^@pkgdep " ENVIRON["OLDNAME"]) \ | 150 | ${AWK} '($$0 ~ "^@pkgdep " ENVIRON["OLDNAME"]) \ | |
141 | { print "@pkgdep " ENVIRON["NEWNAME"]; next } \ | 151 | { print "@pkgdep " ENVIRON["NEWNAME"]; next } \ | |
142 | { print }' \ | 152 | { print }' \ | |
143 | $$contents > $$newcontents; \ | 153 | $$contents > $$newcontents; \ | |
144 | ${MV} -f $$newcontents $$contents; \ | 154 | ${MV} -f $$newcontents $$contents; \ | |
145 | ${PKG_ADMIN} set unsafe_depends_strict=YES $$pkg; \ | 155 | ${PKG_ADMIN} set unsafe_depends_strict=YES $$pkg; \ | |
146 | if ${TEST} "$$oldname" != "$$newname"; then \ | 156 | if ${TEST} "$$oldname" != "$$newname"; then \ | |
147 | ${PKG_ADMIN} set unsafe_depends=YES $$pkg; \ | 157 | ${PKG_ADMIN} set unsafe_depends=YES $$pkg; \ | |
148 | fi; \ | 158 | fi; \ | |
149 | done; \ | 159 | done; \ | |
150 | ${MV} ${_REQUIRED_BY_FILE} ${_PKG_DBDIR}/$$newname/+REQUIRED_BY | 160 | ${MV} ${_REQUIRED_BY_FILE} ${_PKG_DBDIR}/$$newname/+REQUIRED_BY | |
151 | 161 | |||
152 | # Removes unsafe_depends* and rebuild tags from this package. | 162 | # Removes unsafe_depends* and rebuild tags from this package. | |
153 | # | 163 | # | |
154 | # XXX: pkg_admin should not complain on unset with no +INSTALLED_INFO. | 164 | # XXX: pkg_admin should not complain on unset with no +INSTALLED_INFO. | |
155 | # | 165 | # | |
156 | replace-fixup-installed-info: .PHONY | 166 | replace-fixup-installed-info: .PHONY | |
157 | @${STEP_MSG} "Removing unsafe_depends and rebuild tags." | 167 | @${STEP_MSG} "Removing unsafe_depends and rebuild tags." | |
158 | ${RUN} ${_REPLACE_NEWNAME_CMD}; \ | 168 | ${RUN} ${_REPLACE_NEWNAME_CMD}; \ | |
159 | [ ! -f ${_INSTALLED_INFO_FILE} ] || \ | 169 | [ ! -f ${_INSTALLED_INFO_FILE} ] || \ | |
160 | ${MV} ${_INSTALLED_INFO_FILE} ${_PKG_DBDIR}/$$newname/+INSTALLED_INFO; \ | 170 | ${MV} ${_INSTALLED_INFO_FILE} ${_PKG_DBDIR}/$$newname/+INSTALLED_INFO; \ | |
161 | for var in unsafe_depends unsafe_depends_strict rebuild; do \ | 171 | for var in unsafe_depends unsafe_depends_strict rebuild; do \ | |
162 | ${TEST} ! -f ${_PKG_DBDIR}/$$newname/+INSTALLED_INFO || \ | 172 | ${TEST} ! -f ${_PKG_DBDIR}/$$newname/+INSTALLED_INFO || \ | |
163 | ${PKG_ADMIN} unset $$var $$newname; \ | 173 | ${PKG_ADMIN} unset $$var $$newname; \ | |
164 | done | 174 | done | |
165 | 175 | |||
166 | # Removes the state files for the "replace" target, so that it may be re-invoked. | 176 | # Removes the state files for the "replace" target, so that it may be re-invoked. | |
167 | # | 177 | # | |
168 | replace-clean: .PHONY | 178 | replace-clean: .PHONY | |
169 | ${RUN} ${_REPLACE_OLDNAME_CMD}; \ | 179 | ${RUN} ${_REPLACE_OLDNAME_CMD}; \ | |
170 | ${_REPLACE_NEWNAME_CMD}; \ | 180 | ${_REPLACE_NEWNAME_CMD}; \ | |
171 | ${RM} -f ${WRKDIR}/$$oldname${PKG_SUFX}; \ | 181 | ${RM} -f ${WRKDIR}/$$oldname${PKG_SUFX}; \ | |
172 | ${RM} -f ${WRKDIR}/$$newname${PKG_SUFX}; \ | 182 | ${RM} -f ${WRKDIR}/$$newname${PKG_SUFX}; \ | |
173 | ${RM} -f ${_REPLACE_OLDNAME_FILE} ${_REPLACE_NEWNAME_FILE} \ | 183 | ${RM} -f ${_REPLACE_OLDNAME_FILE} ${_REPLACE_NEWNAME_FILE} \ | |
174 | ${_COOKIE.replace} | 184 | ${_COOKIE.replace} | |
185 | ||||
186 | replace-destdir: .PHONY | |||
187 | @${PHASE_MSG} "Updating using binary package of "${PKGNAME:Q} | |||
188 | .if !empty(USE_CROSS_COMPILE:M[yY][eE][sS]) | |||
189 | @${MKDIR} ${_CROSS_DESTDIR}${PREFIX} | |||
190 | ${PKG_ADD} -u -m ${MACHINE_ARCH} -I -p ${_CROSS_DESTDIR}${PREFIX} ${PKGFILE} | |||
191 | @${ECHO} "Fixing recorded cwd..." | |||
192 | @${SED} -e 's|@cwd ${_CROSS_DESTDIR}|@cwd |' ${_PKG_DBDIR}/${PKGNAME:Q}/+CONTENTS > ${_PKG_DBDIR}/${PKGNAME:Q}/+CONTENTS.tmp | |||
193 | @${MV} ${_PKG_DBDIR}/${PKGNAME:Q}/+CONTENTS.tmp ${_PKG_DBDIR}/${PKGNAME:Q}/+CONTENTS | |||
194 | .else | |||
195 | ${PKG_ADD} -u ${PKGFILE} | |||
196 | .endif |
@@ -1,55 +1,66 @@ | @@ -1,55 +1,66 @@ | |||
1 | # $NetBSD: replace.mk,v 1.10 2007/03/09 03:28:58 rillig Exp $ | 1 | # $NetBSD: replace.mk,v 1.11 2009/06/09 08:40:28 joerg Exp $ | |
2 | # | 2 | # | |
3 | # Public targets: | 3 | # Public targets: | |
4 | # | 4 | # | |
5 | # replace: | 5 | # replace: | |
6 | # Updates a package in-place on the system. | 6 | # Updates a package in-place on the system. | |
7 | # It will acquire elevated privileges just-in-time. | 7 | # It will acquire elevated privileges just-in-time. | |
8 | # | 8 | # | |
9 | # undo-replace: | 9 | # undo-replace: | |
10 | # Undoes the effects of a previous "make replace". | 10 | # Undoes the effects of a previous "make replace". | |
11 | # It will acquire elevated privileges just-in-time. | 11 | # It will acquire elevated privileges just-in-time. | |
12 | # | 12 | # | |
13 | # | 13 | # | |
14 | # Private targets that must be defined by the package system flavor: | 14 | # Private targets that must be defined by the package system flavor: | |
15 | # | 15 | # | |
16 | # _flavor-replace: | 16 | # _flavor-replace: | |
17 | # Updates a package in-place on the system. | 17 | # Updates a package in-place on the system (USE_DESTDIR=no). | |
18 | # | |||
19 | # _flavor-destdir-replace: | |||
20 | # Updates a package in-place on the system (USE_DESTDIR=yes). | |||
18 | # | 21 | # | |
19 | # _flavor-undo-replace: | 22 | # _flavor-undo-replace: | |
20 | # Undoes a previous "make _flavor-replace". | 23 | # Undoes a previous "make _flavor-replace". | |
21 | 24 | |||
25 | .if ${_USE_DESTDIR} == "no" | |||
22 | _REPLACE_TARGETS+= ${_PKGSRC_BUILD_TARGETS} | 26 | _REPLACE_TARGETS+= ${_PKGSRC_BUILD_TARGETS} | |
27 | .else | |||
28 | _REPLACE_TARGETS+= package | |||
29 | .endif | |||
23 | _REPLACE_TARGETS+= replace-message | 30 | _REPLACE_TARGETS+= replace-message | |
24 | _REPLACE_TARGETS+= unprivileged-install-hook | 31 | _REPLACE_TARGETS+= unprivileged-install-hook | |
25 | 32 | |||
26 | # | 33 | # | |
27 | # replace | 34 | # replace | |
28 | # | 35 | # | |
29 | 36 | |||
30 | .PHONY: replace | 37 | .PHONY: replace | |
31 | .if defined(_PKGSRC_BARRIER) | 38 | .if defined(_PKGSRC_BARRIER) | |
32 | replace: ${_REPLACE_TARGETS} su-target | 39 | replace: ${_REPLACE_TARGETS} su-target | |
33 | .else | 40 | .else | |
34 | replace: barrier | 41 | replace: barrier | |
35 | .endif | 42 | .endif | |
36 | 43 | |||
37 | replace-message: .PHONY | 44 | replace-message: .PHONY | |
38 | @${PHASE_MSG} "Replacing for ${PKGNAME}" | 45 | @${PHASE_MSG} "Replacing for ${PKGNAME}" | |
39 | @${WARNING_MSG} "experimental target - DATA LOSS MAY OCCUR." | 46 | @${WARNING_MSG} "experimental target - DATA LOSS MAY OCCUR." | |
40 | 47 | |||
48 | .if ${_USE_DESTDIR} == "no" | |||
41 | su-replace: .PHONY _flavor-replace | 49 | su-replace: .PHONY _flavor-replace | |
50 | .else | |||
51 | su-replace: .PHONY _flavor-destdir-replace | |||
52 | .endif | |||
42 | MAKEFLAGS.su-replace= _UPDATE_RUNNING=yes | 53 | MAKEFLAGS.su-replace= _UPDATE_RUNNING=yes | |
43 | 54 | |||
44 | # | 55 | # | |
45 | # undo-replace | 56 | # undo-replace | |
46 | # | 57 | # | |
47 | 58 | |||
48 | undo-replace: .PHONY undo-replace-message su-target | 59 | undo-replace: .PHONY undo-replace-message su-target | |
49 | 60 | |||
50 | undo-replace-message: .PHONY | 61 | undo-replace-message: .PHONY | |
51 | @${PHASE_MSG} "Undoing replacement for ${PKGNAME}" | 62 | @${PHASE_MSG} "Undoing replacement for ${PKGNAME}" | |
52 | @${WARNING_MSG} "experimental target - DATA LOSS MAY OCCUR." | 63 | @${WARNING_MSG} "experimental target - DATA LOSS MAY OCCUR." | |
53 | 64 | |||
54 | su-undo-replace: .PHONY _flavor-undo-replace | 65 | su-undo-replace: .PHONY _flavor-undo-replace | |
55 | MAKEFLAGS.su-undo-replace= _UPDATE_RUNNING=yes | 66 | MAKEFLAGS.su-undo-replace= _UPDATE_RUNNING=yes |
@@ -1,140 +1,140 @@ | @@ -1,140 +1,140 @@ | |||
1 | # $NetBSD: package.mk,v 1.20 2009/03/17 22:13:36 rillig Exp $ | 1 | # $NetBSD: package.mk,v 1.21 2009/06/09 08:40:28 joerg Exp $ | |
2 | # | 2 | # | |
3 | # This file provides the code for the "package" phase. | 3 | # This file provides the code for the "package" phase. | |
4 | # | 4 | # | |
5 | # Public targets: | 5 | # Public targets: | |
6 | # | 6 | # | |
7 | # package: | 7 | # package: | |
8 | # Generates a binary package. | 8 | # Generates a binary package. | |
9 | # It will acquire elevated privileges just-in-time. | 9 | # It will acquire elevated privileges just-in-time. | |
10 | # | 10 | # | |
11 | # XXX: From which files is the binary package generated? The | 11 | # XXX: From which files is the binary package generated? The | |
12 | # installed files in LOCALBASE, or some files in WRKDIR/.destdir? | 12 | # installed files in LOCALBASE, or some files in WRKDIR/.destdir? | |
13 | # | 13 | # | |
14 | 14 | |||
15 | _PACKAGE_TARGETS+= check-vulnerable | 15 | _PACKAGE_TARGETS+= check-vulnerable | |
16 | .if make(replace) | 16 | .if make(replace) && ${_USE_DESTDIR} == "no" | |
17 | _PACKAGE_TARGETS+= replace | 17 | _PACKAGE_TARGETS+= replace | |
18 | .else | 18 | .else | |
19 | _PACKAGE_TARGETS+= install | 19 | _PACKAGE_TARGETS+= install | |
20 | .endif | 20 | .endif | |
21 | _PACKAGE_TARGETS+= acquire-package-lock | 21 | _PACKAGE_TARGETS+= acquire-package-lock | |
22 | _PACKAGE_TARGETS+= ${_COOKIE.package} | 22 | _PACKAGE_TARGETS+= ${_COOKIE.package} | |
23 | _PACKAGE_TARGETS+= release-package-lock | 23 | _PACKAGE_TARGETS+= release-package-lock | |
24 | 24 | |||
25 | .PHONY: package | 25 | .PHONY: package | |
26 | .if !target(package) | 26 | .if !target(package) | |
27 | . if exists(${_COOKIE.package}) | 27 | . if exists(${_COOKIE.package}) | |
28 | package: | 28 | package: | |
29 | @${DO_NADA} | 29 | @${DO_NADA} | |
30 | . elif defined(_PKGSRC_BARRIER) | 30 | . elif defined(_PKGSRC_BARRIER) | |
31 | package: ${_PACKAGE_TARGETS} | 31 | package: ${_PACKAGE_TARGETS} | |
32 | . else | 32 | . else | |
33 | package: barrier | 33 | package: barrier | |
34 | . endif | 34 | . endif | |
35 | .endif | 35 | .endif | |
36 | 36 | |||
37 | .PHONY: acquire-package-lock release-package-lock | 37 | .PHONY: acquire-package-lock release-package-lock | |
38 | acquire-package-lock: acquire-lock | 38 | acquire-package-lock: acquire-lock | |
39 | release-package-lock: release-lock | 39 | release-package-lock: release-lock | |
40 | 40 | |||
41 | .if exists(${_COOKIE.package}) | 41 | .if exists(${_COOKIE.package}) | |
42 | ${_COOKIE.package}: | 42 | ${_COOKIE.package}: | |
43 | @${DO_NADA} | 43 | @${DO_NADA} | |
44 | .else | 44 | .else | |
45 | ${_COOKIE.package}: real-package | 45 | ${_COOKIE.package}: real-package | |
46 | .endif | 46 | .endif | |
47 | 47 | |||
48 | ###################################################################### | 48 | ###################################################################### | |
49 | ### real-package (PRIVATE) | 49 | ### real-package (PRIVATE) | |
50 | ###################################################################### | 50 | ###################################################################### | |
51 | ### real-package is a helper target onto which one can hook all of the | 51 | ### real-package is a helper target onto which one can hook all of the | |
52 | ### targets that do the actual packaging of the built objects. | 52 | ### targets that do the actual packaging of the built objects. | |
53 | ### | 53 | ### | |
54 | _REAL_PACKAGE_TARGETS+= package-message | 54 | _REAL_PACKAGE_TARGETS+= package-message | |
55 | _REAL_PACKAGE_TARGETS+= package-all | 55 | _REAL_PACKAGE_TARGETS+= package-all | |
56 | _REAL_PACKAGE_TARGETS+= package-cookie | 56 | _REAL_PACKAGE_TARGETS+= package-cookie | |
57 | 57 | |||
58 | .PHONY: real-package | 58 | .PHONY: real-package | |
59 | real-package: ${_REAL_PACKAGE_TARGETS} | 59 | real-package: ${_REAL_PACKAGE_TARGETS} | |
60 | 60 | |||
61 | .PHONY: package-message | 61 | .PHONY: package-message | |
62 | package-message: | 62 | package-message: | |
63 | @${PHASE_MSG} "Building binary package for ${PKGNAME}" | 63 | @${PHASE_MSG} "Building binary package for ${PKGNAME}" | |
64 | 64 | |||
65 | ###################################################################### | 65 | ###################################################################### | |
66 | ### package-cookie (PRIVATE) | 66 | ### package-cookie (PRIVATE) | |
67 | ###################################################################### | 67 | ###################################################################### | |
68 | ### package-cookie creates the "package" cookie file | 68 | ### package-cookie creates the "package" cookie file | |
69 | ### | 69 | ### | |
70 | .PHONY: package-cookie | 70 | .PHONY: package-cookie | |
71 | package-cookie: | 71 | package-cookie: | |
72 | ${RUN} ${TEST} ! -f ${_COOKIE.package} || ${FALSE} | 72 | ${RUN} ${TEST} ! -f ${_COOKIE.package} || ${FALSE} | |
73 | ${RUN} ${MKDIR} ${_COOKIE.package:H} | 73 | ${RUN} ${MKDIR} ${_COOKIE.package:H} | |
74 | ${RUN} ${ECHO} ${PKGNAME} > ${_COOKIE.package} | 74 | ${RUN} ${ECHO} ${PKGNAME} > ${_COOKIE.package} | |
75 | 75 | |||
76 | ###################################################################### | 76 | ###################################################################### | |
77 | ### The targets below are run with elevated privileges. | 77 | ### The targets below are run with elevated privileges. | |
78 | ###################################################################### | 78 | ###################################################################### | |
79 | 79 | |||
80 | ###################################################################### | 80 | ###################################################################### | |
81 | ### package-all, su-package-all (PRIVATE) | 81 | ### package-all, su-package-all (PRIVATE) | |
82 | ###################################################################### | 82 | ###################################################################### | |
83 | ### package-all is a helper target to create the binary package and | 83 | ### package-all is a helper target to create the binary package and | |
84 | ### generate any necessary warnings. | 84 | ### generate any necessary warnings. | |
85 | ### | 85 | ### | |
86 | .if ${_USE_DESTDIR} == "no" | 86 | .if ${_USE_DESTDIR} == "no" | |
87 | _PACKAGE_ALL_TARGETS+= package-check-installed | 87 | _PACKAGE_ALL_TARGETS+= package-check-installed | |
88 | .endif | 88 | .endif | |
89 | _PACKAGE_ALL_TARGETS+= package-create | 89 | _PACKAGE_ALL_TARGETS+= package-create | |
90 | _PACKAGE_ALL_TARGETS+= _package-warnings | 90 | _PACKAGE_ALL_TARGETS+= _package-warnings | |
91 | _PACKAGE_ALL_TARGETS+= error-check | 91 | _PACKAGE_ALL_TARGETS+= error-check | |
92 | 92 | |||
93 | .PHONY: package-all su-package-all | 93 | .PHONY: package-all su-package-all | |
94 | .if !empty(_MAKE_PACKAGE_AS_ROOT:M[Yy][Ee][Ss]) | 94 | .if !empty(_MAKE_PACKAGE_AS_ROOT:M[Yy][Ee][Ss]) | |
95 | package-all: su-target | 95 | package-all: su-target | |
96 | .else | 96 | .else | |
97 | package-all: su-package-all | 97 | package-all: su-package-all | |
98 | .endif | 98 | .endif | |
99 | su-package-all: ${_PACKAGE_ALL_TARGETS} | 99 | su-package-all: ${_PACKAGE_ALL_TARGETS} | |
100 | 100 | |||
101 | ###################################################################### | 101 | ###################################################################### | |
102 | ### package-check-installed (PRIVATE, override) | 102 | ### package-check-installed (PRIVATE, override) | |
103 | ###################################################################### | 103 | ###################################################################### | |
104 | ### package-check-installed verifies that the package is installed on | 104 | ### package-check-installed verifies that the package is installed on | |
105 | ### the system. This should be overridden per package system flavor. | 105 | ### the system. This should be overridden per package system flavor. | |
106 | ### | 106 | ### | |
107 | .if !target(package-check-installed) | 107 | .if !target(package-check-installed) | |
108 | .PHONY: package-check-installed | 108 | .PHONY: package-check-installed | |
109 | package-check-installed: | 109 | package-check-installed: | |
110 | @${DO_NADA} | 110 | @${DO_NADA} | |
111 | .endif | 111 | .endif | |
112 | 112 | |||
113 | ###################################################################### | 113 | ###################################################################### | |
114 | ### package-create (PRIVATE, override) | 114 | ### package-create (PRIVATE, override) | |
115 | ###################################################################### | 115 | ###################################################################### | |
116 | ### package-create creates the binary package. This should be overridden | 116 | ### package-create creates the binary package. This should be overridden | |
117 | ### per package system flavor. | 117 | ### per package system flavor. | |
118 | ### | 118 | ### | |
119 | .if !target(package-create) | 119 | .if !target(package-create) | |
120 | .PHONY: package-create | 120 | .PHONY: package-create | |
121 | package-create: | 121 | package-create: | |
122 | @${DO_NADA} | 122 | @${DO_NADA} | |
123 | .endif | 123 | .endif | |
124 | 124 | |||
125 | # Displays warnings about the binary package. | 125 | # Displays warnings about the binary package. | |
126 | # | 126 | # | |
127 | _package-warnings: .PHONY | 127 | _package-warnings: .PHONY | |
128 | .if defined(NO_BIN_ON_CDROM) | 128 | .if defined(NO_BIN_ON_CDROM) | |
129 | @${WARNING_MSG} "${PKGNAME} may not be put on a CD-ROM:" | 129 | @${WARNING_MSG} "${PKGNAME} may not be put on a CD-ROM:" | |
130 | @${WARNING_MSG} ${NO_BIN_ON_CDROM:Q} | 130 | @${WARNING_MSG} ${NO_BIN_ON_CDROM:Q} | |
131 | .endif | 131 | .endif | |
132 | .if defined(NO_BIN_ON_FTP) | 132 | .if defined(NO_BIN_ON_FTP) | |
133 | @${WARNING_MSG} "${PKGNAME} may not be made available through FTP:" | 133 | @${WARNING_MSG} "${PKGNAME} may not be made available through FTP:" | |
134 | @${WARNING_MSG} ${NO_BIN_ON_FTP:Q} | 134 | @${WARNING_MSG} ${NO_BIN_ON_FTP:Q} | |
135 | .endif | 135 | .endif | |
136 | .if defined(ABI_DEPENDS) && !empty(USE_ABI_DEPENDS:M[Nn][Oo]) | 136 | .if defined(ABI_DEPENDS) && !empty(USE_ABI_DEPENDS:M[Nn][Oo]) | |
137 | @${WARNING_MSG} "ABI dependency recommendations are being ignored!" | 137 | @${WARNING_MSG} "ABI dependency recommendations are being ignored!" | |
138 | @${WARNING_MSG} "${PKGNAME} should not be uploaded nor" | 138 | @${WARNING_MSG} "${PKGNAME} should not be uploaded nor" | |
139 | @${WARNING_MSG} "otherwise be used as a binary package!" | 139 | @${WARNING_MSG} "otherwise be used as a binary package!" | |
140 | .endif | 140 | .endif |