Skip to content

docs(install_linux.md): speedup file writing #11474

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

Open
wants to merge 2 commits into
base: trunk
Choose a base branch
from

Conversation

timsu92
Copy link

@timsu92 timsu92 commented Aug 8, 2025

Originally, this guide makes us:

  1. Download to a temporary file
  2. cat the file and tee to the destination
  3. Won't remove temporary file

Hence, I change it to download to the destination directly to enhance performance.

@Copilot Copilot AI review requested due to automatic review settings August 8, 2025 10:05
@timsu92 timsu92 requested a review from a team as a code owner August 8, 2025 10:05
@timsu92 timsu92 requested a review from BagToad August 8, 2025 10:05
@timsu92 timsu92 temporarily deployed to cli-automation August 8, 2025 10:05 — with GitHub Actions Inactive
@cliAutomation cliAutomation added the external pull request originating outside of the CLI core team label Aug 8, 2025
@cliAutomation
Copy link
Collaborator

Hi! Thanks for the pull request. Please ensure that this change is linked to an issue by mentioning an issue number in the description of the pull request. If this pull request would close the issue, please put the word 'Fixes' before the issue number somewhere in the pull request body. If this is a tiny change like fixing a typo, feel free to ignore this message.

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR optimizes the Linux installation process by simplifying the file download and writing procedure. The change eliminates unnecessary intermediate steps and improves performance by downloading directly to the destination.

  • Replaces multi-step download process with direct download to destination
  • Removes temporary file creation and cleanup overhead
  • Streamlines the installation command chain

@@ -16,8 +16,7 @@ Install:
```bash
(type -p wget >/dev/null || (sudo apt update && sudo apt install wget -y)) \
&& sudo mkdir -p -m 755 /etc/apt/keyrings \
&& out=$(mktemp) && wget -nv -O$out https://cli.github.com/packages/githubcli-archive-keyring.gpg \
&& cat $out | sudo tee /etc/apt/keyrings/githubcli-archive-keyring.gpg > /dev/null \
&& sudo wget -nv -O /etc/apt/keyrings/githubcli-archive-keyring.gpg https://cli.github.com/packages/githubcli-archive-keyring.gpg \
Copy link
Preview

Copilot AI Aug 8, 2025

Choose a reason for hiding this comment

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

Running wget with sudo to write directly to /etc/apt/keyrings/ could be a security risk. If the download fails or is compromised, it could affect system files. The original approach using a temporary file first allows for validation before writing to the system directory.

Suggested change
&& sudo wget -nv -O /etc/apt/keyrings/githubcli-archive-keyring.gpg https://cli.github.com/packages/githubcli-archive-keyring.gpg \
&& wget -nv -O /tmp/githubcli-archive-keyring.gpg https://cli.github.com/packages/githubcli-archive-keyring.gpg \
&& sudo mv /tmp/githubcli-archive-keyring.gpg /etc/apt/keyrings/githubcli-archive-keyring.gpg \

Copilot uses AI. Check for mistakes.

Copy link
Member

Choose a reason for hiding this comment

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

I just happened to be reviewing https://github.com/nodesource/distributions/blob/master/scripts/deb/setup_24.x earlier today and wondering about these instructions versus having a single Bash script for setting all of this up. 🤔

The way it handles this is by piping the content of the key into gpg to dearmor it and write the file:

    # Run 'curl' and 'gpg' to download and import the NodeSource signing key
    if ! curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /usr/share/keyrings/nodesource.gpg; then
      handle_error "$?" "Failed to download and import the NodeSource signing key"
    fi

This would be an alternative we could adopt, too

Copy link
Author

@timsu92 timsu92 Aug 9, 2025

Choose a reason for hiding this comment

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

I like the "dearmor" idea. It's a best practice now. But is the key "armored"?

As for command versus bash file, I love command because it's obvious how things will go, and it's easier to adopt. In my case, I adopted into Dockerfile

@Gowza68

This comment was marked as spam.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
external pull request originating outside of the CLI core team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants