Changes
3 changed files (+0/-380)
-
-
@@ -269,50 +269,6 @@ b.pathJoin(&.{ "share/icons/hicolor/256x256/apps", b.fmt("{s}.png", .{app_name}) }),).step); } // Download linuxdeploy tool (AppImage) const linuxdeploy = linuxdeploy: { const tool = b.addExecutable(.{ .name = "download-linuxdeploy", .root_source_file = b.path("build/download_linuxdeploy.zig"), .target = b.graph.host, .optimize = .Debug, }); const run = b.addRunArtifact(tool); run.addArg("--tool-version=1-alpha-20250213-2"); run.addArg(b.fmt("--cpu-arch={s}", .{@tagName(target.result.cpu.arch)})); break :linuxdeploy run.addPrefixedOutputFileArg("--out=", "linuxdeploy.AppImage"); }; const appimage = appimage: { const tool = b.addExecutable(.{ .name = "build_appimage", .root_source_file = b.path("build/build_appimage.zig"), .target = b.graph.host, .optimize = .Debug, }); const run = b.addRunArtifact(tool); run.addPrefixedFileArg("--linuxdeploy=", linuxdeploy); run.addPrefixedFileArg("--exe=", exe.getEmittedBin()); run.addPrefixedFileArg("--desktop-entry=", b.path("data/plac.desktop")); run.addPrefixedFileArg("--icon=", icon_png256); _ = run.addPrefixedOutputDirectoryArg("--appdir=", "AppDir"); break :appimage run.addPrefixedOutputFileArg("--out=", "Plac.AppImage"); }; // AppImage if (b.graph.host.result.os.tag == .linux) { const install = b.addInstallFile(appimage, "Plac.AppImage"); const step = b.step("appimage", "Build AppImage bundle"); step.dependOn(&install.step); } // `zig build run` { const run = b.addRunArtifact(exe);
-
-
gtk-adwaita/build/build_appimage.zig (deleted)
-
@@ -1,190 +0,0 @@// Copyright 2025 Shota FUJI // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // // SPDX-License-Identifier: Apache-2.0 //! This script executes linuxdeploy tool against build output directory. const std = @import("std"); const ExitCode = enum(u8) { ok = 0, generic_error = 1, incorrect_usage = 2, pub inline fn to_u8(self: @This()) u8 { return @intFromEnum(self); } }; pub fn main() !u8 { var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator); defer arena.deinit(); const allocator = arena.allocator(); var args = try std.process.ArgIterator.initWithAllocator(allocator); defer args.deinit(); var arg_linuxdeploy: ?[]const u8 = null; var arg_exe: ?[]const u8 = null; var arg_desktop_entry: ?[]const u8 = null; var arg_icon: ?[]const u8 = null; var arg_out: ?[]const u8 = null; var arg_appdir: ?[]const u8 = null; // Skip exe name _ = args.skip(); while (args.next()) |arg| { var iter = std.mem.splitScalar(u8, arg, '='); const key = iter.next() orelse { continue; }; const value = iter.next() orelse { std.log.err("Arg must be --key=value format (parsing {s})", .{key}); return ExitCode.incorrect_usage.to_u8(); }; if (std.mem.eql(u8, "--linuxdeploy", key)) { arg_linuxdeploy = value; continue; } if (std.mem.eql(u8, "--exe", key)) { arg_exe = value; continue; } if (std.mem.eql(u8, "--desktop-entry", key)) { arg_desktop_entry = value; continue; } if (std.mem.eql(u8, "--icon", key)) { arg_icon = value; continue; } if (std.mem.eql(u8, "--out", key)) { arg_out = value; continue; } if (std.mem.eql(u8, "--appdir", key)) { arg_appdir = value; continue; } std.log.err("Unknown arg: {s}", .{key}); return ExitCode.incorrect_usage.to_u8(); } const linuxdeploy = arg_linuxdeploy orelse { std.log.err("--linuxdeploy is required", .{}); return ExitCode.incorrect_usage.to_u8(); }; const exe = arg_exe orelse { std.log.err("--exe is required", .{}); return ExitCode.incorrect_usage.to_u8(); }; const desktop_entry = arg_desktop_entry orelse { std.log.err("--desktop-entry is required", .{}); return ExitCode.incorrect_usage.to_u8(); }; const icon = arg_icon orelse { std.log.err("--icon is required", .{}); return ExitCode.incorrect_usage.to_u8(); }; const appdir = arg_appdir orelse { std.log.err("--appdir is required", .{}); return ExitCode.incorrect_usage.to_u8(); }; const out = arg_out orelse { std.log.err("--out is required", .{}); return ExitCode.incorrect_usage.to_u8(); }; var base = try std.fs.openDirAbsolute(appdir, .{}); defer base.close(); // linuxdeploy tries to extract from exclude-library-stripped binary for some reason. // We have to manually copy beforehand otherwise nonsensial error ("Could not find dependency") // prevents build process. try base.makePath("usr/bin"); try std.fs.copyFileAbsolute( exe, try std.fs.path.join(allocator, &.{ appdir, "usr/bin", std.fs.path.basename(exe) }), .{}, ); const cwd = std.fs.path.dirname(out) orelse { std.log.err("Unable to obtain cwd from output filename ({s})", .{out}); return ExitCode.generic_error.to_u8(); }; const result = try std.process.Child.run(.{ .allocator = allocator, .argv = &.{ linuxdeploy, "--appdir", appdir, "--desktop-file", desktop_entry, "--icon-file", icon, "--output", "appimage", }, // linuxdeploy emits to cwd and seems not to have an option to set output path. .cwd = cwd, // linuxdeploy logs a lot .max_output_bytes = std.math.maxInt(usize), }); // linuxdeploy prints to stdout... std.io.getStdErr().writeAll(result.stdout) catch {}; if (result.term.Exited != 0) { std.log.err("linuxdeploy exited with {d}", .{result.term.Exited}); return ExitCode.generic_error.to_u8(); } copy_appimage: { var dir = try std.fs.openDirAbsolute(cwd, .{ .iterate = true, .access_sub_paths = false }); defer dir.close(); var iter = dir.iterate(); while (try iter.next()) |entry| { if (entry.kind != .file) { continue; } if (std.mem.endsWith(u8, entry.name, ".AppImage")) { try dir.rename(entry.name, std.fs.path.basename(out)); break :copy_appimage; } } std.log.err("linuxdeploy exited 0, but no .AppImage file were generated", .{}); return ExitCode.generic_error.to_u8(); } return ExitCode.ok.to_u8(); }
-
-
-
@@ -1,146 +0,0 @@// Copyright 2025 Shota FUJI // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // // SPDX-License-Identifier: Apache-2.0 //! This script downloads linuxdeploy AppImage file and make it executable. //! Returns an error code if it has no download option for the specified //! CPU architecture or version. const std = @import("std"); const download_url_tmpl = "https://github.com/linuxdeploy/linuxdeploy/releases/download/{s}/linuxdeploy-{s}.AppImage"; const ExitCode = enum(u8) { ok = 0, generic_error = 1, incorrect_usage = 2, unsupported_cpu_arch = 3, download_failed = 4, pub inline fn to_u8(self: @This()) u8 { return @intFromEnum(self); } }; pub fn main() !u8 { var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator); defer arena.deinit(); const allocator = arena.allocator(); var args = try std.process.ArgIterator.initWithAllocator(allocator); defer args.deinit(); var arg_cpu_arch: ?std.Target.Cpu.Arch = null; var arg_version: ?[]const u8 = null; var arg_out: ?[]const u8 = null; // Skip exe name _ = args.skip(); arg_loop: while (args.next()) |arg| { var iter = std.mem.splitScalar(u8, arg, '='); const key = iter.next() orelse { continue; }; const value = iter.next() orelse { std.log.err("Arg must be --key=value format (parsing {s})", .{key}); return ExitCode.incorrect_usage.to_u8(); }; if (std.mem.eql(u8, "--tool-version", key)) { arg_version = value; continue; } if (std.mem.eql(u8, "--out", key)) { arg_out = value; continue; } if (std.mem.eql(u8, "--cpu-arch", key)) { inline for (@typeInfo(std.Target.Cpu.Arch).@"enum".fields) |field| { if (std.mem.eql(u8, value, field.name)) { arg_cpu_arch = @enumFromInt(field.value); continue :arg_loop; } } std.log.err("Unknown CPU arch: {s}", .{value}); return ExitCode.incorrect_usage.to_u8(); } std.log.err("Unknown arg: {s}", .{key}); return ExitCode.incorrect_usage.to_u8(); } const cpu_arch = arg_cpu_arch orelse { std.log.err("--cpu-arch is required", .{}); return ExitCode.incorrect_usage.to_u8(); }; const version = arg_version orelse { std.log.err("--tool-version is required", .{}); return ExitCode.incorrect_usage.to_u8(); }; const out = arg_out orelse { std.log.err("--out is required", .{}); return ExitCode.incorrect_usage.to_u8(); }; const upstream_arch = switch (cpu_arch) { .x86_64 => "x86_64", .aarch64, .aarch64_be => "aarch64", .arm => "armhf", .x86 => "i386", else => { std.log.err("linuxdeploy cannot run on {s}", .{@tagName(cpu_arch)}); return ExitCode.unsupported_cpu_arch.to_u8(); }, }; var download_url = std.ArrayList(u8).init(allocator); defer download_url.deinit(); try std.fmt.format(download_url.writer(), download_url_tmpl, .{ version, upstream_arch }); var http_client = std.http.Client{ .allocator = allocator }; defer http_client.deinit(); var http_resp = std.ArrayList(u8).init(allocator); defer http_resp.deinit(); const result = try http_client.fetch(.{ .location = .{ .url = download_url.items }, .method = .GET, .keep_alive = false, .response_storage = .{ .dynamic = &http_resp }, .max_append_size = std.math.maxInt(u32), }); if (result.status != .ok) { std.log.err("Download failed: {s} ({d})", .{ @tagName(result.status), result.status }); return ExitCode.download_failed.to_u8(); } const file = try std.fs.createFileAbsolute(out, .{ .mode = 0o755 }); defer file.close(); try file.writeAll(http_resp.items); return ExitCode.ok.to_u8(); }
-