summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorP. J. McDermott <pjm@nac.net>2012-10-03 17:04:40 (EDT)
committer P. J. McDermott <pjm@nac.net>2012-10-03 17:04:40 (EDT)
commit0f5ef3a2873dbe1c7dc3a0db5419737bab680384 (patch)
treef93ebf7a3b6afd52240f056111e77360d5e34b73
parent69caab6f35231ac709a9b259b18b1adb594c3590 (diff)
Finish implementation of ob-installplatconf.
-rw-r--r--locale/en_US/opkbuild.sh8
-rw-r--r--src/ob-installplatconf.sh45
2 files changed, 53 insertions, 0 deletions
diff --git a/locale/en_US/opkbuild.sh b/locale/en_US/opkbuild.sh
index 2bc3e7f..75d32fd 100644
--- a/locale/en_US/opkbuild.sh
+++ b/locale/en_US/opkbuild.sh
@@ -81,3 +81,11 @@ msg_opkbuild_cant_move_native='Can'\''t move extracted upstream source directory
msg_opkbuild_applying_patch='Applying patch "%s"...'
msg_opkbuild_cant_apply_patch='Can'\''t apply patch "%s"'
msg_opkbuild_no_patches='No patches to be applied'
+
+# ob-copyconfig
+msg_opkbuild_no_plat_config='No config files to be copied'
+msg_opkbuild_bad_config_syntax='Syntax error in platform configuration file list "%s"'
+msg_opkbuild_cant_make_config_dest_dir='Can'\''t make directory "%s" for platform configuration'
+msg_opkbuild_no_config_dir='No platform configuration files found'
+msg_opkbuild_copying_config_file='Copying configuration file "%s" to "%s"...'
+msg_opkbuild_cant_copy_config_file='Can'\''t copy configuration file'
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 "${@}"