From 04a0248ef19e7d918dcb426429e8684bf038f6fa Mon Sep 17 00:00:00 2001 From: Juan RP Date: Fri, 20 Feb 2009 06:25:35 +0100 Subject: [PATCH] Add support to install/remove subpkgs independently of its sourcepkg. --HG-- extra : convert_revision : 5495fb6558fa71dd843f54981313df233236ac50 --- shutils/binpkg.sh | 14 ++++++++++++++ shutils/install_funcs.sh | 14 +++++++++++++- shutils/pkgtarget_funcs.sh | 13 ++++++++++--- shutils/stow_funcs.sh | 34 +++++++++++++++++++++++++--------- 4 files changed, 62 insertions(+), 13 deletions(-) diff --git a/shutils/binpkg.sh b/shutils/binpkg.sh index 4fef1c56dd..bc4e5964db 100644 --- a/shutils/binpkg.sh +++ b/shutils/binpkg.sh @@ -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}/* diff --git a/shutils/install_funcs.sh b/shutils/install_funcs.sh index 7f7dc7594e..bdec534096 100644 --- a/shutils/install_funcs.sh +++ b/shutils/install_funcs.sh @@ -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} diff --git a/shutils/pkgtarget_funcs.sh b/shutils/pkgtarget_funcs.sh index 659fa1c6a2..ac56c520db 100644 --- a/shutils/pkgtarget_funcs.sh +++ b/shutils/pkgtarget_funcs.sh @@ -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." diff --git a/shutils/stow_funcs.sh b/shutils/stow_funcs.sh index 810a957693..c427fea964 100644 --- a/shutils/stow_funcs.sh +++ b/shutils/stow_funcs.sh @@ -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 $? }