Skip to content

Add share-log subcommand to upload install.log to paste.rs#4511

Open
Softer wants to merge 8 commits intoarchlinux:masterfrom
Softer:feat-share-log
Open

Add share-log subcommand to upload install.log to paste.rs#4511
Softer wants to merge 8 commits intoarchlinux:masterfrom
Softer:feat-share-log

Conversation

@Softer
Copy link
Copy Markdown
Contributor

@Softer Softer commented May 1, 2026

Replaces the broken curl ... https://0x0.st hint with an integrated archinstall share-log command that uploads /var/log/archinstall/install.log to paste.rs and prints a shareable URL. Also updates the same hint in the README, the bug report docs, and the GitHub bug issue template, so all four user-facing references now point to the working command.

Refs #4396 (0x0.st has disabled uploads). Supersedes #4507, which removes the hint without offering a replacement.

Why paste.rs

  • Text-oriented pastebin with extension-based syntax highlighting, so install.log renders as a readable page rather than a raw download
  • 10 MiB upload limit (well above realistic install.log sizes)
  • Curl-friendly, no account, no server-side state to maintain

The endpoint is referenced exactly once - a constant in archinstall/lib/output.py. If a self-hosted paste service is set up later, or 0x0.st returns, swapping it is a one-line change.

Behavior

$ archinstall share-log
About to upload /var/log/archinstall/install.log (12345 bytes) to https://paste.rs
The log may contain hostname, mirror URLs, package list and partition layout.
The uploaded paste is public.
Continue?
https://paste.rs/abc.def

  • Runs as a subcommand (archinstall share-log), not a flag - it is a standalone command, not an installer option
  • Runs before root check so non-root users can share logs too
  • TUI confirmation via ConfirmationScreen (consistent with the rest of archinstall)
  • Diagnostics go through info(); only the final URL goes to raw print() so it can be piped (archinstall share-log | xclip -sel clip)
  • Logs exceeding 10 MiB are truncated from the bottom up (latest entries kept) instead of refusing to upload
  • File-not-found, empty file, network failure and unexpected response are each handled with a clear message and non-zero exit

Test plan

  • archinstall share-log on a live ISO - URL is printed and the paste is readable
  • archinstall share-log answering No - exits cleanly without uploading
  • archinstall share-log with install.log missing - reports the error and exits non-zero
  • archinstall share-log with no network - reports the error and exits non-zero
  • Trigger an install error and confirm the hint says archinstall share-log

@Torxed
Copy link
Copy Markdown
Member

Torxed commented May 1, 2026

Just note that I started a conversation about an arch official channel for posting these logs. I created a ticket to track the progress on gitlab@archlinux #833

@Softer
Copy link
Copy Markdown
Contributor Author

Softer commented May 1, 2026

We can change --share-log behavior transparently for users any time we need without changing user's expectation. :)

Comment thread archinstall/lib/args.py Outdated
Comment thread archinstall/lib/share_log.py Outdated
Comment thread archinstall/lib/share_log.py Outdated
Comment thread archinstall/lib/share_log.py Outdated
Comment thread archinstall/lib/share_log.py Outdated
@Softer Softer changed the title Add --share-log flag to upload install.log to paste.rs Add share-log subcomamnd to upload install.log to paste.rs May 3, 2026
@Softer
Copy link
Copy Markdown
Contributor Author

Softer commented May 3, 2026

Changes per review:

  • archinstall share-log subcommand instead of --share-log flag
  • Code moved into output.py, share_log.py deleted
  • Large logs truncated from bottom up instead of refusing upload
  • TUI ConfirmationScreen instead of input()
  • info() for diagnostics; final URL stays as print() for pipe-friendliness

Comment thread archinstall/lib/output.py Outdated


def share_install_log() -> int:
from archinstall.lib.command import SysCommand
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Why are they not global?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Circular import: command.py imports debug, error, logger from output.py, so a top-level from archinstall.lib.command import SysCommand here creates a cycle. Removed in the latest commit anyway - switched to urllib.request so these imports are no longer needed.

Comment thread archinstall/lib/output.py Outdated
header += 'Continue?'

try:
from archinstall.tui.ui.components import tui
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Why is this not global?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Circular import: tui.ui.components imports debug from output.py, so a top-level import here creates a cycle. Has to stay local.

Comment thread archinstall/lib/output.py Outdated
from archinstall.tui.ui.components import tui

