Add shell utils required by xbps-src.

These files are moved from the GIT repository.

--HG--
extra : convert_revision : xtraeme%40gmail.com-20090818153742-98s9y92f5m19l3c2
This commit is contained in:
Juan RP 2009-08-18 17:37:42 +02:00
parent deedf07d4e
commit 9680251382
25 changed files with 3352 additions and 6 deletions

View File

@ -1,6 +1,6 @@
include vars.mk
SUBDIRS = lib bin etc
SUBDIRS = lib bin etc shutils
.PHONY: all
all:

View File

@ -7,6 +7,7 @@ BIN = xbps-src
all:
sed -e "s|@@XBPS_INSTALL_PREFIX@@|$(PREFIX)|g" \
-e "s|@@XBPS_INSTALL_ETCDIR@@|$(ETCDIR)|g" \
-e "s|@@XBPS_INSTALL_SHAREDIR@@|$(SHAREDIR)|g" \
main.sh > xbps-src
.PHONY: clean

View File

@ -1,8 +1,6 @@
#!/bin/sh
#
# xbps - A simple, minimal, fast and uncomplete build package system.
#-
# Copyright (c) 2008 Juan Romero Pardines.
# Copyright (c) 2008-2009 Juan Romero Pardines.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@ -100,7 +98,7 @@ set_defvars()
: ${XBPS_DBDIR:=$XBPS_MASTERDIR/var/db/xbps}
: ${XBPS_META_PATH:=$XBPS_DBDIR/}
: ${XBPS_PKGMETADIR:=$XBPS_DBDIR/metadata}
: ${XBPS_SHUTILSDIR:=$XBPS_DISTRIBUTIONDIR/shutils}
: ${XBPS_SHUTILSDIR:=@@XBPS_INSTALL_SHAREDIR@@}
DDIRS="XBPS_TEMPLATESDIR XBPS_TRIGGERSDIR"
DDIRS="$DDIRS XBPS_HELPERSDIR XBPS_SHUTILSDIR"

16
shutils/Makefile Normal file
View File

@ -0,0 +1,16 @@
include ../vars.mk
.PHONY: all
all:
.PHONY: clean
clean:
install:
if [ ! -d $(DESTDIR)$(SHAREDIR) ]; then \
install -d $(DESTDIR)$(SHAREDIR); \
fi
for f in *.sh; do \
install -m 755 $$f $(DESTDIR)$(SHAREDIR); \
done

98
shutils/build_funcs.sh Normal file
View File

@ -0,0 +1,98 @@
#-
# 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.
#-
#
# Runs the "build" phase for a pkg. This builds the binaries and other
# related stuff.
#
build_src_phase()
{
local pkgparam="$1"
local pkg="$pkgname-$version"
local f
[ -z $pkgparam ] && [ -z $pkgname -o -z $version ] && return 1
#
# There's nothing of interest if we are a meta template or an
# {custom,only}-install template.
#
[ "$build_style" = "meta-template" -o \
"$build_style" = "only-install" -o \
"$build_style" = "custom-install" ] && return 0
[ ! -d $wrksrc ] && msg_error "unexistent build directory [$wrksrc]"
cd $wrksrc || exit 1
[ -n "$revision" ] && pkg="${pkg}_${revision}"
# cross compilation vars.
if [ -n "$cross_compiler" ]; then
. $XBPS_HELPERSDIR/cross-compilation.sh
cross_compile_setvars
fi
[ -z "$make_cmd" ] && make_cmd=/usr/bin/make
# Run pre_build func.
run_func pre_build
[ -n "$XBPS_MAKEJOBS" -a -z "$disable_parallel_build" ] && \
makejobs="-j$XBPS_MAKEJOBS"
if [ -z "$in_chroot" ]; then
. $XBPS_SHUTILSDIR/libtool_funcs.sh
libtool_fixup_file
fi
. $XBPS_SHUTILSDIR/buildvars_funcs.sh
set_build_vars
msg_normal "Running build phase for $pkg."
#
# Build package via make.
#
${make_cmd} ${makejobs} ${make_build_args} ${make_build_target}
[ $? -ne 0 ] && msg_error "building $pkg (build phase)."
# Run post_build func.
run_func post_build
unset makejobs
if [ -z "$in_chroot" ]; then
if [ -z "$libtool_fixup_la_stage" \
-o "$libtool_fixup_la_stage" = "postbuild" ]; then
libtool_fixup_la_files
fi
fi
# unset cross compiler vars.
[ -n "$cross_compiler" ] && cross_compile_unsetvars
unset_build_vars
touch -f $XBPS_BUILD_DONE
}

194
shutils/builddep_funcs.sh Normal file
View File

@ -0,0 +1,194 @@
#-
# Copyright (c) 2008-2009 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.
#-
. $XBPS_SHUTILSDIR/tmpl_funcs.sh
#
# Recursive function that installs all direct and indirect
# dependencies of a package.
#
install_pkg_deps()
{
local curpkg="$1"
local curpkgname=$(xbps-pkgdb getpkgname $1)
local saved_prevpkg=$(xbps-pkgdb getpkgname $2)
local j jver jname reqver
[ -z "$curpkg" ] && return 1
if [ -n "$prev_pkg" ]; then
curpkg=$prev_pkg
curpkgname=$(xbps-pkgdb getpkgname ${curpkg})
fi
echo "==> Installing $saved_prevpkg dependency: $curpkgname."
run_template $curpkgname
check_build_depends_pkg
if [ $? -eq 0 ]; then
echo "==> Dependency $curpkgname requires:"
for j in ${build_depends}; do
jname=$(xbps-pkgdb getpkgname ${j})
jver=$($XBPS_REGPKGDB_CMD version ${jname})
reqver=$(xbps-pkgdb getpkgversion ${j})
check_installed_pkg $j
if [ $? -eq 0 ]; then
echo " $jname >= $reqver: found $jname-$jver."
else
echo " $jname >= $reqver: not found."
fi
done
fi
for j in ${build_depends}; do
#
# Check if dep already installed.
#
check_installed_pkg $j
[ $? -eq 0 ] && continue
[ -n "$prev_pkg" ] && unset prev_pkg
#
# Iterate again, this will check if there are more
# required deps for current pkg.
#
install_pkg_deps $j $curpkg
prev_pkg="$j"
done
install_pkg $curpkgname auto
[ -n "$prev_pkg" ] && unset prev_pkg
}
#
# Installs all dependencies required by a package.
#
install_dependencies_pkg()
{
local pkg="$1"
local lpkgname=$(xbps-pkgdb getpkgname ${pkg})
local i ipkgname iversion reqvers notinstalled_deps lver
[ -z "$pkg" ] && return 1
doing_deps=true
if [ -n "$revision" ]; then
lver="${version}_${revision}"
else
lver="${version}"
fi
echo "==> Required build dependencies for $pkgname-$lver... "
for i in ${build_depends}; do
ipkgname=$(xbps-pkgdb getpkgname ${i})
iversion=$($XBPS_REGPKGDB_CMD version $ipkgname)
reqvers=$(xbps-pkgdb getpkgversion ${i})
check_installed_pkg $i
if [ $? -eq 0 ]; then
echo " $ipkgname >= $reqvers: found $ipkgname-$iversion."
continue
else
echo " $ipkgname >= $reqvers: not found."
notinstalled_deps="$notinstalled_deps $i"
fi
done
[ -z "$notinstalled_deps" ] && return 0
for i in ${notinstalled_deps}; do
check_installed_pkg $i
[ $? -eq 0 ] && continue
ipkgname=$(xbps-pkgdb getpkgname ${i})
run_template $ipkgname
check_build_depends_pkg
if [ $? -eq 1 ]; then
msg_normal "Installing $lpkgname dependency: $ipkgname."
install_pkg $ipkgname auto
else
install_pkg_deps $i $pkg
fi
done
}
install_builddeps_required_pkg()
{
local pkg="$1"
local pkgname=$(xbps-pkgdb getpkgname ${pkg})
local dep depname
[ -z "$pkg" ] && return 1
run_template $pkgname
for dep in ${build_depends}; do
check_installed_pkg $dep
if [ $? -ne 0 ]; then
msg_normal "Installing $pkgname dependency: $dep."
depname=$(xbps-pkgdb getpkgname ${dep})
install_pkg $depname auto
fi
done
}
#
# Checks the registered pkgs db file and returns 0 if a pkg that satisfies
# the minimal required version is there, or 1 otherwise.
#
check_installed_pkg()
{
local pkg="$1"
local pkgname reqver iver
[ -z "$pkg" ] && return 2
pkgname=$(xbps-pkgdb getpkgname $pkg)
reqver=$(xbps-pkgdb getpkgversion $pkg)
run_template $pkgname
iver="$($XBPS_REGPKGDB_CMD version $pkgname)"
if [ -n "$iver" ]; then
xbps-cmpver $pkgname-$iver $pkgname-$reqver
[ $? -eq 0 -o $? -eq 1 ] && return 0
fi
return 1
}
#
# Checks the build depends db file and returns 0 if pkg has dependencies,
# otherwise returns 1.
#
check_build_depends_pkg()
{
[ -z "$pkgname" ] && return 2
if [ -n "$build_depends" ]; then
return 0
else
return 1
fi
}

View File

@ -0,0 +1,58 @@
#-
# 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.
#-
#
# Functions to set some env vars required to build the packages
# required by the xbps-base-chroot package.
#
set_build_vars()
{
if [ -z "$in_chroot" ]; then
SAVE_LDLIBPATH=$LD_LIBRARY_PATH
LD_LIBRARY_PATH="$XBPS_MASTERDIR/usr/lib"
PKG_CONFIG="$XBPS_MASTERDIR/usr/bin/pkg-config"
PKG_CONFIG_LIBDIR="$XBPS_MASTERDIR/usr/lib/pkgconfig"
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH"
export PKG_CONFIG_LIBDIR="$PKG_CONFIG_LIBDIR"
export PKG_CONFIG="$PKG_CONFIG"
fi
LDFLAGS="-L$XBPS_MASTERDIR/usr/lib"
CFLAGS="$CFLAGS $XBPS_CFLAGS"
CXXFLAGS="$CXXFLAGS $XBPS_CXXFLAGS"
CPPFLAGS="-I$XBPS_MASTERDIR/usr/include $CPPFLAGS"
export CFLAGS="$CFLAGS" CXXFLAGS="$CXXFLAGS"
export CPPFLAGS="$CPPFLAGS" LDFLAGS="$LDFLAGS"
}
unset_build_vars()
{
if [ -z "$in_chroot" ]; then
unset PKG_CONFIG LD_LIBRARY_PATH
export LD_LIBRARY_PATH=$SAVE_LDLIBPATH
fi
unset LDFLAGS CFLAGS CXXFLAGS CPPFLAGS
}

285
shutils/chroot.sh Normal file
View File

