Annotation of pkgsrc/mk/pkgformat/pkg/scripts.mk, revision 1.1

1.1     ! jlam        1: # $NetBSD$
        !             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)
        !            84: DEINSTALL_SRC?=                ${_HEADER_TMPL} ${HEADER_TEMPLATES}             \
        !            85:                        ${DEINSTALL_TEMPLATES} ${_DEINSTALL_TMPL}       \
        !            86:                        ${_FOOTER_TMPL} ${PKGTASKS_DATAFILE}
        !            87: INSTALL_SRC?=          ${_HEADER_TMPL} ${HEADER_TEMPLATES}             \
        !            88:                        ${_INSTALL_TMPL} ${INSTALL_TEMPLATES}           \
        !            89:                        ${_FOOTER_TMPL} ${PKGTASKS_DATAFILE}
        !            90: .else
        !            91: DEINSTALL_SRC?=                # empty
        !            92: INSTALL_SRC?=          # empty
        !            93: .endif
        !            94: 
        !            95: # _DEINSTALL_FILE
        !            96: #      The location of the file to be added as the deinstall script
        !            97: #      for the package.
        !            98: #
        !            99: #      Possible: any valid path
        !           100: #      Default: ${PKG_DB_TMPDIR}/+DEINSTALL
        !           101: #
        !           102: # _INSTALL_FILE
        !           103: #      The location of the file to be added as the install script
        !           104: #      for the package.
        !           105: #
        !           106: #      Possible: any valid path
        !           107: #      Default: ${PKG_DB_TMPDIR}/+INSTALL
        !           108: #
        !           109: # _pkgformat-generate-install-scripts (PRIVATE)
        !           110: #      Convenience target to generate the deinstall and install
        !           111: #      scripts for the package.
        !           112: #
        !           113: 
        !           114: .if !empty(DEINSTALL_SRC)
        !           115: _DEINSTALL_FILE=       ${PKG_DB_TMPDIR}/+DEINSTALL
        !           116: 
        !           117: ${_DEINSTALL_FILE}: ${DEINSTALL_SRC}
        !           118:        ${RUN}${MKDIR} ${.TARGET:H:Q}
        !           119:        ${RUN}${CAT} ${.ALLSRC} | ${SED} ${FILES_SUBST_SED} > ${.TARGET}.tmp
        !           120:        ${RUN}${CHMOD} +x ${.TARGET}.tmp
        !           121:        ${RUN}${MV} -f ${.TARGET}.tmp ${.TARGET}
        !           122: .endif
        !           123: .if !empty(INSTALL_SRC)
        !           124: _INSTALL_FILE=         ${PKG_DB_TMPDIR}/+INSTALL
        !           125: 
        !           126: ${_INSTALL_FILE}: ${INSTALL_SRC}
        !           127:        ${RUN}${MKDIR} ${.TARGET:H:Q}
        !           128:        ${RUN}${CAT} ${.ALLSRC} | ${SED} ${FILES_SUBST_SED} > ${.TARGET}.tmp
        !           129:        ${RUN}${CHMOD} +x ${.TARGET}.tmp
        !           130:        ${RUN}${MV} -f ${.TARGET}.tmp ${.TARGET}
        !           131: .endif
        !           132: 
        !           133: .PHONY: _pkgformat-generate-install-scripts
        !           134: _pkgformat-generate-install-scripts: ${_DEINSTALL_FILE} ${_INSTALL_FILE}
        !           135: 
        !           136: # Hook into pkgsrc/mk/pkgformat/pkg/metadata.mk to automatically generate
        !           137: # the deinstall and install scripts if needed.
        !           138: #
        !           139: _METADATA_TARGETS+=    ${_DEINSTALL_FILE} ${_INSTALL_FILE}
        !           140: 
        !           141: ###
        !           142: # Variable substitutions for the scripts.
        !           143: 
        !           144: FILES_SUBST+=  PKGBASE=${PKGBASE:Q}
        !           145: 
        !           146: # Variables for programs for use by script templates.
        !           147: FILES_SUBST+=  BASENAME=${BASENAME:Q}
        !           148: FILES_SUBST+=  CHGRP=${CHGRP:Q}
        !           149: FILES_SUBST+=  CMP=${CMP:Q}
        !           150: FILES_SUBST+=  DIRNAME=${DIRNAME:Q}
        !           151: FILES_SUBST+=  ECHO=${ECHO:Q}
        !           152: FILES_SUBST+=  ECHO_N=${ECHO_N:Q}
        !           153: FILES_SUBST+=  EGREP=${EGREP:Q}
        !           154: FILES_SUBST+=  EXPR=${EXPR:Q}
        !           155: FILES_SUBST+=  FALSE=${FALSE:Q}
        !           156: FILES_SUBST+=  GREP=${GREP:Q}
        !           157: FILES_SUBST+=  GTAR=${GTAR:Q}
        !           158: FILES_SUBST+=  HEAD=${HEAD:Q}
        !           159: FILES_SUBST+=  PERL5=${PERL5:Q}
        !           160: FILES_SUBST+=  PWD_CMD=${PWD_CMD:Q}
        !           161: FILES_SUBST+=  SETENV=${SETENV:Q}
        !           162: FILES_SUBST+=  SH=${SH:Q}
        !           163: FILES_SUBST+=  SU=${SU:Q}
        !           164: FILES_SUBST+=  TEST=${TEST:Q}
        !           165: FILES_SUBST+=  TOUCH=${TOUCH:Q}
        !           166: FILES_SUBST+=  TR=${TR:Q}
        !           167: FILES_SUBST+=  TRUE=${TRUE:Q}
        !           168: FILES_SUBST+=  XARGS=${XARGS:Q}
        !           169: 
        !           170: # Variables for the pkg_install package tools.
        !           171: FILES_SUBST+=  PKG_ADMIN=${PKG_ADMIN:Q}
        !           172: FILES_SUBST+=  PKG_INFO=${PKG_INFO:Q}
        !           173: 
        !           174: # Variables for installation prefix references.
        !           175: FILES_SUBST+=  LOCALBASE=${LOCALBASE:Q}
        !           176: FILES_SUBST+=  X11BASE=${X11BASE:Q}
        !           177: FILES_SUBST+=  PREFIX=${PREFIX:Q}
        !           178: 
        !           179: # Variables for the package configuration directory.
        !           180: FILES_SUBST+=  PKG_SYSCONFBASE=${PKG_SYSCONFBASE:Q}
        !           181: FILES_SUBST+=  PKG_SYSCONFBASEDIR=${PKG_SYSCONFBASEDIR:Q}
        !           182: FILES_SUBST+=  PKG_SYSCONFDIR=${PKG_SYSCONFDIR:Q}

CVSweb <webmaster@jp.NetBSD.org>