2009-10-18 09:17:26 +00:00
|
|
|
#-
|
2011-07-01 15:48:29 +00:00
|
|
|
# Copyright (c) 2008-2011 Juan Romero Pardines.
|
2009-10-18 09:17:26 +00: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.
|
|
|
|
#-
|
|
|
|
|
|
|
|
#
|
|
|
|
# Installs a pkg by reading its build template file.
|
|
|
|
#
|
|
|
|
install_pkg()
|
|
|
|
{
|
2009-11-26 22:33:45 +00:00
|
|
|
local curpkgn="$1" fullpkg pkg cdestdir
|
2009-10-18 09:17:26 +00:00
|
|
|
|
2011-07-04 17:07:08 +00:00
|
|
|
# Remove automatic package dependencies if set.
|
2011-07-04 19:29:11 +00:00
|
|
|
autoremove_pkg_dependencies $KEEP_AUTODEPS
|
2011-07-04 17:07:08 +00:00
|
|
|
|
2009-10-18 09:17:26 +00:00
|
|
|
pkg="$curpkgn-$version"
|
2011-07-01 15:48:29 +00:00
|
|
|
[ -n "$INSTALLING_DEPS" ] && setup_tmpl $curpkgn
|
2009-11-26 22:33:45 +00:00
|
|
|
#
|
|
|
|
# Refuse to install the same package that is already installed.
|
|
|
|
#
|
|
|
|
check_installed_pkg "$pkg"
|
|
|
|
if [ $? -eq 1 -o $? -eq 0 ]; then
|
2009-11-26 22:59:25 +00:00
|
|
|
instver="$($XBPS_PKGDB_CMD version $pkgname)"
|
2011-07-06 06:16:56 +00:00
|
|
|
if [ -n "$instver" -a -z "$DESTDIR_ONLY_INSTALL" ]; then
|
2010-01-14 23:15:39 +00:00
|
|
|
echo "=> $pkgname-$instver already installed."
|
|
|
|
return 0
|
2009-11-26 22:59:25 +00:00
|
|
|
fi
|
2009-11-26 22:33:45 +00:00
|
|
|
fi
|
|
|
|
|
2011-07-04 17:07:08 +00:00
|
|
|
# Always fetch distfiles before installing dependencies if
|
|
|
|
# template doesn't use nofetch and do_fetch().
|
|
|
|
[ -z "$nofetch" ] && fetch_distfiles
|
|
|
|
|
2009-10-18 09:17:26 +00:00
|
|
|
#
|
|
|
|
# Install dependencies required by this package.
|
|
|
|
#
|
2011-07-01 15:48:29 +00:00
|
|
|
if [ -z "$INSTALLING_DEPS" ]; then
|
2011-07-04 17:07:08 +00:00
|
|
|
install_dependencies_pkg $pkg || return $?
|
2009-10-18 09:17:26 +00:00
|
|
|
#
|
|
|
|
# At this point all required deps are installed, and
|
2009-11-22 07:31:44 +00:00
|
|
|
# only remaining is the origin package; install it.
|
2009-10-18 09:17:26 +00:00
|
|
|
#
|
2011-07-01 15:48:29 +00:00
|
|
|
unset INSTALLING_DEPS
|
2009-10-18 09:17:26 +00:00
|
|
|
setup_tmpl $curpkgn
|
2011-07-22 08:13:23 +00:00
|
|
|
msg_normal "$pkgver: starting installation...\n"
|
2009-10-18 09:17:26 +00:00
|
|
|
fi
|
|
|
|
|
2011-07-04 17:07:08 +00:00
|
|
|
# Fetch distfiles after installing required dependencies,
|
|
|
|
# because some of them might be required for do_fetch().
|
|
|
|
[ -n "$nofetch" ] && fetch_distfiles
|
2009-10-18 09:17:26 +00:00
|
|
|
|
2011-07-02 15:04:08 +00:00
|
|
|
#
|
|
|
|
# Fetch, extract, build and install into the destination directory.
|
|
|
|
#
|
2009-10-18 09:17:26 +00:00
|
|
|
if [ ! -f "$XBPS_EXTRACT_DONE" ]; then
|
2011-07-18 11:43:22 +00:00
|
|
|
extract_distfiles || return $?
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Apply patches if requested by template file
|
|
|
|
if [ ! -f $XBPS_APPLYPATCHES_DONE ]; then
|
|
|
|
apply_tmpl_patches || return $?
|
2009-10-18 09:17:26 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! -f "$XBPS_CONFIGURE_DONE" ]; then
|
2011-07-18 11:43:22 +00:00
|
|
|
configure_src_phase || return $?
|
2009-10-18 09:17:26 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! -f "$XBPS_BUILD_DONE" ]; then
|
2011-07-18 11:43:22 +00:00
|
|
|
build_src_phase || return $?
|
2009-10-18 09:17:26 +00:00
|
|
|
fi
|
|
|
|
|
2010-01-16 01:11:44 +00:00
|
|
|
# Install pkg into destdir.
|
2010-05-08 07:46:23 +00:00
|
|
|
env xbps_machine=${xbps_machine} MASTERDIR=${_MASTERDIR} \
|
2010-12-18 21:38:21 +00:00
|
|
|
wrksrc=${wrksrc} \
|
2011-07-06 06:42:02 +00:00
|
|
|
BOOTSTRAP_PKG_REBUILD=$BOOTSTRAP_PKG_REBUILD \
|
2010-01-16 01:11:44 +00:00
|
|
|
${fakeroot_cmd} ${fakeroot_cmd_args} \
|
2011-07-14 11:24:00 +00:00
|
|
|
@@XBPS_INSTALL_LIBEXECDIR@@/doinst-helper \
|
2011-07-04 17:07:08 +00:00
|
|
|
${curpkgn} || return $?
|
2010-05-26 13:41:26 +00:00
|
|
|
|
|
|
|
# Strip binaries/libraries.
|
2011-07-04 17:07:08 +00:00
|
|
|
strip_files
|
2009-10-18 09:17:26 +00:00
|
|
|
|
|
|
|
# Always write metadata to package's destdir.
|
2011-07-04 17:07:08 +00:00
|
|
|
trap 'remove_pkgdestdir_sighandler $pkgname $KEEP_AUTODEPS' INT
|
2010-05-12 15:23:35 +00:00
|
|
|
xbps_write_metadata_pkg
|
|
|
|
if [ $? -ne 0 ]; then
|
2010-12-19 23:22:12 +00:00
|
|
|
msg_red "cannot write package metadata for '$pkgname'!\n"
|
2010-12-28 21:55:17 +00:00
|
|
|
trap - INT
|
2010-05-12 15:23:35 +00:00
|
|
|
return 1
|
|
|
|
fi
|
2010-12-28 21:55:17 +00:00
|
|
|
trap - INT
|
2009-10-18 09:17:26 +00:00
|
|
|
|
2011-07-03 00:56:55 +00:00
|
|
|
# If only installation to destdir, return.
|
|
|
|
if [ -n "$DESTDIR_ONLY_INSTALL" ]; then
|
|
|
|
if [ -d "$wrksrc" -a -z "$KEEP_WRKSRC" ]; then
|
|
|
|
remove_tmpl_wrksrc $wrksrc
|
|
|
|
fi
|
2011-07-06 08:46:36 +00:00
|
|
|
autoremove_pkg_dependencies $KEEP_AUTODEPS
|
2011-07-18 09:36:48 +00:00
|
|
|
# Build binary package and update local repo index if
|
|
|
|
# -B is set.
|
|
|
|
if [ -n "$BUILD_BINPKG" ]; then
|
|
|
|
xbps_make_binpkg
|
2011-07-18 11:43:22 +00:00
|
|
|
rval=$?
|
|
|
|
if [ $rval -ne 0 -a $rval -ne 6 ]; then
|
|
|
|
return $?
|
|
|
|
elif [ $rval -eq 6 ]; then
|
|
|
|
# binpkg exists, no need to update
|
|
|
|
# repo pkg-index.
|
|
|
|
:
|
|
|
|
else
|
|
|
|
msg_normal "Updating pkg-index for local repository at:\n"
|
|
|
|
msg_normal " $XBPS_PACKAGESDIR\n"
|
|
|
|
${XBPS_REPO_CMD} genindex ${XBPS_PACKAGESDIR} 2>/dev/null
|
|
|
|
fi
|
2011-07-18 09:36:48 +00:00
|
|
|
fi
|
2011-07-06 06:16:56 +00:00
|
|
|
return 0
|
2011-07-03 00:56:55 +00:00
|
|
|
fi
|
2010-05-07 10:25:24 +00:00
|
|
|
|
|
|
|
# Stow package into masterdir.
|
2011-07-18 11:43:22 +00:00
|
|
|
stow_pkg_handler stow || return $?
|
2010-12-18 21:38:21 +00:00
|
|
|
|
2011-06-20 16:33:30 +00:00
|
|
|
# Copy generated pkg metadata files into its metadata dir.
|
|
|
|
if [ ! -f ${DESTDIR}/files.plist ]; then
|
|
|
|
msg_error "${pkgname}: missing metadata files.plist!"
|
|
|
|
fi
|
|
|
|
cp -f ${DESTDIR}/files.plist ${XBPS_PKGMETADIR}/${pkgname}
|
|
|
|
if [ ! -f ${DESTDIR}/props.plist ]; then
|
|
|
|
msg_error "${pkgname}: missing metadata props.plist!"
|
|
|
|
fi
|
|
|
|
cp -f ${DESTDIR}/props.plist ${XBPS_PKGMETADIR}/${pkgname}
|
|
|
|
if [ -f ${DESTDIR}/INSTALL ]; then
|
|
|
|
install -m750 ${DESTDIR}/INSTALL \
|
|
|
|
${XBPS_PKGMETADIR}/${pkgname}
|
|
|
|
fi
|
|
|
|
if [ -f ${DESTDIR}/REMOVE ]; then
|
|
|
|
install -m750 ${DESTDIR}/REMOVE \
|
|
|
|
${XBPS_PKGMETADIR}/${pkgname}
|
|
|
|
fi
|
2010-12-18 21:38:21 +00:00
|
|
|
#
|
|
|
|
# Remove $wrksrc if -C not specified.
|
|
|
|
#
|
2011-07-02 20:56:26 +00:00
|
|
|
if [ -d "$wrksrc" -a -z "$KEEP_WRKSRC" ]; then
|
2010-12-18 21:38:21 +00:00
|
|
|
remove_tmpl_wrksrc $wrksrc
|
|
|
|
fi
|
2011-06-20 16:45:29 +00:00
|
|
|
|
2011-07-01 15:48:29 +00:00
|
|
|
#
|
|
|
|
# Autoremove packages installed as dependencies if
|
|
|
|
# XBPS_PREFER_BINPKG_DEPS is set.
|
|
|
|
#
|
2011-07-18 09:36:48 +00:00
|
|
|
autoremove_pkg_dependencies $KEEP_AUTODEPS || return $?
|
|
|
|
|
|
|
|
# Build binary package and update local repo index if
|
|
|
|
# -B is set.
|
|
|
|
if [ -n "$BUILD_BINPKG" ]; then
|
|
|
|
xbps_make_binpkg
|
2011-07-18 11:43:22 +00:00
|
|
|
rval=$?
|
|
|
|
if [ "$rval" -ne 0 -a "$rval" -ne 6 ]; then
|
|
|
|
return $rval
|
|
|
|
elif [ "$rval" -eq 6 ]; then
|
|
|
|
# binpkg exists no need to update pkg-index in repo.
|
|
|
|
:
|
|
|
|
else
|
|
|
|
msg_normal "Updating pkg-index for local repository at:\n"
|
|
|
|
msg_normal " $XBPS_PACKAGESDIR\n"
|
|
|
|
${XBPS_REPO_CMD} genindex ${XBPS_PACKAGESDIR} 2>/dev/null
|
|
|
|
fi
|
2011-07-18 09:36:48 +00:00
|
|
|
fi
|
2009-10-18 09:17:26 +00:00
|
|
|
|
2010-01-14 16:45:41 +00:00
|
|
|
return $?
|
|
|
|
}
|
|
|
|
|
2009-10-18 09:17:26 +00:00
|
|
|
#
|
|
|
|
# Lists files installed by a package.
|
|
|
|
#
|
|
|
|
list_pkg_files()
|
|
|
|
{
|
2009-11-22 07:31:44 +00:00
|
|
|
local pkg="$1" ver=
|
2009-10-18 09:17:26 +00:00
|
|
|
|
2010-12-19 23:22:12 +00:00
|
|
|
[ -z $pkg ] && msg_error "unexistent package, aborting.\n"
|
2009-10-18 09:17:26 +00:00
|
|
|
|
2009-10-30 21:14:09 +00:00
|
|
|
ver=$($XBPS_PKGDB_CMD version $pkg)
|
2011-07-03 10:22:29 +00:00
|
|
|
if [ -z "$ver" ]; then
|
|
|
|
msg_warn "$pkg is not installed.\n"
|
|
|
|
return 1
|
|
|
|
fi
|
2009-10-18 09:17:26 +00:00
|
|
|
|
|
|
|
cat $XBPS_PKGMETADIR/$pkg/flist
|
|
|
|
}
|
|
|
|
|
|
|
|
#
|
|
|
|
# Removes a currently installed package (unstow + removed from destdir).
|
|
|
|
#
|
|
|
|
remove_pkg()
|
|
|
|
{
|
2011-07-06 09:27:57 +00:00
|
|
|
local subpkg found pkg
|
2009-10-18 09:17:26 +00:00
|
|
|
|
2010-12-19 23:22:12 +00:00
|
|
|
[ -z $pkgname ] && msg_error "unexistent package, aborting.\n"
|
2009-10-18 09:17:26 +00:00
|
|
|
|
2009-11-22 07:31:44 +00:00
|
|
|
for subpkg in ${subpackages}; do
|
2011-07-06 09:27:57 +00:00
|
|
|
. ${XBPS_SRCPKGDIR}/${sourcepkg}/${subpkg}.template
|
|
|
|
set_tmpl_common_vars
|
|
|
|
pkg="${subpkg}-${version}"
|
|
|
|
if [ -d "$XBPS_DESTDIR/${pkg}" ]; then
|
|
|
|
msg_normal "'${pkg}': removing files from destdir...\n"
|
|
|
|
rm -rf "$XBPS_DESTDIR/${pkg}"
|
2011-07-05 07:23:29 +00:00
|
|
|
found=1
|
2011-07-06 09:27:57 +00:00
|
|
|
else
|
|
|
|
msg_warn "'${pkg}' not installed in destdir!\n"
|
2009-10-18 09:17:26 +00:00
|
|
|
fi
|
2010-12-23 12:14:18 +00:00
|
|
|
# Remove leftover files in $wrksrc.
|
|
|
|
if [ -f "${wrksrc}/.xbps_do_install_${subpkg}_done" ]; then
|
|
|
|
rm -f ${wrksrc}/.xbps_do_install_${subpkg}_done
|
2011-07-05 07:23:29 +00:00
|
|
|
found=1
|
2010-12-23 12:14:18 +00:00
|
|
|
fi
|
2009-10-18 09:17:26 +00:00
|
|
|
done
|
|
|
|
|
2011-07-06 09:27:57 +00:00
|
|
|
pkg="${pkgname}-${version}"
|
|
|
|
if [ -d "$XBPS_DESTDIR/${pkg}" ]; then
|
|
|
|
msg_normal "'${pkg}': removing files from destdir...\n"
|
|
|
|
rm -rf "$XBPS_DESTDIR/${pkg}"
|
2011-07-05 07:23:29 +00:00
|
|
|
found=1
|
2009-10-18 09:17:26 +00:00
|
|
|
fi
|
2011-04-12 08:03:24 +00:00
|
|
|
|
2011-06-30 08:23:48 +00:00
|
|
|
[ -f $XBPS_PRE_INSTALL_DONE ] && rm -f $XBPS_PRE_INSTALL_DONE
|
|
|
|
[ -f $XBPS_POST_INSTALL_DONE ] && rm -f $XBPS_POST_INSTALL_DONE
|
|
|
|
[ -f $XBPS_INSTALL_DONE ] && rm -f $XBPS_INSTALL_DONE
|
2011-04-12 08:03:24 +00:00
|
|
|
|
2011-07-06 09:27:57 +00:00
|
|
|
if [ -n "$DESTDIR_ONLY_INSTALL" ]; then
|
|
|
|
if [ -n "$found" ]; then
|
|
|
|
return 0
|
|
|
|
else
|
|
|
|
msg_warn "'${pkg}' not installed in destdir!\n"
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2011-07-06 06:16:56 +00:00
|
|
|
stow_pkg_handler unstow || return $?
|
|
|
|
|
2011-07-05 07:23:29 +00:00
|
|
|
[ -n "$found" ] && return 0
|
|
|
|
|
|
|
|
return 1
|
2009-10-18 09:17:26 +00:00
|
|
|
}
|