Skip to content
This repository was archived by the owner on Jul 4, 2025. It is now read-only.
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
10 changes: 5 additions & 5 deletions engine/templates/linux/create_deb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@ cp $SOURCE_BINARY_PATH $PACKAGE_NAME/usr/bin/$DESTINATION_BINARY_NAME
export DESTINATION_BINARY_NAME

cp postinst $PACKAGE_NAME/DEBIAN/postinst
sed -i '2s/.*/DESTINATION_BINARY_NAME=\$DESTINATION_BINARY_NAME/' $PACKAGE_NAME/DEBIAN/postinst
sed -i "2s/.*/DESTINATION_BINARY_NAME=$DESTINATION_BINARY_NAME/" $PACKAGE_NAME/DEBIAN/postinst

cp prerm $PACKAGE_NAME/DEBIAN/prerm
sed -i '3s/.*/DESTINATION_BINARY_NAME=\$DESTINATION_BINARY_NAME/' $PACKAGE_NAME/DEBIAN/prerm
sed -i "3s/.*/DESTINATION_BINARY_NAME=$DESTINATION_BINARY_NAME/" $PACKAGE_NAME/DEBIAN/prerm

export DATA_FOLDER_NAME CONFIGURATION_FILE_NAME

cp postrm $PACKAGE_NAME/DEBIAN/postrm
sed -i '3s/.*/DATA_FOLDER_NAME=\$DATA_FOLDER_NAME/' $PACKAGE_NAME/DEBIAN/postrm
sed -i '4s/.*/CONFIGURATION_FILE_NAME=\$CONFIGURATION_FILE_NAME/' $PACKAGE_NAME/DEBIAN/postrm
sed -i "3s/.*/DATA_FOLDER_NAME=$DATA_FOLDER_NAME/" $PACKAGE_NAME/DEBIAN/postrm
sed -i "4s/.*/CONFIGURATION_FILE_NAME=$CONFIGURATION_FILE_NAME/" $PACKAGE_NAME/DEBIAN/postrm

chmod 755 $PACKAGE_NAME/DEBIAN/postinst
chmod 755 $PACKAGE_NAME/DEBIAN/postrm
Expand All @@ -32,4 +32,4 @@ export PACKAGE_NAME VERSION

envsubst < control > $PACKAGE_NAME/DEBIAN/control

dpkg-deb --build $PACKAGE_NAME $PACKAGE_NAME.deb
dpkg-deb --build $PACKAGE_NAME $PACKAGE_NAME.deb
4 changes: 2 additions & 2 deletions engine/templates/linux/postinst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/sh
DESTINATION_BINARY_NAME=cortex
echo "Download cortex.llamacpp engines by default"
USER_TO_RUN_AS=${SUDO_USER:-$(whoami)}
sudo -u "$USER_TO_RUN_AS" /usr/bin/$DESTINATION_BINARY_NAME engines cortex.llamacpp install
echo "Download cortex.llamacpp engines by default for user $USER_TO_RUN_AS"
sudo -u $USER_TO_RUN_AS /usr/bin/$DESTINATION_BINARY_NAME engines install cortex.llamacpp
14 changes: 7 additions & 7 deletions engine/templates/linux/postrm
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@ set +e
DATA_FOLDER_NAME=.cortex
CONFIGURATION_FILE_NAME=.cortexrc

echo "Do you want to delete the '~/${DATA_FOLDER_NAME}' data folder and file '~/${CONFIGURATION_FILE_NAME}'? (yes/no)"
echo "Do you want to delete the ~/$DATA_FOLDER_NAME data folder and file ~/$CONFIGURATION_FILE_NAME? (yes/no)"
read -r answer

USER_TO_RUN_AS=${SUDO_USER:-$(whoami)}

