#!@@SH@@ # # opkhelper # src/oh-copyconfig # Copy build-time or run-time platform configuration files. # # Copyright (C) 2012 Patrick "P. J." McDermott # # This program 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 3 of the License, or # (at your option) any later version. # # This program 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, see . . @@LIBDIR@@/messages . @@LIBDIR@@/locale main() { oh_locale_set oh_set_source_dir .. if [ "${#}" -ne 0 ]; then oh_usage exit 1 fi copied=false if [ -f ../config ]; then copy_config config '.' copied=true fi for bin_config in ../*.pkg/config; do copy_config "${bin_config#../}" 'dest' copied=true done "${copied}" || oh_info "${oh_str_no_plat_config}" } copy_config() { list="${1}" dest_base="${2}" while read -r src dest; do if [ -z "${src}" -o -z "${dest}" ]; then oh_error "${oh_str_bad_config_syntax}" "${list}" fi # Make sure the destination directory exists. mkdir -p "${dest_base}/${dest%/*}" || \ oh_error "${oh_str_cant_make_config_dest_dir}" "${dest%/*}" # Find the config package files. # TODO: Don't hardcode path. config_dir_base="/usr/share/config/${OH_HOST_PLATFORM}/${OH_SOURCE}" if [ -d "${config_dir_base}-${OH_SOURCE_VERSION_UPSTREAM}" ]; then src_base="${config_dir_base}-${OH_SOURCE_VERSION_UPSTREAM}" elif [ -d "${config_dir_base}" ]; then src_base="${config_dir_base}" else # This shouldn't happen unless the package maintainer neglected to # add the config package to the package's Build-Depends field. oh_error "${oh_str_no_config_dir}" fi # Copy the config file(s). oh_info "${oh_str_copying_config_file}" "${src}" "${dest}" cp -p "${src_base}/${src}" "${dest_base}/${dest}" || \ oh_error "${oh_str_cant_copy_config_file}" done <"../${list}" } main "${@}"