Bug 10323

Summary: Sample script to create source release for specific licences fails
Product: [Documentation] Development Manual Reporter: Henry Bruce <henry.bruce>
Component: developmentAssignee: Henry Bruce <henry.bruce>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: Medium CC: bluelightning, pidge, srifenbark
Version: 2.1.2   
Target Milestone: 2.3 M3   
Hardware: x86   
OS: Multiple   
Whiteboard: 14 Mar 2017: Marked doc flag to "done"
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: Done (doc changes complete)
Attachments:
Description Flags
License specific source archive creation script none

Description Henry Bruce 2016-09-22 20:19:02 UTC
See http://www.yoctoproject.org/docs/2.1/dev-manual/dev-manual.html#providing-the-source-code

There is a sample script to create a subset of source release tarballs based on licence. 

$ cd poky/build/tmp/deploy/sources
$ mkdir ~/gpl_source_release
$ for dir in */*GPL*; do cp -r $dir ~/gpl_source_release; done

This fails as there are no files matching the regex */*GPL*. Script should be looking for packages with specified licences in tmp/deploy/licences and then using package name to copy folder from tmp/deploy/sources
Comment 1 Scott Rifenbark 2016-09-23 15:54:56 UTC
Hi, 

Can you put the lines in for the script that would work?  I am not quite sure how they need to be.  

Thanks, 
Scott
Comment 2 Henry Bruce 2016-09-23 18:15:55 UTC
I hacked this together. There will be better solutions...

# Script to archive a subset of packages matching specific licence(s)
# Source and license files are copied into subfolders of package folder
# Must be run from build folder
#!/bin/bash
src_release_dir="source-release"
mkdir -p $src_release_dir
for a in tmp/deploy/sources/*; do
   for d in $a/*; do
      # Get package name from path
      p=`basename $d`
      p=${p%-*}
      p=${p%-*}
      # Only archive GPL packages (update *GPL* regex for your license check)
      numfiles=`ls tmp/deploy/licenses/$p/*GPL* 2> /dev/null | wc -l`
      if [ $numfiles -gt 1 ]; then
         echo Archiving $p
         mkdir -p $src_release_dir/$p/source
         cp $d/* $src_release_dir/$p/source 2> /dev/null
         mkdir -p $src_release_dir/$p/license
         cp tmp/deploy/licenses/$p/* source-release/$p/license 2> /dev/null
      fi
   done
done
Comment 3 Scott Rifenbark 2016-09-26 15:51:20 UTC
Hi, 

Thanks for the bits... So I changed the introductory wording to reflect that the example is a script and then substituted the three-line example with yours.  See http://www.yoctoproject.org/docs/2.2/dev-manual/dev-manual.html#providing-the-source-code and let me know if this works.

Thanks, 
Scott
Comment 4 Henry Bruce 2016-09-26 16:46:05 UTC
Thanks for quick turnaround on this.

I made an error in
cp tmp/deploy/licenses/$p/* source-release/$p/license 2> /dev/null

Should read
cp tmp/deploy/licenses/$p/* $src_release_dir/$p/license 2> /dev/null


I'd like sign-off by Paul and have also added Beth to CC list.
Comment 5 Scott Rifenbark 2016-09-26 16:52:47 UTC
Henry, 

Got it.  See http://www.yoctoproject.org/docs/2.2/dev-manual/dev-manual.html#providing-the-source-code.  We will wait for other feedback before changing bug status. 

Thanks, 
Scott
Comment 6 Paul Eggleton 2016-10-14 03:28:03 UTC
It's a little ugly but I think that's what we can go with for 2.2.
Comment 7 Scott Rifenbark 2016-10-14 19:14:15 UTC
Because it is ugly, I am going to set the target for 2.3.  We beautify it then.

Thanks
Scott
Comment 8 Scott Rifenbark 2016-11-08 17:39:07 UTC
Hi, 

Now that 2.2 is out, what can be done to make this solution less "ugly"?

Scott
Comment 9 Stephen K Jolley 2017-01-12 16:31:35 UTC
Please review comments
Comment 10 Henry Bruce 2017-01-12 17:58:37 UTC
Not sure what to do. This script is no longer broken and is now functional but ugly. I'll to Paul for guidance in cleaning it up. Or maybe we move from docs to tips and tricks?
Comment 11 Scott Rifenbark 2017-01-19 23:57:11 UTC
Ok - so my suggestion is to "RESOLVE" this one.  If we want a prettier one then file a new bug and we will go from there.  Since you own the bug Henry... I will let you make the call and set to RESOLVED and turn the doc flag to "done."

Thanks,
Scott
Comment 12 Henry Bruce 2017-03-13 20:53:31 UTC
Created attachment 3647 [details]
License specific source archive creation script
Comment 13 Henry Bruce 2017-03-13 20:55:08 UTC
I re-tested script and added a test to check that build had been run with source archiver enabled.
Comment 14 Scott Rifenbark 2017-03-14 15:58:54 UTC
Hi, 

I don't own this bug but it has been set to RESOLVED based on some doc fixes admittedly ugly but functional.  I have set the doc flag to "done".

Scott