jordansissel / fpm

Effing package management! Build packages for multiple platforms (deb, rpm, etc) with great ease and sanity.
http://fpm.readthedocs.io/en/latest/
Other
11.17k stars 1.07k forks source link

The OS X installer encountered an error #898

Closed subnetmarco closed 9 years ago

subnetmarco commented 9 years ago

I have created an OS X package, but when trying to install it I get the following error:

The install failed (The Installer encountered an error that caused the installation to fail. Contact the software manufacturer for assistance.)

This is the script: https://gist.github.com/thefosk/d17a3acf0eb22aaf4eca (which works fine for deb and rpm packages)

Basically the script detects the operating system and if ran on OS X it will generate a pkg with the following software:

The problem occurs when trying to install the pkg on OS X 10.10, specifically at the Validating packages phase:

$ sudo installer -verbose -pkg kong-0.1.1beta-2.pkg -target /
installer: Package name is kong-0.1.1beta-2
installer: Installing at base path /
installer: Preparing for installation….....
installer: Preparing the disk….....
installer: Preparing kong-0.1.1beta-2….....
installer: Waiting for other installations to complete….....
installer: Configuring the installation….....
installer:
#
installer: Moving items into place….....
installer: Validating packages….....
#
installer: The install failed (The Installer encountered an error that caused the installation to fail. Contact the software manufacturer for assistance.)

Here is the output with -verboseR:

$ sudo installer -verboseR -pkg kong-0.1.1beta-2.pkg -target /
Password:
Sorry, try again.
Password:
installer: Package name is kong-0.1.1beta-2
installer: Installing at base path /
installer:PHASE:Preparing for installation…
installer:PHASE:Preparing the disk…
installer:PHASE:Preparing kong-0.1.1beta-2…
installer:PHASE:Waiting for other installations to complete…
installer:PHASE:Configuring the installation…
installer:STATUS:
installer:%42.770603
installer:PHASE:Moving items into place…
installer:PHASE:Validating packages…
installer:%97.750000
installer: The install failed (The Installer encountered an error that caused the installation to fail. Contact the software manufacturer for assistance.)
subnetmarco commented 9 years ago

I have further debugged this manually, and it seems like removing the --after-install argument will make it work. I will keep debugging the issue and understand why --after-install doesn't work on OS X. The script that I am running might be wrong.

subnetmarco commented 9 years ago

The after script seems to be right, but it still doesn't work. I have found a workaround and I'm not using the --after-install anymore. No idea why it doesn't work on OS X.

jordansissel commented 9 years ago

Hmm, weird. Thanks for doing some debugging! Can you show your --after-install script?

jordansissel commented 9 years ago

I'm able to reproduce, I think:

% fpm -s empty --after-install =(printf "#\!/bin/sh\nhello world\n") -n fizz -t osxpkg
Created package {:path=>"fizz-1.0.pkg"}

% sudo installer -pkg fizz-1.0.pkg -target /
installer: Package name is fizz-1.0
installer: Installing at base path /
installer: The install failed (The Installer encountered an error that caused the installation to fail. Contact the software manufacturer for assistance.)
jordansissel commented 9 years ago

Oops, haha, I had a typo. It was failing because it tried to run "Hello" as a command. Silly me!

Here's trying it myself, and having it work:

# I used --debug and --debug-workspace to help me see what is going on
% fpm -f --debug --debug-workspace -s empty --after-install =(printf "#\!/bin/sh\necho hello world\n") -n fizz -t osxpkg
...
Created package {:path=>"fizz-1.0.pkg", :file=>"clamp/command.rb", :line=>"67", :method=>"run"}

% sudo installer -pkg fizz-1.0.pkg -target /
installer: Package name is fizz-1.0
installer: Upgrading at base path /
installer: The upgrade was successful.
subnetmarco commented 9 years ago

My script basically creates a folder in etc and moves a file into it:

# Make the package
post_install_script=$(mktemp -t post_install_script.XXX.sh)
echo "mkdir -p /etc/kong;cp /usr/local/lib/luarocks/rocks/kong/$KONG_VERSION/conf/kong.yml /etc/kong/kong.yml" > $post_install_script

cd $OUT
fpm -a all -f -s dir -t $PACKAGE_TYPE -n "kong" -v ${KONG_VERSION} ${FPM_PARAMS} \
--iteration 1 \
--description 'Kong is an open distributed platform for your APIs, focused on high performance and reliability.' \
--vendor Mashape \
--license MIT \
--url http://getkong.org/ \
--after-install $post_install_script \
usr
jordansissel commented 9 years ago

While the verbose output of installer seems ... not awesome, I think we can try debugging this. We'll need to unpack the .pkg file:

# Unpack the .pkg file:
% mkdir /tmp/pkg
% xar -x -f fizz-1.0.pkg -C /tmp/pkg

# Unpack the scripts:
% gzip -dc /tmp/pkg/Scripts | (cd /tmp/pkg; cpio -iv)

# Run the postinstall script manually:
% /tmp/pkg/postinstall
hello world

Try repeating this with your package, see what happens when you run your script?

I suspect, based on your previous comment including your build step, that the post_install_script.XXX.sh is missing a #!/bin/sh header on the first line, so when OSX executes it, it doesn't know what to do, though that's just a hunch.

subnetmarco commented 9 years ago

A missing #!/bin/sh was the problem indeed. Thanks.