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

Fix issue postinstaller not run in macos #1212

Merged
merged 3 commits into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/nightly-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ jobs:

update-latest-version:
runs-on: ubuntu-latest
if: needs.set-public-provider.outputs.public_provider == 'aws-s3'
needs: [get-update-version, set-public-provider, build-linux-x64, build-macos-x64, build-macos-arm64, build-windows-x64]
steps:
- name: Update latest version
Expand Down
9 changes: 7 additions & 2 deletions .github/workflows/template-build-macos.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: build-mac-x64
name: build-mac
on:
workflow_call:
inputs:
Expand Down Expand Up @@ -174,13 +174,18 @@ jobs:
run: |
cd engine
make build-installer PACKAGE_NAME="${{ steps.set-output-params.outputs.package_name }}" VERSION=${{ inputs.new_version }} SOURCE_BINARY_PATH="../../cortex/${{ steps.set-output-params.outputs.destination_binary_name }}" DESTINATION_BINARY_NAME="${{ steps.set-output-params.outputs.destination_binary_name }}" DATA_FOLDER_NAME="${{ steps.set-output-params.outputs.data_folder_name }}" CONFIGURATION_FILE_NAME="${{ steps.set-output-params.outputs.configuration_file_name }}" UNINSTALLER_FILE_NAME="${{ steps.set-output-params.outputs.uninstaller_file_name }}"
cat templates/macos/Scripts/postinstall

- name: Codesign and notary for macos installer
run: |
cd engine
productsign --sign "Developer ID Installer: ${{ secrets.DEVELOPER_ID }}" ${{ steps.set-output-params.outputs.package_name }}.pkg ${{ steps.set-output-params.outputs.package_name }}$-signed.pkg
rm ${{ steps.set-output-params.outputs.package_name }}.pkg
mv ${{ steps.set-output-params.outputs.package_name }}$-signed.pkg ${{ steps.set-output-params.outputs.package_name }}.pkg
mv ${{ steps.set-output-params.outputs.package_name }}$-signed.pkg Distribution.pkg
productbuild --synthesize --package Distribution.pkg Distribution.xml
sed -i '' 's/require-scripts="false"/require-scripts="true"/' Distribution.xml
cat Distribution.xml
productbuild --distribution Distribution.xml --sign "Developer ID Installer: ${{ secrets.DEVELOPER_ID }}" --package-path . ${{ steps.set-output-params.outputs.package_name }}.pkg
xcrun notarytool submit ${{ steps.set-output-params.outputs.package_name }}.pkg --apple-id ${{ secrets.APPLE_ID }} --password ${{ secrets.APPLE_APP_SPECIFIC_PASSWORD }} --team-id ${{ secrets.APPLE_TEAM_ID }} --wait

- name: Package
Expand Down
2 changes: 1 addition & 1 deletion engine/templates/macos/cortex-uninstall.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env sh
DESTINATION_BINARY_NAME=cortex
DATA_FOLDER_NAME=.cortex
CONFIGURATION_FILE_NAME=.cortexrc
Expand Down
9 changes: 5 additions & 4 deletions engine/templates/macos/create_pkg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ CONFIGURATION_FILE_NAME=$6
UNINSTALLER_FILE_NAME=$7

mkdir installer
mkdir scripts
mkdir Scripts

cp $SOURCE_BINARY_PATH installer/$DESTINATION_BINARY_NAME

export DESTINATION_BINARY_NAME
cp post-installer.sh scripts/post-installer.sh
sed -i '' '2s/.*/DESTINATION_BINARY_NAME=\$DESTINATION_BINARY_NAME/' $PACKAGE_NAME/DEBIAN/postinst
cp postinstall Scripts/postinstall
sed -i '' "3s/.*/DESTINATION_BINARY_NAME=$DESTINATION_BINARY_NAME/" Scripts/postinstall
chmod +x Scripts/postinstall

export DATA_FOLDER_NAME CONFIGURATION_FILE_NAME UNINSTALLER_FILE_NAME
cp cortex-uninstall.sh installer/$UNINSTALLER_FILE_NAME
Expand All @@ -22,4 +23,4 @@ sed -i '' "3s/.*/DATA_FOLDER_NAME=$DATA_FOLDER_NAME/" installer/$UNINSTALLER_FIL
sed -i '' "4s/.*/CONFIGURATION_FILE_NAME=$CONFIGURATION_FILE_NAME/" installer/$UNINSTALLER_FILE_NAME
sed -i '' "5s/.*/UNINSTALLER_FILE_NAME=$UNINSTALLER_FILE_NAME/" installer/$UNINSTALLER_FILE_NAME

pkgbuild --identifier ai.cortexcpp.pkg --version $VERSION --scripts scripts --install-location /usr/local/bin --root ./installer ${PACKAGE_NAME}.pkg
pkgbuild --identifier ai.cortexcpp.pkg --version $VERSION --scripts Scripts --install-location /usr/local/bin --root ./installer ${PACKAGE_NAME}.pkg
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#!/bin/bash
#!/usr/bin/env sh
set -e
DESTINATION_BINARY_NAME=cortex
USER_TO_RUN_AS=${SUDO_USER:-$(whoami)}
echo "Download cortex.llamacpp engines by default"
sudo -u $USER_TO_RUN_AS /usr/local/bin/$DESTINATION_BINARY_NAME engines install cortex.llamacpp

exit 0
Loading