diff options
-rw-r--r-- | Makefile.in | 2 | ||||
-rwxr-xr-x | configure | 3 | ||||
-rw-r--r-- | lib/buildsystem.sh | 4 | ||||
-rw-r--r-- | lib/common.sh | 8 | ||||
-rw-r--r-- | lib/load.sh | 3 | ||||
-rw-r--r-- | lib/local.mk | 2 | ||||
-rw-r--r-- | lib/locale.sh | 121 | ||||
-rw-r--r-- | lib/output.sh | 51 | ||||
-rw-r--r-- | src/oh-architecture.sh | 2 | ||||
-rw-r--r-- | src/oh-autobuild.sh | 2 | ||||
-rw-r--r-- | src/oh-autoclean.sh | 2 | ||||
-rw-r--r-- | src/oh-autoconfigure.sh | 2 | ||||
-rw-r--r-- | src/oh-autoinstall.sh | 2 | ||||
-rw-r--r-- | src/oh-autotest.sh | 2 | ||||
-rw-r--r-- | src/oh-fixperms.sh | 12 | ||||
-rw-r--r-- | src/oh-installfiles.sh | 6 | ||||
-rw-r--r-- | src/oh-strip.sh | 8 |
17 files changed, 199 insertions, 33 deletions
diff --git a/Makefile.in b/Makefile.in index a13e63b..2772850 100644 --- a/Makefile.in +++ b/Makefile.in @@ -37,7 +37,6 @@ archtabdir = @archtabdir@ DESTDIR = / sh = @sh@ -libopkbuild_1 = @libopkbuild_1@ multiarch_libdir = @multiarch_libdir@ @@ -91,7 +90,6 @@ script = \ s&@@LOCALEDIR@@&$(localedir)&;\ s&@@ARCHTABDIR@@&$(archtabdir)&;\ s&@@SH@@&$(sh)&;\ - s&@@LIBOPKBUILD_1@@&$(libopkbuild_1)&;\ s&@@MULTIARCH_LIBDIR@@&$(multiarch_libdir)&; .SUFFIXES: @@ -44,7 +44,6 @@ sh make ' dep_libs=' -libopkbuild.1 ' long_opts_with_args=' @@ -180,8 +179,6 @@ Features: Dependencies: --with-sh=PATH use sh at PATH - --with-libopkbuild.1=PATH - use libopkbuild.1 at PATH EOF } diff --git a/lib/buildsystem.sh b/lib/buildsystem.sh index 8e6bf0a..39dcceb 100644 --- a/lib/buildsystem.sh +++ b/lib/buildsystem.sh @@ -114,7 +114,7 @@ oh_buildsystem_find() done fi - ob_warn "$(ob_get_msg 'no_capable_build_sys')" + oh_warn "$(oh_get_msg 'no_capable_build_sys')" return 1 } @@ -165,6 +165,6 @@ oh_buildsystem_arch() fi done - ob_warn "$(ob_get_msg 'no_capable_host_arch')" + oh_warn "$(oh_get_msg 'no_capable_host_arch')" return 1 } diff --git a/lib/common.sh b/lib/common.sh index c9fdc22..52833f4 100644 --- a/lib/common.sh +++ b/lib/common.sh @@ -22,12 +22,12 @@ _OH_COMMON_SM='true' oh_init() { - ob_use locale - ob_use output + oh_use locale + oh_use output # Since nothing other than opkhelper is supposed to use libopkhelper, we can # do strange things like affecting application-wide locale settings from the # library and assume that no one will play with them. - ob_set_locale_path '@@LOCALEDIR@@/%s/LC_MESSAGES/%s.ms' - ob_set_text_domain 'opkhelper' + oh_set_locale_path '@@LOCALEDIR@@/%s/LC_MESSAGES/%s.ms' + oh_set_text_domain 'opkhelper' } diff --git a/lib/load.sh b/lib/load.sh index 6dcec88..9af4958 100644 --- a/lib/load.sh +++ b/lib/load.sh @@ -24,9 +24,6 @@ _OH_LOAD_SM='true' # We have to manually load the "common" module so we can use it in oh_use. . '@@PKGLIBDIR@@/common.sm' -# Assume that every library module and utility uses libopkbuild. -. '@@LIBOPKBUILD_1@@/load.sm' - oh_use() { local module= diff --git a/lib/local.mk b/lib/local.mk index e249963..0f7c62d 100644 --- a/lib/local.mk +++ b/lib/local.mk @@ -19,5 +19,7 @@ pkglib_srcs = \ lib/load.sh \ lib/common.sh \ + lib/output.sh \ + lib/locale.sh \ lib/buildsystem.sh \ $(lib_buildsystem_srcs) diff --git a/lib/locale.sh b/lib/locale.sh new file mode 100644 index 0000000..c8075ea --- /dev/null +++ b/lib/locale.sh @@ -0,0 +1,121 @@ +# opkbuild +# lib/locale +# Locale functions. +# +# 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 2 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 <http://www.gnu.org/licenses/>. + +[ -n "${_OH_LOCALE_SM}" ] && return 0 +_OH_LOCALE_SM='true' + +oh_use output + +_OH_DEFAULT_LOCALE='en_US' +_OH_INTERNAL_TEXT_DOMAIN='opkhelper' +_OH_TEXT_DOMAIN= +_OH_LOCALE_PATH='@@LOCALEDIR@@/%s/LC_MESSAGES/%s.ms' + +oh_get_text_domain() +{ + if [ ${#} -ne 0 ]; then + return 125 + fi + + echo "${_OH_TEXT_DOMAIN}" + return 0 +} + +oh_set_text_domain() +{ + if [ ${#} -eq 1 ]; then + _OH_TEXT_DOMAIN="${1}" + else + return 125 + fi + + # Make sure LC_MESSAGES is set. + if [ -z "${LC_MESSAGES}" ]; then + if [ -n "${LC_ALL}" ]; then + LC_MESSAGES="${LC_ALL}" + elif [ -n "${LANG}" ]; then + LC_MESSAGES="${LANG}" + else + LC_MESSAGES="${_OH_DEFAULT_LOCALE}" + fi + fi + + # TODO: Exit early if domain's messages have already been loaded. + + # Try to load the messages. + if ! _oh_try_load_messages "${LC_MESSAGES%.*}"; then + if ! _oh_try_load_messages "${LC_MESSAGES%_*}"; then + if ! _oh_try_load_messages "${_OH_DEFAULT_LOCALE}"; then + oh_warn 'Cannot load messages in "%s" domain.' \ + "${_OH_TEXT_DOMAIN}" + return 1 + fi + fi + fi + + return 0 +} + +oh_set_locale_path() +{ + local format= + + if [ ${#} -eq 1 ]; then + format="${1}" + else + return 125 + fi + + _OH_LOCALE_PATH="${format}" + + return 0 +} + +oh_get_msg() +{ + local msgid= + + if [ ${#} -eq 1 ]; then + msgid="${1}" + else + return 125 + fi + + IFS= eval echo \$\{"msg_${_OH_TEXT_DOMAIN}_${msgid}"\} + + return 0 +} + +_oh_try_load_messages() +{ + local locale= + local ms= + + locale="${1}" + ms="$(printf "${_OH_LOCALE_PATH}" \ + "${locale}" "${_OH_TEXT_DOMAIN}")" + + if [ -f "${ms}" ]; then + . "${ms}" + else + return 1 + fi + + return 0 +} diff --git a/lib/output.sh b/lib/output.sh new file mode 100644 index 0000000..9459e37 --- /dev/null +++ b/lib/output.sh @@ -0,0 +1,51 @@ +# opkhelper +# lib/output +# Functions for printing messages. +# +# Copyright (C) 2013-2014 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 2 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 <http://www.gnu.org/licenses/>. + +[ -n "${_OH_OUTPUT_SM}" ] && return 0 +_OH_OUTPUT_SM='true' + +oh_error() +{ + local fmt="${1}" + shift 1 + + printf "%s: Error: ${fmt}\n" "${0##*/}" "${@}" >&2 + + exit 1 +} + +oh_warn() +{ + local fmt="${1}" + shift 1 + + printf "%s: Warning: ${fmt}\n" "${0##*/}" "${@}" >&2 + + return 0 +} + +oh_info() +{ + local fmt="${1}" + shift 1 + + printf "%s: ${fmt}\n" "${0##*/}" "${@}" >&2 + + return 0 +} diff --git a/src/oh-architecture.sh b/src/oh-architecture.sh index b026185..4ba5929 100644 --- a/src/oh-architecture.sh +++ b/src/oh-architecture.sh @@ -39,7 +39,7 @@ main() oh_set_buildsystem_option 'build-dir' "${OPTARG}" ;; ?) - ob_error "$(ob_get_msg 'bad_opt')" + oh_error "$(oh_get_msg 'bad_opt')" exit 1 ;; esac diff --git a/src/oh-autobuild.sh b/src/oh-autobuild.sh index c85dd0f..cc365bc 100644 --- a/src/oh-autobuild.sh +++ b/src/oh-autobuild.sh @@ -42,7 +42,7 @@ main() oh_set_buildsystem_option 'build-target' "${OPTARG}" ;; ?) - ob_error "$(ob_get_msg 'bad_opt')" + oh_error "$(oh_get_msg 'bad_opt')" exit 1 ;; esac diff --git a/src/oh-autoclean.sh b/src/oh-autoclean.sh index cf9c8d3..b57b6f1 100644 --- a/src/oh-autoclean.sh +++ b/src/oh-autoclean.sh @@ -39,7 +39,7 @@ main() oh_set_buildsystem_option 'build-dir' "${OPTARG}" ;; ?) - ob_error "$(ob_get_msg 'bad_opt')" + oh_error "$(oh_get_msg 'bad_opt')" exit 1 ;; esac diff --git a/src/oh-autoconfigure.sh b/src/oh-autoconfigure.sh index 3e37228..af18b87 100644 --- a/src/oh-autoconfigure.sh +++ b/src/oh-autoconfigure.sh @@ -42,7 +42,7 @@ main() oh_set_buildsystem_option 'target-arch' "${OPTARG}" ;; ?) - ob_error "$(ob_get_msg 'bad_opt')" + oh_error "$(oh_get_msg 'bad_opt')" exit 1 ;; esac diff --git a/src/oh-autoinstall.sh b/src/oh-autoinstall.sh index efe8500..6dbb532 100644 --- a/src/oh-autoinstall.sh +++ b/src/oh-autoinstall.sh @@ -45,7 +45,7 @@ main() oh_set_buildsystem_option 'build-target' "${OPTARG}" ;; ?) - ob_error "$(ob_get_msg 'bad_opt')" + oh_error "$(oh_get_msg 'bad_opt')" exit 1 ;; esac diff --git a/src/oh-autotest.sh b/src/oh-autotest.sh index aff0999..f11414d 100644 --- a/src/oh-autotest.sh +++ b/src/oh-autotest.sh @@ -36,7 +36,7 @@ main() oh_set_buildsystem_option 'build-dir' "${OPTARG}" ;; ?) - ob_error "$(ob_get_msg 'bad_opt')" + oh_error "$(oh_get_msg 'bad_opt')" exit 1 ;; esac diff --git a/src/oh-fixperms.sh b/src/oh-fixperms.sh index 308e60a..71dda4d 100644 --- a/src/oh-fixperms.sh +++ b/src/oh-fixperms.sh @@ -33,34 +33,34 @@ main() dir="${OPTARG}" ;; ?) - ob_error "$(ob_get_msg 'bad_opt')" + oh_error "$(oh_get_msg 'bad_opt')" exit 1 ;; esac done # Ensure that everything is owned by UID 0 and GID 0. - ob_info "$(ob_get_msg 'chown')" + oh_info "$(oh_get_msg 'chown')" find "${dir}" \ -exec 'chown' '-h' '0:0' '{}' ';' # Ensure that shared libraries, static libraries, and libtool archives have # a rw-r--r-- mode. - ob_info "$(ob_get_msg 'chmod_lib')" + oh_info "$(oh_get_msg 'chmod_lib')" find "${dir}" -type f -a ! -perm 644 \ -a \( -name '*.so*' -o -name '*.a' -o -name '*.la' \) \ -exec 'chmod' '644' '{}' ';' # Ensure that header files have a rw-r--r-- mode. if [ -d "${dir}/usr/include" ]; then - ob_info "$(ob_get_msg 'chmod_include')" + oh_info "$(oh_get_msg 'chmod_include')" find "${dir}/usr/include" -type f -a ! -perm 644 \ -exec 'chmod' '644' '{}' ';' fi # Ensure that manual pages have a rw-r--r-- mode. if [ -d "${dir}/usr/share/man" ]; then - ob_info "$(ob_get_msg 'chmod_man')" + oh_info "$(oh_get_msg 'chmod_man')" find "${dir}/usr/share/man" -type f -a ! -perm 644 \ -exec 'chmod' '644' '{}' ';' fi @@ -68,7 +68,7 @@ main() # Ensure that binary programs and service scripts have a rwxr-xr-x mode. for bindir in /usr/sbin /usr/bin /sbin /bin /usr/games /etc/init.d; do if [ -d "${dir}/${bindir}" ]; then - ob_info "$(ob_get_msg 'chmod_bin')" "${bindir}" + oh_info "$(oh_get_msg 'chmod_bin')" "${bindir}" find "${dir}/${bindir}" -type f -a ! -perm 755 \ -exec 'chmod' '755' '{}' ';' fi diff --git a/src/oh-installfiles.sh b/src/oh-installfiles.sh index 9848ca1..0cdfecf 100644 --- a/src/oh-installfiles.sh +++ b/src/oh-installfiles.sh @@ -36,7 +36,7 @@ main() dir="${OPTARG}" ;; ?) - ob_error "$(ob_get_msg 'bad_opt')" + oh_error "$(oh_get_msg 'bad_opt')" exit 1 ;; esac @@ -45,7 +45,7 @@ main() for pkg in ${OPK_PACKAGES}; do [ -r "../${pkg}.pkg/files" ] || continue - ob_info "$(ob_get_msg 'installing_files')" "${pkg}" + oh_info "$(oh_get_msg 'installing_files')" "${pkg}" mkdir -p "${pkg}.data" chmod 755 "${pkg}.data" @@ -63,7 +63,7 @@ main() # TODO: See above. Count links. if [ "$(find "${dir}" -type f | wc -l)" -gt 0 ]; then - ob_warn "$(ob_get_msg 'files_not_installed')" + oh_warn "$(oh_get_msg 'files_not_installed')" fi } diff --git a/src/oh-strip.sh b/src/oh-strip.sh index 1c21545..7b47d6c 100644 --- a/src/oh-strip.sh +++ b/src/oh-strip.sh @@ -40,7 +40,7 @@ main() keep_debug='true' ;; ?) - ob_error "$(ob_get_msg 'bad_opt')" + oh_error "$(oh_get_msg 'bad_opt')" exit 1 ;; esac @@ -78,7 +78,7 @@ strip_so() file="${1}" debug='' - ob_info "$(ob_get_msg 'strip_so')" "${file}" + oh_info "$(oh_get_msg 'strip_so')" "${file}" if ${keep_debug}; then debug="$(keep_debug "${file}")" @@ -97,7 +97,7 @@ strip_exe() file="${1}" debug='' - ob_info "$(ob_get_msg 'strip_exe')" "${file}" + oh_info "$(oh_get_msg 'strip_exe')" "${file}" if ${keep_debug}; then debug="$(keep_debug "${file}")" @@ -115,7 +115,7 @@ strip_a() { file="${1}" - ob_info "$(ob_get_msg 'strip_a')" "${file}" + oh_info "$(oh_get_msg 'strip_a')" "${file}" ${STRIP} --strip-debug "${dir}/${file}" } |