diff options
author | P. J. McDermott <pjm@nac.net> | 2012-07-31 21:37:57 (EDT) |
---|---|---|
committer | P. J. McDermott <pjm@nac.net> | 2012-07-31 21:37:57 (EDT) |
commit | 9904d628f4676c4ad440190805822c205c911f42 (patch) | |
tree | 46c852865eac6d969650542f295b5e570d84a0bf | |
parent | a95c249fbc6b556270d91b685b980f0cec986b23 (diff) |
Rewrite oh-applypatches.
-rw-r--r-- | locale/en_US.sh | 9 | ||||
-rw-r--r-- | src/oh-applypatches.sh | 46 | ||||
-rw-r--r-- | src/opkbuild.sh | 13 |
3 files changed, 32 insertions, 36 deletions
diff --git a/locale/en_US.sh b/locale/en_US.sh index 520a372..3b14cc8 100644 --- a/locale/en_US.sh +++ b/locale/en_US.sh @@ -70,9 +70,6 @@ oh_str_arch_stat_plat=' Platform: %s' oh_str_host_arch_stat_header='Host system:' oh_str_cant_make_work_area='Can'\''t make work area' oh_str_cant_enter_work_area='Can'\''t enter work area' -oh_str_applying_patch='Applying patch "%s"...' -oh_str_cant_apply_patch='Can'\''t apply patch "%s"' -oh_str_no_patches='No patches to be applied' # oh-unpacksource strings: oh_str_usage_oh_unpacksource='Usage: oh-unpacksource' @@ -86,3 +83,9 @@ oh_str_multiple_top_upstream_dirs='Multiple top-level directories found in upstr oh_str_unpacking_upstream='Extracting upstream source archive...' oh_str_cant_unpack_upstream='Can'\''t extract upstream source archive' oh_str_cant_move_native='Can'\''t move extracted upstream source directory' + +# oh-applypatches strings: +oh_str_usage_oh_applypatches='Usage: oh-applypatches' +oh_str_applying_patch='Applying patch "%s"...' +oh_str_cant_apply_patch='Can'\''t apply patch "%s"' +oh_str_no_patches='No patches to be applied' diff --git a/src/oh-applypatches.sh b/src/oh-applypatches.sh index 5ab52a6..62f9f87 100644 --- a/src/oh-applypatches.sh +++ b/src/oh-applypatches.sh @@ -19,30 +19,34 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. -. @@LIBDIR@@/opkhelper/messages +. @@LIBDIR@@/messages +. @@LIBDIR@@/locale -print_usage() +main() { - printf 'Usage: %s\n' "${1}" -} + oh_locale_set -if [ ${#} -ne 0 ]; then - print_usage ${0} >&2 - exit 1 -fi + if [ "${#}" -ne 0 ]; then + oh_usage + exit 1 + fi -applied=false + apply_patches +} -if [ -d ../patches ]; then - # Iterate over patches ordered alphabetically by name. - for patch in $(ls -1 ../patches | sort); do - oh_info 'Applying patch "%s"...' "${patch}" - patch -N -p 1 -u -d src -i "../../patches/${patch}" || exit 1 - applied=true - done -fi +apply_patches() +{ + applied=false + if [ -d ../patches ]; then + # Iterate over patches ordered alphabetically by name. + for patch in $(ls -1 ../patches | sort); do + oh_info "${oh_str_applying_patch}" "${patch}" + patch -N -p 1 -u -d src -i "../../patches/${patch}" || \ + oh_error "${oh_str_cant_apply_patch}" "${patch}" + applied=true + done + fi + ${applied} || oh_info "${oh_str_no_patches}" +} -# Provide output even if patches directory didn't exist or had no visible files. -if ! ${applied}; then - oh_info 'No patches to be applied' -fi +main "${@}" diff --git a/src/opkbuild.sh b/src/opkbuild.sh index 7fdd33d..c3ae895 100644 --- a/src/opkbuild.sh +++ b/src/opkbuild.sh @@ -357,18 +357,7 @@ step_patch() { oh_cv_set step patch - # TODO: Put this in oh-applypatches. - applied=false - if [ -d ../patches ]; then - # Iterate over patches ordered alphabetically by name. - for patch in $(ls -1 ../patches | sort); do - oh_info "${oh_str_applying_patch}" "${patch}" - patch -N -p 1 -u -d src -i "../../patches/${patch}" || \ - oh_error "${oh_str_cant_apply_patch}" "${patch}" - applied=true - done - fi - ${applied} || oh_info "${oh_str_no_patches}" + oh-applypatches step_config } |