#!/usr/bin/env bash# vim: set sw=4 sts=4 et :# Copyright (c) 2006 Stephen Bennett## Based in part upon dohtml from Portage, which is Copyright 1995-2005# Gentoo Foundation and distributed under the terms of the GNU General# Public License v2.## This file is part of the Paludis package manager. Paludis is free software;# you can redistribute it and/or modify it under the terms of the GNU General# Public License as published by the Free Software Foundation; either version# 2 of the License, or (at your option) any later version.## Paludis is distributed in the hope that it will be useful, but WITHOUT ANY# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more# details.## You should have received a copy of the GNU General Public License along with# this program; if not, write to the Free Software Foundation, Inc., 59 Temple# Place, Suite 330, Boston, MA 02111-1307 USAsource${PALUDIS_EBUILD_DIR}/0/list_functions.bash
if[[ ! -d ${!PALUDIS_IMAGE_DIR_VAR}]];thenecho"${0}: \${${PALUDIS_IMAGE_DIR_VAR}} not valid; aborting" >&2exit247fiallowed_exts="png gif html htm jpg css jps"disallowed_dirs=""allowed_files=""recurse=0doc_prefix=""args=()
split_names(){list=$1if[[${list}== *,* ]];thenecho -n "${list%%,*} "
split_names ${list#*,}elseecho${list}fi}
parse_args(){while[[${#} -gt 0]];docase$1 in
-r)recurse=1;;
-V)verbose=1;;
-A)allowed_exts="${allowed_exts}$(split_names $2)"shift;;
-a)allowed_exts="$(split_names $2)"shift;;
-f)allowed_files="$(split_names $2)"shift;;
-x)disallowed_dirs="$(split_names $2)"shift;;
-p)doc_prefix="$2"shift;;
*/)args=("${args[@]}""$1"* );;
*)args=("${args[@]}""$1");;esacshiftdone}
install_file(){localbn=${1}localdn=${2}localprefix=${3}localret=0path=${bn}[[ -n ${prefix}]]&&path="${prefix}/${path}"[[ -n ${dn}]]&&path="${dn}/${path}"[[ -z ${DOCDESTTREE}]]&&DOCDESTTREE="html"dir="${!PALUDIS_IMAGE_DIR_VAR}usr/share/doc/${!PALUDIS_NAME_VERSION_REVISION_VAR}/${DOCDESTTREE}/${doc_prefix}/${prefix}"if[[ -f ${path}]];thenext="$(basename ${path})"ext="${ext##*.}"if([[ -n ${ext}]]&& has $ext$allowed_exts)|| has $bn$allowed_filesthen[[ ! -d ${dir}]]&& install -d "${dir}"echo"install -m0644 ${path}${dir}"
install -m0644 "${path}""${dir}/${bn}"fielif[[$recurse==1&& -d ${path}]]&&
! has "${bn}"${disallowed_dirs};thenfor f in ${path}/*;dopfx=${bn}[[ -n ${prefix}]]&&pfx="${prefix}/${pfx}"
install_file "$(basename "${f}")""${dn}""${pfx}"((ret+=$?))doneelse(( ++ret ))fireturn${ret}}
parse_args "$@"retval=0for i in "${args[@]}";do
install_file "$(basename "${i}")""$(dirname "${i}")"((retval+=$?))doneexit$retval