xbps-src: multiple changes to improve infrastructure.

- Remove buildvars_funcs.sh, its code has been moved into set_tmpl_common_vars().
- Move stripping code into its own file, and don't run it via fakeroot.
- Remove unnecesary reset_tmpl_vars() call in install_pkg().
- Misc changes.
This commit is contained in:
Juan RP 2010-05-26 15:41:26 +02:00
parent 90a9ea320b
commit c34e13336b
7 changed files with 146 additions and 117 deletions

View File

@ -40,28 +40,6 @@ set_defvars
. $XBPS_SHUTILSDIR/common_funcs.sh
. $XBPS_SHUTILSDIR/builddep_funcs.sh
strip_files()
{
local lver="$1"
if [ ! -x /usr/bin/strip ]; then
return 0
fi
[ -n "$nostrip" ] && return 0
msg_normal "Package '$pkgname ($lver)': stripping files, please wait..."
for f in $(find ${DESTDIR} -type f); do
case "$(file -biz $f)" in
application/x-executable*)
/usr/bin/strip $f && \
echo " Stripped executable: $(basename $f)";;
application/x-sharedlib*|application/x-archive*)
/usr/bin/strip -S $f && \
echo " Stripped library: $(basename $f)";;
esac
done
}
install_src_phase()
{
local f i subpkg lver spkgrev saved_wrksrc
@ -160,11 +138,6 @@ install_src_phase()
msg_normal "Package '$pkgname ($lver)': removing empty dirs..."
find ${DESTDIR} -depth -type d -exec rmdir 2>/dev/null {} \;
fi
# Strip bins/libs.
if [ -z "$noarch" ]; then
strip_files "$lver"
fi
msg_normal "Package '$pkgname ($lver)': installed into destdir."
if [ "$build_style" != "custom-install" -a -z "$distfiles" ]; then
@ -216,7 +189,6 @@ install_src_phase()
#
# Installs a package via 'make install ...'.
#
make_install()
{
local lver="$1"
@ -224,10 +196,7 @@ make_install()
if [ -z "$make_install_target" ]; then
make_install_target="DESTDIR=${DESTDIR} install"
fi
[ -z "$make_cmd" ] && make_cmd=make
. $XBPS_SHUTILSDIR/buildvars_funcs.sh
#
# Install package via make.
#

View File

@ -74,9 +74,6 @@ build_src_phase()
fi
fi
. $XBPS_SHUTILSDIR/buildvars_funcs.sh
set_build_vars
msg_normal "Package '$pkgname ($lver)': running build phase."
if [ "$build_style" = "custom-install" ]; then
@ -109,7 +106,6 @@ build_src_phase()
fi
unset makejobs
unset_build_vars
touch -f $XBPS_BUILD_DONE
}

View File

@ -84,9 +84,6 @@ configure_src_phase()
cd $build_wrksrc || return 1
fi
. $XBPS_SHUTILSDIR/buildvars_funcs.sh
set_build_vars
case "$build_style" in
gnu_configure|gnu-configure)
#
@ -141,7 +138,6 @@ configure_src_phase()
for f in ${configure_env}; do
unset eval ${f%=*}
done
unset_build_vars
touch -f $XBPS_CONFIGURE_DONE
}

View File

@ -25,6 +25,34 @@
. ${XBPS_SHUTILSDIR}/tmpl_funcs.sh
strip_files()
{
local lver
if ! command -v strip 2>&1 >/dev/null; then
return 0
fi
[ -n "$nostrip" ] && return 0
if [ -n "$revision" ]; then
lver="${version}_${revision}"
else
lver="${version}"
fi
msg_normal "Package '$pkgname ($lver)': stripping files, please wait..."
for f in $(find ${DESTDIR} -type f); do
case "$(file -biz $f)" in
application/x-executable*)
strip $f && \
echo " Stripped executable: $(basename $f)";;
application/x-sharedlib*|application/x-archive*)
strip -S $f && \
echo " Stripped library: $(basename $f)";;
esac
done
}
#
# Installs a pkg by reading its build template file.
#
@ -42,10 +70,7 @@ install_pkg()
fi
pkg="$curpkgn-$version"
if [ -n "$doing_deps" ]; then
reset_tmpl_vars
setup_tmpl $curpkgn
fi
[ -n "$doing_deps" ] && setup_tmpl $curpkgn
#
# Refuse to install the same package that is already installed.
@ -112,7 +137,6 @@ install_pkg()
fi
# Install pkg into destdir.
set_build_vars
env xbps_machine=${xbps_machine} MASTERDIR=${_MASTERDIR} \
dontrm_builddir=${dontrm_builddir} wrksrc=${wrksrc} \
${fakeroot_cmd} ${fakeroot_cmd_args} \
@ -122,7 +146,12 @@ install_pkg()
msg_red "xbps-src-doinst-helper failed for '$pkgname'!"
return 1
fi
unset_build_vars
# Strip binaries/libraries.
if [ -z "$noarch" ]; then
. $XBPS_SHUTILSDIR/strip_files.sh
strip_files
fi
# Always write metadata to package's destdir.
. $XBPS_SHUTILSDIR/metadata.sh

