patchinstall.sh: Some style fixes, use underscore for local variables.

This commit is contained in:
Sebastian Lackner 2015-05-06 22:22:46 +02:00
parent 1143708578
commit 552d300345
2 changed files with 88 additions and 70 deletions

View File

@ -182,70 +182,75 @@ if ! command -v diff >/dev/null 2>&1 ||
! command -v grep >/dev/null 2>&1 ||
! command -v cmp >/dev/null 2>&1; then
update_configure ()
update_configure()
{{
autoreconf -f
}}
update_protocol ()
update_protocol()
{{
./tools/make_requests
}}
else
update_configure ()
update_configure()
{{
file="./configure"
_file="./configure"
if ! cp -a "$file" "$file.old"; then
abort "failed to create $file.old"
if ! cp -a "$_file" "$_file.old"; then
abort "failed to create $_file.old"
fi
if ! autoreconf -f; then
rm "$file.old"
rm "$_file.old"
unset _file
return 1
fi
# Shifting by 62 bits is undefined behaviour when off_t is 32-bit, see also
# https://launchpad.net/ubuntu/+source/autoconf/2.69-6 - the bug is still
# present in some other distros (including Archlinux).
large_off_old="^#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))$"
large_off_new="#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))"
sed -i'' -e "s|$large_off_old|$large_off_new|g" "$file"
_large_off_old="^#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))$"
_large_off_new="#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))"
sed -i'' -e "s|$_large_off_old|$_large_off_new|g" "$_file"
unset _large_off_old _large_off_new
# Restore original timestamp when nothing changed
if ! cmp "$file.old" "$file" >/dev/null; then
rm "$file.old"
if ! cmp "$_file.old" "$_file" >/dev/null; then
rm "$_file.old"
else
mv "$file.old" "$file"
mv "$_file.old" "$_file"
fi
unset _file
return 0
}}
update_protocol ()
update_protocol()
{{
file="./include/wine/server_protocol.h"
_file="./include/wine/server_protocol.h"
if ! cp -a "$file" "$file.old"; then
abort "failed to create $file.old"
if ! cp -a "$_file" "$_file.old"; then
abort "failed to create $_file.old"
fi
if ! ./tools/make_requests; then
rm "$file.old"
rm "$_file.old"
unset _file
return 1
fi
# Restore original timestamp when nothing changed
if diff -u "$file.old" "$file" |
if diff -u "$_file.old" "$_file" |
grep -v "^[+-]#define SERVER_PROTOCOL_VERSION" |
grep -v "^\(+++\|---\)" | grep -q "^[+-]"; then
rm "$file.old"
rm "$_file.old"
else
mv "$file.old" "$file"
mv "$_file.old" "$_file"
fi
unset _file
return 0
}}
fi
@ -274,7 +279,7 @@ if test "$backend" = "patch"; then
enable_autoconf=1
fi
patch_apply_file ()
patch_apply_file()
{{
echo "Applying $1"
if ! "$patchdir/gitapply.sh" $gitapply_args < "$1"; then
@ -303,11 +308,11 @@ elif test "$backend" = "epatch"; then
enable_autoconf=1
fi
patch_apply_file ()
patch_apply_file()
{{
shortname="$(basename "$1")"
_shortname="$(basename "$1")"
if grep -q "^GIT binary patch" "$1"; then
ebegin "Applying $shortname"
ebegin "Applying $_shortname"
if ! "$patchdir/gitapply.sh" $gitapply_args < "$1"; then
die "Failed Patch: $1!"
fi
@ -316,6 +321,7 @@ elif test "$backend" = "epatch"; then
else
epatch "$1" # epatch calls die upon failure
fi
unset _shortname
}}
# GIT backend - apply patches using 'git am'
@ -325,14 +331,14 @@ elif test "$backend" = "git" -o "$backend" = "git-am"; then
abort "Backend 'git-am' not possible when DESTDIR points to a git subdirectory."
fi
patch_apply_file ()
patch_apply_file()
{{
echo "Applying $1"
if ! git am "$1"; then
abort "Failed to apply patch, aborting!"
fi
if test "$enable_autoconf" -gt 1; then
do_commit=0
_do_commit=0
# Run 'autoreconf -f' if required
if git show --pretty=format: --name-only | grep -q "^\(configure.ac\|aclocal.m4\)$"; then
@ -341,7 +347,7 @@ elif test "$backend" = "git" -o "$backend" = "git-am"; then
fi
git add ./configure
git add ./include/config.h.in
do_commit=1
_do_commit=1
fi
# Run './tools/make_requests' if required
@ -352,14 +358,16 @@ elif test "$backend" = "git" -o "$backend" = "git-am"; then
git add ./include/wine/server_protocol.h
git add ./server/trace.c
git add ./server/request.h
do_commit=1
_do_commit=1
fi
if test "$do_commit" -ne 0; then
if test "$_do_commit" -ne 0; then
if ! git commit --amend --reuse-message HEAD; then
abort "Failed to include autogenerated changes in commit."
fi
fi
unset _do_commit
fi
}}
@ -375,7 +383,7 @@ elif test "$backend" = "git-apply"; then
enable_autoconf=1
fi
patch_apply_file ()
patch_apply_file()
{{
echo "Applying $1"
if ! git apply "$1"; then
@ -395,20 +403,21 @@ elif test "$backend" = "stg"; then
enable_patchlist=0
enable_autoconf=0
patch_apply_file ()
patch_apply_file()
{{
echo "Applying $1"
shortname="$(basename "$1")"
if ! echo "staging/$shortname" | cat - "$1" | stg import; then
_shortname="$(basename "$1")"
if ! echo "staging/$_shortname" | cat - "$1" | stg import; then
abort "Failed to apply patch, aborting!"
fi
unset _shortname
}}
else
abort "Selected backend $backend not supported."
fi
patch_apply ()
patch_apply()
{{
patch_apply_file "$patchdir/$1"
}}

View File

@ -980,70 +980,75 @@ if ! command -v diff >/dev/null 2>&1 ||
! command -v grep >/dev/null 2>&1 ||
! command -v cmp >/dev/null 2>&1; then
update_configure ()
update_configure()
{
autoreconf -f
}
update_protocol ()
update_protocol()
{
./tools/make_requests
}
else
update_configure ()
update_configure()
{
file="./configure"
_file="./configure"
if ! cp -a "$file" "$file.old"; then
abort "failed to create $file.old"
if ! cp -a "$_file" "$_file.old"; then
abort "failed to create $_file.old"
fi
if ! autoreconf -f; then
rm "$file.old"
rm "$_file.old"
unset _file
return 1
fi
# Shifting by 62 bits is undefined behaviour when off_t is 32-bit, see also
# https://launchpad.net/ubuntu/+source/autoconf/2.69-6 - the bug is still
# present in some other distros (including Archlinux).
large_off_old="^#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))$"
large_off_new="#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))"
sed -i'' -e "s|$large_off_old|$large_off_new|g" "$file"
_large_off_old="^#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))$"
_large_off_new="#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))"
sed -i'' -e "s|$_large_off_old|$_large_off_new|g" "$_file"
unset _large_off_old _large_off_new
# Restore original timestamp when nothing changed
if ! cmp "$file.old" "$file" >/dev/null; then
rm "$file.old"
if ! cmp "$_file.old" "$_file" >/dev/null; then
rm "$_file.old"
else
mv "$file.old" "$file"
mv "$_file.old" "$_file"
fi
unset _file
return 0
}
update_protocol ()
update_protocol()
{
file="./include/wine/server_protocol.h"
_file="./include/wine/server_protocol.h"
if ! cp -a "$file" "$file.old"; then
abort "failed to create $file.old"
if ! cp -a "$_file" "$_file.old"; then
abort "failed to create $_file.old"
fi
if ! ./tools/make_requests; then
rm "$file.old"
rm "$_file.old"
unset _file
return 1
fi
# Restore original timestamp when nothing changed
if diff -u "$file.old" "$file" |
if diff -u "$_file.old" "$_file" |
grep -v "^[+-]#define SERVER_PROTOCOL_VERSION" |
grep -v "^\(+++\|---\)" | grep -q "^[+-]"; then
rm "$file.old"
rm "$_file.old"
else
mv "$file.old" "$file"
mv "$_file.old" "$_file"
fi
unset _file
return 0
}
fi
@ -1072,7 +1077,7 @@ if test "$backend" = "patch"; then
enable_autoconf=1
fi
patch_apply_file ()
patch_apply_file()
{
echo "Applying $1"
if ! "$patchdir/gitapply.sh" $gitapply_args < "$1"; then
@ -1101,11 +1106,11 @@ elif test "$backend" = "epatch"; then
enable_autoconf=1
fi
patch_apply_file ()
patch_apply_file()
{
shortname="$(basename "$1")"
_shortname="$(basename "$1")"
if grep -q "^GIT binary patch" "$1"; then
ebegin "Applying $shortname"
ebegin "Applying $_shortname"
if ! "$patchdir/gitapply.sh" $gitapply_args < "$1"; then
die "Failed Patch: $1!"
fi
@ -1114,6 +1119,7 @@ elif test "$backend" = "epatch"; then
else
epatch "$1" # epatch calls die upon failure
fi
unset _shortname
}
# GIT backend - apply patches using 'git am'
@ -1123,14 +1129,14 @@ elif test "$backend" = "git" -o "$backend" = "git-am"; then
abort "Backend 'git-am' not possible when DESTDIR points to a git subdirectory."
fi
patch_apply_file ()
patch_apply_file()
{
echo "Applying $1"
if ! git am "$1"; then
abort "Failed to apply patch, aborting!"
fi
if test "$enable_autoconf" -gt 1; then
do_commit=0
_do_commit=0
# Run 'autoreconf -f' if required
if git show --pretty=format: --name-only | grep -q "^\(configure.ac\|aclocal.m4\)$"; then
@ -1139,7 +1145,7 @@ elif test "$backend" = "git" -o "$backend" = "git-am"; then
fi
git add ./configure
git add ./include/config.h.in
do_commit=1
_do_commit=1
fi
# Run './tools/make_requests' if required
@ -1150,14 +1156,16 @@ elif test "$backend" = "git" -o "$backend" = "git-am"; then
git add ./include/wine/server_protocol.h
git add ./server/trace.c
git add ./server/request.h
do_commit=1
_do_commit=1
fi
if test "$do_commit" -ne 0; then
if test "$_do_commit" -ne 0; then
if ! git commit --amend --reuse-message HEAD; then
abort "Failed to include autogenerated changes in commit."
fi
fi
unset _do_commit
fi
}
@ -1173,7 +1181,7 @@ elif test "$backend" = "git-apply"; then
enable_autoconf=1
fi
patch_apply_file ()
patch_apply_file()
{
echo "Applying $1"
if ! git apply "$1"; then
@ -1193,20 +1201,21 @@ elif test "$backend" = "stg"; then
enable_patchlist=0
enable_autoconf=0
patch_apply_file ()
patch_apply_file()
{
echo "Applying $1"
shortname="$(basename "$1")"
if ! echo "staging/$shortname" | cat - "$1" | stg import; then
_shortname="$(basename "$1")"
if ! echo "staging/$_shortname" | cat - "$1" | stg import; then
abort "Failed to apply patch, aborting!"
fi
unset _shortname
}
else
abort "Selected backend $backend not supported."
fi
patch_apply ()
patch_apply()
{
patch_apply_file "$patchdir/$1"
}