diff options
-rw-r--r-- | locale/en_US/opkbuild.sh | 8 | ||||
-rw-r--r-- | src/ob-installplatconf.sh | 45 |
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 "${@}" |