summaryrefslogtreecommitdiffstats
path: root/src/ob-applypatches.sh
diff options
context:
space:
mode:
authorP. J. McDermott <pjm@nac.net>2012-10-03 16:26:09 (EDT)
committer P. J. McDermott <pjm@nac.net>2012-10-03 16:26:09 (EDT)
commit1b21d1d9f4947b60a370aad21e732e51b80193c4 (patch)
tree3b3e586c5275170992e470e572d7a4b6a1053a89 /src/ob-applypatches.sh
parent1b3d9defd5b061ffc66e4b866c3ee6ae0d84b07e (diff)
Implement ob-applypatches.
Diffstat (limited to 'src/ob-applypatches.sh')
-rw-r--r--src/ob-applypatches.sh55
1 files changed, 55 insertions, 0 deletions
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 <http://www.gnu.org/licenses/>.
+
+. '@@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 "${@}"