Index: patchconv/rapply.sh |
=================================================================== |
new file mode 100755 |
--- /dev/null |
+++ b/patchconv/rapply.sh |
@@ -0,0 +1,41 @@ |
+#!/bin/bash |
Sebastian Noack
2017/08/23 15:52:33
It seems the only reason this script requires bash
Vasily Kuznetsov
2017/08/23 16:29:39
Done.
|
+# |
+# This file is part of Adblock Plus <https://adblockplus.org/>, |
+# Copyright (C) 2006-2017 eyeo GmbH |
Sebastian Noack
2017/08/23 15:52:33
We don't put the current year into the copyright h
Vasily Kuznetsov
2017/08/23 16:29:39
Done.
|
+# |
+# Adblock Plus is free software: you can redistribute it and/or modify |
+# it under the terms of the GNU General Public License version 3 as |
+# published by the Free Software Foundation. |
+# |
+# Adblock Plus is distributed in the hope that it will be useful, |
+# but WITHOUT ANY WARRANTY; without even the implied warranty of |
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
+# GNU General Public License for more details. |
+# |
+# You should have received a copy of the GNU General Public License |
+# along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
+ |
Sebastian Noack
2017/08/23 15:52:32
It is best practice to put `set -eu` at the top of
Vasily Kuznetsov
2017/08/23 16:29:39
Done.
|
+if [[ "$1" == "" ]]; then |
+ echo "usage: rapply.sh PATCH" |
+ exit 1 |
+fi |
+ |
+SRCFILE="$1" |
+TMPFILE="$TMPDIR/`basename $SRCFILE`" |
Sebastian Noack
2017/08/23 15:52:32
Where does the variable TMPDIR comes from? I don't
Vasily Kuznetsov
2017/08/23 16:29:39
It comes from POSIX (see https://en.wikipedia.org/
|
+ |
+if git st >/dev/null 2>&1; then |
+ IMPORT="git apply" |
+elif hg st >/dev/null 2>&1; then |
+ IMPORT="hg import --no-commit" |
+else |
+ echo "No repository found in `pwd`" |
+ exit 2 |
+fi |
+ |
+if [[ "$SRCFILE" =~ ^https?:// ]]; then |
+ curl "$SRCFILE" | patchconv >"$TMPFILE" || exit 1 |
+else |
+ patchconv <"$SRCFILE" >"$TMPFILE" || exit 1 |
Sebastian Noack
2017/08/23 15:52:33
Nit: Please add a space before and after the angle
Vasily Kuznetsov
2017/08/23 16:29:39
Done.
|
+fi |
+ |
+$IMPORT "$TMPFILE" |
Sebastian Noack
2017/08/23 15:52:32
It seems the temporary file is not cleaned up. But
Vasily Kuznetsov
2017/08/23 16:29:39
You're right, that's better.
Done.
|