# SPDX-License-Identifier: EUPL-1.2+ # SPDX-FileCopyrightText: 2021-2024 Alyssa Ross # SPDX-FileCopyrightText: 2025 Demi Marie Obenour 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; } done { fail("Junk after DONE", 1); } $0 == "DONE" { done = 1; next; } # 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; } if (!done) { fail("Did not receive DONE line"); } printf ("# SPDX-License-Identifier: EUPL-1.2+\n" \ "# SPDX-FileCopyrightText: 2021-2024 Alyssa Ross \n" \ "# Generated by scripts/genfile.sh. Any changes will be overwritten.\n" \ "FILES =") > out_file; for (array_index = 0; array_index < file_count; array_index += 1) { printf " \\\n\t%s", files[array_index] > out_file; } printf ("\n\n" \ "# These are separate because they need to be included, but putting\n" \ "# them as make dependencies would confuse make.\n" \ "LINKS =") > out_file; for (array_index = 0; array_index < symlink_count; array_index += 1) { printf " \\\n\t%s", symlinks[array_index] > out_file; } printf "\n\nS6_RC_FILES =" > out_file; for (array_index = 0; array_index < rc_count; array_index += 1) { printf " \\\n\t%s", rc_files[array_index] > out_file; } print > out_file; if (close(out_file)) { fail("Cannot close output file: " ERRNO); } }