diff --git a/xbps-src/shutils/install_files.sh b/xbps-src/shutils/install_files.sh new file mode 100644 index 00000000000..755e9ca7af1 --- /dev/null +++ b/xbps-src/shutils/install_files.sh @@ -0,0 +1,89 @@ +#!/bin/sh +#- +# Copyright (c) 2011 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. +#- + +vinstall() +{ + local file="$1" + local mode="$2" + local targetdir="$3" + local targetfile="$4" + + if [ -z "$DESTDIR" ]; then + msg_red "vinstall: package DESTDIR unset, can't continue...\n" + return 1 + fi + + if [ $# -lt 3 ]; then + msg_red "vinstall: 3 arguments expected, only provided $#\n" + return 1 + fi + + if [ ! -r "$file" ]; then + msg_red "vinstall: cannot find '$file'...\n" + return 1 + fi + + if [ -z "$targetfile" ]; then + install -Dm${mode} ${file} ${DESTDIR}/${targetdir}/${file} + else + install -Dm${mode} ${file} ${DESTDIR}/${targetdir}/${targetfile} + fi +} + +vcopy() +{ + local files=$1 + local targetdir="$2" + + if [ $# -ne 2 ]; then + msg_red "vcopy: 2 arguments expected: \n" + return 1 + fi + + cp -a $files ${DESTDIR}/${targetdir} +} + +vmkdir() +{ + local dir="$1" + local mode="$2" + + if [ -z "$DESTDIR" ]; then + msg_red "vmkdir: package DESTDIR unset, can't continue...\n" + return 1 + fi + + if [ $# -lt 1 ]; then + msg_red "vmkdir: 1 arguments expected: \n" + return 1 + fi + + if [ -z "$mode" ]; then + install -d ${DESTDIR}/${dir} + else + install -d -m${mode} ${DESTDIR}/${dir} + fi +} diff --git a/xbps-src/shutils/tmpl_funcs.sh.in b/xbps-src/shutils/tmpl_funcs.sh.in index b700d84c1c9..0978b9e0ced 100644 --- a/xbps-src/shutils/tmpl_funcs.sh.in +++ b/xbps-src/shutils/tmpl_funcs.sh.in @@ -284,6 +284,8 @@ set_tmpl_common_vars() { [ -z "$pkgname" ] && return 1 + . ${XBPS_SHUTILSDIR}/install_files.sh + FILESDIR=$XBPS_SRCPKGDIR/$pkgname/files PATCHESDIR=$XBPS_SRCPKGDIR/$pkgname/patches DESTDIR=${XBPS_DESTDIR}/${pkgname}-${version}