View File

@ -1,5 +1,5 @@
#-
# Copyright (c) 2008-2010 Juan Romero Pardines.
# Copyright (c) 2010 Juan Romero Pardines.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@ -23,47 +23,47 @@
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#-
#
# Functions to set some env vars required to build the packages
# required by the xbps-base-chroot package.
#
. ${XBPS_SHUTILSDIR}/tmpl_funcs.sh
set_build_vars()
strip_files()
{
local LDLIBPATH
local subpkg
if [ -z "$in_chroot" ]; then
SAVE_LDLIBPATH=$LD_LIBRARY_PATH
LDFLAGS="-L$XBPS_MASTERDIR/usr/lib"
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
LDLIBPATH="/lib32:/usr/lib32:$LDLIBPATH"
LDFLAGS="-L/lib32 -L/usr/lib32 $LDFLAGS"
export PATH="/bin:/usr/bin:$PATH"
export CC="gcc -m32"
export CXX="g++ -m32"
fi
export CPPFLAGS="-I$XBPS_MASTERDIR/usr/include"
export LDFLAGS="$LDFLAGS"
export LD_LIBRARY_PATH="$LDLIBPATH"
fi
export PKG_CONFIG="$XBPS_MASTERDIR/usr/bin/pkg-config"
export PKG_CONFIG_LIBDIR="$XBPS_MASTERDIR/usr/lib/pkgconfig"
export CFLAGS="$CFLAGS $XBPS_CFLAGS"
export CXXFLAGS="$CXXFLAGS $XBPS_CXXFLAGS"
for subpkg in ${subpackages}; do
. $XBPS_SRCPKGDIR/${sourcepkg}/${subpkg}.template
pkgname=${subpkg}
set_tmpl_common_vars
strip_files_real
setup_tmpl ${sourcepkg}
done
strip_files_real
}
unset_build_vars()
strip_files_real()
{
if [ -z "$in_chroot" ]; then
unset LD_LIBRARY_PATH LDFLAGS
export LD_LIBRARY_PATH=$SAVE_LDLIBPATH
[ -n "$BUILD_32BIT" ] && unset CC CXX
local lver
if ! command -v strip 2>&1 >/dev/null; then
return 0
fi
unset PKG_CONFIG PKG_CONFIG_LIBDIR
unset CPPFLAGS CFLAGS CXXFLAGS
[ -n "$nostrip" ] && return 0
if [ -n "$revision" ]; then
lver="${version}_${revision}"
else
lver="${version}"
fi
msg_normal "Package '$pkgname ($lver)': stripping files, please wait..."
for f in $(find ${DESTDIR} -type f); do
case "$(file -biz $f)" in
application/x-executable*)
strip $f && \
echo " Stripped executable: $(basename $f)";;
application/x-sharedlib*|application/x-archive*)
strip -S $f && \
echo " Stripped library: $(basename $f)";;
esac
done
}

View File

@ -61,7 +61,6 @@ info_tmpl()
#
reset_tmpl_vars()
{
local v=
local TMPL_VARS="pkgname distfiles configure_args configure_env \
make_build_args make_install_args build_style \
short_desc maintainer long_desc checksum wrksrc \
@ -81,14 +80,9 @@ reset_tmpl_vars()
pre_remove post_remove post_stow do_build do_install \
XBPS_EXTRACT_DONE XBPS_CONFIGURE_DONE \
XBPS_BUILD_DONE XBPS_INSTALL_DONE FILESDIR DESTDIR \
SRCPKGDESTDIR PATCHESDIR"
for v in ${TMPL_VARS}; do
eval unset "$v"
done
. $XBPS_SHUTILSDIR/buildvars_funcs.sh
unset_build_vars
SRCPKGDESTDIR PATCHESDIR CFLAGS CXXFLAGS CPPFLAGS \
CC CXX LDFLAGS LD_LIBRARY_PATH"
eval unset "$TMPL_VARS"
}
#
@ -99,6 +93,7 @@ setup_tmpl()
local pkg="$1"
[ -z "$pkg" ] && return 1
if [ "$pkgname" = "$pkg" ]; then
[ -n "$DESTDIR" ] && return 0
fi
@ -111,7 +106,6 @@ setup_tmpl()
reset_tmpl_vars
. $XBPS_SRCPKGDIR/${pkg}/template
prepare_tmpl
set_build_vars
else
msg_error "Cannot find $pkg build template file."
fi
@ -242,14 +236,6 @@ prepare_tmpl()
XBPS_POST_INSTALL_DONE="$wrksrc/.xbps_post_install_done"
set_tmpl_common_vars
if [ -z "$in_chroot" ]; then
export PATH="$XBPS_MASTERDIR/bin:$XBPS_MASTERDIR/sbin"
export PATH="$PATH:$XBPS_MASTERDIR/usr/bin"
export PATH="$PATH:$XBPS_MASTERDIR/usr/sbin"
export PATH="$PATH:/bin:/sbin:/usr/bin:/usr/sbin"
export PATH="$PATH:/sbin:@@XBPS_INSTALL_PREFIX@@/sbin"
fi
}
remove_tmpl_wrksrc()
@ -260,7 +246,7 @@ remove_tmpl_wrksrc()
return 1
fi
msg_normal "Cleaning '$pkgname' build directory... "
msg_normal "Cleaning '${sourcepkg}' build directory... "
rm -rf $lwrksrc
return $?
}
@ -276,4 +262,24 @@ set_tmpl_common_vars()
sourcepkg=${pkgname}
fi
SRCPKGDESTDIR=${XBPS_DESTDIR}/${sourcepkg}-${version}
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
}

