Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/01_bug.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ body:
attributes:
value: >
**Note**: Assuming you have network connectivity,
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`
- type: textarea
id: freeform
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ If you come across any issues, kindly submit your issue here on GitHub or post y
When submitting an issue, please:
* Provide the stacktrace of the output if applicable
* Attach the `/var/log/archinstall/install.log` to the issue ticket. This helps us help you!
* To extract the log from the ISO image, one way is to use<br>
* 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
```


Expand Down
1 change: 0 additions & 1 deletion archinstall/lib/args.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,6 @@ def _define_arguments(self) -> ArgumentParser:
default=False,
help='Enabled verbose options',
)

return parser

def _parse_args(self) -> Arguments:
Expand Down
90 changes: 90 additions & 0 deletions archinstall/lib/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,3 +333,93 @@ def log(

if level != logging.DEBUG:
print(text)


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


def share_install_log() -> int:
from archinstall.lib.command import SysCommand
from archinstall.lib.exceptions import SysCallError

log_path = logger.path

if not log_path.exists():
info(f'Log file not found: {log_path}')
return 1

size = log_path.stat().st_size
if size == 0:
info(f'Log file is empty: {log_path}')
return 1

if size > _PASTE_MAX_SIZE:
info(f'Log file exceeds {_PASTE_MAX_SIZE} bytes, uploading last {_PASTE_MAX_SIZE} bytes')
content = log_path.read_bytes()[-_PASTE_MAX_SIZE:]
else:
content = log_path.read_bytes()

header = f'About to upload {log_path} ({len(content)} bytes) to {_PASTE_URL}\n\n'
header += 'The log may contain hostname, mirror URLs, package list and partition layout.\n'
header += 'The uploaded paste is public.\n\n'
header += 'Continue?'

try:
from archinstall.tui.ui.components import tui

confirmed: bool = tui.run(lambda: _confirm_share(header))
except Exception:
confirmed = False

if not confirmed:
info('Cancelled.')
return 1

import tempfile

if size > _PASTE_MAX_SIZE:
fd, tmp_path_str = tempfile.mkstemp(suffix='.log')
try:
with os.fdopen(fd, 'wb') as f:
f.write(content)
upload_path = tmp_path_str
except Exception:
os.close(fd)
raise
else:
upload_path = str(log_path)
tmp_path_str = None

try:
result = SysCommand(f'curl -sS --data-binary @{upload_path} {_PASTE_URL}')
except SysCallError as e:
info(f'Upload failed: {e}')
return 1
finally:
if tmp_path_str:
Path(tmp_path_str).unlink(missing_ok=True)

url = result.decode().strip()

if not url.startswith('http'):
info(f'Unexpected response from {_PASTE_URL}: {url[:200]!r}')
return 1

# raw print so the URL is pipe-friendly (no ANSI colors, no log prefix)
print(url)
return 0


async def _confirm_share(header: str) -> bool:
from archinstall.lib.menu.helpers import Confirmation
from archinstall.tui.ui.menu_item import MenuItemGroup

result = await Confirmation(
group=MenuItemGroup.yes_no(),
header=header,
allow_skip=False,
preset=False,
).show()

return result.get_value()
9 changes: 6 additions & 3 deletions archinstall/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from archinstall.lib.hardware import SysInfo
from archinstall.lib.network.wifi_handler import WifiHandler
from archinstall.lib.networking import ping
from archinstall.lib.output import debug, error, info, warn
from archinstall.lib.output import debug, error, info, share_install_log, warn
from archinstall.lib.packages.util import check_version_upgrade
from archinstall.lib.pacman.pacman import Pacman
from archinstall.lib.translationhandler import tr, translation_handler
Expand Down Expand Up @@ -79,6 +79,9 @@ def run() -> int:
OR straight as a module: python -m archinstall
In any case we will be attempting to load the provided script to be run from the scripts/ folder
"""
if 'share-log' in sys.argv:
return share_install_log()

arch_config_handler = ArchConfigHandler()

if '--help' in sys.argv or '-h' in sys.argv:
Expand Down Expand Up @@ -141,8 +144,8 @@ def _error_message(exc: Exception) -> None:
Archinstall experienced the above error. If you think this is a bug, please report it to
https://github.com/archlinux/archinstall and include the log file "/var/log/archinstall/install.log".

Hint: To extract the log from a live ISO
curl -F 'file=@/var/log/archinstall/install.log' https://0x0.st
Hint: To upload the log and get a shareable URL, run
archinstall share-log
"""
)
warn(text)
Expand Down
2 changes: 1 addition & 1 deletion docs/help/report_bug.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ When submitting a help ticket, please include the :code:`/var/log/archinstall/in
It can be found both on the live ISO but also in the installed filesystem if the base packages were strapped in.

.. 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.
| Use caution when submitting other log files, but ``archinstall`` pledges to keep ``install.log`` safe for posting publicly!
There are additional log files under ``/var/log/archinstall/`` that can be useful:
Expand Down
Loading