meta/classes/debianize: install appropriate copyright file

Message ID 20240507074102.1147439-1-srinuvasan.a@siemens.com
State Changes Requested
Headers show
Series meta/classes/debianize: install appropriate copyright file | expand

Commit Message

Arjunan, Srinu May 7, 2024, 7:41 a.m. UTC
From: Srinuvasan A <srinuvasan.a@siemens.com>

Presently we have an example to install the copyright file in the debian
package, now we improved little bit to install the appropriate copyright
file based on the configured variable "LICENSE" in the recipe.

Added the example for example-raw recipe.

Signed-off-by: Srinuvasan A <srinuvasan.a@siemens.com>
---
 .../example-raw/example-raw_0.3.bb            |  7 +++--
 .../example-raw/files/default-copyright       | 22 ---------------
 meta/classes/debianize.bbclass                |  6 ++---
 meta/classes/dpkg-helper-license.bbclass      | 27 +++++++++++++++++++
 .../debian/GPL-2.0+/default-copyright.tmpl    | 24 +++++++++++++++++
 .../debian/GPL-2.0/default-copyright.tmpl     | 23 ++++++++++++++++
 .../debian/GPL-3.0/default-copyright.tmpl     | 22 +++++++++++++++
 .../debian/MIT/default-copyright.tmpl         | 26 ++++++++++++++++++
 8 files changed, 130 insertions(+), 27 deletions(-)
 delete mode 100644 meta-isar/recipes-app/example-raw/files/default-copyright
 create mode 100644 meta/classes/dpkg-helper-license.bbclass
 create mode 100644 meta/licenses/debian/GPL-2.0+/default-copyright.tmpl
 create mode 100644 meta/licenses/debian/GPL-2.0/default-copyright.tmpl
 create mode 100644 meta/licenses/debian/GPL-3.0/default-copyright.tmpl
 create mode 100644 meta/licenses/debian/MIT/default-copyright.tmpl

Comments

Jan Kiszka May 8, 2024, 5:35 a.m. UTC | #1
On 07.05.24 09:41, srinuvasan.a@siemens.com wrote:
> From: Srinuvasan A <srinuvasan.a@siemens.com>
> 
> Presently we have an example to install the copyright file in the debian
> package, now we improved little bit to install the appropriate copyright
> file based on the configured variable "LICENSE" in the recipe.
> 
> Added the example for example-raw recipe.
> 
> Signed-off-by: Srinuvasan A <srinuvasan.a@siemens.com>
> ---
>  .../example-raw/example-raw_0.3.bb            |  7 +++--
>  .../example-raw/files/default-copyright       | 22 ---------------
>  meta/classes/debianize.bbclass                |  6 ++---
>  meta/classes/dpkg-helper-license.bbclass      | 27 +++++++++++++++++++
>  .../debian/GPL-2.0+/default-copyright.tmpl    | 24 +++++++++++++++++
>  .../debian/GPL-2.0/default-copyright.tmpl     | 23 ++++++++++++++++
>  .../debian/GPL-3.0/default-copyright.tmpl     | 22 +++++++++++++++
>  .../debian/MIT/default-copyright.tmpl         | 26 ++++++++++++++++++
>  8 files changed, 130 insertions(+), 27 deletions(-)
>  delete mode 100644 meta-isar/recipes-app/example-raw/files/default-copyright
>  create mode 100644 meta/classes/dpkg-helper-license.bbclass
>  create mode 100644 meta/licenses/debian/GPL-2.0+/default-copyright.tmpl
>  create mode 100644 meta/licenses/debian/GPL-2.0/default-copyright.tmpl
>  create mode 100644 meta/licenses/debian/GPL-3.0/default-copyright.tmpl
>  create mode 100644 meta/licenses/debian/MIT/default-copyright.tmpl
> 
> diff --git a/meta-isar/recipes-app/example-raw/example-raw_0.3.bb b/meta-isar/recipes-app/example-raw/example-raw_0.3.bb
> index 35f4b3d9..1730431e 100644
> --- a/meta-isar/recipes-app/example-raw/example-raw_0.3.bb
> +++ b/meta-isar/recipes-app/example-raw/example-raw_0.3.bb
> @@ -6,13 +6,16 @@
>  DESCRIPTION = "Sample application for ISAR"
>  MAINTAINER = "Your name here <you@domain.com>"
>  DEBIAN_DEPENDS = "adduser, apt (>= 0.4.2)"
> +HOMEPAGE = "<Home page of the recipe>"

This visualizes that we have a missing default...

