Merge pull request #29433 from cro/mac_native_pkg

Files for building .pkg files for MacOS X
This commit is contained in:
Mike Place 2015-12-07 12:47:23 -07:00
commit 042daf91b8
23 changed files with 424 additions and 0 deletions

43
pkg/osx/README.md Normal file
View File

@ -0,0 +1,43 @@
===============================
Building Native Packages on OSX
===============================
Salt runs well on the Mac, but does have some limitations.
In this directory you will find scripts and collateral to build an OSX
.pkg-style package that uses a custom-built Python. This process has
been tested on Mac OSX Lion (10.7) and following.
In addition, because of changes in launchd from version
to version of the OS, a simpler approach is taken for
the launchd plist files.
This approach enables Salt users to potentially
add items to their Salt install via 'pip install' without
interfering with the rest of their system's Python packages.
To build a native package you will need the following installed:
- xCode, or the xCode command line tools
- git
The native package will install package files into /opt/salt.
Configuration files will be installed to /etc, but will have
'.dist' appended to them.
Launchd plists will be placed in /Library/LaunchDaemons. By default
salt-minion will NOT be enabled or started.
The process has been automated via the ``build.sh`` script
in the directory with this README file. Checkout the Salt repo from
GitHub, chdir into the base repo directory, and run
./build.sh
References:
http://crushbeercrushcode.org/2014/01/using-pkgbuild-and-productbuild-on-os-x-10-7/
http://stackoverflow.com/questions/11487596/making-os-x-installer-packages-like-a-pro-xcode-developer-id-ready-pkg

127
pkg/osx/build.sh Normal file
View File

@ -0,0 +1,127 @@
#!/bin/bash
# Usage
# ./build.sh <package dir> <version to build> <git tag>
SRCDIR=`pwd`
if [[ ! -e "$SRCDIR/.git" ]] && [[ ! -e "$SRCDIR/scripts/salt" ]]; then
echo "This directory doesn't appear to be a git repository."
echo "The OS X build process needs some files from a Git checkout of Salt."
echo "Run this script from the root of the Git checkout."
exit -1
fi
PKGDIR=$1
rm -rf build
mkdir -p build
BUILDDIR=`pwd`/build
PKGRESOURCES=$SRCDIR/pkg/osx
mkdir -p /opt/salt/python
cd $BUILDDIR
echo "-------- Retrieving libsodium"
wget https://download.libsodium.org/libsodium/releases/libsodium-1.0.2.tar.gz
wget https://download.libsodium.org/libsodium/releases/libsodium-1.0.2.tar.gz.sig
echo "-------- Verifying PGP signature"
gpg --keyserver pgp.mit.edu --recv-key 2B6F76DA
gpg --verify libsodium-1.0.2.tar.gz.sig
echo "-------- Building libsodium"
tar -xvf libsodium-1.0.2.tar.gz
cd libsodium-1.0.2
./configure --prefix=/opt/salt/python
make
make check
make install
cd $BUILDDIR
echo "-------- Retrieving zeromq"
wget http://download.zeromq.org/zeromq-4.0.5.tar.gz
wget http://download.zeromq.org/SHA1SUMS
echo "-------- Building zeromq"
tar -zxvf zeromq-4.0.5.tar.gz
cd zeromq-4.0.5
./configure --prefix=/opt/salt/python
make
make check
make install
cd $BUILDDIR
echo "-------- Retrieving SWIG 3.0.4"
# SWIG
wget http://downloads.sourceforge.net/project/swig/swig/swig-3.0.4/swig-3.0.4.tar.gz
echo "-------- Building SWIG 3.0.4"
tar -zxvf swig-3.0.4.tar.gz
cd swig-3.0.4
./configure --prefix=/opt/salt/python
make
make install
export PATH=/opt/salt/python/bin:$PATH
echo "-------- Installing Salt dependencies with pip"
pip install -r $PKGRESOURCES/requirements.txt
# if $3 exists it will be a git reference, install with pip install git+
# otherwise install with pip install salt==
echo "-------- Installing Salt into the virtualenv"
if [ "$3" == "" ]; then
pip install salt==$2
else
e pip install $3
fi
cd /opt/salt/python/bin
mkdir -p /opt/salt/bin
for f in /opt/salt/python/bin/salt-* do
ln -s $f /opt/salt/bin
done
cp $PKGRESOURCES/scripts/start-*.sh /opt/salt/bin
mkdir -p $PKGDIR/opt
cp -r /opt/salt $PKGDIR/opt
mkdir -p $PKGDIR/Library/LaunchDaemons $PKGDIR/etc
cp $PKGRESOURCES/scripts/com.saltstack.salt.minion.plist $PKGDIR/Library/LaunchDaemons
cp $PKGRESOURCES/scripts/com.saltstack.salt.master.plist $PKGDIR/Library/LaunchDaemons
cp $PKGRESOURCES/scripts/com.saltstack.salt.syndic.plist $PKGDIR/Library/LaunchDaemons
cp $PKGRESOURCES/scripts/com.saltstack.salt.api.plist $PKGDIR/Library/LaunchDaemons
cp $SRCDIR/conf/minion $PKGDIR/etc/salt/minion.dist
cp $SRCDIR/conf/master $PKGDIR/etc/salt/master.dist
cd $PKGRESOURCES
cp distribution.xml.dist distribution.xml
SEDSTR="s/@VERSION@/$2/"
echo $SEDSTR
sed -i '' $SEDSTR distribution.xml
pkgbuild --root $PKGDIR --identifier=com.saltstack.salt --version=$2 --ownership=recommended salt-src-$2.pkg
productbuild --resources=$PKGDIR --distribution=distribution.xml --package-path=salt-src-$2.pkg --version=$2 salt-$2.pkg
# copy the wrapper script to /opt/salt/bin
# ln -s all the different wrapper names to that script
# Copy the launchd plists to $1/Library/LaunchDaemons
# Copy the sample config files to $1/etc
# pkgbuild and productbuild will use $2 to name files.
#pkgbuild
#productbuild
# Q.E.D.

