| 1 | #!/bin/sh |
| 2 | |
| 3 | adonthell_exe="adonthell-0.3.exe" |
| 4 | |
| 5 | # -- check arg |
| 6 | if test "x$1" = "x" ; then |
| 7 | echo "Usage: $0 <path/to/Adonthell>" |
| 8 | exit 1 |
| 9 | fi |
| 10 | |
| 11 | if test ! -f $1"/bin/$adonthell_exe" ; then |
| 12 | echo "Error: $1 is not the expected adonthell package" |
| 13 | exit 1 |
| 14 | fi |
| 15 | |
| 16 | # -- determine installer architecture (x64 or x86) |
| 17 | arch=`file $1"/bin/$adonthell_exe" | grep -o -e x86-64 -e 80386` |
| 18 | case $arch in |
| 19 | x86-64) |
| 20 | arch="x64" |
| 21 | ;; |
| 22 | 80386) |
| 23 | arch="x86" |
| 24 | ;; |
| 25 | *) |
| 26 | echo "Unknown platform $arch" |
| 27 | exit 1 |
| 28 | ;; |
| 29 | esac |
| 30 | |
| 31 | # -- check working directory |
| 32 | if [ ! -f "wastesedge.wxs" ]; then |
| 33 | echo "This script must be run in the wastesedge-0.3.x/win32 directory" |
| 34 | exit 1 |
| 35 | fi |
| 36 | |
| 37 | # -- check Wix Toolkit |
| 38 | if [ ! -x "$(command -v heat)" ]; then |
| 39 | echo "This script requires the WiX toolset installed and in your PATH" |
| 40 | echo "See http://wixtoolset.org/" |
| 41 | exit 1 |
| 42 | fi |
| 43 | |
| 44 | # -- get adonthell version |
| 45 | adonthell_ver=`$1/bin/$adonthell_exe -v` |
| 46 | |
| 47 | # -- codesign Adonthell exe |
| 48 | if [ -x "$(command -v signtool)" ]; then |
| 49 | echo "Codesigning $adonthell_exe" |
| 50 | MSYS2_ARG_CONV_EXCL=/t signtool.exe sign /t http://timestamp.comodoca.com/authenticode $1/bin/$adonthell_exe |
| 51 | fi |
| 52 | |
| 53 | echo "Creating wastesedge-$adonthell_ver-$arch.msi" |
| 54 | |
| 55 | # -- check if the User Manual.pdf is present |
| 56 | if [ ! -f "../User\ Manual.pdf" ]; then |
| 57 | manual=1 |
| 58 | else |
| 59 | echo "PDF Manual not present. Will not be included in installer." |
| 60 | manual=0 |
| 61 | fi |
| 62 | |
| 63 | # -- clean up any __pycache__ directories before collecting package contents |
| 64 | find $1 -name __pycache__ -execdir rm -rf __pycache__ \; |
| 65 | |
| 66 | # -- collect package contents |
| 67 | heat dir "$1" -cg WastesedgePackage -dr INSTALLDIR -gg -sfrag -srd -sw5150 -template fragment -out package.wxs |
| 68 | if [ $? -ne 0 ]; then |
| 69 | exit 1 |
| 70 | fi |
| 71 | |
| 72 | # -- compile |
| 73 | candle -arch $arch -dVersion="$adonthell_ver" -dArch="$arch" -dHaveManual="$manual" wastesedge.wxs package.wxs |
| 74 | if [ $? -ne 0 ]; then |
| 75 | exit 1 |
| 76 | fi |
| 77 | |
| 78 | # -- link |
| 79 | light -b $1 -sw1076 -ext WixUIExtension wastesedge.wixobj package.wixobj -o wastesedge-$adonthell_ver-$arch.msi |
| 80 | if [ $? -ne 0 ]; then |
| 81 | exit 1 |
| 82 | fi |
| 83 | |
| 84 | # -- codesign installer |
| 85 | if [ -x "$(command -v signtool)" ]; then |
| 86 | echo "Codesigning wastesedge-$adonthell_ver-$arch.msi" |
| 87 | MSYS2_ARG_CONV_EXCL="/d;/t" signtool.exe sign /t http://timestamp.comodoca.com/authenticode /d "Adonthell - Waste's Edge v$adonthell_ver ($arch)" wastesedge-$adonthell_ver-$arch.msi |
| 88 | fi |
| 89 | |
| 90 | # -- cleanup |
| 91 | rm wastesedge-$adonthell_ver-$arch.wixpdb |
| 92 | rm wastesedge.wixobj |
| 93 | rm package.wixobj |
| 94 | rm package.wxs |