opensc/MacOSX/build-package.in

165 lines
6.5 KiB
Plaintext
Raw Normal View History

#!/bin/bash
# Building the installer is only tested and supported on 10.9+ with Xcode 6.0.1
# Built package targets 10.10
# Building should also work on older versions with older revisions or slight changes, YMMV
# You need to have the following from homebrew or macports or fink:
# autoconf automake libtool pkg-config
# If you want to compile with OpenSCToken/CryptoTokenKit set the following:
#ENABLE_CRYPTOTOKENKIT="--disable-pcsc --enable-cryptotokenkit"
# When using CryptoTokenKit, code signing is required
#SIGNING_IDENTITY=BA3CE53D402E3C75246557E2890F929F4A778DDE
if test -z "$ENABLE_CRYPTOTOKENKIT"; then
2017-11-01 15:29:19 +00:00
export MACOSX_DEPLOYMENT_TARGET="10.10"
else
2017-11-01 15:29:19 +00:00
export MACOSX_DEPLOYMENT_TARGET="10.12"
fi
set -ex
test -x ./configure || ./bootstrap
BUILDPATH=${PWD}
# Locate the latest OSX SDK
SDK_PATH=$(xcrun --sdk macosx --show-sdk-path)
# Set SDK path
export CFLAGS="$CFLAGS -isysroot $SDK_PATH -arch x86_64"
export SED=/usr/bin/sed
PREFIX=/Library/OpenSC
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/lib/pkgconfig
2016-05-18 14:10:00 +00:00
if ! pkg-config libcrypto --atleast-version=1.0.1; then
# OpenSSL is not installed
if ! test -e $BUILDPATH/openssl_bin/$PREFIX/lib/pkgconfig; then
2016-05-18 14:10:00 +00:00
# Build OpenSSL manually, because Apple's binaries are deprecated
if ! test -e openssl; then
git clone --depth=1 https://github.com/openssl/openssl.git -b OpenSSL_1_0_2-stable
fi
cd openssl
KERNEL_BITS=64 ./config --prefix=$PREFIX
make clean
make update
make depend
2016-05-18 14:10:00 +00:00
make
make INSTALL_PREFIX=$BUILDPATH/openssl_bin install_sw
cd ..
fi
export OPENSSL_CFLAGS="`env PKG_CONFIG_PATH=$BUILDPATH/openssl_bin/$PREFIX/lib/pkgconfig PKG_CONFIG_SYSROOT_DIR=$BUILDPATH/openssl_bin pkg-config --static --cflags libcrypto`"
export OPENSSL_LIBS="` env PKG_CONFIG_PATH=$BUILDPATH/openssl_bin/$PREFIX/lib/pkgconfig PKG_CONFIG_SYSROOT_DIR=$BUILDPATH/openssl_bin pkg-config --static --libs libcrypto`"
fi
if ! test -e $BUILDPATH/openpace_bin/$PREFIX/lib/pkgconfig; then
if ! test -e openpace; then
git clone --depth=1 https://github.com/frankmorgner/openpace.git
fi
cd openpace
autoreconf -vis
./configure --disable-shared --prefix=$PREFIX CRYPTO_CFLAGS="$OPENSSL_CFLAGS" CRYPTO_LIBS="$OPENSSL_LIBS"
make DESTDIR=$BUILDPATH/openpace_bin install
cd ..
export OPENPACE_CFLAGS="`env PKG_CONFIG_PATH=$BUILDPATH/openpace_bin/$PREFIX/lib/pkgconfig PKG_CONFIG_SYSROOT_DIR=$BUILDPATH/openpace_bin pkg-config --static --cflags libeac` $OPENSSL_CFLAGS"
export OPENPACE_LIBS="` env PKG_CONFIG_PATH=$BUILDPATH/openpace_bin/$PREFIX/lib/pkgconfig PKG_CONFIG_SYSROOT_DIR=$BUILDPATH/openpace_bin pkg-config --static --libs libeac` $OPENSSL_LIBS"
fi
2016-10-12 12:52:48 +00:00
if ! test -e ${BUILDPATH}/target/$PREFIX/lib/pkgconfig; then
./configure --prefix=$PREFIX \
--sysconfdir=$PREFIX/etc \
--enable-cvcdir=$PREFIX/etc/cvc \
--enable-x509dir=$PREFIX/etc/x509 \
$ENABLE_CRYPTOTOKENKIT \
--disable-notify \
2016-10-12 12:52:48 +00:00
--disable-dependency-tracking \
--enable-shared \
2017-10-30 10:13:57 +00:00
--enable-static \
2016-10-12 12:52:48 +00:00
--enable-strict \
--disable-assert \
--enable-sm # TODO: remove this (must be sensible default in master)
2016-10-12 12:52:48 +00:00
# always make clean
make clean
2016-10-12 12:52:48 +00:00
# compile
make -j 2
2016-10-12 12:52:48 +00:00
# copy files
rm -rf ${BUILDPATH}/target
2016-10-12 12:52:48 +00:00
make install DESTDIR=${BUILDPATH}/target
2016-10-12 12:52:48 +00:00
# remove garbage
rm -f ${BUILDPATH}/target/$PREFIX/lib/*.la
2017-10-30 10:13:57 +00:00
rm -f ${BUILDPATH}/target/$PREFIX/lib/*.a
2016-10-12 12:52:48 +00:00
# generate .bundle (required by Adobe Acrobat)
./MacOSX/libtool-bundle ${BUILDPATH}/target/$PREFIX/lib/opensc-pkcs11.so ${BUILDPATH}/target/$PREFIX/lib
2016-10-12 12:52:48 +00:00
fi
if test -z "$ENABLE_CRYPTOTOKENKIT"; then
# Check out OpenSC.tokend, if not already fetched.
if ! test -e OpenSC.tokend; then
git clone http://github.com/OpenSC/OpenSC.tokend.git
fi
# Create the symlink to OpenSC sources
test -L OpenSC.tokend/build/opensc-src || ln -sf ${BUILDPATH}/src OpenSC.tokend/build/opensc-src
# Build and copy OpenSC.tokend
xcodebuild -target OpenSC -configuration Deployment -project OpenSC.tokend/Tokend.xcodeproj install DSTROOT=${BUILDPATH}/target
#if ! test -e $BUILDPATH/target/Library/Security/tokend/OpenSC.tokend/Contents/Resources/Applications/terminal-notifier.app; then
#if ! test -e terminal-notifier-1.7.1.zip; then
#curl -L https://github.com/julienXX/terminal-notifier/releases/download/1.7.1/terminal-notifier-1.7.1.zip > terminal-notifier-1.7.1.zip
#fi
#if ! test -e terminal-notifier-1.7.1; then
#unzip terminal-notifier-1.7.1.zip
#fi
#mkdir -p $BUILDPATH/target/Library/Security/tokend/OpenSC.tokend/Contents/Resources/Applications
#cp -r terminal-notifier-1.7.1/terminal-notifier.app $BUILDPATH/target/Library/Security/tokend/OpenSC.tokend/Contents/Resources/Applications
#fi
if ! test -e NotificationProxy; then
git clone http://github.com/frankmorgner/NotificationProxy.git
fi
xcodebuild -target NotificationProxy -configuration Release -project NotificationProxy/NotificationProxy.xcodeproj install DSTROOT=$BUILDPATH/target/Library/Security/tokend/OpenSC.tokend/Contents/Resources/
mkdir -p "$BUILDPATH/target/Applications"
osacompile -o "$BUILDPATH/target/Applications/OpenSC Notify.app" "MacOSX/OpenSC_Notify.applescript"
else
# Check out OpenSCToken, if not already fetched.
if ! test -e OpenSCToken; then
git clone http://github.com/frankmorgner/OpenSCToken.git
fi
2017-11-01 15:14:25 +00:00
# Build and copy OpenSCTokenApp
xcodebuild -target OpenSCTokenApp -configuration Release -project OpenSCToken/OpenSCTokenApp.xcodeproj install DSTROOT=${BUILDPATH}/target
2017-11-01 15:14:25 +00:00
codesign --sign "$SIGNING_IDENTITY" --force --entitlements MacOSX/opensc.entitlements target/Library/OpenSC/bin/*
codesign --sign "$SIGNING_IDENTITY" --force --entitlements MacOSX/opensc.entitlements target/Library/OpenSC/lib/*.dylib
codesign --sign "$SIGNING_IDENTITY" --force --entitlements MacOSX/opensc.entitlements --deep target/Library/OpenSC/lib/opensc-pkcs11.bundle
fi
# Prepare target root
mkdir -p ${BUILDPATH}/target/usr/local/bin
cp MacOSX/opensc-uninstall ${BUILDPATH}/target/usr/local/bin
# Build package
pkgbuild --root ${BUILDPATH}/target --scripts MacOSX/scripts --identifier org.opensc-project.mac --version @PACKAGE_VERSION@ --install-location / OpenSC.pkg
# Build product
productbuild --distribution MacOSX/Distribution.xml --package-path . --resources MacOSX/resources "OpenSC @PACKAGE_VERSION@.pkg"
# Build "Uninstaller"
osacompile -o "OpenSC Uninstaller.app" "MacOSX/OpenSC_Uninstaller.applescript"
# Create .dmg
rm -f OpenSC-@PACKAGE_VERSION@.dmg
2015-09-03 03:41:20 +00:00
i=0
while ! hdiutil create -srcfolder "OpenSC @PACKAGE_VERSION@.pkg" -srcfolder "OpenSC Uninstaller.app" -volname "@PACKAGE_NAME@" OpenSC-@PACKAGE_VERSION@.dmg
2015-09-03 03:41:20 +00:00
do
i=$[$i+1]
if [ $i -gt 2 ]
then
exit 1
fi
done