2009-03-12 22:44:18 +00:00
|
|
|
#-
|
|
|
|
# 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()
|
|
|
|
{
|
2009-03-28 07:27:29 +00:00
|
|
|
local binpkg pkgdir arch use_sudo lver
|
2009-03-12 22:44:18 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
|
2009-03-28 07:27:29 +00:00
|
|
|
if [ -n "$revision" ]; then
|
|
|
|
lver="${version}_${revision}"
|
|
|
|
else
|
|
|
|
lver="${version}"
|
|
|
|
fi
|
|
|
|
binpkg=$pkgname-$lver.$arch.xbps
|
2009-03-12 22:44:18 +00:00
|
|
|
pkgdir=$XBPS_PACKAGESDIR/$arch
|
|
|
|
|
|
|
|
if [ -x ./INSTALL ]; then
|
|
|
|
#
|
|
|
|
# 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-03-31 16:51:05 +00:00
|
|
|
run_rootcmd $use_sudo tar cfp \
|
|
|
|
$XBPS_BUILDDIR/$binpkg ./INSTALL && \
|
|
|
|
run_rootcmd $use_sudo tar rfp $XBPS_BUILDDIR/$binpkg . \
|
2009-03-12 22:44:18 +00:00
|
|
|
--exclude "./INSTALL" \
|
|
|
|
--exclude "./var/db/xbps/metadata/*/flist" && \
|
2009-03-31 16:51:05 +00:00
|
|
|
bzip2 -9 $XBPS_BUILDDIR/$binpkg && \
|
|
|
|
mv $XBPS_BUILDDIR/$binpkg.bz2 $XBPS_BUILDDIR/$binpkg
|
2009-03-12 22:44:18 +00:00
|
|
|
else
|
2009-03-31 16:51:05 +00:00
|
|
|
run_rootcmd $use_sudo tar cfp $XBPS_BUILDDIR/$binpkg . \
|
2009-03-12 22:44:18 +00:00
|
|
|
--exclude "./var/db/xbps/metadata/*/flist" && \
|
2009-03-31 16:51:05 +00:00
|
|
|
bzip2 -9 $XBPS_BUILDDIR/$binpkg && \
|
|
|
|
mv $XBPS_BUILDDIR/$binpkg.bz2 $XBPS_BUILDDIR/$binpkg
|
2009-03-12 22:44:18 +00:00
|
|
|
fi
|
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
[ ! -d $pkgdir ] && mkdir -p $pkgdir
|
2009-03-31 16:51:05 +00:00
|
|
|
mv -f $XBPS_BUILDDIR/$binpkg $pkgdir
|
2009-03-12 22:44:18 +00:00
|
|
|
echo "=> Built package: $binpkg"
|
|
|
|
fi
|
|
|
|
|
|
|
|
return $?
|
|
|
|
}
|