confirmed: bool = tui.run(lambda: _confirm_share(header))
except Exception:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

why do we need a try here?

Comment thread archinstall/lib/output.py Outdated
info('Cancelled.')
return 1

import tempfile
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Why not global?

Comment thread archinstall/lib/output.py Outdated
import tempfile

if size > _PASTE_MAX_SIZE:
fd, tmp_path_str = tempfile.mkstemp(suffix='.log')
Copy link
Copy Markdown
Collaborator

@svartkanin svartkanin May 3, 2026

Choose a reason for hiding this comment

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

we can use pathlib here as it's the main pattern in the code base

       if size > _PASTE_MAX_SIZE:
            with tempfile.TemporaryDirectory() as tmp_dir:
                upload_path = Path(tmp_dir) / 'archinstall_log_upload.log'
                upload_path.write_bytes(content)
                ...
        else:
            ...

In addition lets not call curl from syscommand but actually use Python build ins

    try:
        req = urllib.request.Request(_PASTE_URL, data=content)
        
        with urllib.request.urlopen(req) as response:
            url = response.read().decode().strip()
            
    except urllib.error.URLError as e:
        info(f'Upload failed: {e}')
        return 1

Comment thread archinstall/lib/output.py Outdated
return 0


async def _confirm_share(header: str) -> bool:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The TUI code should not be part of this file as archinstall can be used as a lib it should only expose the share function to consumers, but the consumers should be able to call it and use it independently from the TUI logic.

You can move the confirmation out to the main.py where the function is called, and after confirming it will just call the share function which will then run without interruption

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I see the point about lib purity, but share_install_log is specifically a CLI subcommand helper - it's invoked from main.py as archinstall share-log and there's no realistic scenario where someone calls it programmatically as a library function. Moving the confirmation out would split a 20-line function into two halves across two files for a separation that nobody will consume. Happy to do it if you feel strongly.

Copy link
Copy Markdown
Collaborator

@svartkanin svartkanin May 4, 2026

Choose a reason for hiding this comment

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

It's about dependency management and footprint, this makes output.py dependent on the tui module which is not necessary.
you create a new public function for sharing the log file, so anyone using archinstall as a lib or otherwise would be able to use it, regardless if they need to or not. If anyone wants to create their own ISOs and use archinstall they are dependent on this hardcoded implementation of using the tui.
Also it makes isolated functionality testing very difficult as now a test needs to mock a full blown tui instead of being able to test the actual sharing logic in an isolated way.

In addtion, these

_PASTE_URL = 'https://paste.rs'
_PASTE_MAX_SIZE = 10 * 1024 * 1024

should be parameters into the function as well so the function can be tested easily by providing a simple mock url.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

You know better. Decoupled - share_install_log now takes paste_url, max_size, and confirm as parameters, zero TUI imports in output.py. The TUI confirmation lives in main.py as _tui_confirm and is passed via callback.

@Softer
Copy link
Copy Markdown
Contributor Author

Softer commented May 4, 2026

Since share_install_log is now a standalone function in output.py with no TUI dependencies, I figured it would be a good candidate for unit tests. :-)

Added tests/test_share_log.py covering all code paths:

  • file not found
  • empty file
  • user cancellation
  • successful upload
  • large file truncation
  • network error
  • unexpected server response

@Softer Softer changed the title Add share-log subcomamnd to upload install.log to paste.rs Add share-log subcommand to upload install.log to paste.rs May 4, 2026
Comment thread README.md
* To upload the log from the ISO image and get a shareable URL, run<br>
```shell
curl -F'file=@/var/log/archinstall/install.log' https://0x0.st
archinstall --share-log
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

update to

archinstall share-log

Comment thread tests/test_share_log.py
@@ -0,0 +1,94 @@
# pylint: disable=redefined-outer-name
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thank you for adding tests!

Comment thread docs/help/report_bug.rst

.. tip::
| An easy way to submit logs is ``curl -F 'file=@/var/log/archinstall/install.log' https://0x0.st``.
| An easy way to submit logs is ``archinstall --share-log``, which uploads ``install.log`` to paste.rs and prints a shareable URL.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

update to

archinstall share-log

you can easily post the installation log using the following command:
`curl -F'file=@/var/log/archinstall/install.log' https://0x0.st`
you can easily upload the installation log and get a shareable URL by running:
`archinstall --share-log`
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

same here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants