2008-10-29 18:33:55 +01:00
|
|
|
#!/bin/sh
|
2008-09-26 21:59:07 +02:00
|
|
|
#
|
2008-10-13 07:32:05 +02:00
|
|
|
# xbps - A simple, minimal, fast and uncomplete build package system.
|
2008-09-26 23:23:41 +02:00
|
|
|
#-
|
|
|
|
# Copyright (c) 2008 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.
|
|
|
|
#-
|
2008-10-30 06:40:11 +01:00
|
|
|
trap "echo && exit 1" INT QUIT
|
2008-10-29 03:20:14 +01:00
|
|
|
|
2008-10-23 17:14:00 +02:00
|
|
|
: ${XBPS_CONFIG_FILE:=/etc/xbps.conf}
|
2008-09-26 21:59:07 +02:00
|
|
|
|
2008-09-27 03:17:12 +02:00
|
|
|
: ${progname:=$(basename $0)}
|
2008-12-12 18:12:45 +01:00
|
|
|
: ${fakeroot_cmd:=fakeroot}
|
2008-10-23 17:14:00 +02:00
|
|
|
: ${fetch_cmd:=wget}
|
2008-10-24 03:34:50 +02:00
|
|
|
: ${xbps_machine:=$(uname -m)}
|
2008-09-30 22:48:52 +02:00
|
|
|
|
2008-09-27 03:17:12 +02:00
|
|
|
usage()
|
|
|
|
{
|
2008-09-26 21:59:07 +02:00
|
|
|
cat << _EOF
|
2008-12-12 18:12:45 +01:00
|
|
|
$progname: [-C] [-c <config_file>] <target> <pkg>
|
2008-09-26 21:59:07 +02:00
|
|
|
|
2008-10-13 01:11:24 +02:00
|
|
|
Targets:
|
2008-12-15 07:42:21 +01:00
|
|
|
build <pkg> Build a package (fetch + extract + configure + build).
|
|
|
|
build-pkg [<pkg>|all] Build a binary package from <pkg>.
|
|
|
|
Package must be installed into destdir. If the <all>
|
|
|
|
keyword is used instead of <pkg>, all packages
|
|
|
|
currently installed will be used.
|
|
|
|
chroot Enter to the chroot in masterdir.
|
|
|
|
configure <pkg> Configure a package (fetch + extract + configure).
|
|
|
|
extract <pkg> Extract distribution file(s) into build directory.
|
|
|
|
fetch <pkg> Download distribution file(s).
|
2008-12-20 00:10:06 +01:00
|
|
|
genindex [/path/dir] Generate a package index for a directory containing
|
|
|
|
binary packages. If no path is specified, the
|
2008-12-20 00:12:34 +01:00
|
|
|
XBPS_PACKAGESDIR in the configuration file will be
|
2008-12-20 00:10:06 +01:00
|
|
|
used by default.
|
2008-12-15 07:42:21 +01:00
|
|
|
info <pkg> Show information about <pkg>.
|
|
|
|
install-destdir <pkg> build + install into destdir.
|
|
|
|
install <pkg> install-destdir + stow.
|
|
|
|
list List installed packages in masterdir.
|
|
|
|
listfiles <pkg> List installed files from <pkg>.
|
|
|
|
remove <pkg> Remove package completely (destdir + masterdir).
|
|
|
|
stow <pkg> Copy <pkg> files from destdir into masterdir and
|
|
|
|
register package in database.
|
|
|
|
unstow <pkg> Remove <pkg> files from masterdir and unregister
|
|
|
|
package from database.
|
2008-09-26 21:59:07 +02:00
|
|
|
|
2008-10-13 01:11:24 +02:00
|
|
|
Options:
|
2008-12-15 07:42:21 +01:00
|
|
|
-C Do not remove build directory after successful installation.
|
|
|
|
-c Path to global configuration file:
|
|
|
|
if not specified /etc/xbps.conf is used.
|
2008-09-26 21:59:07 +02:00
|
|
|
_EOF
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
2008-12-13 05:23:16 +01:00
|
|
|
check_path()
|
2008-10-04 20:44:56 +02:00
|
|
|
{
|
2008-12-13 05:23:16 +01:00
|
|
|
eval local orig="$1"
|
2008-10-04 20:44:56 +02:00
|
|
|
|
2008-12-13 05:23:16 +01:00
|
|
|
case "$orig" in
|
|
|
|
/) ;;
|
|
|
|
/*) orig="${orig%/}" ;;
|
|
|
|
*) orig="$(pwd)/${orig%/}" ;;
|
2008-10-04 20:44:56 +02:00
|
|
|
esac
|
|
|
|
|
2008-12-13 05:23:16 +01:00
|
|
|
path_fixed="$orig"
|
2008-10-04 20:44:56 +02:00
|
|
|
}
|
|
|
|
|
2008-12-13 05:23:16 +01:00
|
|
|
run_file()
|
2008-09-29 17:01:12 +02:00
|
|
|
{
|
2008-12-13 05:23:16 +01:00
|
|
|
local file="$1"
|
2008-09-29 22:32:08 +02:00
|
|
|
|
2008-12-13 05:23:16 +01:00
|
|
|
check_path "$file"
|
|
|
|
. $path_fixed
|
2008-09-29 17:01:12 +02:00
|
|
|
}
|
|
|
|
|
2008-12-13 05:23:16 +01:00
|
|
|
set_defvars()
|
2008-09-29 17:01:12 +02:00
|
|
|
{
|
2008-12-13 05:23:16 +01:00
|
|
|
local i=
|
2008-10-11 15:48:01 +02:00
|
|
|
|
2008-12-13 05:23:16 +01:00
|
|
|
: ${XBPS_TEMPLATESDIR:=$XBPS_DISTRIBUTIONDIR/templates}
|
|
|
|
: ${XBPS_HELPERSDIR:=$XBPS_TEMPLATESDIR/helpers}
|
|
|
|
: ${XBPS_CACHEDIR:=$XBPS_MASTERDIR/var/cache/xbps}
|
2008-12-23 12:28:21 +01:00
|
|
|
: ${XBPS_META_PATH:=$XBPS_CACHEDIR/}
|
2008-12-13 05:23:16 +01:00
|
|
|
: ${XBPS_PKGMETADIR:=$XBPS_CACHEDIR/metadata}
|
2008-12-21 23:57:02 +01:00
|
|
|
: ${XBPS_SHUTILSDIR:=$XBPS_DISTRIBUTIONDIR/shutils}
|
2008-10-20 16:34:27 +02:00
|
|
|
|
2008-12-21 23:57:02 +01:00
|
|
|
local DDIRS="XBPS_TEMPLATESDIR XBPS_HELPERSDIR XBPS_SHUTILSDIR"
|
2008-12-13 05:23:16 +01:00
|
|
|
for i in ${DDIRS}; do
|
|
|
|
eval val="\$$i"
|
|
|
|
[ ! -d "$val" ] && msg_error "cannot find $i, aborting."
|
2008-10-12 20:05:52 +02:00
|
|
|
done
|
2008-10-07 02:55:37 +02:00
|
|
|
|
2008-12-27 12:56:51 +01:00
|
|
|
XBPS_REGPKGDB_CMD="xbps-pkgdb -r $XBPS_MASTERDIR"
|
|
|
|
XBPS_BIN_CMD="xbps-bin -r $XBPS_MASTERDIR"
|
2008-10-13 05:50:40 +02:00
|
|
|
}
|
|
|
|
|
2008-10-12 20:05:52 +02:00
|
|
|
#
|
2008-12-13 05:23:16 +01:00
|
|
|
# Checks that all required variables specified in the configuration
|
|
|
|
# file are properly working.
|
2008-10-12 20:05:52 +02:00
|
|
|
#
|
2008-12-13 05:23:16 +01:00
|
|
|
check_config_vars()
|
2008-10-12 20:05:52 +02:00
|
|
|
{
|
2008-12-13 05:23:16 +01:00
|
|
|
local cffound=
|
2008-10-23 17:14:00 +02:00
|
|
|
local f=
|
2008-10-12 20:05:52 +02:00
|
|
|
|
2008-12-13 05:23:16 +01:00
|
|
|
if [ -z "$config_file_specified" ]; then
|
2008-12-22 00:40:36 +01:00
|
|
|
config_file_paths="$XBPS_CONFIG_FILE ./etc/xbps.conf"
|
2008-12-13 05:23:16 +01:00
|
|
|
for f in $config_file_paths; do
|
|
|
|
[ -f $f ] && XBPS_CONFIG_FILE=$f && \
|
|
|
|
cffound=yes && break
|
|
|
|
done
|
|
|
|
[ -z "$cffound" ] && msg_error "cannot find a config file"
|
2008-12-09 16:45:01 +01:00
|
|
|
fi
|
|
|
|
|
2008-12-13 05:23:16 +01:00
|
|
|
run_file ${XBPS_CONFIG_FILE}
|
|
|
|
XBPS_CONFIG_FILE=$path_fixed
|
2008-10-12 20:05:52 +02:00
|
|
|
|
2008-12-13 05:23:16 +01:00
|
|
|
if [ ! -f "$XBPS_CONFIG_FILE" ]; then
|
|
|
|
msg_error "cannot find configuration file: $XBPS_CONFIG_FILE"
|
2008-12-09 17:11:40 +01:00
|
|
|
fi
|
2008-10-12 20:05:52 +02:00
|
|
|
|
2008-12-13 05:23:16 +01:00
|
|
|
local XBPS_VARS="XBPS_MASTERDIR XBPS_DESTDIR XBPS_BUILDDIR \
|
|
|
|
XBPS_SRCDISTDIR"
|
2008-10-22 01:54:48 +02:00
|
|
|
|
2008-12-13 05:23:16 +01:00
|
|
|
for f in ${XBPS_VARS}; do
|
|
|
|
eval val="\$$f"
|
|
|
|
[ -z "$val" ] && msg_error "'$f' not set in configuration file"
|
|
|
|
|
|
|
|
if [ ! -d "$val" ]; then
|
|
|
|
mkdir "$val"
|
|
|
|
[ $? -ne 0 ] && msg_error "couldn't create '$f' directory"
|
2008-10-27 08:44:41 +01:00
|
|
|
fi
|
2008-10-23 17:14:00 +02:00
|
|
|
done
|
2008-09-28 11:41:26 +02:00
|
|
|
}
|
|
|
|
|
2008-09-26 23:23:41 +02:00
|
|
|
#
|
|
|
|
# main()
|
|
|
|
#
|
2008-10-29 18:33:55 +01:00
|
|
|
while getopts "Cc:" opt; do
|
2008-10-23 17:14:00 +02:00
|
|
|
case $opt in
|
2008-11-03 08:38:38 +01:00
|
|
|
C) dontrm_builddir=yes;;
|
|
|
|
c) config_file_specified=yes; XBPS_CONFIG_FILE="$OPTARG";;
|
|
|
|
--) shift; break;;
|
2008-09-26 21:59:07 +02:00
|
|
|
esac
|
|
|
|
done
|
2008-10-23 17:14:00 +02:00
|
|
|
shift $(($OPTIND - 1))
|
2008-09-26 21:59:07 +02:00
|
|
|
|
2008-11-03 11:01:42 +01:00
|
|
|
[ $# -eq 0 -o $# -gt 2 ] && usage
|
2008-09-26 21:59:07 +02:00
|
|
|
|
2008-09-27 03:17:12 +02:00
|
|
|
target="$1"
|
|
|
|
if [ -z "$target" ]; then
|
2008-10-29 23:34:05 +01:00
|
|
|
echo "=> ERROR: missing target."
|
2008-09-26 21:59:07 +02:00
|
|
|
usage
|
|
|
|
fi
|
|
|
|
|
2008-09-30 22:48:52 +02:00
|
|
|
#
|
|
|
|
# Check configuration vars before anyting else, and set defaults vars.
|
|
|
|
#
|
2008-09-29 17:01:12 +02:00
|
|
|
check_config_vars
|
2008-09-30 22:48:52 +02:00
|
|
|
set_defvars
|
2008-12-13 05:23:16 +01:00
|
|
|
. $XBPS_SHUTILSDIR/common_funcs.sh
|
2008-09-29 17:01:12 +02:00
|
|
|
|
2008-09-26 21:59:07 +02:00
|
|
|
# Main switch
|
2008-09-27 03:17:12 +02:00
|
|
|
case "$target" in
|
2008-12-12 18:12:45 +01:00
|
|
|
build|configure)
|
2008-12-13 05:23:16 +01:00
|
|
|
. $XBPS_SHUTILSDIR/tmpl_funcs.sh
|
2008-10-12 20:05:52 +02:00
|
|
|
setup_tmpl $2
|
2008-12-13 05:23:16 +01:00
|
|
|
|
2008-10-27 07:42:40 +01:00
|
|
|
if [ -z "$base_chroot" -a -z "$in_chroot" ]; then
|
2008-12-13 03:01:24 +01:00
|
|
|
. $XBPS_SHUTILSDIR/chroot.sh
|
2008-12-12 18:12:45 +01:00
|
|
|
if [ "$target" = "build" ]; then
|
2008-12-13 03:01:24 +01:00
|
|
|
xbps_chroot_handler build $2
|
2008-12-12 18:12:45 +01:00
|
|
|
else
|
2008-12-13 03:01:24 +01:00
|
|
|
xbps_chroot_handler configure $2
|
2008-12-12 18:12:45 +01:00
|
|
|
fi
|
2008-10-27 07:42:40 +01:00
|
|
|
else
|
2008-12-13 05:23:16 +01:00
|
|
|
. $XBPS_SHUTILSDIR/fetch_funcs.sh
|
2008-10-27 11:19:37 +01:00
|
|
|
fetch_distfiles $2
|
|
|
|
if [ ! -f "$XBPS_EXTRACT_DONE" ]; then
|
2008-12-13 05:23:16 +01:00
|
|
|
. $XBPS_SHUTILSDIR/extract_funcs.sh
|
2008-10-27 11:19:37 +01:00
|
|
|
extract_distfiles $2
|
|
|
|
fi
|
2008-12-12 18:12:45 +01:00
|
|
|
if [ "$target" = "configure" ]; then
|
2008-12-13 05:23:16 +01:00
|
|
|
. $XBPS_SHUTILSDIR/configure_funcs.sh
|
2008-10-27 11:19:37 +01:00
|
|
|
configure_src_phase $2
|
2008-12-12 18:12:45 +01:00
|
|
|
else
|
|
|
|
if [ ! -f "$XBPS_CONFIGURE_DONE" ]; then
|
2008-12-13 05:23:16 +01:00
|
|
|
. $XBPS_SHUTILSDIR/configure_funcs.sh
|
2008-12-12 18:12:45 +01:00
|
|
|
configure_src_phase $2
|
|
|
|
fi
|
2008-12-13 05:23:16 +01:00
|
|
|
. $XBPS_SHUTILSDIR/build_funcs.sh
|
2008-12-12 18:12:45 +01:00
|
|
|
build_src_phase $2
|
2008-10-27 11:19:37 +01:00
|
|
|
fi
|
2008-10-12 20:05:52 +02:00
|
|
|
fi
|
|
|
|
;;
|
2008-12-13 03:01:24 +01:00
|
|
|
build-pkg)
|
|
|
|
. $XBPS_SHUTILSDIR/binpkg.sh
|
2008-12-13 05:23:16 +01:00
|
|
|
. $XBPS_SHUTILSDIR/tmpl_funcs.sh
|
2008-12-13 07:05:42 +01:00
|
|
|
if [ "$2" = "all" ]; then
|
2008-12-26 11:30:19 +01:00
|
|
|
for f in $($XBPS_BIN_CMD list|awk '{print $1}'); do
|
2008-12-13 07:05:42 +01:00
|
|
|
setup_tmpl $f
|
|
|
|
xbps_make_binpkg
|
|
|
|
reset_tmpl_vars
|
|
|
|
done
|
|
|
|
else
|
|
|
|
setup_tmpl $2
|
|
|
|
xbps_make_binpkg
|
|
|
|
fi
|
2008-12-12 18:12:45 +01:00
|
|
|
;;
|
2008-10-24 09:44:51 +02:00
|
|
|
chroot)
|
2008-12-13 03:01:24 +01:00
|
|
|
. $XBPS_SHUTILSDIR/chroot.sh
|
|
|
|
xbps_chroot_handler chroot dummy
|
2008-10-24 09:44:51 +02:00
|
|
|
;;
|
2008-12-12 18:12:45 +01:00
|
|
|
extract|fetch|info)
|
2008-12-13 05:23:16 +01:00
|
|
|
. $XBPS_SHUTILSDIR/tmpl_funcs.sh
|
2008-10-12 20:05:52 +02:00
|
|
|
setup_tmpl $2
|
2008-12-13 05:23:16 +01:00
|
|
|
if [ "$target" = "info" ]; then
|
|
|
|
. $XBPS_SHUTILSDIR/tmpl_funcs.sh
|
|
|
|
info_tmpl $2
|
2008-12-13 15:11:24 +01:00
|
|
|
exit $?
|
2008-12-13 05:23:16 +01:00
|
|
|
fi
|
|
|
|
if [ "$target" = "fetch" ]; then
|
|
|
|
. $XBPS_SHUTILSDIR/fetch_funcs.sh
|
|
|
|
fetch_distfiles $2
|
2008-12-13 15:11:24 +01:00
|
|
|
exit $?
|
2008-12-13 05:23:16 +01:00
|
|
|
fi
|
|
|
|
. $XBPS_SHUTILSDIR/extract_funcs.sh
|
2008-10-12 20:05:52 +02:00
|
|
|
extract_distfiles $2
|
|
|
|
;;
|
2008-12-18 07:32:42 +01:00
|
|
|
genindex)
|
|
|
|
. $XBPS_SHUTILSDIR/binpkg-genindex.sh
|
2008-12-20 00:10:06 +01:00
|
|
|
write_repo_pkgindex $2
|
2008-12-18 07:32:42 +01:00
|
|
|
;;
|
2008-12-12 18:12:45 +01:00
|
|
|
install|install-destdir)
|
2008-10-29 23:34:05 +01:00
|
|
|
[ -z "$2" ] && msg_error "missing package name after target."
|
2008-12-12 18:12:45 +01:00
|
|
|
[ "$target" = "install-destdir" ] && install_destdir_target=yes
|
2008-12-13 05:23:16 +01:00
|
|
|
. $XBPS_SHUTILSDIR/pkgtarget_funcs.sh
|
2008-10-27 10:29:21 +01:00
|
|
|
install_pkg $2
|
2008-10-13 01:11:24 +02:00
|
|
|
;;
|
2008-12-12 18:12:45 +01:00
|
|
|
list|listfiles)
|
2008-12-13 05:23:16 +01:00
|
|
|
if [ "$target" = "list" ]; then
|
2008-12-26 11:30:19 +01:00
|
|
|
$XBPS_BIN_CMD list
|
2008-12-13 15:11:24 +01:00
|
|
|
exit $?
|
2008-12-13 05:23:16 +01:00
|
|
|
fi
|
|
|
|
. $XBPS_SHUTILSDIR/pkgtarget_funcs.sh
|
2008-10-13 05:50:40 +02:00
|
|
|
list_pkg_files $2
|
|
|
|
;;
|
2008-09-28 11:41:26 +02:00
|
|
|
remove)
|
2008-10-29 23:34:05 +01:00
|
|
|
[ -z "$2" ] && msg_error "missing package name after target."
|
2008-12-13 05:23:16 +01:00
|
|
|
. $XBPS_SHUTILSDIR/pkgtarget_funcs.sh
|
2008-10-12 20:05:52 +02:00
|
|
|
remove_pkg $2
|
2008-09-28 11:41:26 +02:00
|
|
|
;;
|
2008-09-28 07:12:07 +02:00
|
|
|
stow)
|
2008-10-04 06:29:49 +02:00
|
|
|
stow_flag=yes
|
2008-12-13 05:23:16 +01:00
|
|
|
. $XBPS_SHUTILSDIR/tmpl_funcs.sh
|
2008-10-12 20:05:52 +02:00
|
|
|
setup_tmpl $2
|
2008-12-13 05:23:16 +01:00
|
|
|
. $XBPS_SHUTILSDIR/stow_funcs.sh
|
2008-10-12 20:05:52 +02:00
|
|
|
stow_pkg $2
|
2008-09-28 07:12:07 +02:00
|
|
|
;;
|
|
|
|
unstow)
|
2008-12-13 05:23:16 +01:00
|
|
|
. $XBPS_SHUTILSDIR/tmpl_funcs.sh
|
2008-10-12 20:05:52 +02:00
|
|
|
setup_tmpl $2
|
2008-12-13 05:23:16 +01:00
|
|
|
. $XBPS_SHUTILSDIR/stow_funcs.sh
|
2008-10-12 20:05:52 +02:00
|
|
|
unstow_pkg $2
|
2008-09-26 21:59:07 +02:00
|
|
|
;;
|
|
|
|
*)
|
2008-10-29 23:34:05 +01:00
|
|
|
echo "=> ERROR: invalid target: $target."
|
2008-09-26 21:59:07 +02:00
|
|
|
usage
|
|
|
|
esac
|
|
|
|
|
|
|
|
# Agur
|
2008-12-13 03:01:24 +01:00
|
|
|
exit $?
|