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