Massive changes to allow installing pkgs in a chroot.

Some changes include:
 - Xstow is not used anymore, files are copied into masterdir.
 - a new target install-chroot has been created.
 - a new meta-template xbps-base-chroot has been created required for
   the install-chroot target.
 - Removed XBPS_SYSCONFDIR, /etc is used by default.
Other changes that I cannot remember right now...

--HG--
extra : convert_revision : fb57d9dafb56aeb03cc935580172e075ce584fd5
This commit is contained in:
Juan RP 2008-10-23 17:14:00 +02:00
parent af9b77fec1
commit 89f264e88c
13 changed files with 302 additions and 314 deletions

14
README
View file

@ -3,10 +3,6 @@ xbps - xtraeme's build package system.
It is a simple build package system that uses Xstow to allow packages It is a simple build package system that uses Xstow to allow packages
to be available at a master directory. to be available at a master directory.
Multiple versions of a package can be installed, because they can be enabled
or disabled at the master directory anytime, to e.g allow testing different
versions of the same package by "stowning" or "unstowning" them.
xbps uses proplib, a property container object library and it's almost the xbps uses proplib, a property container object library and it's almost the
same one available for NetBSD. Be sure to have it installed before using same one available for NetBSD. Be sure to have it installed before using
xbps. You can get it at: xbps. You can get it at:
@ -39,7 +35,7 @@ will be installed and "stowned".
If the package is properly installed, it will be "stowned" automatically. If the package is properly installed, it will be "stowned" automatically.
``stowned´´ means that this package is available in the master directory, ``stowned´´ means that this package is available in the master directory,
on which ``Xstow´´ has created links from DESTDIR/<pkgname>. on which xpbs has copied all files from DESTDIR/<pkgname>.
To remove a currently installed (and stowned) package, you can use: To remove a currently installed (and stowned) package, you can use:
@ -48,14 +44,6 @@ To remove a currently installed (and stowned) package, you can use:
Please note that when you remove it, the package will also be removed Please note that when you remove it, the package will also be removed
from XBPS_DESTDIR and previously "unstowned". from XBPS_DESTDIR and previously "unstowned".
xbps uses some db(1) btree files, to record what packages are currently
"stowned". Once you install successfully or stown a package, the package
will be registered in XBPS_DESTDIR/.xbps-registered-pkg.db.
While "unstowning" a package, it won't be available anymore in the master
directory and therefore it probably won't work if used from
XBPS_DESTDIR/<pkgname>.
Summary, to stow an already installed package (into XBPS_DESTDIR/<pkgname>): Summary, to stow an already installed package (into XBPS_DESTDIR/<pkgname>):
$ xbps.sh stow glib $ xbps.sh stow glib

View file

