Class: Depot::Backends::Deb
- Inherits:
-
Object
- Object
- Depot::Backends::Deb
- Includes:
- Support
- Defined in:
- lib/depot/backends/deb.rb
Instance Method Summary collapse
-
#initialize(store:) ⇒ Deb
constructor
A new instance of Deb.
- #install(inspection, settings: {}) ⇒ Object
Constructor Details
#initialize(store:) ⇒ Deb
Returns a new instance of Deb.
16 17 18 |
# File 'lib/depot/backends/deb.rb', line 16 def initialize(store:) @store = store end |
Instance Method Details
#install(inspection, settings: {}) ⇒ Object
20 21 22 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 84 85 86 87 88 |
# File 'lib/depot/backends/deb.rb', line 20 def install(inspection, settings: {}) return Result.err("Deb backend cannot install #{inspection.format}") unless inspection.deb? Paths.ensure_base_dirs package = DebPackage.new(inspection.input) return Result.err("Invalid Debian package.") unless package.valid? fields = package.control_fields app_id = Util.unique_id(Util.slug("#{fields["Package"] || inspection.display_name}-#{fields["Version"]}"), @store.ids) app_dir = File.join(Paths.apps_dir, app_id) root_dir = File.join(app_dir, "root") FileUtils.mkdir_p(app_dir) package.extract_data_to(root_dir) desktop_source = package.primary_desktop_entry display_name = desktop_name(package, desktop_source) || fields["Package"] || inspection.display_name preferred_icon = desktop_source && package.read_data_entry(desktop_source)[/^Icon=(.+)$/, 1]&.strip icon_name = install_icons(package, root_dir, app_id, desktop_source, preferred_icon) executable = executable_for(package, root_dir, desktop_source) desktop_path = nil if settings.fetch("desktop_integration", true) && desktop_source desktop_path = File.join(Paths.desktop_entries_dir, "depot-#{app_id}.desktop") File.write(desktop_path, rewrite_desktop(package.read_data_entry(desktop_source), root_dir, app_id, display_name, icon_name)) end manifest = { "schema_version" => 1, "app_id" => app_id, "display_name" => display_name, "default_display_name" => display_name, "backend" => "deb-portable", "install_source" => File.(inspection.input), "source_sha256" => inspection.sha256, "source_size" => inspection.size, "installed_executable" => executable, "desktop_entry" => desktop_path, "icons" => installed_icon_paths(app_id, preferred_icon), "default_icon_name" => icon_name, "created_files" => [desktop_path].compact + installed_icon_paths(app_id, preferred_icon), "created_dirs" => [app_dir], "installed_at" => Time.now.utc.iso8601, "package" => fields.slice("Package", "Version", "Architecture", "Maintainer", "Depends", "Homepage"), "desktop_source" => desktop_source, "portable_root" => root_dir, "permissions" => { "executable" => executable ? File.executable?(executable) : false, "requires_sudo" => false, "writes_outside_depot" => false, "notes" => ["Debian package extracted user-locally. Maintainer scripts were not executed."] }, "sandbox" => { "enabled" => false, "preference" => settings.fetch("sandbox_preference", "ask") }, "update" => { "mechanism" => "manual", "source" => File.(inspection.input) }, "warnings" => inspection.warnings + portable_warnings(package) } manifest_path = @store.write(manifest) refresh_desktop_caches if settings.fetch("desktop_integration", true) Result.ok(manifest.merge("manifest_path" => manifest_path), warnings: manifest["warnings"]) rescue DebPackage::FormatError, SystemCallError => e Result.err("Deb install failed: #{e.}") end |