xbps-src: reorganize code in more sections.

This commit is contained in:
Juan RP 2014-09-05 11:10:07 +02:00
parent a078049b40
commit 13c2ca3bd2
11 changed files with 192 additions and 179 deletions

View File

@ -14,7 +14,9 @@ fi
PKGNAME="$1"
XBPS_CROSS_BUILD="$2"
. $XBPS_SHUTILSDIR/common.sh
for f in $XBPS_SHUTILSDIR/*.sh; do
. $f
done
setup_pkg "$PKGNAME" $XBPS_CROSS_BUILD

View File

@ -14,7 +14,9 @@ fi
PKGNAME="$1"
XBPS_CROSS_BUILD="$2"
. $XBPS_SHUTILSDIR/common.sh
for f in $XBPS_SHUTILSDIR/*.sh; do
. $f
done
setup_pkg "$PKGNAME" $XBPS_CROSS_BUILD

View File

@ -14,7 +14,9 @@ fi
PKGNAME="$1"
XBPS_CROSS_BUILD="$2"
. $XBPS_SHUTILSDIR/common.sh
for f in $XBPS_SHUTILSDIR/*.sh; do
. $f
done
setup_pkg "$PKGNAME" $XBPS_CROSS_BUILD

View File

@ -14,7 +14,9 @@ fi
PKGNAME="$1"
XBPS_CROSS_BUILD="$2"
. $XBPS_SHUTILSDIR/common.sh
for f in $XBPS_SHUTILSDIR/*.sh; do
. $f
done
setup_pkg "$PKGNAME" $XBPS_CROSS_BUILD

View File

@ -14,7 +14,9 @@ fi
PKGNAME="$1"
XBPS_CROSS_BUILD="$2"
. $XBPS_SHUTILSDIR/common.sh
for f in $XBPS_SHUTILSDIR/*.sh; do
. $f
done
setup_pkg "$PKGNAME" $XBPS_CROSS_BUILD

View File

@ -16,7 +16,9 @@ PKGNAME="$1"
XBPS_REPOSITORY="$2"
XBPS_CROSS_BUILD="$3"
. $XBPS_SHUTILSDIR/common.sh
for f in $XBPS_SHUTILSDIR/*.sh; do
. $f
done
setup_pkg "$PKGNAME" $XBPS_CROSS_BUILD

View File

@ -14,7 +14,9 @@ fi
PKGNAME="$1"
XBPS_CROSS_BUILD="$2"
. $XBPS_SHUTILSDIR/common.sh
for f in $XBPS_SHUTILSDIR/*.sh; do
. $f
done
setup_pkg "$PKGNAME" $XBPS_CROSS_BUILD

View File

@ -1,5 +1,62 @@
# vim: set ts=4 sw=4 et:
#
setup_pkg_depends() {
local pkg="$1" j _pkgdepname _pkgdep _rpkgname _depname
if [ -n "$pkg" ]; then
# subpkg
if declare -f ${pkg}_package >/dev/null; then
${pkg}_package
fi
fi
for j in ${depends}; do
_rpkgname="${j%\?*}"
_depname="${j#*\?}"
_pkgdepname="$($XBPS_UHELPER_CMD getpkgdepname ${_depname} 2>/dev/null)"
if [ -z "${_pkgdepname}" ]; then
_pkgdepname="$($XBPS_UHELPER_CMD getpkgname ${_depname} 2>/dev/null)"
fi
if [ -z "${_pkgdepname}" ]; then
_pkgdep="${_depname}>=0"
else
_pkgdep="${_depname}"
fi
if [ "${_rpkgname}" = "virtual" ]; then
run_depends+=" virtual?${_pkgdep}"
else
run_depends+=" ${_pkgdep}"
fi
done
for j in ${hostmakedepends}; do
_depname="${j%\?*}"
_pkgdepname="$($XBPS_UHELPER_CMD getpkgdepname ${_depname} 2>/dev/null)"
if [ -z "${_pkgdepname}" ]; then
_pkgdepname="$($XBPS_UHELPER_CMD getpkgname ${_depname} 2>/dev/null)"
fi
if [ -z "${_pkgdepname}" ]; then
_pkgdep="${_depname}>=0"
else
_pkgdep="${_depname}"
fi
host_build_depends+=" ${_pkgdep}"
done
for j in ${makedepends}; do
_depname="${j%\?*}"
_pkgdepname="$($XBPS_UHELPER_CMD getpkgdepname ${_depname} 2>/dev/null)"
if [ -z "${_pkgdepname}" ]; then
_pkgdepname="$($XBPS_UHELPER_CMD getpkgname ${_depname} 2>/dev/null)"
fi
if [ -z "${_pkgdepname}" ]; then
_pkgdep="${_depname}>=0"
else
_pkgdep="${_depname}"
fi
build_depends+=" ${_pkgdep}"
done
}
# Install a required package dependency, like:
#
# xbps-install -Ay <pkgname>

View File

@ -282,8 +282,6 @@ setup_pkg() {
fi
done
. ${XBPS_SHUTILSDIR}/build_dependencies.sh
# Check if base-chroot is already installed.
if [ -z "$bootstrap" ]; then
check_installed_pkg base-chroot-0.1_1
@ -396,173 +394,3 @@ setup_pkg() {
exit 0
fi
}
setup_pkg_depends() {
local pkg="$1" j _pkgdepname _pkgdep _rpkgname _depname
if [ -n "$pkg" ]; then
# subpkg
if declare -f ${pkg}_package >/dev/null; then
${pkg}_package
fi
fi
for j in ${depends}; do
_rpkgname="${j%\?*}"
_depname="${j#*\?}"
_pkgdepname="$($XBPS_UHELPER_CMD getpkgdepname ${_depname} 2>/dev/null)"
if [ -z "${_pkgdepname}" ]; then
_pkgdepname="$($XBPS_UHELPER_CMD getpkgname ${_depname} 2>/dev/null)"
fi
if [ -z "${_pkgdepname}" ]; then
_pkgdep="${_depname}>=0"
else
_pkgdep="${_depname}"
fi
if [ "${_rpkgname}" = "virtual" ]; then
run_depends+=" virtual?${_pkgdep}"
else
run_depends+=" ${_pkgdep}"
fi
done
for j in ${hostmakedepends}; do
_depname="${j%\?*}"
_pkgdepname="$($XBPS_UHELPER_CMD getpkgdepname ${_depname} 2>/dev/null)"
if [ -z "${_pkgdepname}" ]; then
_pkgdepname="$($XBPS_UHELPER_CMD getpkgname ${_depname} 2>/dev/null)"
fi
if [ -z "${_pkgdepname}" ]; then
_pkgdep="${_depname}>=0"
else
_pkgdep="${_depname}"
fi
host_build_depends+=" ${_pkgdep}"
done
for j in ${makedepends}; do
_depname="${j%\?*}"
_pkgdepname="$($XBPS_UHELPER_CMD getpkgdepname ${_depname} 2>/dev/null)"
if [ -z "${_pkgdepname}" ]; then
_pkgdepname="$($XBPS_UHELPER_CMD getpkgname ${_depname} 2>/dev/null)"
fi
if [ -z "${_pkgdepname}" ]; then
_pkgdep="${_depname}>=0"
else
_pkgdep="${_depname}"
fi
build_depends+=" ${_pkgdep}"
done
}
_remove_pkg_cross_deps() {
local rval= tmplogf=
[ -z "$XBPS_CROSS_BUILD" ] && return 0
cd $XBPS_MASTERDIR || return 1
msg_normal "${pkgver:-xbps-src}: removing autocrossdeps, please wait...\n"
tmplogf=$(mktemp)
if [ -z "$XBPS_REMOVE_XCMD" ]; then
source_file $XBPS_CROSSPFDIR/${XBPS_CROSS_BUILD}.sh
XBPS_REMOVE_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_ARCH xbps-remove -r /usr/$XBPS_CROSS_TRIPLET"
fi
$FAKEROOT_CMD $XBPS_REMOVE_XCMD -Ryo > $tmplogf 2>&1
if [ $? -ne 0 ]; then
msg_red "${pkgver:-xbps-src}: failed to remove autocrossdeps:\n"
cat $tmplogf && rm -f $tmplogf
msg_error "${pkgver:-xbps-src}: cannot continue!\n"
fi
rm -f $tmplogf
}
remove_pkg_autodeps() {
local rval= tmplogf=
cd $XBPS_MASTERDIR || return 1
msg_normal "${pkgver:-xbps-src}: removing autodeps, please wait...\n"
tmplogf=$(mktemp)
if [ -z "$CHROOT_READY" ]; then
$FAKEROOT_CMD xbps-reconfigure -r $XBPS_MASTERDIR -a >> $tmplogf 2>&1
$FAKEROOT_CMD xbps-remove -r $XBPS_MASTERDIR -Ryo >> $tmplogf 2>&1
else
_remove_pkg_cross_deps
$FAKEROOT_CMD xbps-reconfigure -a >> $tmplogf 2>&1
$FAKEROOT_CMD xbps-remove -Ryo >> $tmplogf 2>&1
fi
if [ $? -ne 0 ]; then
msg_red "${pkgver:-xbps-src}: failed to remove autodeps:\n"
cat $tmplogf && rm -f $tmplogf
msg_error "${pkgver:-xbps-src}: cannot continue!\n"
fi
rm -f $tmplogf
}
install_cross_pkg() {
local cross="$1" rval errlog
[ -z "$cross" -o "$cross" = "" ] && return 0
source_file ${XBPS_CROSSPFDIR}/${cross}.sh
if [ -z "$CHROOT_READY" ]; then
echo "ERROR: chroot mode not activated (install a bootstrap)."
exit 1
elif [ -z "$IN_CHROOT" ]; then
return 0
fi
# Install required pkgs for cross building.
if [ "$XBPS_TARGET" != "remove-autodeps" ]; then
errlog=$(mktemp)
check_installed_pkg cross-${XBPS_CROSS_TRIPLET}-0.1_1
if [ $? -ne 0 ]; then
msg_normal "Installing cross pkg: cross-${XBPS_CROSS_TRIPLET} ...\n"
$XBPS_INSTALL_CMD -Syd cross-${XBPS_CROSS_TRIPLET} &>$errlog
rval=$?
if [ $rval -ne 0 -a $rval -ne 17 ]; then
msg_red "failed to install cross-${XBPS_CROSS_TRIPLET} (error $rval)\n"
cat $errlog
rm -f $errlog
msg_error "cannot continue due to errors above\n"
fi
fi
if [ ! -d ${XBPS_CROSS_BASE}/var/db/xbps/keys ]; then
mkdir -p ${XBPS_CROSS_BASE}/var/db/xbps/keys
cp ${XBPS_MASTERDIR}/var/db/xbps/keys/*.plist \
${XBPS_CROSS_BASE}/var/db/xbps/keys
fi
$XBPS_INSTALL_CMD -r ${XBPS_CROSS_BASE} -SAyd cross-vpkg-dummy &>$errlog
rval=$?
if [ $rval -ne 0 -a $rval -ne 17 ]; then
msg_red "failed to install cross-vpkg-dummy (error $rval)\n"
cat $errlog
rm -f $errlog
msg_error "cannot continue due to errors above\n"
fi
fi
}
remove_cross_pkg() {
local cross="$1" rval
[ -z "$cross" -o "$cross" = "" ] && return 0
source_file ${XBPS_CROSSPFDIR}/${cross}.sh
if [ -z "$CHROOT_READY" ]; then
echo "ERROR: chroot mode not activated (install a bootstrap)."
exit 1
elif [ -z "$IN_CHROOT" ]; then
return 0
fi
msg_normal "Removing cross pkg: cross-${XBPS_CROSS_TRIPLET} ...\n"
$XBPS_REMOVE_CMD -Ry cross-${XBPS_CROSS_TRIPLET} &>/dev/null
rval=$?
if [ $rval -ne 0 ]; then
msg_error "failed to remove cross-${XBPS_CROSS_TRIPLET} (error $rval)\n"
fi
}

View File

@ -0,0 +1,90 @@
# vim: set ts=4 sw=4 et:
remove_pkg_cross_deps() {
local rval= tmplogf=
[ -z "$XBPS_CROSS_BUILD" ] && return 0
cd $XBPS_MASTERDIR || return 1
msg_normal "${pkgver:-xbps-src}: removing autocrossdeps, please wait...\n"
tmplogf=$(mktemp)
if [ -z "$XBPS_REMOVE_XCMD" ]; then
source_file $XBPS_CROSSPFDIR/${XBPS_CROSS_BUILD}.sh
XBPS_REMOVE_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_ARCH xbps-remove -r /usr/$XBPS_CROSS_TRIPLET"
fi
$FAKEROOT_CMD $XBPS_REMOVE_XCMD -Ryo > $tmplogf 2>&1
if [ $? -ne 0 ]; then
msg_red "${pkgver:-xbps-src}: failed to remove autocrossdeps:\n"
cat $tmplogf && rm -f $tmplogf
msg_error "${pkgver:-xbps-src}: cannot continue!\n"
fi
rm -f $tmplogf
}
install_cross_pkg() {
local cross="$1" rval errlog
[ -z "$cross" -o "$cross" = "" ] && return 0
source_file ${XBPS_CROSSPFDIR}/${cross}.sh
if [ -z "$CHROOT_READY" ]; then
echo "ERROR: chroot mode not activated (install a bootstrap)."
exit 1
elif [ -z "$IN_CHROOT" ]; then
return 0
fi
# Install required pkgs for cross building.
if [ "$XBPS_TARGET" != "remove-autodeps" ]; then
errlog=$(mktemp)
check_installed_pkg cross-${XBPS_CROSS_TRIPLET}-0.1_1
if [ $? -ne 0 ]; then
msg_normal "Installing cross pkg: cross-${XBPS_CROSS_TRIPLET} ...\n"
$XBPS_INSTALL_CMD -Syd cross-${XBPS_CROSS_TRIPLET} &>$errlog
rval=$?
if [ $rval -ne 0 -a $rval -ne 17 ]; then
msg_red "failed to install cross-${XBPS_CROSS_TRIPLET} (error $rval)\n"
cat $errlog
rm -f $errlog
msg_error "cannot continue due to errors above\n"
fi
fi
if [ ! -d ${XBPS_CROSS_BASE}/var/db/xbps/keys ]; then
mkdir -p ${XBPS_CROSS_BASE}/var/db/xbps/keys
cp ${XBPS_MASTERDIR}/var/db/xbps/keys/*.plist \
${XBPS_CROSS_BASE}/var/db/xbps/keys
fi
$XBPS_INSTALL_CMD -r ${XBPS_CROSS_BASE} -SAyd cross-vpkg-dummy &>$errlog
rval=$?
if [ $rval -ne 0 -a $rval -ne 17 ]; then
msg_red "failed to install cross-vpkg-dummy (error $rval)\n"
cat $errlog
rm -f $errlog
msg_error "cannot continue due to errors above\n"
fi
fi
}
remove_cross_pkg() {
local cross="$1" rval
[ -z "$cross" -o "$cross" = "" ] && return 0
source_file ${XBPS_CROSSPFDIR}/${cross}.sh
if [ -z "$CHROOT_READY" ]; then
echo "ERROR: chroot mode not activated (install a bootstrap)."
exit 1
elif [ -z "$IN_CHROOT" ]; then
return 0
fi
msg_normal "Removing cross pkg: cross-${XBPS_CROSS_TRIPLET} ...\n"
$XBPS_REMOVE_CMD -Ry cross-${XBPS_CROSS_TRIPLET} &>/dev/null
rval=$?
if [ $rval -ne 0 ]; then
msg_error "failed to remove cross-${XBPS_CROSS_TRIPLET} (error $rval)\n"
fi
}

View File

@ -118,6 +118,30 @@ install_pkg() {
fi
}
remove_pkg_autodeps() {
local rval= tmplogf=
cd $XBPS_MASTERDIR || return 1
msg_normal "${pkgver:-xbps-src}: removing autodeps, please wait...\n"
tmplogf=$(mktemp)
if [ -z "$CHROOT_READY" ]; then
$FAKEROOT_CMD xbps-reconfigure -r $XBPS_MASTERDIR -a >> $tmplogf 2>&1
$FAKEROOT_CMD xbps-remove -r $XBPS_MASTERDIR -Ryo >> $tmplogf 2>&1
else
remove_pkg_cross_deps
$FAKEROOT_CMD xbps-reconfigure -a >> $tmplogf 2>&1
$FAKEROOT_CMD xbps-remove -Ryo >> $tmplogf 2>&1
fi
if [ $? -ne 0 ]; then
msg_red "${pkgver:-xbps-src}: failed to remove autodeps:\n"
cat $tmplogf && rm -f $tmplogf
msg_error "${pkgver:-xbps-src}: cannot continue!\n"
fi
rm -f $tmplogf
}
remove_pkg_wrksrc() {
if [ -d "$wrksrc" ]; then
msg_normal "$pkgver: cleaning build directory...\n"