Re: [PATCH v6] Generate file lists from a script

Demi Marie Obenour
2025-09-29T17:20:35Z

[-- Attachment #1.1.1: Type: text/plain, Size: 3714 bytes --]

On 9/29/25 04:12, Alyssa Ross wrote:
> Demi Marie Obenour <demiobenour@gmail.com> writes:
>
>> diff --git a/scripts/genfiles.awk b/scripts/genfiles.awk
>> new file mode 100644
>> index 0000000000000000000000000000000000000000..986d86ec7e3080ab7c9a73307d116d244ef542e0
>> --- /dev/null
>> +++ b/scripts/genfiles.awk
>> @@ -0,0 +1,79 @@
>> +# SPDX-License-Identifier: EUPL-1.2+
>> +# 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;
>
> I've been pointing out since v3 that this variable doesn't do anything.
> It's still here!

It actually does do something: the END block runs even after the exit
statement, unless the exit statement is itself in the END block.
I added a comment in v7 to explain this.

>> + 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: CC0-1.0\n" \
>> +"# SPDX-FileCopyrightText: 2025 Demi Marie Obenour <demiobenour@gmail.com>\n" \
>
> Does reuse pick these up? If so, might need to break them up into
> multiple string literals.

Yup, fixed in v7.

> Let's leave a blank line after the header too — I think that's more readable.
>
>> +"FILES =");
>> + for (array_index = 0; array_index < file_count; array_index += 1) {
>> + printf " \\\n\t%s", files[array_index];
>> + }
>> + # GNU Make uses the modification time of the *target* of a symlink,
>> + # rather than the modification time of the symlink itself. It can be told
>> + # to *also* use the symlink's modification time, but not to *only* use
>> + # the symlink's modification time. However, these symlinks will generally
>> + # be broken, so make will not be able to dereference the symlink.
>> + # Therefore, using these symlinks as make dependencies won't work.
>> + printf ("\n\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 "";
>> +}
>> diff --git a/scripts/genfiles.sh b/scripts/genfiles.sh
>> new file mode 100755
>> index 0000000000000000000000000000000000000000..a595d9effd64fe110ed0c2875bbd30f4428ee3f7
>> --- /dev/null
>> +++ b/scripts/genfiles.sh
>> @@ -0,0 +1,24 @@
>> +#!/bin/sh --
>> +set -euo pipefail
>
> Missing copyright.

Fixed in v7.
--
Sincerely,
Demi Marie Obenour (she/her/hers)

[-- Attachment #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 7253 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]