From b14fea2e584992278f14bf46c49ab0506710aeb9 Mon Sep 17 00:00:00 2001 From: Juan RP Date: Thu, 12 Mar 2009 23:44:18 +0100 Subject: [PATCH] Split funcs to build binpkgs into its own file. --HG-- extra : convert_revision : a4fd0f4506bd257308936e0d0c0187fa62a840ed --- bin/xbps-src/main.sh | 2 +- shutils/binpkg.sh | 78 ------------------------------- shutils/make-binpkg.sh | 102 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 103 insertions(+), 79 deletions(-) create mode 100644 shutils/make-binpkg.sh diff --git a/bin/xbps-src/main.sh b/bin/xbps-src/main.sh index 12976ff0a9a..afba042343a 100755 --- a/bin/xbps-src/main.sh +++ b/bin/xbps-src/main.sh @@ -220,7 +220,7 @@ build|configure) fi ;; build-pkg) - . $XBPS_SHUTILSDIR/binpkg.sh + . $XBPS_SHUTILSDIR/make-binpkg.sh . $XBPS_SHUTILSDIR/tmpl_funcs.sh if [ "$2" = "all" ]; then for f in $($XBPS_BIN_CMD list|awk '{print $1}'); do diff --git a/shutils/binpkg.sh b/shutils/binpkg.sh index 768eb06c915..032cac9d1b7 100644 --- a/shutils/binpkg.sh +++ b/shutils/binpkg.sh @@ -428,81 +428,3 @@ _EOF ;; esac } - -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 - - 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 - - binpkg=$pkgname-$version.$arch.xbps - 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. - # - run_rootcmd $use_sudo tar cfp $XBPS_DESTDIR/$binpkg ./INSTALL && \ - run_rootcmd $use_sudo tar rfp $XBPS_DESTDIR/$binpkg . \ - --exclude "./INSTALL" \ - --exclude "./var/db/xbps/metadata/*/flist" && \ - bzip2 -9 $XBPS_DESTDIR/$binpkg && \ - mv $XBPS_DESTDIR/$binpkg.bz2 $XBPS_DESTDIR/$binpkg - else - run_rootcmd $use_sudo tar cfp $XBPS_DESTDIR/$binpkg . \ - --exclude "./var/db/xbps/metadata/*/flist" && \ - bzip2 -9 $XBPS_DESTDIR/$binpkg && \ - mv $XBPS_DESTDIR/$binpkg.bz2 $XBPS_DESTDIR/$binpkg - fi - if [ $? -eq 0 ]; then - [ ! -d $pkgdir ] && mkdir -p $pkgdir - mv -f $XBPS_DESTDIR/$binpkg $pkgdir - echo "=> Built package: $binpkg" - fi - - return $? -} diff --git a/shutils/make-binpkg.sh b/shutils/make-binpkg.sh new file mode 100644 index 00000000000..400b4c114f3 --- /dev/null +++ b/shutils/make-binpkg.sh @@ -0,0 +1,102 @@ +#- +# 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 + + 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 + + binpkg=$pkgname-$version.$arch.xbps + 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. + # + run_rootcmd $use_sudo tar cfp $XBPS_DESTDIR/$binpkg ./INSTALL && \ + run_rootcmd $use_sudo tar rfp $XBPS_DESTDIR/$binpkg . \ + --exclude "./INSTALL" \ + --exclude "./var/db/xbps/metadata/*/flist" && \ + bzip2 -9 $XBPS_DESTDIR/$binpkg && \ + mv $XBPS_DESTDIR/$binpkg.bz2 $XBPS_DESTDIR/$binpkg + else + run_rootcmd $use_sudo tar cfp $XBPS_DESTDIR/$binpkg . \ + --exclude "./var/db/xbps/metadata/*/flist" && \ + bzip2 -9 $XBPS_DESTDIR/$binpkg && \ + mv $XBPS_DESTDIR/$binpkg.bz2 $XBPS_DESTDIR/$binpkg + fi + if [ $? -eq 0 ]; then + [ ! -d $pkgdir ] && mkdir -p $pkgdir + mv -f $XBPS_DESTDIR/$binpkg $pkgdir + echo "=> Built package: $binpkg" + fi + + return $? +}