diff options
author | P. J. McDermott <pjm@nac.net> | 2012-10-24 00:16:12 (EDT) |
---|---|---|
committer | P. J. McDermott <pjm@nac.net> | 2012-10-24 00:16:12 (EDT) |
commit | 9c492336b959a607c9e2dc09e7b16ce2e03fc60e (patch) | |
tree | 5eb4919406e511f6b37b6c1659cd867ee5b3dda4 | |
parent | c20bbe68307a79c5a08ece9cb7b752ff1555c73d (diff) |
Look both ways before installing documentation.
-rw-r--r-- | locale/en_US/opkbuild.sh | 2 | ||||
-rw-r--r-- | src/ob-installdocs.sh | 56 |
2 files changed, 34 insertions, 24 deletions
diff --git a/locale/en_US/opkbuild.sh b/locale/en_US/opkbuild.sh index c1c3ebd..6263ce0 100644 --- a/locale/en_US/opkbuild.sh +++ b/locale/en_US/opkbuild.sh @@ -101,7 +101,9 @@ msg_opkbuild_cant_copy_config_file='Can'\''t copy configuration file' # ob-installdocs msg_opkbuild_cant_get_doc_pkg='Can'\''t find package to provide documentation files' msg_opkbuild_cant_make_doc_dir='Can'\''t make documentation directory' +msg_opkbuild_docs_already_installed='Package documentation already installed into package "%s"' msg_opkbuild_installing_docs='Installing package documentation into package "%s"...' msg_opkbuild_cant_cp_doc_file='Can'\''t copy documentation file "%s"' +msg_opkbuild_docs_already_linked='Link to documentation already made in package "%s"' msg_opkbuild_linking_docs='Making link to documentation in package "%s"...' msg_opkbuild_cant_ln_doc_dir='Can'\''t make link to documentation directory' diff --git a/src/ob-installdocs.sh b/src/ob-installdocs.sh index 4cc522c..1e596e3 100644 --- a/src/ob-installdocs.sh +++ b/src/ob-installdocs.sh @@ -44,32 +44,40 @@ main() "${pkg}" "${OPK_BINARY_VERSION}")" data_doc_dir="${pkg}.data/${doc_dir%/}" if [ "${pkg}" = "${doc_pkg}" ]; then - ob_info "$(ob_get_msg 'installing_docs')" "${pkg}" - mkdir -p "${data_doc_dir}" || \ - ob_error "$(ob_get_msg 'cant_make_doc_dir')" - ob_get_doc_files | while read src dest; do - if [ -f "${src}" ]; then - if [ "${dest%/*}" != "${dest}" ]; then - mkdir -p "${data_doc_dir}/${dest%/*}" || \ - ob_error "$(ob_get_msg 'cant_make_doc_dir')" + if [ -d "${data_doc_dir}" ]; then + ob_info "$(ob_get_msg 'docs_already_installed')" "${pkg}" + else + ob_info "$(ob_get_msg 'installing_docs')" "${pkg}" + mkdir -p "${data_doc_dir}" || \ + ob_error "$(ob_get_msg 'cant_make_doc_dir')" + ob_get_doc_files | while read src dest; do + if [ -f "${src}" ]; then + if [ "${dest%/*}" != "${dest}" ]; then + mkdir -p "${data_doc_dir}/${dest%/*}" || \ + ob_error "$(ob_get_msg 'cant_make_doc_dir')" + fi + cp -R "${src}" "${data_doc_dir}/${dest}" || \ + ob_error "$(ob_get_msg 'cant_cp_doc_file')" "${src}" + elif [ -d "${src}" ]; then + if [ "${dest%/*}" != "${dest}" ]; then + mkdir -p "${data_doc_dir}/${dest%/*}" || \ + ob_error "$(ob_get_msg 'cant_make_doc_dir')" + fi + cp -R "${src}/." "${data_doc_dir}/${dest}" || \ + ob_error "$(ob_get_msg 'cant_cp_doc_file')" "${src}" fi - cp -R "${src}" "${data_doc_dir}/${dest}" || \ - ob_error "$(ob_get_msg 'cant_cp_doc_file')" "${src}" - elif [ -d "${src}" ]; then - if [ "${dest%/*}" != "${dest}" ]; then - mkdir -p "${data_doc_dir}/${dest%/*}" || \ - ob_error "$(ob_get_msg 'cant_make_doc_dir')" - fi - cp -R "${src}/." "${data_doc_dir}/${dest}" || \ - ob_error "$(ob_get_msg 'cant_cp_doc_file')" "${src}" - fi - done + done + fi else - ob_info "$(ob_get_msg 'linking_docs')" "${pkg}" - mkdir -p "${data_doc_dir%/*}" || \ - ob_error "$(ob_get_msg 'cant_make_doc_dir')" - ln -s "${doc_pkg_doc_dir}" "${data_doc_dir}" || \ - ob_error "$(ob_get_msg 'cant_ln_doc_dir')" + if [ -L "${data_doc_dir}" ]; then + ob_info "$(ob_get_msg 'docs_already_linked')" "${pkg}" + else + ob_info "$(ob_get_msg 'linking_docs')" "${pkg}" + mkdir -p "${data_doc_dir%/*}" || \ + ob_error "$(ob_get_msg 'cant_make_doc_dir')" + ln -s "${doc_pkg_doc_dir}" "${data_doc_dir}" || \ + ob_error "$(ob_get_msg 'cant_ln_doc_dir')" + fi fi done } |