|
Packit Service |
82fcde |
#!/bin/bash
|
|
Packit Service |
82fcde |
# Create a patch which backports the support/ subdirectory.
|
|
Packit Service |
82fcde |
# Copyright (C) 2017-2018 Free Software Foundation, Inc.
|
|
Packit Service |
82fcde |
# This file is part of the GNU C Library.
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
# The GNU C Library is free software; you can redistribute it and/or
|
|
Packit Service |
82fcde |
# modify it under the terms of the GNU Lesser General Public
|
|
Packit Service |
82fcde |
# License as published by the Free Software Foundation; either
|
|
Packit Service |
82fcde |
# version 2.1 of the License, or (at your option) any later version.
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
# The GNU C Library is distributed in the hope that it will be useful,
|
|
Packit Service |
82fcde |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
82fcde |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit Service |
82fcde |
# Lesser General Public License for more details.
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
# You should have received a copy of the GNU Lesser General Public
|
|
Packit Service |
82fcde |
# License along with the GNU C Library; if not, see
|
|
Packit Service |
82fcde |
# <http://www.gnu.org/licenses/>.
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
# This script does not backport the Makefile tweaks outside the
|
|
Packit Service |
82fcde |
# support/ directory (which need to be backported separately), or the
|
|
Packit Service |
82fcde |
# changes to test-skeleton.c (which should not be backported).
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
set -e
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
export LC_ALL=C
|
|
Packit Service |
82fcde |
export GIT_CONFIG=/dev/null
|
|
Packit Service |
82fcde |
export GTT_CONFIG_NOSYSTEM=0
|
|
Packit Service |
82fcde |
export GIT_PAGER=
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
usage () {
|
|
Packit Service |
82fcde |
cat >&2 <
|
|
Packit Service |
82fcde |
usage: $0 {patch|commit}
|
|
Packit Service |
82fcde |
EOF
|
|
Packit Service |
82fcde |
exit 1
|
|
Packit Service |
82fcde |
}
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
if test $# -ne 1 ; then
|
|
Packit Service |
82fcde |
usage
|
|
Packit Service |
82fcde |
fi
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
command="$1"
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
case "$command" in
|
|
Packit Service |
82fcde |
patch|commit)
|
|
Packit Service |
82fcde |
;;
|
|
Packit Service |
82fcde |
*)
|
|
Packit Service |
82fcde |
usage
|
|
Packit Service |
82fcde |
;;
|
|
Packit Service |
82fcde |
esac
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
# The upstream branch to work on.
|
|
Packit Service |
82fcde |
branch=origin/master
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
# The commit which added the support/ directory.
|
|
Packit Service |
82fcde |
initial_commit=c23de0aacbeaa7a091609b35764bed931475a16d
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
# We backport the support directory and this script. Directories need
|
|
Packit Service |
82fcde |
# to end in a /.
|
|
Packit Service |
82fcde |
patch_targets="support/ scripts/backport-support.sh"
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
latest_commit="$(git log --max-count=1 --pretty=format:%H "$branch" -- \
|
|
Packit Service |
82fcde |
$patch_targets)"
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
# Simplify the branch name somewhat for reporting.
|
|
Packit Service |
82fcde |
branch_name="$(echo "$branch" | sed s,^origin/,,)"
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
command_patch () {
|
|
Packit Service |
82fcde |
cat <
|
|
Packit Service |
82fcde |
This patch creates the contents of the support/ directory up to this
|
|
Packit Service |
82fcde |
upstream commit on the $branch_name branch:
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
EOF
|
|
Packit Service |
82fcde |
git log --max-count=1 "$latest_commit"
|
|
Packit Service |
82fcde |
echo
|
|
Packit Service |
82fcde |
git diff "$initial_commit"^.."$latest_commit" $patch_targets
|
|
Packit Service |
82fcde |
echo "# Before applying the patch, run this command:" >&2
|
|
Packit Service |
82fcde |
echo "# rm -rf $patch_targets" >&2
|
|
Packit Service |
82fcde |
}
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
command_commit () {
|
|
Packit Service |
82fcde |
git status --porcelain | while read line ; do
|
|
Packit Service |
82fcde |
echo "error: working copy is not clean, cannot commit" >&2
|
|
Packit Service |
82fcde |
exit 1
|
|
Packit Service |
82fcde |
done
|
|
Packit Service |
82fcde |
for path in $patch_targets; do
|
|
Packit Service |
82fcde |
echo "# Processing $path" >&2
|
|
Packit Service |
82fcde |
case "$path" in
|
|
Packit Service |
82fcde |
[a-zA-Z0-9]*/)
|
|
Packit Service |
82fcde |
# Directory.
|
|
Packit Service |
82fcde |
git rm --cached --ignore-unmatch -r "$path"
|
|
Packit Service |
82fcde |
rm -rf "$path"
|
|
Packit Service |
82fcde |
git read-tree --prefix="$path" "$latest_commit":"$path"
|
|
Packit Service |
82fcde |
git checkout "$path"
|
|
Packit Service |
82fcde |
;;
|
|
Packit Service |
82fcde |
*)
|
|
Packit Service |
82fcde |
# File.
|
|
Packit Service |
82fcde |
git show "$latest_commit":"$path" > "$path"
|
|
Packit Service |
82fcde |
git add "$path"
|
|
Packit Service |
82fcde |
esac
|
|
Packit Service |
82fcde |
done
|
|
Packit Service |
82fcde |
git commit -m "Synchronize support/ infrastructure with $branch_name
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
This commit updates the support/ subdirectory to
|
|
Packit Service |
82fcde |
commit $latest_commit
|
|
Packit Service |
82fcde |
on the $branch_name branch.
|
|
Packit Service |
82fcde |
"
|
|
Packit Service |
82fcde |
}
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
command_$command
|