patches and low-level development discussion
 help / color / mirror / code / Atom feed
blob 935eebbdc7f0e2aa07b0b6439ab53d1f50940929 1928 bytes (raw)
name: scripts/genfiles.awk 	 # note: path name is non-authoritative(*)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
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
 
# SPDX-License-Identifier: EUPL-1.2+
# SPDX-FileCopyrightText: 2021-2024 Alyssa Ross <hi@alyssa.is>
# SPDX-FileCopyrightText: 2025 Demi Marie Obenour <demiobenour@gmail.com>
BEGIN {
	RS = "\n";
	FS = "\t";
	modes["120000"] = "symlink";
	modes["100644"] = "regular";
	modes["100755"] = "regular";
}

function fail(msg) {
	exit_code = 1;
	print msg > "/dev/stderr";
	exit 1;
}

# Extract data from built-in variables.
{
	filename = $2;
	raw_mode = $1;
	# awk autocreates empty string entries if the key is invalid,
	# but the code exits in this case so that is okay.
	mode = modes[raw_mode];
}

filename !~ /^[[:alnum:]_./-]+$/ {
	fail("filename '" filename "' has forbidden characters");
}

# Skip license files
/\.license$/ { next }

filename ~ /^image\/etc\/s6-rc\// {
	if (mode != "regular") {
		fail("s6-rc-compile input '" filename "' isn't a regular file");
	}
	rc_files[rc_count++] = filename;
	next;
}

mode == "symlink" {
	symlinks[symlink_count++] = filename;
	next;
}

mode == "regular" {
	files[file_count++] = filename;
	next;
}

{ fail("File '" filename "' is not regular file or symlink (mode " raw_mode ")"); }

END {
	if (exit_code) {
		exit exit_code;
	}
	printf ("# SPDX-License-Identifier: EUPL-1.2+\n" \
"# SPDX-FileCopyrightText: 2021-2024 Alyssa Ross <hi@alyssa.is>\n" \
"# Generated by scripts/genfile.sh.  Any changes will be overwritten.\n" \
"FILES =");
	for (array_index = 0; array_index < file_count; array_index += 1) {
		printf " \\\n\t%s", files[array_index];
	}
	printf ("\n\n" \
"# These are separate because they need to be included, but putting\n" \
"# them as make dependencies would confuse make.\n" \
"LINKS =");
	for (array_index = 0; array_index < symlink_count; array_index += 1) {
		printf " \\\n\t%s", symlinks[array_index];
	}
	printf "\n\nS6_RC_FILES =";
	for (array_index = 0; array_index < rc_count; array_index += 1) {
		printf " \\\n\t%s", rc_files[array_index];
	}
	print "";
}

debug log:

solving 935eebbdc7f0e2aa07b0b6439ab53d1f50940929 ...
found 935eebbdc7f0e2aa07b0b6439ab53d1f50940929 in https://inbox.spectrum-os.org/spectrum-devel/20250926-genfiles-v5-1-3394dfb3b330@gmail.com/

applying [1/1] https://inbox.spectrum-os.org/spectrum-devel/20250926-genfiles-v5-1-3394dfb3b330@gmail.com/
diff --git a/scripts/genfiles.awk b/scripts/genfiles.awk
new file mode 100644
index 0000000000000000000000000000000000000000..935eebbdc7f0e2aa07b0b6439ab53d1f50940929

Checking patch scripts/genfiles.awk...
Applied patch scripts/genfiles.awk cleanly.

index at:
100644 935eebbdc7f0e2aa07b0b6439ab53d1f50940929	scripts/genfiles.awk

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this public inbox

	https://spectrum-os.org/git/crosvm
	https://spectrum-os.org/git/doc
	https://spectrum-os.org/git/mktuntap
	https://spectrum-os.org/git/nixpkgs
	https://spectrum-os.org/git/spectrum
	https://spectrum-os.org/git/ucspi-vsock
	https://spectrum-os.org/git/www

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).