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:
parent
5d6d7b0f4e
commit
e57940985e
15 changed files with 406 additions and 242 deletions
|
@ -1,36 +1,43 @@
|
||||||
include vars.mk
|
include vars.mk
|
||||||
|
|
||||||
BIN = xbps-src
|
BINS = xbps-src
|
||||||
SUBDIRS = etc common helpers triggers shutils
|
SUBDIRS = etc common libexec helpers triggers shutils
|
||||||
|
|
||||||
.PHONY: all
|
.PHONY: all
|
||||||
all:
|
all:
|
||||||
sed -e "s|@@XBPS_INSTALL_PREFIX@@|$(PREFIX)|g" \
|
for bin in $(BINS); do \
|
||||||
-e "s|@@XBPS_INSTALL_ETCDIR@@|$(ETCDIR)|g" \
|
sed -e "s|@@XBPS_INSTALL_PREFIX@@|$(PREFIX)|g" \
|
||||||
-e "s|@@XBPS_INSTALL_SHAREDIR@@|$(SHAREDIR)|g" \
|
-e "s|@@XBPS_INSTALL_ETCDIR@@|$(ETCDIR)|g" \
|
||||||
$(BIN).sh.in > $(BIN)
|
-e "s|@@XBPS_INSTALL_SHAREDIR@@|$(SHAREDIR)|g" \
|
||||||
for dir in $(SUBDIRS); do \
|
-e "s|@@XBPS_INSTALL_SBINDIR@@|$(SBINDIR)|g" \
|
||||||
$(MAKE) -C $$dir || exit 1; \
|
$$bin.sh.in > $$bin; \
|
||||||
|
done
|
||||||
|
for dir in $(SUBDIRS); do \
|
||||||
|
$(MAKE) -C $$dir || exit 1; \
|
||||||
done
|
done
|
||||||
|
|
||||||
.PHONY: clean
|
.PHONY: clean
|
||||||
clean:
|
clean:
|
||||||
-rm -f $(BIN)
|
-rm -f $(BINS)
|
||||||
for dir in $(SUBDIRS); do \
|
for dir in $(SUBDIRS); do \
|
||||||
$(MAKE) -C $$dir clean || exit 1; \
|
$(MAKE) -C $$dir clean || exit 1; \
|
||||||
done
|
done
|
||||||
|
|
||||||
.PHONY: install
|
.PHONY: install
|
||||||
install: all
|
install: all
|
||||||
install -d $(SBINDIR)
|
install -d $(SBINDIR)
|
||||||
install -m 755 $(BIN) $(SBINDIR)
|
for bin in $(BINS); do \
|
||||||
for dir in $(SUBDIRS); do \
|
install -m 755 $$bin $(SBINDIR); \
|
||||||
|
done
|
||||||
|
for dir in $(SUBDIRS); do \
|
||||||
$(MAKE) -C $$dir install || exit 1; \
|
$(MAKE) -C $$dir install || exit 1; \
|
||||||
done
|
done
|
||||||
|
|
||||||
.PHONY: uninstall
|
.PHONY: uninstall
|
||||||
uninstall:
|
uninstall:
|
||||||
-rm -f $(SBINDIR)/$(BIN)
|
for bin in $(BINS); do \
|
||||||
for dir in $(SUBDIRS); do \
|
rm -f $(SBINDIR)/$$bin; \
|
||||||
|
done
|
||||||
|
for dir in $(SUBDIRS); do \
|
||||||
$(MAKE) -C $$dir uninstall || exit 1; \
|
$(MAKE) -C $$dir uninstall || exit 1; \
|
||||||
done
|
done
|
||||||
|
|
|
@ -4,11 +4,12 @@
|
||||||
|
|
||||||
#
|
#
|
||||||
# Directory where xbps-src has been installed. By default /usr/local.
|
# Directory where xbps-src has been installed. By default /usr/local.
|
||||||
|
# Usually you don't have to change this one, it's set by "make install".
|
||||||
#
|
#
|
||||||
XBPS_INSTALLDIR=@@XBPS_INSTALL_PREFIX@@
|
XBPS_INSTALLDIR=@@XBPS_INSTALL_PREFIX@@
|
||||||
|
|
||||||
#
|
#
|
||||||
# Directory where the xbps-src GIT repository is available. This is
|
# Directory where the xbps-src GIT repository is stored. This is
|
||||||
# required to be mounted in the chroot.
|
# required to be mounted in the chroot.
|
||||||
#
|
#
|
||||||
XBPS_DISTRIBUTIONDIR=$HOME/xbps-templates
|
XBPS_DISTRIBUTIONDIR=$HOME/xbps-templates
|
||||||
|
@ -19,13 +20,14 @@ XBPS_DISTRIBUTIONDIR=$HOME/xbps-templates
|
||||||
XBPS_MASTERDIR=$XBPS_DISTRIBUTIONDIR/masterdir
|
XBPS_MASTERDIR=$XBPS_DISTRIBUTIONDIR/masterdir
|
||||||
|
|
||||||
#
|
#
|
||||||
# Binary packages directory: this is where the binary packages will
|
# Directory where a local binary package repository is available
|
||||||
# be created to.
|
# (or will be created from). Packages will be stored here.
|
||||||
#
|
#
|
||||||
XBPS_PACKAGESDIR=$XBPS_DISTRIBUTIONDIR/packages
|
XBPS_PACKAGESDIR=$XBPS_DISTRIBUTIONDIR/packages
|
||||||
|
|
||||||
#
|
#
|
||||||
# Directory where source files will be extracted to.
|
# Directory where source files will be extracted to and build object
|
||||||
|
# files will live on.
|
||||||
#
|
#
|
||||||
XBPS_BUILDDIR=$XBPS_DISTRIBUTIONDIR/builddir
|
XBPS_BUILDDIR=$XBPS_DISTRIBUTIONDIR/builddir
|
||||||
|
|
||||||
|
@ -41,13 +43,13 @@ XBPS_CFLAGS="-O2 -pipe"
|
||||||
XBPS_CXXFLAGS="$XBPS_CFLAGS"
|
XBPS_CXXFLAGS="$XBPS_CFLAGS"
|
||||||
|
|
||||||
#
|
#
|
||||||
# Number of jobs when running GNU or BSD make style packages.
|
# Number of jobs when running make(1)-alike commands.
|
||||||
#
|
#
|
||||||
#XBPS_MAKEJOBS=4
|
#XBPS_MAKEJOBS=4
|
||||||
|
|
||||||
#
|
#
|
||||||
# Compression program used to build the binary packages.
|
# Compression program used to build the binary packages.
|
||||||
# Possible values: gzip, bzip2 or xz. Default xz.
|
# Possible value: gzip, bzip2 or xz. Default xz.
|
||||||
#
|
#
|
||||||
XBPS_COMPRESS_CMD=xz
|
XBPS_COMPRESS_CMD=xz
|
||||||
|
|
||||||
|
@ -60,7 +62,24 @@ XBPS_COMPRESS_CMD=xz
|
||||||
|
|
||||||
#
|
#
|
||||||
# Install required build time dependencies from binary packages,
|
# Install required build time dependencies from binary packages,
|
||||||
# XBPS_PACKAGESDIR will be used in the chroot to resolve
|
# XBPS_PACKAGESDIR will be used in the chroot to resolve builddeps.
|
||||||
# builddeps.
|
|
||||||
#
|
#
|
||||||
#XBPS_PREFER_BINPKG_DEPS=yes
|
#XBPS_PREFER_BINPKG_DEPS=yes
|
||||||
|
|
||||||
|
#
|
||||||
|
# Build packages with your unprivileged user in the chroot
|
||||||
|
# via capchroot. The only required steps with privileges are
|
||||||
|
# the bind mounts, a helper script (xbps-src-chroot-helper) needs
|
||||||
|
# to be run with sudo for this task.
|
||||||
|
#
|
||||||
|
# fakeroot is only used for the installation stage via the helper
|
||||||
|
# script xbps-src-doinst-helper.
|
||||||
|
#
|
||||||
|
# capchroot allows ordinary users to use the chroot(2) syscall.
|
||||||
|
# To make this work, uncomment this option and run the following
|
||||||
|
# commands (as root):
|
||||||
|
#
|
||||||
|
# $ setcap cap_sys_chroot=ep /usr/bin/capchroot
|
||||||
|
# $ echo "/path/to/masterdir $(whoami)" >> /etc/capchroot.allow
|
||||||
|
#
|
||||||
|
#XBPS_USE_CAPCHROOT=yes
|
||||||
|
|
30
xbps-src/libexec/Makefile
Normal file
30
xbps-src/libexec/Makefile
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
include ../vars.mk
|
||||||
|
|
||||||
|
BINS = xbps-src-chroot-helper xbps-src-doinst-helper
|
||||||
|
|
||||||
|
.PHONY: all
|
||||||
|
all:
|
||||||
|
for bin in $(BINS); do \
|
||||||
|
sed -e "s|@@XBPS_INSTALL_PREFIX@@|$(PREFIX)|g" \
|
||||||
|
-e "s|@@XBPS_INSTALL_ETCDIR@@|$(ETCDIR)|g" \
|
||||||
|
-e "s|@@XBPS_INSTALL_SHAREDIR@@|$(SHAREDIR)|g" \
|
||||||
|
-e "s|@@XBPS_INSTALL_SBINDIR@@|$(SBINDIR)|g" \
|
||||||
|
$$bin.sh.in > $$bin; \
|
||||||
|
done
|
||||||
|
|
||||||
|
.PHONY: clean
|
||||||
|
clean:
|
||||||
|
-rm -f $(BINS)
|
||||||
|
|
||||||
|
.PHONY: install
|
||||||
|
install: all
|
||||||
|
install -d $(DESTDIR)$(LIBEXECDIR)
|
||||||
|
for bin in $(BINS); do \
|
||||||
|
install -m 755 $$bin $(DESTDIR)$(LIBEXECDIR); \
|
||||||
|
done
|
||||||
|
|
||||||
|
.PHONY: uninstall
|
||||||
|
uninstall:
|
||||||
|
for bin in $(BINS); do \
|
||||||
|
rm -f $(DESTDIR)$(LIBEXECDIR)/$$bin; \
|
||||||
|
done
|
111
xbps-src/libexec/xbps-src-chroot-helper.sh.in
Normal file
111
xbps-src/libexec/xbps-src-chroot-helper.sh.in
Normal file
|
@ -0,0 +1,111 @@
|
||||||
|
#!/bin/sh
|
||||||
|
#-
|
||||||
|
# Copyright (c) 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.
|
||||||
|
#-
|
||||||
|
|
||||||
|
# Umount stuff if SIGINT or SIGQUIT was caught
|
||||||
|
trap umount_chroot_fs INT QUIT
|
||||||
|
|
||||||
|
HANDLER="$1"
|
||||||
|
|
||||||
|
. @@XBPS_INSTALL_ETCDIR@@/xbps-src.conf
|
||||||
|
|
||||||
|
EXTDIRS="xbps xbps_builddir xbps_packagesdir xbps_srcdistdir"
|
||||||
|
REQFS="sys proc dev ${EXTDIRS}"
|
||||||
|
|
||||||
|
mount_chroot_fs()
|
||||||
|
{
|
||||||
|
local cnt f blah
|
||||||
|
|
||||||
|
for f in ${REQFS}; do
|
||||||
|
if [ ! -f ${XBPS_MASTERDIR}/.${f}_mount_bind_done ]; then
|
||||||
|
echo -n "=> Mounting /${f} in chroot... "
|
||||||
|
if [ ! -d ${XBPS_MASTERDIR}/${f} ]; then
|
||||||
|
mkdir -p ${XBPS_MASTERDIR}/${f}
|
||||||
|
fi
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
umount_chroot_fs()
|
||||||
|
{
|
||||||
|
local fs dir 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
|
||||||
|
|
||||||
|
# Remove created dirs
|
||||||
|
for dir in ${EXTDIRS}; do
|
||||||
|
[ -f ${XBPS_MASTERDIR}/.${dir}_mount_bind_done ] && continue
|
||||||
|
[ -d ${XBPS_MASTERDIR}/${dir} ] && rmdir ${XBPS_MASTERDIR}/${dir}
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ $# -ne 1 ]; then
|
||||||
|
echo "$0: mount || umount"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
case "${HANDLER}" in
|
||||||
|
mount) mount_chroot_fs;;
|
||||||
|
umount) umount_chroot_fs;;
|
||||||
|
*) echo "$0: invalid target." && exit 1;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
exit 0
|
|
@ -1,5 +1,6 @@
|
||||||
|
#!/bin/sh
|
||||||
#-
|
#-
|
||||||
# Copyright (c) 2008-2009 Juan Romero Pardines.
|
# Copyright (c) 2010 Juan Romero Pardines.
|
||||||
# All rights reserved.
|
# All rights reserved.
|
||||||
#
|
#
|
||||||
# Redistribution and use in source and binary forms, with or without
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -23,10 +24,16 @@
|
||||||
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#-
|
#-
|
||||||
|
|
||||||
#
|
PKG_TMPLNAME="$1"
|
||||||
# Runs the "install" phase for a pkg. This consists in installing package
|
|
||||||
# into the destination directory.
|
. @@XBPS_INSTALL_ETCDIR@@/xbps-src.conf
|
||||||
#
|
. @@XBPS_INSTALL_SHAREDIR@@/shutils/init_funcs.sh
|
||||||
|
|
||||||
|
set_defvars
|
||||||
|
|
||||||
|
. $XBPS_SHUTILSDIR/tmpl_funcs.sh
|
||||||
|
. $XBPS_SHUTILSDIR/common_funcs.sh
|
||||||
|
. $XBPS_SHUTILSDIR/builddep_funcs.sh
|
||||||
|
|
||||||
strip_files()
|
strip_files()
|
||||||
{
|
{
|
||||||
|
@ -40,10 +47,10 @@ strip_files()
|
||||||
case "$(file -biz $f)" in
|
case "$(file -biz $f)" in
|
||||||
application/x-executable*)
|
application/x-executable*)
|
||||||
/usr/bin/strip $f && \
|
/usr/bin/strip $f && \
|
||||||
echo "===> Stripped executable: $(basename $f)";;
|
echo "=> Stripped executable: $(basename $f)";;
|
||||||
application/x-sharedlib*|application/x-archive*)
|
application/x-sharedlib*|application/x-archive*)
|
||||||
/usr/bin/strip -S $f && \
|
/usr/bin/strip -S $f && \
|
||||||
echo "===> Stripped library: $(basename $f)";;
|
echo "=> Stripped library: $(basename $f)";;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
@ -166,7 +173,7 @@ make_install()
|
||||||
make_install_target="DESTDIR=${DESTDIR} install"
|
make_install_target="DESTDIR=${DESTDIR} install"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
[ -z "$make_cmd" ] && make_cmd=/usr/bin/make
|
[ -z "$make_cmd" ] && make_cmd=make
|
||||||
|
|
||||||
. $XBPS_SHUTILSDIR/buildvars_funcs.sh
|
. $XBPS_SHUTILSDIR/buildvars_funcs.sh
|
||||||
set_build_vars
|
set_build_vars
|
||||||
|
@ -174,9 +181,16 @@ make_install()
|
||||||
#
|
#
|
||||||
# Install package via make.
|
# Install package via make.
|
||||||
#
|
#
|
||||||
run_rootcmd no ${make_cmd} ${make_install_target} \
|
${make_cmd} ${make_install_target} \
|
||||||
${make_install_args} || msg_error "installing $pkgname-$lver"
|
${make_install_args} || msg_error "installing $pkgname-$lver"
|
||||||
|
|
||||||
# Unset build vars.
|
# Unset build vars.
|
||||||
unset_build_vars
|
unset_build_vars
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[ -z "$PKG_TMPLNAME" ] && exit 1
|
||||||
|
|
||||||
|
setup_tmpl $PKG_TMPLNAME
|
||||||
|
install_src_phase $pkgname
|
||||||
|
|
||||||
|
exit $?
|
|
@ -1,10 +1,19 @@
|
||||||
include ../vars.mk
|
include ../vars.mk
|
||||||
|
|
||||||
|
SCRIPTS = chroot.sh init_funcs.sh pkgtarget_funcs.sh
|
||||||
|
|
||||||
.PHONY: all
|
.PHONY: all
|
||||||
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
|
.PHONY: clean
|
||||||
clean:
|
clean:
|
||||||
|
-rm -f $(SCRIPTS)
|
||||||
|
|
||||||
.PHONY: install
|
.PHONY: install
|
||||||
install:
|
install:
|
||||||
|
|
|
@ -77,7 +77,18 @@ install_pkg_deps()
|
||||||
prev_pkg="$j"
|
prev_pkg="$j"
|
||||||
done
|
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
|
[ -n "$prev_pkg" ] && unset prev_pkg
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,7 +132,13 @@ install_dependencies_pkg()
|
||||||
for i in ${notinstalled_deps}; do
|
for i in ${notinstalled_deps}; do
|
||||||
if [ -n "$XBPS_PREFER_BINPKG_DEPS" ]; then
|
if [ -n "$XBPS_PREFER_BINPKG_DEPS" ]; then
|
||||||
install_pkg_with_binpkg ${i}
|
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
|
fi
|
||||||
pkgn=$($XBPS_PKGDB_CMD getpkgdepname ${i})
|
pkgn=$($XBPS_PKGDB_CMD getpkgdepname ${i})
|
||||||
check_pkgdep_matched "${i}"
|
check_pkgdep_matched "${i}"
|
||||||
|
@ -131,7 +148,21 @@ install_dependencies_pkg()
|
||||||
check_build_depends_pkg
|
check_build_depends_pkg
|
||||||
if [ $? -eq 1 ]; then
|
if [ $? -eq 1 ]; then
|
||||||
msg_normal "Installing $lpkgname dependency: $pkgn."
|
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
|
else
|
||||||
install_pkg_deps "${i}" $pkg
|
install_pkg_deps "${i}" $pkg
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -29,10 +29,19 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
# Umount stuff if SIGINT or SIGQUIT was caught
|
# 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
|
[ -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
|
. $XBPS_SHUTILSDIR/builddep_funcs.sh
|
||||||
check_installed_pkg xbps-base-chroot-0.11
|
check_installed_pkg xbps-base-chroot-0.11
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
|
@ -41,21 +50,11 @@ if [ $? -ne 0 ]; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
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."
|
msg_normal "Entering into the chroot on $XBPS_MASTERDIR."
|
||||||
|
|
||||||
EXTDIRS="xbps xbps_builddir xbps_destdir xbps_packagesdir \
|
if [ ! -d $XBPS_MASTERDIR/usr/local/etc ]; then
|
||||||
xbps_srcdistdir"
|
mkdir -p $XBPS_MASTERDIR/usr/local/etc
|
||||||
REQDIRS="bin sbin tmp var sys proc dev usr/local/etc ${EXTDIRS}"
|
fi
|
||||||
for f in ${REQDIRS}; do
|
|
||||||
[ ! -d $XBPS_MASTERDIR/$f ] && mkdir -p $XBPS_MASTERDIR/$f
|
|
||||||
done
|
|
||||||
unset f REQDIRS
|
|
||||||
|
|
||||||
XBPSSRC_CF=$XBPS_MASTERDIR/usr/local/etc/xbps-src.conf
|
XBPSSRC_CF=$XBPS_MASTERDIR/usr/local/etc/xbps-src.conf
|
||||||
|
|
||||||
|
@ -73,13 +72,20 @@ fi
|
||||||
if [ -n "$XBPS_PREFER_BINPKG_DEPS" ]; then
|
if [ -n "$XBPS_PREFER_BINPKG_DEPS" ]; then
|
||||||
echo "XBPS_PREFER_BINPKG_DEPS=$XBPS_PREFER_BINPKG_DEPS" >> $XBPSSRC_CF
|
echo "XBPS_PREFER_BINPKG_DEPS=$XBPS_PREFER_BINPKG_DEPS" >> $XBPSSRC_CF
|
||||||
fi
|
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()
|
prepare_chroot()
|
||||||
{
|
{
|
||||||
local f=
|
local f=
|
||||||
|
|
||||||
# Create some required files.
|
# 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
|
for f in run/utmp log/btmp log/lastlog log/wtmp; do
|
||||||
touch -f $XBPS_MASTERDIR/var/$f
|
touch -f $XBPS_MASTERDIR/var/$f
|
||||||
done
|
done
|
||||||
|
@ -90,6 +96,7 @@ prepare_chroot()
|
||||||
cat > $XBPS_MASTERDIR/etc/passwd <<_EOF
|
cat > $XBPS_MASTERDIR/etc/passwd <<_EOF
|
||||||
root:x:0:0:root:/root:/bin/bash
|
root:x:0:0:root:/root:/bin/bash
|
||||||
nobody:x:99:99:Unprivileged User:/dev/null:/bin/false
|
nobody:x:99:99:Unprivileged User:/dev/null:/bin/false
|
||||||
|
$(whoami):x:$(id -u):$(id -g):$(whoami) user:/dev/null:/bin/bash
|
||||||
_EOF
|
_EOF
|
||||||
|
|
||||||
# Default group list as specified by LFS.
|
# Default group list as specified by LFS.
|
||||||
|
@ -117,6 +124,7 @@ storage:x:19:
|
||||||
scanner:x:20:
|
scanner:x:20:
|
||||||
nogroup:x:99:
|
nogroup:x:99:
|
||||||
users:x:1000:
|
users:x:1000:
|
||||||
|
$(whoami):x:$(id -g):
|
||||||
_EOF
|
_EOF
|
||||||
|
|
||||||
# Default file as in Ubuntu.
|
# Default file as in Ubuntu.
|
||||||
|
@ -133,28 +141,18 @@ ff02::2 ip6-allrouters
|
||||||
ff02::3 ip6-allhosts
|
ff02::3 ip6-allhosts
|
||||||
_EOF
|
_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
|
# Create /bin/sh symlink to bash
|
||||||
cd $XBPS_MASTERDIR/bin && ln -sf bash sh
|
cd $XBPS_MASTERDIR/bin && ln -sf bash sh
|
||||||
|
|
||||||
touch $XBPS_MASTERDIR/.xbps_perms_done
|
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()
|
prepare_binpkg_repos()
|
||||||
{
|
{
|
||||||
if [ ! -f "$XBPS_MASTERDIR/.xbps_added_local_repo" ]; then
|
if [ ! -f "$XBPS_MASTERDIR/.xbps_added_local_repo" ]; then
|
||||||
msg_normal "Registering local binpkg repo..."
|
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
|
[ $? -eq 0 ] && touch -f $XBPS_MASTERDIR/.xbps_added_local_repo
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
@ -191,8 +189,6 @@ install_xbps_utils()
|
||||||
|
|
||||||
if [ -n "$needed" ]; then
|
if [ -n "$needed" ]; then
|
||||||
echo "=> Installing the required XBPS utils."
|
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
|
for f in bin repo uhelper; do
|
||||||
_cmd=$(which xbps-${f}.static 2>/dev/null)
|
_cmd=$(which xbps-${f}.static 2>/dev/null)
|
||||||
if [ -z "${_cmd}" ]; then
|
if [ -z "${_cmd}" ]; then
|
||||||
|
@ -201,7 +197,6 @@ install_xbps_utils()
|
||||||
fi
|
fi
|
||||||
cp -f ${_cmd} $xbps_prefix/sbin
|
cp -f ${_cmd} $xbps_prefix/sbin
|
||||||
done
|
done
|
||||||
rebuild_ldso_cache
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -225,19 +220,20 @@ xbps_chroot_handler()
|
||||||
|
|
||||||
create_busybox_links
|
create_busybox_links
|
||||||
install_xbps_utils
|
install_xbps_utils
|
||||||
mount_chroot_fs
|
${sudo_cmd} @@XBPS_INSTALL_LIBEXECDIR@@/xbps-src-chroot-helper mount
|
||||||
|
[ $? -ne 0 ] && return $?
|
||||||
prepare_binpkg_repos
|
prepare_binpkg_repos
|
||||||
|
|
||||||
# Reinstall xbps-src in the chroot
|
# Reinstall xbps-src in the chroot
|
||||||
if [ ! -f $XBPS_MASTERDIR/usr/local/sbin/xbps-src ]; then
|
if [ ! -f $XBPS_MASTERDIR/usr/local/sbin/xbps-src ]; then
|
||||||
env in_chroot=yes LANG=C PATH=$path \
|
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"
|
"cd /xbps/xbps-src && make install clean"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$action" = "chroot" ]; then
|
if [ "$action" = "chroot" ]; then
|
||||||
env in_chroot=yes LANG=C PATH=$path \
|
env in_chroot=yes LANG=C PATH=$path \
|
||||||
chroot $XBPS_MASTERDIR /bin/sh
|
${chroot_cmd} $XBPS_MASTERDIR /bin/sh
|
||||||
else
|
else
|
||||||
local lenv
|
local lenv
|
||||||
[ -n "$only_destdir" ] && \
|
[ -n "$only_destdir" ] && \
|
||||||
|
@ -245,75 +241,11 @@ xbps_chroot_handler()
|
||||||
[ -n "$norm_builddir" ] && \
|
[ -n "$norm_builddir" ] && \
|
||||||
action="-C $action"
|
action="-C $action"
|
||||||
env in_chroot=yes LANG=C PATH=$path \
|
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"
|
"cd /xbps/srcpkgs/$pkg && xbps-src $action"
|
||||||
fi
|
fi
|
||||||
msg_normal "Exiting from the chroot on $XBPS_MASTERDIR."
|
msg_normal "Exiting from the chroot on $XBPS_MASTERDIR."
|
||||||
umount_chroot_fs
|
${sudo_cmd} @@XBPS_INSTALL_LIBEXECDIR@@/xbps-src-chroot-helper umount
|
||||||
}
|
return $?
|
||||||
|
|
||||||
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
|
|
||||||
}
|
}
|
|
@ -39,23 +39,6 @@ run_func()
|
||||||
fi
|
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()
|
msg_error()
|
||||||
{
|
{
|
||||||
[ -z "$1" ] && return 1
|
[ -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
|
||||||
|
|
||||||
|
}
|
|
@ -56,7 +56,7 @@ binpkg_cleanup()
|
||||||
#
|
#
|
||||||
xbps_make_binpkg_real()
|
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
|
if [ ! -d "${DESTDIR}" ]; then
|
||||||
msg_warn "cannot find destdir for $pkgname... skipping!"
|
msg_warn "cannot find destdir for $pkgname... skipping!"
|
||||||
|
@ -69,11 +69,6 @@ xbps_make_binpkg_real()
|
||||||
else
|
else
|
||||||
arch=$xbps_machine
|
arch=$xbps_machine
|
||||||
fi
|
fi
|
||||||
if [ -n "$base_chroot" ]; then
|
|
||||||
use_sudo=no
|
|
||||||
else
|
|
||||||
use_sudo=yes
|
|
||||||
fi
|
|
||||||
if [ -n "$revision" ]; then
|
if [ -n "$revision" ]; then
|
||||||
lver="${version}_${revision}"
|
lver="${version}_${revision}"
|
||||||
else
|
else
|
||||||
|
@ -116,8 +111,9 @@ xbps_make_binpkg_real()
|
||||||
trap "binpkg_cleanup" INT
|
trap "binpkg_cleanup" INT
|
||||||
|
|
||||||
echo -n "=> Building $binpkg... "
|
echo -n "=> Building $binpkg... "
|
||||||
run_rootcmd $use_sudo tar --exclude "var/db/xbps/metadata/*/flist" \
|
${fakeroot_cmd} ${fakeroot_cmd_args} \
|
||||||
-cpf - ${mfiles} ${dirs} | \
|
tar --exclude "var/db/xbps/metadata/*/flist" \
|
||||||
|
-cpf - ${mfiles} ${dirs} | \
|
||||||
$XBPS_COMPRESS_CMD ${clevel} -qf > $pkgdir/$binpkg
|
$XBPS_COMPRESS_CMD ${clevel} -qf > $pkgdir/$binpkg
|
||||||
if [ $? -eq 0 ]; then
|
if [ $? -eq 0 ]; then
|
||||||
echo "done."
|
echo "done."
|
||||||
|
|
|
@ -42,7 +42,6 @@ install_pkg()
|
||||||
fi
|
fi
|
||||||
|
|
||||||
pkg="$curpkgn-$version"
|
pkg="$curpkgn-$version"
|
||||||
. $XBPS_SHUTILSDIR/tmpl_funcs.sh
|
|
||||||
if [ -n "$doing_deps" ]; then
|
if [ -n "$doing_deps" ]; then
|
||||||
reset_tmpl_vars
|
reset_tmpl_vars
|
||||||
setup_tmpl $curpkgn
|
setup_tmpl $curpkgn
|
||||||
|
@ -61,21 +60,10 @@ install_pkg()
|
||||||
fi
|
fi
|
||||||
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.
|
# Install dependencies required by this package.
|
||||||
#
|
#
|
||||||
if [ -z "$doing_deps" ]; then
|
if [ -z "$doing_deps" ]; then
|
||||||
. $XBPS_SHUTILSDIR/builddep_funcs.sh
|
|
||||||
install_dependencies_pkg $pkg
|
install_dependencies_pkg $pkg
|
||||||
#
|
#
|
||||||
# At this point all required deps are installed, and
|
# At this point all required deps are installed, and
|
||||||
|
@ -106,8 +94,11 @@ install_pkg()
|
||||||
build_src_phase
|
build_src_phase
|
||||||
fi
|
fi
|
||||||
|
|
||||||
. $XBPS_SHUTILSDIR/install_funcs.sh
|
# Install pkg into destdir.
|
||||||
install_src_phase
|
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.
|
# Always write metadata to package's destdir.
|
||||||
. $XBPS_SHUTILSDIR/metadata.sh
|
. $XBPS_SHUTILSDIR/metadata.sh
|
||||||
|
@ -142,7 +133,8 @@ install_pkg_with_binpkg()
|
||||||
fi
|
fi
|
||||||
|
|
||||||
msg_normal "Installing binary pkg: $pkgpattern"
|
msg_normal "Installing binary pkg: $pkgpattern"
|
||||||
$XBPS_BIN_CMD -y install "$pkgpattern"
|
${fakeroot_cmd} ${fakeroot_cmd_args} ${XBPS_BIN_CMD} \
|
||||||
|
-y install "$pkgpattern"
|
||||||
return $?
|
return $?
|
||||||
}
|
}
|
||||||
|
|
|
@ -97,7 +97,9 @@ setup_tmpl()
|
||||||
local pkg="$1"
|
local pkg="$1"
|
||||||
|
|
||||||
[ -z "$pkg" ] && return 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
|
for f in $(echo $XBPS_COMMONVARSDIR/*.sh); do
|
||||||
[ -r ${f} ] && . ${f}
|
[ -r ${f} ] && . ${f}
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
PREFIX ?= /usr/local
|
PREFIX ?= /usr/local
|
||||||
SBINDIR ?= $(DESTDIR)$(PREFIX)/sbin
|
SBINDIR ?= $(DESTDIR)$(PREFIX)/sbin
|
||||||
#
|
#
|
||||||
# The following two vars shouldn't be specified with DESTDIR!
|
# The following vars shouldn't be specified with DESTDIR!
|
||||||
#
|
#
|
||||||
SHAREDIR ?= $(PREFIX)/share/xbps-src
|
SHAREDIR ?= $(PREFIX)/share/xbps-src
|
||||||
|
LIBEXECDIR ?= $(PREFIX)/libexec
|
||||||
ETCDIR ?= $(PREFIX)/etc
|
ETCDIR ?= $(PREFIX)/etc
|
||||||
|
|
|
@ -29,6 +29,9 @@ trap "echo && exit 1" INT QUIT
|
||||||
|
|
||||||
: ${progname:=$(basename $0)}
|
: ${progname:=$(basename $0)}
|
||||||
: ${fakeroot_cmd:=fakeroot}
|
: ${fakeroot_cmd:=fakeroot}
|
||||||
|
: ${fakeroot_cmd_args:=--}
|
||||||
|
: ${sudo_cmd:=sudo}
|
||||||
|
: ${chroot_cmd:=chroot}
|
||||||
: ${xbps_machine:=$(uname -m)}
|
: ${xbps_machine:=$(uname -m)}
|
||||||
: ${XBPS_UTILS_REQVER:=20091124-1}
|
: ${XBPS_UTILS_REQVER:=20091124-1}
|
||||||
|
|
||||||
|
@ -52,7 +55,6 @@ Targets:
|
||||||
install install-destdir + stow.
|
install install-destdir + stow.
|
||||||
list List installed packages in masterdir.
|
list List installed packages in masterdir.
|
||||||
listfiles List installed files from <pkg>.
|
listfiles List installed files from <pkg>.
|
||||||
reinstall remove + install.
|
|
||||||
remove Remove package completely (destdir + masterdir).
|
remove Remove package completely (destdir + masterdir).
|
||||||
stow Copy <pkg> files from destdir into masterdir and
|
stow Copy <pkg> files from destdir into masterdir and
|
||||||
register package in database.
|
register package in database.
|
||||||
|
@ -93,56 +95,6 @@ run_file()
|
||||||
. $path_fixed
|
. $path_fixed
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#
|
|
||||||
# Checks that all required variables specified in the configuration
|
|
||||||
# file are properly working.
|
|
||||||
#
|
|
||||||
check_config_vars()
|
check_config_vars()
|
||||||
{
|
{
|
||||||
local cffound f
|
local cffound f
|
||||||
|
@ -201,9 +153,24 @@ fi
|
||||||
# Check configuration vars before anyting else, and set defaults vars.
|
# Check configuration vars before anyting else, and set defaults vars.
|
||||||
#
|
#
|
||||||
check_config_vars
|
check_config_vars
|
||||||
|
. @@XBPS_INSTALL_SHAREDIR@@/shutils/init_funcs.sh
|
||||||
set_defvars
|
set_defvars
|
||||||
|
|
||||||
. $XBPS_SHUTILSDIR/common_funcs.sh
|
. $XBPS_SHUTILSDIR/common_funcs.sh
|
||||||
|
|
||||||
|
if [ "$(id -u)" -eq 0 ]; then
|
||||||
|
# disable sudo and fakeroot if uid==0
|
||||||
|
unset sudo_cmd
|
||||||
|
if [ -n "$in_chroot" ]; then
|
||||||
|
unset fakeroot_cmd
|
||||||
|
unset fakeroot_cmd_args
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "$XBPS_USE_CAPCHROOT" ]; then
|
||||||
|
chroot_cmd="capchroot"
|
||||||
|
fi
|
||||||
|
|
||||||
# Main switch
|
# Main switch
|
||||||
case "$target" in
|
case "$target" in
|
||||||
build|configure)
|
build|configure)
|
||||||
|
@ -212,11 +179,7 @@ build|configure)
|
||||||
|
|
||||||
if [ -z "$base_chroot" -a -z "$in_chroot" ]; then
|
if [ -z "$base_chroot" -a -z "$in_chroot" ]; then
|
||||||
. $XBPS_SHUTILSDIR/chroot.sh
|
. $XBPS_SHUTILSDIR/chroot.sh
|
||||||
if [ "$target" = "build" ]; then
|
xbps_chroot_handler $target $pkgname
|
||||||
xbps_chroot_handler build $pkgname
|
|
||||||
else
|
|
||||||
xbps_chroot_handler configure $pkgname
|
|
||||||
fi
|
|
||||||
else
|
else
|
||||||
. $XBPS_SHUTILSDIR/fetch_funcs.sh
|
. $XBPS_SHUTILSDIR/fetch_funcs.sh
|
||||||
fetch_distfiles
|
fetch_distfiles
|
||||||
|
@ -274,10 +237,20 @@ extract|fetch|info)
|
||||||
extract_distfiles
|
extract_distfiles
|
||||||
;;
|
;;
|
||||||
install|install-destdir)
|
install|install-destdir)
|
||||||
|
. $XBPS_SHUTILSDIR/tmpl_funcs.sh
|
||||||
|
[ ! -r ./template ] && msg_error "missing build template file."
|
||||||
|
. ./template
|
||||||
|
|
||||||
[ "$target" = "install-destdir" ] && install_destdir_target=yes
|
[ "$target" = "install-destdir" ] && install_destdir_target=yes
|
||||||
. $XBPS_SHUTILSDIR/pkgtarget_funcs.sh
|
if [ -z "$in_chroot" -a -z "$base_chroot" ]; then
|
||||||
setup_tmpl $(basename_cwd)
|
. $XBPS_SHUTILSDIR/chroot.sh
|
||||||
install_pkg $pkgname
|
xbps_chroot_handler install $(basename_cwd) \
|
||||||
|
$install_destdir_target $dontrm_builddir
|
||||||
|
else
|
||||||
|
. $XBPS_SHUTILSDIR/pkgtarget_funcs.sh
|
||||||
|
setup_tmpl $(basename_cwd)
|
||||||
|
install_pkg $pkgname
|
||||||
|
fi
|
||||||
;;
|
;;
|
||||||
list|listfiles)
|
list|listfiles)
|
||||||
if [ "$target" = "list" ]; then
|
if [ "$target" = "list" ]; then
|
||||||
|
@ -287,12 +260,6 @@ list|listfiles)
|
||||||
. $XBPS_SHUTILSDIR/pkgtarget_funcs.sh
|
. $XBPS_SHUTILSDIR/pkgtarget_funcs.sh
|
||||||
list_pkg_files $2
|
list_pkg_files $2
|
||||||
;;
|
;;
|
||||||
reinstall)
|
|
||||||
. $XBPS_SHUTILSDIR/pkgtarget_funcs.sh
|
|
||||||
setup_tmpl $(basename_cwd)
|
|
||||||
remove_pkg
|
|
||||||
install_pkg $pkgname
|
|
||||||
;;
|
|
||||||
remove)
|
remove)
|
||||||
. $XBPS_SHUTILSDIR/pkgtarget_funcs.sh
|
. $XBPS_SHUTILSDIR/pkgtarget_funcs.sh
|
||||||
setup_tmpl $(basename_cwd)
|
setup_tmpl $(basename_cwd)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue