Provide some vars for use in template's targets.
These new vars are DESTDIR (by default XBPS_DESTDIR/pkgname-version), SRCPKGDESTDIR (XBPS_DESTDIR/sourcepkg-version) and FILESDIR (XBPS_TEMPLATESDIR/pkgname/files). This simplifies packages that used them. --HG-- extra : convert_revision : 287ea7128cb5df19870ca7aff0a3b8f99a11d63a
This commit is contained in:
@@ -59,6 +59,7 @@ xbps_write_metadata_pkg()
|
||||
unset run_depends conf_files keep_dirs noarch install_priority
|
||||
. $XBPS_TEMPLATESDIR/${sourcepkg}/${subpkg}.template
|
||||
pkgname=${sourcepkg}-${subpkg}
|
||||
set_tmpl_common_vars
|
||||
xbps_write_metadata_pkg_real
|
||||
run_template ${sourcepkg}
|
||||
[ "${pkg}" = "${sourcepkg}-${subpkg}" ] && break
|
||||
@@ -71,6 +72,7 @@ xbps_write_metadata_pkg()
|
||||
run_depends="$run_depends ${sourcepkg}-${subpkg}-${version}"
|
||||
done
|
||||
fi
|
||||
set_tmpl_common_vars
|
||||
xbps_write_metadata_pkg_real
|
||||
}
|
||||
|
||||
@@ -80,12 +82,11 @@ xbps_write_metadata_pkg()
|
||||
#
|
||||
xbps_write_metadata_pkg_real()
|
||||
{
|
||||
local destdir=$XBPS_DESTDIR/$pkgname-$version
|
||||
local metadir=$destdir/var/db/xbps/metadata/$pkgname
|
||||
local metadir=${DESTDIR}/var/db/xbps/metadata/$pkgname
|
||||
local f i j arch prioinst TMPFLIST TMPFPLIST
|
||||
local fpattern="s|$destdir||g;s|^\./$||g;/^$/d"
|
||||
local fpattern="s|${DESTDIR}||g;s|^\./$||g;/^$/d"
|
||||
|
||||
if [ ! -d "$destdir" ]; then
|
||||
if [ ! -d "${DESTDIR}" ]; then
|
||||
echo "ERROR: $pkgname not installed into destdir."
|
||||
exit 1
|
||||
fi
|
||||
@@ -111,7 +112,7 @@ xbps_write_metadata_pkg_real()
|
||||
write_metadata_flist_header $TMPFPLIST
|
||||
|
||||
# Pass 1: add links.
|
||||
for f in $(find $destdir -type l); do
|
||||
for f in $(find ${DESTDIR} -type l); do
|
||||
j=$(echo $f|sed -e "$fpattern")
|
||||
[ "$j" = "" ] && continue
|
||||
printf "$j\n" >> $TMPFLIST
|
||||
@@ -124,7 +125,7 @@ xbps_write_metadata_pkg_real()
|
||||
done
|
||||
|
||||
# Pass 2: add regular files.
|
||||
for f in $(find $destdir -type f); do
|
||||
for f in $(find ${DESTDIR} -type f); do
|
||||
j=$(echo $f|sed -e "$fpattern")
|
||||
[ "$j" = "" ] && continue
|
||||
printf "$j\n" >> $TMPFLIST
|
||||
@@ -146,7 +147,7 @@ xbps_write_metadata_pkg_real()
|
||||
done
|
||||
|
||||
# Pass 3: add directories.
|
||||
for f in $(find $destdir -type d|sort -ur); do
|
||||
for f in $(find ${DESTDIR} -type d|sort -ur); do
|
||||
j=$(echo $f|sed -e "$fpattern")
|
||||
[ "$j" = "" ] && continue
|
||||
printf "$j\n" >> $TMPFLIST
|
||||
@@ -184,7 +185,7 @@ xbps_write_metadata_pkg_real()
|
||||
<key>priority</key>
|
||||
<integer>$prioinst</integer>
|
||||
<key>installed_size</key>
|
||||
<integer>$(du -sb $destdir|awk '{print $1}')</integer>
|
||||
<integer>$(du -sb ${DESTDIR}|awk '{print $1}')</integer>
|
||||
<key>maintainer</key>
|
||||
<string>$(echo $maintainer|sed -e 's|<|[|g;s|>|]|g')</string>
|
||||
<key>short_desc</key>
|
||||
@@ -243,8 +244,8 @@ _EOF
|
||||
rm -f $TMPFLIST $TMPFPLIST $TMPFPROPS
|
||||
|
||||
if [ -f "$XBPS_TEMPLATESDIR/$pkgname/INSTALL" ]; then
|
||||
cp -f $XBPS_TEMPLATESDIR/$pkgname/INSTALL $destdir
|
||||
chmod +x $destdir/INSTALL
|
||||
cp -f $XBPS_TEMPLATESDIR/$pkgname/INSTALL ${DESTDIR}
|
||||
chmod +x ${DESTDIR}/INSTALL
|
||||
fi
|
||||
if [ -f "$XBPS_TEMPLATESDIR/$pkgname/REMOVE" ]; then
|
||||
cp -f $XBPS_TEMPLATESDIR/$pkgname/REMOVE $metadir
|
||||
@@ -261,12 +262,14 @@ xbps_make_binpkg()
|
||||
if [ "$pkg" = "$pkgname-$subpkg" ]; then
|
||||
. $XBPS_TEMPLATESDIR/$pkgname/$subpkg.template
|
||||
pkgname=${sourcepkg}-${subpkg}
|
||||
set_tmpl_common_vars
|
||||
xbps_make_binpkg_real
|
||||
return $?
|
||||
fi
|
||||
run_template ${sourcepkg}
|
||||
done
|
||||
|
||||
set_tmpl_common_vars
|
||||
xbps_make_binpkg_real
|
||||
return $?
|
||||
}
|
||||
@@ -277,13 +280,12 @@ xbps_make_binpkg()
|
||||
#
|
||||
xbps_make_binpkg_real()
|
||||
{
|
||||
local destdir=$XBPS_DESTDIR/$pkgname-$version
|
||||
local binpkg=
|
||||
local pkgdir=
|
||||
local arch=
|
||||
local use_sudo=
|
||||
|
||||
cd $destdir || exit 1
|
||||
cd ${DESTDIR} || exit 1
|
||||
|
||||
if [ -n "$noarch" ]; then
|
||||
arch=noarch
|
||||
|
@@ -32,20 +32,21 @@
|
||||
install_pkg_deps()
|
||||
{
|
||||
local curpkg="$1"
|
||||
local saved_prevpkg=$(xbps-pkgdb getpkgname ${2})
|
||||
local curpkgname j jver jname reqver
|
||||
local curpkgname=$(xbps-pkgdb getpkgname $1)
|
||||
local saved_prevpkg=$(xbps-pkgdb getpkgname $2)
|
||||
local j jver jname reqver
|
||||
|
||||
[ -z "$curpkg" ] && return 1
|
||||
[ -n "$prev_pkg" ] && curpkg=$prev_pkg
|
||||
curpkgname=$(xbps-pkgdb getpkgname ${curpkg})
|
||||
|
||||
if [ -n "$prev_pkg" ]; then
|
||||
curpkg=$prev_pkg
|
||||
curpkgname=$(xbps-pkgdb getpkgname ${curpkg})
|
||||
fi
|
||||
|
||||
echo "==> Installing $saved_prevpkg dependency: $curpkgname."
|
||||
|
||||
run_template $curpkgname
|
||||
check_installed_pkg $curpkg
|
||||
[ $? -eq 0 ] && continue
|
||||
|
||||
echo "==> Installing $saved_prevpkg dependency: $curpkg"
|
||||
|
||||
check_build_depends_pkg $curpkg
|
||||
check_build_depends_pkg
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "==> Dependency $curpkgname requires:"
|
||||
for j in ${build_depends}; do
|
||||
@@ -78,6 +79,7 @@ install_pkg_deps()
|
||||
done
|
||||
|
||||
install_pkg $curpkgname auto
|
||||
[ -n "$prev_pkg" ] && unset prev_pkg
|
||||
}
|
||||
|
||||
#
|
||||
@@ -87,11 +89,7 @@ install_dependencies_pkg()
|
||||
{
|
||||
local pkg="$1"
|
||||
local lpkgname=$(xbps-pkgdb getpkgname ${pkg})
|
||||
local i=
|
||||
local ipkgname=
|
||||
local iversion=
|
||||
local reqvers=
|
||||
local notinstalled_deps=
|
||||
local i ipkgname iversion reqvers notinstalled_deps
|
||||
|
||||
[ -z "$pkg" ] && return 1
|
||||
|
||||
@@ -112,19 +110,17 @@ install_dependencies_pkg()
|
||||
fi
|
||||
done
|
||||
|
||||
if [ -z "$notinstalled_deps" ]; then
|
||||
return 0
|
||||
fi
|
||||
[ -z "$notinstalled_deps" ] && return 0
|
||||
|
||||
for i in ${notinstalled_deps}; do
|
||||
ipkgname=$(xbps-pkgdb getpkgname ${i})
|
||||
run_template $ipkgname
|
||||
check_installed_pkg $i
|
||||
[ $? -eq 0 ] && continue
|
||||
|
||||
check_build_depends_pkg $i
|
||||
ipkgname=$(xbps-pkgdb getpkgname ${i})
|
||||
run_template $ipkgname
|
||||
check_build_depends_pkg
|
||||
if [ $? -eq 1 ]; then
|
||||
msg_normal "Installing $lpkgname dependency: $ipkgname"
|
||||
msg_normal "Installing $lpkgname dependency: $ipkgname."
|
||||
install_pkg $ipkgname auto
|
||||
else
|
||||
install_pkg_deps $i $pkg
|
||||
@@ -136,8 +132,7 @@ install_builddeps_required_pkg()
|
||||
{
|
||||
local pkg="$1"
|
||||
local pkgname=$(xbps-pkgdb getpkgname ${pkg})
|
||||
local dep=
|
||||
local depname=
|
||||
local dep depname
|
||||
|
||||
[ -z "$pkg" ] && return 1
|
||||
|
||||
@@ -160,11 +155,9 @@ install_builddeps_required_pkg()
|
||||
check_installed_pkg()
|
||||
{
|
||||
local pkg="$1"
|
||||
local pkgname=
|
||||
local reqver=
|
||||
local iver=
|
||||
local pkgname reqver iver
|
||||
|
||||
[ -z "$pkg" ] && return 1
|
||||
[ -z "$pkg" ] && return 2
|
||||
|
||||
pkgname=$(xbps-pkgdb getpkgname $pkg)
|
||||
reqver=$(xbps-pkgdb getpkgversion $pkg)
|
||||
@@ -185,12 +178,7 @@ check_installed_pkg()
|
||||
#
|
||||
check_build_depends_pkg()
|
||||
{
|
||||
local pkg="$1"
|
||||
local pkgname=$(xbps-pkgdb getpkgname ${pkg})
|
||||
|
||||
[ -z $pkg ] && return 1
|
||||
|
||||
run_template $pkgname
|
||||
[ -z "$pkgname" ] && return 2
|
||||
|
||||
if [ -n "$build_depends" ]; then
|
||||
return 0
|
||||
|
@@ -31,7 +31,6 @@ configure_src_phase()
|
||||
{
|
||||
local pkg="$1"
|
||||
local f=
|
||||
local destdir=$XBPS_DESTDIR/$pkgname-$version
|
||||
|
||||
[ -z $pkg ] && [ -z $pkgname ] && return 1
|
||||
|
||||
@@ -87,8 +86,8 @@ configure_src_phase()
|
||||
if [ "$build_style" = "gnu_configure" ]; then
|
||||
${configure_script} \
|
||||
--prefix=${_prefix} --sysconfdir=/etc \
|
||||
--infodir=$destdir/usr/share/info \
|
||||
--mandir=$destdir/usr/share/man \
|
||||
--infodir=${DESTDIR}/usr/share/info \
|
||||
--mandir=${DESTDIR}/usr/share/man \
|
||||
${configure_args}
|
||||
#
|
||||
# Packages using propietary configure scripts.
|
||||
|
@@ -91,6 +91,7 @@ install_src_phase()
|
||||
fi
|
||||
. $XBPS_TEMPLATESDIR/$pkgname/$subpkg.template
|
||||
pkgname=${sourcepkg}-${subpkg}
|
||||
set_tmpl_common_vars
|
||||
run_func do_install
|
||||
run_template ${sourcepkg}
|
||||
[ "$pkg" = "${sourcepkg}-${subpkg}" ] && break
|
||||
@@ -113,11 +114,9 @@ install_src_phase()
|
||||
|
||||
make_install()
|
||||
{
|
||||
local destdir=$XBPS_DESTDIR/$pkgname-$version
|
||||
|
||||
if [ -z "$make_install_target" ]; then
|
||||
make_install_target="install prefix=$destdir/usr"
|
||||
make_install_target="$make_install_target sysconfdir=$destdir/etc"
|
||||
make_install_target="install prefix=${DESTDIR}/usr"
|
||||
make_install_target="$make_install_target sysconfdir=${DESTDIR}/etc"
|
||||
fi
|
||||
|
||||
[ -z "$make_cmd" ] && make_cmd=/usr/bin/make
|
||||
|
@@ -44,6 +44,7 @@ stow_pkg()
|
||||
fi
|
||||
. $XBPS_TEMPLATESDIR/${sourcepkg}/${subpkg}.template
|
||||
pkgname=${sourcepkg}-${subpkg}
|
||||
set_tmpl_common_vars
|
||||
stow_pkg_real ${pkgname} ${automatic}
|
||||
run_template ${sourcepkg}
|
||||
if [ "${pkg}" = "${sourcepkg}-${subpkg}" ]; then
|
||||
@@ -70,7 +71,6 @@ stow_pkg_real()
|
||||
local pkg="$1"
|
||||
local automatic="$2"
|
||||
local i=
|
||||
local destdir=$XBPS_DESTDIR/$pkg-$version
|
||||
|
||||
[ -z "$pkg" ] && return 2
|
||||
|
||||
@@ -79,16 +79,12 @@ stow_pkg_real()
|
||||
fi
|
||||
|
||||
if [ "$build_style" = "meta-template" ]; then
|
||||
[ ! -d $destdir ] && mkdir -p $destdir
|
||||
[ ! -d ${DESTDIR} ] && mkdir -p ${DESTDIR}
|
||||
fi
|
||||
|
||||
if [ -n "$stow_flag" ]; then
|
||||
if [ "$pkgname" != "$pkg" ]; then
|
||||
. $XBPS_TEMPLATESDIR/$pkg/template
|
||||
fi
|
||||
fi
|
||||
[ -n "$stow_flag" ] && run_template $pkg
|
||||
|
||||
cd $destdir || exit 1
|
||||
cd ${DESTDIR} || exit 1
|
||||
|
||||
# Copy files into masterdir.
|
||||
for i in $(echo *); do
|
||||
@@ -133,9 +129,7 @@ unstow_pkg()
|
||||
msg_error "cannot unstow $pkg! (permission denied)"
|
||||
fi
|
||||
|
||||
if [ "$pkgname" != "$pkg" ]; then
|
||||
. $XBPS_TEMPLATESDIR/$pkg/template
|
||||
fi
|
||||
run_template $pkg
|
||||
|
||||
ver=$($XBPS_REGPKGDB_CMD version $pkg)
|
||||
if [ -z "$ver" ]; then
|
||||
|
@@ -1,5 +1,5 @@
|
||||
#-
|
||||
# Copyright (c) 2008 Juan Romero Pardines.
|
||||
# Copyright (c) 2008-2009 Juan Romero Pardines.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
@@ -42,7 +42,8 @@ info_tmpl()
|
||||
echo "$long_desc"
|
||||
echo
|
||||
. $XBPS_SHUTILSDIR/builddep_funcs.sh
|
||||
check_build_depends_pkg $pkgname-$version
|
||||
run_template $pkgname
|
||||
check_build_depends_pkg
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "This package requires the following dependencies to be built:"
|
||||
for i in ${build_depends}; do
|
||||
@@ -71,7 +72,8 @@ reset_tmpl_vars()
|
||||
install_priority noarch subpackages sourcepkg \
|
||||
abi_depends api_depends \
|
||||
XBPS_EXTRACT_DONE XBPS_CONFIGURE_DONE \
|
||||
XBPS_BUILD_DONE XBPS_INSTALL_DONE FILESDIR"
|
||||
XBPS_BUILD_DONE XBPS_INSTALL_DONE FILESDIR DESTDIR \
|
||||
SRCPKGDESTDIR"
|
||||
|
||||
for v in ${TMPL_VARS}; do
|
||||
eval unset "$v"
|
||||
@@ -94,6 +96,7 @@ setup_tmpl()
|
||||
|
||||
if [ -f "$XBPS_TEMPLATESDIR/$pkg/template" ]; then
|
||||
if [ "$pkgname" != "$pkg" ]; then
|
||||
reset_tmpl_vars
|
||||
. $XBPS_TEMPLATESDIR/$pkg/template
|
||||
fi
|
||||
prepare_tmpl
|
||||
@@ -190,7 +193,7 @@ prepare_tmpl()
|
||||
XBPS_BUILD_DONE="$wrksrc/.xbps_build_done"
|
||||
XBPS_INSTALL_DONE="$wrksrc/.xbps_install_done"
|
||||
|
||||
FILESDIR=${XBPS_TEMPLATESDIR}/${pkgname}/files
|
||||
set_tmpl_common_vars
|
||||
|
||||
if [ -z "$in_chroot" ]; then
|
||||
export PATH="$XBPS_MASTERDIR/bin:$XBPS_MASTERDIR/sbin"
|
||||
@@ -200,6 +203,15 @@ prepare_tmpl()
|
||||
fi
|
||||
}
|
||||
|
||||
set_tmpl_common_vars()
|
||||
{
|
||||
[ -z "$pkgname" ] && return 1
|
||||
|
||||
FILESDIR=${XBPS_TEMPLATESDIR}/${pkgname}/files
|
||||
DESTDIR=${XBPS_DESTDIR}/${pkgname}-${version}
|
||||
SRCPKGDESTDIR=${XBPS_DESTDIR}/${sourcepkg}-${version}
|
||||
}
|
||||
|
||||
run_template()
|
||||
{
|
||||
local pkg="$1"
|
||||
@@ -207,5 +219,6 @@ run_template()
|
||||
if [ "$pkgname" != "$pkg" ]; then
|
||||
reset_tmpl_vars
|
||||
. $XBPS_TEMPLATESDIR/$pkg/template
|
||||
set_tmpl_common_vars
|
||||
fi
|
||||
}
|
||||
|
Reference in New Issue
Block a user