void-packages/xbps-src/shutils/stow_funcs.sh
Juan RP 1ebe5e6b5e Mega-commit removing deps in xbps-base-chroot.
xbps-src:
  * ALWAYS use the static bins, to avoid breakage in the chroot.
  * Remove XBPS_FETCH_CMD. Use xbps-fetch (static) now that it's
    useful to download all distfiles in xbps-base-system.
  * Use busybox in the chroot and create links in /usr/local/bin
    at creation time. This helps to remove many packages that
    had problems with host/target libs (acl, attr, libarchive, etc).

build templates:
  * Add explicit gettext and texinfo build dependencies in all
    packages that need them, because they aren't built anymore
    by xbps-base-chroot.
  * Fixed some packages using build_style=gnu_makefile, that were
    broken because pre/post_configure() is not executed for a while,
    they should use pre/post_build() instead.

--HG--
extra : convert_revision : 0eaaf4917fd824710d0895e0c984bbc236b0cdf8
2009-10-30 22:14:09 +01:00

170 lines
4.4 KiB
Bash

#-
# Copyright (c) 2008-2009 Juan Romero Pardines.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#-
. ${XBPS_SHUTILSDIR}/builddep_funcs.sh
stow_pkg()
{
local pkg="$1"
local subpkg spkgrev
for subpkg in ${subpackages}; do
if [ "${pkg}" != "${sourcepkg}" ] && \
[ "${pkg}" != "${sourcepkg}-${subpkg}" ]; then
continue
fi
if [ -n "$revision" ]; then
spkgrev="${sourcepkg}-${subpkg}-${version}_${revision}"
else
spkgrev="${sourcepkg}-${subpkg}-${version}"
fi
check_installed_pkg ${spkgrev}
[ $? -eq 0 ] && continue
if [ ! -f $XBPS_TEMPLATESDIR/${sourcepkg}/${subpkg}.template ]; then
msg_error "Cannot find subpackage template!"
fi
unset revision
. $XBPS_TEMPLATESDIR/${sourcepkg}/${subpkg}.template
pkgname=${sourcepkg}-${subpkg}
set_tmpl_common_vars
stow_pkg_real ${pkgname}
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/${spkgrev}
return $?
fi
done
stow_pkg_real ${pkg} ${automatic}
return $?
}
#
# Stow a package, i.e copy files from destdir into masterdir
# and register pkg into the package database.
#
stow_pkg_real()
{
local pkg="$1"
local i lver regpkgdb_flags
[ -z "$pkg" ] && return 2
if [ $(id -u) -ne 0 ] && [ ! -w $XBPS_MASTERDIR ]; then
msg_error "cannot stow $pkg! (permission denied)"
fi
if [ "$build_style" = "meta-template" ]; then
[ ! -d ${DESTDIR} ] && mkdir -p ${DESTDIR}
fi
[ -n "$stow_flag" ] && run_template $pkg
cd ${DESTDIR} || exit 1
# Copy files into masterdir.
for i in $(echo *); do
if [ "$i" = "INSTALL" -o "$i" = "REMOVE" -o \
"$i" = "files.plist" -o "$i" = "props.plist" ]; then
continue
fi
cp -a ${i} $XBPS_MASTERDIR
done
#
# Register pkg in plist file.
#
if [ -n "$revision" ]; then
lver="${version}_${revision}"
else
lver="${version}"
fi
$XBPS_PKGDB_CMD register $pkg $lver "$short_desc" || exit 1
return $?
}
#
# Unstow a package, i.e remove its files from masterdir and
# unregister pkg from package database.
#
unstow_pkg()
{
local f ver pkg="$1"
[ -z $pkg ] && msg_error "template wasn't specified?"
if [ $(id -u) -ne 0 ] && \
[ ! -w $XBPS_MASTERDIR ]; then
msg_error "cannot unstow $pkg! (permission denied)"
fi
run_template $pkg
ver=$($XBPS_PKGDB_CMD version $pkg)
if [ -z "$ver" ]; then
msg_error "$pkg is not installed."
fi
cd $XBPS_PKGMETADIR/$pkg || exit 1
if [ "$build_style" = "meta-template" ]; then
# If it's a metapkg, do nothing.
:
elif [ ! -f flist ]; then
msg_error "$pkg is incomplete, missing flist."
elif [ ! -w flist ]; then
msg_error "$pkg cannot be removed (permission denied)."
elif [ -s flist ]; then
# Remove installed files.
for f in $(cat flist); do
if [ -f $XBPS_MASTERDIR/$f -o -h $XBPS_MASTERDIR/$f ]; then
rm $XBPS_MASTERDIR/$f >/dev/null 2>&1
if [ $? -eq 0 ]; then
echo "Removing file: $f"
fi
fi
done
for f in $(cat flist); do
if [ -d $XBPS_MASTERDIR/$f ]; then
rmdir $XBPS_MASTERDIR/$f >/dev/null 2>&1
if [ $? -eq 0 ]; then
echo "Removing directory: $f"
fi
fi
done
fi
# Remove metadata dir.
rm -rf $XBPS_PKGMETADIR/$pkg
# Unregister pkg from plist file.
$XBPS_PKGDB_CMD unregister $pkg $ver
return $?
}