@ -0,0 +1,92 @@
#
# Helper to install packages into a sandbox in masterdir.
# Actually this needs the xbps-base-chroot package installed.
#
# Umount stuff if SIGINT or SIGQUIT was caught
trap umount_chroot_fs INT QUIT
check_installed_pkg xbps-base-chroot 0.1
if [ $? -ne 0 ]; then
echo "*** ERROR: xbps-base-chroot pkg not installed ***"
exit 1
fi
if [ "$(id -u)" -ne 0 ]; then
echo "*** ERROR: you must be root to use this target ***"
exit 1
fi
echo -n "=> Preparing sandbox on $XBPS_MASTERDIR... "
if [ ! -x $XBPS_MASTERDIR/bin/sh ]; then
cd $XBPS_MASTERDIR/bin && ln -s bash sh
fi
if [ ! -f $XBPS_MASTERDIR/.xbps_perms_done ]; then
chown -R root:root $XBPS_MASTERDIR/*
chmod +s $XBPS_MASTERDIR/usr/libexec/pt_chown
cp -af /etc/passwd /etc/shadow /etc/group /etc/hosts $XBPS_MASTERDIR/etc
touch $XBPS_MASTERDIR/.xbps_perms_done
fi
for f in bin sbin tmp var sys proc dev xbps; do
[ ! -d $XBPS_MASTERDIR/$f ] && mkdir -p $XBPS_MASTERDIR/$f
done
for f in sys proc dev; do
if [ ! -f $XBPS_MASTERDIR/.${f}_mount_bind_done ]; then
mount -o bind /$f $XBPS_MASTERDIR/$f
[ $? -eq 0 ] && touch $XBPS_MASTERDIR/.${f}_mount_bind_done
fi
done
if [ ! -f $XBPS_MASTERDIR/.xbps_mount_bind_done ]; then
mount -o bind $XBPS_DISTRIBUTIONDIR $XBPS_MASTERDIR/xbps
[ $? -eq 0 ] && touch $XBPS_MASTERDIR/.xbps_mount_bind_done
fi
if [ ! -f $XBPS_MASTERDIR/.xbps_builddir_mount_bind_done ]; then
[ ! -d $XBPS_MASTERDIR/xbps-builddir ] && mkdir -p \
$XBPS_MASTERDIR/xbps-builddir
mount -o bind $XBPS_BUILDDIR $XBPS_MASTERDIR/xbps-builddir
[ $? -eq 0 ] && touch $XBPS_MASTERDIR/.xbps_builddir_mount_bind_done
fi
echo "XBPS_DISTRIBUTIONDIR=/xbps" > $XBPS_MASTERDIR/etc/xbps.conf
echo "XBPS_MASTERDIR=/" >> $XBPS_MASTERDIR/etc/xbps.conf
echo "XBPS_DESTDIR=/xbps/packages" >> $XBPS_MASTERDIR/etc/xbps.conf
echo "XBPS_BUILDDIR=/xbps-builddir" >> $XBPS_MASTERDIR/etc/xbps.conf
echo "XBPS_SRCDISTDIR=/xbps/srcdistdir" >> $XBPS_MASTERDIR/etc/xbps.conf
echo "XBPS_CFLAGS=\"$XBPS_CFLAGS\"" >> $XBPS_MASTERDIR/etc/xbps.conf
echo "XBPS_CXXFLAGS=\"\$XBPS_CFLAGS\"" >> $XBPS_MASTERDIR/etc/xbps.conf
echo "done."
install_chroot_pkg()
{
local pkg="$1"
[ -z "$pkg" ] && return 1
echo -n "=> Rebuilding dynamic linker's cache..."
chroot $XBPS_MASTERDIR /sbin/ldconfig -c /etc/ld.so.conf
chroot $XBPS_MASTERDIR /sbin/ldconfig -C /etc/ld.so.cache
echo " done."
chroot $XBPS_MASTERDIR /xbps/xbps.sh install $pkg
umount_chroot_fs
}
umount_chroot_fs()
{
for f in sys proc dev xbps xbps-builddir; do
umount $XBPS_MASTERDIR/$f
done
rm -f $XBPS_MASTERDIR/.xbps_builddir_mount_bind_done
rm -f $XBPS_MASTERDIR/.xbps_mount_bind_done
rm -f $XBPS_MASTERDIR/.sys_mount_bind_done
rm -f $XBPS_MASTERDIR/.dev_mount_bind_done
rm -f $XBPS_MASTERDIR/.proc_mount_bind_done
}

View file

@ -1,5 +0,0 @@
#
# Rebuild dynamic linker's cache after building glibc.
#
$XBPS_DESTDIR/$pkgname-$version/sbin/ldconfig -C $XBPS_SYSCONFDIR/ld.so.cache
$XBPS_DESTDIR/$pkgname-$version/sbin/ldconfig

View file

@ -1,4 +1,4 @@
# We must configure it in another directory. # We must configure it in another directory.
$mkdir_cmd -p $wrksrc/build_obj && cd $wrksrc/build_obj mkdir -p $wrksrc/build_obj && cd $wrksrc/build_obj
wrksrc=$wrksrc/build_obj wrksrc=$wrksrc/build_obj

View file

@ -1,3 +1,4 @@
# Create $XBPS_SYSCONFDIR/ld.conf # Create destdir/etc/ld.conf
#
$touch_cmd $XBPS_SYSCONFDIR/ld.so.conf mkdir -p $XBPS_DESTDIR/$pkgname-$version/etc
touch $XBPS_DESTDIR/$pkgname-$version/etc/ld.so.conf

View file

@ -4,6 +4,7 @@ version=2.8
wrksrc="libc" wrksrc="libc"
distfiles="ftp://ftp.archlinux.org/other/glibc/$pkgname-2.8_20080828@.tar.bz2" distfiles="ftp://ftp.archlinux.org/other/glibc/$pkgname-2.8_20080828@.tar.bz2"
build_style=gnu_configure build_style=gnu_configure
configure_env="ac_cv_path_BASH_SHELL=/bin/bash"
configure_script="../configure" configure_script="../configure"
configure_args="--with-tls -disable-profile --with-__thread configure_args="--with-tls -disable-profile --with-__thread
--enable-kernel=2.6.16 --enable-add-ons --without-gd --enable-bind-now --enable-kernel=2.6.16 --enable-add-ons --without-gd --enable-bind-now

View file

@ -0,0 +1,14 @@
# Template file for 'linux-headers'
pkgname=linux-headers
version=2.6.27.3
wrksrc="linux-$version"
distfiles="http://www.kernel.org/pub/linux/kernel/v2.6/linux-$version@.tar.bz2"
build_style=only-install
make_install_target="
INSTALL_HDR_PATH=$XBPS_DESTDIR/$pkgname-$version/usr
headers_install"
short_desc="The Linux kernel headers"
maintainer="Juan RP <xtraeme@gmail.com>"
checksum=52d9526ea8df33c9fab3df4564b0147b1866c76b0fd31474b92592567384a02c
long_desc="
This package provides the linux kernel headers for use in userspace."

View file

@ -4,6 +4,7 @@ version=5.6
distfiles="http://ftp.gnu.org/pub/gnu/ncurses/$pkgname-$version@.tar.gz" distfiles="http://ftp.gnu.org/pub/gnu/ncurses/$pkgname-$version@.tar.gz"
build_style=gnu_configure build_style=gnu_configure
configure_args="--with-shared" configure_args="--with-shared"
make_install_args="ticdir=$XBPS_DESTDIR/$pkgname-$version/usr/share/terminfo"
short_desc="A System V Release 4.0 curses emulation library" short_desc="A System V Release 4.0 curses emulation library"
maintainer="Juan RP <xtraeme@gmail.com>" maintainer="Juan RP <xtraeme@gmail.com>"
checksum=f9cac2b31683a37d65bc37119599752198a0691e462d0d1a252cf9815f5724d5 checksum=f9cac2b31683a37d65bc37119599752198a0691e462d0d1a252cf9815f5724d5

View file

@ -4,7 +4,6 @@ version=7.8
distfiles=" distfiles="
http://kent.dl.sourceforge.net/sourceforge/pcre/$pkgname-$version@.tar.bz2" http://kent.dl.sourceforge.net/sourceforge/pcre/$pkgname-$version@.tar.bz2"
build_style=gnu_configure build_style=gnu_configure
pkgconfig_override="libpcre.pc libpcrecpp.pc"
configure_args="--enable-utf8 --enable-unicode-properties" configure_args="--enable-utf8 --enable-unicode-properties"
short_desc="Perl Compatible Regular Expressions" short_desc="Perl Compatible Regular Expressions"
maintainer="Juan RP <xtraeme@gmail.com>" maintainer="Juan RP <xtraeme@gmail.com>"
@ -16,4 +15,4 @@ long_desc="
correspond to the POSIX regular expression API. The PCRE library is free, correspond to the POSIX regular expression API. The PCRE library is free,
even for building commercial software." even for building commercial software."
build_depends="libtool-2.2.6a" run_depends="glibc-2.8"

View file

@ -3,6 +3,7 @@ pkgname=sed
version=4.1.5 version=4.1.5
distfiles="http://ftp.gnu.org/gnu/$pkgname/$pkgname-$version@.tar.gz" distfiles="http://ftp.gnu.org/gnu/$pkgname/$pkgname-$version@.tar.gz"
build_style=gnu_configure build_style=gnu_configure
configure_args="--bindir=$XBPS_DESTDIR/$pkgname-$version/bin"
short_desc="The GNU stream editor" short_desc="The GNU stream editor"
maintainer="Juan RP <xtraeme@gmail.com>" maintainer="Juan RP <xtraeme@gmail.com>"
checksum=be955bef7a81d69222e929689e0de0ecf64c13dc5b15b2ee5696d5ef66fdeec0 checksum=be955bef7a81d69222e929689e0de0ecf64c13dc5b15b2ee5696d5ef66fdeec0

View file

@ -0,0 +1,12 @@
# Template file for 'xbps-base-chroot'
pkgname=xbps-base-chroot
version=0.1
build_style=meta-template
short_desc="xbps base packages for the chroot target"
maintainer="Juan RP <xtraeme@gmail.com>"
long_desc="
This package installs all necessary packages to be able to build packages
inside of a chroot and continue installing them."
build_depends="glibc-2.8 bash-3.2 coreutils-6.12 sed-4.1.5 make-3.81
tar-1.20 bzip2-1.0.5 gzip-1.3.12 proplib-0.1 linux-headers-2.6.27.3"

View file

@ -22,27 +22,13 @@ XBPS_DESTDIR=$XBPS_DISTRIBUTIONDIR/packages
# #
# Directory where source files will be extracted to. # Directory where source files will be extracted to.
# #
XBPS_BUILDDIR=$XBPS_DISTRIBUTIONDIR/builddir XBPS_BUILDDIR=$XBPS_DISTRIBUTIONDIR/srcdistdir
# #
# Directory where source distribution files are stored. # Directory where source distribution files are stored.
# #
XBPS_SRCDISTDIR=$XBPS_DISTRIBUTIONDIR/srcdistdir XBPS_SRCDISTDIR=$XBPS_DISTRIBUTIONDIR/srcdistdir
#
# Directory where configuration files installed by packages will
# be installed. Please note that files on this directory won't be
# removed if a package is unstowned.
#
# BEWARE: the package itself may overwrite them in some cases!
#
XBPS_SYSCONFDIR=$XBPS_MASTERDIR/etc
#
# Path to the xstow program.
#
XBPS_XSTOW_CMD=$XBPS_MASTERDIR/usr/bin/xstow
# #
# Compilation flags for cc and c++. # Compilation flags for cc and c++.
# #

448
xbps.sh
View file

@ -1,4 +1,4 @@
#!/bin/sh #!/bin/bash
# #
# xbps - A simple, minimal, fast and uncomplete build package system. # xbps - A simple, minimal, fast and uncomplete build package system.
# #
@ -29,8 +29,6 @@
# #
# TODO # TODO
# - Implement support for packages that need personalized installation. # - Implement support for packages that need personalized installation.
# - Implement a chroot target that builds packages as root on it, for
# packages that need it (setuid, setgid).
# - Personalized scripts per template to unpack distfiles. # - Personalized scripts per template to unpack distfiles.
# - Multiple URLs to download source distribution files, aliases, etc. # - Multiple URLs to download source distribution files, aliases, etc.
# - More robust and fast dependency checking. # - More robust and fast dependency checking.
@ -38,35 +36,43 @@
# Default path to configuration file, can be overriden # Default path to configuration file, can be overriden
# via the environment or command line. # via the environment or command line.
# #
: ${XBPS_CONFIG_FILE:=/usr/local/etc/xbps.conf} : ${XBPS_CONFIG_FILE:=/etc/xbps.conf}
: ${progname:=$(basename $0)} : ${progname:=$(basename $0)}
: ${topdir:=$(/bin/pwd 2>/dev/null)} : ${fetch_cmd:=wget}
: ${fetch_cmd:=/usr/bin/wget}
: ${awk_cmd:=/usr/bin/awk}
: ${mkdir_cmd:=/bin/mkdir}
: ${tar_cmd:=/bin/tar}
: ${rm_cmd:=/bin/rm}
: ${mv_cmd:=/bin/mv}
: ${cp_cmd:=/bin/cp}
: ${sed_cmd=/bin/sed}
: ${grep_cmd=/bin/grep}
: ${gunzip_cmd:=/bin/gunzip}
: ${bunzip2_cmd:=/bin/bunzip2}
: ${patch_cmd:=/usr/bin/patch}
: ${find_cmd:=/usr/bin/find}
: ${file_cmd:=/usr/bin/file}
: ${ln_cmd:=/bin/ln}
: ${chmod_cmd:=/bin/chmod}
: ${chmod_cmd:=/bin/chmod}
: ${touch_cmd:=/usr/bin/touch}
: ${env_cmd:=/usr/bin/env}
: ${xstow_args:=-ap} usage()
: ${xstow_ignore_files:=perllocal.pod} # XXX For now ignore them. {
cat << _EOF
$progname: [-C] [-c <config_file>] <target> [package_name]
Targets:
build Builds a package, only build phase is done.
configure Configure a package, only configure phase is done.
extract Extract distribution file(s) into build directory.
fetch Download distribution file(s).
info Show information about <package_name>.
install-chroot Installs a package inside a chroot.
install-destdir build + configure + install into destdir.
install install-destdir + stow.
list Lists all currently installed packages.
listfiles Lists files installed from <package_name>.
remove Remove package completely (destdir + masterdir).
stow Copy files from destdir/<pkgname> into masterdir.
unstow Remove <pkgname> files from masterdir.
Options:
-C Do not remove build directory after successful installation.
-c Path to global configuration file:
if not specified /usr/local/etc/xbps.conf is used.
_EOF
exit 1
}
set_defvars() set_defvars()
{ {
local i=
# Directories # Directories
: ${XBPS_TEMPLATESDIR:=$XBPS_DISTRIBUTIONDIR/templates} : ${XBPS_TEMPLATESDIR:=$XBPS_DISTRIBUTIONDIR/templates}
: ${XBPS_TMPLHELPDIR:=$XBPS_DISTRIBUTIONDIR/helper-templates} : ${XBPS_TMPLHELPDIR:=$XBPS_DISTRIBUTIONDIR/helper-templates}
@ -84,46 +90,7 @@ set_defvars()
fi fi
done done
local CMDS="fetch_cmd awk_cmd mkdir_cmd tar_cmd rm_cmd mv_cmd \ XBPS_PKGDB_CMD="env XBPS_PKGDB_FPATH=$XBPS_PKGDB_FPATH $XBPS_PKGDB_CMD"
cp_cmd sed_cmd grep_cmd gunzip_cmd bunzip2_cmd patch_cmd find_cmd \
file_cmd ln_cmd chmod_cmd chmod_cmd touch_cmd XBPS_DIGEST_CMD \
XBPS_PKGDB_CMD"
for f in ${CMDS}; do
eval val="\$$f"
if [ ! -x "$val" ]; then
echo "*** ERROR: cannot find $f command, aborting ***"
exit 1
fi
done
XBPS_PKGDB_CMD="$env_cmd XBPS_PKGDB_FPATH=$XBPS_PKGDB_FPATH $XBPS_PKGDB_CMD"
}
usage()
{
cat << _EOF
$progname: [-C] [-c <config_file>] <target> [package_name]
Targets:
build Builds a package, only build phase is done.
configure Configure a package, only configure phase is done.
extract Extract distribution file(s) into build directory.
fetch Download distribution file(s).
info Show information about <package_name>.
install-destdir build + configure + install into destdir.
install Same than 'install-destdir' but also stows package.
list Lists all currently 'stowned' packages.
remove Remove package completely (unstow + remove data)
listfiles Lists files installed from <package_name>.
stow Create links in master directory.
unstow Remove links in master directory.
Options:
-C Do not remove build directory after successful installation.
-c Path to global configuration file:
if not specified /usr/local/etc/xbps.conf is used.
_EOF
exit 1
} }
check_path() check_path()
@ -137,7 +104,7 @@ check_path()
orig="${orig%/}" orig="${orig%/}"
;; ;;
*) *)
orig="$topdir/${orig%/}" orig="$(pwd)/${orig%/}"
;; ;;
esac esac
@ -152,40 +119,17 @@ run_file()
. $path_fixed . $path_fixed
} }
#
# This function merges two GNU info dirs into one and puts the result
# into XBPS_MASTERDIR/share/info/dir.
#
merge_infodir_tmpl()
{
local pkgname="$1"
local merge_info_cmd="$XBPS_MASTERDIR/bin/merge-info"
[ -z "$pkgname" -o ! -r "$XBPS_MASTERDIR/share/info/dir" \
-o ! -r "$XBPS_DESTDIR/$pkgname/share/info/dir" ] && return 1
$merge_info_cmd -d $XBPS_MASTERDIR/share/info/dir \
$XBPS_DESTDIR/$pkgname/share/info/dir -o \
$XBPS_MASTERDIR/share/info/dir.new
if [ $? -ne 0 ]; then
echo -n "*** WARNING: there was an error merging info dir from"
echo " $pkgname, aborting ***"
return 1
fi
$mv_cmd -f $XBPS_MASTERDIR/share/info/dir.new \
$XBPS_MASTERDIR/share/info/dir
}
# #
# Shows info about a template. # Shows info about a template.
# #
info_tmpl() info_tmpl()
{ {
local i=
echo "pkgname: $pkgname" echo "pkgname: $pkgname"
echo "version: $version" echo "version: $version"
for i in "${distfiles}"; do for i in "${distfiles}"; do
[ -n "$i" ] && i=$(echo $i|$sed_cmd s'|@||g') && \ [ -n "$i" ] && i=$(echo $i|sed s'|@||g') && \
echo "distfile: $i" echo "distfile: $i"
done done
[ -n $checksum ] && echo "checksum: $checksum" [ -n $checksum ] && echo "checksum: $checksum"
@ -210,6 +154,7 @@ info_tmpl()
check_config_vars() check_config_vars()
{ {
local cffound= local cffound=
local f=
if [ -z "$config_file_specified" ]; then if [ -z "$config_file_specified" ]; then
config_file_paths="$XBPS_CONFIG_FILE ./xbps.conf" config_file_paths="$XBPS_CONFIG_FILE ./xbps.conf"
@ -234,7 +179,7 @@ check_config_vars()
fi fi
local XBPS_VARS="XBPS_MASTERDIR XBPS_DESTDIR XBPS_BUILDDIR \ local XBPS_VARS="XBPS_MASTERDIR XBPS_DESTDIR XBPS_BUILDDIR \
XBPS_SRCDISTDIR XBPS_SYSCONFDIR" XBPS_SRCDISTDIR"
for f in ${XBPS_VARS}; do for f in ${XBPS_VARS}; do
eval val="\$$f" eval val="\$$f"
@ -245,7 +190,7 @@ check_config_vars()
fi fi
if [ ! -d "$val" ]; then if [ ! -d "$val" ]; then
$mkdir_cmd "$val" mkdir "$val"
if [ "$?" -ne 0 ]; then if [ "$?" -ne 0 ]; then
echo -n "*** ERROR: couldn't create '$f'" echo -n "*** ERROR: couldn't create '$f'"
echo "directory, aborting ***" echo "directory, aborting ***"
@ -260,6 +205,7 @@ check_config_vars()
# #
reset_tmpl_vars() reset_tmpl_vars()
{ {
local v=
local TMPL_VARS="pkgname distfiles configure_args configure_env \ local TMPL_VARS="pkgname distfiles configure_args configure_env \
make_build_args make_install_args build_style \ make_build_args make_install_args build_style \
short_desc maintainer long_desc checksum wrksrc \ short_desc maintainer long_desc checksum wrksrc \
@ -273,8 +219,8 @@ reset_tmpl_vars()
XBPS_EXTRACT_DONE XBPS_CONFIGURE_DONE \ XBPS_EXTRACT_DONE XBPS_CONFIGURE_DONE \
XBPS_BUILD_DONE XBPS_INSTALL_DONE" XBPS_BUILD_DONE XBPS_INSTALL_DONE"
for i in ${TMPL_VARS}; do for v in ${TMPL_VARS}; do
eval unset "$i" eval unset "$v"
done done
unset_build_vars unset_build_vars
@ -303,6 +249,8 @@ setup_tmpl()
# #
prepare_tmpl() prepare_tmpl()
{ {
local i=
# #
# There's nothing of interest if we are a meta template. # There's nothing of interest if we are a meta template.
# #
@ -333,8 +281,8 @@ prepare_tmpl()
XBPS_INSTALL_DONE="$wrksrc/.xbps_install_done" XBPS_INSTALL_DONE="$wrksrc/.xbps_install_done"
export PATH="$XBPS_MASTERDIR/bin:$XBPS_MASTERDIR/sbin" export PATH="$XBPS_MASTERDIR/bin:$XBPS_MASTERDIR/sbin"
export PATH="$PATH:$XBPS_MASTERDIR/usr/bin:$XBPS_MASTERDIR/usr/sbin"
export PATH="$PATH:/bin:/sbin:/usr/bin:/usr/sbin" export PATH="$PATH:/bin:/sbin:/usr/bin:/usr/sbin"
export PATH="$PATH:$XBPS_MASTERDIR/usr/bin:$XBPS_MASTERDIR/usr/sbin"
} }
# #
@ -349,6 +297,7 @@ extract_distfiles()
local cursufx= local cursufx=
local lwrksrc= local lwrksrc=
local ltar_cmd= local ltar_cmd=
local f=
# #
# If we are being called via the target, just extract and return. # If we are being called via the target, just extract and return.
@ -370,7 +319,7 @@ extract_distfiles()
echo "multiple distfiles ***" echo "multiple distfiles ***"
exit 1 exit 1
fi fi
$mkdir_cmd $wrksrc mkdir $wrksrc
fi fi
echo "==> Extracting '$pkgname-$version' distfiles." echo "==> Extracting '$pkgname-$version' distfiles."
@ -378,13 +327,13 @@ extract_distfiles()
if [ -n "$tar_override_cmd" ]; then if [ -n "$tar_override_cmd" ]; then
ltar_cmd="$tar_override_cmd" ltar_cmd="$tar_override_cmd"
else else
ltar_cmd="$tar_cmd" ltar_cmd="tar"
fi fi
for f in ${distfiles}; do for f in ${distfiles}; do
curfile=$(basename $f) curfile=$(basename $f)
cursufx=${curfile##*@} cursufx=${curfile##*@}
curfile=$(basename $curfile|$sed_cmd 's|@||g') curfile=$(basename $curfile|sed 's|@||g')
if [ $count -gt 1 ]; then if [ $count -gt 1 ]; then
lwrksrc="$wrksrc/${curfile%$cursufx}" lwrksrc="$wrksrc/${curfile%$cursufx}"
@ -449,7 +398,7 @@ extract_distfiles()
esac esac
done done
$touch_cmd -f $XBPS_EXTRACT_DONE touch -f $XBPS_EXTRACT_DONE
} }
# #
@ -482,6 +431,7 @@ fetch_distfiles()
local localurl= local localurl=
local dfcount=0 local dfcount=0
local ckcount=0 local ckcount=0
local f=
[ -z $pkgname ] && exit 1 [ -z $pkgname ] && exit 1
@ -490,7 +440,7 @@ fetch_distfiles()
# #
[ "$build_style" = "meta-template" ] && return 0 [ "$build_style" = "meta-template" ] && return 0
dfiles=$(echo $distfiles | $sed_cmd 's|@||g') dfiles=$(echo $distfiles | sed 's|@||g')
for f in ${dfiles}; do for f in ${dfiles}; do
curfile=$(basename $f) curfile=$(basename $f)
@ -574,25 +524,33 @@ fetch_distfiles()
unset cksum found unset cksum found
} }
fixup_tmpl_libtool() fixup_libtool_file()
{ {
[ "$pkgname" = "libtool" -o ! -f $wrksrc/libtool ] && return 0
sed -i -e \
's|^hardcode_libdir_flag_spec=.*|hardcode_libdir_flag_spec="-Wl,-rpath /usr/lib"|g' \
$wrksrc/libtool
}
fixup_la_files()
{
local f=
# Ignore libtool itself # Ignore libtool itself
[ "$pkgname" = "libtool" ] && return 0 [ "$pkgname" = "libtool" ] && return 0
# #
# If package has a libtool file replace it with ours, so that # Replace hardcoded or incorrect paths with correct ones.
# we use the master directory while relinking, all will be fine
# once the package is stowned.
# #
if [ -f $wrksrc/ltmain.sh -a -f $wrksrc/libtool ]; then for f in $(find $wrksrc -type f -name \*.la*); do
$rm_cmd -f $wrksrc/libtool
$ln_cmd -s $XBPS_MASTERDIR/usr/bin/libtool $wrksrc/libtool
fi
for f in $($find_cmd $wrksrc -type f -name libtool); do
if [ -f $f ]; then if [ -f $f ]; then
$rm_cmd -f $f echo "Replacing libtool archive: $f"
$ln_cmd -s $XBPS_MASTERDIR/usr/bin/libtool $f sed -i -e "s|\/..\/lib||g" \
-e "s|$XBPS_MASTERDIR||g;" \
-e "s|$XBPS_DESTDIR/$pkgname-$version||g" $f
awk '{ if (/^ dependency_libs/) {gsub("/usr[^]*lib","lib");}print}' \
$f > $f.in && mv $f.in $f
fi fi
done done
} }
@ -601,20 +559,21 @@ set_build_vars()
{ {
SAVE_LDLIBPATH=$LD_LIBRARY_PATH SAVE_LDLIBPATH=$LD_LIBRARY_PATH
LD_LIBRARY_PATH="$XBPS_MASTERDIR/usr/lib" LD_LIBRARY_PATH="$XBPS_MASTERDIR/usr/lib"
LDFLAGS="-L$XBPS_MASTERDIR/usr/lib"
CFLAGS="$CFLAGS $XBPS_CFLAGS" CFLAGS="$CFLAGS $XBPS_CFLAGS"
CXXFLAGS="$CXXFLAGS $XBPS_CXXFLAGS" CXXFLAGS="$CXXFLAGS $XBPS_CXXFLAGS"
CPPFLAGS="-I$XBPS_MASTERDIR/usr/include $CPPFLAGS" CPPFLAGS="-I$XBPS_MASTERDIR/usr/include $CPPFLAGS"
PKG_CONFIG="$XBPS_MASTERDIR/usr/bin/pkg-config" PKG_CONFIG="$XBPS_MASTERDIR/usr/bin/pkg-config"
PKG_CONFIG_LIBDIR="$XBPS_MASTERDIR/usr/lib/pkgconfig"
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH" export LD_LIBRARY_PATH="$LD_LIBRARY_PATH"
export LDFLAGS="$LDFLAGS" CFLAGS="$CFLAGS" CXXFLAGS="$CXXFLAGS" export CFLAGS="$CFLAGS" CXXFLAGS="$CXXFLAGS"
export CPPFLAGS="$CPPFLAGS" PKG_CONFIG="$PKG_CONFIG" export CPPFLAGS="$CPPFLAGS" PKG_CONFIG="$PKG_CONFIG"
export PKG_CONFIG_LIBDIR="$PKG_CONFIG_LIBDIR"
} }
unset_build_vars() unset_build_vars()
{ {
unset LDFLAGS CFLAGS CXXFLAGS CPPFLAGS PKG_CONFIG LD_LIBRARY_PATH unset CFLAGS CXXFLAGS CPPFLAGS PKG_CONFIG LD_LIBRARY_PATH
export LD_LIBRARY_PATH=$SAVE_LDLIBPATH export LD_LIBRARY_PATH=$SAVE_LDLIBPATH
} }
@ -624,6 +583,7 @@ unset_build_vars()
apply_tmpl_patches() apply_tmpl_patches()
{ {
local patch= local patch=
local i=
# #
# If package needs some patches applied before building, # If package needs some patches applied before building,
@ -637,23 +597,23 @@ apply_tmpl_patches()
continue continue
fi fi
$cp_cmd -f $patch $wrksrc cp -f $patch $wrksrc
# Try to guess if its a compressed patch. # Try to guess if its a compressed patch.
if $(echo $patch|$grep_cmd -q .gz); then if $(echo $patch|grep -q .gz); then
$gunzip_cmd $wrksrc/$i gunzip $wrksrc/$i
patch=${i%%.gz} patch=${i%%.gz}
elif $(echo $patch|$grep_cmd -q .bz2); then elif $(echo $patch|grep -q .bz2); then
$bunzip2_cmd $wrksrc/$i bunzip2 $wrksrc/$i
patch=${i%%.bz2} patch=${i%%.bz2}
elif $(echo $patch|$grep_cmd -q .diff); then elif $(echo $patch|grep -q .diff); then
patch=$i patch=$i
else else
echo "*** WARNING: unknown patch type: $i ***" echo "*** WARNING: unknown patch type: $i ***"
continue continue
fi fi
cd $wrksrc && $patch_cmd -p0 < $patch 2>/dev/null cd $wrksrc && patch -p0 < $patch 2>/dev/null
if [ "$?" -eq 0 ]; then if [ "$?" -eq 0 ]; then
echo "=> Patch applied: $i." echo "=> Patch applied: $i."
else else
@ -663,7 +623,7 @@ apply_tmpl_patches()
done done
fi fi
$touch_cmd -f $XBPS_APPLYPATCHES_DONE touch -f $XBPS_APPLYPATCHES_DONE
} }
# #
@ -673,13 +633,16 @@ apply_tmpl_patches()
configure_src_phase() configure_src_phase()
{ {
local pkg="$1" local pkg="$1"
local f=
[ -z $pkg ] && [ -z $pkgname ] && return 1 [ -z $pkg ] && [ -z $pkgname ] && return 1
# #
# There's nothing we can do if we are a meta template. # There's nothing we can do if we are a meta template or an
# only-install template.
# #
[ "$build_style" = "meta-template" ] && return 0 [ "$build_style" = "meta-template" -o \
"$build_style" = "only-install" ] && return 0
if [ ! -d $wrksrc ]; then if [ ! -d $wrksrc ]; then
echo "*** ERROR: unexistent build directory $wrksrc ***" echo "*** ERROR: unexistent build directory $wrksrc ***"
@ -720,10 +683,9 @@ configure_src_phase()
if [ "$build_style" = "gnu_configure" ]; then if [ "$build_style" = "gnu_configure" ]; then
cd $wrksrc || exit 1 cd $wrksrc || exit 1
${configure_script} \ ${configure_script} \
--prefix=${_prefix} \ --prefix=${_prefix} --sysconfdir=/etc \
--infodir=$XBPS_DESTDIR/$pkgname-$version/share/info \ --infodir=$XBPS_DESTDIR/$pkgname-$version/usr/share/info \
--mandir=$XBPS_DESTDIR/$pkgname-$version/share/man \ --mandir=$XBPS_DESTDIR/$pkgname-$version/usr/share/man \
--sysconfdir="$XBPS_SYSCONFDIR" \
${configure_args} ${configure_args}
# #
@ -766,12 +728,9 @@ configure_src_phase()
unset eval ${f%=*} unset eval ${f%=*}
done done
# Override libtool scripts if necessary
fixup_tmpl_libtool
unset_build_vars unset_build_vars
$touch_cmd -f $XBPS_CONFIGURE_DONE touch -f $XBPS_CONFIGURE_DONE
} }
# #
@ -782,13 +741,16 @@ build_src_phase()
{ {
local pkgparam="$1" local pkgparam="$1"
local pkg="$pkgname-$version" local pkg="$pkgname-$version"
local f=
[ -z $pkgparam ] && [ -z $pkgname -o -z $version ] && return 1 [ -z $pkgparam ] && [ -z $pkgname -o -z $version ] && return 1
# #
# There's nothing of interest if we are a meta template. # There's nothing of interest if we are a meta template or an
# only-install template.
# #
[ "$build_style" = "meta-template" ] && return 0 [ "$build_style" = "meta-template" -o \
"$build_style" = "only-install" ] && return 0
if [ ! -d $wrksrc ]; then if [ ! -d $wrksrc ]; then
echo "*** ERROR: unexistent build directory: $wrksrc ***" echo "*** ERROR: unexistent build directory: $wrksrc ***"
@ -822,6 +784,7 @@ build_src_phase()
export "$f" export "$f"
done done
fixup_libtool_file
set_build_vars set_build_vars
# #
# Build package via make. # Build package via make.
@ -843,9 +806,10 @@ build_src_phase()
${run_stuff_before_install_cmd} ${run_stuff_before_install_cmd}
unset rbif unset rbif
fixup_la_files
unset_build_vars unset_build_vars
$touch_cmd -f $XBPS_BUILD_DONE touch -f $XBPS_BUILD_DONE
} }
# #
@ -855,11 +819,13 @@ build_src_phase()
install_src_phase() install_src_phase()
{ {
local pkg="$1" local pkg="$1"
local f=
local i=
[ -z $pkg ] && [ -z $pkgname ] && return 1 [ -z $pkg ] && [ -z $pkgname ] && return 1
if [ -z "$make_install_target" ]; then if [ -z "$make_install_target" ]; then
make_install_target="install prefix=$XBPS_DESTDIR/$pkgname-$version" make_install_target="install prefix=$XBPS_DESTDIR/$pkgname-$version/usr"
make_install_target="$make_install_target sysconfdir=$XBPS_DESTDIR/$pkgname-$version/etc" make_install_target="$make_install_target sysconfdir=$XBPS_DESTDIR/$pkgname-$version/etc"
fi fi
@ -918,13 +884,13 @@ install_src_phase()
echo "==> Installed $pkgname-$version into $XBPS_DESTDIR." echo "==> Installed $pkgname-$version into $XBPS_DESTDIR."
$touch_cmd -f $XBPS_INSTALL_DONE touch -f $XBPS_INSTALL_DONE
# #
# Remove $wrksrc if -C not specified. # Remove $wrksrc if -C not specified.
# #
if [ -d "$wrksrc" -a -z "$dontrm_builddir" ]; then if [ -d "$wrksrc" -a -z "$dontrm_builddir" ]; then
$rm_cmd -rf $wrksrc rm -rf $wrksrc
[ "$?" -eq 0 ] && \ [ "$?" -eq 0 ] && \
echo "=> Removed $pkgname-$version build directory." echo "=> Removed $pkgname-$version build directory."
fi fi
@ -961,36 +927,40 @@ register_pkg_handler()
add_dependency_tolist() add_dependency_tolist()
{ {
local curpkg="$1" local curpkg="$1"
local j=
[ -z "$curpkg" ] && return 1 [ -z "$curpkg" ] && return 1
[ -n "$prev_pkg" ] && curpkg=$prev_pkg [ -n "$prev_pkg" ] && curpkg=$prev_pkg
reset_tmpl_vars if [ "$pkgname" != "${curpkg%-[0-9]*.*}" ]; then
run_file $XBPS_TEMPLATESDIR/${curpkg%-[0-9]*.*}.tmpl reset_tmpl_vars
for i in ${build_depends}; do run_file $XBPS_TEMPLATESDIR/${curpkg%-[0-9]*.*}.tmpl
fi
for j in ${build_depends}; do
# #
# Check if dep already installed. # Check if dep already installed.
# #
check_installed_pkg $i ${i##[aA-zZ]*-} check_installed_pkg $j ${j##[aA-zZ]*-}
# #
# If dep is already installed, check one more time # If dep is already installed, check one more time
# if all its deps are there and continue. # if all its deps are there and continue.
# #
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
install_builddeps_required_pkg $i install_builddeps_required_pkg $j
installed_deps_list="$i $installed_deps_list" installed_deps_list="$j $installed_deps_list"
continue continue
fi fi
deps_list="$i $deps_list" deps_list="$j $deps_list"
[ -n "$prev_pkg" ] && unset prev_pkg [ -n "$prev_pkg" ] && unset prev_pkg
# #
# Check if dependency needs more deps. # Check if dependency needs more deps.
# #
check_build_depends_pkg ${i%-[0-9]*.*} check_build_depends_pkg ${j%-[0-9]*.*}
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
add_dependency_tolist $i add_dependency_tolist $j
prev_pkg="$i" prev_pkg="$j"
fi fi
done done
} }
@ -1003,6 +973,7 @@ find_dupdeps_inlist()
local action="$1" local action="$1"
local tmp_list= local tmp_list=
local dup= local dup=
local f=
[ -z "$action" ] && return 1 [ -z "$action" ] && return 1
@ -1050,6 +1021,7 @@ find_dupdeps_inlist()
install_dependencies_pkg() install_dependencies_pkg()
{ {
local pkg="$1" local pkg="$1"
local i=
deps_list= deps_list=
installed_deps_list= installed_deps_list=
@ -1067,7 +1039,7 @@ install_dependencies_pkg()
echo "==> Required dependencies for $(basename $pkg):" echo "==> Required dependencies for $(basename $pkg):"
for i in ${installed_deps_list}; do for i in ${installed_deps_list}; do
fpkg="$($XBPS_PKGDB_CMD list|$grep_cmd ${i%-[0-9]*.*})" fpkg="$($XBPS_PKGDB_CMD list|grep ${i%-[0-9]*.*})"
echo " $i: found $fpkg." echo " $i: found $fpkg."
done done
@ -1091,6 +1063,7 @@ install_dependencies_pkg()
install_builddeps_required_pkg() install_builddeps_required_pkg()
{ {
local pkg="$1" local pkg="$1"
local dep=
[ -z "$pkg" ] && return 1 [ -z "$pkg" ] && return 1
@ -1120,10 +1093,11 @@ check_installed_pkg()
[ -z "$pkg" -o -z "$reqver" -o ! -r $XBPS_PKGDB_FPATH ] && return 1 [ -z "$pkg" -o -z "$reqver" -o ! -r $XBPS_PKGDB_FPATH ] && return 1
if [ "$pkgname" != "${pkg%-[0-9]*.*}" ]; then if [ "$pkgname" != "${pkg%-[0-9]*.*}" ]; then
reset_tmpl_vars
run_file $XBPS_TEMPLATESDIR/${pkg%-[0-9]*.*}.tmpl run_file $XBPS_TEMPLATESDIR/${pkg%-[0-9]*.*}.tmpl
fi fi
reqver="$(echo $reqver | $sed_cmd 's|[[:punct:]]||g;s|[[:alpha:]]||g')" reqver="$(echo $reqver | sed 's|[[:punct:]]||g;s|[[:alpha:]]||g')"
$XBPS_PKGDB_CMD installed $pkgname $XBPS_PKGDB_CMD installed $pkgname
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
@ -1138,7 +1112,7 @@ check_installed_pkg()
# It's not optimal and may fail, but it is enough # It's not optimal and may fail, but it is enough
# for now. # for now.
# #
iver="$(echo $iver | $sed_cmd 's|[[:punct:]]||g;s|[[:alpha:]]||g')" iver="$(echo $iver | sed 's|[[:punct:]]||g;s|[[:alpha:]]||g')"
if [ "$iver" -eq "$reqver" \ if [ "$iver" -eq "$reqver" \
-o "$iver" -gt "$reqver" ]; then -o "$iver" -gt "$reqver" ]; then
return 0 return 0
@ -1195,11 +1169,6 @@ install_pkg()
# #
[ -z "$origin_tmpl" ] && origin_tmpl=$pkgname [ -z "$origin_tmpl" ] && origin_tmpl=$pkgname
#
# Install xstow if it's not there.
#
install_xstow_pkg
# #
# We are going to install a new package. # We are going to install a new package.
# #
@ -1243,8 +1212,10 @@ install_pkg()
# #
if [ "$build_style" = "meta-template" ]; then if [ "$build_style" = "meta-template" ]; then
register_pkg_handler register $pkgname $version register_pkg_handler register $pkgname $version
echo "==> Installed meta-template: $pkg." [ $? -eq 0 ] && \
return 0 echo "==> Installed meta-template: $pkg." && \
return 0
return 1
fi fi
# #
@ -1253,47 +1224,13 @@ install_pkg()
[ -z "$install_destdir_target" ] && stow_pkg $pkg [ -z "$install_destdir_target" ] && stow_pkg $pkg
} }
#
# Installs and stows the "xstow" package.
#
install_xstow_pkg()
{
[ -x "$XBPS_XSTOW_CMD" ] && return 0
echo "=> xstow application not found, will install it now."
reset_tmpl_vars
setup_tmpl xstow
fetch_distfiles
if [ ! -f "$XBPS_EXTRACT_DONE" ]; then
extract_distfiles
fi
if [ ! -f "$XBPS_CONFIGURE_DONE" ]; then
configure_src_phase
fi
if [ ! -f "$XBPS_BUILD_DONE" ]; then
build_src_phase
fi
install_src_phase
XBPS_XSTOW_CMD="$XBPS_DESTDIR/$pkgname-$version/bin/xstow"
stow_pkg $pkgname-$version
#
# Continue with package that called us.
#
run_file $XBPS_TEMPLATESDIR/$origin_tmpl.tmpl
}
# #
# Lists all currently installed packages. # Lists all currently installed packages.
# #
list_pkgs() list_pkgs()
{ {
local i=
if [ ! -r "$XBPS_PKGDB_FPATH" ]; then if [ ! -r "$XBPS_PKGDB_FPATH" ]; then
echo "=> No packages registered or missing register db file." echo "=> No packages registered or missing register db file."
exit 0 exit 0
@ -1313,6 +1250,7 @@ list_pkgs()
list_pkg_files() list_pkg_files()
{ {
local pkg="$1" local pkg="$1"
local f=
if [ -z $pkg ]; then if [ -z $pkg ]; then
echo "*** ERROR: unexistent package, aborting ***" echo "*** ERROR: unexistent package, aborting ***"
@ -1324,7 +1262,7 @@ list_pkg_files()
exit 1 exit 1
fi fi
for f in $($find_cmd $XBPS_DESTDIR/$pkg -type f -print | sort -u); do for f in $(find $XBPS_DESTDIR/$pkg -type f -print | sort -u); do
echo "${f##$XBPS_DESTDIR/$pkg/}" echo "${f##$XBPS_DESTDIR/$pkg/}"
done done
} }
@ -1364,21 +1302,17 @@ remove_pkg()
fi fi
unstow_pkg $pkg unstow_pkg $pkg
$rm_cmd -rf $XBPS_DESTDIR/$pkg-$version rm -rf $XBPS_DESTDIR/$pkg-$version
return $? return $?
} }
# #
# Stows a currently installed package, i.e creates the links # Stows a package, i.e copy files from destdir into masterdir.
# on the master directory.
# #
stow_pkg() stow_pkg()
{ {
local pkg="$1" local pkg="$1"
local infodir_pkg="share/info/dir" local i=
local infodir_master="$XBPS_MASTERDIR/share/info/dir"
local real_xstowargs="$xstow_args"
local real_xstow_ignore="$xstow_ignore_files"
[ -z "$pkg" ] && return 2 [ -z "$pkg" ] && return 2
@ -1394,34 +1328,13 @@ stow_pkg()
[ "$build_style" = "meta-template" ] && return 0 [ "$build_style" = "meta-template" ] && return 0
fi fi
if [ -r "$XBPS_DESTDIR/$pkg/$infodir_pkg" ]; then cd $XBPS_DESTDIR/$pkgname-$version || exit 1
merge_infodir_tmpl $pkg find . > $XBPS_MASTERDIR/.xbps-filelist-$pkgname-$version
fi sed -i -e "s|^.$||g;s|^./||g" \
$XBPS_MASTERDIR/.xbps-filelist-$pkgname-$version
if [ -r "$XBPS_DESTDIR/$pkg/$infodir_pkg" \ cp -far . $XBPS_MASTERDIR
-a -r "$infodir_master" ]; then mv -f $XBPS_MASTERDIR/.xbps-filelist-$pkgname-$version \
xstow_args="$xstow_args -i-file-in-dir $infodir_pkg" $XBPS_DESTDIR/$pkgname-$version/.xbps-filelist
fi
if [ -n "$ignore_files" ]; then
xstow_ignore_files="$xstow_ignore_files $ignore_files"
fi
if [ -z "$base_package" ]; then
local pkg_masterdir=$XBPS_MASTERDIR/usr
[ ! -d $pkg_masterdir ] && $mkdir_cmd -p $pkg_masterdir
else
local pkg_masterdir=$XBPS_MASTERDIR
fi
$XBPS_XSTOW_CMD -ignore "${xstow_ignore_files}" ${xstow_args} \
-dir $XBPS_DESTDIR -target $pkg_masterdir $XBPS_DESTDIR/$pkg
if [ "$?" -ne 0 ]; then
echo "*** ERROR: couldn't create symlinks for $pkg ***"
exit 1
else
echo "==> Created $pkg symlinks into master directory."
fi
register_pkg_handler register $pkgname $version register_pkg_handler register $pkgname $version
@ -1436,30 +1349,22 @@ stow_pkg()
local pihf="$XBPS_TMPLHELPDIR/$i" local pihf="$XBPS_TMPLHELPDIR/$i"
[ -f "$pihf" ] && . $pihf [ -f "$pihf" ] && . $pihf
done done
xstow_ignore_files="$real_xstow_ignore"
xstow_args="$real_xstowargs"
} }
# #
# Unstows a currently stowned package, i.e removes its links # Unstow a package, i.e removes its files from masterdir.
# from the master directory.
# #
unstow_pkg() unstow_pkg()
{ {
local pkg="$1" local pkg="$1"
local real_xstow_ignore="$xstow_ignore_files" local real_xstow_ignore="$xstow_ignore_files"
local f=
if [ -z "$pkg" ]; then if [ -z "$pkg" ]; then
echo "*** ERROR: template wasn't specified? ***" echo "*** ERROR: template wasn't specified? ***"
exit 1 exit 1
fi fi
if [ "$pkg" = "xstow" ]; then
echo "*** INFO: You aren't allowed to unstow $pkg."
exit 1
fi
if [ "$pkgname" != "$pkg" ]; then if [ "$pkgname" != "$pkg" ]; then
run_file $XBPS_TEMPLATESDIR/$pkg.tmpl run_file $XBPS_TEMPLATESDIR/$pkg.tmpl
fi fi
@ -1469,47 +1374,35 @@ unstow_pkg()
# #
[ "$build_style" = "meta-template" ] && return 0 [ "$build_style" = "meta-template" ] && return 0
if [ -n "$ignore_files" ]; then cd $XBPS_DESTDIR/$pkgname-$version || exit 1
xstow_ignore_files="$xstow_ignore_files $ignore_files" [ ! -f .xbps-filelist ] && exit 1
fi
if [ -z "$base_package" ]; then for f in $(cat .xbps-filelist|sort -ur); do
local pkg_masterdir=$XBPS_MASTERDIR/usr [ -f $XBPS_MASTERDIR/$f -o -h $XBPS_MASTERDIR/$f ] && \
[ ! -d $pkg_masterdir ] && $mkdir_cmd -p $pkg_masterdir rm $XBPS_MASTERDIR/$f && \
else echo "Removing file: $f"
local pkg_masterdir=$XBPS_MASTERDIR done
fi
$XBPS_XSTOW_CMD -dir $XBPS_DESTDIR -target $pkg_masterdir \ for f in $(cat .xbps-filelist|sort -ur); do
-D -i-file-in-dir share/info/dir -ignore \ [ -d $XBPS_MASTERDIR/$f ] && \
"${xstow_ignore_files}" $XBPS_DESTDIR/$pkgname-$version rmdir $XBPS_MASTERDIR/$f && \
if [ $? -ne 0 ]; then echo "Removing directory: $f"
exit 1 done
else
$rm_cmd -f $XBPS_DESTDIR/$pkgname-$version/share/info/dir
echo "==> Removed \`$pkg' symlinks from master directory."
fi
register_pkg_handler unregister $pkgname $version register_pkg_handler unregister $pkgname $version
xstow_ignore_files="$real_xstow_ignore"
} }
# #
# main() # main()
# #
args=$(getopt Cc: $*) while getopts "Cc:" opt; do
[ "$?" -ne 0 ] && usage case $opt in
C)
set -- $args
while [ "$#" -gt 0 ]; do
case "$1" in
-C)
dontrm_builddir=yes dontrm_builddir=yes
;; ;;
-c) c)
config_file_specified=yes config_file_specified=yes
XBPS_CONFIG_FILE="$2" XBPS_CONFIG_FILE="$OPTARG"
shift shift
;; ;;
--) --)
@ -1517,10 +1410,10 @@ while [ "$#" -gt 0 ]; do
break break
;; ;;
esac esac
shift
done done
shift $(($OPTIND - 1))
[ "$#" -gt 2 ] && usage [ $# -eq 0 -o $# -gt 4 ] && usage
target="$1" target="$1"
if [ -z "$target" ]; then if [ -z "$target" ]; then
@ -1569,6 +1462,11 @@ info)
setup_tmpl $2 setup_tmpl $2
info_tmpl $2 info_tmpl $2
;; ;;
install-chroot)
setup_tmpl $2
run_file $XBPS_TMPLHELPDIR/install-chroot.sh
install_chroot_pkg $2
;;
install-destdir) install-destdir)
install_destdir_target=yes install_destdir_target=yes
install_pkg $2 install_pkg $2