2009-10-18 09:17:26 +00:00
|
|
|
#-
|
2010-01-04 15:05:13 +00:00
|
|
|
# Copyright (c) 2008-2010 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.
|
|
|
|
#-
|
|
|
|
|
|
|
|
#
|
|
|
|
# Shows info about a template.
|
|
|
|
#
|
|
|
|
info_tmpl()
|
|
|
|
{
|
|
|
|
local i=
|
|
|
|
|
|
|
|
for f in $(echo $XBPS_COMMONVARSDIR/*.sh); do
|
|
|
|
[ -r ${f} ] && . ${f}
|
|
|
|
done
|
|
|
|
|
|
|
|
echo "pkgname: $pkgname"
|
|
|
|
echo "version: $version"
|
|
|
|
[ -n "$revision" ] && echo "revision: $revision"
|
|
|
|
for i in "${distfiles}"; do
|
|
|
|
[ -n "$i" ] && echo "distfile: $i"
|
|
|
|
done
|
|
|
|
[ -n "$checksum" ] && echo "checksum: $checksum"
|
|
|
|
echo "maintainer: $maintainer"
|
|
|
|
echo "build_style: $build_style"
|
|
|
|
echo "short_desc: $short_desc"
|
|
|
|
echo "$long_desc"
|
|
|
|
echo
|
|
|
|
. $XBPS_SHUTILSDIR/builddep_funcs.sh
|
|
|
|
check_build_depends_pkg
|
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
echo "This package requires the following dependencies to be built:"
|
|
|
|
for i in ${build_depends}; do
|
|
|
|
echo " $i"
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
#
|
|
|
|
# Resets all vars used by a template.
|
|
|
|
#
|
|
|
|
reset_tmpl_vars()
|
|
|
|
{
|
|
|
|
local TMPL_VARS="pkgname distfiles configure_args configure_env \
|
|
|
|
make_build_args make_install_args build_style \
|
|
|
|
short_desc maintainer long_desc checksum wrksrc \
|
|
|
|
make_cmd base_chroot register_shell keep_empty_dirs \
|
|
|
|
make_build_target configure_script noextract nofetch \
|
|
|
|
pre_configure pre_build pre_install build_depends \
|
|
|
|
post_configure post_build post_install nostrip \
|
2010-04-29 03:20:36 +00:00
|
|
|
make_install_target version revision \
|
2009-10-18 09:17:26 +00:00
|
|
|
sgml_catalogs xml_catalogs xml_entries sgml_entries \
|
2009-12-02 02:20:26 +00:00
|
|
|
disable_parallel_build run_depends font_dirs preserve \
|
2009-10-18 09:17:26 +00:00
|
|
|
only_for_archs conf_files keep_libtool_archives \
|
|
|
|
noarch subpackages sourcepkg gtk_iconcache_dirs \
|
|
|
|
abi_depends api_depends triggers openrc_services \
|
2010-01-04 15:05:13 +00:00
|
|
|
replaces system_accounts build_wrksrc create_wrksrc \
|
2010-03-08 09:52:55 +00:00
|
|
|
ignore_vdeps_dir noverifyrdeps conflicts \
|
2010-04-23 13:25:03 +00:00
|
|
|
gconf_entries gconf_schemas stow_copy stow_copy_files \
|
2010-05-11 23:51:53 +00:00
|
|
|
pre_remove post_remove post_stow do_build do_install \
|
2009-12-11 11:03:21 +00:00
|
|
|
XBPS_EXTRACT_DONE XBPS_CONFIGURE_DONE \
|
2009-10-18 09:17:26 +00:00
|
|
|
XBPS_BUILD_DONE XBPS_INSTALL_DONE FILESDIR DESTDIR \
|
2010-05-26 13:41:26 +00:00
|
|
|
SRCPKGDESTDIR PATCHESDIR CFLAGS CXXFLAGS CPPFLAGS \
|
|
|
|
CC CXX LDFLAGS LD_LIBRARY_PATH"
|
|
|
|
eval unset "$TMPL_VARS"
|
2009-10-18 09:17:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#
|
|
|
|
# Reads a template file and setups required variables for operations.
|
|
|
|
#
|
|
|
|
setup_tmpl()
|
|
|
|
{
|
|
|
|
local pkg="$1"
|
|
|
|
|
2009-11-22 07:31:44 +00:00
|
|
|
[ -z "$pkg" ] && return 1
|
2010-05-26 13:41:26 +00:00
|
|
|
|
2010-01-16 01:11:44 +00:00
|
|
|
if [ "$pkgname" = "$pkg" ]; then
|
|
|
|
[ -n "$DESTDIR" ] && return 0
|
|
|
|
fi
|
2009-10-18 09:17:26 +00:00
|
|
|
|
|
|
|
for f in $(echo $XBPS_COMMONVARSDIR/*.sh); do
|
|
|
|
[ -r ${f} ] && . ${f}
|
|
|
|
done
|
|
|
|
|
2009-11-22 07:31:44 +00:00
|
|
|
if [ -f $XBPS_SRCPKGDIR/${pkg}/template ]; then
|
|
|
|
reset_tmpl_vars
|
|
|
|
. $XBPS_SRCPKGDIR/${pkg}/template
|
2009-10-18 09:17:26 +00:00
|
|
|
prepare_tmpl
|
|
|
|
else
|
2009-11-22 07:31:44 +00:00
|
|
|
msg_error "Cannot find $pkg build template file."
|
2009-10-18 09:17:26 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2009-11-22 07:31:44 +00:00
|
|
|
check_builddep_dup()
|
|
|
|
{
|
|
|
|
local dep="$1" i
|
|
|
|
|
|
|
|
for i in ${build_depends}; do
|
|
|
|
[ "${i}" != "${dep}" ] && continue
|
|
|
|
return 1
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
check_rundep_dup()
|
|
|
|
{
|
|
|
|
local dep="$1" i
|
|
|
|
|
|
|
|
for i in ${run_depends}; do
|
|
|
|
[ "${i}" != "${dep}" ] && continue
|
|
|
|
return 1
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2009-10-18 09:17:26 +00:00
|
|
|
Add_dependency()
|
|
|
|
{
|
2009-11-07 04:01:00 +00:00
|
|
|
local type="$1" pkgname="$2" version="$3"
|
2009-10-18 09:17:26 +00:00
|
|
|
|
|
|
|
case "$type" in
|
|
|
|
build|full|run) ;;
|
|
|
|
*) msg_error "Unknown dependency type for $pkgname." ;;
|
|
|
|
esac
|
|
|
|
|
2009-11-07 04:01:00 +00:00
|
|
|
[ -z "$pkgname" ] && msg_error "Add_dependency: pkgname empty!"
|
|
|
|
|
2009-11-22 07:31:44 +00:00
|
|
|
if [ -f $XBPS_SRCPKGDIR/${pkgname}/${pkgname}.depends ]; then
|
|
|
|
. $XBPS_SRCPKGDIR/${pkgname}/${pkgname}.depends
|
|
|
|
elif [ -f $XBPS_SRCPKGDIR/${pkgname}/depends ]; then
|
|
|
|
. $XBPS_SRCPKGDIR/${pkgname}/depends
|
2009-10-18 09:17:26 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$type" = "full" -o "$type" = "build" ]; then
|
2009-11-07 04:01:00 +00:00
|
|
|
if [ -z "$version" -a -z "$api_depends" ]; then
|
2009-11-22 07:31:44 +00:00
|
|
|
if check_builddep_dup "${pkgname}>=0"; then
|
|
|
|
build_depends="${build_depends} ${pkgname}>=0"
|
|
|
|
fi
|
2009-11-07 04:01:00 +00:00
|
|
|
elif [ -z "$version" -a -n "$api_depends" ]; then
|
2009-11-22 07:31:44 +00:00
|
|
|
if check_builddep_dup "${pkgname}${api_depends}"; then
|
|
|
|
build_depends="${build_depends} ${pkgname}${api_depends}"
|
|
|
|
fi
|
2009-10-18 09:17:26 +00:00
|
|
|
else
|
2009-11-22 07:31:44 +00:00
|
|
|
if check_builddep_dup "${pkgname}${version}"; then
|
|
|
|
build_depends="${build_depends} ${pkgname}${version}"
|
|
|
|
fi
|
2009-10-18 09:17:26 +00:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$type" = "full" -o "$type" = "run" ]; then
|
2009-11-07 04:01:00 +00:00
|
|
|
if [ -z "$version" -a -z "$abi_depends" ]; then
|
2009-11-22 07:31:44 +00:00
|
|
|
if check_rundep_dup "${pkgname}>=0"; then
|
|
|
|
run_depends="${run_depends} ${pkgname}>=0"
|
|
|
|
fi
|
2009-11-07 04:01:00 +00:00
|
|
|
elif [ -z "$version" -a -n "$abi_depends" ]; then
|
2009-11-22 07:31:44 +00:00
|
|
|
if check_rundep_dup "${pkgname}${api_depends}"; then
|
|
|
|
run_depends="${run_depends} ${pkgname}${abi_depends}"
|
|
|
|
fi
|
2009-10-18 09:17:26 +00:00
|
|
|
else
|
2009-11-22 07:31:44 +00:00
|
|
|
if check_rundep_dup "${pkgname}${version}"; then
|
|
|
|
run_depends="${run_depends} ${pkgname}${version}"
|
|
|
|
fi
|
2009-10-18 09:17:26 +00:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
unset abi_depends api_depends
|
|
|
|
}
|
|
|
|
|
|
|
|
#
|
|
|
|
# Checks some vars used in templates and sets some of them required.
|
|
|
|
#
|
|
|
|
prepare_tmpl()
|
|
|
|
{
|
|
|
|
local REQ_VARS i found
|
|
|
|
|
|
|
|
#
|
|
|
|
# There's nothing of interest if we are a meta template.
|
|
|
|
#
|
|
|
|
if [ "$build_style" = "meta-template" ]; then
|
|
|
|
set_tmpl_common_vars
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
REQ_VARS="pkgname version build_style short_desc long_desc"
|
|
|
|
|
|
|
|
# Check if required vars weren't set.
|
|
|
|
for i in ${REQ_VARS}; do
|
|
|
|
eval val="\$$i"
|
|
|
|
if [ -z "$val" -o -z "$i" ]; then
|
|
|
|
msg_error "\"$i\" not set on $pkgname template."
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
for i in ${only_for_archs}; do
|
|
|
|
[ "$i" = "$xbps_machine" ] && found=si && break
|
|
|
|
done
|
|
|
|
if [ -n "${only_for_archs}" -a -z "$found" ]; then
|
|
|
|
msg_error "this package is only for: ${only_for_archs}."
|
|
|
|
fi
|
|
|
|
|
|
|
|
unset XBPS_EXTRACT_DONE XBPS_APPLYPATCHES_DONE
|
|
|
|
unset XBPS_CONFIGURE_DONE XBPS_BUILD_DONE XBPS_INSTALL_DONE
|
|
|
|
|
|
|
|
[ -z "$wrksrc" ] && wrksrc="$pkgname-$version"
|
|
|
|
wrksrc="$XBPS_BUILDDIR/$wrksrc"
|
|
|
|
|
2010-04-23 16:45:47 +00:00
|
|
|
XBPS_FETCH_DONE="$wrksrc/.xbps_fetch_done"
|
2009-10-18 09:17:26 +00:00
|
|
|
XBPS_EXTRACT_DONE="$wrksrc/.xbps_extract_done"
|
|
|
|
XBPS_APPLYPATCHES_DONE="$wrksrc/.xbps_applypatches_done"
|
|
|
|
XBPS_CONFIGURE_DONE="$wrksrc/.xbps_configure_done"
|
2010-05-13 22:07:47 +00:00
|
|
|
XBPS_PRECONFIGURE_DONE="$wrksrc/.xbps_pre_configure_done"
|
|
|
|
XBPS_POSTCONFIGURE_DONE="$wrksrc/.xbps_post_configure_done"
|
2009-10-18 09:17:26 +00:00
|
|
|
XBPS_BUILD_DONE="$wrksrc/.xbps_build_done"
|
2010-05-13 22:07:47 +00:00
|
|
|
XBPS_PRE_BUILD_DONE="$wrksrc/.xbps_pre_build_done"
|
|
|
|
XBPS_POST_BUILD_DONE="$wrksrc/.xbps_post_build_done"
|
2009-10-18 09:17:26 +00:00
|
|
|
XBPS_INSTALL_DONE="$wrksrc/.xbps_install_done"
|
2010-05-13 22:07:47 +00:00
|
|
|
XBPS_PRE_INSTALL_DONE="$wrksrc/.xbps_pre_install_done"
|
|
|
|
XBPS_POST_INSTALL_DONE="$wrksrc/.xbps_post_install_done"
|
2009-10-18 09:17:26 +00:00
|
|
|
|
|
|
|
set_tmpl_common_vars
|
|
|
|
}
|
|
|
|
|
2010-05-20 02:05:35 +00:00
|
|
|
remove_tmpl_wrksrc()
|
|
|
|
{
|
|
|
|
local lwrksrc="$1"
|
|
|
|
|
|
|
|
if [ -z "$lwrksrc" -o ! -d "$lwrksrc" ]; then
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
2010-05-26 13:41:26 +00:00
|
|
|
msg_normal "Cleaning '${sourcepkg}' build directory... "
|
2010-05-20 02:05:35 +00:00
|
|
|
rm -rf $lwrksrc
|
|
|
|
return $?
|
|
|
|
}
|
|
|
|
|
2009-10-18 09:17:26 +00:00
|
|
|
set_tmpl_common_vars()
|
|
|
|
{
|
|
|
|
[ -z "$pkgname" ] && return 1
|
|
|
|
|
2009-11-22 07:31:44 +00:00
|
|
|
FILESDIR=$XBPS_SRCPKGDIR/$pkgname/files
|
|
|
|
PATCHESDIR=$XBPS_SRCPKGDIR/$pkgname/patches
|
2009-10-18 09:17:26 +00:00
|
|
|
DESTDIR=${XBPS_DESTDIR}/${pkgname}-${version}
|
|
|
|
if [ -z "${sourcepkg}" ]; then
|
|
|
|
sourcepkg=${pkgname}
|
|
|
|
fi
|
|
|
|
SRCPKGDESTDIR=${XBPS_DESTDIR}/${sourcepkg}-${version}
|
2010-05-26 13:41:26 +00:00
|
|
|
|
|
|
|
export CFLAGS="$XBPS_CFLAGS"
|
|
|
|
export CXXFLAGS="$XBPS_CXXFLAGS"
|
|
|
|
export CPPFLAGS="-I$XBPS_MASTERDIR/usr/include"
|
|
|
|
|
|
|
|
if [ -z "$in_chroot" ]; then
|
|
|
|
if [ -d /usr/lib/libfakeroot ]; then
|
|
|
|
LDLIBPATH="/usr/lib/libfakeroot:$XBPS_MASTERDIR/usr/lib"
|
|
|
|
else
|
|
|
|
LDLIBPATH="$XBPS_MASTERDIR/usr/lib"
|
|
|
|
fi
|
|
|
|
if [ -n "$BUILD_32BIT" ]; then
|
|
|
|
export CC="gcc -m32"
|
|
|
|
export CXX="g++ -m32"
|
|
|
|
LDLIBPATH="$LDLIBPATH:/lib32:/usr/lib32"
|
|
|
|
LDFLAGS="-L/lib32 -L/usr/lib32"
|
|
|
|
fi
|
|
|
|
export LDFLAGS="$LDFLAGS -L$XBPS_MASTERDIR/usr/lib"
|
|
|
|
export LD_LIBRARY_PATH="$LDLIBPATH"
|
|
|
|
fi
|
2009-10-18 09:17:26 +00:00
|
|
|
}
|