Skip to contentSkip to conversation

license.bbclass: remove existing license.manifest before appending new data

PATCH Applied Eric Bénard 3 participants 5 messages Mar 29, 2012 – Mar 30, 2012

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 license.bbclass: remove existing license.manifest before appending new data

without this fix, we append license each time we build again the same image, ending with a large not up to date file.

---
 meta/classes/license.bbclass |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
meta/classes/license.bbclass +4 -0
index 394a6d4..c85233c 100644
@@ -79,6 +79,10 @@ license_create_manifest() {
 	# Get list of installed packages
 	list_installed_packages | grep -v "locale" |sort > ${LICENSE_DIRECTORY}/${IMAGE_NAME}/package.manifest
 	INSTALLED_PKGS=`cat ${LICENSE_DIRECTORY}/${IMAGE_NAME}/package.manifest`
+	# remove existing license.manifest file
+	if [ -f ${LICENSE_DIRECTORY}/${IMAGE_NAME}/license.manifest ]; then
+		rm ${LICENSE_DIRECTORY}/${IMAGE_NAME}/license.manifest
+	fi
 	# list of installed packages is broken for deb
 	for pkg in ${INSTALLED_PKGS}; do
 		# not the best way to do this but licenses are not arch dependant iirc
Signature · 1 line
1.7.7.6
#1 lore raw
Quoted 7 lines · Eric Bénard

without this fix, we append license each time we build again the same image, ending with a large not up to date file.

---
 meta/classes/license.bbclass |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

Merged to master, thanks.

Richard

#2 lore raw
In reply to Eric Bénard
Quoted 20 lines · Eric Bénard

without this fix, we append license each time we build again the same image, ending with a large not up to date file.

---
 meta/classes/license.bbclass |    4 ++++

 1 files changed, 4 insertions(+), 0 deletions(-)
meta/classes/license.bbclass +0 -0
index 394a6d4..c85233c 100644
@@ -79,6 +79,10 @@ license_create_manifest() {
        # Get list of installed packages

       list_installed_packages | grep -v "locale" |sort > ${LICENSE_DIRECTORY}/${IMAGE_NAME}/package.manifest INSTALLED_PKGS=cat ${LICENSE_DIRECTORY}/${IMAGE_NAME}/package.manifest
+       # remove existing license.manifest file
+       if [ -f ${LICENSE_DIRECTORY}/${IMAGE_NAME}/license.manifest ]; then
+               rm ${LICENSE_DIRECTORY}/${IMAGE_NAME}/license.manifest
+       fi

Quoted 1 line
       # list of installed packages is broken for deb

Probably not a concern in this particular case, but in general you should avoid this sort of construct, as it's racy.

Signature · 1 line
Christopher Larson
#3 lore raw
Quoted 9 lines · Chris Larson
Quoted 8 lines · Eric Bénard

without this fix, we append license each time we build again the same image, ending with a large not up to date file.

---
 meta/classes/license.bbclass |    4 ++++

 1 files changed, 4 insertions(+), 0 deletions(-)
Quoted 16 lines
Quoted 12 lines
meta/classes/license.bbclass +0 -0
index 394a6d4..c85233c 100644
@@ -79,6 +79,10 @@ license_create_manifest() {
        # Get list of installed packages

       list_installed_packages | grep -v "locale" |sort > ${LICENSE_DIRECTORY}/${IMAGE_NAME}/package.manifest INSTALLED_PKGS=cat ${LICENSE_DIRECTORY}/${IMAGE_NAME}/package.manifest
+       # remove existing license.manifest file
+       if [ -f ${LICENSE_DIRECTORY}/${IMAGE_NAME}/license.manifest ]; then
+               rm ${LICENSE_DIRECTORY}/${IMAGE_NAME}/license.manifest
+       fi

Quoted 1 line
       # list of installed packages is broken for deb

Probably not a concern in this particular case, but in general you should avoid this sort of construct, as it's racy.

ok, what would be the right way to do that to avoid the race problem ?

Eric

Signature · 1 line
http://eukrea.com/en/news/104-2012
#4 lore raw
Quoted 29 lines · Eric Bénard
Quoted 9 lines · Chris Larson
Quoted 8 lines · Eric Bénard

without this fix, we append license each time we build again the same image, ending with a large not up to date file.

---
 meta/classes/license.bbclass |    4 ++++

 1 files changed, 4 insertions(+), 0 deletions(-)
Quoted 16 lines
Quoted 12 lines
meta/classes/license.bbclass +0 -0
index 394a6d4..c85233c 100644
@@ -79,6 +79,10 @@ license_create_manifest() {
        # Get list of installed packages

       list_installed_packages | grep -v "locale" |sort > ${LICENSE_DIRECTORY}/${IMAGE_NAME}/package.manifest INSTALLED_PKGS=cat ${LICENSE_DIRECTORY}/${IMAGE_NAME}/package.manifest
+       # remove existing license.manifest file
+       if [ -f ${LICENSE_DIRECTORY}/${IMAGE_NAME}/license.manifest ]; then
+               rm ${LICENSE_DIRECTORY}/${IMAGE_NAME}/license.manifest
+       fi

Quoted 1 line
       # list of installed packages is broken for deb

Probably not a concern in this particular case, but in general you should avoid this sort of construct, as it's racy.

Quoted 1 line

ok, what would be the right way to do that to avoid the race problem ?

Generally speaking rather than doing "if this, then do that" particularly with the filesystem, just do it and handle any errors. In this case, rm -f, which exits silently if the file was already removed.

Signature · 1 line
Christopher Larson