case "$answer" in
[yY][eE][sS]|[yY])
echo "Deleting cortex data folders..."
if [ -d "/home/${USER_TO_RUN_AS}/${DATA_FOLDER_NAME}" ]; then
echo "Removing /home/${USER_TO_RUN_AS}/${DATA_FOLDER_NAME}"
rm -rf "/home/${USER_TO_RUN_AS}/${DATA_FOLDER_NAME}" > /dev/null 2>&1
if [ -d "/home/$USER_TO_RUN_AS/$DATA_FOLDER_NAME" ]; then
echo "Removing /home/$USER_TO_RUN_AS/$DATA_FOLDER_NAME"
rm -rf "/home/$USER_TO_RUN_AS/$DATA_FOLDER_NAME" > /dev/null 2>&1
fi
if [ -f "/home/${USER_TO_RUN_AS}/${CONFIGURATION_FILE_NAME}" ]; then
echo "Removing /home/${USER_TO_RUN_AS}/${CONFIGURATION_FILE_NAME}"
rm -f "/home/${USER_TO_RUN_AS}/${CONFIGURATION_FILE_NAME}" > /dev/null 2>&1
if [ -f "/home/$USER_TO_RUN_AS/$CONFIGURATION_FILE_NAME" ]; then
echo "Removing /home/$USER_TO_RUN_AS/$CONFIGURATION_FILE_NAME"
rm -f "/home/$USER_TO_RUN_AS/$CONFIGURATION_FILE_NAME" > /dev/null 2>&1
fi
;;
[nN][oO]|[nN])
Expand Down
14 changes: 7 additions & 7 deletions engine/templates/macos/cortex-uninstall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,19 @@ USER_TO_RUN_AS=${SUDO_USER:-$(whoami)}

rm /usr/local/bin/$DESTINATION_BINARY_NAME

echo "Do you want to delete the '~/${DATA_FOLDER_NAME}' data folder and file '~/${CONFIGURATION_FILE_NAME}'? (yes/no)"
echo "Do you want to delete the '~/$DATA_FOLDER_NAME' data folder and file '~/$CONFIGURATION_FILE_NAME'? (yes/no)"
read -r answer

case "$answer" in
[yY][eE][sS]|[yY])
echo "Deleting cortex data folders..."
if [ -d "/Users/${USER_TO_RUN_AS}/${DATA_FOLDER_NAME}" ]; then
echo "Removing /Users/${USER_TO_RUN_AS}/${DATA_FOLDER_NAME}"
rm -rf "/Users/${USER_TO_RUN_AS}/${DATA_FOLDER_NAME}" > /dev/null 2>&1
if [ -d "/Users/$USER_TO_RUN_AS/$DATA_FOLDER_NAME" ]; then
echo "Removing /Users/$USER_TO_RUN_AS/$DATA_FOLDER_NAME"
rm -rf "/Users/$USER_TO_RUN_AS/$DATA_FOLDER_NAME" > /dev/null 2>&1
fi
if [ -f "/Users/${USER_TO_RUN_AS}/${CONFIGURATION_FILE_NAME}" ]; then
echo "Removing /Users/${USER_TO_RUN_AS}/${CONFIGURATION_FILE_NAME}"
rm -f "/Users/${USER_TO_RUN_AS}/${CONFIGURATION_FILE_NAME}" > /dev/null 2>&1
if [ -f "/Users/$USER_TO_RUN_AS/$CONFIGURATION_FILE_NAME" ]; then
echo "Removing /Users/$USER_TO_RUN_AS/$CONFIGURATION_FILE_NAME"
rm -f "/Users/$USER_TO_RUN_AS/$CONFIGURATION_FILE_NAME" > /dev/null 2>&1
fi
;;
[nN][oO]|[nN])
Expand Down
10 changes: 5 additions & 5 deletions engine/templates/macos/create_pkg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ cp post-installer.sh scripts/post-installer.sh
sed -i '' '2s/.*/DESTINATION_BINARY_NAME=\$DESTINATION_BINARY_NAME/' $PACKAGE_NAME/DEBIAN/postinst

