]> git.ipfire.org Git - thirdparty/glibc.git/blame - scripts/backport-support.sh
Sync "language", "lang_name", "territory", "country_name" with CLDR/langtable
[thirdparty/glibc.git] / scripts / backport-support.sh
CommitLineData
d2583c0b
FW
1#!/bin/bash
2# Create a patch which backports the support/ subdirectory.
04277e02 3# Copyright (C) 2017-2019 Free Software Foundation, Inc.
d2583c0b
FW
4# This file is part of the GNU C Library.
5
6# The GNU C Library is free software; you can redistribute it and/or
7# modify it under the terms of the GNU Lesser General Public
8# License as published by the Free Software Foundation; either
9# version 2.1 of the License, or (at your option) any later version.
10
11# The GNU C Library is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14# Lesser General Public License for more details.
15
16# You should have received a copy of the GNU Lesser General Public
17# License along with the GNU C Library; if not, see
5a82c748 18# <https://www.gnu.org/licenses/>.
d2583c0b
FW
19
20# This script does not backport the Makefile tweaks outside the
21# support/ directory (which need to be backported separately), or the
22# changes to test-skeleton.c (which should not be backported).
23
24set -e
25
26export LC_ALL=C
27export GIT_CONFIG=/dev/null
28export GTT_CONFIG_NOSYSTEM=0
29export GIT_PAGER=
30
31usage () {
32 cat >&2 <<EOF
33usage: $0 {patch|commit}
34EOF
35 exit 1
36}
37
38if test $# -ne 1 ; then
39 usage
40fi
41
42command="$1"
43
44case "$command" in
45 patch|commit)
46 ;;
47 *)
48 usage
49 ;;
50esac
51
52# The upstream branch to work on.
53branch=origin/master
54
55# The commit which added the support/ directory.
56initial_commit=c23de0aacbeaa7a091609b35764bed931475a16d
57
58# We backport the support directory and this script. Directories need
59# to end in a /.
60patch_targets="support/ scripts/backport-support.sh"
61
62latest_commit="$(git log --max-count=1 --pretty=format:%H "$branch" -- \
63 $patch_targets)"
64
65# Simplify the branch name somewhat for reporting.
66branch_name="$(echo "$branch" | sed s,^origin/,,)"
67
68command_patch () {
69 cat <<EOF
70This patch creates the contents of the support/ directory up to this
71upstream commit on the $branch_name branch:
72
73EOF
74 git log --max-count=1 "$latest_commit"
75 echo
76 git diff "$initial_commit"^.."$latest_commit" $patch_targets
77 echo "# Before applying the patch, run this command:" >&2
78 echo "# rm -rf $patch_targets" >&2
79}
80
81command_commit () {
82 git status --porcelain | while read line ; do
83 echo "error: working copy is not clean, cannot commit" >&2
84 exit 1
85 done
86 for path in $patch_targets; do
87 echo "# Processing $path" >&2
88 case "$path" in
89 [a-zA-Z0-9]*/)
90 # Directory.
91 git rm --cached --ignore-unmatch -r "$path"
92 rm -rf "$path"
93 git read-tree --prefix="$path" "$latest_commit":"$path"
94 git checkout "$path"
95 ;;
96 *)
97 # File.
98 git show "$latest_commit":"$path" > "$path"
99 git add "$path"
100 esac
101 done
102 git commit -m "Synchronize support/ infrastructure with $branch_name
103
104This commit updates the support/ subdirectory to
105commit $latest_commit
106on the $branch_name branch.
107"
108}
109
110command_$command