-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
69 lines (61 loc) · 1.54 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
#!/bin/bash
project_name=$1
node_file=$2
suffix=$3
download_url=$4
function download_node() {
mkdir -p build
echo "downloading $node_file"
wget -c -O build/$node_file --no-check-certificate $download_url
echo "download over"
}
if [ -f "build/$node_file" ]; then
echo "node pkg already download"
else
download_node
fi
extract_arg=''
ext=.tar
if [[ "$node_file" == *.gz ]]; then
extract_arg='xzf'
ext="${ext}.gz"
else
extract_arg='Jxf'
ext="${ext}.xz"
fi
dir_name=$(basename $node_file $ext)
function extract_and_init_node() {
rm -rf build/$dir_name
echo "extract node tar"
tar -$extract_arg build/$node_file -C build/
echo "extract over"
current_path=$(pwd)
export PATH=$current_path/build/$dir_name/bin:$PATH
echo "install pm2"
npm install -g pm2
echo "install pm2 over"
mv build/$dir_name build/$project_name
}
if [ -d "build/$project_name" ]; then
echo "node already extracted"
else
extract_and_init_node
fi
echo "copy project..."
resources_path=build/$project_name/resources
rm -rf $resources_path
mkdir -p $resources_path
chmod +x bin/*
/bin/cp -f bin/* build/$project_name/bin/
/bin/cp -rf node_modules $resources_path
/bin/cp -rf core $resources_path
/bin/cp -rf config build/$project_name/
/bin/cp -rf core $resources_path
/bin/cp -f App.js $resources_path
/bin/cp -f LICENSE $resources_path
/bin/cp -f package.json $resources_path
/bin/cp -f package-lock.json $resources_path 2>/dev/null
echo "copy over"
echo "pkg project..."
tar -Jcf build/${project_name}-${suffix}.tar.xz -C build/ $project_name
echo "> pkg finished!"