Skip to contentSkip to conversation

core/legal: support multi-version packages

PATCH New Yann E. MORIN 3 participants 5 messages Jul 16, 2017 – Jul 29, 2017

lore
Share & tools
lore
#0 lore raw

v2 cover core/legal: support multi-version packages

Hello All!

This small series fixes our legal-info license check for packages that have different versions and for which the licensing information has changed between the versions, but the license files are named the same.

This is the case for Qt5 for example, where some license files for 5.6 are different than for 5.8, but are named the same.

Also fix checking the hashes of license files for host packages.

Changes v1 -> v2:
- fallback to the main hash file is the per-version file does not exist,
- fix checking hashes of host license files

Regards,
Yann E. MORIN.

The following changes since commit 9a0a0a976bc1094719556065ab5e982c6ca27563

arch/mips: add support for MIPS32 FP mode (2017-07-16 16:45:22 +0200)

are available in the git repository at:

git://git.buildroot.org/~ymorin/git/buildroot.git

for you to fetch changes up to 868f6cd4d02b61525edf78c8a11afd2655be3425

core/legal-info: use hash file from version sub-dir (2017-07-16 19:20:47 +0200)

----------------------------------------------------------------
Yann E. MORIN (2):
core/legal-info: properly check hashes of license files for host packages core/legal-info: use hash file from version sub-dir

 docs/manual/adding-packages-directory.txt | 4 +++-
 package/pkg-generic.mk                    | 2 +-
 package/pkg-utils.mk                      | 9 ++++++---
 3 files changed, 10 insertions(+), 5 deletions(-)
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
#1 lore raw

PATCH v2 1/2 core/legal-info: properly check hashes of license files for host packages

When called for a host package, we currently miss the hash file, because it is named after the target package.

Fix that by using the package raw-name.

Cc Thomas Petazzoni <[email protected]>
Cc Luca Ceresoli <[email protected]>
---
 package/pkg-generic.mk | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
package/pkg-generic.mk +1 -1
index 2916a7bbad..e4328be4ca 100644
@@ -851,7 +851,7 @@ ifneq ($$(call qstrip,$$($(2)_SOURCE)),)
 ifeq ($$(call qstrip,$$($(2)_LICENSE_FILES)),)
 	@$$(call legal-warning-pkg,$$($(2)_RAW_BASE_NAME),cannot save license ($(2)_LICENSE_FILES not defined))
 else
-	@$$(foreach F,$$($(2)_LICENSE_FILES),$$(call legal-license-file,$$($(2)_NAME),$$($(2)_RAW_BASE_NAME),$$($(2)_PKGDIR),$$(F),$$($(2)_DIR)/$$(F),$$(call UPPERCASE,$(4)))$$(sep))
+	@$$(foreach F,$$($(2)_LICENSE_FILES),$$(call legal-license-file,$$($(2)_RAWNAME),$$($(2)_RAW_BASE_NAME),$$($(2)_PKGDIR),$$(F),$$($(2)_DIR)/$$(F),$$(call UPPERCASE,$(4)))$$(sep))
 endif # license files
 
 ifeq ($$($(2)_SITE_METHOD),local)
Signature · 1 line
2.11.0
#2 lore raw

PATCH v2 1/2 core/legal-info: properly check hashes of license files for host packages

Hello,

Quoted 11 lines · Yann E. MORIN

When called for a host package, we currently miss the hash file, because it is named after the target package.

Fix that by using the package raw-name.

Cc Thomas Petazzoni <[email protected]>
Cc Luca Ceresoli <[email protected]>
---
 package/pkg-generic.mk | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Both patches applied. Thanks!

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#3 lore raw

PATCH v2 2/2 core/legal-info: use hash file from version sub-dir

In reply to Yann E. MORIN

When we have multiple versions for a package, and the licensing terms depend on the version actually selected (e.g. like Qt5), storing the hashes for those license files in the .hash file is broken: the infra will ensure that all hashes for a file do match, which would not be the case here.

We fix that by first looking for a hash file in the version sub-dir first, and if that does not exist, then we use the main hash file.

Drop the useless intermediate variable 'ret'.

Update the documentation accordingly.

Cc Joshua Henderson <[email protected]>
Cc Thomas Petazzoni <[email protected]>
Cc Luca Ceresoli <[email protected]>

---
Changes v1 -> v2:
- fallback to the main hash file iof the version-specific one does not exist (Thomas, Peter, Joshua, Luca)

---
 docs/manual/adding-packages-directory.txt | 4 +++-
 package/pkg-utils.mk                      | 9 ++++++---
 2 files changed, 9 insertions(+), 4 deletions(-)