@ -0,0 +1,285 @@
#-
# 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.
#-
#
# Script 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
prepare_chroot()
{
local f=
# Create some required files.
touch $XBPS_MASTERDIR/etc/mtab
for f in run/utmp log/btmp log/lastlog log/wtmp; do
touch -f $XBPS_MASTERDIR/var/$f
done
for f in run/utmp log/lastlog; do
chmod 644 $XBPS_MASTERDIR/var/$f
done
cat > $XBPS_MASTERDIR/etc/passwd <<_EOF
root:x:0:0:root:/root:/bin/bash
nobody:x:99:99:Unprivileged User:/dev/null:/bin/false
_EOF
# Default group list as specified by LFS.
cat > $XBPS_MASTERDIR/etc/group <<_EOF
root:x:0:
bin:x:1:
sys:x:2:
kmem:x:3:
tty:x:4:
tape:x:5:
daemon:x:6:
floppy:x:7:
disk:x:8:
lp:x:9:
uucp:x:10:
audio:x:11:
video:x:12:
utmp:x:13:
usb:x:14:
cdrom:x:15:
mail:x:34:
nogroup:x:99:
users:x:1000:
_EOF
# Default file as in Ubuntu.
cat > $XBPS_MASTERDIR/etc/hosts <<_EOF
127.0.0.1 xbps localhost.localdomain localhost
127.0.1.1 xbps
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts
_EOF
# Use OpenDNS servers.
cat > $XBPS_MASTERDIR/etc/resolv.conf <<_EOF
nameserver 208.67.222.222
nameserver 208.67.220.220
_EOF
touch $XBPS_MASTERDIR/.xbps_perms_done
}
rebuild_ldso_cache()
{
echo -n "==> Rebuilding chroot's dynamic linker cache..."
chroot $XBPS_MASTERDIR /sbin/ldconfig -c /etc/ld.so.conf
chroot $XBPS_MASTERDIR /sbin/ldconfig -C /etc/ld.so.cache
echo " done."
}
install_xbps_utils()
{
local needed=
local xbps_prefix=$XBPS_MASTERDIR/usr/local
for f in bin cmpver digest pkgdb; do
if [ ! -x $xbps_prefix/sbin/xbps-${f} ]; then
needed=yes
fi
done
if [ -n "$needed" ]; then
cd ${XBPS_MASTERDIR}/bin && ln -s dash sh
echo "=> Building and installing xbps utils."
chroot $XBPS_MASTERDIR sh -c \
"echo /usr/local/lib > /etc/ld.so.conf"
chroot $XBPS_MASTERDIR make -C /xbps
chroot $XBPS_MASTERDIR make -C /xbps install
chroot $XBPS_MASTERDIR make -C /xbps clean
rebuild_ldso_cache
fi
}
xbps_chroot_handler()
{
local action="$1"
local pkg="$2"
local only_destdir="$3"
[ -z "$action" -o -z "$pkg" ] && return 1
[ "$action" != "configure" -a "$action" != "build" -a \
"$action" != "install" -a "$action" != "chroot" ] && return 1
rebuild_ldso_cache
mount_chroot_fs
install_xbps_utils
if [ ! -f $XBPS_MASTERDIR/.xbps_perms_done ]; then
echo -n "==> Preparing chroot on $XBPS_MASTERDIR... "
prepare_chroot
echo "done."
fi
if [ "$action" = "chroot" ]; then
env in_chroot=yes LANG=C chroot $XBPS_MASTERDIR /bin/bash
else
[ -n "$only_destdir" ] && \
local lenv="install_destdir_target=yes"
env in_chroot=yes LANG=C ${lenv} chroot $XBPS_MASTERDIR \
xbps-src $action $pkg
fi
msg_normal "Exiting from the chroot on $XBPS_MASTERDIR."
umount_chroot_fs
}
mount_chroot_fs()
{
local cnt=
REQFS="sys proc dev xbps xbps_builddir xbps_destdir \
xbps_packagesdir xbps_srcdistdir"
if [ -d "$XBPS_CROSS_DIR" ]; then
local cross=yes
REQFS="$REQFS xbps_crossdir"
fi
for f in ${REQFS}; do
if [ ! -f $XBPS_MASTERDIR/.${f}_mount_bind_done ]; then
echo -n "=> Mounting $f in chroot... "
local blah=
case $f in
xbps) blah=$XBPS_DISTRIBUTIONDIR;;
xbps_builddir) blah=$XBPS_BUILDDIR;;
xbps_destdir) blah=$XBPS_DESTDIR;;
xbps_srcdistdir) blah=$XBPS_SRCDISTDIR;;
xbps_packagesdir) blah=$XBPS_PACKAGESDIR;;
xbps_crossdir)
[ -n $cross ] && blah=$XBPS_CROSS_DIR
;;
*) blah=/$f;;
esac
[ ! -d $blah ] && continue
mount --bind $blah $XBPS_MASTERDIR/$f
if [ $? -eq 0 ]; then
echo 1 > $XBPS_MASTERDIR/.${f}_mount_bind_done
echo "done."
else
echo "failed."
fi
else
cnt=$(cat $XBPS_MASTERDIR/.${f}_mount_bind_done)
cnt=$(($cnt + 1))
echo $cnt > $XBPS_MASTERDIR/.${f}_mount_bind_done
fi
done
unset f
}
umount_chroot_fs()
{
local fs=
local dir=
local cnt=
for fs in ${REQFS}; do
[ ! -f $XBPS_MASTERDIR/.${fs}_mount_bind_done ] && continue
cnt=$(cat $XBPS_MASTERDIR/.${fs}_mount_bind_done)
if [ $cnt -gt 1 ]; then
cnt=$(($cnt - 1))
echo $cnt > $XBPS_MASTERDIR/.${fs}_mount_bind_done
else
echo -n "=> Unmounting $fs from chroot... "
umount -f $XBPS_MASTERDIR/$fs
if [ $? -eq 0 ]; then
rm -f $XBPS_MASTERDIR/.${fs}_mount_bind_done
echo "done."
else
echo "failed."
fi
fi
unset fs
done
for dir in ${EXTDIRS}; do
[ -f $XBPS_MASTERDIR/.${dir}_mount_bind_done ] && continue
[ -d $XBPS_MASTERDIR/$dir ] && rmdir $XBPS_MASTERDIR/$dir
done
}
[ -n "$base_chroot" ] && return 0
. $XBPS_SHUTILSDIR/builddep_funcs.sh
check_installed_pkg xbps-base-chroot-0.1
if [ $? -ne 0 ]; then
echo "The '$pkgname' package requires to be installed in a chroot."
echo "Please install the 'xbps-base-chroot' package and try again."
exit 1
fi
if [ "$(id -u)" -ne 0 ]; then
if [ -n "$origin_tmpl" ]; then
. $XBPS_SHUTILSDIR/tmpl_funcs.sh
reset_tmpl_vars
run_file $XBPS_TEMPLATESDIR/$origin_tmpl/template
fi
echo "The '$pkgname' package requires to be installed in a chroot."
echo "You cannot do this as normal user, try again being root."
exit 1
fi
msg_normal "Entering into the chroot on $XBPS_MASTERDIR."
EXTDIRS="xbps xbps_builddir xbps_destdir xbps_packagesdir \
xbps_srcdistdir xbps_crossdir"
REQDIRS="bin sbin tmp var sys proc dev usr/local/etc ${EXTDIRS}"
for f in ${REQDIRS}; do
[ ! -d $XBPS_MASTERDIR/$f ] && mkdir -p $XBPS_MASTERDIR/$f
done
unset f REQDIRS
echo "XBPS_DISTRIBUTIONDIR=/xbps" > $XBPS_MASTERDIR/usr/local/etc/xbps.conf
echo "XBPS_MASTERDIR=/" >> $XBPS_MASTERDIR/usr/local/etc/xbps.conf
echo "XBPS_DESTDIR=/xbps_destdir" >> $XBPS_MASTERDIR/usr/local/etc/xbps.conf
echo "XBPS_PACKAGESDIR=/xbps_packagesdir" >> $XBPS_MASTERDIR/usr/local/etc/xbps.conf
echo "XBPS_BUILDDIR=/xbps_builddir" >> $XBPS_MASTERDIR/usr/local/etc/xbps.conf
echo "XBPS_SRCDISTDIR=/xbps_srcdistdir" >> $XBPS_MASTERDIR/usr/local/etc/xbps.conf
echo "XBPS_CFLAGS=\"$XBPS_CFLAGS\"" >> $XBPS_MASTERDIR/usr/local/etc/xbps.conf
echo "XBPS_CXXFLAGS=\"\$XBPS_CFLAGS\"" >> $XBPS_MASTERDIR/usr/local/etc/xbps.conf
if [ -n "$XBPS_MAKEJOBS" ]; then
echo "XBPS_MAKEJOBS=$XBPS_MAKEJOBS" >> $XBPS_MASTERDIR/usr/local/etc/xbps.conf
fi
if [ -n "$XBPS_CROSS_TARGET" -a -d "$XBPS_CROSS_DIR" ]; then
echo "XBPS_CROSS_TARGET=$XBPS_CROSS_TARGET" >> \
$XBPS_MASTERDIR/usr/local/etc/xbps.conf
echo "XBPS_CROSS_DIR=/xbps_crossdir" >> $XBPS_MASTERDIR/usr/local/etc/xbps.conf
fi

90
shutils/common_funcs.sh Normal file
View File

@ -0,0 +1,90 @@
#-
# 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.
#-
#
# Common functions for xbps.
#
run_func()
{
func="$1"
[ -z "$func" ] && return 1
type -t $func | grep -q 'function'
[ $? -eq 0 ] && $func
}
run_rootcmd()
{
local lenv=
local usesudo="$1"
[ -n "$in_chroot" ] && unset fakeroot_cmd
lenv="XBPS_DESTDIR=$XBPS_DESTDIR"
lenv="XBPS_DISTRIBUTIONDIR=$XBPS_DISTRIBUTIONDIR $lenv"
shift
if [ "$usesudo" = "yes" -a -z "$in_chroot" ]; then
sudo env ${lenv} $@
else
env ${lenv} ${fakeroot_cmd} $@
fi
}
msg_error()
{
[ -z "$1" ] && return 1
if [ -n "$in_chroot" ]; then
echo "[chroot] => ERROR: $1"
else
echo "=> ERROR: $1"
fi
exit 1
}
msg_warn()
{
[ -z "$1" ] && return 1
if [ -n "$in_chroot" ]; then
echo "[chroot] => WARNING: $1"
else
echo "=> WARNING: $1"
fi
}
msg_normal()
{
[ -z "$1" ] && return 1
if [ -n "$in_chroot" ]; then
echo "[chroot] => $1"
else
echo "=> $1"
fi
}

138
shutils/configure_funcs.sh Normal file
View File

@ -0,0 +1,138 @@
#-
# 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.
#-
#
# Runs the "configure" phase for a pkg. This setups the Makefiles or any
# other stuff required to be able to build binaries or such.
#
configure_src_phase()
{
local f lver pkg="$1"
[ -z $pkg ] && [ -z $pkgname ] && return 1
[ ! -d $wrksrc ] && msg_error "unexistent build directory [$wrksrc]."
# Apply patches if requested by template file
if [ ! -f $XBPS_APPLYPATCHES_DONE ]; then
. $XBPS_SHUTILSDIR/patch_funcs.sh
apply_tmpl_patches
fi
#
# There's nothing we can do if we are a meta template or an
# {custom,only}_install template.
#
[ "$build_style" = "meta-template" -o \
"$build_style" = "only-install" -o \
"$build_style" = "custom-install" ] && return 0
if [ -n "$revision" ]; then
lver="${version}_${revision}"
else
lver="${version}"
fi
# cross compilation vars.
if [ -n "$cross_compiler" ]; then
. $XBPS_HELPERSDIR/cross-compilation.sh
cross_compile_setvars
fi
# Run pre_configure func.
run_func pre_configure
# Export configure_env vars.
for f in ${configure_env}; do
export "$f"
done
msg_normal "Running configure phase for $pkgname-$lver."
[ -z "$configure_script" ] && configure_script="./configure"
cd $wrksrc || exit 1
. $XBPS_SHUTILSDIR/buildvars_funcs.sh
set_build_vars
if [ -z "${configure_shell}" ]; then
configure_shell=/bin/bash
fi
#
# Packages using GNU autoconf
#
if [ "$build_style" = "gnu_configure" ]; then
env CONFIG_SHELL=${configure_shell} ${configure_script} \
--prefix=/usr --sysconfdir=/etc \
--infodir=/usr/share/info \
--mandir=/usr/share/man \
${configure_args}
#
# Packages using propietary configure scripts.
#
elif [ "$build_style" = "configure" ]; then
${configure_script} ${configure_args}
#
# Packages that are perl modules and use Makefile.PL files.
# They are all handled by the helper perl-module.sh.
#
elif [ "$build_style" = "perl_module" ]; then
. $XBPS_HELPERSDIR/perl-module.sh
perl_module_build $pkgname
#
# Packages with BSD or GNU Makefiles are easy, just skip
# the configure stage and proceed.
#
elif [ "$build_style" = "bsd_makefile" -o \
"$build_style" = "gnu_makefile" ]; then
:
#
# Unknown build_style type won't work :-)
#
else
msg_error "unknown build_style [$build_style]"
exit 1
fi
if [ "$build_style" != "perl_module" -a "$?" -ne 0 ]; then
msg_error "building $pkg (configure phase)."
fi
# Run post_configure func.
run_func post_configure
# unset configure_env vars.
for f in ${configure_env}; do
unset eval ${f%=*}
done
# unset cross compiler vars.
[ -n "$cross_compiler" ] && cross_compile_unsetvars
unset_build_vars
touch -f $XBPS_CONFIGURE_DONE
}