1
pkg/osx/conclusion.html Normal file
View File

@ -0,0 +1 @@
<h1>Salt is Installed!</h1>

29
pkg/osx/distribution.xml Normal file
View File

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<installer-gui-script minSpecVersion="1">
<title>Salt 2015.5.2</title>
<organization>com.saltstack.salt</organization>
<domains enable_localSystem="true"/>
<options rootVolumeOnly="true" />
<!-- Define documents displayed at various steps -->
<welcome file="welcome.html" mime-type="text/html" />
<license file="license.html" mime-type="text/html" />
<conclusion file="conclusion.html" mime-type="text/html" />
<!-- List all component packages -->
<pkg-ref id="com.saltstack.salt"
version="2015.5.2"
auth="root">salt-src-2015.5.2.pkg</pkg-ref>
<!-- List them again here. They can now be organized
as a hierarchy if you want. -->
<choices-outline>
<line choice="com.saltstack.salt"/>
</choices-outline>
<!-- Define each choice above -->
<choice
id="com.saltstack.salt"
visible="false"
title="Salt 2015.5.2"
description="Salt 2015.5.2"
start_selected="true">
<pkg-ref id="com.saltstack.salt"/>
</choice>
</installer-gui-script>

View File

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<installer-gui-script minSpecVersion="1">
<title>Salt @VERSION@</title>
<organization>com.saltstack.salt</organization>
<domains enable_localSystem="true"/>
<options rootVolumeOnly="true" />
<!-- Define documents displayed at various steps -->
<background file="saltstack.png" mime-type="image/png" scaling="tofit"/>
<welcome file="welcome.html" mime-type="text/html" />
<license file="license.html" mime-type="text/html" />
<conclusion file="conclusion.html" mime-type="text/html" />
<!-- List all component packages -->
<pkg-ref id="com.saltstack.salt"
version="@VERSION@"
auth="root">salt-src-@VERSION@.pkg</pkg-ref>
<!-- List them again here. They can now be organized
as a hierarchy if you want. -->
<choices-outline>
<line choice="com.saltstack.salt"/>
</choices-outline>
<!-- Define each choice above -->
<choice
id="com.saltstack.salt"
visible="false"
title="Salt @VERSION@"
description="Salt @VERSION@"
start_selected="true">
<pkg-ref id="com.saltstack.salt"/>
</choice>
</installer-gui-script>

14
pkg/osx/license.html Normal file
View File

@ -0,0 +1,14 @@
<h1>Salt - Remote execution system</h1>
<p>Copyright 2014-2015 SaltStack Team</p>
<p>Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at</p>
<p> http://www.apache.org/licenses/LICENSE-2.0</p>
<p>Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.</p>

16
pkg/osx/requirements.txt Normal file
View File

@ -0,0 +1,16 @@
pyopenssl
m2crypto
pycrypto
libnacl
raet
requests
cherrypy==3.2.3
jinja2
tornado
pyyaml
msgpack-python
apache-libcloud
linode-python
vultr
pyzmq
Mako

BIN
pkg/osx/saltstack.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

View File

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>salt-api</string>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
<key>ProgramArguments</key>
<array>
<string>/opt/salt/bin/start-salt-api.sh</string>
</array>
<key>SoftResourceLimits</key>
<dict>
<key>NumberOfFiles</key>
<integer>100000</integer>
</dict>
<key>HardResourceLimits</key>
<dict>
<key>NumberOfFiles</key>
<integer>100000</integer>
</dict>
</dict>
</plist>

