AUTH-2712 fixed the mac build script

This commit is contained in:
Dalton 2020-08-18 15:33:50 -05:00 committed by Dalton Cherry
parent 1a96889141
commit 310bd0dbf1
1 changed files with 57 additions and 39 deletions

View File

@ -29,81 +29,99 @@ cd ../src/github.com/cloudflare/cloudflared
GOCACHE="$PWD/../../../../" GOPATH="$PWD/../../../../" CGO_ENABLED=1 make cloudflared GOCACHE="$PWD/../../../../" GOPATH="$PWD/../../../../" CGO_ENABLED=1 make cloudflared
# Add code signing private key to the key chain # Add code signing private key to the key chain
if [[ -z "${CFD_CODE_SIGN_KEY}" ]]; then if [[ -n "${CFD_CODE_SIGN_KEY:-}" ]]; then
# write private key to disk and then import it keychain if [[ -n "${CFD_CODE_SIGN_PASS:-}" ]]; then
echo -n -e ${CFD_CODE_SIGN_KEY} | base64 -D > ${CODE_SIGN_PRIV} # write private key to disk and then import it keychain
security import ${CODE_SIGN_PRIV} -A -P "${CFD_CODE_SIGN_PASS}" echo -n -e ${CFD_CODE_SIGN_KEY} | base64 -D > ${CODE_SIGN_PRIV}
rm ${CODE_SIGN_PRIV} security import ${CODE_SIGN_PRIV} -A -P "${CFD_CODE_SIGN_PASS}"
else rm ${CODE_SIGN_PRIV}
exit 1 fi
fi fi
# Add code signing certificate to the key chain # Add code signing certificate to the key chain
if [[ -z "${CFD_CODE_SIGN_CERT}" ]]; then if [[ -n "${CFD_CODE_SIGN_CERT:-}" ]]; then
# write certificate to disk and then import it keychain # write certificate to disk and then import it keychain
echo -n -e ${CFD_CODE_SIGN_CERT} | base64 -D > ${CODE_SIGN_CERT} echo -n -e ${CFD_CODE_SIGN_CERT} | base64 -D > ${CODE_SIGN_CERT}
security import ${CODE_SIGN_CERT} security import ${CODE_SIGN_CERT}
rm ${CODE_SIGN_CERT} rm ${CODE_SIGN_CERT}
else
exit 1
fi fi
# Add package signing private key to the key chain # Add package signing private key to the key chain
if [[ -z "${CFD_INSTALLER_KEY}" ]]; then if [[ -n "${CFD_INSTALLER_KEY:-}" ]]; then
# write private key to disk and then import it into the keychain if [[ -n "${CFD_INSTALLER_PASS:-}" ]]; then
echo -n -e ${CFD_INSTALLER_KEY} | base64 -D > ${INSTALLER_PRIV} # write private key to disk and then import it into the keychain
security import ${INSTALLER_PRIV} -A -P "${CFD_INSTALLER_PASS}" echo -n -e ${CFD_INSTALLER_KEY} | base64 -D > ${INSTALLER_PRIV}
rm ${INSTALLER_PRIV} security import ${INSTALLER_PRIV} -A -P "${CFD_INSTALLER_PASS}"
else rm ${INSTALLER_PRIV}
exit 1 fi
fi fi
# Add package signing certificate to the key chain # Add package signing certificate to the key chain
if [[ -z "${CFD_INSTALLER_CERT}" ]]; then if [[ -n "${CFD_INSTALLER_CERT:-}" ]]; then
# write certificate to disk and then import it keychain # write certificate to disk and then import it keychain
echo -n -e ${CFD_INSTALLER_CERT} | base64 -D > ${INSTALLER_CERT} echo -n -e ${CFD_INSTALLER_CERT} | base64 -D > ${INSTALLER_CERT}
security import ${INSTALLER_CERT} security import ${INSTALLER_CERT}
rm ${INSTALLER_CERT} rm ${INSTALLER_CERT}
else
exit 1
fi fi
# get the code signing certificate name # get the code signing certificate name
if [[ -z "${CFD_CODE_SIGN_NAME}" ]]; then if [[ -n "${CFD_CODE_SIGN_NAME:-}" ]]; then
CODE_SIGN_NAME=$(security find-identity -v | cut -d'"' -f 2 -s | grep "Developer ID Application:")
else
CODE_SIGN_NAME="${CFD_CODE_SIGN_NAME}" CODE_SIGN_NAME="${CFD_CODE_SIGN_NAME}"
else
if [[ -n "$(security find-identity -v | cut -d'"' -f 2 -s | grep "Developer ID Application:")" ]]; then
CODE_SIGN_NAME=$(echo "something else" | grep "Developer ID Application:")
else
CODE_SIGN_NAME=""
fi
fi fi
# get the package signing certificate name # get the package signing certificate name
if [[ -z "${CFD_INSTALLER_NAME}" ]]; then if [[ -n "${CFD_INSTALLER_NAME:-}" ]]; then
PKG_SIGN_NAME=$(security find-identity -v | cut -d'"' -f 2 -s | grep "Developer ID Installer:")
else
PKG_SIGN_NAME="${CFD_INSTALLER_NAME}" PKG_SIGN_NAME="${CFD_INSTALLER_NAME}"
else
if [[ -n "$(security find-identity -v | cut -d'"' -f 2 -s | grep "Developer ID Installer:")" ]]; then
PKG_SIGN_NAME=$(security find-identity -v | cut -d'"' -f 2 -s | grep "Developer ID Installer:")
else
PKG_SIGN_NAME=""
fi
fi fi
# sign the cloudflared binary # sign the cloudflared binary
codesign -s "${CODE_SIGN_NAME}" -f -v --timestamp --options runtime ${BINARY_NAME} if [[ -n "${CODE_SIGN_NAME:-}" ]]; then
codesign -s "${CODE_SIGN_NAME}" -f -v --timestamp --options runtime ${BINARY_NAME}
fi
# creating build directory # creating build directory
mkdir ${TARGET_DIRECTORY} mkdir "${TARGET_DIRECTORY}"
mkdir ${TARGET_DIRECTORY}/contents mkdir "${TARGET_DIRECTORY}/contents"
cp -r .mac_resources/scripts ${TARGET_DIRECTORY}/scripts cp -r ".mac_resources/scripts" "${TARGET_DIRECTORY}/scripts"
# copy cloudflared into the build directory # copy cloudflared into the build directory
cp ${BINARY_NAME} {$TARGET_DIRECTORY}/contents/${PRODUCT} cp ${BINARY_NAME} "${TARGET_DIRECTORY}/contents/${PRODUCT}"
# compress cloudflared into a tar and gzipped file # compress cloudflared into a tar and gzipped file
tar czf "$FILENAME" ${BINARY_NAME} tar czf "$FILENAME" "${BINARY_NAME}"
# build the installer package # build the installer package
pkgbuild --identifier com.cloudflare.${PRODUCT} \ if [[ -n "${PKG_SIGN_NAME:-}" ]]; then
--version ${VERSION} \ pkgbuild --identifier com.cloudflare.${PRODUCT} \
--scripts ${TARGET_DIRECTORY}/scripts \ --version ${VERSION} \
--root ${TARGET_DIRECTORY}/contents \ --scripts ${TARGET_DIRECTORY}/scripts \
--install-location /usr/local/bin \ --root ${TARGET_DIRECTORY}/contents \
--sign "${PKG_SIGN_NAME}" \ --install-location /usr/local/bin \
${PKGNAME} --sign "${PKG_SIGN_NAME}" \
${PKGNAME}
else
pkgbuild --identifier com.cloudflare.${PRODUCT} \
--version ${VERSION} \
--scripts ${TARGET_DIRECTORY}/scripts \
--root ${TARGET_DIRECTORY}/contents \
--install-location /usr/local/bin \
${PKGNAME}
fi
# cleaning up the build directory # cleaning up the build directory
rm -rf $TARGET_DIRECTORY rm -rf $TARGET_DIRECTORY