Mac OSx PKG preinstall script issue

2.5k views Asked by At

I have a problem with running preinstall script within PKG I created for Mac OS X on linux machine.

My problem is, that preinstall script is not executed and installer finishes with sucess, even my script should cause the failure.

I have prepared following directory structure on the hard-drive:

./Applications
./Resources
./Scripts

by running of following commands:

mkdir -p Payload.pkg
chmod -R a+w Applications
chmod a+x Scripts/preinstall

mkbom -u 0 -g 0 Applications Payload.pkg/Bom

find Applications | cpio --owner 0:0 -H odc -o | gzip -c > Payload.pkg/Payload

pushd Scripts
find . | cpio --owner 0:0 -H odc -o | gzip -c > Payload.pkg/Scripts
popd

chmod a+x Payload.pkg/Scripts

xar --compress none -cf MyApp.pkg Distribution Resources Payload.pkg

I have created package with following structure:

My package.pkg
    +--Distribution
    +--Resources
        +--welcome.rtf
    +--Payload.pkg
        +--Scripts
        +--Bom
        +--PackageInfo
        +--Payload

my preinstall scripts has following content:

#!/bin/bash
##preinstall

pathToScript=$0
pathToPackage=$1
TargetLocation=$2
targetVolume=$3

exit 1

Which should be causing failure of the installer. However it does not. It seems, that script is not invoked.

Could somebody help me please?

1

There are 1 answers

0
miken32 On BEST ANSWER

If you want a script to be called, it needs to be included in the <scripts> section of PackageInfo like so:

  <scripts>
      <preinstall file="./preinstall"/>
  </scripts>

Source: https://hogliux.github.io/bomutils/tutorial.html