2011-07-02 08:49:22 +00:00
|
|
|
#!/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
|
2011-07-02 09:33:59 +00:00
|
|
|
msg_red "vinstall: DESTDIR unset, can't continue...\n"
|
2011-07-02 08:49:22 +00:00
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ $# -lt 3 ]; then
|
2011-07-02 09:33:59 +00:00
|
|
|
msg_red "vinstall: 3 arguments expected: <file> <mode> <target-directory>\n"
|
2011-07-02 08:49:22 +00:00
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! -r "$file" ]; then
|
|
|
|
msg_red "vinstall: cannot find '$file'...\n"
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -z "$targetfile" ]; then
|
2011-07-02 09:33:59 +00:00
|
|
|
install -Dm${mode} ${file} "${DESTDIR}/${targetdir}/$(basename ${file})"
|
2011-07-02 08:49:22 +00:00
|
|
|
else
|
2011-07-02 09:33:59 +00:00
|
|
|
install -Dm${mode} ${file} "${DESTDIR}/${targetdir}/$(basename ${targetfile})"
|
2011-07-02 08:49:22 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
vcopy()
|
|
|
|
{
|
|
|
|
local files=$1
|
|
|
|
local targetdir="$2"
|
|
|
|
|
2011-07-02 09:33:59 +00:00
|
|
|
if [ -z "$DESTDIR" ]; then
|
|
|
|
msg_red "vcopy: DESTDIR unset, can't continue...\n"
|
|
|
|
return 1
|
|
|
|
fi
|
2011-07-02 08:49:22 +00:00
|
|
|
if [ $# -ne 2 ]; then
|
|
|
|
msg_red "vcopy: 2 arguments expected: <files> <target-directory>\n"
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
cp -a $files ${DESTDIR}/${targetdir}
|
|
|
|
}
|
|
|
|
|
2011-07-02 09:33:59 +00:00
|
|
|
vmove()
|
|
|
|
{
|
|
|
|
local files=$1
|
|
|
|
local targetdir="$2"
|
|
|
|
|
|
|
|
if [ -z "$DESTDIR" ]; then
|
|
|
|
msg_red "vmove: DESTDIR unset, can't continue...\n"
|
|
|
|
return 1
|
|
|
|
elif [ -z "$SRCPKGDESTDIR" ]; then
|
|
|
|
msg_red "vmove: SRCPKGDESTDIR unset, can't continue...\n"
|
|
|
|
return 1
|
|
|
|
fi
|
2011-07-02 10:11:01 +00:00
|
|
|
if [ $# -lt 1 ]; then
|
|
|
|
msg_red "vmove: 1 argument expected: <files>\n"
|
2011-07-02 09:33:59 +00:00
|
|
|
return 1
|
|
|
|
fi
|
2011-07-02 10:11:01 +00:00
|
|
|
if [ -z "${targetdir}" ]; then
|
2011-07-02 11:33:06 +00:00
|
|
|
[ ! -d ${DESTDIR} ] && install -d ${DESTDIR}
|
2011-07-02 10:11:01 +00:00
|
|
|
mv ${SRCPKGDESTDIR}/$files ${DESTDIR}
|
|
|
|
else
|
2011-07-02 11:33:06 +00:00
|
|
|
[ ! -d ${DESTDIR}/${targetdir} ] && vmkdir ${targetdir}
|
|
|
|
mv ${SRCPKGDESTDIR}/$files ${DESTDIR}/${targetdir}
|
2011-07-02 10:11:01 +00:00
|
|
|
fi
|
2011-07-02 09:33:59 +00:00
|
|
|
}
|
|
|
|
|
2011-07-02 08:49:22 +00:00
|
|
|
vmkdir()
|
|
|
|
{
|
|
|
|
local dir="$1"
|
|
|
|
local mode="$2"
|
|
|
|
|
|
|
|
if [ -z "$DESTDIR" ]; then
|
2011-07-02 09:33:59 +00:00
|
|
|
msg_red "vmkdir: DESTDIR unset, can't continue...\n"
|
2011-07-02 08:49:22 +00:00
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
2011-07-02 09:33:59 +00:00
|
|
|
if [ -z "$dir" ]; then
|
|
|
|
msg_red "vmkdir: directory argument unset.\n"
|
2011-07-02 08:49:22 +00:00
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -z "$mode" ]; then
|
|
|
|
install -d ${DESTDIR}/${dir}
|
|
|
|
else
|
2011-07-02 09:33:59 +00:00
|
|
|
install -dm${mode} ${DESTDIR}/${dir}
|
2011-07-02 08:49:22 +00:00
|
|
|
fi
|
|
|
|
}
|