summaryrefslogtreecommitdiffstats
path: root/contrib
diff options
context:
space:
mode:
authorTudor Florea <tudor.florea@enea.com>2015-10-08 22:51:41 +0200
committerTudor Florea <tudor.florea@enea.com>2015-10-08 22:51:41 +0200
commit1219bf8a90a7bf8cd3a5363551ef635d51e8fc8e (patch)
treea21a5fc103bb3bd65ecd85ed22be5228fc54e447 /contrib
downloadmeta-openembedded-1219bf8a90a7bf8cd3a5363551ef635d51e8fc8e.tar.gz
initial commit for Enea Linux 5.0 arm
Signed-off-by: Tudor Florea <tudor.florea@enea.com>
Diffstat (limited to 'contrib')
-rwxr-xr-xcontrib/oe-stylize.py406
-rwxr-xr-xcontrib/pw-am.sh15
-rwxr-xr-xcontrib/tesseract-langs.sh92
3 files changed, 513 insertions, 0 deletions
diff --git a/contrib/oe-stylize.py b/contrib/oe-stylize.py
new file mode 100755
index 000000000..712557d4f
--- /dev/null
+++ b/contrib/oe-stylize.py
@@ -0,0 +1,406 @@
1#!/usr/bin/env python
2
3"""\
4Sanitize a bitbake file following the OpenEmbedded style guidelines,
5see http://openembedded.org/wiki/StyleGuide
6
7(C) 2006 Cyril Romain <cyril.romain@gmail.com>
8MIT license
9
10TODO:
11 - add the others OpenEmbedded variables commonly used:
12 - parse command arguments and print usage on misuse
13 . prevent giving more than one .bb file in arguments
14 - write result to a file
15 - backup the original .bb file
16 - make a diff and ask confirmation for patching ?
17 - do not use startswith only:
18 /!\ startswith('SOMETHING') is not taken into account due to the previous startswith('S').
19 - count rule breaks and displays them in the order frequence
20"""
21
22import fileinput
23import string
24import re
25
26__author__ = "Cyril Romain <cyril.romain@gmail.com>"
27__version__ = "$Revision: 0.5 $"
28
29# The standard set of variables often found in .bb files in the preferred order
30OE_vars = [
31 'SUMMARY',
32 'DESCRIPTION',
33 'AUTHOR',
34 'HOMEPAGE',
35 'SECTION',
36 'LICENSE',
37 'LIC_FILES_CHKSUM',
38 'DEPENDS',
39 'PROVIDES',
40 'SRCREV',
41 'SRCDATE',
42 'PE',
43 'PV',
44 'PR',
45 'INC_PR',
46 'SRC_URI',
47 'S',
48 'GPE_TARBALL_SUFFIX',
49 'inherit',
50 'EXTRA_',
51 'export',
52 'do_fetch',
53 'do_unpack',
54 'do_patch',
55 'WORKDIR',
56 'acpaths',
57 'do_configure',
58 'do_compile',
59 'do_install',
60 'PACKAGES',
61 'PACKAGE_ARCH',
62 'RDEPENDS',
63 'RRECOMMENDS',
64 'RSUGGESTS',
65 'RPROVIDES',
66 'RCONFLICTS',
67 'FILES',
68 'do_package',
69 'do_stage',
70 'addhandler',
71 'addtask',
72 'bindir',
73 'headers',
74 'include',
75 'includedir',
76 'python',
77 'qtopiadir',
78 'pkg_preins',
79 'pkg_prerm',
80 'pkg_postins',
81 'pkg_postrm',
82 'require',
83 'sbindir',
84 'basesysconfdir',
85 'sysconfdir',
86 'ALLOW_EMPTY',
87 'ALTERNATIVE_NAME',
88 'ALTERNATIVE_PATH',
89 'ALTERNATIVE_LINK',
90 'ALTERNATIVE_PRIORITY',
91 'ALTNAME',
92 'AMD_DRIVER_LABEL',
93 'AMD_DRIVER_VERSION',
94 'ANGSTROM_EXTRA_INSTALL',
95 'APPDESKTOP',
96 'APPIMAGE',
97 'APPNAME',
98 'APPTYPE',
99 'APPWEB_BUILD',
100 'APPWEB_HOST',
101 'AR',
102 'ARCH',
103 'ARM_INSTRUCTION_SET',
104 'ARM_MUTEX',
105 'ART_CONFIG',
106 'B',
107 'BJAM_OPTS',
108 'BJAM_TOOLS',
109 'BONOBO_HEADERS',
110 'BOOTSCRIPTS',
111 'BROKEN',
112 'BUILD_CPPFLAGS',
113 'CFLAGS',
114 'CCFLAGS',
115 'CMDLINE',
116 'COLLIE_MEMORY_SIZE',
117 'COMPATIBLE_HOST',
118 'COMPATIBLE_MACHINE',
119 'COMPILE_HERMES',
120 'CONFFILES',
121 'CONFLICTS',
122 'CORE_EXTRA_D',
123 'CORE_PACKAGES_D',
124 'CORE_PACKAGES_RD',
125 'CPPFLAGS',
126 'CVSDATE',
127 'CXXFLAGS',
128 'DEBIAN_NOAUTONAME',
129 'DEBUG_APPS',
130 'DEFAULT_PREFERENCE',
131 'DB4_CONFIG',
132 'EXCLUDE_FROM_SHLIBS',
133 'EXCLUDE_FROM_WORLD',
134 'FIXEDSRCDATE',
135 'GLIBC_ADDONS',
136 'GLIBC_EXTRA_OECONF',
137 'GNOME_VFS_HEADERS',
138 'HEADERS',
139 'INHIBIT_DEFAULT_DEPS',
140 'INITSCRIPT_PACKAGES',
141 'INITSCRIPT_NAME',
142 'INITSCRIPT_PARAMS',
143 'PACKAGE_INSTALL',
144 'KERNEL_IMAGETYPE',
145 'KERNEL_IMAGEDEST',
146 'KERNEL_OUTPUT',
147 'KERNEL_RELEASE',
148 'KERNEL_PRIORITY',
149 'KERNEL_SOURCE',
150 'KERNEL_SUFFIX',
151 'KERNEL_VERSION',
152 'K_MAJOR',
153 'K_MICRO',
154 'K_MINOR',
155 'HHV',
156 'KV',
157 'LDFLAGS',
158 'LD',
159 'LD_SO',
160 'LDLIBS',
161 'LEAD_SONAME',
162 'LIBTOOL',
163 'LIBBDB_EXTRA',
164 'LIBV',
165 'MACHINE_ESSENTIAL_EXTRA_RDEPENDS',
166 'MACHINE_ESSENTIAL_EXTRA_RRECOMMENDS',
167 'MACHINE_EXTRA_RDEPENDS',
168 'MACHINE_EXTRA_RRECOMMENDS',
169 'MACHINE_FEATURES',
170 'MACHINE_TASKS',
171 'MACHINE',
172 'MACHTYPE',
173 'MAKE_TARGETS',
174 'MESSAGEUSER',
175 'MESSAGEHOME',
176 'MIRRORS',
177 'MUTEX',
178 'OE_QMAKE_INCDIR_QT',
179 'OE_QMAKE_CXXFLAGS',
180 'ORBIT_IDL_SRC',
181 'PARALLEL_MAKE',
182 'PAKCAGE_ARCH',
183 'PCMCIA_MANAGER',
184 'PKG_BASENAME',
185 'PKG',
186 'QEMU',
187 'QMAKE_PROFILES',
188 'QPEDIR',
189 'QPF_DESCRIPTION',
190 'QPF_PKGPATTERN',
191 'QT_CONFIG_FLAGS',
192 'QT_LIBRARY',
193 'ROOTFS_POSTPROCESS_COMMAND',
194 'RREPLACES',
195 'TARGET_CFLAGS',
196 'TARGET_CPPFLAGS',
197 'TARGET_LDFLAGS',
198 'UBOOT_MACHINE',
199 'UCLIBC_BASE',
200 'UCLIBC_PATCHES',
201 'VIRTUAL_NAME',
202 'XORG_PN',
203 'XSERVER',
204 'others'
205]
206
207varRegexp = r'^([a-zA-Z_0-9${}-]*)([ \t]*)([+.:]?=[+.]?)([ \t]*)([^\t]+)'
208routineRegexp = r'^([a-zA-Z0-9_ ${}-]+?)\('
209
210# Variables seen in the processed .bb
211seen_vars = {}
212for v in OE_vars:
213 seen_vars[v] = []
214
215# _Format guideline #0_:
216# No spaces are allowed at the beginning of lines that define a variable or
217# a do_ routine
218def respect_rule0(line):
219 return line.lstrip()==line
220def conformTo_rule0(line):
221 return line.lstrip()
222
223# _Format guideline #1_:
224# No spaces are allowed behind the line continuation symbol '\'
225def respect_rule1(line):
226 if line.rstrip().endswith('\\'):
227 return line.endswith('\\')
228 else:
229 return True
230def conformTo_rule1(line):
231 return line.rstrip()
232
233# _Format guideline #2_:
234# Tabs should not be used (use spaces instead).
235def respect_rule2(line):
236 return line.count('\t')==0
237def conformTo_rule2(line):
238 return line.expandtabs()
239
240# _Format guideline #3_:
241# Comments inside bb files are allowed using the '#' character at the
242# beginning of a line.
243def respect_rule3(line):
244 if line.lstrip().startswith('#'):
245 return line.startswith('#')
246 else:
247 return True
248def conformTo_rule3(line):
249 return line.lstrip()
250
251# _Format guideline #4_:
252# Use quotes on the right hand side of assignments FOO = "BAR"
253def respect_rule4(line):
254 r = re.search(varRegexp, line)
255 if r is not None:
256 r2 = re.search(r'("?)([^"\\]*)(["\\]?)', r.group(5))
257 # do not test for None it because always match
258 return r2.group(1)=='"' and r2.group(3)!=''
259 return False
260def conformTo_rule4(line):
261 r = re.search(varRegexp, line)
262 return ''.join([r.group(1), ' ', r.group(3), ' "', r.group(5), r.group(5).endswith('"') and '' or '"'])
263
264# _Format guideline #5_:
265# The correct spacing for a variable is FOO = "BAR".
266def respect_rule5(line):
267 r = re.search(varRegexp, line)
268 return r is not None and r.group(2)==" " and r.group(4)==" "
269def conformTo_rule5(line):
270 r = re.search(varRegexp, line)
271 return ''.join([r.group(1), ' ', r.group(3), ' ', r.group(5)])
272
273# _Format guideline #6_:
274# Don't use spaces or tabs on empty lines
275def respect_rule6(line):
276 return not line.isspace() or line=="\n"
277def conformTo_rule6(line):
278 return ""
279
280# _Format guideline #7_:
281# Indentation of multiline variables such as SRC_URI is desireable.
282def respect_rule7(line):
283 return True
284def conformTo_rule7(line):
285 return line
286
287rules = (
288 (respect_rule0, conformTo_rule0, "No spaces are allowed at the beginning of lines that define a variable or a do_ routine"),
289 (respect_rule1, conformTo_rule1, "No spaces are allowed behind the line continuation symbol '\\'"),
290 (respect_rule2, conformTo_rule2, "Tabs should not be used (use spaces instead)"),
291 (respect_rule3, conformTo_rule3, "Comments inside bb files are allowed using the '#' character at the beginning of a line"),
292 (respect_rule4, conformTo_rule4, "Use quotes on the right hand side of assignments FOO = \"BAR\""),
293 (respect_rule5, conformTo_rule5, "The correct spacing for a variable is FOO = \"BAR\""),
294 (respect_rule6, conformTo_rule6, "Don't use spaces or tabs on empty lines"),
295 (respect_rule7, conformTo_rule7, "Indentation of multiline variables such as SRC_URI is desireable"),
296)
297
298# Function to check that a line respects a rule. If not, it tries to conform
299# the line to the rule. Reminder or Disgression message are dump accordingly.
300def follow_rule(i, line):
301 oldline = line
302 # if the line does not respect the rule
303 if not rules[i][0](line):
304 # try to conform it to the rule
305 line = rules[i][1](line)
306 # if the line still does not respect the rule
307 if not rules[i][0](line):
308 # this is a rule disgression
309 print ("## Disgression: ", rules[i][2], " in:", oldline)
310 else:
311 # just remind user about his/her errors
312 print ("## Reminder: ", rules[i][2], " in :", oldline)
313 return line
314
315
316if __name__ == "__main__":
317
318 # -- retrieves the lines of the .bb file --
319 lines = []
320 for line in fileinput.input():
321 # use 'if True' to warn user about all the rule he/she breaks
322 # use 'if False' to conform to rules{2,1,6} without warnings
323 if True:
324 lines.append(line)
325 else:
326 # expandtabs on each line so that rule2 is always respected
327 # rstrip each line so that rule1 is always respected
328 line = line.expandtabs().rstrip()
329 # ignore empty lines (or line filled with spaces or tabs only)
330 # so that rule6 is always respected
331 if line is not '':
332 lines.append(line)
333
334 # -- parse the file --
335 var = ""
336 in_routine = False
337 commentBloc = []
338 olines = []
339 for line in lines:
340 originalLine = line
341 # rstrip line to remove line breaks characters
342 line = line.rstrip()
343 line = follow_rule(2, line)
344 line = follow_rule(1, line)
345 line = follow_rule(6, line)
346
347 # ignore empty lines
348 if line.isspace() or line is '':
349 # flush comments into the olines
350 for c in commentBloc: olines.append(c)
351 commentBloc = []
352 continue
353
354 if line.startswith('}'):
355 in_routine=False
356 keep = line.endswith('\\') or in_routine
357
358 # handles commented lines
359 if line.lstrip().startswith('#'):
360 # check and follow rule3 if not in a variables or routines
361 if not in_routine:
362 line = follow_rule(3, line)
363 commentBloc.append(line)
364 continue
365
366 if var in seen_vars:
367 for c in commentBloc: seen_vars[var].append(c)
368 commentBloc = []
369 seen_vars[var].append(line)
370 else:
371 for k in OE_vars:
372 if line.startswith(k):
373 var = k
374 break
375 if re.match(routineRegexp, line) is not None:
376 in_routine=True
377 line = follow_rule(0, line)
378 elif re.match(varRegexp, line) is not None:
379 line = follow_rule(0, line)
380 line = follow_rule(4, line)
381 line = follow_rule(5, line)
382 if var == "":
383 if not in_routine:
384 print ("## Warning: unknown variable/routine \"%s\"" % originalLine.rstrip('\n'))
385 var = 'others'
386 for c in commentBloc: seen_vars[var].append(c)
387 commentBloc = []
388 seen_vars[var].append(line)
389 if not keep and not in_routine: var = ""
390
391 # -- dump the sanitized .bb file --
392 addEmptyLine = False
393 # write comments that are not related to variables nor routines
394 for l in commentBloc: olines.append(l)
395 # write variables and routines
396 previourVarPrefix = "unknown"
397 for k in OE_vars:
398 if k=='SRC_URI': addEmptyLine = True
399 if seen_vars[k] != []:
400 if addEmptyLine and not k.startswith(previourVarPrefix):
401 olines.append("")
402 for l in seen_vars[k]:
403 olines.append(l)
404 previourVarPrefix = k.split('_')[0]=='' and "unknown" or k.split('_')[0]
405 for line in olines: print(line)
406
diff --git a/contrib/pw-am.sh b/contrib/pw-am.sh
new file mode 100755
index 000000000..8987eee8e
--- /dev/null
+++ b/contrib/pw-am.sh
@@ -0,0 +1,15 @@
1#!/bin/sh
2#
3# Idea and implementation: Koen Kooi
4# Multiple patches support: Marcin Juszkiewicz
5#
6# This script will fetch an 'mbox' patch from patchwork and git am it
7# usage: pw-am.sh <number>
8# example: 'pw-am.sh 221' will get the patch from http://patchwork.openembedded.org/patch/221/
9
10for patchnumber in $@;
11do
12 wget -nv http://patches.openembedded.org/patch/$patchnumber/mbox/ -O pw-am-$patchnumber.patch
13 git am -s pw-am-$patchnumber.patch
14 rm pw-am-$patchnumber.patch
15done
diff --git a/contrib/tesseract-langs.sh b/contrib/tesseract-langs.sh
new file mode 100755
index 000000000..50873c139
--- /dev/null
+++ b/contrib/tesseract-langs.sh
@@ -0,0 +1,92 @@
1#! /bin/sh
2
3# Copyright (C) 2014, O.S. Systems Software Ltda. All Rights Reserved
4# Released under the MIT license (see meta-openembedded layer's COPYING.MIT)
5
6PV='3.02'
7
8# Sometimes the software package has a minor version, but language
9# packages have not. Example:
10# software package: tesseract-ocr-3.02.02.tar.gz
11# language package: tesseract-ocr-3.02.por.tar.gz
12MINOR_PV=02
13
14recipes_dir=$1
15
16usage() {
17 echo "Usage: `basename $0` <recipes dir> [ <download dir> ]"
18}
19
20if [ -z "$recipes_dir" ]; then
21 usage
22 exit 1
23fi
24mkdir -p "$recipes_dir"
25
26file_list_uri='https://code.google.com/p/tesseract-ocr/downloads/list'
27file_list=`mktemp`
28
29remove_dl_dir=
30if [ -z "$2" ]; then
31 remove_dl_dir=1
32 dl_dir=`mktemp -d`
33else
34 dl_dir="$2"
35fi
36
37mkdir -p $dl_dir
38
39tesseract_langs() {
40 wget -q -O "$file_list" "$file_list_uri"
41
42 grep -E 'a href="detail\?name=tesseract-ocr-'${PV}'\.[^\.]+.tar.gz&amp;can=2&amp;q=">' "$file_list" | \
43 sed -r -e 's/.*tesseract-ocr-'${PV}'\.*([^\.]+)\.tar\.gz.*/\1/' | \
44 grep -Ev '('${MINOR_PV}'|'${MINOR_PV}'-doc-html)' | \
45 sort -u
46}
47
48download_lang_files() {
49 local langs="$1"
50 local uri
51 for lang in $langs; do
52 if [ ! -e "$dl_dir/tesseract-ocr-${PV}.${lang}.tar.gz" ]; then
53 uri="https://tesseract-ocr.googlecode.com/files/tesseract-ocr-${PV}.${lang}.tar.gz"
54 echo "Downloading $uri"
55 wget -q -P "$dl_dir" "$uri"
56 fi
57 done
58}
59
60create_recipe() {
61 local lang=$1
62 local tarball
63
64 tarball="$dl_dir/tesseract-ocr-${PV}.${lang}.tar.gz"
65
66 md5sum=`md5sum $tarball | awk '{print $1}'`
67 sha256sum=`sha256sum $tarball | awk '{print $1}'`
68
69 cat > $recipes_dir/tesseract-lang-`echo ${lang} | sed s/_/-/g`_${PV}.bb <<EOF
70# Copyright (C) 2014, O.S. Systems Software Ltda. All Rights Reserved
71# Released under the MIT license (see meta-openembedded layer's COPYING.MIT)
72
73TESSERACT_LANG = "$lang"
74
75require tesseract-lang.inc
76
77SRC_URI[md5sum] = "${md5sum}"
78SRC_URI[sha256sum] = "${sha256sum}"
79EOF
80}
81
82
83LANGS=`tesseract_langs`
84
85download_lang_files "$LANGS"
86
87for lang in $LANGS; do
88 create_recipe $lang
89done
90
91[ -n "$remove_dl_dir" ] && rm -rf $dl_dir
92rm -f $file_list