> +
> +LICENSE = "MIT"
>  
>  SRC_URI = "file://README \
>  	   file://postinst \
> -	   file://rules \
> -	   file://default-copyright"
> +	   file://rules"
>  
>  inherit dpkg-raw
> +inherit dpkg-helper-license

Can't we get this via debianize automatically? If LICENSE is unset or an
own copyright file is provided, it won't do any harm, right?

>  
>  do_install() {
>  	bbnote "Creating ${PN} binary"
> diff --git a/meta-isar/recipes-app/example-raw/files/default-copyright b/meta-isar/recipes-app/example-raw/files/default-copyright
> deleted file mode 100644
> index 3511cb51..00000000
> --- a/meta-isar/recipes-app/example-raw/files/default-copyright
> +++ /dev/null
> @@ -1,22 +0,0 @@
> -MIT License
> -
> -Copyright (c) 2017-2024, Siemens
> -Copyright (c) 2024 ilbers GmbH
> -
> -Permission is hereby granted, free of charge, to any person obtaining a copy
> -of this software and associated documentation files (the "Software"), to deal
> -in the Software without restriction, including without limitation the rights
> -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
> -copies of the Software, and to permit persons to whom the Software is
> -furnished to do so, subject to the following conditions:
> -
> -The above copyright notice and this permission notice shall be included in all
> -copies or substantial portions of the Software.
> -
> -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
> -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
> -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
> -SOFTWARE.
> diff --git a/meta/classes/debianize.bbclass b/meta/classes/debianize.bbclass
> index adb6cf2b..54a16260 100644
> --- a/meta/classes/debianize.bbclass
> +++ b/meta/classes/debianize.bbclass
> @@ -120,9 +120,9 @@ deb_debianize() {
>  	else
>  		deb_create_rules
>  	fi
> -	# Add the copyright if unpacked sources does not contain copyright file
> -	if [ ! -f ${S}/debian/copyright ] && [ -f ${WORKDIR}/default-copyright ]; then
> -		install -v -m 644 ${WORKDIR}/default-copyright ${S}/debian/copyright
> +	# Add the copyright if unpacked sources does not contain copyright file as well as the recipes configured the LICENSE
> +	if [ ! -f ${S}/debian/copyright ] && [ -f ${WORKDIR}/${LICENSE}/default-copyright ]; then
> +		 install -v -m 644 ${WORKDIR}/${LICENSE}/default-copyright ${S}/debian/copyright
>  	fi
>  	# prepend a changelog-entry unless an existing changelog file already
>  	# contains an entry with CHANGELOG_V
> diff --git a/meta/classes/dpkg-helper-license.bbclass b/meta/classes/dpkg-helper-license.bbclass
> new file mode 100644
> index 00000000..81e6d4e6
> --- /dev/null
> +++ b/meta/classes/dpkg-helper-license.bbclass
> @@ -0,0 +1,27 @@
> +# This software is a part of ISAR.
> +# Copyright (C) 2024 Siemens AG
> +#
> +# SPDX-License-Identifier: MIT
> +
> +LICENSE ??= ""
> +

Missing HOMEPAGE default, given that all templates require this variable.

> +inherit template
> +
> +# Path to copyright template files
> +FILESPATH:prepend := "${LAYERDIR_core}/licenses/debian:"
> +
> +# GPL-2.0 licensed packages
> +SRC_URI:append = " ${@ 'file://GPL-2.0/default-copyright.tmpl' if d.getVar('LICENSE') == 'GPL-2.0' else '' }"
> +TEMPLATE_FILES:append = "${@ ' GPL-2.0/default-copyright.tmpl' if d.getVar('LICENSE') == 'GPL-2.0' else '' }"
> +
> +# GPL-2.0+ licensed packages
> +SRC_URI:append = " ${@ 'file://GPL-2.0+/default-copyright.tmpl' if d.getVar('LICENSE') == 'GPL-2.0+' else '' }"
> +TEMPLATE_FILES:append = "${@ ' GPL-2.0+/default-copyright.tmpl' if d.getVar('LICENSE') == 'GPL-2.0+' else '' }"
> +
> +# GPL-3.0 licensed packages
> +SRC_URI:append = " ${@ 'file://GPL-3.0/default-copyright.tmpl' if d.getVar('LICENSE') == 'GPL-3.0' else '' }"
> +TEMPLATE_FILES:append = "${@ ' GPL-3.0/default-copyright.tmpl' if d.getVar('LICENSE') == 'GPL-3.0' else '' }"
> +
> +# MIT licensed packages
> +SRC_URI:append = " ${@ 'file://MIT/default-copyright.tmpl' if d.getVar('LICENSE') == 'MIT' else '' }"
> +TEMPLATE_FILES:append = "${@ ' MIT/default-copyright.tmpl' if d.getVar('LICENSE') == 'MIT' else '' }"

This could be enhanced by supporting license choices ("A | B") and
multiple license ("A & B"). OTOH, the "Files:" tag in the templates are
even more likely to become incorrect in such cases.

> diff --git a/meta/licenses/debian/GPL-2.0+/default-copyright.tmpl b/meta/licenses/debian/GPL-2.0+/default-copyright.tmpl
> new file mode 100644
> index 00000000..5c6d27c5
> --- /dev/null
> +++ b/meta/licenses/debian/GPL-2.0+/default-copyright.tmpl
> @@ -0,0 +1,24 @@
> +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
> +Upstream-Name: ${BPN}
> +Source: ${HOMEPAGE}
> +
> +Files: *
> +Copyright: ${MAINTAINER}
> +License: GPL-2.0+
> +
> +License: GPL-2.0+
> + This package is free software; you can redistribute it and/or modify
> + it under the terms of the GNU General Public License as published by
> + the Free Software Foundation; either version 2 of the License, or
> + (at your option) any later version.
> + .
> + This package is distributed in the hope that it will be useful,
> + but WITHOUT ANY WARRANTY; without even the implied warranty of
> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + GNU General Public License for more details.
> + .
> + You should have received a copy of the GNU General Public License
> + along with this program. If not, see <https://www.gnu.org/licenses/>
> + .
> + On Debian systems, the complete text of the GNU General
> + Public License version 2 can be found in "/usr/share/common-licenses/GPL-2".
> diff --git a/meta/licenses/debian/GPL-2.0/default-copyright.tmpl b/meta/licenses/debian/GPL-2.0/default-copyright.tmpl
> new file mode 100644
> index 00000000..223e5841
> --- /dev/null
> +++ b/meta/licenses/debian/GPL-2.0/default-copyright.tmpl
> @@ -0,0 +1,23 @@
> +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
> +Upstream-Name: ${BPN}
> +Source: ${HOMEPAGE}
> +
> +Files: *
> +Copyright: ${MAINTAINER}
> +License: GPL-2.0
> +
> +License: GPL-2.0
> + This package is free software; you can redistribute it and/or modify
> + it under the terms of the GNU General Public License as published by
> + the Free Software Foundation; either version 2 of the License.
> + .
> + This package is distributed in the hope that it will be useful,
> + but WITHOUT ANY WARRANTY; without even the implied warranty of
> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + GNU General Public License for more details.
> + .
> + You should have received a copy of the GNU General Public License
> + along with this program. If not, see <https://www.gnu.org/licenses/>
> + .
> + On Debian systems, the complete text of the GNU General
> + Public License version 2 can be found in "/usr/share/common-licenses/GPL-2".
> diff --git a/meta/licenses/debian/GPL-3.0/default-copyright.tmpl b/meta/licenses/debian/GPL-3.0/default-copyright.tmpl
> new file mode 100644
> index 00000000..c2511481
> --- /dev/null
> +++ b/meta/licenses/debian/GPL-3.0/default-copyright.tmpl
> @@ -0,0 +1,22 @@
> +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
> +Upstream-Name: ${BPN}
> +Source: ${HOMEPAGE}
> +
> +Files: *
> +Copyright: ${MAINTAINER}
> +License: GPL-3.0
> +
> +License: GPL-3.0
> + This program is free software: you can redistribute it and/or modify  it under
> + the terms of the GNU General Public License as published by the Free
> + Software Foundation, version 3 of the License.
> + .
> + This program is distributed in the hope that it will be useful, but WITHOUT ANY
> + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
> + PARTICULAR PURPOSE.  See the GNU General Public License for more details.
> + .
> + You should have received a copy of the GNU General Public License along with
> + this program.  If not, see <http://www.gnu.org/licenses/>.
> + .
> + On Debian systems, the complete text of the GNU General Public License version
> + 3 can be found in "/usr/share/common-licenses/GPL-3".
> diff --git a/meta/licenses/debian/MIT/default-copyright.tmpl b/meta/licenses/debian/MIT/default-copyright.tmpl
> new file mode 100644
> index 00000000..2bced7f5
> --- /dev/null
> +++ b/meta/licenses/debian/MIT/default-copyright.tmpl
> @@ -0,0 +1,26 @@
> +Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
> +Upstream-Name: ${BPN}
> +Source: ${HOMEPAGE}
> +
> +Files: *
> +Copyright: ${MAINTAINER}
> +License: MIT
> +
> +License: MIT
> + Permission is hereby granted, free of charge, to any person obtaining a copy
> + of this software and associated documentation files (the "Software"), to deal
> + in the Software without restriction, including without limitation the rights
> + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
> + copies of the Software, and to permit persons to whom the Software is
> + furnished to do so, subject to the following conditions:
> + .
> + The above copyright notice and this permission notice shall be included in all
> + copies or substantial portions of the Software.
> + .
> + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
> + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
> + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
> + SOFTWARE.

Jan
Srinuvasan Arjunan May 8, 2024, 6:24 a.m. UTC | #2
On Wednesday, May 8, 2024 at 11:05:46 AM UTC+5:30 Jan Kiszka wrote:

On 07.05.24 09:41, srinuv...@siemens.com wrote: 
> From: Srinuvasan A <srinuv...@siemens.com> 
> 
> Presently we have an example to install the copyright file in the debian 
> package, now we improved little bit to install the appropriate copyright 
> file based on the configured variable "LICENSE" in the recipe. 
> 
> Added the example for example-raw recipe. 
> 
> Signed-off-by: Srinuvasan A <srinuv...@siemens.com> 
> --- 
> .../example-raw/example-raw_0.3.bb | 7 +++-- 
> .../example-raw/files/default-copyright | 22 --------------- 
> meta/classes/debianize.bbclass | 6 ++--- 
> meta/classes/dpkg-helper-license.bbclass | 27 +++++++++++++++++++ 
> .../debian/GPL-2.0+/default-copyright.tmpl | 24 +++++++++++++++++ 
> .../debian/GPL-2.0/default-copyright.tmpl | 23 ++++++++++++++++ 
> .../debian/GPL-3.0/default-copyright.tmpl | 22 +++++++++++++++ 
> .../debian/MIT/default-copyright.tmpl | 26 ++++++++++++++++++ 
> 8 files changed, 130 insertions(+), 27 deletions(-) 
> delete mode 100644 
meta-isar/recipes-app/example-raw/files/default-copyright 
> create mode 100644 meta/classes/dpkg-helper-license.bbclass 
> create mode 100644 meta/licenses/debian/GPL-2.0+/default-copyright.tmpl 
> create mode 100644 meta/licenses/debian/GPL-2.0/default-copyright.tmpl 
> create mode 100644 meta/licenses/debian/GPL-3.0/default-copyright.tmpl 
> create mode 100644 meta/licenses/debian/MIT/default-copyright.tmpl 
> 
> diff --git a/meta-isar/recipes-app/example-raw/example-raw_0.3.bb 
b/meta-isar/recipes-app/example-raw/example-raw_0.3.bb 
> index 35f4b3d9..1730431e 100644 
> --- a/meta-isar/recipes-app/example-raw/example-raw_0.3.bb 
> +++ b/meta-isar/recipes-app/example-raw/example-raw_0.3.bb 
> @@ -6,13 +6,16 @@ 
> DESCRIPTION = "Sample application for ISAR" 
> MAINTAINER = "Your name here <y...@domain.com>" 
> DEBIAN_DEPENDS = "adduser, apt (>= 0.4.2)" 
> +HOMEPAGE = "<Home page of the recipe>" 

This visualizes that we have a missing default...


     You meant that we should provide the actual home page of this recipe 
instead of <replace home page of the recipe> ? 



> + 
> +LICENSE = "MIT" 
> 
> SRC_URI = "file://README \ 
> file://postinst \ 
> - file://rules \ 
> - file://default-copyright" 
> + file://rules" 
> 
> inherit dpkg-raw 
> +inherit dpkg-helper-license 

Can't we get this via debianize automatically? If LICENSE is unset or an 
own copyright file is provided, it won't do any harm, right?



     Initially i tried with that approach, i meant selection of licenses in 
debianize class instead of dpkg-helper-license class, but here i faced 
     build issue with the prebuilt-deb recipe, here we are inheriting the 
dpkg-prebuilt class , in this class we are getting SRC_URI without expansion
    
 https://github.com/ilbers/isar/blob/master/meta/classes/dpkg-prebuilt.bbclass#L10, 
but we are appending to the SRC_URI for selection of template files based 
on the LICENSE variable this not works with that recipes, due to this the 
build is not completed successfully.

     Already started discussion to fix this issue in mailing list,  please 
refer: https://groups.google.com/g/isar-users/c/DnT1KcBiFtc
  
      But for other valid reason i don't want to add the SRC_URI expansion 
in the dpkg-prebuilt class, instead introduced a new class, suppose if we 
want to configure the LICENSE in any recipes just inherit the 
dpkg-helper-licenses class is fine. 

If we not configured the LICENSE it won't do any harm.
 



> 
> do_install() { 
> bbnote "Creating ${PN} binary" 
> diff --git a/meta-isar/recipes-app/example-raw/files/default-copyright 
b/meta-isar/recipes-app/example-raw/files/default-copyright 
> deleted file mode 100644 
> index 3511cb51..00000000 
> --- a/meta-isar/recipes-app/example-raw/files/default-copyright 
> +++ /dev/null 
> @@ -1,22 +0,0 @@ 
> -MIT License 
> - 
> -Copyright (c) 2017-2024, Siemens 
> -Copyright (c) 2024 ilbers GmbH 
> - 
> -Permission is hereby granted, free of charge, to any person obtaining a 
copy 
> -of this software and associated documentation files (the "Software"), to 
deal 
> -in the Software without restriction, including without limitation the 
rights 
> -to use, copy, modify, merge, publish, distribute, sublicense, and/or 
sell 
> -copies of the Software, and to permit persons to whom the Software is 
> -furnished to do so, subject to the following conditions: 
> - 
> -The above copyright notice and this permission notice shall be included 
in all 
> -copies or substantial portions of the Software. 
> - 
> -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 
OR 
> -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
> -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 
THE 
> -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
> -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
FROM, 
> -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 
IN THE 
> -SOFTWARE. 
> diff --git a/meta/classes/debianize.bbclass 
b/meta/classes/debianize.bbclass 
> index adb6cf2b..54a16260 100644 
> --- a/meta/classes/debianize.bbclass 
> +++ b/meta/classes/debianize.bbclass 
> @@ -120,9 +120,9 @@ deb_debianize() { 
> else 
> deb_create_rules 
> fi 
> - # Add the copyright if unpacked sources does not contain copyright file 
> - if [ ! -f ${S}/debian/copyright ] && [ -f ${WORKDIR}/default-copyright 
]; then 
> - install -v -m 644 ${WORKDIR}/default-copyright ${S}/debian/copyright 
> + # Add the copyright if unpacked sources does not contain copyright file 
as well as the recipes configured the LICENSE 
> + if [ ! -f ${S}/debian/copyright ] && [ -f 
${WORKDIR}/${LICENSE}/default-copyright ]; then 
> + install -v -m 644 ${WORKDIR}/${LICENSE}/default-copyright 
${S}/debian/copyright 
> fi 
> # prepend a changelog-entry unless an existing changelog file already 
> # contains an entry with CHANGELOG_V 
> diff --git a/meta/classes/dpkg-helper-license.bbclass 
b/meta/classes/dpkg-helper-license.bbclass 
> new file mode 100644 
> index 00000000..81e6d4e6 
> --- /dev/null 
> +++ b/meta/classes/dpkg-helper-license.bbclass 
> @@ -0,0 +1,27 @@ 
> +# This software is a part of ISAR. 
> +# Copyright (C) 2024 Siemens AG 
> +# 
> +# SPDX-License-Identifier: MIT 
> + 
> +LICENSE ??= "" 
> + 

Missing HOMEPAGE default, given that all templates require this variable.


   Will add this variable 



> +inherit template 
> + 
> +# Path to copyright template files 
> +FILESPATH:prepend := "${LAYERDIR_core}/licenses/debian:" 
> + 
> +# GPL-2.0 licensed packages 
> +SRC_URI:append = " ${@ 'file://GPL-2.0/default-copyright.tmpl' if 
d.getVar('LICENSE') == 'GPL-2.0' else '' }" 
> +TEMPLATE_FILES:append = "${@ ' GPL-2.0/default-copyright.tmpl' if 
d.getVar('LICENSE') == 'GPL-2.0' else '' }" 
> + 
> +# GPL-2.0+ licensed packages 
> +SRC_URI:append = " ${@ 'file://GPL-2.0+/default-copyright.tmpl' if 
d.getVar('LICENSE') == 'GPL-2.0+' else '' }" 
> +TEMPLATE_FILES:append = "${@ ' GPL-2.0+/default-copyright.tmpl' if 
d.getVar('LICENSE') == 'GPL-2.0+' else '' }" 
> + 
> +# GPL-3.0 licensed packages 
> +SRC_URI:append = " ${@ 'file://GPL-3.0/default-copyright.tmpl' if 
d.getVar('LICENSE') == 'GPL-3.0' else '' }" 
> +TEMPLATE_FILES:append = "${@ ' GPL-3.0/default-copyright.tmpl' if 
d.getVar('LICENSE') == 'GPL-3.0' else '' }" 
> + 
> +# MIT licensed packages 
> +SRC_URI:append = " ${@ 'file://MIT/default-copyright.tmpl' if 
d.getVar('LICENSE') == 'MIT' else '' }" 
> +TEMPLATE_FILES:append = "${@ ' MIT/default-copyright.tmpl' if 
d.getVar('LICENSE') == 'MIT' else '' }" 

