All of lore.kernel.org
 help / color / mirror / Atom feed
From: Joshua Lock <josh@linux.intel.com>
To: poky@yoctoproject.org
Subject: Re: [PATCH 2/2] distrodata.bbclass: Add checklicense task
Date: Fri, 13 May 2011 10:13:34 -0700	[thread overview]
Message-ID: <1305306814.2023.19.camel@scimitar> (raw)
In-Reply-To: <748c06bb7ff87fb396298084a35cb0eb45a088c1.1305269419.git.lei.mei@intel.com>

On Thu, 2011-01-13 at 15:04 +0800, Mei Lei wrote:
> From: Mei Lei <lei.mei@intel.com>
> 
> This task will check which license text is missing

Can you flesh out this commit log some please? Why is this task useful?
When should it be used? Etc.

Code style comments in line below, thanks!

> 
> Signed-off-by: Mei Lei <lei.mei@intel.com>
> ---
>  meta/classes/distrodata.bbclass |   88 ++++++++++++++++++++++++---------------
>  1 files changed, 54 insertions(+), 34 deletions(-)
> 
> diff --git a/meta/classes/distrodata.bbclass b/meta/classes/distrodata.bbclass
> index 905dad7..58a2cf7 100644
> --- a/meta/classes/distrodata.bbclass
> +++ b/meta/classes/distrodata.bbclass
> @@ -4,18 +4,8 @@ addhandler distro_eventhandler
>  python distro_eventhandler() {
>  
>      if bb.event.getName(e) == "BuildStarted":
> -	"""initialize log files."""
> -	logpath = bb.data.getVar('LOG_DIR', e.data, 1)
> -	bb.utils.mkdirhier(logpath)
> -	logfile = os.path.join(logpath, "distrodata.%s.csv" % bb.data.getVar('DATETIME', e.data, 1))
> -	if not os.path.exists(logfile):
> -		slogfile = os.path.join(logpath, "distrodata.csv")
> -		if os.path.exists(slogfile):
> -			os.remove(slogfile)
> -		os.system("touch %s" % logfile)
> -		os.symlink(logfile, slogfile)
> -		bb.data.setVar('LOG_FILE', logfile, e.data)
> -
> +	import oe.distro_check as dc
> +	logfile = dc.create_log_file(e.data,"distrodata.csv")
>  	lf = bb.utils.lockfile(logfile + ".lock")
>  	f = open(logfile, "a")
>  	f.write("Package,Description,Owner,License,ChkSum,Status,VerMatch,Version,Upsteam,Non-Update,Reason,Recipe Status\n")
> @@ -211,17 +201,8 @@ do_distrodataall() {
>  addhandler checkpkg_eventhandler
>  python checkpkg_eventhandler() {
>      if bb.event.getName(e) == "BuildStarted":
> -	"""initialize log files."""
> -	logpath = bb.data.getVar('LOG_DIR', e.data, 1)
> -	bb.utils.mkdirhier(logpath)
> -	logfile = os.path.join(logpath, "checkpkg.%s.csv" % bb.data.getVar('DATETIME', e.data, 1))
> -	if not os.path.exists(logfile):
> -		slogfile = os.path.join(logpath, "checkpkg.csv")
> -		if os.path.exists(slogfile):
> -			os.remove(slogfile)
> -		os.system("touch %s" % logfile)
> -		os.symlink(logfile, slogfile)
> -		bb.data.setVar('LOG_FILE', logfile, e.data)
> +	import oe.distro_check as dc
> +	logfile = dc.create_log_file(e.data,"checkpkg.csv")
>  
>  	lf = bb.utils.lockfile(logfile + ".lock")
>  	f = open(logfile, "a")
> @@ -662,17 +643,8 @@ python check_eventhandler() {
>          distro_check_dir = os.path.join(tmpdir, "distro_check")
>          datetime = bb.data.getVar('DATETIME', e.data, 1)
>          """initialize log files."""
> -        logpath = bb.data.getVar('LOG_DIR', e.data, 1)
> -        bb.utils.mkdirhier(logpath)
> -        logfile = os.path.join(logpath, "distrocheck.%s.csv" % bb.data.getVar('DATETIME', e.data, 1))
> -        if not os.path.exists(logfile):
> -                slogfile = os.path.join(logpath, "distrocheck.csv")
> -                if os.path.exists(slogfile):
> -                        os.remove(slogfile)
> -                os.system("touch %s" % logfile)
> -                os.symlink(logfile, slogfile)
> -                bb.data.setVar('LOG_FILE', logfile, e.data)
> -
> +        import oe.distro_check as dc
> +        logfile = dc.create_log_file(e.data,"distrocheck.csv")
>      return
>  }
>  
> @@ -701,3 +673,51 @@ do_distro_checkall[nostamp] = "1"
>  do_distro_checkall() {
>  	:
>  }
> +##Check Missing License Text
> +addhandler checklicense_eventhandler
> +python checklicense_eventhandler() {
> +    if bb.event.getName(e) == "BuildStarted":
> +        """initialize log files."""
> +        import oe.distro_check as dc
> +        logfile = dc.create_log_file(e.data,"missinglicense.csv")
Whitespace: logfile = dc.create_log_file(e.data, "missinglicense.csv")
> +        lf = bb.utils.lockfile(logfile + ".lock")
Personally I prefer to use string formatting rather for this sort of
thing:
+        lf = bb.utils.lockfile("%s.lock" % logfile)
> +        f = open(logfile, "a")
> +        f.write("Package\tLicense\tMissingLicense\n")
> +        f.close()
> +        bb.utils.unlockfile(lf)
> +    return
> +}
> +
> +addtask checklicense
> +do_checklicense[nostamp] = "1"
> +python do_checklicense() {
> +    import os
> +    import bb
> +    import shutil
> +    logpath = bb.data.getVar('LOG_DIR', d, 1)
> +    bb.utils.mkdirhier(logpath)
> +    pn = bb.data.getVar('PN',d,1)

pn = bb.data.getVar('PN', d, True)

Please try and maintain whitespace style and use boolean values where
appropriate.

> +    logfile = os.path.join(logpath, "missinglicense.csv")
> +    generic_directory = bb.data.getVar('COMMON_LICENSE_DIR', d, True)
> +    license_types = bb.data.getVar('LICENSE', d, True)
> +    for license_type in ((license_types.replace('+', '').replace('|', '&')
> +                          .replace('(', '').replace(')', '').replace(';', '')
> +                          .replace(',', '').replace(" ", "").split("&"))):
> +        if not os.path.isfile(os.path.join(generic_directory, license_type)):
> +            lf = bb.utils.lockfile(logfile + ".lock")
Maybe use string formatters here too:
+            lf = bb.utils.lockfile("%s.lock" % logfile)
> +            f = open(logfile,"a") 
> +            f.write("%s\t%s\t%s\n" % \
> +        		(pn,license_types,license_type))
> +            f.close()
> +            bb.utils.unlockfile(lf)
> +    return
> +}
> +
> +addtask checklicenseall after do_checklicense
> +do_checklicenseall[recrdeptask] = "do_checklicense"
> +do_checklicenseall[nostamp] = "1"
> +do_checklicenseall() {
> +	:
> +}
> +
> +

-- 
Joshua Lock
        Yocto Build System Monkey
        Intel Open Source Technology Centre



  reply	other threads:[~2011-05-13 17:13 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-13  6:59 [PATCH 0/2] Add checklicense task to get missing license text Mei Lei
2011-05-13  6:59 ` [PATCH 1/2] distro_check.py: Add a new function to reduce the repeat code Mei Lei
2011-05-13 17:13   ` Joshua Lock
2011-05-13  6:59 ` [PATCH 2/2] distrodata.bbclass: Add checklicense task Mei Lei
2011-05-13 17:13   ` Joshua Lock [this message]
2011-05-16 12:30     ` Mei, Lei

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1305306814.2023.19.camel@scimitar \
    --to=josh@linux.intel.com \
    --cc=poky@yoctoproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.