2009-10-18 11:17:26 +02:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
2011-02-11 14:19:34 +01:00
|
|
|
# Copyright (c) 2008-2011 Juan Romero Pardines.
|
2009-10-18 11:17:26 +02:00
|
|
|
# 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.
|
|
|
|
#-
|
2011-02-11 14:19:34 +01:00
|
|
|
|
2011-07-18 18:50:23 +02:00
|
|
|
XBPS_CONFIG_FILE=@@XBPS_INSTALL_ETCDIR@@/xbps-src.conf
|
2009-10-18 11:17:26 +02:00
|
|
|
|
2011-07-18 18:50:23 +02:00
|
|
|
progname=$(basename $0)
|
|
|
|
fakeroot_cmd=/usr/bin/fakeroot
|
|
|
|
fakeroot_cmd_args="--"
|
|
|
|
sudo_cmd=sudo
|
|
|
|
chroot_cmd=chroot
|
|
|
|
xbps_machine=$(uname -m)
|
2009-10-18 11:17:26 +02:00
|
|
|
|
2011-07-02 20:31:43 +02:00
|
|
|
# Required utilities in host system.
|
2011-07-11 12:32:44 +02:00
|
|
|
REQHOST_UTILS="awk bash bison sed gcc msgfmt patch makeinfo \
|
|
|
|
perl fakeroot tar xz gzip bzip2"
|
2011-07-02 20:31:43 +02:00
|
|
|
|
2010-05-17 22:23:52 +02:00
|
|
|
check_reqhost_utils()
|
|
|
|
{
|
2011-07-11 12:32:44 +02:00
|
|
|
local broken
|
|
|
|
|
2011-07-04 19:07:08 +02:00
|
|
|
[ -n "$IN_CHROOT" ] && return 0
|
2011-07-11 09:21:29 +02:00
|
|
|
[ -r "$XBPS_MASTERDIR/.xbps_perms_done" ] && return 0
|
2010-05-17 22:23:52 +02:00
|
|
|
|
2011-07-02 20:31:43 +02:00
|
|
|
for f in ${REQHOST_UTILS}; do
|
2010-05-17 22:23:52 +02:00
|
|
|
if ! command -v ${f} 2>&1 >/dev/null; then
|
2011-07-11 12:32:44 +02:00
|
|
|
echo "${f} is missing in your system, can't continue!"
|
|
|
|
broken=1
|
2010-05-17 22:23:52 +02:00
|
|
|
fi
|
|
|
|
done
|
2011-07-11 12:32:44 +02:00
|
|
|
|
|
|
|
[ -n "$broken" ] && exit 1
|
2010-05-17 22:23:52 +02:00
|
|
|
}
|
|
|
|
|
2009-10-18 11:17:26 +02:00
|
|
|
usage()
|
|
|
|
{
|
|
|
|
cat << _EOF
|
2011-07-17 20:12:31 +02:00
|
|
|
$progname: [-BCDhKS] [-c file] [-m dir] [-p dir] [-s dir] [target] [pkgname]
|
2009-10-18 11:17:26 +02:00
|
|
|
|
|
|
|
Targets:
|
2011-07-04 23:30:30 +02:00
|
|
|
bootstrap
|
2011-07-17 20:12:31 +02:00
|
|
|
Build and install from source the bootstrap packages into <masterdir>.
|
2011-07-04 23:30:30 +02:00
|
|
|
|
|
|
|
build [pkgname]
|
2011-07-17 20:12:31 +02:00
|
|
|
Build package source (fetch + extract + configure + build).
|
2011-07-04 23:30:30 +02:00
|
|
|
|
xbps-src: make some targets work by specifying its pkgname.
There are now two ways to use the following targets:
build, build-pkg, clean, configure, extract, fetch, info, install,
install-destdir, remove, stow, unstow.
1) The known way: 'cd srcpkgs/foo && xbps-src <target>"
2) The new way: 'xbps-src <target> foo'.
2010-12-21 18:45:39 +01:00
|
|
|
build-pkg [pkgname|all]
|
2011-07-17 20:12:31 +02:00
|
|
|
Build a binary package from <pkgname> or all packages with the <all>
|
|
|
|
keyword. The package(s) must be installed into <destdir> for this to work.
|
2011-07-04 23:30:30 +02:00
|
|
|
|
|
|
|
checkvers
|
2011-07-17 20:12:31 +02:00
|
|
|
Checks installed package versions in <masterdir> against the srcpkgs tree
|
|
|
|
for new available versions.
|
2011-07-04 23:30:30 +02:00
|
|
|
|
|
|
|
chroot
|
2011-07-17 20:12:31 +02:00
|
|
|
Enter to the chroot in <masterdir>.
|
2011-07-04 23:30:30 +02:00
|
|
|
|
|
|
|
clean [pkgname]
|
2011-07-17 20:12:31 +02:00
|
|
|
Remove <pkgname> build directory.
|
2011-07-04 23:30:30 +02:00
|
|
|
|
|
|
|
configure [pkgname]
|
2011-07-17 20:12:31 +02:00
|
|
|
Configure a package (fetch + extract + configure).
|
2011-07-04 23:30:30 +02:00
|
|
|
|
|
|
|
extract [pkgname]
|
2011-07-17 20:12:31 +02:00
|
|
|
Extract package source distribution file(s) into the build directory.
|
|
|
|
By default set to <masterdir>/builddir.
|
2011-07-04 23:30:30 +02:00
|
|
|
|
|
|
|
fetch [pkgname]
|
2011-07-17 20:12:31 +02:00
|
|
|
Download package source distribution file(s).
|
2011-07-04 23:30:30 +02:00
|
|
|
|
|
|
|
info [pkgname]
|
2011-07-17 20:12:31 +02:00
|
|
|
Show information for the specified package.
|
2011-07-04 23:30:30 +02:00
|
|
|
|
|
|
|
install [pkgname]
|
2011-07-17 20:12:31 +02:00
|
|
|
Installs a package into destination directory and \`stows' its files into
|
|
|
|
<masterdir>. If a package is not from bootstrap group, its files will be
|
|
|
|
symlinked rather than being fully copied.
|
2011-07-04 23:30:30 +02:00
|
|
|
|
|
|
|
list
|
2011-07-17 20:12:31 +02:00
|
|
|
List installed packages in <masterdir>.
|
2011-07-04 23:30:30 +02:00
|
|
|
|
|
|
|
list-files <pkgname>
|
2011-07-17 20:12:31 +02:00
|
|
|
List package files from <pkgname>. Package must be fully installed
|
|
|
|
into <masterdir> for this to work.
|
2011-07-04 23:30:30 +02:00
|
|
|
|
|
|
|
make-repoidx
|
2011-07-17 20:12:31 +02:00
|
|
|
Build a package index for the local repository associated with the
|
|
|
|
master directory <masterdir>. By default set to <masterdir/host/binpkgs.
|
|
|
|
To specify another repo, use -p <dir>.
|
2011-07-04 23:30:30 +02:00
|
|
|
|
|
|
|
remove [pkgname]
|
2011-07-17 20:12:31 +02:00
|
|
|
Remove package completely from <destdir> and <masterdir>.
|
2011-07-04 23:30:30 +02:00
|
|
|
|
|
|
|
stow [pkgname]
|
2011-07-17 20:12:31 +02:00
|
|
|
Stow <pkgname> files from <destdir> into <masterdir> and register package
|
|
|
|
in database. When a package is \`stown', its files will be available in
|
|
|
|
<masterdir>, and other packages will be able to found it.
|
2011-07-04 23:30:30 +02:00
|
|
|
|
|
|
|
unstow [pkgname]
|
2011-07-17 20:12:31 +02:00
|
|
|
Remove <pkgname> files from <masterdir> and unregister package
|
|
|
|
from database.
|
2011-07-04 23:30:30 +02:00
|
|
|
|
|
|
|
On targets that accept [pkgname], a package name can be specified and xbps-src
|
|
|
|
will execute the task on any CWD (Current Working Directory). If the argument
|
|
|
|
is omitted xbps-src assumes that CWD is in the target package. Example:
|
|
|
|
|
|
|
|
$ cd srcpkgs/libX11 && xbps-src install
|
|
|
|
$ xbps-src install libX11
|
|
|
|
|
|
|
|
Both ways are equivalent.
|
2009-10-18 11:17:26 +02:00
|
|
|
|
|
|
|
Options:
|
2011-07-18 14:00:03 +02:00
|
|
|
-B Used in the install target, a binary package is built for any
|
|
|
|
required dependency as well as for <pkgname>. The local repository
|
|
|
|
pkg-index is created or updated after a successful package installation.
|
2011-07-17 20:12:31 +02:00
|
|
|
-C Do not remove build directory after successful installation.
|
|
|
|
-c Path to global configuration file:
|
|
|
|
if not specified @@XBPS_INSTALL_ETCDIR@@/xbps-src.conf is used.
|
2011-07-18 14:00:03 +02:00
|
|
|
-D Only install <pkgname> to package's destdir (set to
|
|
|
|
<masterdir>/destdir/<pkgname>-<version> by default).
|
2011-07-17 20:12:31 +02:00
|
|
|
-h Usage output.
|
|
|
|
-K Do not remove automatic package dependencies while building
|
|
|
|
or installing a package with XBPS_PREFER_BINPKG_DEPS enabled.
|
|
|
|
-m Master directory, overwritting the value set in the configuration
|
|
|
|
file xbps-src.conf.
|
|
|
|
-p Local packages repository, overwritting default path at
|
|
|
|
<masterdir>/host/binpkgs or if XBPS_HOSTDIR is set <hostdir>/binpkgs.
|
|
|
|
-S Overrides and disables XBPS_PREFER_BINPKG_DEPS even if it was
|
|
|
|
set in the configuration file xbps-src.conf.
|
|
|
|
-s Source distribution files directory, overwritting default path at
|
|
|
|
<masterdir>/host/sources or if XBPS_HOSTDIR is set <hostdir>/sources.
|
2009-10-18 11:17:26 +02:00
|
|
|
_EOF
|
|
|
|
}
|
|
|
|
|
2009-11-22 08:31:44 +01:00
|
|
|
basename_cwd()
|
|
|
|
{
|
|
|
|
echo $(basename $(pwd))
|
|
|
|
}
|
|
|
|
|
2009-10-18 11:17:26 +02:00
|
|
|
check_path()
|
|
|
|
{
|
|
|
|
eval local orig="$1"
|
|
|
|
|
|
|
|
case "$orig" in
|
|
|
|
/) ;;
|
|
|
|
/*) orig="${orig%/}" ;;
|
|
|
|
*) orig="$(pwd)/${orig%/}" ;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
path_fixed="$orig"
|
|
|
|
}
|
|
|
|
|
|
|
|
run_file()
|
|
|
|
{
|
|
|
|
local file="$1"
|
|
|
|
|
|
|
|
check_path "$file"
|
|
|
|
. $path_fixed
|
|
|
|
}
|
|
|
|
|
|
|
|
check_config_vars()
|
|
|
|
{
|
2010-05-26 15:41:26 +02:00
|
|
|
local val cffound f cfpaths cf="xbps-src.conf"
|
2009-10-18 11:17:26 +02:00
|
|
|
|
2010-05-26 15:41:26 +02:00
|
|
|
if [ -z "$XBPS_CONFIG_FILE" ]; then
|
|
|
|
cfpaths="@@XBPS_INSTALL_PREFIX@@/etc/${cf} ./etc/${cf}"
|
|
|
|
for f in $cfpaths; do
|
|
|
|
if [ -f ${f} ]; then
|
|
|
|
XBPS_CONFIG_FILE=${f}
|
|
|
|
cffound=yes
|
|
|
|
break
|
|
|
|
fi
|
2009-10-18 11:17:26 +02:00
|
|
|
done
|
2010-12-20 00:22:12 +01:00
|
|
|
[ -z "$cffound" ] && msg_error "cannot find a config file\n"
|
2009-10-18 11:17:26 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
run_file ${XBPS_CONFIG_FILE}
|
2010-05-26 15:41:26 +02:00
|
|
|
export XBPS_CONFIG_FILE=$path_fixed
|
2009-10-18 11:17:26 +02:00
|
|
|
|
|
|
|
if [ ! -f "$XBPS_CONFIG_FILE" ]; then
|
2010-12-20 00:22:12 +01:00
|
|
|
msg_error "cannot find configuration file: $XBPS_CONFIG_FILE\n"
|
2009-10-18 11:17:26 +02:00
|
|
|
fi
|
|
|
|
|
2010-05-26 15:41:26 +02:00
|
|
|
for f in XBPS_DISTRIBUTIONDIR XBPS_MASTERDIR; do
|
|
|
|
eval val="\$${f}"
|
|
|
|
if [ -z "$val" ]; then
|
2010-12-20 00:22:12 +01:00
|
|
|
msg_error "'${f}' not set in configuration file!\n"
|
2010-05-26 15:41:26 +02:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
if [ ! -d "$XBPS_MASTERDIR" ]; then
|
|
|
|
mkdir -p "$val"
|
|
|
|
if [ $? -ne 0 ]; then
|
2010-12-20 00:22:12 +01:00
|
|
|
msg_error "couldn't create 'XBPS_MASTERDIR' directory\n"
|
2010-05-26 15:41:26 +02:00
|
|
|
fi
|
2010-04-26 02:51:48 +02:00
|
|
|
fi
|
2010-06-03 01:49:33 +02:00
|
|
|
[ -z "${_MASTERDIR_FLAG}" ] && export _MASTERDIR="$XBPS_MASTERDIR"
|
2009-10-18 11:17:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#
|
|
|
|
# main()
|
|
|
|
#
|
2011-07-17 20:12:31 +02:00
|
|
|
while getopts "CBc:DhKm:p:Ss:" opt; do
|
2009-10-18 11:17:26 +02:00
|
|
|
case $opt in
|
2011-07-17 20:12:31 +02:00
|
|
|
B) export BUILD_BINPKG=1;;
|
2011-07-04 23:30:30 +02:00
|
|
|
C) export KEEP_WRKSRC=1;;
|
|
|
|
c) XBPS_CONFIG_FILE="$OPTARG";;
|
|
|
|
D) export DESTDIR_ONLY_INSTALL=1;;
|
|
|
|
h) usage && exit 0;;
|
|
|
|
K) export KEEP_AUTODEPS=1;;
|
|
|
|
m)
|
|
|
|
_MASTERDIR_FLAG=1
|
|
|
|
_MASTERDIR="$OPTARG"
|
|
|
|
if [ ! -d ${_MASTERDIR} ]; then
|
|
|
|
mkdir -p ${_MASTERDIR}
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
p)
|
|
|
|
_PACKAGEDIR="$OPTARG"
|
|
|
|
if [ ! -d ${_PACKAGEDIR} ]; then
|
|
|
|
mkdir -p ${_PACKAGEDIR}/${xbps_machine}
|
|
|
|
mkdir -p ${_PACKAGEDIR}/noarch
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
S) UNSET_PREFER_BINPKG_DEPS=1;;
|
|
|
|
s) export XBPS_SRCDISTDIR="$OPTARG";;
|
|
|
|
--) shift; break;;
|
2009-10-18 11:17:26 +02:00
|
|
|
esac
|
|
|
|
done
|
|
|
|
shift $(($OPTIND - 1))
|
|
|
|
|
2010-04-27 14:23:53 +02:00
|
|
|
[ $# -eq 0 -o $# -gt 2 ] && usage && exit 1
|
2009-10-18 11:17:26 +02:00
|
|
|
|
|
|
|
target="$1"
|
xbps-src: make some targets work by specifying its pkgname.
There are now two ways to use the following targets:
build, build-pkg, clean, configure, extract, fetch, info, install,
install-destdir, remove, stow, unstow.
1) The known way: 'cd srcpkgs/foo && xbps-src <target>"
2) The new way: 'xbps-src <target> foo'.
2010-12-21 18:45:39 +01:00
|
|
|
_pkgname="$2"
|
2011-07-17 20:12:31 +02:00
|
|
|
|
2009-10-18 11:17:26 +02:00
|
|
|
if [ -z "$target" ]; then
|
|
|
|
echo "=> ERROR: missing target."
|
2010-04-27 14:23:53 +02:00
|
|
|
usage && exit 1
|
2009-10-18 11:17:26 +02:00
|
|
|
fi
|
|
|
|
|
2011-07-04 19:07:08 +02:00
|
|
|
if [ -n "$IN_CHROOT" ]; then
|
2010-05-26 15:41:26 +02:00
|
|
|
XBPS_CONFIG_FILE="/usr/local/etc/xbps-src.conf"
|
|
|
|
fi
|
|
|
|
|
2009-10-18 11:17:26 +02:00
|
|
|
#
|
|
|
|
# Check configuration vars before anyting else, and set defaults vars.
|
|
|
|
#
|
|
|
|
check_config_vars
|
2010-04-27 01:34:19 +02:00
|
|
|
if [ -n "${_MASTERDIR}" ]; then
|
|
|
|
export XBPS_MASTERDIR=${_MASTERDIR}
|
|
|
|
fi
|
2010-01-16 02:11:44 +01:00
|
|
|
. @@XBPS_INSTALL_SHAREDIR@@/shutils/init_funcs.sh
|
2009-10-18 11:17:26 +02:00
|
|
|
set_defvars
|
2011-07-18 16:30:31 +02:00
|
|
|
for f in $XBPS_SHUTILSDIR/*.sh; do
|
2011-07-06 14:20:27 +02:00
|
|
|
[ -r "$f" ] && . $f
|
2011-07-02 17:04:08 +02:00
|
|
|
done
|
2010-01-16 02:11:44 +01:00
|
|
|
|
2011-07-02 22:56:26 +02:00
|
|
|
# Disable XBPS_PREFER_BINPKG_DEPS if requested.
|
|
|
|
[ -n "$UNSET_PREFER_BINPKG_DEPS" ] && unset XBPS_PREFER_BINPKG_DEPS
|
|
|
|
|
2011-01-16 18:13:55 +01:00
|
|
|
#
|
|
|
|
# Check for required utilities in host system.
|
|
|
|
#
|
|
|
|
check_reqhost_utils
|
|
|
|
|
2010-05-26 15:41:26 +02:00
|
|
|
#
|
|
|
|
# Fix up some vars when XBPS_USE_CAPABILITIES is set.
|
|
|
|
#
|
2010-04-26 14:54:06 +02:00
|
|
|
if [ -n "$XBPS_USE_CAPABILITIES" ]; then
|
2011-07-14 13:24:00 +02:00
|
|
|
chroot_cmd="@@XBPS_INSTALL_LIBEXECDIR@@/capchroot"
|
2010-04-26 14:15:49 +02:00
|
|
|
unset sudo_cmd
|
|
|
|
fi
|
|
|
|
|
2010-01-16 02:11:44 +01:00
|
|
|
if [ "$(id -u)" -eq 0 ]; then
|
|
|
|
# disable sudo and fakeroot if uid==0
|
2010-04-26 14:15:49 +02:00
|
|
|
chroot_cmd="chroot"
|
2010-01-16 02:11:44 +01:00
|
|
|
unset sudo_cmd
|
2011-07-04 19:07:08 +02:00
|
|
|
if [ -n "$IN_CHROOT" ]; then
|
2010-01-16 02:11:44 +01:00
|
|
|
unset fakeroot_cmd
|
|
|
|
unset fakeroot_cmd_args
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2010-05-26 15:41:26 +02:00
|
|
|
#
|
|
|
|
# Sanitize PATH.
|
|
|
|
#
|
2011-07-04 19:07:08 +02:00
|
|
|
if [ -z "$IN_CHROOT" ]; then
|
2010-05-26 15:41:26 +02:00
|
|
|
# In non chroot case always prefer host tools.
|
2011-07-11 13:12:27 +02:00
|
|
|
MYPATH="$PATH:$XBPS_MASTERDIR/bin:$XBPS_MASTERDIR/usr/bin"
|
2010-05-26 15:41:26 +02:00
|
|
|
MYPATH="$XBPS_MASTERDIR/usr/local/bin:$MYPATH"
|
|
|
|
MYPATH="$XBPS_MASTERDIR/usr/local/sbin:$MYPATH"
|
|
|
|
else
|
2011-07-02 09:15:29 +02:00
|
|
|
if [ -n "$XBPS_CCACHE" ]; then
|
|
|
|
CCACHEPATH="/usr/lib/ccache/bin"
|
2011-07-19 00:22:52 +02:00
|
|
|
if [ -n "$XBPS_HOSTDIR" ]; then
|
|
|
|
[ ! -d "$XBPS_HOSTDIR/ccache" ] && \
|
|
|
|
mkdir -p $XBPS_HOSTDIR/ccache
|
|
|
|
export CCACHE_DIR="$XBPS_HOSTDIR/ccache"
|
|
|
|
else
|
|
|
|
[ ! -d "$XBPS_MASTERDIR/host/ccache" ] && \
|
|
|
|
mkdir -p $XBPS_MASTERDIR/host/ccache
|
|
|
|
export CCACHE_DIR="$XBPS_MASTERDIR/host/ccache"
|
|
|
|
fi
|
2011-07-02 09:15:29 +02:00
|
|
|
fi
|
2010-05-26 15:41:26 +02:00
|
|
|
# In chroot always prefer tools from bootstrap.
|
2011-07-03 14:38:51 +02:00
|
|
|
MYPATH="$CCACHEPATH:/tools/bin:/usr/local/sbin:/bin:/usr/bin"
|
|
|
|
MYPATH="$MYPATH:/sbin:/usr/local/bin:/usr/sbin"
|
2010-05-26 15:41:26 +02:00
|
|
|
fi
|
|
|
|
export PATH="$MYPATH"
|
|
|
|
|
2011-07-06 08:16:56 +02:00
|
|
|
#
|
|
|
|
# If masterdir is ready (base-chroot installed and chroot set up) and
|
|
|
|
# XBPS_PREFER_BINPKG_DEPS enabled, force ignoring rules to handle
|
|
|
|
# bootstrap packages.
|
|
|
|
#
|
|
|
|
if [ -n "$DESTDIR_ONLY_INSTALL" -a -n "$XBPS_PREFER_BINPKG_DEPS" \
|
|
|
|
-a -f "$XBPS_MASTERDIR/.xbps_perms_done" ]; then
|
2011-07-06 08:28:34 +02:00
|
|
|
export BOOTSTRAP_PKG_REBUILD=1
|
2011-07-06 08:16:56 +02:00
|
|
|
fi
|
|
|
|
|
2010-05-26 15:41:26 +02:00
|
|
|
#
|
|
|
|
# Main switch.
|
|
|
|
#
|
2009-10-18 11:17:26 +02:00
|
|
|
case "$target" in
|
2010-05-04 22:23:54 +02:00
|
|
|
bootstrap)
|
2011-06-23 03:25:23 +02:00
|
|
|
[ ! -d $XBPS_SRCPKGDIR/base-chroot ] && \
|
|
|
|
msg_error "Cannot find $XBPS_SRCPKGDIR/base-chroot directory!\n"
|
|
|
|
cd $XBPS_SRCPKGDIR/base-chroot && _ORIGINPKG="$(basename_cwd)"
|
2010-05-14 00:07:47 +02:00
|
|
|
setup_tmpl ${_ORIGINPKG} && install_pkg $pkgname
|
2010-05-04 22:23:54 +02:00
|
|
|
;;
|
2009-10-18 11:17:26 +02:00
|
|
|
build|configure)
|
xbps-src: make some targets work by specifying its pkgname.
There are now two ways to use the following targets:
build, build-pkg, clean, configure, extract, fetch, info, install,
install-destdir, remove, stow, unstow.
1) The known way: 'cd srcpkgs/foo && xbps-src <target>"
2) The new way: 'xbps-src <target> foo'.
2010-12-21 18:45:39 +01:00
|
|
|
if [ -z "${_pkgname}" ]; then
|
|
|
|
[ ! -r ./template ] && msg_error "missing build template in $(pwd).\n"
|
|
|
|
. ./template
|
|
|
|
_pkgname=$(basename_cwd)
|
|
|
|
fi
|
2009-10-18 11:17:26 +02:00
|
|
|
|
2011-07-06 08:16:56 +02:00
|
|
|
if [ -z "$bootstrap" -a -z "$IN_CHROOT" ]; then
|
2011-07-04 21:29:11 +02:00
|
|
|
xbps_chroot_handler $target ${_pkgname}
|
2009-10-18 11:17:26 +02:00
|
|
|
else
|
xbps-src: make some targets work by specifying its pkgname.
There are now two ways to use the following targets:
build, build-pkg, clean, configure, extract, fetch, info, install,
install-destdir, remove, stow, unstow.
1) The known way: 'cd srcpkgs/foo && xbps-src <target>"
2) The new way: 'xbps-src <target> foo'.
2010-12-21 18:45:39 +01:00
|
|
|
_ORIGINPKG="${_pkgname}"
|
2010-05-14 00:07:47 +02:00
|
|
|
setup_tmpl ${_ORIGINPKG}
|
2010-05-13 22:21:08 +02:00
|
|
|
# If pkg has dependencies, install them first.
|
|
|
|
install_dependencies_pkg "$pkgname-$version"
|
|
|
|
if [ $? -ne 0 ]; then
|
2010-12-20 00:22:12 +01:00
|
|
|
msg_red "cannot install required deps for $pkgname.\n"
|
2010-05-13 22:21:08 +02:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
# All deps were installed, continue with the origin pkg...
|
2010-05-14 00:07:47 +02:00
|
|
|
setup_tmpl ${_ORIGINPKG}
|
2011-07-17 20:12:31 +02:00
|
|
|
fetch_distfiles || exit $?
|
2009-10-18 11:17:26 +02:00
|
|
|
if [ ! -f "$XBPS_EXTRACT_DONE" ]; then
|
2011-07-17 20:12:31 +02:00
|
|
|
extract_distfiles || exit $?
|
2009-10-18 11:17:26 +02:00
|
|
|
fi
|
|
|
|
if [ "$target" = "configure" ]; then
|
2011-07-17 20:12:31 +02:00
|
|
|
configure_src_phase || exit $?
|
2009-10-18 11:17:26 +02:00
|
|
|
else
|
|
|
|
if [ ! -f "$XBPS_CONFIGURE_DONE" ]; then
|
2011-07-17 20:12:31 +02:00
|
|
|
configure_src_phase || exit $?
|
2009-10-18 11:17:26 +02:00
|
|
|
fi
|
2011-07-17 20:12:31 +02:00
|
|
|
build_src_phase || exit $?
|
2009-10-18 11:17:26 +02:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
build-pkg)
|
2010-03-30 17:01:59 +02:00
|
|
|
if [ -n "${_PACKAGEDIR}" ]; then
|
|
|
|
export XBPS_PACKAGESDIR=${_PACKAGEDIR}
|
|
|
|
fi
|
2009-10-18 11:17:26 +02:00
|
|
|
if [ "$2" = "all" ]; then
|
|
|
|
for f in $($XBPS_BIN_CMD list|awk '{print $1}'); do
|
2009-10-30 22:14:09 +01:00
|
|
|
pkg=$(${XBPS_PKGDB_CMD} getpkgname $f)
|
2009-11-22 08:31:44 +01:00
|
|
|
setup_tmpl $pkg
|
|
|
|
if [ "${pkg}" = "${sourcepkg}" ]; then
|
|
|
|
xbps_make_binpkg
|
2009-10-20 10:49:41 +02:00
|
|
|
fi
|
2009-10-18 11:17:26 +02:00
|
|
|
done
|
|
|
|
else
|
xbps-src: make some targets work by specifying its pkgname.
There are now two ways to use the following targets:
build, build-pkg, clean, configure, extract, fetch, info, install,
install-destdir, remove, stow, unstow.
1) The known way: 'cd srcpkgs/foo && xbps-src <target>"
2) The new way: 'xbps-src <target> foo'.
2010-12-21 18:45:39 +01:00
|
|
|
if [ -z "${_pkgname}" ]; then
|
|
|
|
[ ! -r ./template ] && msg_error "missing build template in $(pwd).\n"
|
|
|
|
_pkgname=$(basename_cwd)
|
|
|
|
fi
|
|
|
|
setup_tmpl ${_pkgname}
|
2009-11-22 08:31:44 +01:00
|
|
|
xbps_make_binpkg
|
2009-10-18 11:17:26 +02:00
|
|
|
fi
|
|
|
|
;;
|
2010-05-19 03:00:52 +02:00
|
|
|
checkvers)
|
|
|
|
check_installed_packages
|
|
|
|
;;
|
2009-10-18 11:17:26 +02:00
|
|
|
chroot)
|
|
|
|
xbps_chroot_handler chroot dummy
|
|
|
|
;;
|
2010-05-20 04:05:35 +02:00
|
|
|
clean)
|
xbps-src: make some targets work by specifying its pkgname.
There are now two ways to use the following targets:
build, build-pkg, clean, configure, extract, fetch, info, install,
install-destdir, remove, stow, unstow.
1) The known way: 'cd srcpkgs/foo && xbps-src <target>"
2) The new way: 'xbps-src <target> foo'.
2010-12-21 18:45:39 +01:00
|
|
|
if [ -z "${_pkgname}" ]; then
|
|
|
|
[ ! -r ./template ] && msg_error "missing build template in $(pwd).\n"
|
|
|
|
_pkgname=$(basename_cwd)
|
|
|
|
fi
|
|
|
|
setup_tmpl ${_pkgname}
|
2010-05-20 04:05:35 +02:00
|
|
|
remove_tmpl_wrksrc $wrksrc
|
|
|
|
;;
|
2009-10-18 11:17:26 +02:00
|
|
|
extract|fetch|info)
|
xbps-src: make some targets work by specifying its pkgname.
There are now two ways to use the following targets:
build, build-pkg, clean, configure, extract, fetch, info, install,
install-destdir, remove, stow, unstow.
1) The known way: 'cd srcpkgs/foo && xbps-src <target>"
2) The new way: 'xbps-src <target> foo'.
2010-12-21 18:45:39 +01:00
|
|
|
if [ -z "${_pkgname}" ]; then
|
|
|
|
[ ! -r ./template ] && msg_error "missing build template in $(pwd).\n"
|
|
|
|
_pkgname=$(basename_cwd)
|
|
|
|
fi
|
|
|
|
setup_tmpl ${_pkgname}
|
2009-10-18 11:17:26 +02:00
|
|
|
if [ "$target" = "info" ]; then
|
2009-11-22 08:31:44 +01:00
|
|
|
info_tmpl
|
2009-10-18 11:17:26 +02:00
|
|
|
exit $?
|
|
|
|
fi
|
2011-02-11 15:29:00 +01:00
|
|
|
fetch_distfiles $update_checksum
|
2011-10-06 17:05:17 +02:00
|
|
|
[ "$target" = "extract" ] && extract_distfiles
|
2009-10-18 11:17:26 +02:00
|
|
|
;;
|
2011-07-04 23:30:30 +02:00
|
|
|
install)
|
xbps-src: make some targets work by specifying its pkgname.
There are now two ways to use the following targets:
build, build-pkg, clean, configure, extract, fetch, info, install,
install-destdir, remove, stow, unstow.
1) The known way: 'cd srcpkgs/foo && xbps-src <target>"
2) The new way: 'xbps-src <target> foo'.
2010-12-21 18:45:39 +01:00
|
|
|
if [ -z "${_pkgname}" ]; then
|
|
|
|
[ ! -r ./template ] && msg_error "missing build template in $(pwd).\n"
|
|
|
|
_pkgname=$(basename_cwd)
|
|
|
|
fi
|
|
|
|
setup_tmpl ${_pkgname}
|
|
|
|
_ORIGINPKG="${_pkgname}"
|
2011-07-06 08:16:56 +02:00
|
|
|
if [ -z "$IN_CHROOT" -a -z "$bootstrap" ]; then
|
2011-07-17 20:12:31 +02:00
|
|
|
xbps_chroot_handler $target ${_ORIGINPKG} || exit $?
|
2010-01-16 02:11:44 +01:00
|
|
|
else
|
2011-07-17 20:12:31 +02:00
|
|
|
install_pkg $pkgname || exit $?
|
2010-01-16 02:11:44 +01:00
|
|
|
fi
|
2009-10-18 11:17:26 +02:00
|
|
|
;;
|
2011-07-17 20:12:31 +02:00
|
|
|
list)
|
|
|
|
$XBPS_BIN_CMD list
|
|
|
|
;;
|
|
|
|
list-files)
|
|
|
|
list_pkg_files ${_pkgname}
|
|
|
|
;;
|
2010-04-27 01:34:19 +02:00
|
|
|
make-repoidx)
|
2010-05-03 22:33:52 +02:00
|
|
|
if [ -n "${_PACKAGEDIR}" ]; then
|
|
|
|
export XBPS_PACKAGESDIR=${_PACKAGEDIR}
|
|
|
|
fi
|
2011-07-17 20:12:31 +02:00
|
|
|
msg_normal "Updating pkg-index for local repository at:\n"
|
|
|
|
msg_normal " $XBPS_PACKAGESDIR\n"
|
2010-04-27 01:34:19 +02:00
|
|
|
${XBPS_REPO_CMD} genindex ${XBPS_PACKAGESDIR} 2>/dev/null
|
|
|
|
;;
|
2009-10-18 11:17:26 +02:00
|
|
|
remove)
|
xbps-src: make some targets work by specifying its pkgname.
There are now two ways to use the following targets:
build, build-pkg, clean, configure, extract, fetch, info, install,
install-destdir, remove, stow, unstow.
1) The known way: 'cd srcpkgs/foo && xbps-src <target>"
2) The new way: 'xbps-src <target> foo'.
2010-12-21 18:45:39 +01:00
|
|
|
if [ -z "${_pkgname}" ]; then
|
|
|
|
[ ! -r ./template ] && msg_error "missing build template in $(pwd).\n"
|
|
|
|
_pkgname=$(basename_cwd)
|
|
|
|
fi
|
|
|
|
setup_tmpl ${_pkgname}
|
2011-07-06 11:29:38 +02:00
|
|
|
if [ -z "$IN_CHROOT" -a -z "$bootstrap" ]; then
|
2011-07-04 21:29:11 +02:00
|
|
|
xbps_chroot_handler $target ${_pkgname}
|
2011-06-16 12:21:12 +02:00
|
|
|
else
|
|
|
|
remove_pkg
|
|
|
|
fi
|
2009-10-18 11:17:26 +02:00
|
|
|
;;
|
|
|
|
stow)
|
|
|
|
stow_flag=yes
|
xbps-src: make some targets work by specifying its pkgname.
There are now two ways to use the following targets:
build, build-pkg, clean, configure, extract, fetch, info, install,
install-destdir, remove, stow, unstow.
1) The known way: 'cd srcpkgs/foo && xbps-src <target>"
2) The new way: 'xbps-src <target> foo'.
2010-12-21 18:45:39 +01:00
|
|
|
if [ -z "${_pkgname}" ]; then
|
|
|
|
[ ! -r ./template ] && msg_error "missing build template in $(pwd).\n"
|
|
|
|
_pkgname=$(basename_cwd)
|
|
|
|
fi
|
|
|
|
setup_tmpl ${_pkgname}
|
2009-11-22 08:31:44 +01:00
|
|
|
stow_pkg_handler stow
|
2009-10-18 11:17:26 +02:00
|
|
|
;;
|
|
|
|
unstow)
|
xbps-src: make some targets work by specifying its pkgname.
There are now two ways to use the following targets:
build, build-pkg, clean, configure, extract, fetch, info, install,
install-destdir, remove, stow, unstow.
1) The known way: 'cd srcpkgs/foo && xbps-src <target>"
2) The new way: 'xbps-src <target> foo'.
2010-12-21 18:45:39 +01:00
|
|
|
if [ -z "${_pkgname}" ]; then
|
|
|
|
[ ! -r ./template ] && msg_error "missing build template in $(pwd).\n"
|
|
|
|
_pkgname=$(basename_cwd)
|
|
|
|
fi
|
|
|
|
setup_tmpl ${_pkgname}
|
2009-11-22 08:31:44 +01:00
|
|
|
stow_pkg_handler unstow
|
2009-10-18 11:17:26 +02:00
|
|
|
;;
|
|
|
|
*)
|
2011-07-04 23:30:30 +02:00
|
|
|
msg_red "xbps-src: invalid target $target.\n"
|
2010-04-27 14:23:53 +02:00
|
|
|
usage && exit 1
|
2009-10-18 11:17:26 +02:00
|
|
|
esac
|
|
|
|
|
|
|
|
# Agur
|
|
|
|
exit $?
|