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

Fixed install_linux.sh #239

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Conversation

geoffreysmith
Copy link

@geoffreysmith geoffreysmith commented Jun 23, 2024

Thought I submitted this last night, whatever:

Bash 5.2, Ubuntu 24.04

Input from root of ~/Workspaces/monaspace

Input:

sudo bash /util/install_linux.sh

Also tried:

chmod -X install_linux.sh

Though sudo should have overwritten that.

Output (original line 12 & 15, directories created manually and also tried to let the script do its thing made no difference.

Output:

cp: cannot stat {{directory_name}}*': No such file or directory

Edit: I believe context on the terminal is correct, as non root "geoffrey" ... it does some weird things when starting over with original script and deleting /home/geoffrey/share/fonts/

Input:

rm -rf ~/local/share/fonts```` geoffrey@dell:~$ [ -d "/home/geoffrey/.local/share/fonts/" ] && echo "dir exists" || echo "dir does not exist"```

Output:

```dir does not exist````

Input (original install_linux.sh):

cd geoffrey@dell:~/Workspaces/monaspace$ echo ~

Output:
```/home/geoffrey``

Run command with debug:

[sudo] password for geoffrey: 
+ mkdir -p /root/.local/share/fonts
+ rm -rf '/root/.local/share/fonts/Monaspace*'
+ mkdir -p /root/.local/share/fonts/Monaspace/
+ cp ./fonts/otf/MonaspaceArgon-BoldItalic.otf ``` (ommitting all the fonts)```

It will see me as root, install it into root the root user's ```/root/.local/share/fonrts``` then install the rest into ```/home/geoffrey/fonts```

Which I'm not going to type out anymore exact commands I think it is obvious what is happening. I also didn't know I had Starship installed but that didn't matter. The script needs a major overhaul.  Running my script produces somehow different results (Starship remove/purge just to make sure):

Input/Output:
``` bash
geoffrey@dell:~/Workspaces/github-forks/monaspace$ sudo bash -x util/install_linux.sh 
+ set -e
+ set -u
+ set -o pipefail
+ echo 'Starting font installation script...'
Starting font installation script...
+ echo 'Creating directory: ~/.local/share/fonts'
Creating directory: ~/.local/share/fonts
+ mkdir -p /root/.local/share/fonts
+ echo 'Removing existing Monaspace fonts from ~/.local/share/fonts'
Removing existing Monaspace fonts from ~/.local/share/fonts
+ rm -rf /root/.local/share/fonts/Monaspace
+ echo 'Creating directory: ~/.local/share/fonts/Monaspace/'
Creating directory: ~/.local/share/fonts/Monaspace/
+ mkdir -p /root/.local/share/fonts/Monaspace/
+ '[' -d ./fonts/otf ']'
+ echo 'Copying fonts from ./fonts/otf/ to ~/.local/share/fonts/Monaspace/'
Copying fonts from ./fonts/otf/ to ~/.local/share/fonts/Monaspace/`

Take my word for it but it does not install /home/geoffrey/fonts but it puts it all under root. Coming from Debian/Fedora I don't think this would have happened. It would have kept my username, but I'd be in an admin group so I think my PID would be the same but would run through the wheel group. The differences in the scripts with no changes except conditionals impacting globbing is really strange.

I am going to update this script, then try to run under a cross-compile matrix. I do not know why the differences are happening.

…s 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.
@geoffreysmith geoffreysmith changed the title Fixed linux_install.sh Fixed install_linux.sh Jun 23, 2024
@geoffreysmith
Copy link
Author

geoffreysmith commented Jun 24, 2024

I don't want to recreate the repository right now but changing from WHOAMI to LOGNAME is showing the user invoking the script:

Fonts copied to /home/geoffrey/.local/share/fonts/Monaspace and font cache updated.

I'm downloading Fedora to make sure but I'm not worried about it. The deno dependency is ... odd. All I know is that I only have these kerning fonts and my command line is jacked but that was to be expected. It solved the immediate error until someone wants to take the time to create a cross-compile test-suite for this. It'd not be a big effort but definitely uh summer intern work.

Thanks.

Copy link

@barnett-yuxiang barnett-yuxiang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's pretty good.

# remove all fonts from ~/.local/share/fonts that start with "Monaspace"
rm -rf ~/.local/share/fonts/Monaspace*
# Set the target font directory
TARGET_DIR="/home/$USER/.local/share/fonts/Monaspace"
Copy link

@opatry opatry Nov 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be $HOME.

Suggested change
TARGET_DIR="/home/$USER/.local/share/fonts/Monaspace"
target_dir="$HOME/.local/share/fonts/Monaspace"

Also, uppercase variables are usually used for environment variables, not local script variables.

@opatry
Copy link

opatry commented Nov 4, 2024

See PR #266

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

3 participants