-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* refractor bash script writing into `installer_utils` folder * Fix packager for GUIs, add installer for GUIs on Linux * update docs for linux gui installer
- Loading branch information
1 parent
fb45eb0
commit ac12e5f
Showing
15 changed files
with
434 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# Helper functions to create a linux CLI installer. | ||
|
||
|
||
def create_bash_installer(name_pkg, version) -> str: | ||
"""Create a bash installer for a CLI application. | ||
:param name_pkg: The name of the program. | ||
:param version: The version of the program. | ||
:return: The bash installer content. | ||
""" | ||
return rf"""#!/bin/bash | ||
# This is a generated installer for {name_pkg} v{version} | ||
# Default installation name and folder | ||
INSTALL_NAME={name_pkg} | ||
INSTALL_DIR=/usr/local/bin | ||
# Check if user has a better path: | ||
read -p "Enter the installation path (default: $INSTALL_DIR): " USER_INSTALL_DIR | ||
if [ ! -z "$USER_INSTALL_DIR" ]; then | ||
INSTALL_DIR=$USER_INSTALL_DIR | ||
fi | ||
# Check if installation folder exists | ||
if [ ! -d "$INSTALL_DIR" ]; then | ||
echo "Error: Installation folder does not exist." | ||
exit 1 | ||
fi | ||
# Check if installation folder requires root access | ||
if [ ! -w "$INSTALL_DIR" ]; then | ||
echo "Error: Installation folder requires root access. Please run with sudo." | ||
exit 1 | ||
fi | ||
INSTALL_FILE=$INSTALL_DIR/$INSTALL_NAME | ||
# check if installation file already exist and if it does, ask if overwrite is ok | ||
if [ -f "$INSTALL_FILE" ]; then | ||
read -p "File already exists. Overwrite? (y/n): " OVERWRITE | ||
if [ "$OVERWRITE" != "y" ]; then | ||
echo "Installation aborted." | ||
exit 1 | ||
fi | ||
fi | ||
if ! [[ ":$PATH:" == *":$INSTALL_DIR:"* ]]; then\ | ||
echo "$INSTALL_DIR is not on your PATH. Please add it." | ||
fi | ||
sed -e '1,/^#__PROGRAM_BINARY__$/d' "$0" > $INSTALL_FILE | ||
chmod +x $INSTALL_FILE | ||
echo "Successfully installed $INSTALL_NAME to $INSTALL_DIR" | ||
exit 0 | ||
#__PROGRAM_BINARY__ | ||
""" |
Oops, something went wrong.