summaryrefslogtreecommitdiffstats
path: root/src/oh-applypatches.sh
diff options
context:
space:
mode:
Diffstat (limited to 'src/oh-applypatches.sh')
-rw-r--r--src/oh-applypatches.sh46
1 files changed, 25 insertions, 21 deletions
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 "${@}"