File vlc-beta.rebase-changes.sh of Package vlc-beta
#!/bin/bash
set -e
unset LANG
unset ${!LC_*}
read td < <(mktemp --directory --tmpdir=/dev/shm .XXX)
trap "rm -rf '${td}'" EXIT
#
d_extract="${td}/e"
d_old="${td}/o"
d_new="${td}/n"
#
read vlc_beta_pkg < <(readlink -f "$1")
read vlc_git < <(readlink -f "$2")
#
test -f "${vlc_git}/.git/config"
test -f "${vlc_beta_pkg}/.osc/_package"
read pkg < "$_"
test "${pkg}" = 'vlc-beta'
mkdir "${d_extract}" "${d_old}" "${d_new}"
pushd "${vlc_beta_pkg}" > /dev/null
for patch in *.patch
do
sed '
/^---[[:blank:]]/d
/^+++[[:blank:]]/d
/^@@[[:blank:]]/d
' < "${patch}" > "${d_old}/${patch}"
done
popd > /dev/null
#
pushd "${vlc_git}" > /dev/null
git --no-pager checkout master
git --no-pager pull
git --no-pager log --oneline -n1
git --no-pager checkout vlc-beta
git --no-pager rebase master
git --no-pager format-patch --no-base --quiet --output-directory "${d_extract}" master..HEAD
#
sed -i -n '
: sep
n
/^---$/b stat
b sep
: stat
n
/^$/b body
b stat
: body
n
/^diff[[:blank:]]\+--git[[:blank:]]\+/b body
/^index[[:blank:]]\+[0-9a-f]\+/b body
p
b body
' "${d_extract}"/*.patch
popd > /dev/null
#
pushd "${d_extract}" > /dev/null
for patch in *.patch
do
o="${patch}"
n="${patch#*-}"
mv "${o}" "${n}"
sed '
/^---[[:blank:]]/d
/^+++[[:blank:]]/d
/^@@[[:blank:]]/d
' < "${n}" > "${d_new}/${n}"
if diff -u "${d_old}/${n}" "${d_new}/${n}"
then
rm "${n}"
else
mv -vit "${vlc_beta_pkg}" "${n}"
fi
done
popd > /dev/null
pushd "${vlc_beta_pkg}" > /dev/null
osc st
popd > /dev/null