Update of /cvsroot/linux-vax/toolchain/scripts
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2731
Modified Files:
try_patches.sh prepare_toolchain_hacking.sh
Log Message:
- Allow me to not apply all patches, but only up to a given number. This
should ease to refresh patches.
Index: prepare_toolchain_hacking.sh
===================================================================
RCS file: /cvsroot/linux-vax/toolchain/scripts/prepare_toolchain_hacking.sh,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- prepare_toolchain_hacking.sh 23 Sep 2005 14:05:40 -0000 1.3
+++ prepare_toolchain_hacking.sh 1 Oct 2005 14:20:21 -0000 1.4
@@ -61,7 +61,12 @@
COMPONENT=""
;;
esac
+ MAX_PATCH=999999
case "${1}" in
+ *+patches-*)
+ APPLY_PATCHES=yes
+ MAX_PATCH="`echo "${1}" | sed -e 's/.*patches-\([0-9]*\)$/\1/'`"
+ ;;
*+patches)
APPLY_PATCHES=yes
;;
@@ -78,8 +83,8 @@
copy_directory.sh "${SRC_DIR}" "${DEST_BASE}-hacked"
if [ "${APPLY_PATCHES}" = yes ]; then
- try_patches.sh "${COMPONENT}" "${DEST_BASE}-fresh" "${VAX_PATCHES_PATH}"
- try_patches.sh "${COMPONENT}" "${DEST_BASE}-hacked" "${VAX_PATCHES_PATH}"
+ try_patches.sh "${COMPONENT}" "${DEST_BASE}-fresh" "${VAX_PATCHES_PATH}" "${MAX_PATCH}"
+ try_patches.sh "${COMPONENT}" "${DEST_BASE}-hacked" "${VAX_PATCHES_PATH}" "${MAX_PATCH}"
fi
fi
Index: try_patches.sh
===================================================================
RCS file: /cvsroot/linux-vax/toolchain/scripts/try_patches.sh,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- try_patches.sh 15 Apr 2005 10:48:17 -0000 1.2
+++ try_patches.sh 1 Oct 2005 14:20:21 -0000 1.3
@@ -1,11 +1,27 @@
#!/bin/sh
+function remove_leading_zero() {
+ local NUMBER
+ NUMBER="`echo "${1}" | sed -e 's/^0*//g'`"
+ [ -z "${NUMBER}" ] && NUMBER=0
+
+ echo "${NUMBER}"
+}
+
#
# $1 - component to patch (gcc, glibc, ports, binutils)
# $2 - destination directory; patches are expected to apply with -p1
# $3 - directory containing the patches
+# ---- optional argument ----
+# $4 - an (optional) maximum patch number. Only patches with a number
+# less than $4 are applied (ie. $4 = 7 ---> apply patches 0..6)
#
function try_patches() {
+ MAX_PATCH=999999
+ if [ $# -eq 4 ]; then
+ MAX_PATCH="`remove_leading_zero "${4}"`"
+ fi
+
echo -n "Looking for ${1} patches... "
if ! ls ${3}/${1}-[0-9][0-9][0-9][0-9][0-9][0-9]-*.patch > /dev/null 2>&1; then
echo "none."
@@ -15,21 +31,30 @@
fi
for patchfile in ${3}/${1}-[0-9][0-9][0-9][0-9][0-9][0-9]-*.patch; do
- echo "Applying `basename "${patch}"` ..."
- pushd "${2}"
- patch -p1 --verbose < "${patchfile}"
- popd
+ THIS_PATCH="`echo "${patchfile}" | sed -e "s/^.*${1}-\\\([0-9][0-9][0-9][0-9][0-9][0-9]\\\)-.*\\.patch$/\\1/"`"
+ THIS_PATCH="`remove_leading_zero "${THIS_PATCH}"`"
+ if [ ${THIS_PATCH} -ge ${MAX_PATCH} ]; then
+ echo "Ignoring `basename "${patchfile}"`"
+ else
+ echo "Applying `basename "${patchfile}"` ..."
+ pushd "${2}"
+ patch -p1 < "${patchfile}"
+ popd
+ fi
done
}
-if [ $# -ne 3 ]; then
- echo "$0 <component> <directory-to-patch> <directory-containing-patches>" >&2
+if [ $# -ne 3 -a $# -ne 4 ]; then
+ echo "$0 <component> <directory-to-patch> <directory-containing-patches> (max_patch_number)" >&2
echo "All patches are expected to apply with -p1 within directory-to-patch." >&2
echo "Their names are expected to be in this form:" >&2
echo "" >&2
echo " COMPONENT-nnnnnn-description.patch" >&2
echo "" >&2
echo "nnnnnn is exactly six decimal digits; description mustn't contain spaces." >&2
+ echo "" >&2
+ echo "If a max_patch_number is given, only patche files with a number smaller" >&2
+ echo "than max_patch_number will be applied." >&2
exit 1
fi
@@ -41,6 +66,16 @@
echo "${3} is not a directory, so I don't expect patches here..." >&2
exit 1
fi
+if [ $# -eq 4 ]; then
+ if ! echo "${4}" | grep -q '^[0-9]*$'; then
+ echo "${4} is not a number..." >&2
+ exit 1
+ fi
+fi
-try_patches "${1}" "${2}" "${3}"
+if [ $# -eq 3 ]; then
+ try_patches "${1}" "${2}" "${3}"
+elif [ $# -eq 4 ]; then
+ try_patches "${1}" "${2}" "${3}" "`remove_leading_zero "${4}"`"
+fi
|