Difference between revisions of "Free Software Directory:Participate/Script aid"

From Free Software Directory
Jump to: navigation, search
(Remove POSIX compliance, use extended regular expressions, improve patterns, note need to specify .CSV language as English)
(Improve copyright and license detection.)
Line 63: Line 63:
 
     -printf ',' \
 
     -printf ',' \
 
     -exec sh -c 'grep -Eiq \
 
     -exec sh -c 'grep -Eiq \
      "(©|\(c\)|ac?ord|agree|allow|as[[:space:]]+is[^[:alnum:]]|cc|condi|copy(right|left|fai?r|m[ei])|d[ei]re(it|ch)o|droit|eula|exclusiv|fdl|forbid|garant|[al]?gpl|law|le[iy]|liab|licen|mar(k|ca)|not[ií]c(e|ia)|notifica|patent|permi|proh?ib|respons[aái]b|right|termo?s?|trade|transfer|warrant)" \
+
      "(©|[[:space:]]+((agreement|a(co|cue)rdo)|(allowed|permitid[ao])|as[[:space:]]+is[^[:alnum:]]|condi(tions?|ci(ón|ones)|ç(ão|ões))|copy(right|left|fai?r|m[ei])|eula|exclusiv[aeo]|fdl|(forbid(s|den)?|pro(hibited|h?ibid[ao]))|[al]?gpl|l(aw|e[iy])|(liab(le|ilit(y|ies))|respons(ib(le|ilit(y|ies))|ab(le|ilidad(es?)?)|áve(l|is)))|licen([cs]e|(ç|ci)a)|(not(ice|[ií]cia|ifica(tion|ção|ción)))|patente?|(right|d(erech|ireit)o|droit)|t(erms?|érminos?|ermos?)|trade[[:space:]]+(mark|secret)|transfer|(gu?arant|warrant)))" \
 
      "$0"
 
      "$0"
 
  grep_exit_status=$?
 
  grep_exit_status=$?

Revision as of 15:25, 28 April 2020

Purpose

This script aims to help contributors on finding things that might be needed to consider during evaluation of the project/software.

For example, it lists all the MIME/media types of files in the current directory, so that one can find cases of files without complete and corresponding source and also find JavaScript files to look or insert GNU LibreJS syntax.

It also scans files for words related to DOM Level 0 event handlers, so that the contributor can also evaluate if there is need to add GNU LibreJS syntax.

The output is in CSV format. You can use GNU Awk to parse or query such files, before doing so, set FPAT to ([^,]*)|(\"[^\"]+\") and RS to \r\n, This variable setting was based on the related section in the GNU Awk User's Guide and on Awk's Texinfo/Info page.

You're welcome to contribute to this script and add your name and contact information to the copyright notice of the script.

Usage

Best if you take the complete corresponding source of the project being evaluated (e.g.: when using git clone, you can accomplish this using the --recursive option.

git clone --recursive [Some git repository.]
cd [Directory created by git]
[Script aid.] > [Desired text file to store output.]; printf '\a'

printf '\a' can be replaced by a command to play an audio file of your choice.

Now leave the script to do its work and wait for the sound clue to continue working on the evaluation.

Notes

  • The script always takes the current working directory as basis of operation.
  • When importing, make sure that the selected language is English, so that "TRUE" and "FALSE" can be translated as correct bolean representation in your language of choice.
  • Be aware of false-positives.
  • Due to our lack of knowledge on various spoken languages, some things might not be found by the script.

Script

#!/bin/sh

# FSD Participation Aid: Helps user evaluate entries for the Free Software Directory.
# Copyright (C) 2016, 2018, 2020  Adonay "adfeno" Felipe Nogueira <https://libreplanet.org/wiki/User:Adfeno> <adfeno@hyperbola.info>

# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.

# 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
# Affero General Public License for more details.

# You should have received a copy of the GNU Affero General Public
# License along with this program.  If not, see
# <https://www.gnu.org/licenses/>.

printf '"Path","MIME","Charset","Copyright or license","Script tag or DOM Level 0","Notes"\r\n'
find "." ! \( -name '.' -or \( -type d -or -type l \) \) \
     -exec sh -c 'file -hi "$0" \
     	      	  | sed '\''{ s/^\.\//"/g
		    	      s/: /",/g
			      s/; charset=/,/g }'\'' \
		  | tr -d "\n"' '{}' \; \
     -printf ',' \
     -exec sh -c 'grep -Eiq \
		       "(©|[[:space:]]+((agreement|a(co|cue)rdo)|(allowed|permitid[ao])|as[[:space:]]+is[^[:alnum:]]|condi(tions?|ci(ón|ones)|ç(ão|ões))|copy(right|left|fai?r|m[ei])|eula|exclusiv[aeo]|fdl|(forbid(s|den)?|pro(hibited|h?ibid[ao]))|[al]?gpl|l(aw|e[iy])|(liab(le|ilit(y|ies))|respons(ib(le|ilit(y|ies))|ab(le|ilidad(es?)?)|áve(l|is)))|licen([cs]e|(ç|ci)a)|(not(ice|[ií]cia|ifica(tion|ção|ción)))|patente?|(right|d(erech|ireit)o|droit)|t(erms?|érminos?|ermos?)|trade[[:space:]]+(mark|secret)|transfer|(gu?arant|warrant)))" \
		       "$0"
		  grep_exit_status=$?
		  if [ $grep_exit_status -eq 0 ]; then
		     printf "TRUE"
		  elif [ $grep_exit_status -eq 1 ]; then
		     printf "FALSE"
		  fi' '{}' \; \
     -printf ',' \
     -exec sh -c 'grep -Eiq \
     	      	       "(script|addEventListener|(after|before|on)(abort|autocomplete(error)?|blur|cancel|canplay(through)?|(cue|duration|hash|language|rate|readystate|volume)?change|(db)?click|close|contextmenu|drag(end|enter|exit|leave|over|start)|drop|emptied|ended|error|focus|input|invalid|key(down|press|up)|(un)?load(ed(meta)?data)?|start|message|mouse(down|enter|leave|move|out|over|up|wheel)|(off|on)line|page(hide|show)|pause|play(ing)?|popstate|print|progress|reset|resize|scroll|seek(ed|ing)|select|show|sort|stalled|storage|submit|suspend|timeupdate|toggle|waiting))" \
     	      	       "$0"
		  grep_exit_status=$?
		  if [ $grep_exit_status -eq 0 ]; then
		     printf "TRUE"
		  elif [ $grep_exit_status -eq 1 ]; then
		     printf "FALSE"
		  fi' '{}' \; \
     -printf ',' \
     -printf '\r\n'


Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the page “GNU Free Documentation License”.

The copyright and license notices on this page only apply to the text on this page. Any software or copyright-licenses or other similar notices described in this text has its own copyright notice and license, which can usually be found in the distribution or license text itself.