util/autoport: Add function to create empty files

As per commit cf4722d317 ("src/mb: Update unlicensable files with the
CC-PDDC SPDX ID") effectively empty files should use the Creative
Commons Public Domain Dedication and Certification (CC-PDDC) license
header. Add a function to create an empty file and add the CC-PDDC SPDX
header and a comment to change the license if content is added.

The only empty files that autoport currently generates are ec.asl and
superio.asl on non-laptop systems, where NoEC() is used.

Change-Id: I409a6d90d671258e318c26e34a35c238d6fd28c1
Signed-off-by: Nicholas Chin <nic.c3.14@gmail.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/84329
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Nico Huber <nico.h@gmx.de>
This commit is contained in:
Nicholas Chin 2024-06-23 10:39:23 -06:00 committed by Matt DeVillier
commit 36ac6226ff
2 changed files with 12 additions and 7 deletions

View file

@ -16,9 +16,6 @@ Method(_PTS, 1)
}
`)
si := Create(ctx, "acpi/superio.asl")
defer si.Close()
ec := Create(ctx, "acpi/ec.asl")
defer ec.Close()
Create_Empty(ctx, "acpi/superio.asl", ASL)
Create_Empty(ctx, "acpi/ec.asl", ASL)
}

View file

@ -120,8 +120,9 @@ var CommentFormatStrings map[Filetype]string = map[Filetype]string {
type License string
const (
GPL2_only License = "GPL-2.0-only"
GPL2_or_later = "GPL-2.0-or-later"
CC_PDDC License = "CC-PDDC"
GPL2_only = "GPL-2.0-only"
GPL2_or_later = "GPL-2.0-or-later"
)
var KconfigBool map[string]bool = map[string]bool{}
@ -233,6 +234,13 @@ func Create(ctx Context, name string) *os.File {
}
return mf
}
func Create_Empty(ctx Context, name string, filetype Filetype) {
f := Create(ctx, name)
defer f.Close()
Add_SPDX(f, filetype, CC_PDDC)
Add_Comment(f, filetype,
"Please update the license if adding licensable material.")
}
func Add_SPDX(f *os.File, filetype Filetype, license License) {
Add_Comment(f, filetype, "SPDX-License-Identifier: " + string(license))