This could be enhanced by supporting license choices ("A | B") and 
multiple license ("A & B"). OTOH, the "Files:" tag in the templates are 
even more likely to become incorrect in such cases.



    This will take a look. 



> diff --git a/meta/licenses/debian/GPL-2.0+/default-copyright.tmpl 
b/meta/licenses/debian/GPL-2.0+/default-copyright.tmpl 
> new file mode 100644 
> index 00000000..5c6d27c5 
> --- /dev/null 
> +++ b/meta/licenses/debian/GPL-2.0+/default-copyright.tmpl 
> @@ -0,0 +1,24 @@ 
> +Format: 
https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ 
> +Upstream-Name: ${BPN} 
> +Source: ${HOMEPAGE} 
> + 
> +Files: * 
> +Copyright: ${MAINTAINER} 
> +License: GPL-2.0+ 
> + 
> +License: GPL-2.0+ 
> + This package is free software; you can redistribute it and/or modify 
> + it under the terms of the GNU General Public License as published by 
> + the Free Software Foundation; either version 2 of the License, or 
> + (at your option) any later version. 
> + . 
> + This package is distributed in the hope that it will be useful, 
> + but WITHOUT ANY WARRANTY; without even the implied warranty of 
> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
> + GNU General Public License for more details. 
> + . 
> + You should have received a copy of the GNU General Public License 
> + along with this program. If not, see <https://www.gnu.org/licenses/> 
> + . 
> + On Debian systems, the complete text of the GNU General 
> + Public License version 2 can be found in 
"/usr/share/common-licenses/GPL-2". 
> diff --git a/meta/licenses/debian/GPL-2.0/default-copyright.tmpl 
b/meta/licenses/debian/GPL-2.0/default-copyright.tmpl 
> new file mode 100644 
> index 00000000..223e5841 
> --- /dev/null 
> +++ b/meta/licenses/debian/GPL-2.0/default-copyright.tmpl 
> @@ -0,0 +1,23 @@ 
> +Format: 
https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ 
> +Upstream-Name: ${BPN} 
> +Source: ${HOMEPAGE} 
> + 
> +Files: * 
> +Copyright: ${MAINTAINER} 
> +License: GPL-2.0 
> + 
> +License: GPL-2.0 
> + This package is free software; you can redistribute it and/or modify 
> + it under the terms of the GNU General Public License as published by 
> + the Free Software Foundation; either version 2 of the License. 
> + . 
> + This package is distributed in the hope that it will be useful, 
> + but WITHOUT ANY WARRANTY; without even the implied warranty of 
> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
> + GNU General Public License for more details. 
> + . 
> + You should have received a copy of the GNU General Public License 
> + along with this program. If not, see <https://www.gnu.org/licenses/> 
> + . 
> + On Debian systems, the complete text of the GNU General 
> + Public License version 2 can be found in 
"/usr/share/common-licenses/GPL-2". 
> diff --git a/meta/licenses/debian/GPL-3.0/default-copyright.tmpl 
b/meta/licenses/debian/GPL-3.0/default-copyright.tmpl 
> new file mode 100644 
> index 00000000..c2511481 
> --- /dev/null 
> +++ b/meta/licenses/debian/GPL-3.0/default-copyright.tmpl 
> @@ -0,0 +1,22 @@ 
> +Format: 
https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ 
> +Upstream-Name: ${BPN} 
> +Source: ${HOMEPAGE} 
> + 
> +Files: * 
> +Copyright: ${MAINTAINER} 
> +License: GPL-3.0 
> + 
> +License: GPL-3.0 
> + This program is free software: you can redistribute it and/or modify it 
under 
> + the terms of the GNU General Public License as published by the Free 
> + Software Foundation, version 3 of the License. 
> + . 
> + This program is distributed in the hope that it will be useful, but 
WITHOUT ANY 
> + WARRANTY; without even the implied warranty of MERCHANTABILITY or 
FITNESS FOR A 
> + PARTICULAR PURPOSE. See the GNU General Public License for more 
details. 
> + . 
> + You should have received a copy of the GNU General Public License along 
with 
> + this program. If not, see <http://www.gnu.org/licenses/>. 
> + . 
> + On Debian systems, the complete text of the GNU General Public License 
version 
> + 3 can be found in "/usr/share/common-licenses/GPL-3". 
> diff --git a/meta/licenses/debian/MIT/default-copyright.tmpl 
b/meta/licenses/debian/MIT/default-copyright.tmpl 
> new file mode 100644 
> index 00000000..2bced7f5 
> --- /dev/null 
> +++ b/meta/licenses/debian/MIT/default-copyright.tmpl 
> @@ -0,0 +1,26 @@ 
> +Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ 
> +Upstream-Name: ${BPN} 
> +Source: ${HOMEPAGE} 
> + 
> +Files: * 
> +Copyright: ${MAINTAINER} 
> +License: MIT 
> + 
> +License: MIT 
> + Permission is hereby granted, free of charge, to any person obtaining a 
copy 
> + of this software and associated documentation files (the "Software"), 
to deal 
> + in the Software without restriction, including without limitation the 
rights 
> + to use, copy, modify, merge, publish, distribute, sublicense, and/or 
sell 
> + copies of the Software, and to permit persons to whom the Software is 
> + furnished to do so, subject to the following conditions: 
> + . 
> + The above copyright notice and this permission notice shall be included 
in all 
> + copies or substantial portions of the Software. 
> + . 
> + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 
OR 
> + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 
MERCHANTABILITY, 
> + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 
THE 
> + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
> + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
FROM, 
> + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 
IN THE 
> + SOFTWARE. 