export DATA_FOLDER_NAME CONFIGURATION_FILE_NAME UNINSTALLER_FILE_NAME
cp cortex-uninstall.sh scripts/$UNINSTALLER_FILE_NAME
sed -i '' '2s/.*/DESTINATION_BINARY_NAME=\$DESTINATION_BINARY_NAME/' scripts/$UNINSTALLER_FILE_NAME
sed -i '' '3s/.*/DATA_FOLDER_NAME=\$DATA_FOLDER_NAME/' scripts/$UNINSTALLER_FILE_NAME
sed -i '' '4s/.*/CONFIGURATION_FILE_NAME=\$CONFIGURATION_FILE_NAME/' scripts/$UNINSTALLER_FILE_NAME
sed -i '' '5s/.*/UNINSTALLER_FILE_NAME=\$UNINSTALLER_FILE_NAME/' scripts/$UNINSTALLER_FILE_NAME
cp cortex-uninstall.sh installer/$UNINSTALLER_FILE_NAME
sed -i '' "2s/.*/DESTINATION_BINARY_NAME=$DESTINATION_BINARY_NAME/" installer/$UNINSTALLER_FILE_NAME
sed -i '' "3s/.*/DATA_FOLDER_NAME=$DATA_FOLDER_NAME/" installer/$UNINSTALLER_FILE_NAME
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
4 changes: 2 additions & 2 deletions engine/templates/macos/post-installer.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
DESTINATION_BINARY_NAME=cortex
echo "Download cortex.llamacpp engines by default"
USER_TO_RUN_AS=${SUDO_USER:-$(whoami)}
sudo -u "$USER_TO_RUN_AS" /usr/local/bin/$DESTINATION_BINARY_NAME engines cortex.llamacpp install
echo "Download cortex.llamacpp engines by default"
sudo -u $USER_TO_RUN_AS /usr/local/bin/$DESTINATION_BINARY_NAME engines install cortex.llamacpp
2 changes: 1 addition & 1 deletion engine/templates/windows/installer-beta.iss
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Name: "{group}\cortexcpp-beta"; Filename: "{app}\cortex-beta.exe"

; Define the run section to execute the application after installation
[Run]
Filename: "{app}\cortex-beta.exe"; Parameters: "engines cortex.llamacpp install"; WorkingDir: "{app}"; StatusMsg: "Initializing cortex configuration..."; Flags: nowait postinstall
Filename: "{app}\cortex-beta.exe"; Parameters: "engines install cortex.llamacpp"; WorkingDir: "{app}"; StatusMsg: "Initializing cortex configuration..."; Flags: nowait postinstall
[Code]
procedure AddToUserPath;
var
Expand Down
2 changes: 1 addition & 1 deletion engine/templates/windows/installer-nightly.iss
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Name: "{group}\cortexcpp-nightly"; Filename: "{app}\cortex-nightly.exe"

; Define the run section to execute the application after installation
[Run]
Filename: "{app}\cortex-nightly.exe"; Parameters: "engines cortex.llamacpp install"; WorkingDir: "{app}"; StatusMsg: "Initializing cortex configuration..."; Flags: nowait postinstall
Filename: "{app}\cortex-nightly.exe"; Parameters: "engines install cortex.llamacpp"; WorkingDir: "{app}"; StatusMsg: "Initializing cortex configuration..."; Flags: nowait postinstall
[Code]
procedure AddToUserPath;
var
Expand Down
2 changes: 1 addition & 1 deletion engine/templates/windows/installer.iss
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Name: "{group}\cortexcpp"; Filename: "{app}\cortex.exe"

; Define the run section to execute the application after installation
[Run]
Filename: "{app}\cortex.exe"; Parameters: "engines cortex.llamacpp install"; WorkingDir: "{app}"; StatusMsg: "Initializing cortex configuration..."; Flags: nowait postinstall
Filename: "{app}\cortex.exe"; Parameters: "engines install cortex.llamacpp"; WorkingDir: "{app}"; StatusMsg: "Initializing cortex configuration..."; Flags: nowait postinstall
[Code]
procedure AddToUserPath;
var
Expand Down