Add support to install/remove subpkgs independently of its sourcepkg.

--HG--
extra : convert_revision : 5495fb6558fa71dd843f54981313df233236ac50
This commit is contained in:
Juan RP 2009-02-20 06:25:35 +01:00
parent b225a1dc30
commit 04a0248ef1
4 changed files with 62 additions and 13 deletions

View File

@ -42,15 +42,29 @@ _EOF
xbps_write_metadata_pkg()
{
local pkg="$1"
local subpkg=
for subpkg in ${subpackages}; do
if [ "${pkg}" != "${sourcepkg}" ] && \
[ "${pkg}" != "${sourcepkg}-${subpkg}" ]; then
continue
fi
check_installed_pkg ${sourcepkg}-${subpkg}-${version}
[ $? -eq 0 ] && continue
if [ ! -f $XBPS_TEMPLATESDIR/${sourcepkg}/${subpkg}.template ]; then
msg_error "Cannot find subpackage template!"
fi
. $XBPS_TEMPLATESDIR/${sourcepkg}/${subpkg}.template
pkgname=${sourcepkg}-${subpkg}
xbps_write_metadata_pkg_real
run_template ${sourcepkg}
[ "${pkg}" = "${sourcepkg}-${subpkg}" ] && break
done
[ -n "${subpackages}" ] && [ "$pkg" != "${sourcepkg}" ] && return $?
if [ -n "${subpackages}" ]; then
run_template ${sourcepkg}
rm -rf $XBPS_DESTDIR/${sourcepkg}-${version}/*

View File

@ -32,6 +32,7 @@ install_src_phase()
local pkg="$1"
local f=
local i=
local subpkg=
[ -z $pkg ] && [ -z $pkgname ] && return 1
#
@ -77,11 +78,22 @@ install_src_phase()
# Build subpackages if found.
#
for subpkg in ${subpackages}; do
msg_normal "Preparing $pkgname subpackage: $pkgname-$subpkg"
if [ "${pkg}" != "${sourcepkg}" ] && \
[ "${pkg}" != "${sourcepkg}-${subpkg}" ]; then
continue
fi
check_installed_pkg ${sourcepkg}-${subpkg}-${version}
[ $? -eq 0 ] && continue
msg_normal "Preparing ${sourcepkg} subpackage: $sourcepkg-$subpkg"
if [ ! -f $XBPS_TEMPLATESDIR/$pkgname/$subpkg.template ]; then
msg_error "Cannot find subpackage template!"
fi
. $XBPS_TEMPLATESDIR/$pkgname/$subpkg.template
pkgname=${sourcepkg}-${subpkg}
run_func do_install
run_template ${sourcepkg}
[ "$pkg" = "${sourcepkg}-${subpkg}" ] && break
done
[ -n "$subpackages" ] && setup_tmpl ${sourcepkg}

View File

@ -107,18 +107,18 @@ install_pkg()
fi
. $XBPS_SHUTILSDIR/install_funcs.sh
install_src_phase
install_src_phase $curpkgn
# Always write metadata to package's destdir.
. $XBPS_SHUTILSDIR/binpkg.sh
xbps_write_metadata_pkg
xbps_write_metadata_pkg $curpkgn
#
# Do not stow package if it wasn't requested.
#
if [ -z "$install_destdir_target" ]; then
. $XBPS_SHUTILSDIR/stow_funcs.sh
stow_pkg $pkg $automatic
stow_pkg $curpkgn $automatic
fi
}
@ -144,6 +144,7 @@ list_pkg_files()
remove_pkg()
{
local pkg="$1"
local subpkg=
local ver=
[ -z $pkg ] && msg_error "unexistent package, aborting."
@ -153,6 +154,12 @@ remove_pkg()
fi
. $XBPS_TEMPLATESDIR/$pkg/template
for f in ${subpackages}; do
if [ "$pkg" = "${pkgname}-${f}" ]; then
pkgname=${pkg}
break;
fi
done
ver=$($XBPS_REGPKGDB_CMD version $pkg)
[ -z "$ver" ] && msg_error "$pkg is not installed."

View File

@ -30,10 +30,28 @@ stow_pkg()
local subpkg=
for subpkg in ${subpackages}; do
if [ "${pkg}" != "${sourcepkg}" ] && \
[ "${pkg}" != "${sourcepkg}-${subpkg}" ]; then
continue
fi
check_installed_pkg ${sourcepkg}-${subpkg}-${version}
[ $? -eq 0 ] && continue
if [ ! -f $XBPS_TEMPLATESDIR/${sourcepkg}/${subpkg}.template ]; then
msg_error "Cannot find subpackage template!"
fi
. $XBPS_TEMPLATESDIR/${sourcepkg}/${subpkg}.template
pkgname=${sourcepkg}-${subpkg}
stow_pkg_real ${pkg} ${automatic}
stow_pkg_real ${pkgname} ${automatic}
run_template ${sourcepkg}
if [ "${pkg}" = "${sourcepkg}-${subpkg}" ]; then
#
# If it's a subpackage, just remove sourcepkg from
# destdir and return, we are done.
#
rm -rf $XBPS_DESTDIR/${sourcepkg}-${version}
return $?
fi
done
stow_pkg_real ${pkg} ${automatic}
@ -50,7 +68,7 @@ stow_pkg_real()
local pkg="$1"
local automatic="$2"
local i=
local destdir=$XBPS_DESTDIR/$pkgname-$version
local destdir=$XBPS_DESTDIR/$pkg-$version
[ -z "$pkg" ] && return 2
@ -63,11 +81,9 @@ stow_pkg_real()
fi
if [ -n "$stow_flag" ]; then
pkg=$XBPS_TEMPLATESDIR/$pkg/template
if [ "$pkgname" != "$pkg" ]; then
. $pkg
. $XBPS_TEMPLATESDIR/$pkg/template
fi
pkg=$pkgname-$version
fi
cd $destdir || exit 1
@ -87,7 +103,7 @@ stow_pkg_real()
regpkgdb_flags="-a"
fi
$XBPS_REGPKGDB_CMD $regpkgdb_flags register \
$pkgname $version "$short_desc" || exit 1
$pkg $version "$short_desc" || exit 1
#
# Run template postinstall helpers if requested.
@ -124,7 +140,7 @@ unstow_pkg()
msg_error "$pkg is not installed."
fi
cd $XBPS_PKGMETADIR/$pkgname || exit 1
cd $XBPS_PKGMETADIR/$pkg || exit 1
if [ "$build_style" = "meta-template" ]; then
# If it's a metapkg, do nothing.
:
@ -154,10 +170,10 @@ unstow_pkg()
fi
# Remove metadata dir.
rm -rf $XBPS_PKGMETADIR/$pkgname
rm -rf $XBPS_PKGMETADIR/$pkg
# Unregister pkg from plist file.
$XBPS_REGPKGDB_CMD unregister $pkgname $ver
$XBPS_REGPKGDB_CMD unregister $pkg $ver
return $?
}