2009-10-18 11:17:26 +02:00
|
|
|
#-
|
|
|
|
# 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
|
|
|
|
|
2009-11-22 08:31:44 +01:00
|
|
|
stow_pkg_handler()
|
2009-10-18 11:17:26 +02:00
|
|
|
{
|
2009-11-22 08:31:44 +01:00
|
|
|
local action="$1" subpkg spkgrev
|
2009-10-18 11:17:26 +02:00
|
|
|
|
|
|
|
for subpkg in ${subpackages}; do
|
|
|
|
if [ -n "$revision" ]; then
|
2009-11-22 08:31:44 +01:00
|
|
|
spkgrev="${subpkg}-${version}_${revision}"
|
2009-10-18 11:17:26 +02:00
|
|
|
else
|
2009-11-22 08:31:44 +01:00
|
|
|
spkgrev="${subpkg}-${version}"
|
2009-10-18 11:17:26 +02:00
|
|
|
fi
|
2009-11-22 08:31:44 +01:00
|
|
|
if [ "$action" = "stow" ]; then
|
|
|
|
check_installed_pkg ${spkgrev}
|
|
|
|
[ $? -eq 0 ] && continue
|
|
|
|
fi
|
|
|
|
if [ ! -f $XBPS_SRCPKGDIR/${sourcepkg}/${subpkg}.template ]; then
|
|
|
|
msg_error "Cannot find $subpkg subpkg build template!"
|
2009-10-18 11:17:26 +02:00
|
|
|
fi
|
|
|
|
unset revision
|
2009-11-22 08:31:44 +01:00
|
|
|
. $XBPS_SRCPKGDIR/${sourcepkg}/${subpkg}.template
|
|
|
|
pkgname=${subpkg}
|
2009-10-18 11:17:26 +02:00
|
|
|
set_tmpl_common_vars
|
2009-11-22 08:31:44 +01:00
|
|
|
if [ "$action" = "stow" ]; then
|
|
|
|
stow_pkg_real || return $?
|
|
|
|
else
|
|
|
|
unstow_pkg_real || return $?
|
2009-10-18 11:17:26 +02:00
|
|
|
fi
|
2009-11-23 06:30:04 +01:00
|
|
|
setup_tmpl ${sourcepkg}
|
2009-10-18 11:17:26 +02:00
|
|
|
done
|
|
|
|
|
2009-11-22 08:31:44 +01:00
|
|
|
if [ "$action" = "stow" ]; then
|
|
|
|
stow_pkg_real
|
|
|
|
else
|
|
|
|
unstow_pkg_real
|
|
|
|
fi
|
2009-10-18 11:17:26 +02:00
|
|
|
return $?
|
|
|
|
}
|
|
|
|
|
|
|
|
#
|
|
|
|
# Stow a package, i.e copy files from destdir into masterdir
|
|
|
|
# and register pkg into the package database.
|
|
|
|
#
|
|
|
|
stow_pkg_real()
|
|
|
|
{
|
|
|
|
local i lver regpkgdb_flags
|
|
|
|
|
2009-11-22 08:31:44 +01:00
|
|
|
[ -z "$pkgname" ] && return 2
|
2009-10-18 11:17:26 +02:00
|
|
|
|
|
|
|
if [ $(id -u) -ne 0 ] && [ ! -w $XBPS_MASTERDIR ]; then
|
2009-11-22 08:31:44 +01:00
|
|
|
msg_error "cannot stow $pkgname! (permission denied)"
|
2009-10-18 11:17:26 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$build_style" = "meta-template" ]; then
|
|
|
|
[ ! -d ${DESTDIR} ] && mkdir -p ${DESTDIR}
|
|
|
|
fi
|
|
|
|
|
2009-11-23 06:30:04 +01:00
|
|
|
[ -n "$stow_flag" ] && setup_tmpl $pkgname
|
2009-10-18 11:17:26 +02:00
|
|
|
|
|
|
|
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
|
2009-11-22 08:31:44 +01:00
|
|
|
$XBPS_PKGDB_CMD register $pkgname $lver "$short_desc"
|
2009-10-18 11:17:26 +02:00
|
|
|
return $?
|
|
|
|
}
|
|
|
|
|
|
|
|
#
|
|
|
|
# Unstow a package, i.e remove its files from masterdir and
|
|
|
|
# unregister pkg from package database.
|
|
|
|
#
|
2009-11-22 08:31:44 +01:00
|
|
|
unstow_pkg_real()
|
2009-10-18 11:17:26 +02:00
|
|
|
{
|
2009-11-22 08:31:44 +01:00
|
|
|
local f ver
|
2009-10-18 11:17:26 +02:00
|
|
|
|
2009-11-22 08:31:44 +01:00
|
|
|
[ -z $pkgname ] && return 1
|
2009-10-18 11:17:26 +02:00
|
|
|
|
|
|
|
if [ $(id -u) -ne 0 ] && \
|
|
|
|
[ ! -w $XBPS_MASTERDIR ]; then
|
2009-11-22 08:31:44 +01:00
|
|
|
msg_error "cannot unstow $pkgname! (permission denied)"
|
2009-10-18 11:17:26 +02:00
|
|
|
fi
|
|
|
|
|
2009-11-23 06:30:04 +01:00
|
|
|
setup_tmpl $pkgname
|
2009-10-18 11:17:26 +02:00
|
|
|
|
2009-11-22 08:31:44 +01:00
|
|
|
ver=$($XBPS_PKGDB_CMD version $pkgname)
|
2009-10-18 11:17:26 +02:00
|
|
|
if [ -z "$ver" ]; then
|
2009-11-22 08:31:44 +01:00
|
|
|
msg_error "$pkgname is not installed."
|
2009-10-18 11:17:26 +02:00
|
|
|
fi
|
|
|
|
|
2009-11-22 08:31:44 +01:00
|
|
|
cd $XBPS_PKGMETADIR/$pkgname || exit 1
|
2009-10-18 11:17:26 +02:00
|
|
|
if [ "$build_style" = "meta-template" ]; then
|
|
|
|
# If it's a metapkg, do nothing.
|
|
|
|
:
|
|
|
|
elif [ ! -f flist ]; then
|
2009-11-22 08:31:44 +01:00
|
|
|
msg_error "$pkgname is incomplete, missing flist."
|
2009-10-18 11:17:26 +02:00
|
|
|
elif [ ! -w flist ]; then
|
2009-11-22 08:31:44 +01:00
|
|
|
msg_error "$pkgname cannot be removed (permission denied)."
|
2009-10-18 11:17:26 +02:00
|
|
|
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.
|
2009-11-22 08:31:44 +01:00
|
|
|
rm -rf $XBPS_PKGMETADIR/$pkgname
|
2009-10-18 11:17:26 +02:00
|
|
|
|
|
|
|
# Unregister pkg from plist file.
|
2009-11-22 08:31:44 +01:00
|
|
|
$XBPS_PKGDB_CMD unregister $pkgname $ver
|
2009-10-18 11:17:26 +02:00
|
|
|
return $?
|
|
|
|
}
|