| ... | @@ -56,6 +56,11 @@ location: Location, | ... | @@ -56,6 +56,11 @@ location: Location, |
| 56 | location_tok: std.zig.Ast.TokenIndex, | 56 | location_tok: std.zig.Ast.TokenIndex, |
| 57 | hash_tok: std.zig.Ast.OptionalTokenIndex, | 57 | hash_tok: std.zig.Ast.OptionalTokenIndex, |
| 58 | name_tok: std.zig.Ast.TokenIndex, | 58 | name_tok: std.zig.Ast.TokenIndex, |
| | 59 | name: []const u8, |
| | 60 | parent_specified_paths: std.array_hash_map.String(void), |
| | 61 | parent_specified_paths_tok: std.zig.Ast.OptionalTokenIndex, |
| | 62 | parent_specified_version: std.SemanticVersion, |
| | 63 | parent_specified_version_tok: std.zig.Ast.OptionalTokenIndex, |
| 59 | lazy_status: LazyStatus, | 64 | lazy_status: LazyStatus, |
| 60 | /// Same as `parent_packge_root` except it is unchanged when recursing into | 65 | /// Same as `parent_packge_root` except it is unchanged when recursing into |
| 61 | /// relative file paths (as opposed to URL). | 66 | /// relative file paths (as opposed to URL). |
| ... | @@ -632,7 +637,7 @@ pub fn run(f: *Fetch) RunError!void { | ... | @@ -632,7 +637,7 @@ pub fn run(f: *Fetch) RunError!void { |
| 632 | log.debug("FileNotFound: {f}", .{package_root}); | 637 | log.debug("FileNotFound: {f}", .{package_root}); |
| 633 | if (job_queue.read_only and f.lazy_status == .eager) return f.fail( | 638 | if (job_queue.read_only and f.lazy_status == .eager) return f.fail( |
| 634 | f.name_tok, | 639 | f.name_tok, |
| 635 | try eb.printString("package not found at '{f}'", .{package_root}), | 640 | try eb.printString("package not found at {qf}", .{package_root}), |
| 636 | ); | 641 | ); |
| 637 | }, | 642 | }, |
| 638 | error.Canceled => |e| return e, | 643 | error.Canceled => |e| return e, |
| ... | @@ -762,7 +767,7 @@ fn runResource( | ... | @@ -762,7 +767,7 @@ fn runResource( |
| 762 | try loadManifest(f, pkg_path); | 767 | try loadManifest(f, pkg_path); |
| 763 | | 768 | |
| 764 | const filter: Filter = .{ | 769 | const filter: Filter = .{ |
| 765 | .include_paths = if (f.have_manifest) f.manifest.paths else .{}, | 770 | .include_paths = if (f.have_manifest) f.manifest.paths else f.parent_specified_paths, |
| 766 | }; | 771 | }; |
| 767 | | 772 | |
| 768 | // Ignore errors that were excluded by manifest, such as failure to | 773 | // Ignore errors that were excluded by manifest, such as failure to |
| ... | @@ -856,9 +861,15 @@ pub fn computedPackageHash(f: *const Fetch) Package.Hash { | ... | @@ -856,9 +861,15 @@ pub fn computedPackageHash(f: *const Fetch) Package.Hash { |
| 856 | const version: []const u8 = std.mem.print(&version_buffer, "{f}", .{man.version}) catch &version_buffer; | 861 | const version: []const u8 = std.mem.print(&version_buffer, "{f}", .{man.version}) catch &version_buffer; |
| 857 | return .init(f.computed_hash.digest, man.name, version, man.id, saturated_size); | 862 | return .init(f.computed_hash.digest, man.name, version, man.id, saturated_size); |
| 858 | } | 863 | } |
| 859 | // In the future build.zig.zon fields will be added to allow overriding these values | 864 | // Previous version of Zig did not use f.name to affect the package hash, so |
| 860 | // for naked tarballs. | 865 | // allow the user to opt in by only doing that if they specify a version. |
| 861 | return .init(f.computed_hash.digest, "N", "V", 0xffff, saturated_size); | 866 | var version_buffer: [Manifest.max_version_len]u8 = undefined; |
| | 867 | if (f.parent_specified_version_tok != .none) { |
| | 868 | const v = std.mem.print(&version_buffer, "{f}", .{f.parent_specified_version}) catch unreachable; |
| | 869 | return .init(f.computed_hash.digest, f.name, v, 0xffff, saturated_size); |
| | 870 | } else { |
| | 871 | return .init(f.computed_hash.digest, "N", "V", 0xffff, saturated_size); |
| | 872 | } |
| 862 | } | 873 | } |
| 863 | | 874 | |
| 864 | /// `computeHash` gets a free check for the existence of `build.zig`, but when | 875 | /// `computeHash` gets a free check for the existence of `build.zig`, but when |
| ... | @@ -902,12 +913,24 @@ fn loadManifest(f: *Fetch, pkg_root: Path) RunError!void { | ... | @@ -902,12 +913,24 @@ fn loadManifest(f: *Fetch, pkg_root: Path) RunError!void { |
| 902 | error.ErrorsBundled => return error.FetchFailed, | 913 | error.ErrorsBundled => return error.FetchFailed, |
| 903 | else => |e| { | 914 | else => |e| { |
| 904 | try eb.addRootErrorMessage(.{ | 915 | try eb.addRootErrorMessage(.{ |
| 905 | .msg = try eb.printString("unable to load package manifest '{f}': {t}", .{ manifest_path, e }), | 916 | .msg = try eb.printString("unable to load package manifest {qf}: {t}", .{ manifest_path, e }), |
| 906 | }); | 917 | }); |
| 907 | return error.FetchFailed; | 918 | return error.FetchFailed; |
| 908 | }, | 919 | }, |
| 909 | }; | 920 | }; |
| 910 | f.have_manifest = true; | 921 | f.have_manifest = true; |
| | 922 | |
| | 923 | if (f.parent_specified_paths_tok.unwrap()) |tok| { |
| | 924 | return f.fail(tok, try eb.printString("paths provided for package containing {s}", .{ |
| | 925 | Manifest.basename, |
| | 926 | })); |
| | 927 | } |
| | 928 | |
| | 929 | if (f.parent_specified_version_tok.unwrap()) |tok| { |
| | 930 | return f.fail(tok, try eb.printString("version provided for package containing {s}", .{ |
| | 931 | Manifest.basename, |
| | 932 | })); |
| | 933 | } |
| 911 | } | 934 | } |
| 912 | | 935 | |
| 913 | fn queueJobsForDeps(f: *Fetch) RunError!void { | 936 | fn queueJobsForDeps(f: *Fetch) RunError!void { |
| ... | @@ -1008,6 +1031,11 @@ fn queueJobsForDeps(f: *Fetch) RunError!void { | ... | @@ -1008,6 +1031,11 @@ fn queueJobsForDeps(f: *Fetch) RunError!void { |
| 1008 | .location_tok = dep.location_tok, | 1031 | .location_tok = dep.location_tok, |
| 1009 | .hash_tok = dep.hash_tok, | 1032 | .hash_tok = dep.hash_tok, |
| 1010 | .name_tok = dep.name_tok, | 1033 | .name_tok = dep.name_tok, |
| | 1034 | .name = dep_name, |
| | 1035 | .parent_specified_paths = dep.paths, |
| | 1036 | .parent_specified_paths_tok = dep.paths_tok, |
| | 1037 | .parent_specified_version = dep.version, |
| | 1038 | .parent_specified_version_tok = dep.version_tok, |
| 1011 | .lazy_status = switch (f.job_queue.mode) { | 1039 | .lazy_status = switch (f.job_queue.mode) { |
| 1012 | .needed => if (dep.lazy) .available else .eager, | 1040 | .needed => if (dep.lazy) .available else .eager, |
| 1013 | .all => .eager, | 1041 | .all => .eager, |
| ... | @@ -1753,7 +1781,7 @@ fn computeHash(f: *Fetch, pkg_path: Path, filter: Filter) RunError!ComputedHash | ... | @@ -1753,7 +1781,7 @@ fn computeHash(f: *Fetch, pkg_path: Path, filter: Filter) RunError!ComputedHash |
| 1753 | | 1781 | |
| 1754 | while (walker.next(io) catch |err| { | 1782 | while (walker.next(io) catch |err| { |
| 1755 | try eb.addRootErrorMessage(.{ .msg = try eb.printString( | 1783 | try eb.addRootErrorMessage(.{ .msg = try eb.printString( |
| 1756 | "unable to walk temporary directory '{f}': {t}", | 1784 | "unable to walk temporary directory {qf}: {t}", |
| 1757 | .{ pkg_path, err }, | 1785 | .{ pkg_path, err }, |
| 1758 | ) }); | 1786 | ) }); |
| 1759 | return error.FetchFailed; | 1787 | return error.FetchFailed; |
| ... | @@ -1784,7 +1812,7 @@ fn computeHash(f: *Fetch, pkg_path: Path, filter: Filter) RunError!ComputedHash | ... | @@ -1784,7 +1812,7 @@ fn computeHash(f: *Fetch, pkg_path: Path, filter: Filter) RunError!ComputedHash |
| 1784 | .file => .file, | 1812 | .file => .file, |
| 1785 | .sym_link => .link, | 1813 | .sym_link => .link, |
| 1786 | else => return f.fail(f.location_tok, try eb.printString( | 1814 | else => return f.fail(f.location_tok, try eb.printString( |
| 1787 | "package contains '{s}' which has illegal file type '{t}'", | 1815 | "package contains {q} which has illegal file type {t}", |
| 1788 | .{ entry.path, entry.kind }, | 1816 | .{ entry.path, entry.kind }, |
| 1789 | )), | 1817 | )), |
| 1790 | }; | 1818 | }; |
| ... | @@ -1826,10 +1854,9 @@ fn computeHash(f: *Fetch, pkg_path: Path, filter: Filter) RunError!ComputedHash | ... | @@ -1826,10 +1854,9 @@ fn computeHash(f: *Fetch, pkg_path: Path, filter: Filter) RunError!ComputedHash |
| 1826 | error.DirNotEmpty => continue, | 1854 | error.DirNotEmpty => continue, |
| 1827 | error.FileNotFound => continue, | 1855 | error.FileNotFound => continue, |
| 1828 | else => |e| { | 1856 | else => |e| { |
| 1829 | try eb.addRootErrorMessage(.{ .msg = try eb.printString( | 1857 | try eb.addRootErrorMessage(.{ |
| 1830 | "unable to delete empty directory '{s}': {s}", | 1858 | .msg = try eb.printString("unable to delete empty directory {q}: {t}", .{ sus_dir, e }), |
| 1831 | .{ sus_dir, @errorName(e) }, | 1859 | }); |
| 1832 | ) }); | | |
| 1833 | return error.FetchFailed; | 1860 | return error.FetchFailed; |
| 1834 | }, | 1861 | }, |
| 1835 | }; | 1862 | }; |
| ... | @@ -1847,9 +1874,7 @@ fn computeHash(f: *Fetch, pkg_path: Path, filter: Filter) RunError!ComputedHash | ... | @@ -1847,9 +1874,7 @@ fn computeHash(f: *Fetch, pkg_path: Path, filter: Filter) RunError!ComputedHash |
| 1847 | hashed_file.failure catch |err| { | 1874 | hashed_file.failure catch |err| { |
| 1848 | any_failures = true; | 1875 | any_failures = true; |
| 1849 | try eb.addRootErrorMessage(.{ | 1876 | try eb.addRootErrorMessage(.{ |
| 1850 | .msg = try eb.printString("unable to hash '{s}': {s}", .{ | 1877 | .msg = try eb.printString("unable to hash {q}: {t}", .{ hashed_file.fs_path, err }), |
| 1851 | hashed_file.fs_path, @errorName(err), | | |
| 1852 | }), | | |
| 1853 | }); | 1878 | }); |
| 1854 | }; | 1879 | }; |
| 1855 | hasher.update(&hashed_file.hash); | 1880 | hasher.update(&hashed_file.hash); |
| ... | @@ -1859,8 +1884,8 @@ fn computeHash(f: *Fetch, pkg_path: Path, filter: Filter) RunError!ComputedHash | ... | @@ -1859,8 +1884,8 @@ fn computeHash(f: *Fetch, pkg_path: Path, filter: Filter) RunError!ComputedHash |
| 1859 | deleted_file.failure catch |err| { | 1884 | deleted_file.failure catch |err| { |
| 1860 | any_failures = true; | 1885 | any_failures = true; |
| 1861 | try eb.addRootErrorMessage(.{ | 1886 | try eb.addRootErrorMessage(.{ |
| 1862 | .msg = try eb.printString("failed to delete excluded path '{s}' from package: {s}", .{ | 1887 | .msg = try eb.printString("failed to delete excluded path {q} from package: {t}", .{ |
| 1863 | deleted_file.fs_path, @errorName(err), | 1888 | deleted_file.fs_path, err, |
| 1864 | }), | 1889 | }), |
| 1865 | }); | 1890 | }); |
| 1866 | }; | 1891 | }; |
| ... | @@ -2216,21 +2241,21 @@ const UnpackResult = struct { | ... | @@ -2216,21 +2241,21 @@ const UnpackResult = struct { |
| 2216 | switch (item) { | 2241 | switch (item) { |
| 2217 | .unable_to_create_sym_link => |info| { | 2242 | .unable_to_create_sym_link => |info| { |
| 2218 | eb.extra.items[note_i] = @backingInt(try eb.addErrorMessage(.{ | 2243 | eb.extra.items[note_i] = @backingInt(try eb.addErrorMessage(.{ |
| 2219 | .msg = try eb.printString("unable to create symlink from '{s}' to '{s}': {s}", .{ | 2244 | .msg = try eb.printString("unable to create symlink from {q} to {q}: {t}", .{ |
| 2220 | info.file_name, info.link_name, @errorName(info.code), | 2245 | info.file_name, info.link_name, info.code, |
| 2221 | }), | 2246 | }), |
| 2222 | })); | 2247 | })); |
| 2223 | }, | 2248 | }, |
| 2224 | .unable_to_create_file => |info| { | 2249 | .unable_to_create_file => |info| { |
| 2225 | eb.extra.items[note_i] = @backingInt(try eb.addErrorMessage(.{ | 2250 | eb.extra.items[note_i] = @backingInt(try eb.addErrorMessage(.{ |
| 2226 | .msg = try eb.printString("unable to create file '{s}': {s}", .{ | 2251 | .msg = try eb.printString("unable to create file {q}: {t}", .{ |
| 2227 | info.file_name, @errorName(info.code), | 2252 | info.file_name, info.code, |
| 2228 | }), | 2253 | }), |
| 2229 | })); | 2254 | })); |
| 2230 | }, | 2255 | }, |
| 2231 | .unsupported_file_type => |info| { | 2256 | .unsupported_file_type => |info| { |
| 2232 | eb.extra.items[note_i] = @backingInt(try eb.addErrorMessage(.{ | 2257 | eb.extra.items[note_i] = @backingInt(try eb.addErrorMessage(.{ |
| 2233 | .msg = try eb.printString("file '{s}' has unsupported type '{c}'", .{ | 2258 | .msg = try eb.printString("file {q} has unsupported type '{c}'", .{ |
| 2234 | info.file_name, info.file_type, | 2259 | info.file_name, info.file_type, |
| 2235 | }), | 2260 | }), |
| 2236 | })); | 2261 | })); |