2009-10-18 09:17:26 +00:00
|
|
|
#-
|
2010-01-17 07:50:36 +00:00
|
|
|
# Copyright (c) 2008-2010 Juan Romero Pardines.
|
2009-10-18 09:17:26 +00:00
|
|
|
# All rights reserved.
|
|
|
|
#
|
|
|
|
# Redistribution and use in source and binary forms, with or without
|
|
|
|
# modification, are permitted provided that the following conditions
|
|
|
|
# are met:
|
|
|
|
# 1. Redistributions of source code must retain the above copyright
|
|
|
|
# notice, this list of conditions and the following disclaimer.
|
|
|
|
# 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
# notice, this list of conditions and the following disclaimer in the
|
|
|
|
# documentation and/or other materials provided with the distribution.
|
|
|
|
#
|
|
|
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
#-
|
|
|
|
|
|
|
|
xbps_make_binpkg()
|
|
|
|
{
|
|
|
|
local subpkg
|
|
|
|
|
2009-11-22 07:31:44 +00:00
|
|
|
[ -z "$pkgname" ] && return 1
|
|
|
|
|
2009-10-18 09:17:26 +00:00
|
|
|
for subpkg in ${subpackages}; do
|
2009-12-27 15:48:27 +00:00
|
|
|
unset revision noarch
|
2009-11-22 07:31:44 +00:00
|
|
|
. $XBPS_SRCPKGDIR/$pkgname/$subpkg.template
|
|
|
|
pkgname=${subpkg}
|
2009-10-20 08:06:02 +00:00
|
|
|
set_tmpl_common_vars
|
|
|
|
xbps_make_binpkg_real
|
2009-11-23 05:30:04 +00:00
|
|
|
setup_tmpl ${sourcepkg}
|
2009-10-18 09:17:26 +00:00
|
|
|
done
|
|
|
|
|
2009-11-22 07:31:44 +00:00
|
|
|
[ -n "${subpackages}" ] && set_tmpl_common_vars
|
2009-10-18 09:17:26 +00:00
|
|
|
xbps_make_binpkg_real
|
|
|
|
return $?
|
|
|
|
}
|
|
|
|
|
2009-11-23 10:50:18 +00:00
|
|
|
binpkg_cleanup()
|
|
|
|
{
|
|
|
|
printf "\nInterrupted! removing $binpkg file!\n"
|
|
|
|
rm -f $pkgdir/$binpkg
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
2009-10-18 09:17:26 +00:00
|
|
|
#
|
|
|
|
# This function builds a binary package from an installed xbps
|
|
|
|
# package in destdir.
|
|
|
|
#
|
|
|
|
xbps_make_binpkg_real()
|
|
|
|
{
|
2010-01-16 01:11:44 +00:00
|
|
|
local mfiles binpkg pkgdir arch lver dirs _dirs d clevel
|
2009-10-18 09:17:26 +00:00
|
|
|
|
2009-11-22 07:31:44 +00:00
|
|
|
if [ ! -d "${DESTDIR}" ]; then
|
|
|
|
msg_warn "cannot find destdir for $pkgname... skipping!"
|
2009-10-18 09:17:26 +00:00
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
cd ${DESTDIR}
|
|
|
|
|
|
|
|
if [ -n "$noarch" ]; then
|
|
|
|
arch=noarch
|
|
|
|
else
|
|
|
|
arch=$xbps_machine
|
|
|
|
fi
|
|
|
|
if [ -n "$revision" ]; then
|
|
|
|
lver="${version}_${revision}"
|
|
|
|
else
|
|
|
|
lver="${version}"
|
|
|
|
fi
|
|
|
|
binpkg=$pkgname-$lver.$arch.xbps
|
|
|
|
pkgdir=$XBPS_PACKAGESDIR/$arch
|
2009-11-22 07:31:44 +00:00
|
|
|
#
|
|
|
|
# Don't overwrite existing binpkgs by default, skip them.
|
|
|
|
#
|
|
|
|
if [ -f $pkgdir/$binpkg ]; then
|
2009-11-23 10:50:18 +00:00
|
|
|
echo "=> Skipping existing $binpkg pkg..."
|
2009-11-22 07:31:44 +00:00
|
|
|
return 0
|
|
|
|
fi
|
2009-10-18 09:17:26 +00:00
|
|
|
|
|
|
|
#
|
|
|
|
# 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.
|
|
|
|
#
|
2009-10-20 13:19:09 +00:00
|
|
|
if [ -x ./INSTALL -a -x ./REMOVE ]; then
|
|
|
|
mfiles="./INSTALL ./REMOVE"
|
|
|
|
elif [ -x ./INSTALL ]; then
|
|
|
|
mfiles="./INSTALL"
|
|
|
|
elif [ -x ./REMOVE ]; then
|
|
|
|
mfiles="./REMOVE"
|
2009-10-18 09:17:26 +00:00
|
|
|
fi
|
2009-10-20 13:19:09 +00:00
|
|
|
mfiles="$mfiles ./files.plist ./props.plist"
|
2009-12-19 03:57:39 +00:00
|
|
|
_dirs=$(find . -maxdepth 1 -type d -o -type l)
|
2009-10-20 13:19:09 +00:00
|
|
|
for d in ${_dirs}; do
|
|
|
|
[ "$d" = "." ] && continue
|
|
|
|
dirs="$d $dirs"
|
|
|
|
done
|
|
|
|
|
|
|
|
[ -n "$XBPS_COMPRESS_LEVEL" ] && clevel="-$XBPS_COMPRESS_LEVEL"
|
2009-10-18 09:17:26 +00:00
|
|
|
|
2009-10-20 13:19:09 +00:00
|
|
|
[ ! -d $pkgdir ] && mkdir -p $pkgdir
|
2009-11-23 10:50:18 +00:00
|
|
|
|
|
|
|
# Remove binpkg if interrupted...
|
|
|
|
trap "binpkg_cleanup" INT
|
|
|
|
|
|
|
|
echo -n "=> Building $binpkg... "
|
2010-01-16 01:11:44 +00:00
|
|
|
${fakeroot_cmd} ${fakeroot_cmd_args} \
|
|
|
|
tar --exclude "var/db/xbps/metadata/*/flist" \
|
|
|
|
-cpf - ${mfiles} ${dirs} | \
|
2009-10-20 13:19:09 +00:00
|
|
|
$XBPS_COMPRESS_CMD ${clevel} -qf > $pkgdir/$binpkg
|
2009-10-18 09:17:26 +00:00
|
|
|
if [ $? -eq 0 ]; then
|
2009-11-23 10:50:18 +00:00
|
|
|
echo "done."
|
|
|
|
else
|
|
|
|
rm -f $pkgdir/$binpkg
|
|
|
|
echo "failed!"
|
2009-10-18 09:17:26 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
return $?
|
|
|
|
}
|