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'.
This commit is contained in:
Juan RP 2010-12-21 18:45:39 +01:00
parent b5e94efcfb
commit 2d32c8fd9e

View file

@ -67,32 +67,34 @@ $progname: [-Ch] [-c <file>] [-m <dir>] [-p <dir>] [-s <dir>] <target>
Targets: Targets:
bootstrap Build and install the bootstrap packages into <masterdir>. bootstrap Build and install the bootstrap packages into <masterdir>.
build Build a package (fetch + extract + configure + build). build [pkgname] Build a package (fetch + extract + configure + build).
build-pkg [all] Build a binary package from <pkg>. build-pkg [pkgname|all]
Build a binary package from <pkg>.
Package must be installed into destdir. If the <all> Package must be installed into destdir. If the <all>
keyword is used all packages currently installed in keyword is used all packages currently installed in
<masterdir>/<destdir> will be used. <masterdir>/<destdir> will be used. Otherwise <pkgname>
if specified, or the one in cwd.
checkvers Checks installed package versions against srcpkgs checkvers Checks installed package versions against srcpkgs
for new available versions. for new available versions.
chroot Enter to the chroot in <masterdir>. chroot Enter to the chroot in <masterdir>.
clean Remove <pkg> build directory. clean [pkgname] Remove <pkg> build directory.
configure Configure a package (fetch + extract + configure). configure [pkgname] Configure a package (fetch + extract + configure).
extract Extract distribution file(s) into build directory. extract [pkgname] Extract distribution file(s) into build directory.
Build directory is always available in Build directory is always available in
<masterdir>/pkg-builddir/<pkg>. <masterdir>/pkg-builddir/<pkg>.
fetch Download distribution file(s). fetch [pkgname] Download distribution file(s).
info Show information for current pkg build template. info [pkgname] Show information for current pkg build template.
install-destdir build + install into destdir. install-destdir [pkgname] build + install into destdir.
install install-destdir + stow. install [pkgname] install-destdir + stow.
list List installed packages in <masterdir>. list List installed packages in <masterdir>.
listfiles List installed files from <pkg>. listfiles <pkgname> List installed files from <pkg>.
make-repoidx Build a package index for the local repository associated make-repoidx Build a package index for the local repository associated
with the master directory <masterdir> or <pkgdir>, with the master directory <masterdir> or <pkgdir>,
or updates it. or updates it.
remove Remove package completely (destdir + masterdir). remove [pkgname] Remove package completely (destdir + masterdir).
stow Stow <pkg> files from <destdir> into <masterdir> and stow [pkgname] Stow <pkg> files from <destdir> into <masterdir> and
register package in database. register package in database.
unstow Remove <pkg> files from <masterdir> and unregister unstow [pkgname] Remove <pkg> files from <masterdir> and unregister
package from database. package from database.
Options: Options:
@ -205,6 +207,7 @@ shift $(($OPTIND - 1))
[ $# -eq 0 -o $# -gt 2 ] && usage && exit 1 [ $# -eq 0 -o $# -gt 2 ] && usage && exit 1
target="$1" target="$1"
_pkgname="$2"
if [ -z "$target" ]; then if [ -z "$target" ]; then
echo "=> ERROR: missing target." echo "=> ERROR: missing target."
usage && exit 1 usage && exit 1
@ -280,14 +283,17 @@ bootstrap)
;; ;;
build|configure) build|configure)
. $XBPS_SHUTILSDIR/tmpl_funcs.sh . $XBPS_SHUTILSDIR/tmpl_funcs.sh
if [ -z "${_pkgname}" ]; then
[ ! -r ./template ] && msg_error "missing build template in $(pwd).\n" [ ! -r ./template ] && msg_error "missing build template in $(pwd).\n"
. ./template . ./template
_pkgname=$(basename_cwd)
fi
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
xbps_chroot_handler $target $(basename_cwd) xbps_chroot_handler $target ${_pkgname}
else else
_ORIGINPKG="$(basename_cwd)" _ORIGINPKG="${_pkgname}"
setup_tmpl ${_ORIGINPKG} setup_tmpl ${_ORIGINPKG}
# If pkg has dependencies, install them first. # If pkg has dependencies, install them first.
. $XBPS_SHUTILSDIR/pkgtarget_funcs.sh . $XBPS_SHUTILSDIR/pkgtarget_funcs.sh
@ -333,8 +339,11 @@ build-pkg)
fi fi
done done
else else
if [ -z "${_pkgname}" ]; then
[ ! -r ./template ] && msg_error "missing build template in $(pwd).\n" [ ! -r ./template ] && msg_error "missing build template in $(pwd).\n"
setup_tmpl $(basename_cwd) _pkgname=$(basename_cwd)
fi
setup_tmpl ${_pkgname}
xbps_make_binpkg xbps_make_binpkg
fi fi
;; ;;
@ -349,14 +358,20 @@ chroot)
;; ;;
clean) clean)
. $XBPS_SHUTILSDIR/tmpl_funcs.sh . $XBPS_SHUTILSDIR/tmpl_funcs.sh
if [ -z "${_pkgname}" ]; then
[ ! -r ./template ] && msg_error "missing build template in $(pwd).\n" [ ! -r ./template ] && msg_error "missing build template in $(pwd).\n"
setup_tmpl $(basename_cwd) _pkgname=$(basename_cwd)
fi
setup_tmpl ${_pkgname}
remove_tmpl_wrksrc $wrksrc remove_tmpl_wrksrc $wrksrc
;; ;;
extract|fetch|info) extract|fetch|info)
. $XBPS_SHUTILSDIR/tmpl_funcs.sh . $XBPS_SHUTILSDIR/tmpl_funcs.sh
if [ -z "${_pkgname}" ]; then
[ ! -r ./template ] && msg_error "missing build template in $(pwd).\n" [ ! -r ./template ] && msg_error "missing build template in $(pwd).\n"
setup_tmpl $(basename_cwd) _pkgname=$(basename_cwd)
fi
setup_tmpl ${_pkgname}
if [ "$target" = "info" ]; then if [ "$target" = "info" ]; then
. $XBPS_SHUTILSDIR/tmpl_funcs.sh . $XBPS_SHUTILSDIR/tmpl_funcs.sh
info_tmpl info_tmpl
@ -372,13 +387,15 @@ extract|fetch|info)
;; ;;
install|install-destdir) install|install-destdir)
. $XBPS_SHUTILSDIR/tmpl_funcs.sh . $XBPS_SHUTILSDIR/tmpl_funcs.sh
if [ -z "${_pkgname}" ]; then
[ ! -r ./template ] && msg_error "missing build template in $(pwd).\n" [ ! -r ./template ] && msg_error "missing build template in $(pwd).\n"
. ./template _pkgname=$(basename_cwd)
fi
setup_tmpl ${_pkgname}
install_destdir_target=no install_destdir_target=no
[ "$target" = "install-destdir" ] && install_destdir_target=yes [ "$target" = "install-destdir" ] && install_destdir_target=yes
_ORIGINPKG="$(basename_cwd)" _ORIGINPKG="${_pkgname}"
if [ -z "$in_chroot" -a -z "$base_chroot" ]; then if [ -z "$in_chroot" -a -z "$base_chroot" ]; then
. $XBPS_SHUTILSDIR/chroot.sh . $XBPS_SHUTILSDIR/chroot.sh
xbps_chroot_handler $target ${_ORIGINPKG} $dontrm_builddir xbps_chroot_handler $target ${_ORIGINPKG} $dontrm_builddir
@ -407,22 +424,31 @@ make-repoidx)
;; ;;
remove) remove)
. $XBPS_SHUTILSDIR/pkgtarget_funcs.sh . $XBPS_SHUTILSDIR/pkgtarget_funcs.sh
if [ -z "${_pkgname}" ]; then
[ ! -r ./template ] && msg_error "missing build template in $(pwd).\n" [ ! -r ./template ] && msg_error "missing build template in $(pwd).\n"
setup_tmpl $(basename_cwd) _pkgname=$(basename_cwd)
fi
setup_tmpl ${_pkgname}
remove_pkg remove_pkg
;; ;;
stow) stow)
stow_flag=yes stow_flag=yes
. $XBPS_SHUTILSDIR/tmpl_funcs.sh . $XBPS_SHUTILSDIR/tmpl_funcs.sh
if [ -z "${_pkgname}" ]; then
[ ! -r ./template ] && msg_error "missing build template in $(pwd).\n" [ ! -r ./template ] && msg_error "missing build template in $(pwd).\n"
setup_tmpl $(basename_cwd) _pkgname=$(basename_cwd)
fi
setup_tmpl ${_pkgname}
. $XBPS_SHUTILSDIR/stow_funcs.sh . $XBPS_SHUTILSDIR/stow_funcs.sh
stow_pkg_handler stow stow_pkg_handler stow
;; ;;
unstow) unstow)
. $XBPS_SHUTILSDIR/tmpl_funcs.sh . $XBPS_SHUTILSDIR/tmpl_funcs.sh
if [ -z "${_pkgname}" ]; then
[ ! -r ./template ] && msg_error "missing build template in $(pwd).\n" [ ! -r ./template ] && msg_error "missing build template in $(pwd).\n"
setup_tmpl $(basename_cwd) _pkgname=$(basename_cwd)
fi
setup_tmpl ${_pkgname}
. $XBPS_SHUTILSDIR/stow_funcs.sh . $XBPS_SHUTILSDIR/stow_funcs.sh
stow_pkg_handler unstow stow_pkg_handler unstow
;; ;;