Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

macOS packaging for beats #6344

Closed
wants to merge 4 commits into from
Closed

macOS packaging for beats #6344

wants to merge 4 commits into from

Conversation

adriansr
Copy link
Contributor

@adriansr adriansr commented Feb 9, 2018

Added support to create signed PKG installers, bundled in a DMG file with a rudimentary uninstaller in it.

Currently disconnected from the packaging flow, must be run by hand after make package

Will be run by dev-tools/deploy given the environment variables KEYCHAIN and KEYCHAN_PASS point to a keychain file with the code-signing certificates and its password, respectively.

@adriansr adriansr added enhancement in progress Pull request is currently in progress. discuss Issue needs further discussion. review Packaging labels Feb 9, 2018
<string>--path.config</string>
<string>/etc/{{.beat_name}}</string>
<string>--path.data</string>
<string>{{.install_path}}/{{.beat_vendor}}/{{.beat_name}}</string>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be OK to set path.data to /var/lib/{{.beat_name}} similar to Linux?

-path.data /var/lib/{{.beat_name}} \

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

-srcfolder dmg \
-ov \
"$DMG_NAME"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we sign the the dmg too? (e.g. codesign -s <identity> <disk-image>)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. I didn't know signing DMGs was a thing.

@ph ph mentioned this pull request Feb 12, 2018
@adriansr
Copy link
Contributor Author

adriansr commented Feb 16, 2018

Pending tasks:

  • Add KEYCHAIN* parameters to jenkins jobs (elastic/infra#3938)
  • do not add icon to DMG. It only works locally.
  • Add icon to uninstaller (artwork pending).
  • Include uninstaller along the beat binaries.
  • preference pane.

@andrewkroh
Copy link
Member

This looks really good!

Include uninstaller along the beat binaries.

What do you think about creating an /Applications/Elastic directory that contains an "Uninstall Filebeat" link to the uninstall app?

Is there anything I can help with?

I'm thinking the next step should be to get this building as part of https://beats-ci.elastic.co/job/elastic+beats+master+package/. We can get the key information stored into Vault then load it from there. This should make us a bit more prepared to integrate with the Release Manager.

@adriansr
Copy link
Contributor Author

What do you think about creating an /Applications/Elastic directory that contains an "Uninstall Filebeat" link to the uninstall app?

My plan was to add an Uninstall button to each beat in the Preference Pane.

I'm thinking the next step should be to get this building as part of https://beats-ci.elastic.co/job/elastic+beats+master+package/. We can get the key information stored into Vault then load it from there. This should make us a bit more prepared to integrate with the Release Manager.

Yes, that is already in progress. The certificates are deployed to the macOS images and the password is in Vault, now I'm waiting for infra to make the password and certificate path available to the build job via env vars (I added a link to the issue above).

@adriansr
Copy link
Contributor Author

jenkins, test it

@adriansr
Copy link
Contributor Author

jenkins, package it

@@ -17,3 +17,6 @@ docker run --rm -v ${BUILD_DIR}:/build \
tudorg/fpm /build/run-$runid.sh

rm ${BUILD_DIR}/settings-$runid.yml ${BUILD_DIR}/run-$runid.sh

echo 'Running macOS packager'
${BASEDIR}/pkg/build.sh
Copy link
Member

@andrewkroh andrewkroh Feb 21, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there should be a conditional preventing this from error'ing out if we aren't on Darwin.

Or it might be better to separate this into it's own build target such that you can run make packages on any machine with Docker and can run make macos-dmgs (naming TBD) afterwards to build the the DMGs (and it only works on macOS).

@adriansr adriansr changed the title [WIP] macOS packaging for beats macOS packaging for beats Mar 23, 2018
@adriansr adriansr removed discuss Issue needs further discussion. in progress Pull request is currently in progress. labels Mar 23, 2018
@adriansr
Copy link
Contributor Author

jenkins, test it

def main():
parser = argparse.ArgumentParser(
description="Builds OSX packages for Beats")
args = parser.parse_args()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably this should have the same option as dev-tools/deploy?

beats/dev-tools/deploy

Lines 9 to 10 in 96b5aee

parser.add_argument("--no-snapshot", action="store_true",
help="Don't append -SNAPSHOT to the version.")

Copy link
Member

@andrewkroh andrewkroh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I think you should probably squash this one down yourself first in order to cleanup the commit message.

Copy link
Member

@andrewkroh andrewkroh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Can you please squash.

Copy link
Member

@andrewkroh andrewkroh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrong PR I built (unsigned) and installed BeatsPrefPane.pkg locally. It all went well. I'll test again after having some Beat packages installed too.

@adriansr
Copy link
Contributor Author

adriansr commented May 31, 2018

Please do not merge until further notice

@adriansr adriansr force-pushed the osxpkg branch 4 times, most recently from dd234de to 633ddae Compare June 7, 2018 10:51
This adds a new make target, `osx-package`, that will build a PKG
installer for each beat supported in macOS. Also features a DMG file
wrapping the installer and uninstaller.

Installer and binaries need to be signed. Valid Apple-issued certificates
and their associated keys need to be available in an unlocked keychain:
- `Developer ID application` certificate, for code-signing.
- `Developer ID installer` certificate, for signing .pkg installers.
The installer package includes the Beats preference pane and installs it
along with the Beat.
Now `dev-tools/osx-deploy` builds two sets of packages per Beat:
- beatname-oss-version.{pkg,dmg} packages without X-Pack content.
- beatname-version.{pkg,dmg} packages with X-Pack content

The main Makefile target has been renamed to `osx-package-all` to match
the existing `package-all` target. From inside a Beat it is possible to
use the targets `osx-package-oss` and `osx-package-elastic` to build
only one set of packages.
When Docker is run in Mac under Virtualbox, volumes in docker don't have
the expected uid=0,gid=0 permissions, but those that Docker is using
inside it's VM (uid=1000(docker) gid=50(staff). This caused files in the
TAR archives to have wrong permissions, triggering a packaging test error
later on.
@adriansr
Copy link
Contributor Author

adriansr commented Jun 19, 2018

Ready to rebase and merge

@andrewkroh
Copy link
Member

@adriansr With KEYCHAIN (and KEYCHAIN_PASS) not being used, can they be removed from the Jenkins job configuration?

It looks like Ansible installs the keychain-db file to Jenkins, but does not add it to the keychain search list or unlock it. Was that done manually or am I missing something?

It looks like Ansible could be made do the following and this would put the worker in a ready state. WDYT?

security list-keychains -s <keychain>
security -v unlock-keychain <keychain> < vault read -field=password

@adriansr
Copy link
Contributor Author

adriansr commented Jul 2, 2018

@andrewkroh

The problem that prompted me to get rid of KEYCHAIN is that, in macOS 10.12 and later, there is no reliable way of handling keychains from launchd services, due to issues with session isolation.

The only reliable way to perform the code-signing from Jenkins is to copy the certificates into the System keychain. So we will need Ansible to do something like this https://apple.stackexchange.com/questions/80623/import-certificates-into-the-system-keychain-via-the-command-line

@andrewkroh
Copy link
Member

Added via #7481.

@andrewkroh andrewkroh closed this Jul 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants