fix macos installation
This commit is contained in:
@@ -45,6 +45,16 @@ fi
|
||||
if [ -f "${PROJECT_FILE_PART}_setup.exe.sig" ]; then
|
||||
rm -f "${PROJECT_FILE_PART}_setup.exe.sig" || error_exit "failed to delete file: ${PROJECT_FILE_PART}_setup.exe.sig" 1
|
||||
fi
|
||||
|
||||
if [ -f "${PROJECT_FILE_PART}.dmg" ]; then
|
||||
rm -f "${PROJECT_FILE_PART}.dmg" || error_exit "failed to delete file: ${PROJECT_FILE_PART}_setup.exe" 1
|
||||
fi
|
||||
if [ -f "${PROJECT_FILE_PART}.dmg.sha256" ]; then
|
||||
rm -f "${PROJECT_FILE_PART}.dmg.sha256" || error_exit "failed to delete file: ${PROJECT_FILE_PART}_setup.exe.sha256" 1
|
||||
fi
|
||||
if [ -f "${PROJECT_FILE_PART}.dmg.sig" ]; then
|
||||
rm -f "${PROJECT_FILE_PART}.dmg.sig" || error_exit "failed to delete file: ${PROJECT_FILE_PART}_setup.exe.sig" 1
|
||||
fi
|
||||
popd
|
||||
|
||||
rsync -av --progress ${PROJECT_DIST_DIR}/ ${TEMP_DIR}/${PROJECT_NAME}/ || error_exit "failed to rsync" 1
|
||||
@@ -62,7 +72,7 @@ done
|
||||
pushd "${TEMP_DIR}/${PROJECT_NAME}/"
|
||||
IFS=$'\n'
|
||||
set -f
|
||||
FILE_LIST=$(find . -type f)
|
||||
FILE_LIST=$(find . -type f -not -path "*/.app/*")
|
||||
for FILE in ${FILE_LIST}; do
|
||||
create_file_validations "${FILE}"
|
||||
done
|
||||
@@ -76,23 +86,63 @@ create_file_validations "${PROJECT_OUT_FILE}"
|
||||
popd
|
||||
|
||||
if [ -d "${TEMP_DIR}/${PROJECT_NAME}/${PROJECT_NAME}.app" ]; then
|
||||
APP_SRC="${TEMP_DIR}/${PROJECT_NAME}/${PROJECT_NAME}.app"
|
||||
|
||||
DMG_ROOT="${TEMP_DIR}/dmgroot"
|
||||
mkdir -p "${DMG_ROOT}" || error_exit "failed to create dmgroot" 1
|
||||
|
||||
rsync -a "${APP_SRC}" "${DMG_ROOT}/" || error_exit "failed to stage app bundle" 1
|
||||
INSTALLER="${DMG_ROOT}/Install ${PROJECT_NAME}.command"
|
||||
INSTALLER_SRC="${PROJECT_SOURCE_DIR}/${PROJECT_NAME}/Install ${PROJECT_NAME}.command"
|
||||
|
||||
ln -s /Applications "${DMG_ROOT}/Applications" || true
|
||||
if [ -f "${INSTALLER_SRC}" ]; then
|
||||
HIDDEN_DIR="${DMG_ROOT}/.payload"
|
||||
mkdir -p "${HIDDEN_DIR}" || error_exit "failed to create payload dir" 1
|
||||
APP_DEST_DIR="${HIDDEN_DIR}"
|
||||
else
|
||||
APP_DEST_DIR="${DMG_ROOT}"
|
||||
fi
|
||||
|
||||
rsync -a "${APP_SRC}" "${APP_DEST_DIR}/" || error_exit "failed to stage app bundle" 1
|
||||
|
||||
if [ -f "${INSTALLER_SRC}" ]; then
|
||||
chflags hidden "${HIDDEN_DIR}" "${HIDDEN_DIR}/${PROJECT_NAME}.app" 2>/dev/null || true
|
||||
fi
|
||||
|
||||
ln -s /Applications "${DMG_ROOT}/Applications" 2>/dev/null || true
|
||||
|
||||
BUNDLE_ID="$(/usr/bin/defaults read "${APP_SRC}/Contents/Info" CFBundleIdentifier 2>/dev/null || true)"
|
||||
if [ -z "${BUNDLE_ID}" ] && [ -f "${APP_SRC}/Contents/Info.plist" ]; then
|
||||
BUNDLE_ID="$(/usr/libexec/PlistBuddy -c 'Print :CFBundleIdentifier' "${APP_SRC}/Contents/Info.plist" 2>/dev/null || true)"
|
||||
fi
|
||||
if [ -z "${BUNDLE_ID}" ]; then
|
||||
BUNDLE_ID="${PROJECT_MACOS_BUNDLE_ID:-com.example.${PROJECT_NAME}}"
|
||||
fi
|
||||
|
||||
if [ -f "${INSTALLER_SRC}" ]; then
|
||||
cp -f "${INSTALLER_SRC}" "${INSTALLER}" || error_exit "failed to copy install command" 1
|
||||
chmod +x "${INSTALLER}" || error_exit "failed to chmod install command" 1
|
||||
|
||||
SAFE_PREFIX="$(printf '%s' "${BUNDLE_ID}" | sed -e 's/[\/&]/\\&/g')"
|
||||
/usr/bin/sed -i '' -e "s|^LABEL_PREFIX=.*$|LABEL_PREFIX=\"${SAFE_PREFIX}\"|g" "${INSTALLER}"
|
||||
|
||||
LABEL_ASSIGNED="$(/usr/bin/awk -F= '/^LABEL_PREFIX=/{sub(/^[^=]*=/,""); gsub(/^"|"$/,""); print; exit}' "${INSTALLER}")"
|
||||
if ! /usr/bin/awk -v v="${LABEL_ASSIGNED}" '
|
||||
BEGIN {
|
||||
if (length(v) == 0) exit 1;
|
||||
if (v == "__LABEL_PREFIX__") exit 1;
|
||||
if (v !~ /^[A-Za-z0-9._-]+$/) exit 1;
|
||||
if (v !~ /\./) exit 1;
|
||||
exit 0;
|
||||
}'; then
|
||||
error_exit "DMG build abort: invalid LABEL_PREFIX written to installer (value: \"${LABEL_ASSIGNED}\"). Check BUNDLE_ID and sed substitution." 1
|
||||
fi
|
||||
fi
|
||||
|
||||
DMG_OUT="${PROJECT_FILE_PART}.dmg"
|
||||
|
||||
hdiutil create \
|
||||
-volname "${PROJECT_NAME}" \
|
||||
-fs HFS+ \
|
||||
-srcfolder "${DMG_ROOT}" \
|
||||
-ov -format UDZO \
|
||||
"${PROJECT_DIST_DIR}/${DMG_OUT}" ||
|
||||
error_exit "hdiutil failed" 1
|
||||
"${PROJECT_DIST_DIR}/${DMG_OUT}" || error_exit "hdiutil failed" 1
|
||||
|
||||
pushd "${PROJECT_DIST_DIR}"
|
||||
create_file_validations "${DMG_OUT}"
|
||||
|
Reference in New Issue
Block a user