forked from itsnotlupus/nmcsocks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·72 lines (63 loc) · 1.88 KB
/
build.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/bin/sh
if [ ! -f "$1" ]
then
echo "Build a binary version of NmcSocks using a node.js tarball."
echo "Usage: $0 <node-tarball.tgz> [openssl_dir]"
exit 1
fi
# This is for MingW, which apparently needs to be told where openssl hangs at.
if [ -d "$2" ]
then
echo "Using $2 as openssl build directory.."
FLAGS=" --openssl-libpath=$2 --openssl-includes=$2/include"
else
FLAGS=""
fi
echo "* Flattening NmcSocks Source Files."
rm -rf flat/
mkdir -p flat
cp lib/*.js flat/
cp lib/ndns/*.js flat/
cp node_modules/optimist/index.js flat/optimist.js
cp node_modules/optimist/node_modules/wordwrap/index.js flat/wordwrap.js
#cat node_modules/binary/index.js | perl -pe 's{./lib/vars.js}{vars}g' > flat/binary.js
cp node_modules/binary/index.js flat/binary.js
cp node_modules/binary/lib/vars.js flat/vars.js
cp node_modules/binary/node_modules/put/index.js flat/put.js
cp node_modules/binary/node_modules/buffers/index.js flat/buffers.js
cp node_modules/binary/node_modules/chainsaw/index.js flat/chainsaw.js
cp node_modules/binary/node_modules/chainsaw/node_modules/traverse/index.js flat/traverse.js
cp lib/_third_party_main.js flat/_third_party_main.js
cp lib/_dcrypt.js flat/dcrypt.js
# convert all require("./path/file") to require("file")
cd flat
for file in *
do
perl -pi -e 's{require\(['\''"][^"'\'']+/([^"'\''/]+)['\''"]\)}{require("$1")}g' "$file"
done
cd ..
echo "* Unzipping node.js tarball."
rm -rf tmp/
mkdir -p tmp
cd tmp
tar zxf ../"$1"
cd *
echo "* Patching node.js"
cp ../../flat/* lib/
perl -pi -e 's{(node::ParseArgs\(&?argc, argv\);)}{//$1};' src/node.cc
echo "* Building node.js"
./configure $FLAGS && make
cd ../..
cp tmp/*/build/default/node nmcsocks
if [ -f nmcsocks.exe ]
then
strip nmcsocks.exe
elif [ -f nmcsocks ]
then
strip nmcsocks
else
echo "## Something went wrong. No executable was built."
exit 1
fi
echo "* nmcsocks is ready."
# more error checking would be nice..