Annotation of pkgsrc/mk/pkgformat/pkg/scripts.mk, revision 1.2
1.2 ! jlam 1: # $NetBSD: scripts.mk,v 1.1 2017/06/01 02:09:43 jlam Exp $
1.1 jlam 2: #
3: # Copyright (c) 2017 The NetBSD Foundation, Inc.
4: # All rights reserved.
5: #
6: # This code is derived from software contributed to The NetBSD Foundation
7: # by Johnny C. Lam.
8: #
9: # Redistribution and use in source and binary forms, with or without
10: # modification, are permitted provided that the following conditions
11: # are met:
12: # 1. Redistributions of source code must retain the above copyright
13: # notice, this list of conditions and the following disclaimer.
14: # 2. Redistributions in binary form must reproduce the above copyright
15: # notice, this list of conditions and the following disclaimer in the
16: # documentation and/or other materials provided with the distribution.
17: #
18: # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
19: # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20: # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21: # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
22: # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23: # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24: # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25: # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26: # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27: # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28: # POSSIBILITY OF SUCH DAMAGE.
29:
30: # This Makefile fragment provides the targets to make the +DEINSTALL
31: # and +INSTALL scripts and hooks into metadata.mk to automatically
32: # generate them as needed.
33:
34: # HEADER_TEMPLATES
35: # List of package-provided template files to be concatenated
36: # into a header for the install and deinstall scripts. The
37: # concatenated files are placed after the main header template
38: # file.
39: #
40: # DEINSTALL_TEMPLATES
41: # List of package-provided template files to be concatenated
42: # to form the body of the deinstall script. The concatenated
43: # files are placed before the main deinstall template file.
44: # The script templates should exit with a code >0 if an error
45: # occurs.
46: #
47: # INSTALL_TEMPLATES
48: # List of package-provided template files to be concatenated
49: # to form the body of the install script. The concatenated
50: # files are placed after the main install template file. The
51: # script templates should exit with a code >0 if an error
52: # occurs.
53: #
54: _HEADER_TMPL= ${PKGSRCDIR}/mk/pkgformat/pkg/templates/header
55: HEADER_TEMPLATES?= # empty
56: .for _file_ in ${PKGDIR}/HEADER
57: . if exists(${_file_}) && empty(HEADER_TEMPLATES:M${_file_})
58: HEADER_TEMPLATES+= ${_file_}
59: . endif
60: .endfor
61: _DEINSTALL_TMPL= ${PKGSRCDIR}/mk/pkgformat/pkg/templates/deinstall
62: DEINSTALL_TEMPLATES?= # empty
63: .for _file_ in ${PKGDIR}/DEINSTALL
64: . if exists(${_file_}) && empty(DEINSTALL_TEMPLATES:M${_file_})
65: DEINSTALL_TEMPLATES+= ${_file_}
66: . endif
67: .endfor
68: _INSTALL_TMPL= ${PKGSRCDIR}/mk/pkgformat/pkg/templates/install
69: INSTALL_TEMPLATES?= # empty
70: .for _file_ in ${PKGDIR}/INSTALL
71: . if exists(${_file_}) && empty(INSTALL_TEMPLATES:M${_file_})
72: INSTALL_TEMPLATES+= ${_file_}
73: . endif
74: .endfor
75: _FOOTER_TMPL?= ${PKGSRCDIR}/mk/pkgformat/pkg/templates/footer
76:
77: # DEINSTALL_SRC
78: # INSTALL_SRC
79: # List of source files that are concatenated to form the
80: # deinstall and install scripts.
81: #
82: .if ( "${USE_PKGTASKS:tl}" == "yes" ) || !empty(HEADER_TEMPLATES) || \
83: !empty(DEINSTALL_TEMPLATES) || !empty(INSTALL_TEMPLATES)
1.2 ! jlam 84: USE_PKGTASKS= yes # script templates use pkgtasks
1.1 jlam 85: DEINSTALL_SRC?= ${_HEADER_TMPL} ${HEADER_TEMPLATES} \
86: ${DEINSTALL_TEMPLATES} ${_DEINSTALL_TMPL} \
87: ${_FOOTER_TMPL} ${PKGTASKS_DATAFILE}
88: INSTALL_SRC?= ${_HEADER_TMPL} ${HEADER_TEMPLATES} \
89: ${_INSTALL_TMPL} ${INSTALL_TEMPLATES} \
90: ${_FOOTER_TMPL} ${PKGTASKS_DATAFILE}
91: .else
92: DEINSTALL_SRC?= # empty
93: INSTALL_SRC?= # empty
94: .endif
95:
96: # _DEINSTALL_FILE
97: # The location of the file to be added as the deinstall script
98: # for the package.
99: #
100: # Possible: any valid path
101: # Default: ${PKG_DB_TMPDIR}/+DEINSTALL
102: #
103: # _INSTALL_FILE
104: # The location of the file to be added as the install script
105: # for the package.
106: #
107: # Possible: any valid path
108: # Default: ${PKG_DB_TMPDIR}/+INSTALL
109: #
110: # _pkgformat-generate-install-scripts (PRIVATE)
111: # Convenience target to generate the deinstall and install
112: # scripts for the package.
113: #
114:
115: .if !empty(DEINSTALL_SRC)
116: _DEINSTALL_FILE= ${PKG_DB_TMPDIR}/+DEINSTALL
117:
118: ${_DEINSTALL_FILE}: ${DEINSTALL_SRC}
119: ${RUN}${MKDIR} ${.TARGET:H:Q}
120: ${RUN}${CAT} ${.ALLSRC} | ${SED} ${FILES_SUBST_SED} > ${.TARGET}.tmp
121: ${RUN}${CHMOD} +x ${.TARGET}.tmp
122: ${RUN}${MV} -f ${.TARGET}.tmp ${.TARGET}
123: .endif
124: .if !empty(INSTALL_SRC)
125: _INSTALL_FILE= ${PKG_DB_TMPDIR}/+INSTALL
126:
127: ${_INSTALL_FILE}: ${INSTALL_SRC}
128: ${RUN}${MKDIR} ${.TARGET:H:Q}
129: ${RUN}${CAT} ${.ALLSRC} | ${SED} ${FILES_SUBST_SED} > ${.TARGET}.tmp
130: ${RUN}${CHMOD} +x ${.TARGET}.tmp
131: ${RUN}${MV} -f ${.TARGET}.tmp ${.TARGET}
132: .endif
133:
134: .PHONY: _pkgformat-generate-install-scripts
135: _pkgformat-generate-install-scripts: ${_DEINSTALL_FILE} ${_INSTALL_FILE}
136:
137: # Hook into pkgsrc/mk/pkgformat/pkg/metadata.mk to automatically generate
138: # the deinstall and install scripts if needed.
139: #
140: _METADATA_TARGETS+= ${_DEINSTALL_FILE} ${_INSTALL_FILE}
141:
142: ###
143: # Variable substitutions for the scripts.
144:
145: FILES_SUBST+= PKGBASE=${PKGBASE:Q}
146:
147: # Variables for programs for use by script templates.
148: FILES_SUBST+= BASENAME=${BASENAME:Q}
149: FILES_SUBST+= CHGRP=${CHGRP:Q}
150: FILES_SUBST+= CMP=${CMP:Q}
151: FILES_SUBST+= DIRNAME=${DIRNAME:Q}
152: FILES_SUBST+= ECHO=${ECHO:Q}
153: FILES_SUBST+= ECHO_N=${ECHO_N:Q}
154: FILES_SUBST+= EGREP=${EGREP:Q}
155: FILES_SUBST+= EXPR=${EXPR:Q}
156: FILES_SUBST+= FALSE=${FALSE:Q}
157: FILES_SUBST+= GREP=${GREP:Q}
158: FILES_SUBST+= GTAR=${GTAR:Q}
159: FILES_SUBST+= HEAD=${HEAD:Q}
160: FILES_SUBST+= PERL5=${PERL5:Q}
161: FILES_SUBST+= PWD_CMD=${PWD_CMD:Q}
162: FILES_SUBST+= SETENV=${SETENV:Q}
163: FILES_SUBST+= SH=${SH:Q}
164: FILES_SUBST+= SU=${SU:Q}
165: FILES_SUBST+= TEST=${TEST:Q}
166: FILES_SUBST+= TOUCH=${TOUCH:Q}
167: FILES_SUBST+= TR=${TR:Q}
168: FILES_SUBST+= TRUE=${TRUE:Q}
169: FILES_SUBST+= XARGS=${XARGS:Q}
170:
171: # Variables for the pkg_install package tools.
172: FILES_SUBST+= PKG_ADMIN=${PKG_ADMIN:Q}
173: FILES_SUBST+= PKG_INFO=${PKG_INFO:Q}
174:
175: # Variables for installation prefix references.
176: FILES_SUBST+= LOCALBASE=${LOCALBASE:Q}
177: FILES_SUBST+= X11BASE=${X11BASE:Q}
178: FILES_SUBST+= PREFIX=${PREFIX:Q}
179:
180: # Variables for the package configuration directory.
181: FILES_SUBST+= PKG_SYSCONFBASE=${PKG_SYSCONFBASE:Q}
182: FILES_SUBST+= PKG_SYSCONFBASEDIR=${PKG_SYSCONFBASEDIR:Q}
183: FILES_SUBST+= PKG_SYSCONFDIR=${PKG_SYSCONFDIR:Q}
CVSweb <webmaster@jp.NetBSD.org>