summaryrefslogtreecommitdiffstats
path: root/src/ob-installplatconf.sh
diff options
context:
space:
mode:
Diffstat (limited to 'src/ob-installplatconf.sh')
-rw-r--r--src/ob-installplatconf.sh45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/ob-installplatconf.sh b/src/ob-installplatconf.sh
index 5db0e22..147a958 100644
--- a/src/ob-installplatconf.sh
+++ b/src/ob-installplatconf.sh
@@ -31,6 +31,51 @@ main()
ob_init_package '..'
ob_parse_package_metadata -c '.opkbuild.cache'
+
+ copied='false'
+
+ if [ -r '../config' ]; then
+ copy_config 'config' '.'
+ copied='true'
+ fi
+
+ for bin_config in ../*.pkg/config; do
+ copy_config "${bin_config#../}" 'dest'
+ copied='true'
+ done
+
+ "${copied}" || ob_info "$(ob_get_msg 'no_plat_config')"
+}
+
+copy_config()
+{
+ list="${1}"
+ dest_base="${2}"
+
+ while read -r src dest; do
+ if [ -z "${src}" -o -z "${dest}" ]; then
+ ob_error "$(ob_get_msg 'bad_config_syntax')" "${list}"
+ fi
+ # Make sure the destination directory exists.
+ mkdir -p "${dest_base}/${dest%/*}" || \
+ ob_error "$(ob_get_msg 'cant_make_config_dest_dir')" "${dest%/*}"
+ # Find the config package files.
+ # TODO: Don't hardcode path.
+ config_dir_base="/usr/share/config/${OB_HOST_PLATFORM}/${OB_SOURCE}"
+ if [ -d "${config_dir_base}-${OB_SOURCE_VERSION_UPSTREAM}" ]; then
+ src_base="${config_dir_base}-${OB_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.
+ ob_error "$(ob_get_msg 'no_config_dir')"
+ fi
+ # Copy the config file(s).
+ ob_info "$(ob_get_msg 'copying_config_file')" "${src}" "${dest}"
+ cp -p "${src_base}/${src}" "${dest_base}/${dest}" || \
+ ob_error "$(ob_get_msg 'cant_copy_config_file')"
+ done <"../${list}"
}
main "${@}"