From 1b21d1d9f4947b60a370aad21e732e51b80193c4 Mon Sep 17 00:00:00 2001 From: P. J. McDermott Date: Wed, 03 Oct 2012 16:26:09 -0400 Subject: Implement ob-applypatches. --- (limited to 'src/ob-applypatches.sh') diff --git a/src/ob-applypatches.sh b/src/ob-applypatches.sh new file mode 100644 index 0000000..98aabb9 --- /dev/null +++ b/src/ob-applypatches.sh @@ -0,0 +1,55 @@ +#!@@SH@@ +# +# opkbuild +# src/ob-applypatches +# Apply patches to source code. +# +# 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 3 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 . + +. '@@LIBOPKBUILD@@/load.sm' + +ob_use locale +ob_use output +ob_use package + +main() +{ + ob_set_text_domain 'opkbuild' + + ob_init_package '..' + ob_parse_package_metadata -c '.opkbuild.cache' + + apply_patches +} + +apply_patches() +{ + applied='false' + + if [ -d ../patches ]; then + # Iterate over patches ordered alphabetically by name. + for patch in $(ls -1 ../patches | sort); do + ob_info "$(ob_get_msg 'applying_patch')" "${patch}" + patch -N -p 1 -u -d src -i "../../patches/${patch}" || \ + ob_error "$(ob_get_msg 'cant_apply_patch')" "${patch}" + applied='true' + done + fi + + ${applied} || ob_info "$(ob_get_msg 'no_patches')" +} + +main "${@}" -- cgit v0.9.1