-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild
executable file
·144 lines (124 loc) · 4.38 KB
/
build
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
#!/bin/csh
if (-d temp/) then
rm -r temp
endif
if (-d war) then
rm -r war
endif
mkdir temp
mkdir temp/js
mkdir war
mkdir war/js
mkdir war/style
mkdir war/style/images
mkdir war/applogos
mkdir war/images
mkdir war/WEB-INF
echo Obfuscating. Wait, it will take about ten seconds....
#--- list here all the names to be mangled
set to_mangle = ( \
z_language z_months z_date z_btnInstall z_betterInstall z_installFailure \
z_installConflict z_noReceipts \
z_safariInstall z_OK z_cancel z_info z_warning z_error z_confirm z_preferences \
z_edit z_testMode z_noFileApi z_noFileApiProp z_noFileSelected z_pickImageError \
z_whoAmI z_banner z_newLogin z_badLogin z_loginAs z_newAlbum z_authDenied \
z_revokeAccess z_enterTweet z_photosUploaded z_albumCreated z_chooseNetwork \
z_noNetwork z_initLogin z_picasaLogin z_login z_passwd z_selectOrCreateAlbum \
z_createAlbumProlog1 z_createAlbumProlog2 z_title z_description z_albumDescr \
z_photoAlbum z_albumTitle z_email z_phone z_gender z_birthday z_grantedPay \
z_deniedPay z_pendingPay z_cancelPay z_install_changed z_usedLang \
)
#--- the externals for google closure compiler
cat >temp/externs.js <<END_EXTERNALS
Navigator.prototype.mozApps;
Navigator.prototype.mozPay = function(jwts) {};
Navigator.prototype.mozSetMessageHandler = function(type, handler) {};
function Apps() {}
Apps.prototype.getSelf = function() {};
Apps.prototype.install = function(url, opt_args) {};
Apps.prototype.getInstalled = function() {};
function App() {}
App.prototype.manifest;
App.prototype.manifestURL;
App.prototype.origin;
App.prototype.installOrigin;
App.prototype.installTime;
App.prototype.receipts;
App.prototype.launch = function() {};
App.prototype.checkForUpdate = function() {};
function chrome() {}
chrome.prototype.webstore;
chrome.prototype.webstore.install = function(url, ok_callback, fail_callback) {};
chrome.prototype.app;
chrome.prototype.app.isInstalled;
HTMLCanvasElement.prototype.toBlob = function(callback, opt_type, opt_args) {};
Event.prototype.isTrusted;
END_EXTERNALS
# build a sed script to mangle most of our strings
set vals = (a b c d e f g h i j k l m n o p q r s t u v w x y z)
set ix = 1;
set jx = 0;
set p = "";
echo "# sed script" > temp/sedscript
foreach name ($to_mangle)
if ($ix > ${#vals}) then
@ jx++
set p = $vals[$jx]
set ix = 1
endif
echo s\`\(\'\|\"\)$name\(\'\|\"\)\`\\1${p}${vals[$ix]}\\2\` >> temp/sedscript
@ ix++
end
# modify index.html to point at the new css and js
sed -e '/-- REPLACED --/, /-- REPLACEMENT/d' -e '/REPLACE END --/d' pretty/index.html >temp/index.html
switch ($OSTYPE)
case "linux-gnu":
set sedregopt = "r"
breaksw
case "darwin"*:
set sedregopt = "E"
breaksw
default:
set sedregopt = "r"
breaksw
endsw
# mangle our strings in index.html
sed -$sedregopt -f temp/sedscript temp/index.html > war/index.html
# mangle our strings in all js files
foreach file(pretty/js/*.js)
sed -$sedregopt -f temp/sedscript $file > temp/js/`basename $file`
end
# compress the style sheets
foreach file(pretty/style/*.css)
java -classpath ../.. -jar buildlib/yui.jar $file >> war/style/jaxogram.min.css
end
# cook the proper java command to obfuscate all js files (closure compiler)
set jarcmd = "java -jar buildlib/compiler.jar --compilation_level ADVANCED_OPTIMIZATIONS --externs temp/externs.js --js_output_file=war/js/jaxogram.min.js"
# to avoid obfuscation (debug):
# set jarcmd = "java -jar buildlib/compiler.jar --compilation_level WHITESPACE_ONLY --formatting PRETTY_PRINT --externs temp/externs.js --js_output_file=war/js/jaxogram.min.js"
foreach file(temp/js/*.js)
set jarcmd = "${jarcmd} --js=${file}"
end
# do the obfuscation
$jarcmd >& temp/warn
# copy other required files to dist
cp -p pretty/WEB-INF/appengine-web.xml war/WEB-INF
cp -p pretty/WEB-INF/web.xml war/WEB-INF
cp -p pretty/WEB-INF/logging.properties war/WEB-INF
cp -p -r pretty/WEB-INF/lib war/WEB-INF
cp -p pretty/manifest.webapp war
cp -p pretty/hosted_manifest.webapp war
cp -p pretty/favicon.ico war
cp -p pretty/images/* war/images
cp -p -r pretty/style/images/* war/style/images
cp -p pretty/applogos/* war/applogos
# zip it
if (-e jaxogram.zip) then
rm jaxogram.zip
endif
cd war
# zip -r ../jaxogram.zip * >& ../temp/zipped
zip ../jaxogram.zip \
-r manifest.webapp index.html favicon.ico js style applogos images \
>& ../temp/zipped
echo All done. Result in jaxogram.zip