2014-03-01 11:37:30 +00:00
|
|
|
# This hook generates a XBPS binary package from an installed package in destdir.
|
|
|
|
|
2014-03-02 05:30:25 +00:00
|
|
|
genpkg() {
|
2014-06-06 18:51:47 +00:00
|
|
|
local pkgdir="$1" arch="$2" desc="$3" pkgver="$4" binpkg="$5"
|
|
|
|
local _preserve _deps _shprovides _shrequires _gitrevs _provides _conflicts
|
2014-09-28 07:31:39 +00:00
|
|
|
local _replaces _reverts _mutable_files _conf_files f
|
2014-03-01 11:37:30 +00:00
|
|
|
|
|
|
|
if [ ! -d "${PKGDESTDIR}" ]; then
|
|
|
|
msg_warn "$pkgver: cannot find pkg destdir... skipping!\n"
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
[ ! -d $pkgdir ] && mkdir -p $pkgdir
|
|
|
|
|
|
|
|
while [ -f $pkgdir/${binpkg}.lock ]; do
|
2014-03-02 06:07:59 +00:00
|
|
|
msg_warn "${pkgver}: binpkg is being created, waiting for 1s...\n"
|
2014-03-01 11:37:30 +00:00
|
|
|
sleep 1
|
|
|
|
done
|
|
|
|
|
|
|
|
# Don't overwrite existing binpkgs by default, skip them.
|
|
|
|
if [ -f $pkgdir/$binpkg -a -z "$XBPS_BUILD_FORCEMODE" ]; then
|
2014-03-02 06:07:59 +00:00
|
|
|
msg_normal "${pkgver}: skipping existing $binpkg pkg...\n"
|
2014-03-01 11:37:30 +00:00
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
touch -f $pkgdir/${binpkg}.lock
|
|
|
|
|
|
|
|
if [ ! -d $pkgdir ]; then
|
|
|
|
mkdir -p $pkgdir
|
|
|
|
fi
|
|
|
|
cd $pkgdir
|
|
|
|
|
2015-11-10 11:04:15 +00:00
|
|
|
_preserve=${preserve:+-p}
|
2014-03-01 11:37:30 +00:00
|
|
|
if [ -s ${PKGDESTDIR}/rdeps ]; then
|
2019-07-10 17:48:54 +00:00
|
|
|
_deps="$(<${PKGDESTDIR}/rdeps)"
|
2014-03-01 11:37:30 +00:00
|
|
|
fi
|
|
|
|
if [ -s ${PKGDESTDIR}/shlib-provides ]; then
|
2019-07-10 17:48:54 +00:00
|
|
|
_shprovides="$(<${PKGDESTDIR}/shlib-provides)"
|
2014-03-01 11:37:30 +00:00
|
|
|
fi
|
|
|
|
if [ -s ${PKGDESTDIR}/shlib-requires ]; then
|
2019-07-10 17:48:54 +00:00
|
|
|
_shrequires="$(<${PKGDESTDIR}/shlib-requires)"
|
2014-03-01 11:37:30 +00:00
|
|
|
fi
|
2014-12-11 10:02:22 +00:00
|
|
|
if [ -s ${XBPS_STATEDIR}/gitrev ]; then
|
2019-07-10 17:48:54 +00:00
|
|
|
_gitrevs="$(<${XBPS_STATEDIR}/gitrev)"
|
2014-03-02 07:33:28 +00:00
|
|
|
fi
|
2014-03-01 11:37:30 +00:00
|
|
|
|
2015-11-10 11:04:15 +00:00
|
|
|
# Stripping whitespaces
|
|
|
|
local _provides="$(echo $provides)"
|
|
|
|
local _conflicts="$(echo $conflicts)"
|
|
|
|
local _replaces="$(echo $replaces)"
|
|
|
|
local _reverts="$(echo $reverts)"
|
|
|
|
local _mutable_files="$(echo $mutable_files)"
|
2015-11-18 10:19:09 +00:00
|
|
|
local _conf_files="$(expand_destdir "$conf_files")"
|
2015-11-10 11:04:15 +00:00
|
|
|
local _alternatives="$(echo $alternatives)"
|
|
|
|
local _tags="$(echo $tags)"
|
2019-06-06 19:04:06 +00:00
|
|
|
local _changelog="$(echo $changelog)"
|
2014-03-01 11:37:30 +00:00
|
|
|
|
2014-05-05 08:59:33 +00:00
|
|
|
msg_normal "Creating $binpkg for repository $pkgdir ...\n"
|
2014-03-01 11:37:30 +00:00
|
|
|
|
|
|
|
#
|
|
|
|
# Create the XBPS binary package.
|
|
|
|
#
|
|
|
|
xbps-create \
|
2015-09-10 18:07:13 +00:00
|
|
|
${_provides:+--provides "${_provides}"} \
|
|
|
|
${_conflicts:+--conflicts "${_conflicts}"} \
|
|
|
|
${_replaces:+--replaces "${_replaces}"} \
|
|
|
|
${_reverts:+--reverts "${_reverts}"} \
|
|
|
|
${_mutable_files:+--mutable-files "${_mutable_files}"} \
|
|
|
|
${_deps:+--dependencies "${_deps}"} \
|
|
|
|
${_conf_files:+--config-files "${_conf_files}"} \
|
|
|
|
${PKG_BUILD_OPTIONS:+--build-options "${PKG_BUILD_OPTIONS}"} \
|
|
|
|
${_gitrevs:+--source-revisions "${_gitrevs}"} \
|
|
|
|
${_shprovides:+--shlib-provides "${_shprovides}"} \
|
|
|
|
${_shrequires:+--shlib-requires "${_shrequires}"} \
|
2015-10-30 11:39:59 +00:00
|
|
|
${_alternatives:+--alternatives "${_alternatives}"} \
|
2015-09-10 18:07:13 +00:00
|
|
|
${_preserve:+--preserve} \
|
2015-11-10 10:33:19 +00:00
|
|
|
${tags:+--tags "${tags}"} \
|
2019-06-06 19:04:06 +00:00
|
|
|
${_changelog:+--changelog "${_changelog}"} \
|
2020-03-03 09:26:12 +00:00
|
|
|
${XBPS_PKG_COMPTYPE:+--compression $XBPS_PKG_COMPTYPE} \
|
2014-03-01 11:37:30 +00:00
|
|
|
--architecture ${arch} \
|
|
|
|
--homepage "${homepage}" \
|
|
|
|
--license "${license}" \
|
|
|
|
--maintainer "${maintainer}" \
|
2014-03-02 06:07:59 +00:00
|
|
|
--desc "${desc}" \
|
2015-09-10 18:07:13 +00:00
|
|
|
--pkgver "${pkgver}" \
|
|
|
|
--quiet \
|
|
|
|
${PKGDESTDIR}
|
2014-03-01 11:37:30 +00:00
|
|
|
rval=$?
|
|
|
|
|
|
|
|
rm -f $pkgdir/${binpkg}.lock
|
|
|
|
|
|
|
|
if [ $rval -ne 0 ]; then
|
|
|
|
rm -f $pkgdir/$binpkg
|
|
|
|
msg_error "Failed to created binary package: $binpkg!\n"
|
|
|
|
fi
|
|
|
|
}
|
2014-03-02 05:30:25 +00:00
|
|
|
|
|
|
|
hook() {
|
2014-09-28 07:31:39 +00:00
|
|
|
local arch= binpkg= repo= _pkgver= _desc= _pkgn= _pkgv= _provides= \
|
2015-02-05 10:30:32 +00:00
|
|
|
_replaces= _reverts= f= found_dbg_subpkg=
|
2014-03-02 06:07:59 +00:00
|
|
|
|
2015-12-03 09:04:16 +00:00
|
|
|
if [ "${archs// /}" = "noarch" ]; then
|
2014-03-02 06:07:59 +00:00
|
|
|
arch=noarch
|
|
|
|
elif [ -n "$XBPS_TARGET_MACHINE" ]; then
|
|
|
|
arch=$XBPS_TARGET_MACHINE
|
|
|
|
else
|
|
|
|
arch=$XBPS_MACHINE
|
|
|
|
fi
|
2015-12-03 09:04:16 +00:00
|
|
|
if [ "${archs// /}" != "noarch" -a -z "$XBPS_CROSS_BUILD" -a -n "$XBPS_ARCH" -a "$XBPS_ARCH" != "$XBPS_TARGET_MACHINE" ]; then
|
2014-03-02 06:07:59 +00:00
|
|
|
arch=${XBPS_ARCH}
|
|
|
|
fi
|
|
|
|
|
|
|
|
binpkg=${pkgver}.${arch}.xbps
|
|
|
|
|
2014-11-01 12:10:22 +00:00
|
|
|
if [ -n "$repository" ]; then
|
|
|
|
repo=$XBPS_REPOSITORY/$repository
|
2014-03-02 06:07:59 +00:00
|
|
|
else
|
|
|
|
repo=$XBPS_REPOSITORY
|
|
|
|
fi
|
|
|
|
|
|
|
|
genpkg ${repo} ${arch} "${short_desc}" ${pkgver} ${binpkg}
|
2014-03-02 05:30:25 +00:00
|
|
|
|
2014-07-23 13:23:18 +00:00
|
|
|
for f in ${provides}; do
|
|
|
|
_pkgn="$($XBPS_UHELPER_CMD getpkgname $f)"
|
|
|
|
_pkgv="$($XBPS_UHELPER_CMD getpkgversion $f)"
|
|
|
|
_provides+=" ${_pkgn}-32bit-${_pkgv}"
|
|
|
|
done
|
2014-08-22 07:21:04 +00:00
|
|
|
for f in ${replaces}; do
|
|
|
|
_pkgn="$($XBPS_UHELPER_CMD getpkgdepname $f)"
|
|
|
|
_pkgv="$($XBPS_UHELPER_CMD getpkgdepversion $f)"
|
|
|
|
_replaces+=" ${_pkgn}-32bit${_pkgv}"
|
|
|
|
done
|
2014-07-23 13:23:18 +00:00
|
|
|
|
2014-03-02 05:30:25 +00:00
|
|
|
# Generate -dbg pkg.
|
2015-02-05 10:30:32 +00:00
|
|
|
for f in ${subpackages}; do
|
|
|
|
# If there's an explicit subpkg named ${pkgname}-dbg, don't generate
|
|
|
|
# it automagically (required by linuxX.X).
|
|
|
|
if [ "${sourcepkg}-dbg" = "$f" ]; then
|
|
|
|
found_dbg_subpkg=1
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
if [ -z "$found_dbg_subpkg" -a -d "${XBPS_DESTDIR}/${XBPS_CROSS_TRIPLET}/${pkgname}-dbg-${version}" ]; then
|
2014-06-06 18:51:47 +00:00
|
|
|
source ${XBPS_COMMONDIR}/environment/setup-subpkg/subpkg.sh
|
2014-05-05 08:59:33 +00:00
|
|
|
repo=$XBPS_REPOSITORY/debug
|
2014-03-02 06:07:59 +00:00
|
|
|
_pkgver=${pkgname}-dbg-${version}_${revision}
|
|
|
|
_desc="${short_desc} (debug files)"
|
|
|
|
binpkg=${_pkgver}.${arch}.xbps
|
|
|
|
PKGDESTDIR="${XBPS_DESTDIR}/${XBPS_CROSS_TRIPLET}/${pkgname}-dbg-${version}"
|
|
|
|
genpkg ${repo} ${arch} "${_desc}" ${_pkgver} ${binpkg}
|
2014-03-02 05:30:25 +00:00
|
|
|
fi
|
2014-03-02 11:26:24 +00:00
|
|
|
# Generate 32bit pkg.
|
2014-03-07 09:12:20 +00:00
|
|
|
if [ "$XBPS_TARGET_MACHINE" != "i686" ]; then
|
|
|
|
return
|
|
|
|
fi
|
2014-03-06 20:03:23 +00:00
|
|
|
if [ -d "${XBPS_DESTDIR}/${pkgname}-32bit-${version}" ]; then
|
2014-06-06 18:51:47 +00:00
|
|
|
source ${XBPS_COMMONDIR}/environment/setup-subpkg/subpkg.sh
|
2014-11-01 12:10:22 +00:00
|
|
|
if [ -n "$repository" ]; then
|
|
|
|
repo=$XBPS_REPOSITORY/multilib/$repository
|
2014-05-05 08:59:33 +00:00
|
|
|
else
|
|
|
|
repo=$XBPS_REPOSITORY/multilib
|
|
|
|
fi
|
2014-03-06 20:03:23 +00:00
|
|
|
_pkgver=${pkgname}-32bit-${version}_${revision}
|
2014-03-02 11:26:24 +00:00
|
|
|
_desc="${short_desc} (32bit)"
|
|
|
|
binpkg=${_pkgver}.x86_64.xbps
|
2014-03-06 20:03:23 +00:00
|
|
|
PKGDESTDIR="${XBPS_DESTDIR}/${pkgname}-32bit-${version}"
|
2014-07-23 11:07:46 +00:00
|
|
|
[ -n "${_provides}" ] && export provides="${_provides}"
|
2014-08-22 07:21:04 +00:00
|
|
|
[ -n "${_replaces}" ] && export replaces="${_replaces}"
|
2014-03-02 11:26:24 +00:00
|
|
|
genpkg ${repo} x86_64 "${_desc}" ${_pkgver} ${binpkg}
|
|
|
|
fi
|
2014-03-02 05:30:25 +00:00
|
|
|
}
|