xbps-src: apply indentation and avoid XBPS_MASTERDIR in the chroot case.

This commit is contained in:
Juan RP 2014-04-28 23:03:35 +02:00
parent b9f2cbed05
commit cf97b1a2b4
1 changed files with 383 additions and 373 deletions

756
xbps-src
View File

@ -2,174 +2,175 @@
# vim: set ts=4 sw=4 et: # vim: set ts=4 sw=4 et:
usage() { usage() {
cat << _EOF cat << _EOF
$(basename $0): [options] <target> [arguments] $(basename $0): [options] <target> [arguments]
Targets: (only one may be specified) Targets: (only one may be specified)
binary-bootstrap [arch] binary-bootstrap [arch]
Install bootstrap packages from host repositories into <masterdir>. Install bootstrap packages from host repositories into <masterdir>.
If the optional 'arch' argument is set, it will install bootstrap packages If the optional 'arch' argument is set, it will install bootstrap packages
from this architecture, and its required xbps utilities. The <masterdir> from this architecture, and its required xbps utilities. The <masterdir>
will be initialized for chroot operations. will be initialized for chroot operations.
bootstrap bootstrap
Build and install from source the bootstrap packages into <masterdir>. Build and install from source the bootstrap packages into <masterdir>.
bootstrap-update bootstrap-update
Updates bootstrap packages with latest versions available from registered Updates bootstrap packages with latest versions available from registered
repositories in the XBPS configuration file. repositories in the XBPS configuration file.
build <pkgname> build <pkgname>
Build package source (fetch + extract + configure + build). Build package source (fetch + extract + configure + build).
chroot chroot
Enter to the chroot in <masterdir>. Enter to the chroot in <masterdir>.
clean <pkgname> clean <pkgname>
Remove <pkgname> build directory. Remove <pkgname> build directory.
configure <pkgname> configure <pkgname>
Configure a package (fetch + extract + configure). Configure a package (fetch + extract + configure).
extract <pkgname> extract <pkgname>
Extract package source distribution file(s) into the build directory. Extract package source distribution file(s) into the build directory.
By default set to <masterdir>/builddir. By default set to <masterdir>/builddir.
fetch <pkgname> fetch <pkgname>
Download package source distribution file(s). Download package source distribution file(s).
install <pkgname> install <pkgname>
Install target package into <destdir> but not building the binary package Install target package into <destdir> but not building the binary package
and not removing build directory for inspection purposes. and not removing build directory for inspection purposes.
pkg <pkgname> pkg <pkgname>
Build binary package for <pkgname> and all required dependencies. Build binary package for <pkgname> and all required dependencies.
remove <pkgname> remove <pkgname>
Remove target package from <destdir>. If <pkgname>-<version> is not matched Remove target package from <destdir>. If <pkgname>-<version> is not matched
from build template nothing is removed. from build template nothing is removed.
remove-autodeps remove-autodeps
Removes all package dependencies that were installed automatically. Removes all package dependencies that were installed automatically.
show <pkgname> show <pkgname>
Show information for the specified package. Show information for the specified package.
show-build-deps <pkgname> show-build-deps <pkgname>
Show required build dependencies for <pkgname>. Show required build dependencies for <pkgname>.
show-deps <pkgname> show-deps <pkgname>
Show required run-time dependencies for <pkgname>. Package must be Show required run-time dependencies for <pkgname>. Package must be
installed into destdir. installed into destdir.
show-files <pkgname> show-files <pkgname>
Show files installed by <pkgname>. Package must be installed into destdir. Show files installed by <pkgname>. Package must be installed into destdir.
show-options <pkgname> show-options <pkgname>
Show available build options by <pkgname>. Show available build options by <pkgname>.
show-shlib-provides <pkgname> show-shlib-provides <pkgname>
Show list of provided shlibs for <pkgname>. Package must be installed into destdir. Show list of provided shlibs for <pkgname>. Package must be installed into destdir.
show-shlib-requires <pkgname> show-shlib-requires <pkgname>
Show list of required shlibs for <pkgname>. Package must be installed into destdir. Show list of required shlibs for <pkgname>. Package must be installed into destdir.
show-var <var> show-var <var>
Prints the value of <var> if it's defined in xbps-src. Prints the value of <var> if it's defined in xbps-src.
show-repo-updates show-repo-updates
Prints the list of outdated packages in XBPS repositories. Prints the list of outdated packages in XBPS repositories.
show-sys-updates show-sys-updates
Prints the list of oudated packages in your system. Prints the list of oudated packages in your system.
update-bulk update-bulk
Rebuilds all packages in the system repositories that are outdated. Rebuilds all packages in the system repositories that are outdated.
update-sys update-sys
Rebuilds all packages in your system that are outdated and updates them. Rebuilds all packages in your system that are outdated and updates them.
zap zap
Removes a masterdir but preserving ccache, distcc and host directories. Removes a masterdir but preserving ccache, distcc and host directories.
Options: Options:
-a <profile>
Cross compile packages for this profile. Supported values:
armv6hf-musl - for ARMv6 EABI (LE Hard Float) Musl/Linux -a <profile>
armv6hf - for ARMv6 EABI (LE Hard Float) GNU/Linux Cross compile packages for this profile. Supported values:
armv7hf-musl - for ARMv7 EABI (LE Hard Float) Musl/Linux
armv7hf - for ARMv7 EABI (LE Hard Float) GNU/Linux
i686-musl - for i686 Musl/Linux
i686 - for i686 GNU/Linux
mips - for MIPS o32 (BE Soft Float) GNU/Linux
mipsel - for MIPS o32 (LE Soft Float) GNU/Linux
x86_64-musl - for x86_64 Musl/Linux
-C Do not remove build directory, automatic dependencies and armv6hf-musl - for ARMv6 EABI (LE Hard Float) Musl/Linux
package destdir after successful install. armv6hf - for ARMv6 EABI (LE Hard Float) GNU/Linux
armv7hf-musl - for ARMv7 EABI (LE Hard Float) Musl/Linux
armv7hf - for ARMv7 EABI (LE Hard Float) GNU/Linux
i686-musl - for i686 Musl/Linux
i686 - for i686 GNU/Linux
mips - for MIPS o32 (BE Soft Float) GNU/Linux
mipsel - for MIPS o32 (LE Soft Float) GNU/Linux
x86_64-musl - for x86_64 Musl/Linux
-f Force building and registering binary packages into the local repository, -C Do not remove build directory, automatic dependencies and
even if same version is already registered. package destdir after successful install.
-g Enable building -dbg packages with debugging symbols. -f Force building and registering binary packages into the local repository,
even if same version is already registered.
-H <hostdir> -g Enable building -dbg packages with debugging symbols.
Absolute path to a directory to be bind mounted at <masterdir>/host.
The host directory stores binary packages, sources and package dependencies
downloaded from remote repositories.
If unset defaults to xbps-packages/hostdir.
-h Usage output. -H <hostdir>
Absolute path to a directory to be bind mounted at <masterdir>/host.
The host directory stores binary packages, sources and package dependencies
downloaded from remote repositories.
If unset defaults to xbps-packages/hostdir.
-I Ignore required dependencies, useful for extracting/fetching sources. -h Usage output.
-j Number of parallel build jobs to use when building packages. -I Ignore required dependencies, useful for extracting/fetching sources.
-L Disable ASCII colors. -j Number of parallel build jobs to use when building packages.
-m <masterdir> -L Disable ASCII colors.
Absolute path to a directory to be used as masterdir.
The masterdir is the main directory to build/store/compile packages.
If unset defaults to xbps-packages/masterdir.
-N Disable use of remote repositories to resolve dependencies. -m <masterdir>
Absolute path to a directory to be used as masterdir.
The masterdir is the main directory to build/store/compile packages.
If unset defaults to xbps-packages/masterdir.
-o <opt,~opt2,...> -N Disable use of remote repositories to resolve dependencies.
Enable or disable (prefixed with ~) package build options.
Supported options can be shown with the 'show-options' target.
-r <repo> -o <opt,~opt2,...>
Use an alternative local repository to store generated binary packages. Enable or disable (prefixed with ~) package build options.
If unset defaults to <hostdir>/binpkgs. If set the binpkgs will Supported options can be shown with the 'show-options' target.
be stored into <hostdir>/binpkgs/<repo>.
This alternative repository will also be used to resolve dependencies -r <repo>
with highest priority order than others. Use an alternative local repository to store generated binary packages.
If unset defaults to <hostdir>/binpkgs. If set the binpkgs will
be stored into <hostdir>/binpkgs/<repo>.
This alternative repository will also be used to resolve dependencies
with highest priority order than others.
_EOF _EOF
} }
check_reqhost_utils() { check_reqhost_utils() {
local broken local broken
[ -n "$IN_CHROOT" ] && return 0 [ -n "$IN_CHROOT" ] && return 0
for f in ${REQHOST_UTILS}; do for f in ${REQHOST_UTILS}; do
if ! command -v ${f} &>/dev/null; then if ! command -v ${f} &>/dev/null; then
echo "${f} is missing in your system, can't continue!" echo "${f} is missing in your system, can't continue!"
broken=1 broken=1
fi fi
done done
[ -n "$broken" ] && exit 1 [ -n "$broken" ] && exit 1
[ -z "$1" ] && return 0 [ -z "$1" ] && return 0
for f in ${REQHOST_UTILS_BOOTSTRAP}; do for f in ${REQHOST_UTILS_BOOTSTRAP}; do
if ! command -v ${f} &>/dev/null; then if ! command -v ${f} &>/dev/null; then
echo "${f} is missing in your system, can't continue!" echo "${f} is missing in your system, can't continue!"
broken=1 broken=1
fi fi
done done
[ -n "$broken" ] && exit 1 [ -n "$broken" ] && exit 1
} }
check_config_vars() { check_config_vars() {
@ -183,41 +184,41 @@ check_config_vars() {
export XBPS_HOSTDIR="${XBPS_DISTDIR}/hostdir" export XBPS_HOSTDIR="${XBPS_DISTDIR}/hostdir"
[ ! -d $XBPS_HOSTDIR ] && mkdir -p $XBPS_HOSTDIR [ ! -d $XBPS_HOSTDIR ] && mkdir -p $XBPS_HOSTDIR
fi fi
if [ -d "$XBPS_MASTERDIR" -a ! -w "$XBPS_MASTERDIR" ]; then if [ -d "$XBPS_MASTERDIR" -a ! -w "$XBPS_MASTERDIR" ]; then
echo "ERROR: not enough perms for masterdir $XBPS_MASTERDIR." echo "ERROR: not enough perms for masterdir $XBPS_MASTERDIR."
exit 1 exit 1
fi fi
} }
check_build_requirements() { check_build_requirements() {
local found local found
for f in $XBPS_SHUTILSDIR/*.sh; do for f in $XBPS_SHUTILSDIR/*.sh; do
[ -r $f ] && . $f [ -r $f ] && . $f
done done
case "$XBPS_TARGET" in case "$XBPS_TARGET" in
*bootstrap*) found=1;; *bootstrap*) found=1;;
*) ;; *) ;;
esac esac
if [ -z "$found" ]; then if [ -z "$found" ]; then
xbps-uhelper cmpver "$XBPS_VERSION" "$XBPS_VERSION_REQ" xbps-uhelper cmpver "$XBPS_VERSION" "$XBPS_VERSION_REQ"
if [ $? -eq 255 ]; then if [ $? -eq 255 ]; then
echo "ERROR: requires xbps>=${XBPS_VERSION_REQ}" echo "ERROR: requires xbps>=${XBPS_VERSION_REQ}"
echo "Bootstrap packages must be updated with 'xbps-src bootstrap-update'" echo "Bootstrap packages must be updated with 'xbps-src bootstrap-update'"
exit 1 exit 1
fi fi
fi fi
# Set XBPS_REPOSITORY to our current branch. # Set XBPS_REPOSITORY to our current branch.
if [ -z "$XBPS_ALT_REPOSITORY" ]; then if [ -z "$XBPS_ALT_REPOSITORY" ]; then
pushd "$PWD" &>/dev/null pushd "$PWD" &>/dev/null
cd $XBPS_DISTDIR cd $XBPS_DISTDIR
_gitbranch="$(git symbolic-ref --short HEAD 2>/dev/null)" _gitbranch="$(git symbolic-ref --short HEAD 2>/dev/null)"
if [ -n "${_gitbranch}" -a "${_gitbranch}" != "master" ]; then if [ -n "${_gitbranch}" -a "${_gitbranch}" != "master" ]; then
export XBPS_ALT_REPOSITORY="${_gitbranch}" export XBPS_ALT_REPOSITORY="${_gitbranch}"
export XBPS_REPOSITORY="${XBPS_REPOSITORY}/${_gitbranch}" export XBPS_REPOSITORY="${XBPS_REPOSITORY}/${_gitbranch}"
msg_normal "Using \`$XBPS_REPOSITORY\' as local repository.\n" msg_normal "Using \`$XBPS_REPOSITORY\' as local repository.\n"
fi fi
popd &>/dev/null popd &>/dev/null
else else
export XBPS_REPOSITORY="${XBPS_REPOSITORY}/${XBPS_ALT_REPOSITORY}" export XBPS_REPOSITORY="${XBPS_REPOSITORY}/${XBPS_ALT_REPOSITORY}"
msg_normal "Using \`$XBPS_REPOSITORY\' as local repository.\n" msg_normal "Using \`$XBPS_REPOSITORY\' as local repository.\n"
@ -226,58 +227,58 @@ check_build_requirements() {
install_bbotstrap() { install_bbotstrap() {
[ -n "$CHROOT_READY" ] && return [ -n "$CHROOT_READY" ] && return
# binary bootstrap # binary bootstrap
msg_normal "Installing bootstrap from binary package repositories...\n" msg_normal "Installing bootstrap from binary package repositories...\n"
# XBPS_TARGET_PKG == arch # XBPS_TARGET_PKG == arch
if [ -n "$XBPS_TARGET_PKG" ]; then if [ -n "$XBPS_TARGET_PKG" ]; then
_bootstrap_arch="env XBPS_TARGET_ARCH=$XBPS_TARGET_PKG" _bootstrap_arch="env XBPS_TARGET_ARCH=$XBPS_TARGET_PKG"
if [ "${XBPS_TARGET_PKG}" != "${XBPS_TARGET_PKG#*-}" ]; then if [ "${XBPS_TARGET_PKG}" != "${XBPS_TARGET_PKG#*-}" ]; then
_subarch="-${XBPS_TARGET_PKG#*-}" _subarch="-${XBPS_TARGET_PKG#*-}"
fi fi
fi fi
${_bootstrap_arch} xbps-install -S ${XBPS_INSTALL_ARGS} \ ${_bootstrap_arch} xbps-install -S ${XBPS_INSTALL_ARGS} \
-c ${XBPS_HOSTDIR}/repocache -r $XBPS_MASTERDIR \ -c ${XBPS_HOSTDIR}/repocache -r $XBPS_MASTERDIR \
--repository=$XBPS_REPOSITORY -y base-chroot${_subarch} --repository=$XBPS_REPOSITORY -y base-chroot${_subarch}
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
msg_error "Failed to install bootstrap packages!\n" msg_error "Failed to install bootstrap packages!\n"
fi fi
# Reconfigure base-directories. # Reconfigure base-directories.
XBPS_ARCH=$XBPS_TARGET_PKG xbps-reconfigure -r $XBPS_MASTERDIR -f base-directories &>/dev/null XBPS_ARCH=$XBPS_TARGET_PKG xbps-reconfigure -r $XBPS_MASTERDIR -f base-directories &>/dev/null
msg_normal "Installed bootstrap successfully!\n" msg_normal "Installed bootstrap successfully!\n"
chroot_prepare $XBPS_TARGET_PKG || msg_error "Failed to initialize chroot!\n" chroot_prepare $XBPS_TARGET_PKG || msg_error "Failed to initialize chroot!\n"
} }
masterdir_zap() { masterdir_zap() {
for f in bin boot builddir destdir dev etc home lib lib32 lib64 mnt \ for f in bin boot builddir destdir dev etc home lib lib32 lib64 mnt \
opt proc root run sbin sys tmp usr var xbps .xbps_chroot_init; do opt proc root run sbin sys tmp usr var xbps .xbps_chroot_init; do
if [ -d "$XBPS_MASTERDIR/$f" ]; then if [ -d "$XBPS_MASTERDIR/$f" ]; then
echo "Removing directory $XBPS_MASTERDIR/$f ..." echo "Removing directory $XBPS_MASTERDIR/$f ..."
rm -rf $XBPS_MASTERDIR/$f rm -rf $XBPS_MASTERDIR/$f
elif [ -h "$XBPS_MASTERDIR/$f" ]; then elif [ -h "$XBPS_MASTERDIR/$f" ]; then
echo "Removing link $XBPS_MASTERDIR/$f ..." echo "Removing link $XBPS_MASTERDIR/$f ..."
rm -f $XBPS_MASTERDIR/$f rm -f $XBPS_MASTERDIR/$f
elif [ -f "$XBPS_MASTERDIR/$f" ]; then elif [ -f "$XBPS_MASTERDIR/$f" ]; then
echo "Removing file $XBPS_MASTERDIR/$f ..." echo "Removing file $XBPS_MASTERDIR/$f ..."
rm -f $XBPS_MASTERDIR/$f rm -f $XBPS_MASTERDIR/$f
fi fi
done done
echo "$XBPS_MASTERDIR masterdir cleaned up." echo "$XBPS_MASTERDIR masterdir cleaned up."
} }
exit_func() { exit_func() {
if [ -z "$XBPS_KEEP_ALL" ]; then if [ -z "$XBPS_KEEP_ALL" ]; then
if [ -n "$IN_CHROOT" ]; then if [ -n "$IN_CHROOT" ]; then
remove_pkg_autodeps remove_pkg_autodeps
fi fi
fi fi
if [ -n "$sourcepkg" ]; then if [ -n "$sourcepkg" ]; then
remove_pkg $XBPS_CROSS_BUILD remove_pkg $XBPS_CROSS_BUILD
remove_pkg_wrksrc remove_pkg_wrksrc
fi fi
if [ -z "$IN_CHROOT" ]; then if [ -z "$IN_CHROOT" ]; then
msg_red "xbps-src: a failure has ocurred! exiting...\n" msg_red "xbps-src: a failure has ocurred! exiting...\n"
fi fi
exit 2 exit 2
} }
basename_cwd() { basename_cwd() {
@ -306,23 +307,23 @@ readonly XBPS_MACHINE=$(uname -m)
XBPS_OPTIONS= XBPS_OPTIONS=
while getopts "a:CfghH:Ij:Lm:No:r:V" opt; do while getopts "a:CfghH:Ij:Lm:No:r:V" opt; do
case $opt in case $opt in
a) readonly XBPS_CROSS_BUILD="$OPTARG"; XBPS_OPTIONS+="-a $OPTARG ";; a) readonly XBPS_CROSS_BUILD="$OPTARG"; XBPS_OPTIONS+="-a $OPTARG ";;
C) readonly XBPS_KEEP_ALL=1; XBPS_OPTIONS+="-C ";; C) readonly XBPS_KEEP_ALL=1; XBPS_OPTIONS+="-C ";;
f) readonly XBPS_BUILD_FORCEMODE=1; XBPS_OPTIONS+="-f ";; f) readonly XBPS_BUILD_FORCEMODE=1; XBPS_OPTIONS+="-f ";;
g) readonly XBPS_DEBUG_PKGS=1; XBPS_OPTIONS+="-g ";; g) readonly XBPS_DEBUG_PKGS=1; XBPS_OPTIONS+="-g ";;
H) readonly XBPS_HOSTDIR="$(readlink -m $OPTARG 2>/dev/null)"; XBPS_OPTIONS+="-H $XBPS_HOSTDIR ";; H) readonly XBPS_HOSTDIR="$(readlink -m $OPTARG 2>/dev/null)"; XBPS_OPTIONS+="-H $XBPS_HOSTDIR ";;
h) usage && exit 0;; h) usage && exit 0;;
I) readonly XBPS_SKIP_DEPS=1; XBPS_OPTIONS+="-I ";; I) readonly XBPS_SKIP_DEPS=1; XBPS_OPTIONS+="-I ";;
j) readonly XBPS_MAKEJOBS="$OPTARG"; XBPS_OPTIONS+="-j $OPTARG ";; j) readonly XBPS_MAKEJOBS="$OPTARG"; XBPS_OPTIONS+="-j $OPTARG ";;
L) export NOCOLORS=1; XBPS_OPTIONS+="-L ";; L) export NOCOLORS=1; XBPS_OPTIONS+="-L ";;
m) readonly XBPS_MASTERDIR=$(readlink -m $OPTARG 2>/dev/null); XBPS_OPTIONS+="-m $XBPS_MASTERDIR ";; m) readonly XBPS_MASTERDIR=$(readlink -m $OPTARG 2>/dev/null); XBPS_OPTIONS+="-m $XBPS_MASTERDIR ";;
N) readonly XBPS_SKIP_REMOTEREPOS=1; XBPS_OPTIONS+="-N ";; N) readonly XBPS_SKIP_REMOTEREPOS=1; XBPS_OPTIONS+="-N ";;
o) readonly XBPS_BUILD_OPTS="$OPTARG"; XBPS_OPTIONS+="-o $OPTARG ";; o) readonly XBPS_BUILD_OPTS="$OPTARG"; XBPS_OPTIONS+="-o $OPTARG ";;
r) readonly XBPS_ALT_REPOSITORY="$OPTARG"; XBPS_OPTIONS+="-r $OPTARG ";; r) readonly XBPS_ALT_REPOSITORY="$OPTARG"; XBPS_OPTIONS+="-r $OPTARG ";;
V) echo $XBPS_SRC_VERSION && exit 0;; V) echo $XBPS_SRC_VERSION && exit 0;;
--) shift; break;; --) shift; break;;
esac esac
done done
shift $(($OPTIND - 1)) shift $(($OPTIND - 1))
@ -335,17 +336,17 @@ umask 022
# #
# Required utilities in host system for the bootstrap target. # Required utilities in host system for the bootstrap target.
readonly REQHOST_UTILS_BOOTSTRAP="awk bash bison sed gcc g++ msgfmt makeinfo \ readonly REQHOST_UTILS_BOOTSTRAP="awk bash bison sed gcc g++ msgfmt makeinfo \
perl fakeroot tar xz gzip bzip2 patch flex" perl fakeroot tar xz gzip bzip2 patch flex"
# Required utilities in host system for chroot ops. # Required utilities in host system for chroot ops.
readonly REQHOST_UTILS="xbps-install xbps-query xbps-rindex xbps-uhelper \ readonly REQHOST_UTILS="xbps-install xbps-query xbps-rindex xbps-uhelper \
xbps-reconfigure xbps-remove xbps-create git" xbps-reconfigure xbps-remove xbps-create git"
check_reqhost_utils check_reqhost_utils
if [ -n "$IN_CHROOT" ]; then if [ -n "$IN_CHROOT" ]; then
readonly XBPS_CONFIG_FILE=/etc/xbps/xbps-src.conf readonly XBPS_CONFIG_FILE=/etc/xbps/xbps-src.conf
readonly XBPS_DISTDIR=/xbps-packages readonly XBPS_DISTDIR=/xbps-packages
else else
_distdir="$(readlink -f $(dirname $0))" _distdir="$(readlink -f $(dirname $0))"
if [ "${_distdir}" = "." ]; then if [ "${_distdir}" = "." ]; then
@ -370,36 +371,45 @@ fi
check_config_vars check_config_vars
if [ -n "$XBPS_HOSTDIR" ]; then if [ -n "$XBPS_HOSTDIR" ]; then
export XBPS_REPOSITORY=$XBPS_HOSTDIR/binpkgs export XBPS_REPOSITORY=$XBPS_HOSTDIR/binpkgs
readonly XBPS_SRCDISTDIR=$XBPS_HOSTDIR/sources readonly XBPS_SRCDISTDIR=$XBPS_HOSTDIR/sources
else else
export XBPS_REPOSITORY=$XBPS_MASTERDIR/host/binpkgs export XBPS_REPOSITORY=$XBPS_MASTERDIR/host/binpkgs
readonly XBPS_SRCDISTDIR=$XBPS_MASTERDIR/host/sources readonly XBPS_SRCDISTDIR=$XBPS_MASTERDIR/host/sources
fi fi
if [ -n "$IN_CHROOT" ]; then if [ -n "$IN_CHROOT" ]; then
readonly XBPS_UHELPER_CMD="xbps-uhelper" readonly XBPS_UHELPER_CMD="xbps-uhelper"
readonly XBPS_INSTALL_CMD="xbps-install" readonly XBPS_INSTALL_CMD="xbps-install"
readonly XBPS_QUERY_CMD="xbps-query" readonly XBPS_QUERY_CMD="xbps-query"
readonly XBPS_RINDEX_CMD="xbps-rindex" readonly XBPS_RINDEX_CMD="xbps-rindex"
readonly XBPS_RECONFIGURE_CMD="xbps-reconfigure" readonly XBPS_RECONFIGURE_CMD="xbps-reconfigure"
readonly XBPS_REMOVE_CMD="xbps-remove" readonly XBPS_REMOVE_CMD="xbps-remove"
readonly XBPS_SRCPKGDIR=/xbps-packages/srcpkgs
readonly XBPS_COMMONDIR=/xbps-packages/common
readonly XBPS_DESTDIR=/destdir
readonly XBPS_BUILDDIR=/builddir
readonly XBPS_SHUTILSDIR=$XBPS_COMMONDIR/xbps-src/shutils
readonly XBPS_TRIGGERSDIR=$XBPS_SRCPKGDIR/xbps-triggers/files
readonly XBPS_CROSSPFDIR=$XBPS_COMMONDIR/cross-profiles
readonly XBPS_BUILDSTYLEDIR=$XBPS_COMMONDIR/build_style
readonly XBPS_LIBEXECDIR=$XBPS_COMMONDIR/xbps-src/libexec
else else
readonly XBPS_UHELPER_CMD="xbps-uhelper -r $XBPS_MASTERDIR" readonly XBPS_UHELPER_CMD="xbps-uhelper -r $XBPS_MASTERDIR"
readonly XBPS_INSTALL_CMD="xbps-install -C _empty.conf_ --repository=$XBPS_REPOSITORY -r $XBPS_MASTERDIR" readonly XBPS_INSTALL_CMD="xbps-install -C _empty.conf_ --repository=$XBPS_REPOSITORY -r $XBPS_MASTERDIR"
readonly XBPS_QUERY_CMD="xbps-query -C _empty.conf_ --repository=$XBPS_REPOSITORY -r $XBPS_MASTERDIR" readonly XBPS_QUERY_CMD="xbps-query -C _empty.conf_ --repository=$XBPS_REPOSITORY -r $XBPS_MASTERDIR"
readonly XBPS_RINDEX_CMD="xbps-rindex" readonly XBPS_RINDEX_CMD="xbps-rindex"
readonly XBPS_RECONFIGURE_CMD="xbps-reconfigure -r $XBPS_MASTERDIR" readonly XBPS_RECONFIGURE_CMD="xbps-reconfigure -r $XBPS_MASTERDIR"
readonly XBPS_REMOVE_CMD="xbps-remove -r $XBPS_MASTERDIR" readonly XBPS_REMOVE_CMD="xbps-remove -r $XBPS_MASTERDIR"
readonly XBPS_SRCPKGDIR=$XBPS_DISTDIR/srcpkgs
readonly XBPS_COMMONDIR=$XBPS_DISTDIR/common
readonly XBPS_SHUTILSDIR=$XBPS_COMMONDIR/xbps-src/shutils
readonly XBPS_DESTDIR=$XBPS_MASTERDIR/destdir
readonly XBPS_BUILDDIR=$XBPS_MASTERDIR/builddir
readonly XBPS_TRIGGERSDIR=$XBPS_SRCPKGDIR/xbps-triggers/files
readonly XBPS_CROSSPFDIR=$XBPS_COMMONDIR/cross-profiles
readonly XBPS_BUILDSTYLEDIR=$XBPS_COMMONDIR/build_style
readonly XBPS_LIBEXECDIR=$XBPS_COMMONDIR/xbps-src/libexec
fi fi
readonly XBPS_SRCPKGDIR=$XBPS_DISTDIR/srcpkgs
readonly XBPS_COMMONDIR=$XBPS_DISTDIR/common
readonly XBPS_SHUTILSDIR=$XBPS_COMMONDIR/xbps-src/shutils
readonly XBPS_DESTDIR=$XBPS_MASTERDIR/destdir
readonly XBPS_BUILDDIR=$XBPS_MASTERDIR/builddir
readonly XBPS_TRIGGERSDIR=$XBPS_SRCPKGDIR/xbps-triggers/files
readonly XBPS_CROSSPFDIR=$XBPS_COMMONDIR/cross-profiles
readonly XBPS_BUILDSTYLEDIR=$XBPS_COMMONDIR/build_style
readonly XBPS_LIBEXECDIR=$XBPS_COMMONDIR/xbps-src/libexec
readonly CHROOT_CMD=xbps-uchroot readonly CHROOT_CMD=xbps-uchroot
# XBPS_FETCH_CMD can be overriden # XBPS_FETCH_CMD can be overriden
@ -419,7 +429,7 @@ if [ "$(id -u)" -eq 0 ]; then
fi fi
if [ -f $XBPS_MASTERDIR/.xbps_chroot_init ]; then if [ -f $XBPS_MASTERDIR/.xbps_chroot_init ]; then
export CHROOT_READY=1 export CHROOT_READY=1
fi fi
if [ -s $XBPS_MASTERDIR/.xbps_chroot_init ]; then if [ -s $XBPS_MASTERDIR/.xbps_chroot_init ]; then
@ -433,12 +443,12 @@ if [ -s $XBPS_MASTERDIR/.xbps_chroot_init ]; then
fi fi
export XBPS_SHUTILSDIR XBPS_CROSSPFDIR XBPS_TRIGGERSDIR \ export XBPS_SHUTILSDIR XBPS_CROSSPFDIR XBPS_TRIGGERSDIR \
XBPS_SRCPKGDIR XBPS_COMMONDIR XBPS_BUILDDIR \ XBPS_SRCPKGDIR XBPS_COMMONDIR XBPS_BUILDDIR \
XBPS_REPOSITORY XBPS_ALT_REPOSITORY XBPS_SRCDISTDIR XBPS_DIGEST_CMD \ XBPS_REPOSITORY XBPS_ALT_REPOSITORY XBPS_SRCDISTDIR XBPS_DIGEST_CMD \
XBPS_UHELPER_CMD XBPS_INSTALL_CMD XBPS_QUERY_CMD \ XBPS_UHELPER_CMD XBPS_INSTALL_CMD XBPS_QUERY_CMD \
XBPS_RINDEX_CMD XBPS_RECONFIGURE_CMD XBPS_REMOVE_CMD \ XBPS_RINDEX_CMD XBPS_RECONFIGURE_CMD XBPS_REMOVE_CMD \
XBPS_CMPVER_CMD XBPS_FETCH_CMD XBPS_VERSION XBPS_APIVER \ XBPS_CMPVER_CMD XBPS_FETCH_CMD XBPS_VERSION XBPS_APIVER \
XBPS_BUILDSTYLEDIR XBPS_CFLAGS XBPS_CXXFLAGS XBPS_LDFLAGS \ XBPS_BUILDSTYLEDIR XBPS_CFLAGS XBPS_CXXFLAGS XBPS_LDFLAGS \
XBPS_MAKEJOBS XBPS_BUILD_FORCEMODE XBPS_USE_GIT_REVS XBPS_DEBUG_PKGS \ XBPS_MAKEJOBS XBPS_BUILD_FORCEMODE XBPS_USE_GIT_REVS XBPS_DEBUG_PKGS \
XBPS_CCACHE XBPS_DISTCC XBPS_DISTCC_HOSTS XBPS_SKIP_DEPS \ XBPS_CCACHE XBPS_DISTCC XBPS_DISTCC_HOSTS XBPS_SKIP_DEPS \
XBPS_SKIP_REMOTEREPOS XBPS_CROSS_BUILD XBPS_BUILD_OPTS \ XBPS_SKIP_REMOTEREPOS XBPS_CROSS_BUILD XBPS_BUILD_OPTS \
@ -457,49 +467,49 @@ done
# Sanitize PATH. # Sanitize PATH.
# #
if [ -z "$IN_CHROOT" ]; then if [ -z "$IN_CHROOT" ]; then
# In non chroot case always prefer host tools. # In non chroot case always prefer host tools.
MYPATH="$XBPS_MASTERDIR/usr/bin:$XBPS_MASTERDIR/usr/sbin" MYPATH="$XBPS_MASTERDIR/usr/bin:$XBPS_MASTERDIR/usr/sbin"
export PATH="$PATH:$MYPATH" export PATH="$PATH:$MYPATH"
else else
MYPATH="/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin" MYPATH="/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin"
export PATH="$MYPATH" export PATH="$MYPATH"
if [ -n "$XBPS_CCACHE" ]; then if [ -n "$XBPS_CCACHE" ]; then
CCACHEPATH="/usr/lib/ccache/bin" CCACHEPATH="/usr/lib/ccache/bin"
if [ -n "$XBPS_HOSTDIR" -a -d "$XBPS_HOSTDIR/ccache" ]; then if [ -n "$XBPS_HOSTDIR" -a -d "$XBPS_HOSTDIR/ccache" ]; then
export CCACHE_DIR="$XBPS_HOSTDIR/ccache" export CCACHE_DIR="$XBPS_HOSTDIR/ccache"
else else
if [ ! -d "$XBPS_MASTERDIR/ccache" ]; then if [ ! -d "$XBPS_MASTERDIR/ccache" ]; then
mkdir -p $XBPS_MASTERDIR/ccache mkdir -p $XBPS_MASTERDIR/ccache
fi fi
export CCACHE_DIR="$XBPS_MASTERDIR/ccache" export CCACHE_DIR="$XBPS_MASTERDIR/ccache"
fi fi
export PATH="$CCACHEPATH:$PATH" export PATH="$CCACHEPATH:$PATH"
fi fi
if [ -n "$XBPS_DISTCC" ]; then if [ -n "$XBPS_DISTCC" ]; then
DISTCCPATH="/usr/lib/distcc/bin" DISTCCPATH="/usr/lib/distcc/bin"
if [ -n "$XBPS_HOSTDIR" -a -d "$XBPS_HOSTDIR/distcc" ]; then if [ -n "$XBPS_HOSTDIR" -a -d "$XBPS_HOSTDIR/distcc" ]; then
export DISTCC_DIR="$XBPS_HOSTDIR/distcc" export DISTCC_DIR="$XBPS_HOSTDIR/distcc"
else else
if [ ! -d "$XBPS_MASTERDIR/distcc" ]; then if [ ! -d "$XBPS_MASTERDIR/distcc" ]; then
mkdir -p $XBPS_MASTERDIR/distcc mkdir -p $XBPS_MASTERDIR/distcc
fi fi
export DISTCC_DIR="$XBPS_MASTERDIR/distcc" export DISTCC_DIR="$XBPS_MASTERDIR/distcc"
fi fi
export DISTCC_HOSTS="$XBPS_DISTCC_HOSTS" export DISTCC_HOSTS="$XBPS_DISTCC_HOSTS"
export PATH="$DISTCCPATH:$PATH" export PATH="$DISTCCPATH:$PATH"
fi fi
fi fi
if [ -z "$CHROOT_READY" ]; then if [ -z "$CHROOT_READY" ]; then
if [ -n "$BASE_CHROOT_REQ" ]; then if [ -n "$BASE_CHROOT_REQ" ]; then
check_installed_pkg base-chroot-$BASE_CHROOT_REQ check_installed_pkg base-chroot-$BASE_CHROOT_REQ
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
# Prepare chroot if required base-chroot pkg is installed. # Prepare chroot if required base-chroot pkg is installed.
msg_normal "Preparing chroot on $XBPS_MASTERDIR...\n" msg_normal "Preparing chroot on $XBPS_MASTERDIR...\n"
chroot_prepare || return $? chroot_prepare || return $?
export CHROOT_READY=1 export CHROOT_READY=1
fi fi
fi fi
fi fi
check_build_requirements check_build_requirements
@ -510,114 +520,114 @@ trap 'exit_func' INT TERM HUP
# Main switch. # Main switch.
# #
case "$XBPS_TARGET" in case "$XBPS_TARGET" in
binary-bootstrap) binary-bootstrap)
install_bbotstrap install_bbotstrap
;; ;;
bootstrap) bootstrap)
# bootstrap from sources # bootstrap from sources
# check for required host utils # check for required host utils
check_reqhost_utils bootstrap check_reqhost_utils bootstrap
[ ! -d $XBPS_SRCPKGDIR/base-chroot ] && \ [ ! -d $XBPS_SRCPKGDIR/base-chroot ] && \
msg_error "Cannot find $XBPS_SRCPKGDIR/base-chroot directory!\n" msg_error "Cannot find $XBPS_SRCPKGDIR/base-chroot directory!\n"
XBPS_TARGET_PKG="base-chroot" XBPS_TARGET_PKG="base-chroot"
setup_pkg $XBPS_TARGET_PKG && install_pkg $XBPS_TARGET setup_pkg $XBPS_TARGET_PKG && install_pkg $XBPS_TARGET
;; ;;
bootstrap-update) bootstrap-update)
if [ -n "$CHROOT_READY" -a -z "$IN_CHROOT" ]; then if [ -n "$CHROOT_READY" -a -z "$IN_CHROOT" ]; then
chroot_handler ${XBPS_TARGET} dummy chroot_handler ${XBPS_TARGET} dummy
else else
${FAKEROOT_CMD} ${XBPS_INSTALL_CMD} -yu ${FAKEROOT_CMD} ${XBPS_INSTALL_CMD} -yu
fi fi
;; ;;
chroot) chroot)
chroot_handler chroot dummy chroot_handler chroot dummy
;; ;;
clean) clean)
read_pkg read_pkg
if [ -n "$CHROOT_READY" -a -z "$IN_CHROOT" ]; then if [ -n "$CHROOT_READY" -a -z "$IN_CHROOT" ]; then
chroot_handler $XBPS_TARGET $XBPS_TARGET_PKG || exit $? chroot_handler $XBPS_TARGET $XBPS_TARGET_PKG || exit $?
else else
remove_pkg_wrksrc $wrksrc remove_pkg_wrksrc $wrksrc
if declare -f do_clean >/dev/null; then if declare -f do_clean >/dev/null; then
run_func do_clean run_func do_clean
fi fi
fi fi
;; ;;
remove-autodeps) remove-autodeps)
if [ -n "$CHROOT_READY" -a -z "$IN_CHROOT" ]; then if [ -n "$CHROOT_READY" -a -z "$IN_CHROOT" ]; then
chroot_handler remove-autodeps chroot_handler remove-autodeps
else else
pkgver=xbps-src pkgver=xbps-src
remove_pkg_autodeps remove_pkg_autodeps
fi fi
;; ;;
fetch|extract|build|configure|install|install-destdir|pkg|build-pkg) fetch|extract|build|configure|install|install-destdir|pkg|build-pkg)
BEGIN_INSTALL=1 BEGIN_INSTALL=1
read_pkg read_pkg
if [ -n "$CHROOT_READY" -a -z "$IN_CHROOT" ]; then if [ -n "$CHROOT_READY" -a -z "$IN_CHROOT" ]; then
chroot_handler $XBPS_TARGET $XBPS_TARGET_PKG chroot_handler $XBPS_TARGET $XBPS_TARGET_PKG
else else
install_pkg $XBPS_TARGET $XBPS_CROSS_BUILD install_pkg $XBPS_TARGET $XBPS_CROSS_BUILD
fi fi
;; ;;
remove|remove-destdir) remove|remove-destdir)
read_pkg read_pkg
remove_pkg $XBPS_CROSS_BUILD remove_pkg $XBPS_CROSS_BUILD
;; ;;
list) list)
$XBPS_QUERY_CMD -l $XBPS_QUERY_CMD -l
;; ;;
show) show)
read_pkg read_pkg
show_pkg show_pkg
;; ;;
show-files) show-files)
read_pkg read_pkg
show_pkg_files show_pkg_files
;; ;;
show-deps) show-deps)
read_pkg read_pkg
show_pkg_deps show_pkg_deps
;; ;;
show-build-deps) show-build-deps)
read_pkg read_pkg
show_pkg_build_deps show_pkg_build_deps
;; ;;
show-options) show-options)
read_pkg read_pkg
show_pkg_options show_pkg_options
;; ;;
show-shlib-provides) show-shlib-provides)
read_pkg read_pkg
show_pkg_shlib_provides show_pkg_shlib_provides
;; ;;
show-shlib-requires) show-shlib-requires)
read_pkg read_pkg
show_pkg_shlib_requires show_pkg_shlib_requires
;; ;;
show-var) show-var)
eval value="\${$XBPS_TARGET_PKG}" eval value="\${$XBPS_TARGET_PKG}"
echo $value echo $value
;; ;;
show-repo-updates) show-repo-updates)
bulk_build bulk_build
;; ;;
show-sys-updates) show-sys-updates)
bulk_build -i bulk_build -i
;; ;;
update-bulk) update-bulk)
bulk_update bulk_update
;; ;;
update-sys) update-sys)
bulk_update -i bulk_update -i
;; ;;
zap) zap)
masterdir_zap masterdir_zap
;; ;;
*) *)
msg_red "xbps-src: invalid target $target.\n" msg_red "xbps-src: invalid target $target.\n"
usage && exit 1 usage && exit 1
;; ;;
esac esac
# Agur # Agur