This repository has been archived by the owner on Jan 4, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathconfigure
executable file
·154 lines (139 loc) · 4.74 KB
/
configure
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
#!/bin/bash
files='find . -type f -not \( -path "*$0*" -o -path "*git*" -o -path "*skin*" -o -path "*.md*" -o -ipath "*make*" \)'
function replace {
fieldName=$1
oldValue=$2
newValue=$3
verbose=$4
forced=$5
if [[ $forced -ne 1 ]]; then
if [[ $oldValue == $newValue ]]; then
echo "The add-on already uses this $fieldName."
exit 1
fi
if [ -z "`eval $files | xargs egrep $oldValue -l`" ]; then
echo "ERROR: The addon's $fieldName was already customized."
echo "Please clone the repository again to create a new add-on."
exit 1
fi
fi
if [[ $verbose -ne 1 ]]; then
read -p "This add-on's $fieldName will be changed. Continue? (y/n)? "
else
read -p "This add-on's $fieldName will be changed from '$oldValue' to '$newValue'. Continue? (y/n)? "
fi
if [[ $REPLY == "y" ]]; then
if [[ "`uname`" == "Linux" ]]; then
eval $files -print0 | xargs -0 sed -i 's/'"$oldValue"'/'"$newValue"'/g'
elif [[ "`uname`" == "Darwin" ]]; then
eval $files -print0 | xargs -0 sed -i '' 's/'"$oldValue"'/'"$newValue"'/g'
else
echo "ERROR: Your operating system is not supported yet."
exit 1
fi
printf "Done."
if [ $verbose == "1" ]; then
echo " Modified files:"
eval $files | xargs egrep $newValue -l
printf "\n"
else
printf "\n\n"
fi
else
echo "WARNING: No changes were made to the addon's $fieldName."
exit 1
fi
}
function proxy {
profileName=$1
addonDir=$2
addonId=`sed -n 's/<em:id>\(.*\)@mozilla.com<\/em:id>/\1/p' install.rdf | head -n 1 | tr -d ' '`
forced=$3
if [[ "`uname`" == "Linux" ]]; then
profile="~/.mozilla/firefox/*$profileName"
elif [[ "`uname`" == "Darwin" ]]; then
profile="~/Library/Application\ Support/Firefox/Profiles/*$profileName"
else
echo "ERROR: Your operating system is not supported yet."
echo "Please refer to the readme for manually creating an extension proxy file."
exit 1
fi
if [[ $forced -ne 1 ]]; then
read -p "This '$addonId' extension will be linked with the '$profileName' profile. Continue? (y/n)? "
if [[ $REPLY != "y" ]]; then
exit 1
fi
fi
if [[ -n "`eval cd $profile 2>&1`" ]]; then
echo "ERROR: The specified profile does not seem to exist at $profile"
echo "Please refer to the readme for manually creating an extension proxy file."
exit 1
fi
eval cd $profile
mkdir extensions &> /dev/null
touch extensions/[email protected]
echo $addonDir > extensions/[email protected]
echo "Done."
printf "\n"
echo "This add-on will be installed in the '$profileName' profile next time you open Firefox."
echo "Tip: whenever you change something, go to about:addons in Firefox and re-enable the add-on to quickly update it."
}
if [[ $# -eq 0 ]]; then
echo "Customize this add-on template:"
echo " -i <identifier> Specify the id, used to identify resources and files in this bundle"
echo " -n <project name> Specify the name, displayed in the Toolbox and various Firefox menus"
echo " -v <version> Specify the version, useful for tracking bugs"
echo " -d <description> Specify the description, shown on addons.mozilla.org"
echo " -a <autor name> Specify the author, shown on addons.mozilla.org"
echo " -h <url> Specify the add-on's support homepage url"
echo " -P <profile> Create an extension proxy file for this add-on, for the specified profile"
exit 1
fi
while getopts "i:n:v:d:a:h:P:" opt; do
case $opt in
i)
replace "id" "my-addon" $OPTARG 1
;;
n)
replace "name" "MyAddon" $OPTARG 1
;;
v)
regex="\(<em:version>\).*\(<\/em:version>\)"
replace "version" $regex '\1'"$OPTARG"'\2' 0 1
;;
d)
regex="\(<em:description>\).*\(<\/em:description>\)"
replace "description" $regex '\1'"$OPTARG"'\2' 0 1
;;
a)
regex="\(<em:creator>\).*\(<\/em:creator>\)"
replace "author" $regex '\1'"$OPTARG"'\2' 0 1
;;
h)
regex="\(<em:homepageURL>\).*\(<\/em:homepageURL>\)"
replace "homepage" $regex '\1'"$OPTARG"'\2' 0 1
;;
P)
INSTALL_PROFILE=$OPTARG
;;
\?)
echo "Invalid option: -$OPTARG" >&2
exit 1
;;
:)
echo "Option -$OPTARG requires an argument." >&2
exit 1
;;
esac
done
if [[ $INSTALL_PROFILE ]]; then
proxy $INSTALL_PROFILE `pwd`
else
read -p "WARNING: No user profile specified. Do you want this add-on to be installed next time you open Firefox? (y/n) "
if [[ $REPLY == "y" ]]; then
proxy "default" `pwd` 1
else
echo "WARNING: This add-on won't be automatically installed next time you open Firefox."
echo "For a faster development process, please refer to the readme for creating an extension proxy file."
fi
fi