pkgsrc/mk/pkgformat/pkg/package.mk
reed 6bdad51ddf Rename "flavor" to "pkgformat".
This is from Anton Panev's GSoC 2011 project to add RPM and DPKG
support to pkgsrc. (I am not adding that further support in this
commit.)

This is just a rename of the existing functionality. Now it will
be easy to test the GSoC work by simply putting in a single
directory (such as "rpm" or "deb"). See
http://addpackageforma.sourceforge.net/ for some details.

This is from Anton's CVS, but I made some minor changes:

- changed plural pkgformats to singular pkgformat (to be consistent)

- fixed a few places (in comments) that were missed

- catch up on some additions to flavor not in the pkgforma cvs:
PKGSRC_SETENV and _flavor-destdir-undo-replace and
undo-destdir-replace-install.
2011-10-15 00:23:07 +00:00

159 lines
5.5 KiB
Makefile

# $NetBSD: package.mk,v 1.1 2011/10/15 00:23:09 reed Exp $
.if defined(PKG_SUFX)
WARNINGS+= "PKG_SUFX is deprecated, please use PKG_COMPRESSION"
. if ${PKG_SUFX} == ".tgz"
PKG_COMPRESSION= gzip
. elif ${PKG_SUFX} == ".tbz"
PKG_COMPRESSION= bzip2
. else
WARNINGS+= "Unsupported value for PKG_SUFX"
. endif
.endif
PKG_SUFX?= .tgz
FILEBASE?= ${PKGBASE}
PKGFILE?= ${PKGREPOSITORY}/${FILEBASE}-${PKGVERSION}${PKG_SUFX}
PKGREPOSITORY?= ${PACKAGES}/${PKGREPOSITORYSUBDIR}
PKGREPOSITORYSUBDIR?= All
######################################################################
### package-check-installed (PRIVATE, pkgsrc/mk/package/package.mk)
######################################################################
### package-check-installed verifies that the package is installed on
### the system.
###
.PHONY: package-check-installed
package-check-installed:
${RUN} ${PKG_INFO} -qe ${PKGNAME} \
|| ${FAIL_MSG} "${PKGNAME} is not installed."
######################################################################
### package-create (PRIVATE, pkgsrc/mk/package/package.mk)
######################################################################
### package-create creates the binary package.
###
.PHONY: package-create
package-create: package-remove ${PKGFILE} package-links
_PKG_ARGS_PACKAGE+= ${_PKG_CREATE_ARGS}
_PKG_ARGS_PACKAGE+= -F ${PKG_COMPRESSION}
.if ${_USE_DESTDIR} == "no"
_PKG_ARGS_PACKAGE+= -p ${PREFIX}
.else
_PKG_ARGS_PACKAGE+= -I ${PREFIX} -p ${DESTDIR}${PREFIX}
. if ${_USE_DESTDIR} == "user-destdir"
_PKG_ARGS_PACKAGE+= -u ${REAL_ROOT_USER} -g ${REAL_ROOT_GROUP}
. endif
.endif
.if ${PKG_INSTALLATION_TYPE} == "pkgviews"
_PKG_ARGS_PACKAGE+= -E
.endif
${PKGFILE}: ${_CONTENTS_TARGETS}
${RUN} ${MKDIR} ${.TARGET:H}
@${STEP_MSG} "Creating binary package ${.TARGET}"
${RUN} tmpname=${.TARGET:S,${PKG_SUFX}$,.tmp${PKG_SUFX},}; \
if ${PKG_CREATE} ${_PKG_ARGS_PACKAGE} "$$tmpname"; then \
${MV} -f "$$tmpname" ${.TARGET}; \
else \
exitcode=$$?; ${RM} -f "$$tmpname"; exit $$exitcode; \
fi
######################################################################
### package-remove (PRIVATE)
######################################################################
### package-remove removes the binary package from the package
### repository.
###
.PHONY: package-remove
package-remove:
${RUN} ${RM} -f ${PKGFILE}
######################################################################
### package-links (PRIVATE)
######################################################################
### package-links creates symlinks to the binary package from the
### non-primary categories to which the package belongs.
###
package-links: delete-package-links
.for _dir_ in ${CATEGORIES:S/^/${PACKAGES}\//}
${RUN} ${MKDIR} ${_dir_:Q}
${RUN} [ -d ${_dir_:Q} ] \
|| ${FAIL_MSG} "Can't create directory "${_dir_:Q}"."
${RUN} ${RM} -f ${_dir_:Q}/${PKGFILE:T}
${RUN} ${LN} -s ../${PKGREPOSITORYSUBDIR}/${PKGFILE:T} ${_dir_:Q}
.endfor
######################################################################
### delete-package-links (PRIVATE)
######################################################################
### delete-package-links removes the symlinks to the binary package from
### the non-primary categories to which the package belongs.
###
delete-package-links:
${RUN} ${FIND} ${PACKAGES} -type l -name ${PKGFILE:T} -print \
| ${XARGS} ${RM} -f
######################################################################
### tarup (PUBLIC)
######################################################################
### tarup is a public target to generate a binary package from an
### installed package instance.
###
_PKG_TARUP_CMD= ${LOCALBASE}/bin/pkg_tarup
.PHONY: tarup
tarup: package-remove tarup-pkg package-links
######################################################################
### tarup-pkg (PRIVATE)
######################################################################
### tarup-pkg creates a binary package from an installed package instance
### using "pkg_tarup".
###
tarup-pkg:
${RUN} [ -x ${_PKG_TARUP_CMD} ] || exit 1; \
${PKGSRC_SETENV} PKG_DBDIR=${_PKG_DBDIR} PKG_SUFX=${PKG_SUFX} \
PKGREPOSITORY=${PKGREPOSITORY} \
${_PKG_TARUP_CMD} -f ${FILEBASE} ${PKGNAME}
######################################################################
### package-install (PUBLIC)
######################################################################
### When DESTDIR support is active, package-install uses package to
### create a binary package and installs it.
### Otherwise it is identical to calling package.
###
.PHONY: package-install real-package-install su-real-package-install
.if defined(_PKGSRC_BARRIER)
package-install: package real-package-install
.else
package-install: barrier
.endif
.if ${_USE_DESTDIR} != "no"
. if !empty(USE_CROSS_COMPILE:M[yY][eE][sS])
real-package-install: su-real-package-install
. else
real-package-install: su-target
. endif
.else
real-package-install:
@${DO_NADA}
.endif
su-real-package-install:
@${PHASE_MSG} "Install binary package of "${PKGNAME:Q}
.if !empty(USE_CROSS_COMPILE:M[yY][eE][sS])
@${MKDIR} ${_CROSS_DESTDIR}${PREFIX}
${PKG_ADD} -m ${MACHINE_ARCH} -I -p ${_CROSS_DESTDIR}${PREFIX} ${PKGFILE}
@${ECHO} "Fixing recorded cwd..."
@${SED} -e 's|@cwd ${_CROSS_DESTDIR}|@cwd |' ${_PKG_DBDIR}/${PKGNAME:Q}/+CONTENTS > ${_PKG_DBDIR}/${PKGNAME:Q}/+CONTENTS.tmp
@${MV} ${_PKG_DBDIR}/${PKGNAME:Q}/+CONTENTS.tmp ${_PKG_DBDIR}/${PKGNAME:Q}/+CONTENTS
.else
${RUN} case ${_AUTOMATIC:Q}"" in \
[yY][eE][sS]) ${PKG_ADD} -A ${PKGFILE} ;; \
*) ${PKG_ADD} ${PKGFILE} ;; \
esac
.endif