1 | #!/bin/bash |
---|
2 | ## this script generates executables for jiwigo |
---|
3 | ## to use it, you have to download the "work" directory |
---|
4 | ## here : http://www.jiwigo.com/downloads/work.tar.gz |
---|
5 | ## you just have to change work_path to indicate the path to "work" |
---|
6 | ## and "project_path" to the path of the project. |
---|
7 | ## you have to run the mvn jar command before launching this script |
---|
8 | ## the mvn command is writter in the install file of the project : install/install.txt |
---|
9 | ## all the generated files will be moved to the "generation" directory. |
---|
10 | ## the package dpkg-dev must be installed |
---|
11 | work_path='/home/mael/Documents/jiwigo/work' |
---|
12 | project_path='/home/mael/workspace/jiwigo' |
---|
13 | target_path=$project_path/target |
---|
14 | |
---|
15 | |
---|
16 | |
---|
17 | ############################################################################################### |
---|
18 | ##################### building deb ############################## |
---|
19 | ############################################################################################### |
---|
20 | |
---|
21 | |
---|
22 | echo '##### building deb... #####' |
---|
23 | cd $work_path |
---|
24 | |
---|
25 | |
---|
26 | #Calculate size and version to complete debian's control file |
---|
27 | size=`du -cs jiwigo` |
---|
28 | size=`echo $size | cut -d ' ' -f 1` |
---|
29 | version=`find $target_path -type f -name \*with-dependencies.jar | xargs -I file echo file | cut -d '-' -f 2` |
---|
30 | cp $work_path/templates/control_template $work_path/temp |
---|
31 | echo Version: $version >> $work_path/temp |
---|
32 | echo Installed-Size: $size >> $work_path/temp |
---|
33 | rm $work_path/jiwigo/DEBIAN/control |
---|
34 | mv temp $work_path/jiwigo/DEBIAN/control |
---|
35 | |
---|
36 | #copies sources |
---|
37 | rm -rf $work_path/jiwigo/usr/share/jiwigo/src/src-jiwigo/* |
---|
38 | cp -r $project_path/src/* $work_path/jiwigo/usr/share/jiwigo/src/src-jiwigo/ |
---|
39 | |
---|
40 | #copies the jar |
---|
41 | rm $work_path/jiwigo/usr/share/jiwigo/jiwigo.jar |
---|
42 | find $target_path -type f -name \*with-dependencies.jar -exec cp {} $work_path/jiwigo/usr/share/jiwigo/jiwigo.jar \; |
---|
43 | |
---|
44 | #delete temporary files |
---|
45 | find "$work_path" | egrep "~$" | perl -n -e 'system("rm $_");' |
---|
46 | |
---|
47 | #changes current directory |
---|
48 | cd "$work_path" |
---|
49 | |
---|
50 | #makes deb |
---|
51 | dpkg-deb --build jiwigo |
---|
52 | |
---|
53 | rm "$work_path/depot/jiwigo.deb" |
---|
54 | rm "$work_path/depot/Packages.gz" |
---|
55 | #moves deb |
---|
56 | mv -f "$work_path/jiwigo.deb" "$work_path/depot/jiwigo.deb" |
---|
57 | |
---|
58 | #makes Packages.gz |
---|
59 | cd "$work_path/depot" |
---|
60 | dpkg-scanpackages . /dev/null | gzip - > Packages.gz |
---|
61 | |
---|
62 | |
---|
63 | ############################################################################################### |
---|
64 | ##################### Building exe ############################## |
---|
65 | ############################################################################################### |
---|
66 | |
---|
67 | echo '##### building exe... #####' |
---|
68 | cd $work_path |
---|
69 | work_path_for_sed="$(echo $work_path | sed 's/\//\\\//g')" |
---|
70 | sed 's/#jar_location/'$work_path_for_sed'\/jiwigo\/usr\/share\/jiwigo\/jiwigo.jar/g' templates/launch4j_template.xml > launch4j_tmp.xml |
---|
71 | sed 's/#exe_location/'$work_path_for_sed'\/jiwigo.exe/g' launch4j_tmp.xml > launch4j.xml |
---|
72 | rm launch4j_tmp.xml |
---|
73 | $work_path/launch4j/launch4j $work_path/launch4j.xml |
---|
74 | rm launch4j.xml |
---|
75 | |
---|
76 | |
---|
77 | ############################################################################################### |
---|
78 | ##################### completes generation folder ############################## |
---|
79 | ############################################################################################### |
---|
80 | |
---|
81 | echo '##### completing generation folder... #####' |
---|
82 | rm $work_path/generation/* |
---|
83 | mv $work_path/jiwigo.exe $work_path/generation/ |
---|
84 | cp $work_path/depot/jiwigo.deb $work_path/generation/ |
---|
85 | cp $work_path/jiwigo/usr/share/jiwigo/jiwigo.jar $work_path/generation/ |
---|
86 | cd $project_path/ |
---|
87 | tar -zcf $work_path/generation/jiwigo-src.tar.gz --exclude '.*' src pom.xml install |
---|
88 | echo '##### Done #####' |
---|