From 63fa875896f8fc883580062180636c9f3b780330 Mon Sep 17 00:00:00 2001 From: P. J. McDermott Date: Tue, 24 Apr 2012 19:33:27 -0400 Subject: Make oh-* tools consistently use message library. --- diff --git a/src/oh-applypatches.sh b/src/oh-applypatches.sh index a688f32..ac51da9 100644 --- a/src/oh-applypatches.sh +++ b/src/oh-applypatches.sh @@ -19,6 +19,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . +. @@LIBDIR@@/opkhelper/messages + print_usage() { printf 'Usage: %s\n' "$1" @@ -34,7 +36,7 @@ applied=false if [ -d ../patches ]; then # Iterate over patches ordered alphabetically by name. for patch in $(ls -1 ../patches | sort); do - printf 'oh-applypatches: Applying patch "%s"...\n' "${patch}" + oh_info 'Applying patch "%s"...' "${patch}" patch -N -p 1 -u -d src -i "../../patches/${patch}" || exit 1 applied=true done @@ -42,5 +44,5 @@ fi # Provide output even if patches directory didn't exist or had no visible files. if ! ${applied}; then - printf 'oh-applypatches: No patches to be applied.\n' + oh_info 'No patches to be applied' fi diff --git a/src/oh-buildopk.sh b/src/oh-buildopk.sh index 8eefa95..e8d840e 100644 --- a/src/oh-buildopk.sh +++ b/src/oh-buildopk.sh @@ -21,6 +21,7 @@ . @@LIBDIR@@/opkhelper/controlfields . @@LIBDIR@@/opkhelper/architecture +. @@LIBDIR@@/opkhelper/messages print_usage() { @@ -78,7 +79,7 @@ else # Iterate over packages. while [ ${#} -gt 0 ]; do - printf 'oh-buildopk: Packing package "%s"...\n' "${1}" + oh_info 'Packing package "%s"...' "${1}" arch="$(oh_get_package_architecture ${1})" diff --git a/src/oh-checkbuilddeps.sh b/src/oh-checkbuilddeps.sh index 1f68728..fac59dd 100644 --- a/src/oh-checkbuilddeps.sh +++ b/src/oh-checkbuilddeps.sh @@ -20,6 +20,7 @@ # along with this program. If not, see . . @@LIBDIR@@/opkhelper/controlfields +. @@LIBDIR@@/opkhelper/messages print_usage() { @@ -59,7 +60,7 @@ if [ ${#} -ne 0 ]; then exit 1 fi -printf 'oh-checkbuilddeps: Checking build dependencies...\n' +oh_info 'Checking build dependencies...' IFS=',' for dep in $(oh_get_field Build-Depends); do @@ -80,9 +81,7 @@ for dep in $(oh_get_field Build-Depends); do # TODO: Test this. if [ -z "$(opkg status "${dep}" | grep "^Package: ${dep}")" ]; then - printf 'oh-checkbuilddeps: Error: Dependency %s not installed.\n' \ - "${dep}" >&2 - exit 1 + oh_error 'Dependency %s not installed' "${dep}" fi done diff --git a/src/oh-copyconfig.sh b/src/oh-copyconfig.sh index 1ca7783..c81a1a3 100644 --- a/src/oh-copyconfig.sh +++ b/src/oh-copyconfig.sh @@ -19,24 +19,20 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . +. @@LIBDIR@@/opkhelper/messages + print_usage() { printf 'Usage: %s\n' "$1" } -error() -{ - printf 'oh-copyconfig: Error: %s\n' "${1}" >&2 - exit 1 -} - if [ ! -f ../config ]; then - printf 'oh-copyconfig: No config files to copy.\n' + oh_info 'No config files to copy' exit 0 fi if [ -z "${OH_HOST_PLATFORM}" ]; then - error 'No target platform defined' + oh_error 'No target platform defined' fi if [ ${#} -ne 0 ]; then @@ -46,7 +42,7 @@ fi while read -r type src dest; do if [ -z "${type}" -o -z "${src}" -o -z "${dest}" ]; then - error 'Invalid syntax in config list' + oh_error 'Invalid syntax in config list' fi case "${type}" in runtime) @@ -58,7 +54,7 @@ while read -r type src dest; do full_dest="${dest}" ;; *) - error "Invalid config type \"${type}\"" + oh_error 'Invalid config type "%s"' "${type}" ;; esac # Make sure the destination directory exists. @@ -71,10 +67,10 @@ while read -r type src dest; do else # This shouldn't happen unless the package maintainer neglected to add # the config package to the package's Build-Depends field. - error 'No platform config directory found' + oh_error 'No platform config directory found' fi # Copy the config file(s). - printf 'oh-copyconfig: Copying "%s" to "%s"...\n' "${src}" "${dest}" + oh_info 'Copying "%s" to "%s"...' "${src}" "${dest}" mkdir -p "$(dirname "${full_dest}")" - cp -p "${full_src}" "${full_dest}" || error "Cannot copy \"${src}\"" + cp -p "${full_src}" "${full_dest}" || oh_error 'Cannot copy "%s"' "${src}" done < ../config diff --git a/src/oh-gencontrol.sh b/src/oh-gencontrol.sh index 207240f..4cc48e5 100644 --- a/src/oh-gencontrol.sh +++ b/src/oh-gencontrol.sh @@ -21,6 +21,7 @@ . @@LIBDIR@@/opkhelper/controlfields . @@LIBDIR@@/opkhelper/architecture +. @@LIBDIR@@/opkhelper/messages print_usage() { @@ -29,15 +30,12 @@ print_usage() missing_field() { - printf 'oh-gencontrol: Error: Missing field "%s" in control file.\n' \ - "${1}" >&2 - exit 2 + oh_error 'Missing field "%s" in control file' "${1}" } invalid_pkg_name() { - printf 'oh-gencontrol: Error: Invalid package name: "%s"\n' "${1}" >&2 - exit 2 + oh_error 'Invalid package name: "%s"' "${1}" } copy_required_field() @@ -67,8 +65,7 @@ gen_control_src() srcpkg=$(oh_get_field Source) || missing_field Source oh_validate_pkg_name "${srcpkg}" || invalid_pkg_name "${srcpkg}" - printf 'oh-gencontrol: Generating control directory for package "%s"...\n' \ - "${srcpkg}-src" + oh_info 'Generating control directory for package "%s"...' "${srcpkg}-src" control_dir="${srcpkg}-src.control" control="${control_dir}/control" @@ -92,8 +89,7 @@ gen_control_bin() binpkg="${1}" oh_validate_pkg_name "${binpkg}" || invalid_pkg_name "${binpkg}" - printf 'oh-gencontrol: Generating control directory for package "%s"...\n' \ - "${binpkg}" + oh_info 'Generating control directory for package "%s"...' "${binpkg}" data_dir="${binpkg}.data" control_dir="${binpkg}.control" diff --git a/src/oh-installdocs.sh b/src/oh-installdocs.sh index 452bff5..f950651 100644 --- a/src/oh-installdocs.sh +++ b/src/oh-installdocs.sh @@ -19,17 +19,13 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . +. @@LIBDIR@@/opkhelper/messages + print_usage() { printf 'Usage: %s providing_pkg\n' "$1" } -error() -{ - printf 'oh-installdocs: Error: %s\n' "${1}" >&2 - exit 1 -} - if [ ${#} -ne 1 ]; then print_usage ${0} >&2 exit 1 @@ -41,21 +37,19 @@ for pkgdir in *.data/; do mkdir -p ${pkg}.data/usr/share/doc/ if [ ${pkg} = ${1} ]; then # Make the providing package provide the documentation files. - printf 'oh-installdocs: Installing package documentation into package "%s"...\n' \ - "${pkg}" + oh_info 'Installing package documentation into package "%s"...' "${pkg}" mkdir -p ${pkg}.data/usr/share/doc/${pkg} - [ ! -f ../copyright ] && error 'Missing "copyright" file' - [ ! -f ../changelog ] && error 'Missing "changelog" file' + [ ! -f ../copyright ] && oh_error 'Missing "copyright" file' + [ ! -f ../changelog ] && oh_error 'Missing "changelog" file' cp ../copyright ${pkgdir}/usr/share/doc/${pkg}/copyright || \ - error 'Cannot copy documentation files' + oh_error 'Cannot copy documentation files' cp ../changelog ${pkgdir}/usr/share/doc/${pkg}/changelog.dist || \ - error 'Cannot copy documentation files' + oh_error 'Cannot copy documentation files' else # Make dependent packages link to the providing package's documentation # directory. - printf 'oh-installdocs: Making link to documentation in package "%s"...\n' \ - "${pkg}" + oh_info 'Making link to documentation in package "%s"...' "${pkg}" ln -s /usr/share/doc/${1} ${pkgdir}/usr/share/doc/${pkg} || \ - error 'Cannot make link to documentation files' + oh_error 'Cannot make link to documentation files' fi done diff --git a/src/oh-installfiles.sh b/src/oh-installfiles.sh index 41e9e27..e0da7c8 100644 --- a/src/oh-installfiles.sh +++ b/src/oh-installfiles.sh @@ -19,6 +19,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . +. @@LIBDIR@@/opkhelper/messages + print_usage() { printf 'Usage: %s pkgname...\n' "$1" @@ -37,7 +39,7 @@ IFS=' # Iterate over packages. while [ ${#} -gt 0 ]; do - printf 'oh-installfiles: Installing files for package "%s"...\n' "${1}" + oh_info 'Installing files for package "%s"...' "${1}" mkdir ${1}.data || exit 1 chmod 755 ${1}.data || exit 1 @@ -60,8 +62,7 @@ done # TODO: This should be part of some kind of warnings/lint framework/script and # allow the user to drop to a debug shell before cleanup. if [ "$(find dest -type f | wc -l)" -gt 0 ]; then - printf 'oh-installfiles: Warning: %s\n' \ - 'Files remain in installation directory.' >&2 + oh_warn 'Files remain in installation directory' fi # Reset the IFS. diff --git a/src/oh-strip.sh b/src/oh-strip.sh index 6b8ceaf..adbf217 100644 --- a/src/oh-strip.sh +++ b/src/oh-strip.sh @@ -19,17 +19,13 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . +. @@LIBDIR@@/opkhelper/messages + print_usage() { printf 'Usage: %s [-g] [-l] binaryfile...\n' "$1" } -error() -{ - printf 'oh-strip: Error: %s\n' "${1}" - exit 1 -} - opts=$(getopt -n "${0}" -o 'gl' -- "${@}") if [ ${?} -ne 0 ]; then print_usage "${0}" >&2 @@ -71,22 +67,22 @@ fi # Iterate over object files. while [ ${#} -gt 0 ]; do - printf 'oh-strip: Stripping symbols from file "%s"...\n' "${1}" + oh_info 'Stripping symbols from file "%s"...' "${1}" if ${make_dbg_obj}; then # Copy debugging symbols into a debugging object file and add a GDB link # from the original object file to the debugging object file. mkdir -p "$(dirname "dest/usr/lib/debug/${1}")" || \ - error 'Cannot make directory path to debugging object' + oh_error 'Cannot make directory path to debugging object' ${OBJCOPY:-objcopy} --only-keep-debug --compress-debug-sections "dest/${1}" \ - "dest/usr/lib/debug/${1}" || error 'Cannot make debugging object' + "dest/usr/lib/debug/${1}" || oh_error 'Cannot make debugging object' ${OBJCOPY:-objcopy} --add-gnu-debuglink="dest/usr/lib/debug/${1}" "dest/${1}" || \ - error 'Cannot add GDB link' + oh_error 'Cannot add GDB link' chmod 644 "dest/usr/lib/debug/${1}" || \ - error 'Cannot set mode on debugging object' + oh_error 'Cannot set mode on debugging object' fi # Strip the object file of symbols. # TODO: If the file is not a library, strip it of all symbols. - ${STRIP:-strip} -g "dest/${1}" || error 'Cannot strip object' + ${STRIP:-strip} -g "dest/${1}" || oh_error 'Cannot strip object' shift done -- cgit v0.9.1