xargs --no-run-if-empty rm -f
end
+MACRO_PATCHES = /usr/lib/pakfire/patch %{patches}
+
# Pre-defined build scripts.
build
# These variables are used if you have to add some targets
--build=%{DISTRO_MACHINE} \
--prefix=/usr
-patches =
+# By default, take all patches from the patches directory
+# in alphabetical order.
+patches = $(find %{DIR_PATCHES} -not -type d 2>/dev/null | sort)
sources = %{thisapp}.tar.gz
# Macro definitions
# Guesses the compression type automatically.
MACRO_EXTRACT = tar xvaf
-MACRO_PATCHES
- patches="%{patches}"
-
- if [ -n "${patches}" ]; then
- _patches=""
- for patch in ${patches}; do
- _patches="${_patches} %{DIR_PATCHES}/${patch}"
- done
- patches="${_patches}"
- unset _patches
- else
- for patch in %{DIR_PATCHES}/*.{diff,patch{,0}}; do
- [ -e "${patch}" ] || continue
- patches="${patches} ${patch}"
- done
- fi
-
- for patch in ${patches}; do
- case "${patch}" in
- *.patch0)
- cmd="patch -Np0"
- ;;
- *.patch|*.diff)
- cmd="patch -Np1"
- ;;
- esac
-
- ${cmd} -i ${patch}
- done
- unset cmd patch patches
-end
-
# Remove rpath from libtool.
MACRO_FIX_LIBTOOL
if [ -e "%{DIR_APP}/libtool" ]; then
compress-man-pages \
dependency-tracker \
pakfire-multicall.py \
+ patch \
py-compile \
quality-agent \
remove-static-libs \
--- /dev/null
+#!/bin/bash
+# Script that automatically applies patches.
+
+if [ -n "$@" ]; then
+ echo "Applying patches..."
+fi
+
+# Apply all patches given on command line.
+for patch in $@; do
+ # Check if patch file does exist.
+ if ! [ -e "${patch}" ]; then
+ echo >&2 " ERROR: Patch file does not exist: ${patch}"
+ exit 1
+ fi
+
+ # Options applied to patch command.
+ options="-N"
+
+ # Get right -p1 option.
+ case "${patch}" in
+ *.patch[0-9])
+ # Get patch level from file name.
+ level=${patch:$(( ${#patch} - 1))}
+ options="${options} -p${level}"
+ ;;
+ *.patch|*.diff)
+ # Default is -p1.
+ options="${options} -p1"
+ ;;
+ *.off)
+ # Ignore disabled patches.
+ continue
+ ;;
+ *)
+ echo >&2 " ERROR: Unknown filetype: ${patch}"
+ exit 1
+ ;;
+ esac
+
+ echo " Applying ${patch} (${options})..."
+ patch ${options} -i ${patch} || exit $?
+done
+
+exit 0