summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--locale/en_US/opkbuild.sh5
-rw-r--r--src/Makefile.in4
-rw-r--r--src/ob-applypatches.sh55
3 files changed, 62 insertions, 2 deletions
diff --git a/locale/en_US/opkbuild.sh b/locale/en_US/opkbuild.sh
index 9f6705a..f40658a 100644
--- a/locale/en_US/opkbuild.sh
+++ b/locale/en_US/opkbuild.sh
@@ -73,3 +73,8 @@ msg_opkbuild_multiple_top_upstream_dirs='Multiple top-level directories found in
msg_opkbuild_unpacking_upstream='Extracting upstream source archive...'
msg_opkbuild_cant_unpack_upstream='Can'\''t extract upstream source archive'
msg_opkbuild_cant_move_native='Can'\''t move extracted upstream source directory'
+
+# ob-applypatches
+msg_opkbuild_applying_patch='Applying patch "%s"...'
+msg_opkbuild_cant_apply_patch='Can'\''t apply patch "%s"'
+msg_opkbuild_no_patches='No patches to be applied'
diff --git a/src/Makefile.in b/src/Makefile.in
index 3d02603..d4fea35 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -39,8 +39,8 @@ sed_script = s&@@PACKAGE_NAME@@&$(package_name)&;\
SRCS = opkbuild.sh \
ob-checkbuilddeps.sh \
ob-buildenv.sh \
- ob-unpacksource.sh #\
- ob-applypatches.sh \
+ ob-unpacksource.sh \
+ ob-applypatches.sh #\
ob-installplatconf.sh \
ob-installdocs.sh \
ob-gencontrol.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 <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 "${@}"