2009-10-18 11:17:26 +02:00
|
|
|
#-
|
2010-01-14 17:45:41 +01:00
|
|
|
# Copyright (c) 2008-2010 Juan Romero Pardines.
|
2009-10-18 11:17:26 +02:00
|
|
|
# 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}/tmpl_funcs.sh
|
2010-12-18 22:38:21 +01:00
|
|
|
. ${XBPS_SHUTILSDIR}/common_funcs.sh
|
2009-10-18 11:17:26 +02:00
|
|
|
|
|
|
|
#
|
|
|
|
# Installs a pkg by reading its build template file.
|
|
|
|
#
|
|
|
|
install_pkg()
|
|
|
|
{
|
2009-11-26 23:33:45 +01:00
|
|
|
local curpkgn="$1" fullpkg pkg cdestdir
|
2009-10-18 11:17:26 +02:00
|
|
|
|
|
|
|
#
|
|
|
|
# If we are being invoked through the chroot, re-read config file
|
|
|
|
# to get correct stuff.
|
|
|
|
#
|
|
|
|
if [ -n "$in_chroot" ]; then
|
|
|
|
check_config_vars
|
|
|
|
set_defvars
|
|
|
|
fi
|
|
|
|
|
|
|
|
pkg="$curpkgn-$version"
|
2010-05-26 15:41:26 +02:00
|
|
|
[ -n "$doing_deps" ] && setup_tmpl $curpkgn
|
2009-10-18 11:17:26 +02:00
|
|
|
|
2009-11-26 23:33:45 +01:00
|
|
|
#
|
|
|
|
# Refuse to install the same package that is already installed.
|
|
|
|
#
|
|
|
|
. $XBPS_SHUTILSDIR/builddep_funcs.sh
|
|
|
|
check_installed_pkg "$pkg"
|
|
|
|
if [ $? -eq 1 -o $? -eq 0 ]; then
|
2009-11-26 23:59:25 +01:00
|
|
|
instver="$($XBPS_PKGDB_CMD version $pkgname)"
|
|
|
|
if [ -n "$instver" ]; then
|
2010-01-15 00:15:39 +01:00
|
|
|
echo "=> $pkgname-$instver already installed."
|
|
|
|
return 0
|
2009-11-26 23:59:25 +01:00
|
|
|
fi
|
2009-11-26 23:33:45 +01:00
|
|
|
fi
|
|
|
|
|
2009-10-18 11:17:26 +02:00
|
|
|
#
|
|
|
|
# Install dependencies required by this package.
|
|
|
|
#
|
|
|
|
if [ -z "$doing_deps" ]; then
|
2010-05-12 02:16:31 +02:00
|
|
|
install_dependencies_pkg $pkg
|
2010-12-18 22:38:21 +01:00
|
|
|
[ $? -eq 1 ] && return 1
|
2009-10-18 11:17:26 +02:00
|
|
|
#
|
|
|
|
# At this point all required deps are installed, and
|
2009-11-22 08:31:44 +01:00
|
|
|
# only remaining is the origin package; install it.
|
2009-10-18 11:17:26 +02:00
|
|
|
#
|
|
|
|
unset doing_deps
|
|
|
|
setup_tmpl $curpkgn
|
2010-12-20 00:22:12 +01:00
|
|
|
msg_normal "Installing '$pkgname'...\n"
|
2009-10-18 11:17:26 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
#
|
|
|
|
# Fetch, extract, build and install into the destination directory.
|
|
|
|
#
|
|
|
|
. $XBPS_SHUTILSDIR/fetch_funcs.sh
|
|
|
|
fetch_distfiles
|
|
|
|
|
|
|
|
if [ ! -f "$XBPS_EXTRACT_DONE" ]; then
|
|
|
|
. $XBPS_SHUTILSDIR/extract_funcs.sh
|
2010-05-12 17:23:35 +02:00
|
|
|
extract_distfiles
|
|
|
|
if [ $? -ne 0 ]; then
|
2010-12-20 00:22:12 +01:00
|
|
|
msg_red "cannot extract distfiles for '$pkgname'!\n"
|
2010-05-12 17:23:35 +02:00
|
|
|
return 1
|
|
|
|
fi
|
2009-10-18 11:17:26 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! -f "$XBPS_CONFIGURE_DONE" ]; then
|
|
|
|
. $XBPS_SHUTILSDIR/configure_funcs.sh
|
2010-05-12 17:23:35 +02:00
|
|
|
configure_src_phase
|
|
|
|
if [ $? -ne 0 ]; then
|
2010-12-20 00:22:12 +01:00
|
|
|
msg_red "cannot configure '$pkgname'!\n"
|
2010-05-12 17:23:35 +02:00
|
|
|
return 1
|
|
|
|
fi
|
2009-10-18 11:17:26 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! -f "$XBPS_BUILD_DONE" ]; then
|
|
|
|
. $XBPS_SHUTILSDIR/build_funcs.sh
|
2010-05-12 17:23:35 +02:00
|
|
|
build_src_phase
|
|
|
|
if [ $? -ne 0 ]; then
|
2010-12-20 00:22:12 +01:00
|
|
|
msg_red "cannot build '$pkgname'!\n"
|
2010-05-12 17:23:35 +02:00
|
|
|
return 1
|
|
|
|
fi
|
2009-10-18 11:17:26 +02:00
|
|
|
fi
|
|
|
|
|
2010-01-16 02:11:44 +01:00
|
|
|
# Install pkg into destdir.
|
2010-05-08 09:46:23 +02:00
|
|
|
env xbps_machine=${xbps_machine} MASTERDIR=${_MASTERDIR} \
|
2010-12-18 22:38:21 +01:00
|
|
|
wrksrc=${wrksrc} \
|
2010-01-16 02:11:44 +01:00
|
|
|
${fakeroot_cmd} ${fakeroot_cmd_args} \
|
2010-12-18 22:38:21 +01:00
|
|
|
@@XBPS_INSTALL_LIBEXECDIR@@/xbps-src-doinst-helper ${curpkgn}
|
2010-05-12 17:23:35 +02:00
|
|
|
if [ $? -ne 0 ]; then
|
2010-12-20 00:22:12 +01:00
|
|
|
msg_red "xbps-src-doinst-helper failed for '$pkgname'!\n"
|
2010-05-12 17:23:35 +02:00
|
|
|
return 1
|
|
|
|
fi
|
2010-05-26 15:41:26 +02:00
|
|
|
|
|
|
|
# Strip binaries/libraries.
|
|
|
|
if [ -z "$noarch" ]; then
|
|
|
|
. $XBPS_SHUTILSDIR/strip_files.sh
|
|
|
|
strip_files
|
|
|
|
fi
|
2009-10-18 11:17:26 +02:00
|
|
|
|
|
|
|
# Always write metadata to package's destdir.
|
|
|
|
. $XBPS_SHUTILSDIR/metadata.sh
|
2010-12-28 22:55:17 +01:00
|
|
|
trap 'remove_pkgdestdir_sighandler ${pkgname}' INT
|
2010-05-12 17:23:35 +02:00
|
|
|
xbps_write_metadata_pkg
|
|
|
|
if [ $? -ne 0 ]; then
|
2010-12-20 00:22:12 +01:00
|
|
|
msg_red "cannot write package metadata for '$pkgname'!\n"
|
2010-12-28 22:55:17 +01:00
|
|
|
trap - INT
|
2010-05-12 17:23:35 +02:00
|
|
|
return 1
|
|
|
|
fi
|
2010-12-28 22:55:17 +01:00
|
|
|
trap - INT
|
2009-10-18 11:17:26 +02:00
|
|
|
|
2010-05-07 12:25:24 +02:00
|
|
|
[ "$install_destdir_target" = "yes" ] && return 0
|
|
|
|
|
|
|
|
# Stow package into masterdir.
|
|
|
|
. $XBPS_SHUTILSDIR/stow_funcs.sh
|
2010-05-12 17:23:35 +02:00
|
|
|
stow_pkg_handler stow
|
|
|
|
if [ $? -ne 0 ]; then
|
2010-12-20 00:22:12 +01:00
|
|
|
msg_red "cannot stow '$pkgname'!\n"
|
2010-05-12 17:23:35 +02:00
|
|
|
return 1
|
|
|
|
fi
|
2010-12-18 22:38:21 +01:00
|
|
|
|
|
|
|
#
|
|
|
|
# Remove $wrksrc if -C not specified.
|
|
|
|
#
|
|
|
|
if [ -d "$wrksrc" -a "$dontrm_builddir" = "no" ]; then
|
|
|
|
remove_tmpl_wrksrc $wrksrc
|
|
|
|
fi
|
2009-10-18 11:17:26 +02:00
|
|
|
}
|
|
|
|
|
2010-01-14 17:45:41 +01:00
|
|
|
#
|
|
|
|
# Installs a pkg by installing a binary package from
|
|
|
|
# repository pool, matching the pkg pattern.
|
|
|
|
#
|
|
|
|
install_pkg_with_binpkg()
|
|
|
|
{
|
|
|
|
local pkgpattern="$1"
|
|
|
|
|
2010-12-20 00:22:12 +01:00
|
|
|
msg_normal "Installing binary pkg: $pkgpattern\n"
|
2010-01-16 02:11:44 +01:00
|
|
|
${fakeroot_cmd} ${fakeroot_cmd_args} ${XBPS_BIN_CMD} \
|
2010-04-27 23:09:08 +02:00
|
|
|
-y install \""$pkgpattern\""
|
2010-01-14 17:45:41 +01:00
|
|
|
return $?
|
|
|
|
}
|
|
|
|
|
2009-10-18 11:17:26 +02:00
|
|
|
#
|
|
|
|
# Lists files installed by a package.
|
|
|
|
#
|
|
|
|
list_pkg_files()
|
|
|
|
{
|
2009-11-22 08:31:44 +01:00
|
|
|
local pkg="$1" ver=
|
2009-10-18 11:17:26 +02:00
|
|
|
|
2010-12-20 00:22:12 +01:00
|
|
|
[ -z $pkg ] && msg_error "unexistent package, aborting.\n"
|
2009-10-18 11:17:26 +02:00
|
|
|
|
2009-10-30 22:14:09 +01:00
|
|
|
ver=$($XBPS_PKGDB_CMD version $pkg)
|
2010-12-20 00:22:12 +01:00
|
|
|
[ -z "$ver" ] && msg_error "$pkg is not installed.\n"
|
2009-10-18 11:17:26 +02:00
|
|
|
|
|
|
|
cat $XBPS_PKGMETADIR/$pkg/flist
|
|
|
|
}
|
|
|
|
|
|
|
|
#
|
|
|
|
# Removes a currently installed package (unstow + removed from destdir).
|
|
|
|
#
|
|
|
|
remove_pkg()
|
|
|
|
{
|
2009-11-22 08:31:44 +01:00
|
|
|
local subpkg ver
|
2009-10-18 11:17:26 +02:00
|
|
|
|
2010-12-20 00:22:12 +01:00
|
|
|
[ -z $pkgname ] && msg_error "unexistent package, aborting.\n"
|
2009-10-18 11:17:26 +02:00
|
|
|
|
2009-11-22 08:31:44 +01:00
|
|
|
ver=$($XBPS_PKGDB_CMD version $pkgname)
|
2010-12-20 00:22:12 +01:00
|
|
|
[ -z "$ver" ] && msg_error "$pkgname is not installed.\n"
|
2009-11-22 08:31:44 +01:00
|
|
|
|
|
|
|
. $XBPS_SHUTILSDIR/stow_funcs.sh
|
|
|
|
stow_pkg_handler unstow || return $?
|
2009-10-18 11:17:26 +02:00
|
|
|
|
2009-11-22 08:31:44 +01:00
|
|
|
for subpkg in ${subpackages}; do
|
2010-01-09 23:35:11 +01:00
|
|
|
if [ -d "$XBPS_DESTDIR/${subpkg}-${ver%_*}" ]; then
|
|
|
|
rm -rf "$XBPS_DESTDIR/${subpkg}-${ver%_*}"
|
2009-10-18 11:17:26 +02:00
|
|
|
fi
|
2010-12-23 13:14:18 +01:00
|
|
|
# Remove leftover files in $wrksrc.
|
|
|
|
if [ -f "${wrksrc}/.xbps_do_install_${subpkg}_done" ]; then
|
|
|
|
rm -f ${wrksrc}/.xbps_do_install_${subpkg}_done
|
|
|
|
fi
|
2009-10-18 11:17:26 +02:00
|
|
|
done
|
|
|
|
|
2010-01-09 23:35:11 +01:00
|
|
|
if [ -d "$XBPS_DESTDIR/${pkgname}-${ver%_*}" ]; then
|
|
|
|
rm -rf "$XBPS_DESTDIR/${pkgname}-${ver%_*}"
|
2009-10-18 11:17:26 +02:00
|
|
|
fi
|
2010-12-23 13:14:18 +01:00
|
|
|
|
2009-10-18 11:17:26 +02:00
|
|
|
return $?
|
|
|
|
}
|