Class: Depot::Backends::AppImage
- Inherits:
-
Object
- Object
- Depot::Backends::AppImage
- Defined in:
- lib/depot/backends/app_image.rb
Constant Summary collapse
- EXTRACTION_TIMEOUT_SECONDS =
25
Instance Method Summary collapse
-
#initialize(store:) ⇒ AppImage
constructor
A new instance of AppImage.
- #install(inspection, settings: {}) ⇒ Object
Constructor Details
#initialize(store:) ⇒ AppImage
Returns a new instance of AppImage.
19 20 21 |
# File 'lib/depot/backends/app_image.rb', line 19 def initialize(store:) @store = store end |
Instance Method Details
#install(inspection, settings: {}) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/depot/backends/app_image.rb', line 23 def install(inspection, settings: {}) return Result.err("AppImage backend cannot install #{inspection.format}") unless inspection.appimage? Paths.ensure_base_dirs taken = @store.ids app_id = Util.unique_id(Util.slug(inspection.display_name), taken) app_dir = File.join(Paths.apps_dir, app_id) FileUtils.mkdir_p(app_dir) installed_name = File.basename(inspection.input) installed_path = File.join(app_dir, installed_name) FileUtils.cp(inspection.input, installed_path) FileUtils.chmod(File.stat(installed_path).mode | 0o111, installed_path) = (installed_path, app_id) display_name = .fetch("name", inspection.display_name) icon_paths = .fetch("icons", []) icon_name = icon_paths.any? ? app_id : nil desktop_path = nil if settings.fetch("desktop_integration", true) desktop_path = File.join(Paths.desktop_entries_dir, "depot-#{app_id}.desktop") entry = DesktopEntry.new(app_id:, name: display_name, exec_path: installed_path, icon_name:) File.write(desktop_path, entry.contents) end manifest = { "schema_version" => 1, "app_id" => app_id, "display_name" => display_name, "default_display_name" => display_name, "backend" => "appimage", "install_source" => File.(inspection.input), "source_sha256" => inspection.sha256, "source_size" => inspection.size, "installed_executable" => installed_path, "desktop_entry" => desktop_path, "icons" => icon_paths, "default_icon_name" => icon_name, "customizations" => {}, "created_files" => ([installed_path, desktop_path] + icon_paths).compact, "created_dirs" => [app_dir], "installed_at" => Time.now.utc.iso8601, "permissions" => (installed_path), "sandbox" => { "enabled" => false, "preference" => settings.fetch("sandbox_preference", "ask") }, "update" => { "mechanism" => "manual", "source" => File.(inspection.input) }, "warnings" => inspection.warnings + .fetch("warnings", []) } manifest_path = @store.write(manifest) Result.ok(manifest.merge("manifest_path" => manifest_path), warnings: manifest["warnings"]) rescue SystemCallError => e Result.err("Install failed: #{e.}") end |