docs/manual/adding-packages-directory.txt +3 -1
index 804946c504..809cc97389 100644
@@ -482,7 +482,9 @@ this in a comment line above the hashes.
 
 .Note
 The hashes for license files are used to detect a license change when a
-package version is bumped.
+package version is bumped. For a package with multiple versions (like Qt5),
+create the hash file in a subdirectory +<packageversion>+ of that package
+(see also xref:patch-apply-order[]).
 
 .Note
 The number of spaces does not matter, so one can use spaces (or tabs) to
package/pkg-utils.mk +6 -3
index accf48c464..c3acc22b17 100644
@@ -86,9 +86,12 @@ endef
 define legal-license-file # pkgname, pkgname-pkgver, pkgdir, filename, file-fullpath, {HOST|TARGET}
 	mkdir -p $(LICENSE_FILES_DIR_$(6))/$(2)/$(dir $(4)) && \
 	{ \
-		support/download/check-hash $(3)/$(1).hash $(5) $(4); \
-		ret=$${?}; \
-		case $${ret} in (0|3) ;; (*) exit 1;; esac; \
+		if [ -f $(3)/$($(PKG)_VERSION)/$(1).hash ]; then \
+			support/download/check-hash $(3)/$($(PKG)_VERSION)/$(1).hash $(5) $(4); \
+		else \
+			support/download/check-hash $(3)/$(1).hash $(5) $(4); \
+		fi; \
+		case $${?} in (0|3) ;; (*) exit 1;; esac; \
 	} && \
 	cp $(5) $(LICENSE_FILES_DIR_$(6))/$(2)/$(4)
 endef
Signature · 1 line
2.11.0
#4 lore raw

PATCH v2 2/2 core/legal-info: use hash file from version sub-dir

Yann, All,

Quoted 54 lines · Yann E. MORIN

When we have multiple versions for a package, and the licensing terms depend on the version actually selected (e.g. like Qt5), storing the hashes for those license files in the .hash file is broken: the infra will ensure that all hashes for a file do match, which would not be the case here.

We fix that by first looking for a hash file in the version sub-dir first, and if that does not exist, then we use the main hash file.

Drop the useless intermediate variable 'ret'.

Update the documentation accordingly.

Cc Joshua Henderson <[email protected]>
Cc Thomas Petazzoni <[email protected]>
Cc Luca Ceresoli <[email protected]>

---
Changes v1 -> v2:
- fallback to the main hash file iof the version-specific one does not exist (Thomas, Peter, Joshua, Luca)

---
 docs/manual/adding-packages-directory.txt | 4 +++-
 package/pkg-utils.mk                      | 9 ++++++---
 2 files changed, 9 insertions(+), 4 deletions(-)
docs/manual/adding-packages-directory.txt +3 -1
index 804946c504..809cc97389 100644
@@ -482,7 +482,9 @@ this in a comment line above the hashes.
 
 .Note
 The hashes for license files are used to detect a license change when a
-package version is bumped.
+package version is bumped. For a package with multiple versions (like Qt5),
+create the hash file in a subdirectory +<packageversion>+ of that package
+(see also xref:patch-apply-order[]).
 
 .Note
 The number of spaces does not matter, so one can use spaces (or tabs) to
package/pkg-utils.mk +0 -2
index accf48c464..c3acc22b17 100644
@@ -86,9 +86,12 @@ endef
 define legal-license-file # pkgname, pkgname-pkgver, pkgdir, filename, file-fullpath, {HOST|TARGET}
 	mkdir -p $(LICENSE_FILES_DIR_$(6))/$(2)/$(dir $(4)) && \
 	{ \
-		support/download/check-hash $(3)/$(1).hash $(5) $(4); \
-		ret=$${?}; \

package/pkg-utils.mk endef · line 97

Quoted 10 lines
package/pkg-utils.mk +6 -1
-		case $${ret} in (0|3) ;; (*) exit 1;; esac; \
+		if [ -f $(3)/$($(PKG)_VERSION)/$(1).hash ]; then \
+			support/download/check-hash $(3)/$($(PKG)_VERSION)/$(1).hash $(5) $(4); \
+		else \
+			support/download/check-hash $(3)/$(1).hash $(5) $(4); \
+		fi; \
+		case $${?} in (0|3) ;; (*) exit 1;; esac; \
 	} && \
 	cp $(5) $(LICENSE_FILES_DIR_$(6))/$(2)/$(4)
 endef

I took it for a test spin and this looks good to me. I also uncovered a separate, but related question [1], with the exception case that qt5 is.

[1] https://patchwork.ozlabs.org/patch/789653/

Josh