Added support to build pkgs in the chroot as normal user via capchroot.
Please read the comment in xbps-src.conf to use it. Fully tested and working nicely, probably some pkgs will need minimal changes. --HG-- extra : convert_revision : 820ad6d48aa74cf5b6db1871adea750acccaa82f
This commit is contained in:
@@ -1,10 +1,19 @@
|
||||
include ../vars.mk
|
||||
|
||||
SCRIPTS = chroot.sh init_funcs.sh pkgtarget_funcs.sh
|
||||
|
||||
.PHONY: all
|
||||
all:
|
||||
for f in $(SCRIPTS); do \
|
||||
sed -e "s|@@XBPS_INSTALL_PREFIX@@|$(PREFIX)|g" \
|
||||
-e "s|@@XBPS_INSTALL_SHAREDIR@@|$(SHAREDIR)|g" \
|
||||
-e "s|@@XBPS_INSTALL_LIBEXECDIR@@|$(LIBEXECDIR)|g" \
|
||||
$$f.in > $$f; \
|
||||
done
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
-rm -f $(SCRIPTS)
|
||||
|
||||
.PHONY: install
|
||||
install:
|
||||
|
||||
@@ -77,7 +77,18 @@ install_pkg_deps()
|
||||
prev_pkg="$j"
|
||||
done
|
||||
|
||||
install_pkg $curpkgname
|
||||
if [ -n "$XBPS_PREFER_BINPKG_DEPS" ]; then
|
||||
install_pkg_with_binpkg ${curpkg}
|
||||
if [ $? -eq 255 ]; then
|
||||
# xbps-bin returned unexpected error
|
||||
return $?
|
||||
elif [ $? -eq 1 ]; then
|
||||
# Package not found, build from source.
|
||||
install_pkg $curpkgname
|
||||
fi
|
||||
else
|
||||
install_pkg $curpkgname
|
||||
fi
|
||||
[ -n "$prev_pkg" ] && unset prev_pkg
|
||||
}
|
||||
|
||||
@@ -121,7 +132,13 @@ install_dependencies_pkg()
|
||||
for i in ${notinstalled_deps}; do
|
||||
if [ -n "$XBPS_PREFER_BINPKG_DEPS" ]; then
|
||||
install_pkg_with_binpkg ${i}
|
||||
[ $? -eq 0 ] && continue
|
||||
if [ $? -eq 255 ]; then
|
||||
# xbps-bin returned unexpected error (-1)
|
||||
return $?
|
||||
elif [ $? -eq 0 ]; then
|
||||
# installed successfully
|
||||
continue
|
||||
fi
|
||||
fi
|
||||
pkgn=$($XBPS_PKGDB_CMD getpkgdepname ${i})
|
||||
check_pkgdep_matched "${i}"
|
||||
@@ -131,7 +148,21 @@ install_dependencies_pkg()
|
||||
check_build_depends_pkg
|
||||
if [ $? -eq 1 ]; then
|
||||
msg_normal "Installing $lpkgname dependency: $pkgn."
|
||||
install_pkg $pkgn
|
||||
if [ -n "$XBPS_PREFER_BINPKG_DEPS" ]; then
|
||||
install_pkg_with_binpkg ${i}
|
||||
if [ $? -eq 255 ]; then
|
||||
# xbps-bin returned unexpected error
|
||||
return $?
|
||||
elif [ $? -eq 0 ]; then
|
||||
# installed successfully
|
||||
continue
|
||||
else
|
||||
# package not found, build source.
|
||||
install_pkg $pkgn
|
||||
fi
|
||||
else
|
||||
install_pkg $pkgn
|
||||
fi
|
||||
else
|
||||
install_pkg_deps "${i}" $pkg
|
||||
fi
|
||||
|
||||
@@ -29,10 +29,19 @@
|
||||
#
|
||||
|
||||
# Umount stuff if SIGINT or SIGQUIT was caught
|
||||
trap umount_chroot_fs INT QUIT
|
||||
trap "${sudo_cmd} @@XBPS_INSTALL_LIBEXECDIR@@/xbps-src-chroot-helper umount && exit $?" INT QUIT
|
||||
|
||||
[ -n "$base_chroot" ] && return 0
|
||||
|
||||
if [ "${chroot_cmd}" = "chroot" ]; then
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo "Root permissions are required for the chroot, try again."
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
chroot_cmd_args="--"
|
||||
fi
|
||||
|
||||
. $XBPS_SHUTILSDIR/builddep_funcs.sh
|
||||
check_installed_pkg xbps-base-chroot-0.11
|
||||
if [ $? -ne 0 ]; then
|
||||
@@ -41,21 +50,11 @@ if [ $? -ne 0 ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo "This package requires to be installed in a chroot."
|
||||
echo "You cannot do this as normal user, try again being root."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
msg_normal "Entering into the chroot on $XBPS_MASTERDIR."
|
||||
|
||||
EXTDIRS="xbps xbps_builddir xbps_destdir xbps_packagesdir \
|
||||
xbps_srcdistdir"
|
||||
REQDIRS="bin sbin tmp var sys proc dev usr/local/etc ${EXTDIRS}"
|
||||
for f in ${REQDIRS}; do
|
||||
[ ! -d $XBPS_MASTERDIR/$f ] && mkdir -p $XBPS_MASTERDIR/$f
|
||||
done
|
||||
unset f REQDIRS
|
||||
if [ ! -d $XBPS_MASTERDIR/usr/local/etc ]; then
|
||||
mkdir -p $XBPS_MASTERDIR/usr/local/etc
|
||||
fi
|
||||
|
||||
XBPSSRC_CF=$XBPS_MASTERDIR/usr/local/etc/xbps-src.conf
|
||||
|
||||
@@ -73,13 +72,20 @@ fi
|
||||
if [ -n "$XBPS_PREFER_BINPKG_DEPS" ]; then
|
||||
echo "XBPS_PREFER_BINPKG_DEPS=$XBPS_PREFER_BINPKG_DEPS" >> $XBPSSRC_CF
|
||||
fi
|
||||
echo "XBPS_COMPRESS_CMD=$XBPS_COMPRESS_CMD" >> $XBPSSRC_CF
|
||||
if [ -n "$XBPS_COMPRESS_LEVEL" ]; then
|
||||
echo "XBPS_COMPRESS_LEVEL=$XBPS_COMPRESS_LEVEL" >> $XBPSSRC_CF
|
||||
fi
|
||||
|
||||
prepare_chroot()
|
||||
{
|
||||
local f=
|
||||
|
||||
# Create some required files.
|
||||
touch $XBPS_MASTERDIR/etc/mtab
|
||||
cp -f /etc/mtab $XBPS_MASTERDIR/etc
|
||||
cp -f /etc/resolv.conf $XBPS_MASTERDIR/etc
|
||||
[ -f /etc/localtime ] && cp -f /etc/localtime $XBPS_MASTERDIR/etc
|
||||
|
||||
for f in run/utmp log/btmp log/lastlog log/wtmp; do
|
||||
touch -f $XBPS_MASTERDIR/var/$f
|
||||
done
|
||||
@@ -90,6 +96,7 @@ prepare_chroot()
|
||||
cat > $XBPS_MASTERDIR/etc/passwd <<_EOF
|
||||
root:x:0:0:root:/root:/bin/bash
|
||||
nobody:x:99:99:Unprivileged User:/dev/null:/bin/false
|
||||
$(whoami):x:$(id -u):$(id -g):$(whoami) user:/dev/null:/bin/bash
|
||||
_EOF
|
||||
|
||||
# Default group list as specified by LFS.
|
||||
@@ -117,6 +124,7 @@ storage:x:19:
|
||||
scanner:x:20:
|
||||
nogroup:x:99:
|
||||
users:x:1000:
|
||||
$(whoami):x:$(id -g):
|
||||
_EOF
|
||||
|
||||
# Default file as in Ubuntu.
|
||||
@@ -133,28 +141,18 @@ ff02::2 ip6-allrouters
|
||||
ff02::3 ip6-allhosts
|
||||
_EOF
|
||||
|
||||
cp -f /etc/resolv.conf $XBPS_MASTERDIR/etc
|
||||
[ -f /etc/localtime ] && cp -f /etc/localtime $XBPS_MASTERDIR/etc
|
||||
# Create /bin/sh symlink to bash
|
||||
cd $XBPS_MASTERDIR/bin && ln -sf bash sh
|
||||
|
||||
touch $XBPS_MASTERDIR/.xbps_perms_done
|
||||
|
||||
}
|
||||
|
||||
rebuild_ldso_cache()
|
||||
{
|
||||
echo -n "==> Rebuilding chroot's dynamic linker cache..."
|
||||
chroot $XBPS_MASTERDIR /sbin/ldconfig -c /etc/ld.so.conf
|
||||
chroot $XBPS_MASTERDIR /sbin/ldconfig -C /etc/ld.so.cache
|
||||
echo " done."
|
||||
}
|
||||
|
||||
prepare_binpkg_repos()
|
||||
{
|
||||
if [ ! -f "$XBPS_MASTERDIR/.xbps_added_local_repo" ]; then
|
||||
msg_normal "Registering local binpkg repo..."
|
||||
chroot $XBPS_MASTERDIR xbps-repo.static add /xbps_packagesdir
|
||||
${chroot_cmd} $XBPS_MASTERDIR ${chroot_cmd_args} \
|
||||
xbps-repo.static add /xbps_packagesdir
|
||||
[ $? -eq 0 ] && touch -f $XBPS_MASTERDIR/.xbps_added_local_repo
|
||||
fi
|
||||
}
|
||||
@@ -191,8 +189,6 @@ install_xbps_utils()
|
||||
|
||||
if [ -n "$needed" ]; then
|
||||
echo "=> Installing the required XBPS utils."
|
||||
chroot $XBPS_MASTERDIR sh -c \
|
||||
"echo /usr/local/lib > /etc/ld.so.conf"
|
||||
for f in bin repo uhelper; do
|
||||
_cmd=$(which xbps-${f}.static 2>/dev/null)
|
||||
if [ -z "${_cmd}" ]; then
|
||||
@@ -201,7 +197,6 @@ install_xbps_utils()
|
||||
fi
|
||||
cp -f ${_cmd} $xbps_prefix/sbin
|
||||
done
|
||||
rebuild_ldso_cache
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -225,19 +220,20 @@ xbps_chroot_handler()
|
||||
|
||||
create_busybox_links
|
||||
install_xbps_utils
|
||||
mount_chroot_fs
|
||||
${sudo_cmd} @@XBPS_INSTALL_LIBEXECDIR@@/xbps-src-chroot-helper mount
|
||||
[ $? -ne 0 ] && return $?
|
||||
prepare_binpkg_repos
|
||||
|
||||
# Reinstall xbps-src in the chroot
|
||||
if [ ! -f $XBPS_MASTERDIR/usr/local/sbin/xbps-src ]; then
|
||||
env in_chroot=yes LANG=C PATH=$path \
|
||||
chroot $XBPS_MASTERDIR sh -c \
|
||||
${chroot_cmd} $XBPS_MASTERDIR ${chroot_cmd_args} sh -c \
|
||||
"cd /xbps/xbps-src && make install clean"
|
||||
fi
|
||||
|
||||
if [ "$action" = "chroot" ]; then
|
||||
env in_chroot=yes LANG=C PATH=$path \
|
||||
chroot $XBPS_MASTERDIR /bin/sh
|
||||
${chroot_cmd} $XBPS_MASTERDIR /bin/sh
|
||||
else
|
||||
local lenv
|
||||
[ -n "$only_destdir" ] && \
|
||||
@@ -245,75 +241,11 @@ xbps_chroot_handler()
|
||||
[ -n "$norm_builddir" ] && \
|
||||
action="-C $action"
|
||||
env in_chroot=yes LANG=C PATH=$path \
|
||||
${lenv} chroot $XBPS_MASTERDIR sh -c \
|
||||
${lenv} ${chroot_cmd} $XBPS_MASTERDIR \
|
||||
${chroot_cmd_args} sh -c \
|
||||
"cd /xbps/srcpkgs/$pkg && xbps-src $action"
|
||||
fi
|
||||
msg_normal "Exiting from the chroot on $XBPS_MASTERDIR."
|
||||
umount_chroot_fs
|
||||
}
|
||||
|
||||
mount_chroot_fs()
|
||||
{
|
||||
local cnt=
|
||||
|
||||
REQFS="sys proc dev xbps xbps_builddir \
|
||||
xbps_packagesdir xbps_srcdistdir"
|
||||
|
||||
for f in ${REQFS}; do
|
||||
if [ ! -f $XBPS_MASTERDIR/.${f}_mount_bind_done ]; then
|
||||
echo -n "=> Mounting $f in chroot... "
|
||||
local blah=
|
||||
case $f in
|
||||
xbps) blah=$XBPS_DISTRIBUTIONDIR;;
|
||||
xbps_builddir) blah=$XBPS_BUILDDIR;;
|
||||
xbps_srcdistdir) blah=$XBPS_SRCDISTDIR;;
|
||||
xbps_packagesdir) blah=$XBPS_PACKAGESDIR;;
|
||||
*) blah=/$f;;
|
||||
esac
|
||||
[ ! -d $blah ] && echo "failed." && continue
|
||||
mount --bind $blah $XBPS_MASTERDIR/$f
|
||||
if [ $? -eq 0 ]; then
|
||||
echo 1 > $XBPS_MASTERDIR/.${f}_mount_bind_done
|
||||
echo "done."
|
||||
else
|
||||
echo "failed."
|
||||
fi
|
||||
else
|
||||
cnt=$(cat $XBPS_MASTERDIR/.${f}_mount_bind_done)
|
||||
cnt=$(($cnt + 1))
|
||||
echo $cnt > $XBPS_MASTERDIR/.${f}_mount_bind_done
|
||||
fi
|
||||
done
|
||||
unset f
|
||||
}
|
||||
|
||||
umount_chroot_fs()
|
||||
{
|
||||
local fs=
|
||||
local dir=
|
||||
local cnt=
|
||||
|
||||
for fs in ${REQFS}; do
|
||||
[ ! -f $XBPS_MASTERDIR/.${fs}_mount_bind_done ] && continue
|
||||
cnt=$(cat $XBPS_MASTERDIR/.${fs}_mount_bind_done)
|
||||
if [ $cnt -gt 1 ]; then
|
||||
cnt=$(($cnt - 1))
|
||||
echo $cnt > $XBPS_MASTERDIR/.${fs}_mount_bind_done
|
||||
else
|
||||
echo -n "=> Unmounting $fs from chroot... "
|
||||
umount -f $XBPS_MASTERDIR/$fs
|
||||
if [ $? -eq 0 ]; then
|
||||
rm -f $XBPS_MASTERDIR/.${fs}_mount_bind_done
|
||||
echo "done."
|
||||
else
|
||||
echo "failed."
|
||||
fi
|
||||
fi
|
||||
unset fs
|
||||
done
|
||||
|
||||
for dir in ${EXTDIRS}; do
|
||||
[ -f $XBPS_MASTERDIR/.${dir}_mount_bind_done ] && continue
|
||||
[ -d $XBPS_MASTERDIR/$dir ] && rmdir $XBPS_MASTERDIR/$dir
|
||||
done
|
||||
${sudo_cmd} @@XBPS_INSTALL_LIBEXECDIR@@/xbps-src-chroot-helper umount
|
||||
return $?
|
||||
}
|
||||
@@ -39,23 +39,6 @@ run_func()
|
||||
fi
|
||||
}
|
||||
|
||||
run_rootcmd()
|
||||
{
|
||||
local lenv=
|
||||
local usesudo="$1"
|
||||
|
||||
[ -n "$in_chroot" ] && unset fakeroot_cmd
|
||||
|
||||
lenv="XBPS_DISTRIBUTIONDIR=$XBPS_DISTRIBUTIONDIR"
|
||||
|
||||
shift
|
||||
if [ "$usesudo" = "yes" -a -z "$in_chroot" ]; then
|
||||
sudo env ${lenv} $@
|
||||
else
|
||||
env ${lenv} ${fakeroot_cmd} $@
|
||||
fi
|
||||
}
|
||||
|
||||
msg_error()
|
||||
{
|
||||
[ -z "$1" ] && return 1
|
||||
|
||||
70
xbps-src/shutils/init_funcs.sh.in
Normal file
70
xbps-src/shutils/init_funcs.sh.in
Normal file
@@ -0,0 +1,70 @@
|
||||
#-
|
||||
# Copyright (c) 2008-2010 Juan Romero Pardines.
|
||||
# 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.
|
||||
#-
|
||||
|
||||
set_defvars()
|
||||
{
|
||||
local DDIRS i instver instsharedir
|
||||
|
||||
instsharedir=@@XBPS_INSTALL_SHAREDIR@@
|
||||
|
||||
: ${XBPS_TRIGGERSDIR:=$instsharedir/triggers}
|
||||
: ${XBPS_HELPERSDIR:=$instsharedir/helpers}
|
||||
: ${XBPS_SHUTILSDIR:=$instsharedir/shutils}
|
||||
: ${XBPS_COMMONVARSDIR:=$instsharedir/common}
|
||||
: ${XBPS_DBDIR:=$XBPS_MASTERDIR/var/db/xbps}
|
||||
: ${XBPS_META_PATH:=$XBPS_DBDIR/}
|
||||
: ${XBPS_PKGMETADIR:=$XBPS_DBDIR/metadata}
|
||||
: ${XBPS_SRCPKGDIR:=$XBPS_DISTRIBUTIONDIR/srcpkgs}
|
||||
if [ -n "$in_chroot" ]; then
|
||||
: ${XBPS_DESTDIR:=/pkg-destdir}
|
||||
else
|
||||
: ${XBPS_DESTDIR:=$XBPS_MASTERDIR/pkg-destdir}
|
||||
fi
|
||||
|
||||
DDIRS="XBPS_TRIGGERSDIR XBPS_HELPERSDIR"
|
||||
DDIRS="$DDIRS XBPS_COMMONVARSDIR XBPS_SHUTILSDIR"
|
||||
for i in ${DDIRS}; do
|
||||
eval val="\$$i"
|
||||
[ ! -d "$val" ] && msg_error "cannot find $i, aborting."
|
||||
done
|
||||
|
||||
export XBPS_PKGDB_CMD="xbps-uhelper.static -r $XBPS_MASTERDIR"
|
||||
export XBPS_BIN_CMD="xbps-bin.static -r $XBPS_MASTERDIR"
|
||||
export XBPS_DIGEST_CMD="xbps-uhelper.static digest"
|
||||
export XBPS_CMPVER_CMD="xbps-uhelper.static cmpver"
|
||||
export XBPS_FETCH_CMD="xbps-uhelper.static fetch"
|
||||
|
||||
#
|
||||
# Check that installed xbps utils version is recent enough.
|
||||
#
|
||||
instver=$(${XBPS_PKGDB_CMD} -V)
|
||||
${XBPS_CMPVER_CMD} "${instver}" "${XBPS_UTILS_REQVER}"
|
||||
if [ $? -eq 255 ]; then
|
||||
echo -n "Your xbps utilities are too old, "
|
||||
echo "required version: ${XBPS_UTILS_REQVER}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
}
|
||||
@@ -1,182 +0,0 @@
|
||||
#-
|
||||
# Copyright (c) 2008-2009 Juan Romero Pardines.
|
||||
# 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.
|
||||
#-
|
||||
|
||||
#
|
||||
# Runs the "install" phase for a pkg. This consists in installing package
|
||||
# into the destination directory.
|
||||
#
|
||||
|
||||
strip_files()
|
||||
{
|
||||
if [ ! -x /usr/bin/strip ]; then
|
||||
return 0
|
||||
fi
|
||||
[ -n "$nostrip" ] && return 0
|
||||
|
||||
msg_normal "Finding binaries/libraries to strip..."
|
||||
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
|
||||
|
||||
[ -z $pkgname ] && return 1
|
||||
|
||||
if [ -n "$revision" ]; then
|
||||
lver="${version}_${revision}"
|
||||
else
|
||||
lver="${version}"
|
||||
fi
|
||||
|
||||
#
|
||||
# There's nothing we can do if we are a meta template.
|
||||
# Just creating the dir is enough to write the package metadata.
|
||||
#
|
||||
if [ "$build_style" = "meta-template" ]; then
|
||||
mkdir -p $XBPS_DESTDIR/$pkgname-$version
|
||||
return 0
|
||||
fi
|
||||
|
||||
saved_wrksrc=$wrksrc
|
||||
cd $wrksrc || msg_error "can't change cwd to wrksrc!"
|
||||
if [ -n "$build_wrksrc" ]; then
|
||||
cd $build_wrksrc \
|
||||
|| msg_error "can't change cwd to build_wrksrc!"
|
||||
fi
|
||||
|
||||
# Run pre_install func.
|
||||
run_func pre_install || msg_error "pre_install stage failed!"
|
||||
|
||||
msg_normal "Running install phase for $pkgname-$lver."
|
||||
|
||||
# Type of installation: custom, make or python.
|
||||
case "$build_style" in
|
||||
custom-install)
|
||||
run_func do_install || msg_error "do_install stage failed!"
|
||||
;;
|
||||
python-module)
|
||||
. $XBPS_HELPERSDIR/python-module.sh
|
||||
run_func do_install || msg_error "python module install failed!"
|
||||
;;
|
||||
*)
|
||||
make_install $lver
|
||||
;;
|
||||
esac
|
||||
|
||||
# Run post_install func.
|
||||
run_func post_install || msg_error "post_install stage failed!"
|
||||
|
||||
# Remove libtool archives by default.
|
||||
if [ -z "$keep_libtool_archives" ]; then
|
||||
find ${DESTDIR} -type f -name \*.la -delete
|
||||
fi
|
||||
# Always remove perllocal.pod and .packlist files.
|
||||
if [ "$pkgname" != "perl" ]; then
|
||||
find ${DESTDIR} -type f -name perllocal.pod -delete
|
||||
find ${DESTDIR} -type f -name .packlist -delete
|
||||
fi
|
||||
# Remove empty directories by default.
|
||||
if [ -z "$keep_empty_dirs" ]; then
|
||||
find ${DESTDIR} -depth -type d -empty -delete
|
||||
fi
|
||||
# Strip bins/libs.
|
||||
if [ -z "$noarch" ]; then
|
||||
strip_files
|
||||
fi
|
||||
|
||||
msg_normal "Installed $pkgname-$lver into $XBPS_DESTDIR."
|
||||
|
||||
if [ "$build_style" != "custom-install" -a -z "$distfiles" ]; then
|
||||
touch -f $XBPS_INSTALL_DONE
|
||||
fi
|
||||
|
||||
#
|
||||
# Build subpackages if found.
|
||||
#
|
||||
for subpkg in ${subpackages}; do
|
||||
if [ -n "$revision" ]; then
|
||||
spkgrev="${subpkg}-${version}_${revision}"
|
||||
else
|
||||
spkgrev="${subpkg}-${version}"
|
||||
fi
|
||||
check_installed_pkg ${spkgrev}
|
||||
[ $? -eq 0 ] && continue
|
||||
|
||||
msg_normal "Preparing ${sourcepkg} subpackage: ${subpkg}"
|
||||
if [ ! -f $XBPS_SRCPKGDIR/${sourcepkg}/${subpkg}.template ]; then
|
||||
msg_error "Cannot find ${subpkg} subpkg build template!"
|
||||
fi
|
||||
. $XBPS_SRCPKGDIR/${sourcepkg}/${subpkg}.template
|
||||
pkgname=${subpkg}
|
||||
set_tmpl_common_vars
|
||||
run_func do_install || \
|
||||
msg_error "$pkgname do_install stage failed!"
|
||||
done
|
||||
|
||||
#
|
||||
# Remove $wrksrc if -C not specified.
|
||||
#
|
||||
if [ -d "$saved_wrksrc" -a -z "$dontrm_builddir" ]; then
|
||||
rm -rf $saved_wrksrc && \
|
||||
msg_normal "Removed $sourcepkg-$lver build directory."
|
||||
fi
|
||||
}
|
||||
|
||||
#
|
||||
# Installs a package via 'make install ...'.
|
||||
#
|
||||
|
||||
make_install()
|
||||
{
|
||||
local lver="$1"
|
||||
|
||||
if [ -z "$make_install_target" ]; then
|
||||
make_install_target="DESTDIR=${DESTDIR} install"
|
||||
fi
|
||||
|
||||
[ -z "$make_cmd" ] && make_cmd=/usr/bin/make
|
||||
|
||||
. $XBPS_SHUTILSDIR/buildvars_funcs.sh
|
||||
set_build_vars
|
||||
|
||||
#
|
||||
# Install package via make.
|
||||
#
|
||||
run_rootcmd no ${make_cmd} ${make_install_target} \
|
||||
${make_install_args} || msg_error "installing $pkgname-$lver"
|
||||
|
||||
# Unset build vars.
|
||||
unset_build_vars
|
||||
}
|
||||
@@ -56,7 +56,7 @@ binpkg_cleanup()
|
||||
#
|
||||
xbps_make_binpkg_real()
|
||||
{
|
||||
local mfiles binpkg pkgdir arch use_sudo lver dirs _dirs d clevel
|
||||
local mfiles binpkg pkgdir arch lver dirs _dirs d clevel
|
||||
|
||||
if [ ! -d "${DESTDIR}" ]; then
|
||||
msg_warn "cannot find destdir for $pkgname... skipping!"
|
||||
@@ -69,11 +69,6 @@ xbps_make_binpkg_real()
|
||||
else
|
||||
arch=$xbps_machine
|
||||
fi
|
||||
if [ -n "$base_chroot" ]; then
|
||||
use_sudo=no
|
||||
else
|
||||
use_sudo=yes
|
||||
fi
|
||||
if [ -n "$revision" ]; then
|
||||
lver="${version}_${revision}"
|
||||
else
|
||||
@@ -116,8 +111,9 @@ xbps_make_binpkg_real()
|
||||
trap "binpkg_cleanup" INT
|
||||
|
||||
echo -n "=> Building $binpkg... "
|
||||
run_rootcmd $use_sudo tar --exclude "var/db/xbps/metadata/*/flist" \
|
||||
-cpf - ${mfiles} ${dirs} | \
|
||||
${fakeroot_cmd} ${fakeroot_cmd_args} \
|
||||
tar --exclude "var/db/xbps/metadata/*/flist" \
|
||||
-cpf - ${mfiles} ${dirs} | \
|
||||
$XBPS_COMPRESS_CMD ${clevel} -qf > $pkgdir/$binpkg
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "done."
|
||||
|
||||
@@ -42,7 +42,6 @@ install_pkg()
|
||||
fi
|
||||
|
||||
pkg="$curpkgn-$version"
|
||||
. $XBPS_SHUTILSDIR/tmpl_funcs.sh
|
||||
if [ -n "$doing_deps" ]; then
|
||||
reset_tmpl_vars
|
||||
setup_tmpl $curpkgn
|
||||
@@ -61,21 +60,10 @@ install_pkg()
|
||||
fi
|
||||
fi
|
||||
|
||||
#
|
||||
# Execute command in chroot if necessary.
|
||||
#
|
||||
if [ -z "$base_chroot" -a -z "$in_chroot" ]; then
|
||||
. $XBPS_SHUTILSDIR/chroot.sh
|
||||
[ -n "$install_destdir_target" ] && cdestdir=yes
|
||||
xbps_chroot_handler install $curpkgn $cdestdir $dontrm_builddir
|
||||
return $?
|
||||
fi
|
||||
|
||||
#
|
||||
# Install dependencies required by this package.
|
||||
#
|
||||
if [ -z "$doing_deps" ]; then
|
||||
. $XBPS_SHUTILSDIR/builddep_funcs.sh
|
||||
install_dependencies_pkg $pkg
|
||||
#
|
||||
# At this point all required deps are installed, and
|
||||
@@ -106,8 +94,11 @@ install_pkg()
|
||||
build_src_phase
|
||||
fi
|
||||
|
||||
. $XBPS_SHUTILSDIR/install_funcs.sh
|
||||
install_src_phase
|
||||
# Install pkg into destdir.
|
||||
env xbps_machine=${xbps_machine} \
|
||||
${fakeroot_cmd} ${fakeroot_cmd_args} \
|
||||
@@XBPS_INSTALL_LIBEXECDIR@@/xbps-src-doinst-helper \
|
||||
${curpkgn} || return $?
|
||||
|
||||
# Always write metadata to package's destdir.
|
||||
. $XBPS_SHUTILSDIR/metadata.sh
|
||||
@@ -142,7 +133,8 @@ install_pkg_with_binpkg()
|
||||
fi
|
||||
|
||||
msg_normal "Installing binary pkg: $pkgpattern"
|
||||
$XBPS_BIN_CMD -y install "$pkgpattern"
|
||||
${fakeroot_cmd} ${fakeroot_cmd_args} ${XBPS_BIN_CMD} \
|
||||
-y install "$pkgpattern"
|
||||
return $?
|
||||
}
|
||||
|
||||
@@ -97,7 +97,9 @@ setup_tmpl()
|
||||
local pkg="$1"
|
||||
|
||||
[ -z "$pkg" ] && return 1
|
||||
[ "$pkgname" = "$pkg" ] && return 0
|
||||
if [ "$pkgname" = "$pkg" ]; then
|
||||
[ -n "$DESTDIR" ] && return 0
|
||||
fi
|
||||
|
||||
for f in $(echo $XBPS_COMMONVARSDIR/*.sh); do
|
||||
[ -r ${f} ] && . ${f}
|
||||
|
||||
Reference in New Issue
Block a user