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,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
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 | |
@@ -48,21 +48,22 @@ XXX: Why isn't this variable in the prev | @@ -48,21 +48,22 @@ XXX: Why isn't this variable in the prev | |||
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,39 +1,49 @@ | @@ -1,39 +1,49 @@ | |||
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 \ | |
@@ -162,13 +172,25 @@ replace-fixup-installed-info: .PHONY | @@ -162,13 +172,25 @@ replace-fixup-installed-info: .PHONY | |||
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,54 +1,65 @@ | @@ -1,54 +1,65 @@ | |||
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 |
@@ -1,29 +1,29 @@ | @@ -1,29 +1,29 @@ | |||
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} |