mirror of
https://github.com/crosstool-ng/crosstool-ng.git
synced 2025-01-02 19:16:39 +00:00
scripts: output renumbered patches in a new directory
When renumbering patches, the original patches get removed and replaced with the new ones. This can be annoying to loose the original patches. Fix this by putting the new patchs in a directory of their own.
This commit is contained in:
parent
6c88248647
commit
33374cac39
@ -9,37 +9,47 @@ myname="$0"
|
|||||||
|
|
||||||
doUsage() {
|
doUsage() {
|
||||||
cat <<_EOF_
|
cat <<_EOF_
|
||||||
Usage: ${myname} <dir> <base> <inc> [sed_re]
|
Usage: ${myname} <src_dir> <dst_dir> <base> <inc> [sed_re]
|
||||||
Will renumber all patches found in 'dir', starting at 'base', and with
|
Renumbers all patches found in 'src_dir', starting at 'base', with an
|
||||||
an increment of 'inc'.
|
increment of 'inc', and puts the renumbered patches in 'dst_dir'.
|
||||||
|
Leading digits are replaced with the new indexes, and a subsequent '_'
|
||||||
|
is replaced with a '-'.
|
||||||
If 'sed_re' is given, it is interpreted as a valid sed expression, and
|
If 'sed_re' is given, it is interpreted as a valid sed expression, and
|
||||||
it will be applied to the patch name.
|
is be applied to the patch name.
|
||||||
If the environment variable FAKE is set to 'y', then the command will
|
If the environment variable FAKE is set to 'y', then nothing gets done,
|
||||||
only be printed, and not executed (so you can check beforehand).
|
the command to run is only be printed, and not executed (so you can
|
||||||
|
check beforehand).
|
||||||
|
'dst_dir' must not yet exist.
|
||||||
Eg.:
|
Eg.:
|
||||||
patch-renumber.sh patches/gcc/4.3.1 100 10
|
patch-renumber.sh patches/gcc/4.2.3 patches/gcc/4.2.4 100 10
|
||||||
patch-renumber.sh patches/gcc/4.2.4 100 10 's/(all[_-])*(gcc[-_])*//;'
|
patch-renumber.sh /some/dir/my-patches patches/gcc/4.3.1 100 10 's/(all[_-])*(gcc[-_])*//;'
|
||||||
_EOF_
|
_EOF_
|
||||||
}
|
}
|
||||||
|
|
||||||
[ $# -lt 3 -o $# -gt 4 ] && { doUsage; exit 1; }
|
[ $# -lt 4 -o $# -gt 5 ] && { doUsage; exit 1; }
|
||||||
[ -d "${1}" ] || { doUsage; exit 1; }
|
|
||||||
|
|
||||||
dir="${1}"
|
src="${1}"
|
||||||
cpt="${2}"
|
dst="${2}"
|
||||||
inc="${3}"
|
cpt="${3}"
|
||||||
sed_re="${4}"
|
inc="${4}"
|
||||||
|
sed_re="${5}"
|
||||||
case "$(LC_ALL=C hg id "${dir}" 2>/dev/null)" in
|
if [ ! -d "${src}" ]; then
|
||||||
"") CMD="";;
|
printf "%s: '%s': not a directory\n" "${myname}" "${src}"
|
||||||
*) CMD="hg";;
|
exit 1
|
||||||
esac
|
fi
|
||||||
|
if [ -d "${dst}" ]; then
|
||||||
if [ "${FAKE}" = "y" ]; then
|
printf "%s: '%s': directory already exists\n" "${myname}" "${dst}"
|
||||||
CMD="echo ${CMD}"
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
for p in "${dir}"/*.patch*; do
|
Q=
|
||||||
|
if [ -n "${FAKE}" ]; then
|
||||||
|
printf "%s: won't do anything: FAKE='%s'\n" "${myname}" "${FAKE}"
|
||||||
|
Q="echo"
|
||||||
|
fi
|
||||||
|
|
||||||
|
${Q} mkdir -pv "${dst}"
|
||||||
|
for p in "${src}/"*.patch*; do
|
||||||
[ -e "${p}" ] || { echo "No such file '${p}'"; exit 1; }
|
[ -e "${p}" ] || { echo "No such file '${p}'"; exit 1; }
|
||||||
newname="$(printf "%03d-%s" \
|
newname="$(printf "%03d-%s" \
|
||||||
"${cpt}" \
|
"${cpt}" \
|
||||||
@ -48,6 +58,6 @@ for p in "${dir}"/*.patch*; do
|
|||||||
-e "${sed_re}" \
|
-e "${sed_re}" \
|
||||||
)" \
|
)" \
|
||||||
)"
|
)"
|
||||||
[ "${p}" = "${dir}/${newname}" ] || ${CMD} mv -v "${p}" "${dir}/${newname}"
|
${Q} cp -v "${p}" "${dst}/${newname}"
|
||||||
cpt=$((cpt+inc))
|
cpt=$((cpt+inc))
|
||||||
done
|
done
|
||||||
|
Loading…
Reference in New Issue
Block a user