summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xscripts/git-ptx-patches73
-rw-r--r--scripts/lib/ptxd_make_world_patchin.sh27
2 files changed, 94 insertions, 6 deletions
diff --git a/scripts/git-ptx-patches b/scripts/git-ptx-patches
index c5eb405f4..396797c6e 100755
--- a/scripts/git-ptx-patches
+++ b/scripts/git-ptx-patches
@@ -18,6 +18,7 @@ if [ ! -L .ptxdist/series ]; then
fi
remove_old=no
+tag=base
if grep -q "$PTX_PATCHES_HEADER" .ptxdist/series; then
echo "Found series file generated by git-ptx-patches."
@@ -31,8 +32,57 @@ if grep -q "$PTX_PATCHES_HEADER" .ptxdist/series; then
fi
fi
+while getopts "ft:n:" opt; do
+ case "${opt}" in
+ f)
+ remove_old="force"
+ ;;
+ t)
+ tag="${OPTARG}"
+ range="${tag}"
+ ;;
+ esac
+done
+shift $((${OPTIND} - 1))
+
if [ "x$1" = "x--force-remove" ]; then
remove_old="force"
+ shift
+fi
+
+tag2=$(grep "#tag:" .ptxdist/series | awk "/#tag:${tag}/{getline;print \$0}" | sed 's,#tag:,,' | cut -d' ' -f1)
+if [ "${tag}" != "${tag2}" ]; then
+ range="${tag}..${tag2}"
+else
+ range="${tag}"
+ tag2=""
+fi
+
+echo "$PTX_PATCHES_HEADER" > .ptxdist/series.0
+:> .ptxdist/series.1
+if grep -q "#tag:" .ptxdist/series; then
+ tagline=$(grep "#tag:${tag}" .ptxdist/series)
+ t=$(echo "${tagline}"|cut -d' ' -f1)
+ if [ "#tag:${tag}" == "${t}" ]; then
+ tagopt=$(echo "${tagline}"|cut -d' ' -f2-)
+ sed -e "/$PTX_PATCHES_HEADER/d" -n -e "0,/#tag:${tag}/p" .ptxdist/series >> .ptxdist/series.0
+ # Remove patches before #tag:${tag} so they don't get rm'd with remove_old=yes
+ sed -i --follow-symlinks "0,/#tag:${tag}/d" .ptxdist/series
+ if [ -n "${tag2}" ]; then
+ sed -n -e "/#tag:${tag2}/,/git-ptx-patches magic/p" .ptxdist/series > .ptxdist/series.1
+ sed -i "/git-ptx-patches magic/d" .ptxdist/series.1
+ sed -i --follow-symlinks "/#tag:${tag2}/,/git-ptx-patches magic/d" .ptxdist/series
+ fi
+ else
+ echo "series contains #tag:* lines, but could not find #tag:${tag} line in series. Aborting."
+ exit 1
+ fi
+else
+ if [ "${tag}" != "base" ]; then
+ echo "When using series with no #tag:* lines, you must use base tag."
+ exit 1
+ fi
+ echo "#tag:${tag} --start-number 1" >> .ptxdist/series.0
fi
case "$remove_old" in
@@ -53,7 +103,13 @@ case "$remove_old" in
".ptxdist/patches/") continue ;;
".ptxdist/patches/series") continue ;;
".ptxdist/patches/autogen.sh") continue ;;
- *) rm -rf "$file" ;;
+ *)
+ if grep -q "${file##\.ptxdist/patches/}" .ptxdist/series.{0,1}; then
+ echo "Keep base patch ${file}"
+ else
+ rm -rf "$file"
+ fi
+ ;;
esac
done
;;
@@ -63,8 +119,10 @@ if git format-patch -h 2>&1 | grep -q signature; then
GIT_EXTRA_ARGS="--no-signature"
fi
-echo "$PTX_PATCHES_HEADER" > .ptxdist/series
-git format-patch -N $GIT_EXTRA_ARGS -o .ptxdist/patches/ base | sed -e 's,^.ptxdist/patches/,,' >> .ptxdist/series
+cat .ptxdist/series.0 > .ptxdist/series
+git format-patch -N $GIT_EXTRA_ARGS ${tagopt} -o .ptxdist/patches/ ${range} | sed -e 's,^.ptxdist/patches/,,' > .ptxdist/series.auto
+cat .ptxdist/series.auto >> .ptxdist/series
+cat .ptxdist/series.1 >> .ptxdist/series
cat .ptxdist/series | _md5sum >> .ptxdist/series
# The first line of the patch is 'From <some-git-hash> ...'
@@ -75,14 +133,17 @@ while read patch para; do
"series"|"autogen.sh") continue ;;
*) ;;
esac
- if grep -q "$patch" .ptxdist/series; then
+ if grep -q "$patch" .ptxdist/series.auto; then
p=".ptxdist/patches/$patch"
lines=$(cat "$p" | wc -l)
lines=$[lines-1]
tail -n$lines "$p" > ".$patch.ptx-patches"
mv ".$patch.ptx-patches" "$p"
else
- echo "Old patch \"$patch\"!"
+ if grep -q "$patch" .ptxdist/series.{0,1}; then
+ echo "Base patch \"$patch\"!"
+ else
+ echo "Old patch \"$patch\"!"
+ fi
fi
done
-
diff --git a/scripts/lib/ptxd_make_world_patchin.sh b/scripts/lib/ptxd_make_world_patchin.sh
index bbb749045..d3544f245 100644
--- a/scripts/lib/ptxd_make_world_patchin.sh
+++ b/scripts/lib/ptxd_make_world_patchin.sh
@@ -112,6 +112,16 @@ ptxd_make_world_patchin_apply_git_compat()
esac
case "${patch}" in
+ "#tag:"*)
+ local tag="${patch##\#tag:}"
+ if [ -f ${pkg_patchin_dir}/.ptxdist/git-patches/series ]; then
+ mv ${pkg_patchin_dir}/.ptxdist/git-patches/series{,.${tag}} &&
+ touch ${pkg_patchin_dir}/.ptxdist/git-patches/series
+ else
+ touch ${pkg_patchin_dir}/.ptxdist/git-patches/series.${tag}
+ fi
+ continue
+ ;;
""|"#"*) continue ;; # skip empty lines and comments
*.gz) cat="zcat" ;;
*.bz2) cat="bzcat" ;;
@@ -141,6 +151,23 @@ ptxd_make_world_patchin_apply_git()
#
ptxd_make_world_patchin_apply_git_compat || return
+ grep "\#tag:" "${pkg_patchin_dir}/.ptxdist/series" | while read tagline; do
+ local tag="${tagline##\#tag:}"
+ tag=$(echo ${tag}|cut -d' ' -f1)
+ if [ -f "${pkg_patchin_dir}/.ptxdist/git-patches/series.${tag}" ]; then
+ mv ${pkg_patchin_dir}/.ptxdist/git-patches/series{,.1} || return
+ mv ${pkg_patchin_dir}/.ptxdist/git-patches/series{.${tag},} || return
+
+ git quiltimport \
+ --patches "${pkg_patchin_dir}/.ptxdist/git-patches" \
+ --author "unknown author <unknown.author@example.com>"
+ echo "tagging -> ${tag}"
+ git tag -f ${tag}
+ mv ${pkg_patchin_dir}/.ptxdist/git-patches/series{,.${tag}} || return
+ mv ${pkg_patchin_dir}/.ptxdist/git-patches/series{.1,} || return
+ fi
+ done
+
git quiltimport \
--patches "${pkg_patchin_dir}/.ptxdist/git-patches" \
--author "unknown author <unknown.author@example.com>"