-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
patches.sh
executable file
·57 lines (49 loc) · 1.61 KB
/
patches.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/bin/sh
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
action=$1
# Make sure the user has specified the location of mozilla-central in their
# environment. Some people (i.e. trickypr) prefer to clone it into other places
if [ ! -f .moz-central ]
then
echo "Please make sure you specify the location of your checkout of `mozilla-central`"
echo "inside of the `.moz-central` file."
exit 1
fi
mozilla_centeral_repo=$(cat .moz-central)
last_patch=`exec ls -1 ./template/patches.optional | sed 's/-.*//g' | sort -n | tail -1`
next_patch=`expr 1 + ${last_patch:=0}`
root_pwd=$PWD
if [ $action = "import" ]
then
echo "Importing:"
echo
cd $mozilla_centeral_repo
for file in $root_pwd/template/patches.optional/*.patch
do
echo " $file..."
# --forward is used to skip the patch if it has already been applied
patch -p1 --forward < $file
done
cd $root_pwd
elif [ $action = "export" ]
then
if [ -x "$2" ]
then
echo "Please provide a file name. Usage: $0 $action <filename>"
exit 1
fi
echo "Exporting: ${@:2}"
echo
cd $mozilla_centeral_repo
git add ${@:2}
git commit
git format-patch --start-number $next_patch -1 -o $root_pwd/template/patches.optional
cd $root_pwd
else
echo "Usage: $0 import|export"
echo
echo " import: Import all patches in ./template/patches.optional"
echo " export: Exports a specific patch. Usage: $0 export <filename>"
fi