1+ if [ " $# " -ne 1 ]
2+ then
3+ echo " usage: $0 <buildNumber>"
4+ exit
5+ fi
6+
7+ buildnumber=" $1 "
8+ url=" https://buildmaster.lubar.me/artifacts/download?applicationId=48&releaseNumber=dfhack-0.47.04-r1&buildNumber=${1} &artifactName="
9+ dst=" release"
10+ pre=" dfplex-v0.2-"
11+ assets=" ${pre} assets"
12+ root=` pwd`
13+
14+ if [ ! -d " static" ]
15+ then
16+ echo " static/ folder not found -- is this the right directory?"
17+ exit 1
18+ fi
19+
20+ if [ -d " $dst " ]
21+ then
22+ echo " Removing previous..."
23+ rm -r " $dst "
24+ fi
25+
26+ # ########### create assets template #############
27+ echo " Creating asset template..."
28+ mkdir " $dst " && cd " $dst " && mkdir " $assets " && cd " $assets "
29+
30+ # dist/shared
31+ for filename in $root /dist/shared/*
32+ do
33+ if [ -d " $filename " ]
34+ then
35+ cp -r " $filename " .
36+ elif [ -f " $filename " ]
37+ then
38+ cp " $filename " .
39+ fi
40+ done
41+
42+ # static
43+ cp -r " $root /static" " ./hack/www"
44+
45+ # dfhack init
46+ cp " $root /devel/dfhack.init" .
47+
48+ # license
49+ cp " $root /LICENSE.rst" .
50+
51+ # ########### create target packages #############
52+ for platform in " Windows32" " Windows64" " Linux32" " Linux64"
53+ do
54+ cd " $root /$dst "
55+ echo " assembling ${platform} "
56+ target=" ${pre}${platform} "
57+ cp -r " ${assets} " " ${target} "
58+ cd " ${target} /hack"
59+ if [ ! -d " plugins" ]
60+ then
61+ mkdir " plugins"
62+ fi
63+ cd " plugins"
64+
65+ # Download zip from build server
66+ wget -O " artifact.zip" " ${url}${platform} "
67+ if [ $? -ne 0 ]
68+ then
69+ echo " Failed to download artifact for $platform " .
70+ exit 2
71+ fi
72+
73+ # extract zip
74+ 7z e " artifact.zip"
75+ if [ $? -ne 0 ]
76+ then
77+ echo " Failed to extract zip for $platform " .
78+ exit 3
79+ fi
80+
81+ # remove zip to avoid name clash with next step.
82+ rm " artifact.zip"
83+
84+ # extract zip
85+ zip=` find . -name " *.zip" `
86+ if [ -f " $zip " ]
87+ then
88+ 7z e " $zip "
89+ if [ $? -ne 0 ]
90+ then
91+ echo " Failed to extract archive for $platform " .
92+ exit 5
93+ fi
94+ fi
95+
96+ # extract tar.gz
97+ targz=` find . -name " *.tar.gz" `
98+ if [ -f " $targz " ]
99+ then
100+ tar -xf " $targz "
101+ if [ $? -ne 0 ]
102+ then
103+ echo " Failed to extract archive for $platform " .
104+ exit 5
105+ fi
106+ fi
107+
108+ if find . | grep -q " dfplex.plug.*"
109+ then
110+ echo " Extracted binary for $platform successfully."
111+ else
112+ echo " failed to extract binary from archive for $platform . Contents are:"
113+ find .
114+ exit 4
115+ fi
116+
117+ # clean up.
118+ touch " a.zip"
119+ touch " a.tar.gz"
120+ rm * .zip
121+ rm * .tar.gz
122+
123+ cd " $root /$dst "
124+ echo " Creating $target .zip ..."
125+ 7z a " $target .zip" " $target "
126+
127+ if [ $? -ne 0 ]
128+ then
129+ echo " Failed to create archive for $platform , $target .zip" .
130+ exit 7
131+ fi
132+
133+ echo " "
134+ done
0 commit comments