fix: don't include dest_dir in config_dir

This should fix $CONFIG_DIRECTORY including the installation directory in its path.
This commit is contained in:
villamorrd 2025-02-01 20:58:52 +08:00
parent e125d8f1aa
commit d171634f9b
No known key found for this signature in database
GPG Key ID: 1067C46DC2A6070B
1 changed files with 4 additions and 5 deletions

View File

@ -31,7 +31,6 @@ pub fn build(b: *std.Build) !void {
executable_name = b.option([]const u8, "name", "Specify installed executable file name (default is ly)") orelse "ly"; executable_name = b.option([]const u8, "name", "Specify installed executable file name (default is ly)") orelse "ly";
const bin_directory = try b.allocator.dupe(u8, config_directory); const bin_directory = try b.allocator.dupe(u8, config_directory);
config_directory = try std.fs.path.join(b.allocator, &[_][]const u8{ dest_directory, config_directory });
const build_options = b.addOptions(); const build_options = b.addOptions();
const version_str = try getVersionStr(b, "ly", ly_version); const version_str = try getVersionStr(b, "ly", ly_version);
@ -222,22 +221,22 @@ pub fn ServiceInstaller(comptime init_system: InitSystem) type {
} }
fn install_ly(allocator: std.mem.Allocator, install_config: bool) !void { fn install_ly(allocator: std.mem.Allocator, install_config: bool) !void {
const ly_config_directory = try std.fs.path.join(allocator, &[_][]const u8{ config_directory, "/ly" }); const ly_config_directory = try std.fs.path.join(allocator, &[_][]const u8{ dest_directory, config_directory, "/ly" });
std.fs.cwd().makePath(ly_config_directory) catch { std.fs.cwd().makePath(ly_config_directory) catch {
std.debug.print("warn: {s} already exists as a directory.\n", .{ly_config_directory}); std.debug.print("warn: {s} already exists as a directory.\n", .{ly_config_directory});
}; };
const ly_lang_path = try std.fs.path.join(allocator, &[_][]const u8{ config_directory, "/ly/lang" }); const ly_lang_path = try std.fs.path.join(allocator, &[_][]const u8{ dest_directory, config_directory, "/ly/lang" });
std.fs.cwd().makePath(ly_lang_path) catch { std.fs.cwd().makePath(ly_lang_path) catch {
std.debug.print("warn: {s} already exists as a directory.\n", .{config_directory}); std.debug.print("warn: {s} already exists as a directory.\n", .{ ly_lang_path });
}; };
{ {
const exe_path = try std.fs.path.join(allocator, &[_][]const u8{ dest_directory, prefix_directory, "/bin" }); const exe_path = try std.fs.path.join(allocator, &[_][]const u8{ dest_directory, prefix_directory, "/bin" });
if (!std.mem.eql(u8, dest_directory, "")) { if (!std.mem.eql(u8, dest_directory, "")) {
std.fs.cwd().makePath(exe_path) catch { std.fs.cwd().makePath(exe_path) catch {
std.debug.print("warn: {s} already exists as a directory.\n", .{exe_path}); std.debug.print("warn: {s} already exists as a directory.\n", .{ exe_path });
}; };
} }