mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-07 03:34:15 +02:00
[appimage] fix: not able to import AppImage files (regression from 0.9.21)
This commit is contained in:
@@ -29,6 +29,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|||||||
|
|
||||||
- AppImage
|
- AppImage
|
||||||
- trying to download a file without a URL associated with [#210](https://github.com/vinifmor/bauh/issues/210)
|
- trying to download a file without a URL associated with [#210](https://github.com/vinifmor/bauh/issues/210)
|
||||||
|
- regression: not able to import AppImage files (introduced in **0.9.21**)
|
||||||
|
|
||||||
- Arch
|
- Arch
|
||||||
- **wget** as a hard requirement for Arch package management
|
- **wget** as a hard requirement for Arch package management
|
||||||
|
|||||||
@@ -566,18 +566,19 @@ class AppImageManager(SoftwareManager):
|
|||||||
|
|
||||||
downloaded, file_name = True, pkg.local_file_path.split('/')[-1]
|
downloaded, file_name = True, pkg.local_file_path.split('/')[-1]
|
||||||
|
|
||||||
file_path = out_dir + '/' + file_name
|
install_file_path = out_dir + '/' + file_name
|
||||||
|
|
||||||
try:
|
try:
|
||||||
moved, output = handler.handle_simple(SimpleProcess(['mv', pkg.local_file_path, file_path]))
|
moved, output = handler.handle_simple(SimpleProcess(['mv', pkg.local_file_path, install_file_path]))
|
||||||
except:
|
except:
|
||||||
self.logger.error("Could not rename file '' as '{}'".format(pkg.local_file_path, file_path))
|
output = ''
|
||||||
|
self.logger.error("Could not rename file '' as '{}'".format(pkg.local_file_path, install_file_path))
|
||||||
moved = False
|
moved = False
|
||||||
|
|
||||||
if not moved:
|
if not moved:
|
||||||
watcher.show_message(title=self.i18n['error'].capitalize(),
|
watcher.show_message(title=self.i18n['error'].capitalize(),
|
||||||
body=self.i18n['appimage.install.imported.rename_error'].format(
|
body=self.i18n['appimage.install.imported.rename_error'].format(bold(pkg.local_file_path.split('/')[-1]),
|
||||||
bold(pkg.local_file_path.split('/')[-1]), bold(output)),
|
bold(output)),
|
||||||
type_=MessageType.ERROR)
|
type_=MessageType.ERROR)
|
||||||
|
|
||||||
return TransactionResult.fail()
|
return TransactionResult.fail()
|
||||||
@@ -600,76 +601,76 @@ class AppImageManager(SoftwareManager):
|
|||||||
dest=bold(install_file_path)))
|
dest=bold(install_file_path)))
|
||||||
return TransactionResult.fail()
|
return TransactionResult.fail()
|
||||||
|
|
||||||
watcher.change_substatus(self.i18n['appimage.install.permission'].format(bold(file_name)))
|
watcher.change_substatus(self.i18n['appimage.install.permission'].format(bold(file_name)))
|
||||||
permission_given = handler.handle(SystemProcess(new_subprocess(['chmod', 'a+x', install_file_path])))
|
permission_given = handler.handle(SystemProcess(new_subprocess(['chmod', 'a+x', install_file_path])))
|
||||||
|
|
||||||
if permission_given:
|
if permission_given:
|
||||||
|
|
||||||
watcher.change_substatus(self.i18n['appimage.install.extract'].format(bold(file_name)))
|
watcher.change_substatus(self.i18n['appimage.install.extract'].format(bold(file_name)))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
res, output = handler.handle_simple(
|
res, output = handler.handle_simple(
|
||||||
SimpleProcess([install_file_path, '--appimage-extract'], cwd=out_dir))
|
SimpleProcess([install_file_path, '--appimage-extract'], cwd=out_dir))
|
||||||
|
|
||||||
if 'Error: Failed to register AppImage in AppImageLauncherFS' in output:
|
if 'Error: Failed to register AppImage in AppImageLauncherFS' in output:
|
||||||
watcher.show_message(title=self.i18n['error'],
|
|
||||||
body=self.i18n['appimage.install.appimagelauncher.error'].format(
|
|
||||||
appimgl=bold('AppImageLauncher'), app=bold(pkg.name)),
|
|
||||||
type_=MessageType.ERROR)
|
|
||||||
handler.handle(SystemProcess(new_subprocess(['rm', '-rf', out_dir])))
|
|
||||||
return TransactionResult.fail()
|
|
||||||
except:
|
|
||||||
watcher.show_message(title=self.i18n['error'],
|
watcher.show_message(title=self.i18n['error'],
|
||||||
body=traceback.format_exc(),
|
body=self.i18n['appimage.install.appimagelauncher.error'].format(
|
||||||
|
appimgl=bold('AppImageLauncher'), app=bold(pkg.name)),
|
||||||
type_=MessageType.ERROR)
|
type_=MessageType.ERROR)
|
||||||
traceback.print_exc()
|
|
||||||
handler.handle(SystemProcess(new_subprocess(['rm', '-rf', out_dir])))
|
handler.handle(SystemProcess(new_subprocess(['rm', '-rf', out_dir])))
|
||||||
return TransactionResult.fail()
|
return TransactionResult.fail()
|
||||||
|
except:
|
||||||
|
watcher.show_message(title=self.i18n['error'],
|
||||||
|
body=traceback.format_exc(),
|
||||||
|
type_=MessageType.ERROR)
|
||||||
|
traceback.print_exc()
|
||||||
|
handler.handle(SystemProcess(new_subprocess(['rm', '-rf', out_dir])))
|
||||||
|
return TransactionResult.fail()
|
||||||
|
|
||||||
watcher.change_substatus(self.i18n['appimage.install.desktop_entry'])
|
watcher.change_substatus(self.i18n['appimage.install.desktop_entry'])
|
||||||
extracted_folder = '{}/{}'.format(out_dir, 'squashfs-root')
|
extracted_folder = '{}/{}'.format(out_dir, 'squashfs-root')
|
||||||
|
|
||||||
if os.path.exists(extracted_folder):
|
if os.path.exists(extracted_folder):
|
||||||
desktop_entry = self._find_desktop_file(extracted_folder)
|
desktop_entry = self._find_desktop_file(extracted_folder)
|
||||||
|
|
||||||
with open('{}/{}'.format(extracted_folder, desktop_entry)) as f:
|
with open('{}/{}'.format(extracted_folder, desktop_entry)) as f:
|
||||||
de_content = f.read()
|
de_content = f.read()
|
||||||
|
|
||||||
|
if de_content:
|
||||||
|
de_content = replace_desktop_entry_exec_command(desktop_entry=de_content,
|
||||||
|
appname=pkg.name,
|
||||||
|
file_path=install_file_path)
|
||||||
|
extracted_icon = self._find_icon_file(extracted_folder)
|
||||||
|
|
||||||
|
if extracted_icon:
|
||||||
|
icon_path = out_dir + '/logo.' + extracted_icon.split('/')[-1].split('.')[-1]
|
||||||
|
shutil.copy(extracted_icon, icon_path)
|
||||||
|
|
||||||
if de_content:
|
if de_content:
|
||||||
de_content = replace_desktop_entry_exec_command(desktop_entry=de_content,
|
de_content = RE_DESKTOP_ICON.sub('Icon={}\n'.format(icon_path), de_content)
|
||||||
appname=pkg.name,
|
|
||||||
file_path=install_file_path)
|
|
||||||
extracted_icon = self._find_icon_file(extracted_folder)
|
|
||||||
|
|
||||||
if extracted_icon:
|
pkg.icon_path = icon_path
|
||||||
icon_path = out_dir + '/logo.' + extracted_icon.split('/')[-1].split('.')[-1]
|
|
||||||
shutil.copy(extracted_icon, icon_path)
|
|
||||||
|
|
||||||
if de_content:
|
if not de_content:
|
||||||
de_content = RE_DESKTOP_ICON.sub('Icon={}\n'.format(icon_path), de_content)
|
de_content = pkg.to_desktop_entry()
|
||||||
|
|
||||||
pkg.icon_path = icon_path
|
Path(DESKTOP_ENTRIES_PATH).mkdir(parents=True, exist_ok=True)
|
||||||
|
|
||||||
if not de_content:
|
with open(self._gen_desktop_entry_path(pkg), 'w+') as f:
|
||||||
de_content = pkg.to_desktop_entry()
|
f.write(de_content)
|
||||||
|
|
||||||
Path(DESKTOP_ENTRIES_PATH).mkdir(parents=True, exist_ok=True)
|
try:
|
||||||
|
shutil.rmtree(extracted_folder)
|
||||||
|
except:
|
||||||
|
traceback.print_exc()
|
||||||
|
|
||||||
with open(self._gen_desktop_entry_path(pkg), 'w+') as f:
|
SymlinksVerifier.create_symlink(app=pkg, file_path=install_file_path, logger=self.logger,
|
||||||
f.write(de_content)
|
watcher=watcher)
|
||||||
|
return TransactionResult(success=True, installed=[pkg], removed=[])
|
||||||
try:
|
else:
|
||||||
shutil.rmtree(extracted_folder)
|
watcher.show_message(title=self.i18n['error'],
|
||||||
except:
|
body='Could extract content from {}'.format(bold(file_name)),
|
||||||
traceback.print_exc()
|
type_=MessageType.ERROR)
|
||||||
|
|
||||||
SymlinksVerifier.create_symlink(app=pkg, file_path=install_file_path, logger=self.logger,
|
|
||||||
watcher=watcher)
|
|
||||||
return TransactionResult(success=True, installed=[pkg], removed=[])
|
|
||||||
else:
|
|
||||||
watcher.show_message(title=self.i18n['error'],
|
|
||||||
body='Could extract content from {}'.format(bold(file_name)),
|
|
||||||
type_=MessageType.ERROR)
|
|
||||||
|
|
||||||
handler.handle(SystemProcess(new_subprocess(['rm', '-rf', out_dir])))
|
handler.handle(SystemProcess(new_subprocess(['rm', '-rf', out_dir])))
|
||||||
return TransactionResult.fail()
|
return TransactionResult.fail()
|
||||||
|
|||||||
Reference in New Issue
Block a user