Skip to content

Commit 727df5c

Browse files
committed
Add --share-log flag to upload install.log to paste.rs
1 parent 6fefa3b commit 727df5c

6 files changed

Lines changed: 92 additions & 7 deletions

File tree

.github/ISSUE_TEMPLATE/01_bug.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ body:
4141
attributes:
4242
value: >
4343
**Note**: Assuming you have network connectivity,
44-
you can easily post the installation log using the following command:
45-
`curl -F'file=@/var/log/archinstall/install.log' https://0x0.st`
44+
you can easily upload the installation log and get a shareable URL by running:
45+
`archinstall --share-log`
4646
4747
- type: textarea
4848
id: freeform

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,9 @@ If you come across any issues, kindly submit your issue here on GitHub or post y
101101
When submitting an issue, please:
102102
* Provide the stacktrace of the output if applicable
103103
* Attach the `/var/log/archinstall/install.log` to the issue ticket. This helps us help you!
104-
* To extract the log from the ISO image, one way is to use<br>
104+
* To upload the log from the ISO image and get a shareable URL, run<br>
105105
```shell
106-
curl -F'file=@/var/log/archinstall/install.log' https://0x0.st
106+
archinstall --share-log
107107
```
108108

109109

archinstall/lib/args.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ class Arguments:
5555
skip_wifi_check: bool = False
5656
advanced: bool = False
5757
verbose: bool = False
58+
share_log: bool = False
5859

5960

6061
@dataclass
@@ -431,6 +432,12 @@ def _define_arguments(self) -> ArgumentParser:
431432
default=False,
432433
help='Enabled verbose options',
433434
)
435+
parser.add_argument(
436+
'--share-log',
437+
action='store_true',
438+
default=False,
439+
help='Upload /var/log/archinstall/install.log to paste.rs and print the URL, then exit',
440+
)
434441

435442
return parser
436443

archinstall/lib/share_log.py

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
import sys
2+
3+
from archinstall.lib.command import SysCommand
4+
from archinstall.lib.exceptions import SysCallError
5+
from archinstall.lib.output import logger
6+
7+
# paste.rs is a minimal text pastebin with syntax highlighting by extension.
8+
# 10 MiB is its documented upload limit.
9+
_PASTE_URL = 'https://paste.rs'
10+
_PASTE_MAX_SIZE = 10 * 1024 * 1024
11+
12+
13+
def share_install_log() -> int:
14+
"""Upload /var/log/archinstall/install.log to paste.rs and print the URL.
15+
16+
Intended for users to paste the URL into a GitHub issue when reporting a
17+
bug. Always asks for explicit confirmation - the log may contain hostname,
18+
mirror URLs, package list, partition layout and other system details which
19+
become public on upload.
20+
21+
All diagnostic output goes to stderr instead of the standard log helpers,
22+
so the file we are about to upload is not modified by this command.
23+
"""
24+
log_path = logger.path
25+
26+
if not log_path.exists():
27+
print(f'Log file not found: {log_path}', file=sys.stderr)
28+
return 1
29+
30+
size = log_path.stat().st_size
31+
if size == 0:
32+
print(f'Log file is empty: {log_path}', file=sys.stderr)
33+
return 1
34+
35+
if size > _PASTE_MAX_SIZE:
36+
print(
37+
f'Log file is too large to share: {size} bytes '
38+
f'(limit: {_PASTE_MAX_SIZE} bytes). '
39+
f'Trim it or upload manually.',
40+
file=sys.stderr,
41+
)
42+
return 1
43+
44+
print(f'About to upload {log_path} ({size} bytes) to {_PASTE_URL}', file=sys.stderr)
45+
print(
46+
'The log may contain hostname, mirror URLs, package list and '
47+
'partition layout. The uploaded paste is public.',
48+
file=sys.stderr,
49+
)
50+
51+
try:
52+
answer = input('Continue? [y/N]: ').strip().lower()
53+
except (EOFError, KeyboardInterrupt):
54+
print(file=sys.stderr)
55+
return 1
56+
57+
if answer not in ('y', 'yes'):
58+
print('Cancelled.', file=sys.stderr)
59+
return 1
60+
61+
try:
62+
result = SysCommand(f'curl -sS --data-binary @{log_path} {_PASTE_URL}')
63+
except SysCallError as e:
64+
print(f'Upload failed: {e}', file=sys.stderr)
65+
return 1
66+
67+
url = result.decode().strip()
68+
69+
if not url.startswith('http'):
70+
print(f'Unexpected response from {_PASTE_URL}: {url[:200]!r}', file=sys.stderr)
71+
return 1
72+
73+
print(url)
74+
return 0

archinstall/main.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
from archinstall.lib.output import debug, error, info, warn
1717
from archinstall.lib.packages.util import check_version_upgrade
1818
from archinstall.lib.pacman.pacman import Pacman
19+
from archinstall.lib.share_log import share_install_log
1920
from archinstall.lib.translationhandler import tr, translation_handler
2021
from archinstall.lib.utils.util import running_from_iso
2122
from archinstall.tui.ui.components import tui
@@ -95,6 +96,9 @@ def run() -> int:
9596
print(tr('Archinstall requires root privileges to run. See --help for more.'))
9697
return 1
9798

99+
if arch_config_handler.args.share_log:
100+
return share_install_log()
101+
98102
translation_handler.save_console_font()
99103

100104
_log_sys_info()
@@ -141,8 +145,8 @@ def _error_message(exc: Exception) -> None:
141145
Archinstall experienced the above error. If you think this is a bug, please report it to
142146
https://github.com/archlinux/archinstall and include the log file "/var/log/archinstall/install.log".
143147
144-
Hint: To extract the log from a live ISO
145-
curl -F 'file=@/var/log/archinstall/install.log' https://0x0.st
148+
Hint: To upload the log and get a shareable URL, run
149+
archinstall --share-log
146150
"""
147151
)
148152
warn(text)

docs/help/report_bug.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ When submitting a help ticket, please include the :code:`/var/log/archinstall/in
1515
It can be found both on the live ISO but also in the installed filesystem if the base packages were strapped in.
1616

1717
.. tip::
18-
| An easy way to submit logs is ``curl -F 'file=@/var/log/archinstall/install.log' https://0x0.st``.
18+
| An easy way to submit logs is ``archinstall --share-log``, which uploads ``install.log`` to paste.rs and prints a shareable URL.
1919
| Use caution when submitting other log files, but ``archinstall`` pledges to keep ``install.log`` safe for posting publicly!
2020
2121
There are additional log files under ``/var/log/archinstall/`` that can be useful:

0 commit comments

Comments
 (0)