View File

@ -0,0 +1,70 @@
#-
# 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.
#-
#
# This helper sets some required vars to be able to cross build
# packages on xbps. The target is specified in the configuration file
# and will be read any time the cross compilation flag is used.
#
[ -z "$XBPS_CROSS_TARGET" -o ! -d $XBPS_CROSS_DIR/bin ] && return 1
# Check if all required bins are there.
for bin in gcc g++ cpp ar as ranlib ld strip; do
if [ ! -x $XBPS_CROSS_DIR/bin/$XBPS_CROSS_TARGET-${bin} ]; then
msg_error "cross-compilation: cannot find ${bin}, aborting."
fi
done
SAVE_PATH="$PATH"
if [ "$xbps_machine" = "x86_64" ]; then
XBPS_CROSS_HOST="x86_64-unknown-linux-gnu"
else
XBPS_CROSS_HOST="$xbps_machine-pc-linux-gnu"
fi
cross_compile_setvars()
{
export GCC=$XBPS_CROSS_TARGET-gcc
export CC=$XBPS_CROSS_TARGET-gcc
export CXX=$XBPS_CROSS_TARGET-g++
export CPP=$XBPS_CROSS_TARGET-cpp
export AR=$XBPS_CROSS_TARGET-ar
export AS=$XBPS_CROSS_TARGET-as
export RANLIB=$XBPS_CROSS_TARGET-ranlib
export LD=$XBPS_CROSS_TARGET-ld
export STRIP=$XBPS_CROSS_TARGET-strip
export PATH="$XBPS_CROSS_DIR/bin:$PATH"
}
cross_compile_unsetvars()
{
unset GCC CC CXX CPP AR AS RANLIB LD STRIP PATH
export PATH="$SAVE_PATH"
}
if [ "$build_style" = "gnu_configure" ]; then
configure_args="--build=$XBPS_CROSS_HOST --host=$XBPS_CROSS_TARGET"
configure_args="$configure_args --target=$XBPS_CROSS_TARGET"
fi

176
shutils/extract_funcs.sh Normal file
View File

@ -0,0 +1,176 @@
#-
# 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.
#-
#
# Extracts contents of distfiles specified in a template into
# the $wrksrc directory.
#
extract_distfiles()
{
local count=0 pkg="$1"
local curfile cursufx lwrksrc ltar_cmd f lver
[ -f $XBPS_EXTRACT_DONE ] && return 0
[ -z "$in_chroot" -a ! -w $XBPS_BUILDDIR ] && \
msg_error "can't extract distfile(s) (permission denied)"
#
# If we are being called via the target, just extract and return.
#
[ -n "$pkg" -a -z "$pkgname" ] && return 1
#
# There's nothing of interest if we are a meta template.
#
[ "$build_style" = "meta-template" ] && return 0
if [ -n "$revision" ]; then
lver="${version}_${revision}"
else
lver="${version}"
fi
#
# If noextract is set, do a "fake extraction".
#
if [ -z "$distfiles" -o -n "$noextract" ]; then
mkdir $wrksrc
touch -f $XBPS_EXTRACT_DONE
return 0
fi
for f in ${distfiles}; do
count=$(($count + 1))
done
if [ "$count" -gt 1 ]; then
if [ -z "$wrksrc" ]; then
msg_error "\$wrksrc must be defined with multiple distfiles."
exit 1
fi
mkdir $wrksrc
fi
msg_normal "Extracting $pkgname-$lver distfile(s)."
if [ -n "$tar_override_cmd" ]; then
ltar_cmd="$tar_override_cmd"
else
ltar_cmd="tar"
fi
for f in ${distfiles}; do
curfile=$(basename $f)
if $(echo $f|grep -q '.tar.lzma'); then
cursufx=".tar.lzma"
elif $(echo $f|grep -q '.tar.bz2'); then
cursufx=".tar.bz2"
elif $(echo $f|grep -q '.tbz'); then
cursufx=".tbz"
elif $(echo $f|grep -q '.tar.gz'); then
cursufx=".tar.gz"
elif $(echo $f|grep -q '.tgz'); then
cursufx=".tgz"
elif $(echo $f|grep -q '.gz'); then
cursufx=".gz"
elif $(echo $f|grep -q '.bz2'); then
cursufx=".bz2"
elif $(echo $f|grep -q '.tar'); then
cursufx=".tar"
elif $(echo $f|grep -q '.zip'); then
cursufx=".zip"
else
msg_error "unknown distfile suffix for $curfile."
fi
if [ $count -gt 1 ]; then
lwrksrc="$wrksrc"
else
lwrksrc="$XBPS_BUILDDIR"
fi
case ${cursufx} in
.tar.lzma)
if [ -x $XBPS_MASTERDIR/usr/bin/lzma ]; then
cp -f $XBPS_SRCDISTDIR/$curfile $lwrksrc
cd $lwrksrc && \
$XBPS_MASTERDIR/usr/bin/lzma \
-d $curfile && \
$ltar_cmd xf ${curfile%.lzma} \
-C $lwrksrc && \
rm -f ${curfile%.lzma}
if [ $? -ne 0 ]; then
msg_error "extracting $curfile into $lwrksrc."
fi
else
msg_error "cannot find lzma bin for extraction."
fi
;;
.tar.bz2|.tbz)
$ltar_cmd xfj $XBPS_SRCDISTDIR/$curfile -C $lwrksrc
if [ $? -ne 0 ]; then
msg_error "extracting $curfile into $lwrksrc."
fi
;;
.tar.gz|.tgz)
$ltar_cmd xfz $XBPS_SRCDISTDIR/$curfile -C $lwrksrc
if [ $? -ne 0 ]; then
msg_error "extracting $curfile into $lwrksrc."
fi
;;
.gz|.bz2)
cp -f $XBPS_SRCDISTDIR/$curfile $lwrksrc
if [ "$cursufx" = ".gz" ]; then
cd $lwrksrc && gunzip $curfile
else
cd $lwrksrc && bunzip2 $curfile
fi
;;
.tar)
$ltar_cmd xf $XBPS_SRCDISTDIR/$curfile -C $lwrksrc
if [ $? -ne 0 ]; then
msg_error "extracting $curfile into $lwrksrc."
fi
;;
.zip)
if [ -x $XBPS_MASTERDIR/usr/bin/unzip ]; then
$XBPS_MASTERDIR/usr/bin/unzip \
-q -x $XBPS_SRCDISTDIR/$curfile -d $lwrksrc
if [ $? -ne 0 ]; then
msg_error "extracting $curfile into $lwrksrc."
fi
else
msg_error "cannot find unzip bin for extraction"
fi
;;
*)
msg_error "cannot guess $curfile extract suffix. ($cursufx)"
;;
esac
done
touch -f $XBPS_EXTRACT_DONE
}

158
shutils/fetch_funcs.sh Normal file
View File

@ -0,0 +1,158 @@
#-
# 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.
#-
#
# Verifies that file's checksum downloaded matches what it's specified
# in template file.
#
verify_sha256_cksum()
{
local file="$1"
local origsum="$2"
[ -z "$file" -o -z "$cksum" ] && return 1
filesum=$(xbps-digest $XBPS_SRCDISTDIR/$file)
if [ "$origsum" != "$filesum" ]; then
msg_error "SHA256 checksum doesn't match for $file."
fi
msg_normal "SHA256 checksum OK for $file."
}
fetch_update_cksum()
{
local tmpl="$XBPS_TEMPLATESDIR/$pkgname/template"
local upcmd=$(basename $XBPS_SRCDISTDIR/$1)
sed -i -e "s|checksum.*|checksum=$(xbps-digest ${upcmd})|" $tmpl
return $?
}
#
# Downloads the distfiles and verifies checksum for all them.
#
fetch_distfiles()
{
local pkg="$1"
local upcksum="$2"
local dfiles=
local localurl=
local dfcount=0
local ckcount=0
local f=
[ -z $pkgname ] && exit 1
#
# There's nothing of interest if we are a meta template.
#
[ "$build_style" = "meta-template" ] && return 0
cd $XBPS_SRCDISTDIR
for f in ${distfiles}; do
curfile=$(basename $f)
if [ -f "$XBPS_SRCDISTDIR/$curfile" ]; then
if [ -n "$upcksum" ]; then
fetch_update_cksum $curfile
run_template $pkgname
fi
for i in ${checksum}; do
if [ $dfcount -eq $ckcount -a -n $i ]; then
cksum=$i
found=yes
break
fi
ckcount=$(($ckcount + 1))
done
if [ -z $found ]; then
msg_error "cannot find checksum for $curfile."
fi
verify_sha256_cksum $curfile $cksum
if [ $? -eq 0 ]; then
unset cksum found
ckcount=0
dfcount=$(($dfcount + 1))
continue
fi
fi
msg_normal "Fetching distfile: $curfile."
if [ -n "$distfiles" ]; then
localurl="$f"
else
localurl="$url/$curfile"
fi
$fetch_cmd $localurl
if [ $? -ne 0 ]; then
unset localurl
if [ ! -f $XBPS_SRCDISTDIR/$curfile ]; then
msg_error "couldn't fetch $curfile."
else
msg_error "there was an error fetching $curfile."
fi
else
unset localurl
if [ -n "$upcksum" ]; then
fetch_update_cksum $curfile
run_template $pkgname
fi
#
# XXX duplicate code.
#
for i in ${checksum}; do
if [ $dfcount -eq $ckcount -a -n $i ]; then
cksum=$i
found=yes
break
fi
ckcount=$(($ckcount + 1))
done
if [ -z $found ]; then
msg_error "cannot find checksum for $curfile."
fi
verify_sha256_cksum $curfile $cksum
if [ $? -eq 0 ]; then
unset cksum found
ckcount=0
fi
fi
dfcount=$(($dfcount + 1))
done
unset cksum found
}

169
shutils/install_funcs.sh Normal file
View File

