2014-03-01 12:37:30 +01:00
|
|
|
# This hook generates a XBPS binary package from an installed package in destdir.
|
|
|
|
|
2014-03-02 06:30:25 +01:00
|
|
|
genpkg() {
|
2014-06-06 20:51:47 +02:00
|
|
|
local pkgdir="$1" arch="$2" desc="$3" pkgver="$4" binpkg="$5"
|
|
|
|
local _preserve _deps _shprovides _shrequires _gitrevs _provides _conflicts
|
|
|
|
local _replaces _mutable_files _conf_files f
|
2014-03-01 12:37:30 +01: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 07:07:59 +01:00
|
|
|
msg_warn "${pkgver}: binpkg is being created, waiting for 1s...\n"
|
2014-03-01 12:37:30 +01: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 07:07:59 +01:00
|
|
|
msg_normal "${pkgver}: skipping existing $binpkg pkg...\n"
|
2014-03-01 12:37:30 +01:00
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
touch -f $pkgdir/${binpkg}.lock
|
|
|
|
|
|
|
|
if [ ! -d $pkgdir ]; then
|
|
|
|
mkdir -p $pkgdir
|
|
|
|
fi
|
|
|
|
cd $pkgdir
|
|
|
|
|
|
|
|
if [ -n "$preserve" ]; then
|
|
|
|
_preserve="-p"
|
|
|
|
fi
|
|
|
|
if [ -s ${PKGDESTDIR}/rdeps ]; then
|
|
|
|
_deps="$(cat ${PKGDESTDIR}/rdeps)"
|
|
|
|
fi
|
|
|
|
if [ -s ${PKGDESTDIR}/shlib-provides ]; then
|
|
|
|
_shprovides="$(cat ${PKGDESTDIR}/shlib-provides)"
|
|
|
|
fi
|
|
|
|
if [ -s ${PKGDESTDIR}/shlib-requires ]; then
|
|
|
|
_shrequires="$(cat ${PKGDESTDIR}/shlib-requires)"
|
|
|
|
fi
|
2014-03-02 08:33:28 +01:00
|
|
|
if [ -s ${wrksrc}/.xbps_${sourcepkg}_git_revs ]; then
|
|
|
|
_gitrevs="$(cat ${wrksrc}/.xbps_${sourcepkg}_git_revs)"
|
|
|
|
fi
|
2014-03-01 12:37:30 +01:00
|
|
|
|
|
|
|
if [ -n "$provides" ]; then
|
|
|
|
local _provides=
|
|
|
|
for f in ${provides}; do
|
|
|
|
_provides="${_provides} ${f}"
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
if [ -n "$conflicts" ]; then
|
|
|
|
local _conflicts=
|
|
|
|
for f in ${conflicts}; do
|
|
|
|
_conflicts="${_conflicts} ${f}"
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
if [ -n "$replaces" ]; then
|
|
|
|
local _replaces=
|
|
|
|
for f in ${replaces}; do
|
|
|
|
_replaces="${_replaces} ${f}"
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
if [ -n "$mutable_files" ]; then
|
|
|
|
local _mutable_files=
|
|
|
|
for f in ${mutable_files}; do
|
|
|
|
_mutable_files="${_mutable_files} ${f}"
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
if [ -n "$conf_files" ]; then
|
|
|
|
local _conf_files=
|
|
|
|
for f in ${conf_files}; do
|
|
|
|
_conf_files="${_conf_files} ${f}"
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
2014-05-05 10:59:33 +02:00
|
|
|
msg_normal "Creating $binpkg for repository $pkgdir ...\n"
|
2014-03-01 12:37:30 +01:00
|
|
|
|
|
|
|
#
|
|
|
|
# Create the XBPS binary package.
|
|
|
|
#
|
|
|
|
xbps-create \
|
|
|
|
--architecture ${arch} \
|
|
|
|
--provides "${_provides}" \
|
|
|
|
--conflicts "${_conflicts}" \
|
|
|
|
--replaces "${_replaces}" \
|
|
|
|
--mutable-files "${_mutable_files}" \
|
|
|
|
--dependencies "${_deps}" \
|
|
|
|
--config-files "${_conf_files}" \
|
|
|
|
--homepage "${homepage}" \
|
|
|
|
--license "${license}" \
|
|
|
|
--maintainer "${maintainer}" \
|
2014-03-02 07:07:59 +01:00
|
|
|
--desc "${desc}" \
|
2014-03-01 12:37:30 +01:00
|
|
|
--built-with "xbps-src-${XBPS_SRC_VERSION}" \
|
|
|
|
--build-options "${PKG_BUILD_OPTIONS}" \
|
2014-06-06 20:51:47 +02:00
|
|
|
--pkgver "${pkgver}" --tags "${tags}" --quiet \
|
2014-03-02 08:33:28 +01:00
|
|
|
--source-revisions "${_gitrevs}" \
|
2014-03-01 12:37:30 +01:00
|
|
|
--shlib-provides "${_shprovides}" \
|
|
|
|
--shlib-requires "${_shrequires}" \
|
|
|
|
${_preserve} ${_sourcerevs} ${PKGDESTDIR}
|
|
|
|
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 06:30:25 +01:00
|
|
|
|
|
|
|
hook() {
|
2014-07-23 15:19:16 +02:00
|
|
|
local arch= binpkg= repo= _pkgver= _desc= _pkgn= _pkgv= _provides= _replaces=
|
2014-03-02 07:07:59 +01:00
|
|
|
|
|
|
|
if [ -n "$noarch" ]; then
|
|
|
|
arch=noarch
|
|
|
|
elif [ -n "$XBPS_TARGET_MACHINE" ]; then
|
|
|
|
arch=$XBPS_TARGET_MACHINE
|
|
|
|
else
|
|
|
|
arch=$XBPS_MACHINE
|
|
|
|
fi
|
2014-04-28 15:08:44 +02:00
|
|
|
if [ -z "$noarch" -a -z "$XBPS_CROSS_BUILD" -a -n "$XBPS_ARCH" -a "$XBPS_ARCH" != "$XBPS_TARGET_MACHINE" ]; then
|
2014-03-02 07:07:59 +01:00
|
|
|
arch=${XBPS_ARCH}
|
|
|
|
fi
|
|
|
|
|
|
|
|
binpkg=${pkgver}.${arch}.xbps
|
|
|
|
|
|
|
|
if [ -n "$nonfree" ]; then
|
|
|
|
repo=$XBPS_REPOSITORY/nonfree
|
|
|
|
else
|
|
|
|
repo=$XBPS_REPOSITORY
|
|
|
|
fi
|
|
|
|
|
|
|
|
genpkg ${repo} ${arch} "${short_desc}" ${pkgver} ${binpkg}
|
2014-03-02 06:30:25 +01:00
|
|
|
|
2014-07-23 15:23:18 +02: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 09:21:04 +02: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 15:23:18 +02:00
|
|
|
|
2014-03-02 06:30:25 +01:00
|
|
|
# Generate -dbg pkg.
|
2014-03-02 07:07:59 +01:00
|
|
|
if [ -d "${XBPS_DESTDIR}/${XBPS_CROSS_TRIPLET}/${pkgname}-dbg-${version}" ]; then
|
2014-06-06 20:51:47 +02:00
|
|
|
source ${XBPS_COMMONDIR}/environment/setup-subpkg/subpkg.sh
|
2014-05-05 10:59:33 +02:00
|
|
|
repo=$XBPS_REPOSITORY/debug
|
2014-03-02 07:07:59 +01: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 06:30:25 +01:00
|
|
|
fi
|
2014-03-02 12:26:24 +01:00
|
|
|
# Generate 32bit pkg.
|
2014-03-07 10:12:20 +01:00
|
|
|
if [ "$XBPS_TARGET_MACHINE" != "i686" ]; then
|
|
|
|
return
|
|
|
|
fi
|
2014-03-06 21:03:23 +01:00
|
|
|
if [ -d "${XBPS_DESTDIR}/${pkgname}-32bit-${version}" ]; then
|
2014-06-06 20:51:47 +02:00
|
|
|
source ${XBPS_COMMONDIR}/environment/setup-subpkg/subpkg.sh
|
2014-05-05 10:59:33 +02:00
|
|
|
if [ -n "$nonfree" ]; then
|
|
|
|
repo=$XBPS_REPOSITORY/multilib/nonfree
|
|
|
|
else
|
|
|
|
repo=$XBPS_REPOSITORY/multilib
|
|
|
|
fi
|
2014-03-06 21:03:23 +01:00
|
|
|
_pkgver=${pkgname}-32bit-${version}_${revision}
|
2014-03-02 12:26:24 +01:00
|
|
|
_desc="${short_desc} (32bit)"
|
|
|
|
binpkg=${_pkgver}.x86_64.xbps
|
2014-03-06 21:03:23 +01:00
|
|
|
PKGDESTDIR="${XBPS_DESTDIR}/${pkgname}-32bit-${version}"
|
2014-07-23 13:07:46 +02:00
|
|
|
[ -n "${_provides}" ] && export provides="${_provides}"
|
2014-08-22 09:21:04 +02:00
|
|
|
[ -n "${_replaces}" ] && export replaces="${_replaces}"
|
2014-03-02 12:26:24 +01:00
|
|
|
genpkg ${repo} x86_64 "${_desc}" ${_pkgver} ${binpkg}
|
|
|
|
fi
|
2014-03-02 06:30:25 +01:00
|
|
|
}
|