View File

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>salt-master</string>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
<key>ProgramArguments</key>
<array>
<string>/opt/salt/bin/start-salt-master.sh</string>
</array>
<key>SoftResourceLimits</key>
<dict>
<key>NumberOfFiles</key>
<integer>100000</integer>
</dict>
<key>HardResourceLimits</key>
<dict>
<key>NumberOfFiles</key>
<integer>100000</integer>
</dict>
</dict>
</plist>

View File

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>salt-minion</string>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
<key>ProgramArguments</key>
<array>
<string>/opt/salt/bin/start-salt-minion.sh</string>
</array>
<key>SoftResourceLimits</key>
<dict>
<key>NumberOfFiles</key>
<integer>100000</integer>
</dict>
<key>HardResourceLimits</key>
<dict>
<key>NumberOfFiles</key>
<integer>100000</integer>
</dict>
</dict>
</plist>

View File

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>salt-syndic</string>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
<key>ProgramArguments</key>
<array>
<string>/opt/salt/bin/start-salt-syndic.sh</string>
</array>
<key>SoftResourceLimits</key>
<dict>
<key>NumberOfFiles</key>
<integer>100000</integer>
</dict>
<key>HardResourceLimits</key>
<dict>
<key>NumberOfFiles</key>
<integer>100000</integer>
</dict>
</dict>
</plist>

1
pkg/osx/scripts/salt-api Symbolic link
View File

@ -0,0 +1 @@
salt

1
pkg/osx/scripts/salt-cloud Symbolic link
View File

@ -0,0 +1 @@
salt

1
pkg/osx/scripts/salt-master Symbolic link
View File

@ -0,0 +1 @@
salt

1
pkg/osx/scripts/salt-minion Symbolic link
View File

@ -0,0 +1 @@
salt

1
pkg/osx/scripts/salt-syndic Symbolic link
View File

@ -0,0 +1 @@
salt

1
pkg/osx/scripts/salt-unity Symbolic link
View File

@ -0,0 +1 @@
salt

View File

@ -0,0 +1,2 @@
#!/bin/bash
exec /opt/salt/bin/salt-api $@

View File

@ -0,0 +1,2 @@
#!/bin/bash
exec /opt/salt/bin/salt-master $@

View File

@ -0,0 +1,2 @@
#!/bin/bash
exec /opt/salt/bin/salt-minion $@

View File

@ -0,0 +1,2 @@
#!/bin/bash
exec /opt/salt/bin/salt-syndic $@

46
pkg/osx/welcome.html Normal file
View File

@ -0,0 +1,46 @@
<p>
<a href="http://saltstack.com">SaltStack</a> is extremely fast and scalable
systems and configuration management software for predictive orchestration,
cloud and data center automation, server provisioning, application deployment
and more. </p>
<p>Documentation for Salt is available at
<a href="http://docs.saltstack.com">http://docs.saltstack.com</a>
</p>
<p> This package will install Salt on your Mac. Salt
installs into /opt/salt. You may want to add /opt/salt/bin to your
PATH environment variable.</p>
<p>LaunchD plist files will be installed in /Library/LaunchDaemons.
To enable startup of Salt processes on boot, run one or more of the following
as root:</p>
<table border=0 cellpadding='5'>
<tr><td>salt-minion</td>
<td>launchctl load /Library/LaunchDaemons/com.saltstack.salt.minion.plist</td></tr>
<tr><td>salt-master</td>
<td>launchctl load /Library/LaunchDaemons/com.saltstack.salt.master.plist</td></tr>
<tr><td>salt-syndic</td>
<td>launchctl load /Library/LaunchDaemons/com.saltstack.salt.syndic.plist</td></tr>
<tr><td>salt-api</td>
<td>launchctl load /Library/LaunchDaemons/com.saltstack.salt.api.plist</td></tr>
</table>
<p>Sample configuration files (master.dist and minion.dist) will be
installed to /etc/salt. Create copies of them without the '.dist' in
the filename and edit as you see fit.</p>
<p>This Salt package uses a custom-built Python. To install additional
Python modules for Salt, use the associated 'pip' binary. For example,
if you need LDAP support in Salt you will need the 'python-ldap' module.
Install it with
<blockquote>
/opt/salt/python/bin/pip install python-ldap
</blockquote>
<p>
Note that some Python modules need a compiler available. Installing
Apple's xCode command line tools should provide the necessary utilities.
Alternatively, <a href="http://macports.org">MacPorts</a>,
<a href="http://finkproject.org">Fink</a>, or <a href="http://brew.sh">
Homebrew</a> may provide what you need.