@ -0,0 +1,169 @@
#-
# 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.
#-
#
# Runs the "install" phase for a pkg. This consists in installing package
# into the destination directory.
#
install_src_phase()
{
local pkg="$1"
local f i subpkg lver spkgrev
[ -z $pkg ] && [ -z $pkgname ] && return 1
if [ -n "$revision" ]; then
lver="${version}_${revision}"
else
lver="${version}"
fi
#
# There's nothing we can do if we are a meta template.
# Just creating the dir is enough to write the package metadata.
#
if [ "$build_style" = "meta-template" ]; then
mkdir -p $XBPS_DESTDIR/$pkgname-$version
return 0
fi
[ ! -d $wrksrc ] && msg_error "unexistent build directory [$wrksrc]"
cd $wrksrc || exit 1
# Run pre_install func.
run_func pre_install
msg_normal "Running install phase for $pkgname-$lver."
# cross compilation vars.
if [ -n "$cross_compiler" ]; then
. $XBPS_HELPERSDIR/cross-compilation.sh
cross_compile_setvars
fi
if [ "$build_style" = "custom-install" ]; then
run_func do_install
else
make_install $lver
fi
# Run post_install func.
run_func post_install
# Remove libtool archives from pkg destdir.
if [ -n "$libtool_no_delete_archives" ]; then
find ${DESTDIR} -type f -name \*.la -delete
fi
# unset cross compiler vars.
[ -n "$cross_compiler" ] && cross_compile_unsetvars
msg_normal "Installed $pkgname-$lver into $XBPS_DESTDIR."
if [ "$build_style" != "custom-install" -a -z "$distfiles" ]; then
touch -f $XBPS_INSTALL_DONE
fi
#
# Build subpackages if found.
#
for subpkg in ${subpackages}; do
if [ "${pkg}" != "${sourcepkg}" ] && \
[ "${pkg}" != "${sourcepkg}-${subpkg}" ]; then
continue
fi
if [ -n "$revision" ]; then
spkgrev="${sourcepkg}-${subpkg}-${version}_${revision}"
else
spkgrev="${sourcepkg}-${subpkg}-${version}"
fi
check_installed_pkg ${spkgrev}
[ $? -eq 0 ] && continue
msg_normal "Preparing ${sourcepkg} subpackage: $sourcepkg-$subpkg"
if [ ! -f $XBPS_TEMPLATESDIR/$pkgname/$subpkg.template ]; then
msg_error "Cannot find subpackage template!"
fi
. $XBPS_TEMPLATESDIR/$pkgname/$subpkg.template
pkgname=${sourcepkg}-${subpkg}
set_tmpl_common_vars
run_func do_install
run_template ${sourcepkg}
[ "$pkg" = "${sourcepkg}-${subpkg}" ] && break
done
[ -n "$subpackages" ] && setup_tmpl ${sourcepkg}
#
# Remove $wrksrc if -C not specified.
#
if [ -d "$wrksrc" -a -z "$dontrm_builddir" ]; then
rm -rf $wrksrc
[ $? -eq 0 ] && \
msg_normal "Removed $pkgname-$lver build directory."
fi
}
#
# Installs a package via 'make install ...'.
#
make_install()
{
local lver="$1"
if [ -z "$make_install_target" ]; then
make_install_target="DESTDIR=${DESTDIR} install"
fi
[ -z "$make_cmd" ] && make_cmd=/usr/bin/make
. $XBPS_SHUTILSDIR/buildvars_funcs.sh
set_build_vars
#
# Install package via make.
#
run_rootcmd no ${make_cmd} ${make_install_target} ${make_install_args}
if [ "$?" -ne 0 ]; then
msg_error "installing $pkgname-$lver."
exit 1
fi
# Replace libtool archives if requested.
if [ -z "$in_chroot" ]; then
if [ "$libtool_fixup_la_stage" = "postinstall" ]; then
. $XBPS_SHUTILSDIR/libtool_funcs.sh
libtool_fixup_la_files postinstall
fi
fi
# Always remove perllocal.pod and .packlist files.
find ${DESTDIR} -name perllocal.pod -delete
find ${DESTDIR} -name .packlist -delete
# Unset build vars.
unset_build_vars
}

71
shutils/libtool_funcs.sh Normal file
View File

@ -0,0 +1,71 @@
#-
# 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.
#-
#
# Functions to fixup libtool archives while building packages
# required by xbps-base-chroot, not within the chroot.
#
libtool_fixup_file()
{
local hldirf="hardcode_libdir_flag_spec"
[ "$pkgname" = "libtool" -o ! -f $wrksrc/libtool ] && return 0
[ -n "$no_libtool_fixup" ] && return 0
sed -i -e "s|^$hldirf=.*|$hldirf=\"-Wl,-rpath /usr/lib\"|g" \
$wrksrc/libtool
}
libtool_fixup_la_files()
{
local f=
local postinstall="$1"
local where=
# Ignore libtool itself
[ "$pkgname" = "libtool" ] && return 0
[ ! -f "$wrksrc/libtool" -o ! -f "$wrksrc/ltmain.sh" ] && return 0
#
# Replace hardcoded or incorrect paths with correct ones.
#
if [ -z "$postinstall" ]; then
where="$wrksrc"
else
where="$XBPS_DESTDIR/$pkgname-$version"
fi
for f in $(find $where -type f -name \*.la*); do
if [ -f $f ]; then
msg_normal "Fixing up libtool archive: ${f##$where/}."
sed -i -e "s|\/..\/lib||g;s|\/\/lib|/usr/lib|g" \
-e "s|$XBPS_MASTERDIR||g;s|$wrksrc||g" \
-e "s|$where||g" $f
awk '{ if (/^ dependency_libs/) {gsub("/usr[^]*lib","lib");}print}' \
$f > $f.in && mv $f.in $f
fi
done
}

123
shutils/make-binpkg.sh Normal file
View File

@ -0,0 +1,123 @@
#-
# Copyright (c) 2008-2009 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.
#-
xbps_make_binpkg()
{
local pkg="$1"
local subpkg
for subpkg in ${subpackages}; do
if [ "$pkg" = "$pkgname-$subpkg" ]; then
. $XBPS_TEMPLATESDIR/$pkgname/$subpkg.template
pkgname=${sourcepkg}-${subpkg}
set_tmpl_common_vars
xbps_make_binpkg_real
return $?
fi
run_template ${sourcepkg}
done
set_tmpl_common_vars
xbps_make_binpkg_real
return $?
}
#
# This function builds a binary package from an installed xbps
# package in destdir.
#
xbps_make_binpkg_real()
{
local binpkg pkgdir arch use_sudo lver
local tar_flags="cfp"
if [ ! -d ${DESTDIR} ]; then
echo "$pkgname: unexistent destdir... skipping!"
return 0
fi
cd ${DESTDIR}
if [ -n "$noarch" ]; then
arch=noarch
else
arch=$xbps_machine
fi
if [ -n "$base_chroot" ]; then
use_sudo=no
else
use_sudo=yes
fi
if [ -n "$revision" ]; then
lver="${version}_${revision}"
else
lver="${version}"
fi
binpkg=$pkgname-$lver.$arch.xbps
pkgdir=$XBPS_PACKAGESDIR/$arch
#
# Make sure that INSTALL is the first file on the archive,
# this is to ensure that it's run before any other file is
# unpacked.
#
if [ -x ./INSTALL ]; then
run_rootcmd $use_sudo tar $tar_flags \
$XBPS_BUILDDIR/$binpkg ./INSTALL
[ $? -ne 0 ] && msg_error "Failed to add INSTALL script."
fi
if [ -x ./REMOVE ]; then
if [ -x ./INSTALL ]; then
tar_flags="rfp"
fi
run_rootcmd $use_sudo tar $tar_flags \
$XBPS_BUILDDIR/$binpkg ./REMOVE
[ $? -ne 0 ] && msg_error "Failed to add REMOVE script."
fi
if [ -x ./INSTALL -o -x ./REMOVE ]; then
tar_flags="rfp"
elif [ ! -x ./INSTALL -o ! -x ./REMOVE ]; then
tar_flags="cfp"
fi
run_rootcmd $use_sudo tar $tar_flags $XBPS_BUILDDIR/$binpkg \
./files.plist ./props.plist
[ $? -ne 0 ] && msg_error "Failed to add metadata files."
run_rootcmd $use_sudo tar rfp $XBPS_BUILDDIR/$binpkg . \
--exclude "./INSTALL" --exclude "./REMOVE" \
--exclude "./files.plist" --exclude "./props.plist" \
--exclude "./var/db/xbps/metadata/*/flist" && \
bzip2 -9 $XBPS_BUILDDIR/$binpkg && \
mv $XBPS_BUILDDIR/$binpkg.bz2 $XBPS_BUILDDIR/$binpkg
if [ $? -eq 0 ]; then
[ ! -d $pkgdir ] && mkdir -p $pkgdir
mv -f $XBPS_BUILDDIR/$binpkg $pkgdir
echo "=> Built package: $binpkg"
fi
return $?
}

374
shutils/metadata.sh Normal file
View File

@ -0,0 +1,374 @@
#-
# Copyright (c) 2008-2009 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.
#-
write_metadata_flist_header()
{
[ ! -f "$1" ] && return 1
cat > $1 <<_EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
_EOF
}
xbps_write_metadata_pkg()
{
local pkg="$1"
local subpkg spkgrev
for subpkg in ${subpackages}; do
if [ "${pkg}" != "${sourcepkg}" ] && \
[ "${pkg}" != "${sourcepkg}-${subpkg}" ]; then
continue
fi
if [ -n "${revision}" ]; then
spkgrev="${sourcepkg}-${subpkg}-${version}_${revision}"
else
spkgrev="${sourcepkg}-${subpkg}-${version}"
fi
check_installed_pkg ${spkgrev}
[ $? -eq 0 ] && continue
if [ ! -f $XBPS_TEMPLATESDIR/${sourcepkg}/${subpkg}.template ]; then
msg_error "Cannot find subpackage template!"
fi
unset run_depends conf_files keep_dirs noarch triggers \
revision openrc_services essential
. $XBPS_TEMPLATESDIR/${sourcepkg}/${subpkg}.template
pkgname=${sourcepkg}-${subpkg}
set_tmpl_common_vars
xbps_write_metadata_pkg_real
run_template ${sourcepkg}
[ "${pkg}" = "${sourcepkg}-${subpkg}" ] && break
done
[ -n "${subpackages}" ] && [ "$pkg" != "${sourcepkg}" ] && return $?
if [ "$build_style" = "meta-template" -a -z "${run_depends}" ]; then
for subpkg in ${subpackages}; do
if [ -n "${revision}" ]; then
spkgrev="${sourcepkg}-${subpkg}-${version}_${revision}"
else
spkgrev="${sourcepkg}-${subpkg}-${version}"
fi
run_depends="${run_depends} ${spkgrev}"
done
fi
set_tmpl_common_vars
xbps_write_metadata_pkg_real
}
#
# This function writes the metadata files into package's destdir,
# these will be used for binary packages.
#
xbps_write_metadata_pkg_real()
{
local metadir=${DESTDIR}/var/db/xbps/metadata/$pkgname
local f i j found arch dirat lnkat newlnk lver TMPFLIST TMPFPLIST
local fpattern="s|${DESTDIR}||g;s|^\./$||g;/^$/d"
if [ ! -d "${DESTDIR}" ]; then
echo "ERROR: $pkgname not installed into destdir."
exit 1
fi
if [ -n "$noarch" ]; then
arch=noarch
else
arch=$xbps_machine
fi
if [ -n "$revision" ]; then
lver="${version}_${revision}"
else
lver="${version}"
fi
# Write the files.plist file.
TMPFLIST=$(mktemp -t flist.XXXXXXXXXX) || exit 1
TMPFPLIST=$(mktemp -t fplist.XXXXXXXXXX) || exit 1
#
# Find out if this package contains info files and compress
# all them with gzip.
#
if [ -f ${DESTDIR}/usr/share/info/dir ]; then
# Always remove this file if curpkg is not texinfo.
if [ "$pkgname" != "texinfo" ]; then
rm -f ${DESTDIR}/usr/share/info/dir
fi
# Add info-files trigger.
triggers="info-files $triggers"
for f in $(find -L ${DESTDIR}/usr/share/info -type f); do
j=$(echo $f|sed -e "$fpattern")
[ "$j" = "" ] && continue
[ "$j" = "/usr/share/info/dir" ] && continue
# Ignore compressed files.
if $(echo $j|grep -q '.*.gz$'); then
continue
fi
# Ignore non info files.
if ! $(echo $j|grep -q '.*.info$') && \
! $(echo $j|grep -q '.*.info-[0-9]*$'); then
continue
fi
if [ -h ${DESTDIR}/$j ]; then
dirat=$(dirname $j)
lnkat=$(readlink ${DESTDIR}/$j)
newlnk=$(basename $j)
rm -f ${DESTDIR}/$j
cd ${DESTDIR}/$dirat
ln -s ${lnkat}.gz ${newlnk}.gz
continue
fi
echo "=> Compressing info file: $j..."
gzip -q9 ${DESTDIR}/$j
done
fi
#
# Find out if this package contains manual pages and
# compress all them with gzip.
#
if [ -d "${DESTDIR}/usr/share/man" ]; then
for f in $(find -L ${DESTDIR}/usr/share/man -type f); do
j=$(echo $f|sed -e "$fpattern")
[ "$j" = "" ] && continue
if $(echo $j|grep -q '.*.gz$'); then
continue
fi
if [ -h ${DESTDIR}/$j ]; then
dirat=$(dirname $j)
lnkat=$(readlink ${DESTDIR}/$j)
newlnk=$(basename $j)
rm -f ${DESTDIR}/$j
cd ${DESTDIR}/$dirat
ln -s ${lnkat}.gz ${newlnk}.gz
continue
fi
echo "=> Compressing manpage: $j..."
gzip -q9 ${DESTDIR}/$j
done
fi
cd ${DESTDIR}
msg_normal "Writing package metadata for $pkgname-$lver..."
write_metadata_flist_header $TMPFPLIST
# Pass 1: add links.
echo "<key>links</key>" >> $TMPFPLIST
echo "<array>" >> $TMPFPLIST
for f in $(find ${DESTDIR} -type l); do
j=$(echo $f|sed -e "$fpattern")
[ "$j" = "" ] && continue
echo "$j" >> $TMPFLIST
echo "<dict>" >> $TMPFPLIST
echo "<key>file</key>" >> $TMPFPLIST
echo "<string>$j</string>" >> $TMPFPLIST
echo "</dict>" >> $TMPFPLIST
done
echo "</array>" >> $TMPFPLIST
# Pass 2: add regular files.
echo "<key>files</key>" >> $TMPFPLIST
echo "<array>" >> $TMPFPLIST
for f in $(find ${DESTDIR} -type f); do
j=$(echo $f|sed -e "$fpattern")
[ "$j" = "" ] && continue
echo "$j" >> $TMPFLIST
# Skip configuration files.
for i in ${conf_files}; do
[ "$j" = "$i" ] && found=1 && break
done
[ -n "$found" ] && unset found && continue
echo "<dict>" >> $TMPFPLIST
echo "<key>file</key>" >> $TMPFPLIST
echo "<string>$j</string>" >> $TMPFPLIST
echo "<key>sha256</key>" >> $TMPFPLIST
echo "<string>$(xbps-digest $f)</string>" >> $TMPFPLIST
echo "</dict>" >> $TMPFPLIST
done
echo "</array>" >> $TMPFPLIST
# Pass 3: add directories.
echo "<key>dirs</key>" >> $TMPFPLIST
echo "<array>" >> $TMPFPLIST
for f in $(find ${DESTDIR} -type d|sort -ur); do
j=$(echo $f|sed -e "$fpattern")
[ "$j" = "" ] && continue
echo "$j" >> $TMPFLIST
echo "<dict>" >> $TMPFPLIST
echo "<key>file</key>" >> $TMPFPLIST
echo "<string>$j</string>" >> $TMPFPLIST
for i in ${keep_dirs}; do
if [ "$j" = "$i" ]; then
echo "<key>keep</key>" >> $TMPFPLIST
echo "<true/>" >> $TMPFPLIST
break
fi
done
echo "</dict>" >> $TMPFPLIST
done
echo "</array>" >> $TMPFPLIST
# Add configuration files into its own array.
if [ -n "${conf_files}" ]; then
echo "<key>conf_files</key>" >> $TMPFPLIST
echo "<array>" >> $TMPFPLIST
for f in ${conf_files}; do
i=${DESTDIR}/${f}
[ ! -f ${i} ] && continue
echo "<dict>" >> $TMPFPLIST
echo "<key>file</key>" >> $TMPFPLIST
echo "<string>$f</string>" >> $TMPFPLIST
echo "<key>sha256</key>" >> $TMPFPLIST
echo "<string>$(xbps-digest ${i})</string>" >> $TMPFPLIST
echo "</dict>" >> $TMPFPLIST
done
echo "</array>" >> $TMPFPLIST
fi
echo "</dict>" >> $TMPFPLIST
echo "</plist>" >> $TMPFPLIST
sed -i -e /^$/d $TMPFLIST
# Write the props.plist file.
local TMPFPROPS=$(mktemp -t fprops.XXXXXXXXXX) || exit 1
cat > $TMPFPROPS <<_EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>pkgname</key>
<string>$pkgname</string>
<key>version</key>
<string>$lver</string>
<key>architecture</key>
<string>$arch</string>
<key>installed_size</key>
<integer>$(du -sb ${DESTDIR}|awk '{print $1}')</integer>
<key>maintainer</key>
<string>$(echo $maintainer|sed -e 's|<|[|g;s|>|]|g')</string>
<key>short_desc</key>
<string>$short_desc</string>
<key>long_desc</key>
<string>$long_desc</string>
_EOF
#
# If package sets $openrc_services, add the openrc-service
# trigger and OpenRC run dependency.
#
if [ -n "$openrc_services" ]; then
triggers="$triggers openrc-service"
Add_dependency run OpenRC
fi
# Is this an essential pkg?
if [ -n "$essential" ]; then
echo "<key>essential</key>" >> $TMPFPROPS
echo "<true/>" >> $TMPFPROPS
fi
# Dependencies
if [ -n "$run_depends" ]; then
echo "<key>run_depends</key>" >> $TMPFPROPS
echo "<array>" >> $TMPFPROPS
for f in ${run_depends}; do
echo "<string>$f</string>" >> $TMPFPROPS
done
echo "</array>" >> $TMPFPROPS
fi
# Configuration files
if [ -n "$conf_files" ]; then
echo "<key>conf_files</key>" >> $TMPFPROPS
echo "<array>" >> $TMPFPROPS
for f in ${conf_files}; do
echo "<string>$f</string>" >> $TMPFPROPS
done
echo "</array>" >> $TMPFPROPS
fi
# Keep directories while removing.
if [ -n "$keep_dirs" ]; then
echo "<key>keep_dirs</key>" >> $TMPFPROPS
echo "<array>" >> $TMPFPROPS
for f in ${keep_dirs}; do
echo "<string>$f</string>" >> $TMPFPROPS
done
echo "</array>" >> $TMPFPROPS
fi
# Terminate the property list file.
echo "</dict>" >> $TMPFPROPS
echo "</plist>" >> $TMPFPROPS
if [ ! -d $metadir ]; then
mkdir -p $metadir >/dev/null 2>&1
if [ $? -ne 0 ]; then
echo "ERROR: you don't have enough perms for this."
rm -f $TMPFLIST $TMPFPROPS
exit 1
fi
fi
# Write metadata files and cleanup.
if [ -s $TMPFLIST ]; then
mv -f $TMPFLIST $metadir/flist
else
rm -f $TMPFLIST
fi
mv -f $TMPFPLIST ${DESTDIR}/files.plist
mv -f $TMPFPROPS ${DESTDIR}/props.plist
$XBPS_REGPKGDB_CMD sanitize-plist ${DESTDIR}/files.plist
$XBPS_REGPKGDB_CMD sanitize-plist ${DESTDIR}/props.plist
chmod 644 ${DESTDIR}/files.plist ${DESTDIR}/props.plist
[ -f $metadir/flist ] && chmod 644 $metadir/flist
#
# Update desktop-file-utils database if package contains
# any desktop file in /usr/share/applications.
#
if [ -d ${DESTDIR}/usr/share/applications ]; then
if find . -type f -name \*.desktop 2>&1 >/dev/null; then
triggers="$triggers update-desktopdb"
fi
fi
#
# Create the INSTALL/REMOVE scripts if package uses them
# or uses any available trigger.
#
. ${XBPS_SHUTILSDIR}/metadata_scripts.sh
xbps_write_metadata_scripts_pkg install
xbps_write_metadata_scripts_pkg remove
}

222
shutils/metadata_scripts.sh Normal file
View File

@ -0,0 +1,222 @@
#-
# Copyright (c) 2009 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.
#-
xbps_write_metadata_scripts_pkg()
{
local action="$1"
local tmpf=$(mktemp -t xbps-install.XXXXXXXXXX) || exit 1
local fpattern="s|${DESTDIR}||g;s|^\./$||g;/^$/d"
local targets found info_files
case "$action" in
install) ;;
remove) ;;
*) return 1;;
esac
cd ${DESTDIR}
cat >> $tmpf <<_EOF
#!/bin/sh -e
#
# Generic INSTALL/REMOVE script.
#
# \$1 = action
# \$2 = pkgname
# \$3 = version
#
# Note that paths must be relative to CWD, to avoid calling
# host commands if /bin/sh (dash) is not installed and it's
# not possible to chroot(3).
#
export PATH="./bin:./sbin:./usr/bin:./usr/sbin"
TRIGGERSDIR="./var/db/xbps/triggers"
ACTION="\$1"
PKGNAME="\$2"
VERSION="\$3"
_EOF
#
# Handle GNU Info files.
#
if [ -d "${DESTDIR}/usr/share/info" ]; then
unset info_files
for f in $(find ${DESTDIR}/usr/share/info -type f); do
j=$(echo $f|sed -e "$fpattern")
[ "$j" = "" ] && continue
[ "$j" = "/usr/share/info/dir" ] && continue
if [ -z "$info_files" ]; then
info_files="$j"
else
info_files="$info_files $j"
fi
done
if [ -n "${info_files}" ]; then
for f in ${triggers}; do
[ "$f" = "info-files" ] && found=1
done
[ -z "$found" ] && triggers="$triggers info-files"
unset found
echo "export info_files=\"${info_files}\"" >> $tmpf
echo >> $tmpf
fi
fi
#
# Handle OpenRC services.
#
if [ -n "${openrc_services}" ]; then
echo "export openrc_services=\"${openrc_services}\"" >> $tmpf
echo >> $tmpf
fi
#
# (Un)Register a shell in /etc/shells.
#
if [ -n "${register_shell}" ]; then
for f in ${triggers}; do
[ "$f" = "register-shell" ] && found=1
done
[ -z "$found" ] && triggers="$triggers register-shell"
unset found
echo "export register_shell=\"${register_shell}\"" >> $tmpf
echo >> $tmpf
fi
#
# Handle SGML/XML catalog entries via xmlcatmgr.
#
if [ -n "${sgml_catalogs}" ]; then
for catalog in ${sgml_catalogs}; do
sgml_entries="${sgml_entries} CATALOG ${catalog} --"
done
fi
if [ -n "${sgml_entries}" ]; then
echo "export sgml_entries=\"${sgml_entries}\"" >> $tmpf
echo >> $tmpf
fi
if [ -n "${xml_catalogs}" ]; then
for catalog in ${xml_catalogs}; do
xml_entries="${xml_entries} nextCatalog ${catalog} --"
done
fi
if [ -n "${xml_entries}" ]; then
echo "export xml_entries=\"${xml_entries}\"" >> $tmpf
echo >> $tmpf
fi
#
# Handle X11 font updates via mkfontdir/mkfontscale.
#
if [ -n "${font_dirs}" ]; then
echo "export font_dirs=\"${font_dirs}\"" >> $tmpf
echo >> $tmpf
fi
#
# Handle GTK+ Icon cache directories.
#
if [ -n "${gtk_iconcache_dirs}" ]; then
echo "export gtk_iconcache_dirs=\"${gtk_iconcache_dirs}\"" \
>> $tmpf
echo >> $tmpf
fi
if [ -n "$triggers" ]; then
found=1
echo "case \"\${ACTION}\" in" >> $tmpf
echo "pre)" >> $tmpf
for f in ${triggers}; do
if [ ! -f $XBPS_TRIGGERSDIR/$f ]; then
rm -f $tmpf
msg_error "$pkgname: unknown trigger $f, aborting!"
fi
done
for f in ${triggers}; do
targets=$($XBPS_TRIGGERSDIR/$f targets)
for j in ${targets}; do
if ! $(echo $j|grep -q pre-${action}); then
continue
fi
printf "\t\${TRIGGERSDIR}/$f run $j \${PKGNAME} \${VERSION}\n" >> $tmpf
printf "\t[ \$? -ne 0 ] && exit \$?\n" >> $tmpf
done
done
printf "\t;;\n" >> $tmpf
echo "post)" >> $tmpf
for f in ${triggers}; do
targets=$($XBPS_TRIGGERSDIR/$f targets)
for j in ${targets}; do
if ! $(echo $j|grep -q post-${action}); then
continue
fi
printf "\t\${TRIGGERSDIR}/$f run $j \${PKGNAME} \${VERSION}\n" >> $tmpf
printf "\t[ \$? -ne 0 ] && exit \$?\n" >> $tmpf
done
done
printf "\t;;\n" >> $tmpf
echo "esac" >> $tmpf
echo >> $tmpf
fi
case "$action" in
install)
if [ -n "${sourcepkg}" -a "${sourcepkg}" != "${pkgname}" ]; then
install_file=${XBPS_TEMPLATESDIR}/${pkgname}/${pkgname}.INSTALL
else
install_file=${XBPS_TEMPLATESDIR}/${pkgname}/INSTALL
fi
if [ -f ${install_file} ]; then
found=1
cat ${install_file} >> $tmpf
fi
echo "exit 0" >> $tmpf
if [ -z "$found" ]; then
rm -f $tmpf
return 0
fi
mv $tmpf ${DESTDIR}/INSTALL && chmod 755 ${DESTDIR}/INSTALL
;;
remove)
if [ -n "${sourcepkg}" -a "${sourcepkg}" != "${pkgname}" ]; then
remove_file=${XBPS_TEMPLATESDIR}/${pkgname}/${pkgname}.REMOVE
else
remove_file=${XBPS_TEMPLATESDIR}/${pkgname}/REMOVE
fi
if [ -f ${remove_file} ]; then
found=1
cat ${remove_file} >> $tmpf
fi
echo "exit 0" >> $tmpf
if [ -z "$found" ]; then
rm -f $tmpf
return 0
fi
mv $tmpf ${DESTDIR}/REMOVE && chmod 755 ${DESTDIR}/REMOVE
;;
esac
}

439
shutils/mktoolchain.sh Executable file
View File

@ -0,0 +1,439 @@
#!/bin/sh
#
#-
# 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.
#-
#
# Script to be able to build a full cross toolchain for Linux/x86.
# This has been made thanks to various sources recollected from wikipedia
# and other cross compiling related pages.
# Setup some defaults
: ${GNU_URL_BASE:=http://ftp.gnu.org/gnu}
: ${KERNEL_URL_BASE:=http://www.kernel.org/pub/linux/kernel/v2.6}
: ${GCC_VER:=4.3.2}
: ${BINUTILS_VER:=2.19}
: ${GLIBC_VER:=2.7}
: ${KERNEL_VER:=2.6.27.3}
: ${CROSSDIR:=$HOME/mktoolchain}
: ${BUILDDIR:=$CROSSDIR/build}
: ${SOURCEDISTDIR:=$BUILDDIR/sources}
: ${FETCH_CMD:=wget}
usage()
{
echo "usage: $0 [-b dir] [-c dir] [-s dir] <target triplet>"
echo
echo "Optional flags:"
echo " -b Directory to be used for temporary building."
echo " -c Directory to be used for final cross tools."
echo " -s Directory where the sources are available."
exit 1
}
check_path()
{
local orig="$1"
case "$orig" in
/) ;;
/*) orig="${orig%/}" ;;
*) orig="$PWD/${orig%/}" ;;
esac
SANITIZED_DESTDIR=$orig
}
fetch_sources()
{
local pkg=
cd $SOURCEDISTDIR || exit 1
pkg=linux
if [ ! -f $pkg-$KERNEL_VER.tar.bz2 ]; then
echo "Fetching $pkg kernel-$KERNEL_VER sources..."
$FETCH_CMD $KERNEL_URL_BASE/$pkg-$KERNEL_VER.tar.bz2 || exit 1
fi
pkg=gcc
if [ ! -f $pkg-$GCC_VER.tar.bz2 ]; then
echo "Fetching $pkg-$GCC_VER..."
$FETCH_CMD $GNU_URL_BASE/$pkg/$pkg-$GCC_VER/$pkg-$GCC_VER.tar.bz2 || exit 1
fi
pkg=binutils
if [ ! -f $pkg-$BINUTILS_VER.tar.bz2 ]; then
echo "Fetching $pkg-$BINUTILS_VER..."
$FETCH_CMD $GNU_URL_BASE/$pkg/$pkg-$BINUTILS_VER.tar.bz2 \
|| exit 1
fi
pkg=glibc
if [ ! -f $pkg-$GLIBC_VER.tar.bz2 ]; then
echo "Fetching $pkg-$GLIBC_VER..."
$FETCH_CMD $GNU_URL_BASE/$pkg/$pkg-$GLIBC_VER.tar.bz2 || exit 1
fi
}
kernel_headers()
{
local pkg="linux-$KERNEL_VER"
cd $BUILDDIR || exit 1
tar xfj $SOURCEDISTDIR/$pkg.tar.bz2 -C $BUILDDIR || exit 1
cd $pkg || exit 1
make ARCH=$KERNEL_ARCH headers_check || exit 1
make ARCH=$KERNEL_ARCH headers_install \
INSTALL_HDR_PATH=$SYSROOT/usr || exit 1
cd $SYSROOT/usr/include && ln -s asm asm-$KERNEL_ARCH
cd $BUILDDIR && rm -rf $pkg || exit 1
touch -f $BUILDDIR/.kernel_headers_done
}
binutils()
{
local pkg="binutils-$BINUTILS_VER"
cd $BUILDDIR || exit 1
if [ ! -d $pkg ]; then
tar xfj $SOURCEDISTDIR/$pkg.tar.bz2 -C $BUILDDIR || exit 1
fi
cd $pkg || exit 1
[ ! -d build ] && mkdir build || exit 1
cd build || exit 1
../configure --prefix=$CROSSDIR \
--target=$CROSS_TARGET \
--with-sysroot=$SYSROOT \
--with-build-sysroot=$SYSROOT \
--disable-nls --enable-shared \
--disable-multilib || exit 1
make configure-host && make && make install || exit 1
# Remove unneeded stuff
for f in info man share; do
[ -d $CROSSDIR/$f ] && rm -rf $CROSSDIR/$f
done
cd $BUILDDIR && rm -rf $pkg || exit 1
touch -f $BUILDDIR/.binutils_done
}
glibc_patches()
{
# Apply some required patches for i[56]86-pc-linux-gnu and
# common targets.
$FETCH_CMD http://www.freesa.org/toolchain/patches/glibc-2.7-fixup_for_gcc43-1.patch
$FETCH_CMD http://www.freesa.org/toolchain/patches/glibc-2.7-i586_chk-1.patch
$FETCH_CMD http://www.freesa.org/toolchain/patches/glibc-2.7-libgcc_eh-1.patch
$FETCH_CMD http://svn.exactcode.de/t2/trunk/package/base/glibc/x86-fnstsw.patch
patch -Np1 -i glibc-2.7-fixup_for_gcc43-1.patch || exit 1
patch -Np1 -i glibc-2.7-i586_chk-1.patch || exit 1
patch -Np1 -i glibc-2.7-libgcc_eh-1.patch || exit 1
patch -Np1 -i x86-fnstsw.patch || exit 1
touch -f $BUILDDIR/glibc-$GLIBC_VER/.patches_done
}
gcc()
{
local stage="$1"
local pkg="gcc-$GCC_VER"
local configure_args=
local make_args=
local make_install_args=
local touch_f=
cd $BUILDDIR || exit 1
if [ ! -d $pkg ]; then
tar xfj $SOURCEDISTDIR/$pkg.tar.bz2 -C $BUILDDIR || exit 1
fi
[ ! -d $pkg/build ] && mkdir $pkg/build
cd $pkg/build || exit 1
case $stage in
full)
# gcc with support for C and C++.
touch_f=".gcc_full_done"
make_args="AS_FOR_TARGET=$CROSS_TARGET-as"
make_args="$make_args LD_FOR_TARGET=$CROSS_TARGET-ld"
make_install_args="install"
configure_args="--enable-shared --enable-threads=posix"
configure_args="$configure_args --enable-languages=c,c++"
configure_args="$configure_args --enable-__cxa_atexit"
configure_args="$configure_args --enable-tls"
;;
libgcc)
# Enough to be able to build full glibc.
make all-target-libgcc && make install-target-libgcc || exit 1
rm -rf $SYSROOT/lib/crt* || exit 1
touch -f $BUILDDIR/.gcc_libgcc_done
cd $BUILDDIR/$pkg && rm -rf build
return 0
;;
bootstrap)
# gcc bootstrap
touch_f=".gcc_bootstrap_done"
make_args="all-gcc"
make_install_args="install-gcc"
configure_args="--disable-shared --disable-libmudflap"
configure_args="$configure_args --disable-threads"
configure_args="$configure_args --disable-libssp"
configure_args="$configure_args --enable-languages=c"
;;
*) ;;
esac
../configure --prefix=$CROSSDIR \
--build=$CROSS_HOST --host=$CROSS_HOST \
--target=$CROSS_TARGET \
--with-sysroot=$SYSROOT \
--with-build-sysroot=$SYSROOT \
--disable-multilib \
${configure_args} || exit 1
env LDFLAGS_FOR_TARGET="--sysroot=$SYSROOT" \
CPPFLAGS_FOR_TARGET="--sysroot=$SYSROOT" \
make ${make_args} && make ${make_install_args} || exit 1
# Remove unneeded stuff
for f in info share man; do
[ -d $CROSSDIR/$f ] && rm -rf $CROSSDIR/$f
done
# Do not remove builddir if bootstrap, we want all objs for
# the libgcc pass.
if [ "$stage" != "bootstrap" ]; then
cd $BUILDDIR/$pkg && rm -rf build || exit 1
fi
touch -f $BUILDDIR/$touch_f
}
glibc()
{
local stage="$1"
local pkg="glibc-$GLIBC_VER"
local touch_f=
local cross_binutils="$CROSSDIR/$CROSS_TARGET/bin"
local configure_args=
local CC=
local BUILD_CC=
local RANLIB=
local AR=
cd $BUILDDIR || exit 1
if [ ! -d $pkg ]; then
tar xfj $SOURCEDISTDIR/$pkg.tar.bz2 -C $BUILDDIR || exit 1
fi
cd $pkg || exit 1
[ ! -f .patches_done ] && glibc_patches
[ ! -d build ] && mkdir build
cd build || exit 1
# NPTL support.
echo "libc_cv_forced_unwind=yes" > config.cache
echo "libc_cv_c_cleanup=yes" >> config.cache
if [ "$KERNEL_ARCH" = "i386" ]; then
echo "CFLAGS+=-march=${CROSS_TARGET%%-*} -mtune=generic" \
> configparms
fi
case $stage in
startup|full)
BUILD_CC=$CROSS_TARGET-gcc
CC=$CROSS_TARGET-gcc
AR=$CROSS_TARGET-ar
RANLIB=$CROSS_TARGET-ranlib
configure_args="${configure_args} --with-binutils=$CROSSDIR/bin"
configure_args="${configure_args} --cache-file=config.cache"
;;
headers)
CC=gcc
configure_args="${configure_args} --with-binutils=$cross_binutils"
configure_args="${configure_args} --disable-sanity-checks"
;;
*) ;;
esac
CC=${CC} BUILD_CC=${BUILD_CC} AR=${AR} RANLIB=${RANLIB} \
../configure --prefix=/usr \
--host=$CROSS_TARGET --build=$CROSS_HOST \
--enable-kernel=2.6.25 --with-tls \
--with-__thread --without-selinux \
--without-gd --without-cvs --disable-profile \
--enable-add-ons \
--with-headers=$SYSROOT/usr/include \
${configure_args} || exit 1
case $stage in
startup)
touch_f=".glibc_startup_done"
make -r -C ../csu objdir=$PWD $PWD/csu/crt1.o || exit 1
make -r -C ../csu objdir=$PWD $PWD/csu/crti.o || exit 1
make -r -C ../csu objdir=$PWD $PWD/csu/crtn.o || exit 1
mkdir -p $SYSROOT/lib || exit 1
cp -f csu/crt1.o csu/crti.o csu/crtn.o $SYSROOT/lib || exit 1
;;
headers)
touch_f=".glibc_headers_done"
make cross-compiling=yes \
install_root=$SYSROOT install-headers || exit 1
cp -v bits/stdio_lim.h $SYSROOT/usr/include/bits || exit 1
touch $SYSROOT/usr/include/gnu/stubs.h || exit 1
cp -v ../nptl/sysdeps/pthread/pthread.h \
$SYSROOT/usr/include || exit 1
if [ "$KERNEL_ARCH" = "i386" ]; then
local bitsdir="nptl/sysdeps/unix/sysv/linux/i386/bits"
cp -v ../$bitsdir/pthreadtypes.h \
$SYSROOT/usr/include/bits || exit 1
fi
;;
full)
touch_f=".glibc_full_done"
make && make install_root=$SYSROOT install || exit 1
;;
esac
if [ "$stage" != "headers" ]; then
cd $BUILDDIR/$pkg && rm -rf build || exit 1
fi
touch -f $BUILDDIR/$touch_f
}
while getopts "b:c:s:" opt; do
case $opt in
b) BUILDDIR=$OPTARG
check_path $BUILDDIR
BUILDDIR=$SANITIZED_DESTDIR
;;
c) CROSSDIR=$OPTARG
check_path $CROSSDIR
CROSSDIR=$SANITIZED_DESTDIR
;;
s) SOURCEDISTDIR=$OPTARG
check_path $SOURCEDISTDIR
SOURCEDISTDIR=$SANITIZED_DESTDIR
;;
--) shift; break;;
esac
done
shift $(($OPTIND - 1))
[ $# -ne 1 ] && usage
if [ -z "$1" ]; then
echo "ERROR: missing target triplet."
exit 1
else
CROSS_TARGET=$1
case $CROSS_TARGET in
i686-pc-linux-gnu)
KERNEL_ARCH=i386
CROSS_HOST="$(uname -m)-unknown-linux-gnu"
;;
x86-64-unknown-linux-gnu)
KERNEL_ARCH=x86_64
CROSS_HOST="$(uname -m)-pc-linux-gnu"
;;
*)
echo "ERROR: unknown target triplet $CROSS_TARGET."
exit 1
;;
esac
fi
CROSSDIR=$CROSSDIR/$CROSS_TARGET
SYSROOT=$CROSSDIR/sysroot
[ ! -d $SYSROOT/usr ] && mkdir -p $SYSROOT/usr
[ ! -d $BUILDDIR ] && mkdir -p $BUILDDIR
[ ! -d $SOURCEDISTDIR ] && mkdir -p $SOURCEDISTDIR
unset CFLAGS CXXFLAGS CC CXX AR AS RANLIB LD_STRIP
unset LD_LIBRARY_PATH LD_RUN_PATH
export PATH="$CROSSDIR/bin:/bin:/usr/bin"
fetch_sources
if [ ! -f $BUILDDIR/.kernel_headers_done ]; then
echo "Installing kernel headers..."
kernel_headers
fi
if [ ! -f $BUILDDIR/.binutils_done ]; then
echo "Installing binutils..."
binutils
fi
if [ ! -f $BUILDDIR/.glibc_headers_done ]; then
echo "Installing glibc headers..."
glibc headers
fi
if [ ! -f $BUILDDIR/.gcc_bootstrap_done ]; then
echo "Installing gcc (bootstrap)..."
gcc bootstrap
fi
if [ ! -f $BUILDDIR/.glibc_startup_done ]; then
echo "Installing glibc (startup)..."
glibc startup
fi
if [ ! -f $BUILDDIR/.gcc_libgcc_done ]; then
echo "Installing gcc (libgcc)..."
gcc libgcc
fi
if [ ! -f $BUILDDIR/.glibc_full_done ]; then
echo "Installing glibc (full)..."
glibc full
fi
if [ ! -f $BUILDDIR/.gcc_full_done ]; then
echo "Installing gcc (full)..."
gcc full
fi
[ -d $BUILDDIR ] && rm -rf $BUILDDIR
echo "Finished. Toolchain for $CROSS_TARGET at $CROSSDIR."
exit 0

82
shutils/patch_funcs.sh Normal file
View File

@ -0,0 +1,82 @@
#-
# 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.
#-
#
# Applies to the build directory the patches specified by a template.
#
apply_tmpl_patches()
{
local patch=
local i=
# Apply some build/install patches automatically.
if [ -f $XBPS_TEMPLATESDIR/$pkgname/build.diff ]; then
patch_files="build.diff $patch_files"
fi
if [ -f $XBPS_TEMPLATESDIR/$pkgname/install.diff ]; then
patch_files="install.diff $patch_files"
fi
[ -z "$patch_args" ] && patch_args="-p0"
[ -z "$patch_files" ] && return 0
#
# If package needs some patches applied before building,
# apply them now.
#
for i in ${patch_files}; do
patch="$XBPS_TEMPLATESDIR/$pkgname/$i"
if [ ! -f "$patch" ]; then
msg_warn "unexistent patch: $i."
continue
fi
cp -f $patch $wrksrc
# Try to guess if its a compressed patch.
if $(echo $patch|grep -q '.diff.gz'); then
gunzip $wrksrc/$i
patch=${i%%.gz}
elif $(echo $patch|grep -q '.diff.bz2'); then
bunzip2 $wrksrc/$i
patch=${i%%.bz2}
elif $(echo $patch|grep -q '.diff'); then
patch=$i
else
msg_warn "unknown patch type: $i."
continue
fi
cd $wrksrc && patch -s ${patch_args} < \
$patch 2>/dev/null
if [ "$?" -eq 0 ]; then
msg_normal "Patch applied: $i."
else
msg_error "couldn't apply patch: $i."
fi
done
touch -f $XBPS_APPLYPATCHES_DONE
}

173
shutils/pkgtarget_funcs.sh Normal file
View File

@ -0,0 +1,173 @@
#-
# Copyright (c) 2008-2009 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.
#-
. ${XBPS_SHUTILSDIR}/tmpl_funcs.sh
#
# Installs a pkg by reading its build template file.
#
install_pkg()
{
local pkg=
local curpkgn="$1"
local automatic="$2"
local cdestdir=
local cur_tmpl="$XBPS_TEMPLATESDIR/$curpkgn/template"
if [ -z $cur_tmpl -o ! -f $cur_tmpl ]; then
msg_error "cannot find $cur_tmpl template build file."
fi
#
# If we are being invoked through the chroot, re-read config file
# to get correct stuff.
#
if [ -n "$in_chroot" ]; then
check_config_vars
set_defvars
fi
. $XBPS_SHUTILSDIR/tmpl_funcs.sh
reset_tmpl_vars
. $cur_tmpl
pkg="$curpkgn-$version"
#
# If we are the originator package save the path this template in
# other var for future use.
#
[ -z "$origin_tmpl" ] && origin_tmpl=$pkgname
if [ -z "$base_chroot" -a -z "$in_chroot" ]; then
. $XBPS_SHUTILSDIR/chroot.sh
[ -n "$install_destdir_target" ] && cdestdir=yes
xbps_chroot_handler install $curpkgn $cdestdir
return $?
fi
#
# We are going to install a new package.
#
setup_tmpl $curpkgn
#
# Install dependencies required by this package.
#
if [ -z "$doing_deps" ]; then
. $XBPS_SHUTILSDIR/builddep_funcs.sh
install_dependencies_pkg $pkg
#
# At this point all required deps are installed, and
# only remaining is the origin template; install it.
#
unset doing_deps
reset_tmpl_vars
setup_tmpl $curpkgn
fi
#
# Fetch, extract, build and install into the destination directory.
#
. $XBPS_SHUTILSDIR/fetch_funcs.sh
fetch_distfiles
if [ ! -f "$XBPS_EXTRACT_DONE" ]; then
. $XBPS_SHUTILSDIR/extract_funcs.sh
extract_distfiles
fi
if [ ! -f "$XBPS_CONFIGURE_DONE" ]; then
. $XBPS_SHUTILSDIR/configure_funcs.sh
configure_src_phase
fi
if [ ! -f "$XBPS_BUILD_DONE" ]; then
. $XBPS_SHUTILSDIR/build_funcs.sh
build_src_phase
fi
. $XBPS_SHUTILSDIR/install_funcs.sh
install_src_phase $curpkgn
# Always write metadata to package's destdir.
. $XBPS_SHUTILSDIR/metadata.sh
xbps_write_metadata_pkg $curpkgn
#
# Do not stow package if it wasn't requested.
#
if [ -z "$install_destdir_target" ]; then
. $XBPS_SHUTILSDIR/stow_funcs.sh
stow_pkg $curpkgn $automatic
fi
}
#
# Lists files installed by a package.
#
list_pkg_files()
{
local pkg="$1"
local ver=
[ -z $pkg ] && msg_error "unexistent package, aborting."
ver=$($XBPS_REGPKGDB_CMD version $pkg)
[ -z "$ver" ] && msg_error "$pkg is not installed."
cat $XBPS_PKGMETADIR/$pkg/flist
}
#
# Removes a currently installed package (unstow + removed from destdir).
#
remove_pkg()
{
local pkg="$1" subpkg ver
[ -z $pkg ] && msg_error "unexistent package, aborting."
if [ ! -f "$XBPS_TEMPLATESDIR/$pkg/template" ]; then
msg_error "cannot find template build file."
fi
. $XBPS_TEMPLATESDIR/$pkg/template
for f in ${subpackages}; do
if [ "$pkg" = "${pkgname}-${f}" ]; then
pkgname=${pkg}
break;
fi
done
ver=$($XBPS_REGPKGDB_CMD version $pkg)
[ -z "$ver" ] && msg_error "$pkg is not installed."
. $XBPS_SHUTILSDIR/stow_funcs.sh
unstow_pkg $pkg
if [ $? -eq 0 -a -d $XBPS_DESTDIR/$pkg-${ver%_${revision}} ]; then
rm -rf $XBPS_DESTDIR/$pkg-${ver%_${revision}}
fi
return $?
}

174
shutils/stow_funcs.sh Normal file
View File

@ -0,0 +1,174 @@
#-
# Copyright (c) 2008-2009 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.
#-
. ${XBPS_SHUTILSDIR}/builddep_funcs.sh
stow_pkg()
{
local pkg="$1"
local automatic="$2"
local subpkg spkgrev
for subpkg in ${subpackages}; do
if [ "${pkg}" != "${sourcepkg}" ] && \
[ "${pkg}" != "${sourcepkg}-${subpkg}" ]; then
continue
fi
if [ -n "$revision" ]; then
spkgrev="${sourcepkg}-${subpkg}-${version}_${revision}"
else
spkgrev="${sourcepkg}-${subpkg}-${version}"
fi
check_installed_pkg ${spkgrev}
[ $? -eq 0 ] && continue
if [ ! -f $XBPS_TEMPLATESDIR/${sourcepkg}/${subpkg}.template ]; then
msg_error "Cannot find subpackage template!"
fi
unset revision
. $XBPS_TEMPLATESDIR/${sourcepkg}/${subpkg}.template
pkgname=${sourcepkg}-${subpkg}
set_tmpl_common_vars
stow_pkg_real ${pkgname} ${automatic}
run_template ${sourcepkg}
if [ "${pkg}" = "${sourcepkg}-${subpkg}" ]; then
#
# If it's a subpackage, just remove sourcepkg from
# destdir and return, we are done.
#
rm -rf $XBPS_DESTDIR/${spkgrev}
return $?
fi
done
stow_pkg_real ${pkg} ${automatic}
return $?
}
#
# Stow a package, i.e copy files from destdir into masterdir
# and register pkg into the package database.
#
stow_pkg_real()
{
local pkg="$1"
local automatic="$2"
local i lver regpkgdb_flags
[ -z "$pkg" ] && return 2
if [ $(id -u) -ne 0 ] && [ ! -w $XBPS_MASTERDIR ]; then
msg_error "cannot stow $pkg! (permission denied)"
fi
if [ "$build_style" = "meta-template" ]; then
[ ! -d ${DESTDIR} ] && mkdir -p ${DESTDIR}
fi
[ -n "$stow_flag" ] && run_template $pkg
cd ${DESTDIR} || exit 1
# Copy files into masterdir.
for i in $(echo *); do
[ "$i" = "INSTALL" ] && continue
cp -a ${i} $XBPS_MASTERDIR
done
#
# Register pkg in plist file and add automatic installation
# object if requested.
#
[ -n "$automatic" ] && regpkgdb_flags="-a"
if [ -n "$revision" ]; then
lver="${version}_${revision}"
else
lver="${version}"
fi
$XBPS_REGPKGDB_CMD $regpkgdb_flags register \
$pkg $lver "$short_desc" || exit 1
}
#
# Unstow a package, i.e remove its files from masterdir and
# unregister pkg from package database.
#
unstow_pkg()
{
local f ver pkg="$1"
[ -z $pkg ] && msg_error "template wasn't specified?"
if [ $(id -u) -ne 0 ] && \
[ ! -w $XBPS_MASTERDIR ]; then
msg_error "cannot unstow $pkg! (permission denied)"
fi
run_template $pkg
ver=$($XBPS_REGPKGDB_CMD version $pkg)
if [ -z "$ver" ]; then
msg_error "$pkg is not installed."
fi
cd $XBPS_PKGMETADIR/$pkg || exit 1
if [ "$build_style" = "meta-template" ]; then
# If it's a metapkg, do nothing.
:
elif [ ! -f flist ]; then
msg_error "$pkg is incomplete, missing flist."
elif [ ! -w flist ]; then
msg_error "$pkg cannot be removed (permission denied)."
elif [ -s flist ]; then
# Remove installed files.
for f in $(cat flist); do
if [ -f $XBPS_MASTERDIR/$f -o -h $XBPS_MASTERDIR/$f ]; then
rm $XBPS_MASTERDIR/$f >/dev/null 2>&1
if [ $? -eq 0 ]; then
echo "Removing file: $f"
fi
fi
done
for f in $(cat flist); do
if [ -d $XBPS_MASTERDIR/$f ]; then
rmdir $XBPS_MASTERDIR/$f >/dev/null 2>&1
if [ $? -eq 0 ]; then
echo "Removing directory: $f"
fi
fi
done
fi
# Remove metadata dir.
rm -rf $XBPS_PKGMETADIR/$pkg
# Unregister pkg from plist file.
$XBPS_REGPKGDB_CMD unregister $pkg $ver
return $?
}

224
shutils/tmpl_funcs.sh Normal file
View File

@ -0,0 +1,224 @@
#-
# Copyright (c) 2008-2009 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.
#-
#
# Shows info about a template.
#
info_tmpl()
{
local i=
echo "pkgname: $pkgname"
echo "version: $version"
[ -n "$revision" ] && echo "revision: $revision"
for i in "${distfiles}"; do
[ -n "$i" ] && echo "distfile: $i"
done
[ -n "$checksum" ] && echo "checksum: $checksum"
echo "maintainer: $maintainer"
echo "build_style: $build_style"
echo "short_desc: $short_desc"
echo "$long_desc"
echo
. $XBPS_SHUTILSDIR/builddep_funcs.sh
run_template $pkgname
check_build_depends_pkg
if [ $? -eq 0 ]; then
echo "This package requires the following dependencies to be built:"
for i in ${build_depends}; do
echo " $i"
done
fi
}
#
# Resets all vars used by a template.
#
reset_tmpl_vars()
{
local v=
local TMPL_VARS="pkgname distfiles configure_args configure_env \
make_build_args make_install_args build_style \
short_desc maintainer long_desc checksum wrksrc \
patch_files make_cmd base_chroot register_shell \
make_build_target configure_script noextract \
pre_configure pre_build pre_install configure_shell \
post_configure post_build post_install \
make_install_target version revision essential \
sgml_catalogs xml_catalogs xml_entries sgml_entries \
build_depends libtool_fixup_la_stage no_fixup_libtool \
disable_parallel_build run_depends cross_compiler \
only_for_archs patch_args conf_files keep_dirs \
noarch subpackages sourcepkg gtk_iconcache_dirs \
abi_depends api_depends triggers openrc_services \
libtool_no_delete_archives \
XBPS_EXTRACT_DONE XBPS_CONFIGURE_DONE \
XBPS_BUILD_DONE XBPS_INSTALL_DONE FILESDIR DESTDIR \
SRCPKGDESTDIR"
for v in ${TMPL_VARS}; do
eval unset "$v"
done
. $XBPS_SHUTILSDIR/buildvars_funcs.sh
unset_build_vars
}
#
# Reads a template file and setups required variables for operations.
#
setup_tmpl()
{
local pkg="$1"
[ -z "$pkg" ] && msg_error "missing package name after target."
. $XBPS_SHUTILSDIR/tmpl_vars.sh
if [ -f "$XBPS_TEMPLATESDIR/$pkg/template" ]; then
if [ "$pkgname" != "$pkg" ]; then
reset_tmpl_vars
. $XBPS_TEMPLATESDIR/$pkg/template
fi
prepare_tmpl
else
msg_error "cannot find '$pkg' template build file."
fi
}
Add_dependency()
{
local type="$1"
local pkgname="$2"
local minver="$3"
case "$type" in
build|full|run) ;;
*) msg_error "Unknown dependency type for $pkgname." ;;
esac
if [ -f $XBPS_TEMPLATESDIR/$pkgname/$pkgname.depends ]; then
. $XBPS_TEMPLATESDIR/$pkgname/$pkgname.depends
elif [ -f $XBPS_TEMPLATESDIR/$pkgname/depends ]; then
. $XBPS_TEMPLATESDIR/$pkgname/depends
fi
if [ "$type" = "full" -o "$type" = "build" ]; then
if [ -z "$minver" -a -z "$api_depends" ]; then
build_depends="${build_depends} $pkgname-0"
elif [ -z "$minver" -a -n "$api_depends" ]; then
build_depends="${build_depends} $pkgname-$api_depends"
else
build_depends="${build_depends} $pkgname-$minver"
fi
fi
if [ "$type" = "full" -o "$type" = "run" ]; then
if [ -z "$minver" -a -z "$abi_depends" ]; then
run_depends="${run_depends} $pkgname-0"
elif [ -z "$minver" -a -n "$abi_depends" ]; then
run_depends="${run_depends} $pkgname-$abi_depends"
else
run_depends="${run_depends} $pkgname-$minver"
fi
fi
unset abi_depends api_depends
}
#
# Checks some vars used in templates and sets some of them required.
#
prepare_tmpl()
{
local REQ_VARS i found
#
# There's nothing of interest if we are a meta template.
#
[ "$build_style" = "meta-template" ] && return 0
REQ_VARS="pkgname version build_style short_desc long_desc"
# Check if required vars weren't set.
for i in ${REQ_VARS}; do
eval val="\$$i"
if [ -z "$val" -o -z "$i" ]; then
msg_error "\"$i\" not set on $pkgname template."
fi
done
for i in ${only_for_archs}; do
[ "$i" = "$xbps_machine" ] && found=si && break
done
if [ -n "${only_for_archs}" -a -z "$found" ]; then
msg_error "this package is only for: ${only_for_archs}."
fi
unset XBPS_EXTRACT_DONE XBPS_APPLYPATCHES_DONE
unset XBPS_CONFIGURE_DONE XBPS_BUILD_DONE XBPS_INSTALL_DONE
[ -z "$wrksrc" ] && wrksrc="$pkgname-$version"
wrksrc="$XBPS_BUILDDIR/$wrksrc"
XBPS_EXTRACT_DONE="$wrksrc/.xbps_extract_done"
XBPS_APPLYPATCHES_DONE="$wrksrc/.xbps_applypatches_done"
XBPS_CONFIGURE_DONE="$wrksrc/.xbps_configure_done"
XBPS_BUILD_DONE="$wrksrc/.xbps_build_done"
XBPS_INSTALL_DONE="$wrksrc/.xbps_install_done"
set_tmpl_common_vars
if [ -z "$in_chroot" ]; then
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:/usr/local/sbin"
fi
}
set_tmpl_common_vars()
{
[ -z "$pkgname" ] && return 1
FILESDIR=${XBPS_TEMPLATESDIR}/${pkgname}/files
DESTDIR=${XBPS_DESTDIR}/${pkgname}-${version}
if [ -z "${sourcepkg}" ]; then
sourcepkg=${pkgname}
fi
SRCPKGDESTDIR=${XBPS_DESTDIR}/${sourcepkg}-${version}
}
run_template()
{
local pkg="$1"
if [ "$pkgname" != "$pkg" ]; then
reset_tmpl_vars
. $XBPS_TEMPLATESDIR/$pkg/template
set_tmpl_common_vars
fi
}

12
shutils/tmpl_vars.sh Normal file
View File

@ -0,0 +1,12 @@
#
# Common vars that can be used by templates.
#
SOURCEFORGE_SITE="http://downloads.sourceforge.net/sourceforge"
NONGNU_SITE="http://download.savannah.nongnu.org/releases"
UBUNTU_SITE="http://archive.ubuntu.com/ubuntu/pool"
XORG_SITE="http://xorg.freedesktop.org/releases/individual"
DEBIAN_SITE="http://ftp.debian.org/debian/pool"
GNOME_SITE="http://ftp.gnome.org/pub/GNOME/sources"
KERNEL_SITE="http://www.kernel.org/pub/linux"
CPAN_SITE="http://cpan.perl.org/modules/by-module"

View File

@ -1,8 +1,9 @@
# Common variables.
PREFIX ?= /usr/local
PREFIX ?=
SBINDIR ?= $(DESTDIR)$(PREFIX)/sbin
LIBDIR ?= $(DESTDIR)$(PREFIX)/lib
SHAREDIR ?= $(PREFIX)/usr/share/xbps/shutils
ETCDIR ?= $(PREFIX)/etc
TOPDIR ?= ..
INSTALL_STRIPPED ?= -s