From 6f0aa4ebd2c62f622f875711a916eb45dd9a3a56 Mon Sep 17 00:00:00 2001 From: hiento09 <136591877+hiento09@users.noreply.github.com> Date: Fri, 13 Sep 2024 15:17:09 +0700 Subject: [PATCH] Correct command post install download cortex.llamacpp (#1211) Co-authored-by: Hien To --- engine/templates/linux/create_deb.sh | 10 +++++----- engine/templates/linux/postinst | 4 ++-- engine/templates/linux/postrm | 14 +++++++------- engine/templates/macos/cortex-uninstall.sh | 14 +++++++------- engine/templates/macos/create_pkg.sh | 10 +++++----- engine/templates/macos/post-installer.sh | 4 ++-- engine/templates/windows/installer-beta.iss | 2 +- engine/templates/windows/installer-nightly.iss | 2 +- engine/templates/windows/installer.iss | 2 +- 9 files changed, 31 insertions(+), 31 deletions(-) diff --git a/engine/templates/linux/create_deb.sh b/engine/templates/linux/create_deb.sh index 190bd293f..119d12421 100644 --- a/engine/templates/linux/create_deb.sh +++ b/engine/templates/linux/create_deb.sh @@ -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 @@ -32,4 +32,4 @@ export PACKAGE_NAME VERSION envsubst < control > $PACKAGE_NAME/DEBIAN/control -dpkg-deb --build $PACKAGE_NAME $PACKAGE_NAME.deb \ No newline at end of file +dpkg-deb --build $PACKAGE_NAME $PACKAGE_NAME.deb diff --git a/engine/templates/linux/postinst b/engine/templates/linux/postinst index 2ca83f96e..37debeed5 100644 --- a/engine/templates/linux/postinst +++ b/engine/templates/linux/postinst @@ -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 diff --git a/engine/templates/linux/postrm b/engine/templates/linux/postrm index 9bf1aed7f..e0970b352 100644 --- a/engine/templates/linux/postrm +++ b/engine/templates/linux/postrm @@ -3,7 +3,7 @@ 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)} @@ -11,13 +11,13 @@ 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]) diff --git a/engine/templates/macos/cortex-uninstall.sh b/engine/templates/macos/cortex-uninstall.sh index 471bb88d4..af3244fa7 100644 --- a/engine/templates/macos/cortex-uninstall.sh +++ b/engine/templates/macos/cortex-uninstall.sh @@ -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]) diff --git a/engine/templates/macos/create_pkg.sh b/engine/templates/macos/create_pkg.sh index 61adbd2b3..fc1a98f70 100644 --- a/engine/templates/macos/create_pkg.sh +++ b/engine/templates/macos/create_pkg.sh @@ -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 diff --git a/engine/templates/macos/post-installer.sh b/engine/templates/macos/post-installer.sh index 504f31756..fbdbe0632 100644 --- a/engine/templates/macos/post-installer.sh +++ b/engine/templates/macos/post-installer.sh @@ -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 diff --git a/engine/templates/windows/installer-beta.iss b/engine/templates/windows/installer-beta.iss index 8624ef068..b514abeac 100644 --- a/engine/templates/windows/installer-beta.iss +++ b/engine/templates/windows/installer-beta.iss @@ -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 diff --git a/engine/templates/windows/installer-nightly.iss b/engine/templates/windows/installer-nightly.iss index 0abe36863..e72e71c56 100644 --- a/engine/templates/windows/installer-nightly.iss +++ b/engine/templates/windows/installer-nightly.iss @@ -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 diff --git a/engine/templates/windows/installer.iss b/engine/templates/windows/installer.iss index 7c5a7bae4..ff6c7fe0b 100644 --- a/engine/templates/windows/installer.iss +++ b/engine/templates/windows/installer.iss @@ -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