View File

@ -138,32 +138,40 @@ run_file()
check_config_vars()
{
local val cffound f
local val cffound f cfpaths cf="xbps-src.conf"
if [ -z "$config_file_specified" ]; then
config_file_paths="$XBPS_CONFIG_FILE ./etc/xbps-src.conf"
for f in $config_file_paths; do
[ -f $f ] && XBPS_CONFIG_FILE=$f && \
cffound=yes && break
if [ -z "$XBPS_CONFIG_FILE" ]; then
cfpaths="@@XBPS_INSTALL_PREFIX@@/etc/${cf} ./etc/${cf}"
for f in $cfpaths; do
if [ -f ${f} ]; then
XBPS_CONFIG_FILE=${f}
cffound=yes
break
fi
done
[ -z "$cffound" ] && msg_error "cannot find a config file"
fi
run_file ${XBPS_CONFIG_FILE}
XBPS_CONFIG_FILE=$path_fixed
export XBPS_CONFIG_FILE=$path_fixed
if [ ! -f "$XBPS_CONFIG_FILE" ]; then
msg_error "cannot find configuration file: $XBPS_CONFIG_FILE"
fi
eval val="\$XBPS_MASTERDIR"
[ -z "$val" ] && msg_error "'XBPS_MASTERDIR' not set in configuration file"
if [ ! -d "$val" ]; then
mkdir "$val"
[ $? -ne 0 ] && msg_error "couldn't create 'XBPS_MASTERDIR' directory"
for f in XBPS_DISTRIBUTIONDIR XBPS_MASTERDIR; do
eval val="\$${f}"
if [ -z "$val" ]; then
msg_error "'${f}' not set in configuration file!"
fi
done
if [ ! -d "$XBPS_MASTERDIR" ]; then
mkdir -p "$val"
if [ $? -ne 0 ]; then
msg_error "couldn't create 'XBPS_MASTERDIR' directory"
fi
fi
export PATH="@@XBPS_INSTALL_PREFIX@@/sbin:$PATH"
export _MASTERDIR="$XBPS_MASTERDIR"
}
#
@ -172,7 +180,7 @@ check_config_vars()
while getopts "Cc:hm:p:" opt; do
case $opt in
C) export dontrm_builddir=yes;;
c) config_file_specified=yes; XBPS_CONFIG_FILE="$OPTARG";;
c) XBPS_CONFIG_FILE="$OPTARG";;
h) usage && exit 0;;
m)
_MASTERDIR="$OPTARG"
@ -205,6 +213,10 @@ fi
#
check_reqhost_utils
if [ -n "$in_chroot" ]; then
XBPS_CONFIG_FILE="/usr/local/etc/xbps-src.conf"
fi
#
# Check configuration vars before anyting else, and set defaults vars.
#
@ -217,6 +229,9 @@ set_defvars
. $XBPS_SHUTILSDIR/common_funcs.sh
#
# Fix up some vars when XBPS_USE_CAPABILITIES is set.
#
if [ -n "$XBPS_USE_CAPABILITIES" ]; then
chroot_cmd="@@XBPS_INSTALL_LIBEXECDIR@@/xbps-src-capchroot"
unset sudo_cmd
@ -234,7 +249,25 @@ fi
[ -z "$dontrm_builddir" ] && dontrm_builddir=no
# Main switch
#
# Sanitize PATH.
#
if [ -z "$in_chroot" ]; then
# In non chroot case always prefer host tools.
MYPATH="/bin:/usr/bin:/sbin:/usr/sbin:$MYPATH"
MYPATH="$XBPS_MASTERDIR/bin:$XBPS_MASTERDIR/usr/bin:$MYPATH"
MYPATH="$XBPS_MASTERDIR/usr/local/bin:$MYPATH"
MYPATH="$XBPS_MASTERDIR/usr/local/sbin:$MYPATH"
else
# In chroot always prefer tools from bootstrap.
MYPATH="/tools/bin:/usr/local/sbin:/usr/local/bin"
MYPATH="/bin:/sbin:/usr/bin:/usr/sbin:$MYPATH"
fi
export PATH="$MYPATH"
#
# Main switch.
#
case "$target" in
bootstrap)
. $XBPS_SHUTILSDIR/tmpl_funcs.sh