Jan

Patch

diff --git a/meta-isar/recipes-app/example-raw/example-raw_0.3.bb b/meta-isar/recipes-app/example-raw/example-raw_0.3.bb
index 35f4b3d9..1730431e 100644
--- a/meta-isar/recipes-app/example-raw/example-raw_0.3.bb
+++ b/meta-isar/recipes-app/example-raw/example-raw_0.3.bb
@@ -6,13 +6,16 @@ 
 DESCRIPTION = "Sample application for ISAR"
 MAINTAINER = "Your name here <you@domain.com>"
 DEBIAN_DEPENDS = "adduser, apt (>= 0.4.2)"
+HOMEPAGE = "<Home page of the recipe>"
+
+LICENSE = "MIT"
 
 SRC_URI = "file://README \
 	   file://postinst \
-	   file://rules \
-	   file://default-copyright"
+	   file://rules"
 
 inherit dpkg-raw
+inherit dpkg-helper-license
 
 do_install() {
 	bbnote "Creating ${PN} binary"
diff --git a/meta-isar/recipes-app/example-raw/files/default-copyright b/meta-isar/recipes-app/example-raw/files/default-copyright
deleted file mode 100644
index 3511cb51..00000000
--- a/meta-isar/recipes-app/example-raw/files/default-copyright
+++ /dev/null
@@ -1,22 +0,0 @@ 
-MIT License
-
-Copyright (c) 2017-2024, Siemens
-Copyright (c) 2024 ilbers GmbH
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
diff --git a/meta/classes/debianize.bbclass b/meta/classes/debianize.bbclass
index adb6cf2b..54a16260 100644
--- a/meta/classes/debianize.bbclass
+++ b/meta/classes/debianize.bbclass
@@ -120,9 +120,9 @@  deb_debianize() {
 	else
 		deb_create_rules
 	fi
-	# Add the copyright if unpacked sources does not contain copyright file
-	if [ ! -f ${S}/debian/copyright ] && [ -f ${WORKDIR}/default-copyright ]; then
-		install -v -m 644 ${WORKDIR}/default-copyright ${S}/debian/copyright
+	# Add the copyright if unpacked sources does not contain copyright file as well as the recipes configured the LICENSE
+	if [ ! -f ${S}/debian/copyright ] && [ -f ${WORKDIR}/${LICENSE}/default-copyright ]; then
+		 install -v -m 644 ${WORKDIR}/${LICENSE}/default-copyright ${S}/debian/copyright
 	fi
 	# prepend a changelog-entry unless an existing changelog file already
 	# contains an entry with CHANGELOG_V
diff --git a/meta/classes/dpkg-helper-license.bbclass b/meta/classes/dpkg-helper-license.bbclass
new file mode 100644
index 00000000..81e6d4e6
--- /dev/null
+++ b/meta/classes/dpkg-helper-license.bbclass
@@ -0,0 +1,27 @@ 
+# This software is a part of ISAR.
+# Copyright (C) 2024 Siemens AG
+#
+# SPDX-License-Identifier: MIT
+
+LICENSE ??= ""
+
+inherit template
+
+# Path to copyright template files
+FILESPATH:prepend := "${LAYERDIR_core}/licenses/debian:"
+
+# GPL-2.0 licensed packages
+SRC_URI:append = " ${@ 'file://GPL-2.0/default-copyright.tmpl' if d.getVar('LICENSE') == 'GPL-2.0' else '' }"
+TEMPLATE_FILES:append = "${@ ' GPL-2.0/default-copyright.tmpl' if d.getVar('LICENSE') == 'GPL-2.0' else '' }"
+
+# GPL-2.0+ licensed packages
+SRC_URI:append = " ${@ 'file://GPL-2.0+/default-copyright.tmpl' if d.getVar('LICENSE') == 'GPL-2.0+' else '' }"
+TEMPLATE_FILES:append = "${@ ' GPL-2.0+/default-copyright.tmpl' if d.getVar('LICENSE') == 'GPL-2.0+' else '' }"
+
+# GPL-3.0 licensed packages
+SRC_URI:append = " ${@ 'file://GPL-3.0/default-copyright.tmpl' if d.getVar('LICENSE') == 'GPL-3.0' else '' }"
+TEMPLATE_FILES:append = "${@ ' GPL-3.0/default-copyright.tmpl' if d.getVar('LICENSE') == 'GPL-3.0' else '' }"
+
+# MIT licensed packages
+SRC_URI:append = " ${@ 'file://MIT/default-copyright.tmpl' if d.getVar('LICENSE') == 'MIT' else '' }"
+TEMPLATE_FILES:append = "${@ ' MIT/default-copyright.tmpl' if d.getVar('LICENSE') == 'MIT' else '' }"
diff --git a/meta/licenses/debian/GPL-2.0+/default-copyright.tmpl b/meta/licenses/debian/GPL-2.0+/default-copyright.tmpl
new file mode 100644
index 00000000..5c6d27c5
--- /dev/null
+++ b/meta/licenses/debian/GPL-2.0+/default-copyright.tmpl
@@ -0,0 +1,24 @@ 
+Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
+Upstream-Name: ${BPN}
+Source: ${HOMEPAGE}
+
+Files: *
+Copyright: ${MAINTAINER}
+License: GPL-2.0+
+
+License: GPL-2.0+
+ This package is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+ .
+ This package is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ GNU General Public License for more details.
+ .
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>
+ .
+ On Debian systems, the complete text of the GNU General
+ Public License version 2 can be found in "/usr/share/common-licenses/GPL-2".
diff --git a/meta/licenses/debian/GPL-2.0/default-copyright.tmpl b/meta/licenses/debian/GPL-2.0/default-copyright.tmpl
new file mode 100644
index 00000000..223e5841
--- /dev/null
+++ b/meta/licenses/debian/GPL-2.0/default-copyright.tmpl
@@ -0,0 +1,23 @@ 
+Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
+Upstream-Name: ${BPN}
+Source: ${HOMEPAGE}
+
+Files: *
+Copyright: ${MAINTAINER}
+License: GPL-2.0
+
+License: GPL-2.0
+ This package is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License.
+ .
+ This package is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ GNU General Public License for more details.
+ .
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>
+ .
+ On Debian systems, the complete text of the GNU General
+ Public License version 2 can be found in "/usr/share/common-licenses/GPL-2".
diff --git a/meta/licenses/debian/GPL-3.0/default-copyright.tmpl b/meta/licenses/debian/GPL-3.0/default-copyright.tmpl
new file mode 100644
index 00000000..c2511481
--- /dev/null
+++ b/meta/licenses/debian/GPL-3.0/default-copyright.tmpl
@@ -0,0 +1,22 @@ 
+Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
+Upstream-Name: ${BPN}
+Source: ${HOMEPAGE}
+
+Files: *
+Copyright: ${MAINTAINER}
+License: GPL-3.0
+
+License: GPL-3.0
+ This program is free software: you can redistribute it and/or modify  it under
+ the terms of the GNU General Public License as published by the Free
+ Software Foundation, version 3 of the License.
+ .
+ This program is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ PARTICULAR PURPOSE.  See the GNU General Public License for more details.
+ .
+ You should have received a copy of the GNU General Public License along with
+ this program.  If not, see <http://www.gnu.org/licenses/>.
+ .
+ On Debian systems, the complete text of the GNU General Public License version
+ 3 can be found in "/usr/share/common-licenses/GPL-3".
diff --git a/meta/licenses/debian/MIT/default-copyright.tmpl b/meta/licenses/debian/MIT/default-copyright.tmpl
new file mode 100644
index 00000000..2bced7f5
--- /dev/null
+++ b/meta/licenses/debian/MIT/default-copyright.tmpl
@@ -0,0 +1,26 @@ 
+Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
+Upstream-Name: ${BPN}
+Source: ${HOMEPAGE}
+
+Files: *
+Copyright: ${MAINTAINER}
+License: MIT
+
+License: MIT
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to deal
+ in the Software without restriction, including without limitation the rights
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+ .
+ The above copyright notice and this permission notice shall be included in all
+ copies or substantial portions of the Software.
+ .
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ SOFTWARE.