From dcb5910dc57c644efd53b169a6c546c93c472934 Mon Sep 17 00:00:00 2001 From: Geoffrey Smith <275938+geoffreysmith@users.noreply.github.com> Date: Sun, 23 Jun 2024 03:31:55 -0500 Subject: [PATCH 1/4] Bash5.2 empty fonts director kept getting cp stat cannot mkdir, ran as sudo and tried chmod +x on linux_install.sh. Told ChaptGPT to fix it, found no errors but added a robust bash file that fixed it somehow. --- util/install_linux.sh | 35 +++++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/util/install_linux.sh b/util/install_linux.sh index b1ece38..f0d285c 100755 --- a/util/install_linux.sh +++ b/util/install_linux.sh @@ -1,18 +1,41 @@ #!/bin/bash -# ensure that ~/.local/share/fonts exists +set -e # Exit immediately if a command exits with a non-zero status +set -u # Treat unset variables as an error and exit immediately +set -o pipefail # Return the exit status of the last command in the pipeline that failed + +echo "Starting font installation script..." + +# Ensure that ~/.local/share/fonts exists +echo "Creating directory: ~/.local/share/fonts" mkdir -p ~/.local/share/fonts -# remove all fonts from ~/.local/share/fonts that start with "Monaspace" +# Remove all fonts from ~/.local/share/fonts that start with "Monaspace" +echo "Removing existing Monaspace fonts from ~/.local/share/fonts" rm -rf ~/.local/share/fonts/Monaspace* +# Recreate the Monaspace directory +echo "Creating directory: ~/.local/share/fonts/Monaspace/" mkdir -p ~/.local/share/fonts/Monaspace/ -# copy all fonts from ./otf to ~/.local/share/fonts -cp ./fonts/otf/* ~/.local/share/fonts/Monaspace/ +# Copy all fonts from ./otf to ~/.local/share/fonts/Monaspace/ +if [ -d "./fonts/otf" ]; then + echo "Copying fonts from ./fonts/otf/ to ~/.local/share/fonts/Monaspace/" + cp -v ./fonts/otf/* ~/.local/share/fonts/Monaspace/ || echo "No files to copy from ./fonts/otf" +else + echo "Directory ./fonts/otf does not exist" +fi -# copy variable fonts from ./variable to ~/.local/share/fonts -cp ./fonts/variable/* ~/.local/share/fonts/Monaspace/ +# Copy variable fonts from ./variable to ~/.local/share/fonts/Monaspace/ +if [ -d "./fonts/variable" ]; then + echo "Copying fonts from ./fonts/variable/ to ~/.local/share/fonts/Monaspace/" + cp -v ./fonts/variable/* ~/.local/share/fonts/Monaspace/ || echo "No files to copy from ./fonts/variable" +else + echo "Directory ./fonts/variable does not exist" +fi # Build font information caches +echo "Rebuilding font information caches with fc-cache -f" fc-cache -f + +echo "Font installation completed successfully." \ No newline at end of file From 9b4eac7ed35ee424c41379e0f50a8ee1687f3bb6 Mon Sep 17 00:00:00 2001 From: Geoffrey Smith <275938+geoffreysmith@users.noreply.github.com> Date: Sun, 23 Jun 2024 05:04:31 -0500 Subject: [PATCH 2/4] Added change log --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..6c547af --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1 @@ +Added change log From d6b7f0b266a8805cd7cfe0ee3fd4a98449558270 Mon Sep 17 00:00:00 2001 From: Geoffrey Smith <275938+geoffreysmith@users.noreply.github.com> Date: Sun, 23 Jun 2024 06:37:39 -0500 Subject: [PATCH 3/4] Removed change log. Really just figuring out why my commits aren't signing --- CHANGELOG.md | 1 - 1 file changed, 1 deletion(-) delete mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md deleted file mode 100644 index 6c547af..0000000 --- a/CHANGELOG.md +++ /dev/null @@ -1 +0,0 @@ -Added change log From c73a34bd04dd68a10b0e04f713f5138c85c5511f Mon Sep 17 00:00:00 2001 From: Geoffrey Smith <275938+geoffreysmith@users.noreply.github.com> Date: Sun, 23 Jun 2024 18:51:06 -0500 Subject: [PATCH 4/4] Looks at user who invoked the script, should cross-compile. --- util/install_linux.sh | 57 +++++++++++++++++-------------------------- 1 file changed, 22 insertions(+), 35 deletions(-) diff --git a/util/install_linux.sh b/util/install_linux.sh index f0d285c..323c4cd 100755 --- a/util/install_linux.sh +++ b/util/install_linux.sh @@ -1,41 +1,28 @@ #!/bin/bash -set -e # Exit immediately if a command exits with a non-zero status -set -u # Treat unset variables as an error and exit immediately -set -o pipefail # Return the exit status of the last command in the pipeline that failed - -echo "Starting font installation script..." - -# Ensure that ~/.local/share/fonts exists -echo "Creating directory: ~/.local/share/fonts" -mkdir -p ~/.local/share/fonts - -# Remove all fonts from ~/.local/share/fonts that start with "Monaspace" -echo "Removing existing Monaspace fonts from ~/.local/share/fonts" -rm -rf ~/.local/share/fonts/Monaspace* - -# Recreate the Monaspace directory -echo "Creating directory: ~/.local/share/fonts/Monaspace/" -mkdir -p ~/.local/share/fonts/Monaspace/ - -# Copy all fonts from ./otf to ~/.local/share/fonts/Monaspace/ -if [ -d "./fonts/otf" ]; then - echo "Copying fonts from ./fonts/otf/ to ~/.local/share/fonts/Monaspace/" - cp -v ./fonts/otf/* ~/.local/share/fonts/Monaspace/ || echo "No files to copy from ./fonts/otf" -else - echo "Directory ./fonts/otf does not exist" -fi +# Set the current user +USER=$(logname) +echo "Current user is $USER" + +# Set the target font directory +TARGET_DIR="/home/$USER/.local/share/fonts/Monaspace" + +# Create the ~/.local/share/fonts/ directory if it doesn't exist +mkdir -p "/home/$USER/.local/share/fonts" -# Copy variable fonts from ./variable to ~/.local/share/fonts/Monaspace/ -if [ -d "./fonts/variable" ]; then - echo "Copying fonts from ./fonts/variable/ to ~/.local/share/fonts/Monaspace/" - cp -v ./fonts/variable/* ~/.local/share/fonts/Monaspace/ || echo "No files to copy from ./fonts/variable" -else - echo "Directory ./fonts/variable does not exist" +# Remove the Monaspace directory if it exists +if [ -d "$TARGET_DIR" ]; then + rm -rf "$TARGET_DIR" fi -# Build font information caches -echo "Rebuilding font information caches with fc-cache -f" -fc-cache -f +# Create the Monaspace directory +mkdir -p "$TARGET_DIR" + +# Copy fonts from the local repository to the target directory +cp -r ./fonts/otf/* "$TARGET_DIR/" +cp -r ./fonts/variable/* "$TARGET_DIR/" + +# Update the font cache +fc-cache -fv -echo "Font installation completed successfully." \ No newline at end of file +echo "Fonts copied to $TARGET_DIR and font cache updated."