tools: add a directory to contain usefull user-facing tools
PATCH v3 1/8 tools: add a directory to store some useful user-facing tools
In reply to Yann E. MORINAdd a tools directory to store useful little scripts, tools, etc... Users may add that directory in their PATH if they want to, but this is not mandatory.
Add the first tool: brmake, a small script that redirects the build output log to a file, keeping just Buildroot's own messages, with the date+time added at the start of the line.
We need to unbuffer the output of make so that, when the script is interrupted (SIGINT, ^C), there is no lingering output not yet digested by the logger loop.
---
Changes v2 -> v3:
- detect unconfigured build tree (Ricardo)
- rename 00-README -> readme.txt (Thomas, Arnout)
Changes v1 -> v2:
- rename contrib -> tools (Arnout)
- detect missing unbuffer (Arnout)
Notes:
- Arnout suggested using 'stdbuf' instead of 'unbuffer', but that has some shortcomings in weird corner-cases because it uses LD_PRELOAD to call a constructor that forces settings on stdout/stderr/stdin (it cost me three days to investigate a build failure because of that). So, I stuck with 'unbuffer'...
- I also tried to use bash' coproc, but it seems there was a regression in later bash versions that causes an incorrect redirect. So, I stuck with 'unbuffer'...
--- docs/manual/writing-rules.txt | 5 ++-- tools/brmake | 62 +++++++++++++++++++++++++++++++++++++++++++ tools/readme.txt | 9 +++++++ 3 files changed, 74 insertions(+), 2 deletions(-) create mode 100755 tools/brmake create mode 100644 tools/readme.txt
docs/manual/writing-rules.txt +3 -2
@@ -146,5 +146,6 @@ syntax, refer to http://www.methods.co.nz/asciidoc/userguide.html[]. === Support scripts -Some scripts in the +support/+ directory are written in Python and should follow -the https://www.python.org/dev/peps/pep-0008/[PEP8 Style Guide for Python Code]. +Some scripts in the +support/+ and +tools/+ directories are written in +Python and should follow the +https://www.python.org/dev/peps/pep-0008/[PEP8 Style Guide for Python Code].
tools/brmake new file +62 -0
62 lines not on this page · raw message
tools/readme.txt new file +9 -0
@@ -0,0 +1,9 @@ +This directory contains various useful scripts and tools for working +with Buildroot. You need not add this directory in your PATH to use +any of those tools, but you may do so if you want. + +brmake + a script that can be run instead of make, that prepends the date in + front of each line, redirects all of the build output to a file + ("'br.log' in the current directory), and just outputs the Buildroot + messages (those lines starting with >>>) on stdout.
Signature · 1 line
2.11.0
PATCH v3 2/8 tools: move test-pkg out of support/scripts
In reply to Yann E. MORINMove it to the top-level tools/ directory, so that it is easier to find for users.
Add a legacy symlink for those users who already used them, so as not to break their habits.
--- docs/manual/adding-packages-tips.txt | 12 +-- support/scripts/test-pkg | 198 +---------------------------------- tools/readme.txt | 5 + tools/test-pkg | 197 ++++++++++++++++++++++++++++++++++ 4 files changed, 209 insertions(+), 203 deletions(-) mode change 100755 => 120000 support/scripts/test-pkg create mode 100755 tools/test-pkg
docs/manual/adding-packages-tips.txt +6 -6
@@ -45,9 +45,9 @@ continuously test random configurations. However, these only build the `master` branch of the git tree, and your new fancy package is not yet there. -Buildroot provides a script in +support/scripts/test-pkg+ that uses the -same base configurations as used by the autobuilders so you can test -your package in the same conditions. +Buildroot provides a script in +tools/test-pkg+ that uses the same base +configurations as used by the autobuilders so you can test your package +in the same conditions. First, create a config snippet that contains all the necessary options needed to enable your package, but without any architecture or toolchain
@@ -74,7 +74,7 @@ Then run the +test-pkg+ script, by telling it what config snippet to use and what package to test: ---- -$ ./support/scripts/test-pkg -c libcurl.config -p libcurl +$ ./tools/test-pkg -c libcurl.config -p libcurl ---- This will try to build your package against all the toolchains used
@@ -83,7 +83,7 @@ too long to do so). The output lists all toolchains and the corresponding result (excerpt, results are fake): ---- -$ ./support/scripts/test-pkg -c libcurl.config -p libcurl +$ ./tools/test-pkg -c libcurl.config -p libcurl armv5-ctng-linux-gnueabi [ 1/11]: OK armv7-ctng-linux-gnueabihf [ 2/11]: OK br-aarch64-glibc [ 3/11]: SKIPPED
@@ -124,7 +124,7 @@ The +test-pkg+ script accepts a few options, for which you can get some help by running: ---- -$ ./support/scripts/test-pkg -h +$ ./tools/test-pkg -h ---- [[github-download-url]]
support/scripts/test-pkg deleted +0 -197
197 lines not on this page · raw message
support/scripts/test-pkg new file +1 -0
@@ -0,0 +1 @@ +../../tools/test-pkg
tools/readme.txt +5 -0
@@ -7,3 +7,8 @@ brmake front of each line, redirects all of the build output to a file ("'br.log' in the current directory), and just outputs the Buildroot messages (those lines starting with >>>) on stdout. + +test-pkg + a script that tests a specific package against a set of various + toolchains, with the goal to detect toolchain-related dependencies + (wchar, threads...)
tools/test-pkg new file +197 -0
197 lines not on this page · raw message
Signature · 1 line
2.11.0
v3 cover tools: add a directory to contain usefull user-facing tools
Hello All!
Currently, we provide a few user-facing utilities, like get-developers, in support/scripts/ . But this directory also contains internal scripts that a user should not be directly concerned with. Besides, it is two-level deep in the hierarchy, which is not really nice.
So, we introduce tools/ as a top-level directory, with the goal to store and expose all user-facing utilities, while keeping our internal scripts in support/scripts/ .
The first patch in the series introduces a new utility, brmake, a wrapper around make that stores all the output to a log file and displays only the >>> lines.
The second and subsequent patches each move a few user-facing utilities out of support/scripts/ and into tools/ .
Changes v2 -> v3:
- rename readme file (Arnout, Thomas)
- fix DEVELOPPERS (Ricardo)
Changes v1 -> v2:
- rename contrib -> tools (Arnout)
- move more scripts
Regards,
Yann E. MORIN.
The following changes since commit 87d0964e0b815d39b140be8ee5cd322d6714ee14
libva-intel-driver: bump version to 1.8.3 (2017-06-28 23:29:21 +0200)
are available in the git repository at:
git://git.buildroot.org/~ymorin/git/buildroot.git
for you to fetch changes up to 1b7714308bccb32916cf2a41590894d59a58c6e1
tools move xorg-release out of support/scripts/ (2017-06-30 17:56:58 +0200)
----------------------------------------------------------------
Yann E. MORIN (8):
tools: add a directory to store some useful user-facing tools
tools: move test-pkg out of support/scripts
tools: move get-developers out of support/scripts/
tools: move check-package out of support/scripts/
tools: move size-stat-compare out of support/scripts/
tools: move scancpan out of support/scripts/
tools: move scanpypi out of support/scripts/
tools move xorg-release out of support/scripts/
DEVELOPERS | 3 +-
docs/manual/adding-packages-tips.txt | 12 +-
docs/manual/contribute.txt | 2 +-
docs/manual/writing-rules.txt | 5 +-
support/scripts/check-package | 145 +---
support/scripts/get-developers | 84 +-
support/scripts/pkg-stats | 2 +-
support/scripts/scancpan | 859 +--------------------
support/scripts/scanpypi | 654 +---------------
support/scripts/size-stats-compare | 128 +--
support/scripts/test-pkg | 198 +----
support/scripts/xorg-release | 181 +----
tools/brmake | 62 ++
{support/scripts => tools}/check-package | 2 +-
.../scripts => tools}/checkpackagelib/__init__.py | 0
{support/scripts => tools}/checkpackagelib/base.py | 2 +-
{support/scripts => tools}/checkpackagelib/lib.py | 2 +-
.../checkpackagelib/lib_config.py | 2 +-
.../scripts => tools}/checkpackagelib/lib_hash.py | 2 +-
.../scripts => tools}/checkpackagelib/lib_mk.py | 2 +-
.../scripts => tools}/checkpackagelib/lib_patch.py | 2 +-
.../scripts => tools}/checkpackagelib/readme.txt | 10 +-
{support/scripts => tools}/get-developers | 0
{support/scripts => tools}/getdeveloperlib.py | 0
tools/readme.txt | 40 +
{support/scripts => tools}/scancpan | 0
{support/scripts => tools}/scanpypi | 0
{support/scripts => tools}/size-stats-compare | 0
{support/scripts => tools}/test-pkg | 0
{support/scripts => tools}/xorg-release | 0
30 files changed, 134 insertions(+), 2265 deletions(-)
mode change 100755 => 120000 support/scripts/check-package
mode change 100755 => 120000 support/scripts/get-developers
mode change 100755 => 120000 support/scripts/scancpan
mode change 100755 => 120000 support/scripts/scanpypi
mode change 100755 => 120000 support/scripts/size-stats-compare
mode change 100755 => 120000 support/scripts/test-pkg
mode change 100755 => 120000 support/scripts/xorg-release
create mode 100755 tools/brmake
copy {support/scripts => tools}/check-package (98%)
rename {support/scripts => tools}/checkpackagelib/__init__.py (100%)
rename {support/scripts => tools}/checkpackagelib/base.py (78%)
rename {support/scripts => tools}/checkpackagelib/lib.py (95%)
rename {support/scripts => tools}/checkpackagelib/lib_config.py (98%)
rename {support/scripts => tools}/checkpackagelib/lib_hash.py (96%)
rename {support/scripts => tools}/checkpackagelib/lib_mk.py (99%)
rename {support/scripts => tools}/checkpackagelib/lib_patch.py (96%)
rename {support/scripts => tools}/checkpackagelib/readme.txt (91%)
copy {support/scripts => tools}/get-developers (100%)
rename {support/scripts => tools}/getdeveloperlib.py (100%)
create mode 100644 tools/readme.txt
copy {support/scripts => tools}/scancpan (100%)
copy {support/scripts => tools}/scanpypi (100%)
copy {support/scripts => tools}/size-stats-compare (100%)
copy {support/scripts => tools}/test-pkg (100%)
copy {support/scripts => tools}/xorg-release (100%)Signature · 6 lines
.-----------------.--------------------.------------------.--------------------. | Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: | | +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ | | +33 223 225 172 `------------.-------: X AGAINST | \e/ There is no | | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. | '------------------------------^-------^------------------^--------------------'
PATCH v3 3/8 tools: move get-developers out of support/scripts/
Move it to the top-level tools/ directory, so that it is easier to find for users.
Add a legacy symlink for those users who already used them, so as not to break their habits.
---
docs/manual/contribute.txt | 2 +-
support/scripts/get-developers | 84 +--------------------------
tools/get-developers | 83 ++++++++++++++++++++++++++
{support/scripts => tools}/getdeveloperlib.py | 0
tools/readme.txt | 5 ++
5 files changed, 90 insertions(+), 84 deletions(-)
mode change 100755 => 120000 support/scripts/get-developers
create mode 100755 tools/get-developers
rename {support/scripts => tools}/getdeveloperlib.py (100%)docs/manual/contribute.txt +1 -1
@@ -295,7 +295,7 @@ information). This tool reads your patches and outputs the appropriate +git send-email+ command to use: --------------------- -$ ./support/scripts/get-developers outgoing/* +$ ./tools/get-developers outgoing/* --------------------- Use the output of +get-developers+ to send your patches:
support/scripts/get-developers deleted +0 -83
83 lines not on this page · raw message
support/scripts/get-developers new file +1 -0
@@ -0,0 +1 @@ +../../tools/get-developers
tools/get-developers new file +83 -0
83 lines not on this page · raw message
tools/getdeveloperlib.py renamed from support/scripts/getdeveloperlib.py +0 -0
tools/readme.txt +5 -0
@@ -8,6 +8,11 @@ brmake ("'br.log' in the current directory), and just outputs the Buildroot messages (those lines starting with >>>) on stdout. +get-developpers + a script to return the list of people interested in a specific part + of Buildroot, so they can be Cc:ed on a mail. Accepts a patch as + input, a package name or and architecture name. + test-pkg a script that tests a specific package against a set of various toolchains, with the goal to detect toolchain-related dependencies
Signature · 1 line
2.11.0
PATCH v3 4/8 tools: move check-package out of support/scripts/
In reply to Yann E. MORINMove it to the top-level tools/ directory, so that it is easier to find for users.
Add a legacy symlink for those users who already used them, so as not to break their habits.
---
Changes v2 -> v3:
- fix leftover paths in comments (Ricardo)
- update paths in DEVELOPPERS (Ricardo)
---
DEVELOPERS | 3 +-
support/scripts/check-package | 145 +--------------------
support/scripts/pkg-stats | 2 +-
tools/check-package | 144 ++++++++++++++++++++
.../scripts => tools}/checkpackagelib/__init__.py | 0
{support/scripts => tools}/checkpackagelib/base.py | 2 +-
{support/scripts => tools}/checkpackagelib/lib.py | 2 +-
.../checkpackagelib/lib_config.py | 2 +-
.../scripts => tools}/checkpackagelib/lib_hash.py | 2 +-
.../scripts => tools}/checkpackagelib/lib_mk.py | 2 +-
.../scripts => tools}/checkpackagelib/lib_patch.py | 2 +-
.../scripts => tools}/checkpackagelib/readme.txt | 10 +-
tools/readme.txt | 4 +
13 files changed, 163 insertions(+), 157 deletions(-)
mode change 100755 => 120000 support/scripts/check-package
create mode 100755 tools/check-package
rename {support/scripts => tools}/checkpackagelib/__init__.py (100%)
rename {support/scripts => tools}/checkpackagelib/base.py (78%)
rename {support/scripts => tools}/checkpackagelib/lib.py (95%)
rename {support/scripts => tools}/checkpackagelib/lib_config.py (98%)
rename {support/scripts => tools}/checkpackagelib/lib_hash.py (96%)
rename {support/scripts => tools}/checkpackagelib/lib_mk.py (99%)
rename {support/scripts => tools}/checkpackagelib/lib_patch.py (96%)
rename {support/scripts => tools}/checkpackagelib/readme.txt (91%)DEVELOPERS +2 -1
@@ -1386,7 +1386,8 @@ N: Rhys Williams <[email protected]> F: package/lirc-tools/ N: Ricardo Martincoski <[email protected]> -F: support/scripts/check*package* +F: tools/check-package +F: tools/checkpackagelib/ N: Richard Braun <[email protected]> F: package/curlftpfs/
support/scripts/check-package deleted +0 -144
144 lines not on this page · raw message
support/scripts/check-package new file +1 -0
@@ -0,0 +1 @@ +../../tools/check-package
support/scripts/pkg-stats +1 -1
@@ -337,7 +337,7 @@ for i in $(find boot/ linux/ package/ toolchain/ -name '*.mk' | sort) ; do fi file_list=$(find ${package_dir} -name '*.mk' -o -name '*.in*' -o -name '*.hash') - nwarnings=$(./support/scripts/check-package ${file_list} 2>&1 | sed '/\([0-9]*\) warnings generated/!d; s//\1/') + nwarnings=$(./tools/check-package ${file_list} 2>&1 | sed '/\([0-9]*\) warnings generated/!d; s//\1/') if [ ${nwarnings} -eq 0 ] ; then echo "<td class=\"centered correct\">${nwarnings}</td>" else
tools/check-package new file +144 -0
144 lines not on this page · raw message
tools/checkpackagelib/__init__.py renamed from support/scripts/checkpackagelib/__init__.py +0 -0
tools/checkpackagelib/base.py renamed from support/scripts/checkpackagelib/base.py +1 -1
@@ -1,4 +1,4 @@ -# See support/scripts/checkpackagelib/readme.txt before editing this file. +# See tools/checkpackagelib/readme.txt before editing this file. class _CheckFunction(object):
tools/checkpackagelib/lib.py renamed from support/scripts/checkpackagelib/lib.py +1 -1
@@ -1,4 +1,4 @@ -# See support/scripts/checkpackagelib/readme.txt before editing this file. +# See tools/checkpackagelib/readme.txt before editing this file. from base import _CheckFunction
tools/checkpackagelib/lib_config.py renamed from support/scripts/checkpackagelib/lib_config.py +1 -1
@@ -1,4 +1,4 @@ -# See support/scripts/checkpackagelib/readme.txt before editing this file. +# See tools/checkpackagelib/readme.txt before editing this file. # Kconfig generates errors if someone introduces a typo like "boool" instead of # "bool", so below check functions don't need to check for things already # checked by running "make menuconfig".
tools/checkpackagelib/lib_hash.py renamed from support/scripts/checkpackagelib/lib_hash.py +1 -1
@@ -1,4 +1,4 @@ -# See support/scripts/checkpackagelib/readme.txt before editing this file. +# See tools/checkpackagelib/readme.txt before editing this file. # The validity of the hashes itself is checked when building, so below check # functions don't need to check for things already checked by running # "make package-dirclean package-source".
tools/checkpackagelib/lib_mk.py renamed from support/scripts/checkpackagelib/lib_mk.py +1 -1
@@ -1,4 +1,4 @@ -# See support/scripts/checkpackagelib/readme.txt before editing this file. +# See tools/checkpackagelib/readme.txt before editing this file. # There are already dependency checks during the build, so below check # functions don't need to check for things already checked by exploring the # menu options using "make menuconfig" and by running "make" with appropriate
tools/checkpackagelib/lib_patch.py renamed from support/scripts/checkpackagelib/lib_patch.py +1 -1
@@ -1,4 +1,4 @@ -# See support/scripts/checkpackagelib/readme.txt before editing this file. +# See tools/checkpackagelib/readme.txt before editing this file. # The format of the patch files is tested during the build, so below check # functions don't need to check for things already checked by running # "make package-dirclean package-patch".
tools/checkpackagelib/readme.txt renamed from support/scripts/checkpackagelib/readme.txt +5 -5
@@ -57,19 +57,19 @@ Some hints when changing this code: Usage examples: - to get a list of check functions that would be called without actually calling them you can use the --dry-run option: -$ support/scripts/check-package --dry-run package/yourfavorite/* +$ tools/check-package --dry-run package/yourfavorite/* - when you just added a new check function, e.g. Something, check how it behaves for all current packages: -$ support/scripts/check-package --include-only Something $(find package -type f) +$ tools/check-package --include-only Something $(find package -type f) - the effective processing time (when the .pyc were already generated and all files to be processed are cached in the RAM) should stay in the order of few seconds: -$ support/scripts/check-package $(find package -type f) >/dev/null ; \ - time support/scripts/check-package $(find package -type f) >/dev/null +$ tools/check-package $(find package -type f) >/dev/null ; \ + time tools/check-package $(find package -type f) >/dev/null - vim users can navigate the warnings (most editors probably have similar function) since warnings are generated in the form 'path/file:line: warning': $ find package/ -name 'Config.*' > filelist && vim -c \ - 'set makeprg=support/scripts/check-package\ $(cat\ filelist)' -c make -c copen + 'set makeprg=tools/check-package\ $(cat\ filelist)' -c make -c copen
tools/readme.txt +4 -0
@@ -8,6 +8,10 @@ brmake ("'br.log' in the current directory), and just outputs the Buildroot messages (those lines starting with >>>) on stdout. +check-package + a script that checks the coding style of a package's Config.in and + .mk files, and also tests them for various types of typoes. + get-developpers a script to return the list of people interested in a specific part of Buildroot, so they can be Cc:ed on a mail. Accepts a patch as
Signature · 1 line
2.11.0
PATCH v3 5/8 tools: move size-stat-compare out of support/scripts/
In reply to Yann E. MORINMove it to the top-level tools/ directory, so that it is easier to find for users.
Add a legacy symlink for those users who already used them, so as not to break their habits.
--- support/scripts/size-stats-compare | 128 +------------------------------------ tools/readme.txt | 5 ++ tools/size-stats-compare | 127 ++++++++++++++++++++++++++++++++++++ 3 files changed, 133 insertions(+), 127 deletions(-) mode change 100755 => 120000 support/scripts/size-stats-compare create mode 100755 tools/size-stats-compare
support/scripts/size-stats-compare deleted +0 -127
@@ -1,127 +0,0 @@ -#!/usr/bin/env python - -# Copyright (C) 2016 Thomas De Schampheleire <[email protected]> - -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 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 -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -# TODO (improvements) -# - support K,M,G size suffixes for threshold -# - output CSV file in addition to stdout reporting - -import csv -import argparse -import sys - -def read_file_size_csv(inputf, detail=None): - """Extract package or file sizes from CSV file into size dictionary""" - sizes = {} - reader = csv.reader(inputf) - - header = next(reader) - if (header[0] != 'File name' or header[1] != 'Package name' or - header[2] != 'File size' or header[3] != 'Package size'): - print(("Input file %s does not contain the expected header. Are you " - "sure this file corresponds to the file-size-stats.csv " - "file created by 'make graph-size'?") % inputf.name) - sys.exit(1) - - for row in reader: - if detail: - sizes[row[0]] = int(row[2]) - else: - sizes[row[1]] = int(row[3]) - - return sizes - -def compare_sizes(old, new): - """Return delta/added/removed dictionaries based on two input size - dictionaries""" - delta = {} - oldkeys = set(old.keys()) - newkeys = set(new.keys()) - - # packages/files in both - for entry in newkeys.intersection(oldkeys): - delta[entry] = ('', new[entry] - old[entry]) - # packages/files only in new - for entry in newkeys.difference(oldkeys): - delta[entry] = ('added', new[entry]) - # packages/files only in old - for entry in oldkeys.difference(newkeys): - delta[entry] = ('removed', -old[entry]) - - return delta - -def print_results(result, threshold): - """Print the given result dictionary sorted by size, ignoring any entries - below or equal to threshold""" - - from six import iteritems - list_result = list(iteritems(result)) - # result is a dictionary: name -> (flag, size difference) - # list_result is a list of tuples: (name, (flag, size difference)) - - for entry in sorted(list_result, key=lambda entry: entry[1][1]): - if threshold is not None and abs(entry[1][1]) <= threshold: - continue - print('%12s %7s %s' % (entry[1][1], entry[1][0], entry[0])) - - -# main ######################################################################### - -description = """ -Compare rootfs size between Buildroot compilations, for example after changing -configuration options or after switching to another Buildroot release. - -This script compares the file-size-stats.csv file generated by 'make graph-size' -with the corresponding file from another Buildroot compilation. -The size differences can be reported per package or per file. -Size differences smaller or equal than a given threshold can be ignored. -""" - -parser = argparse.ArgumentParser(description=description, - formatter_class=argparse.RawDescriptionHelpFormatter) - -parser.add_argument('-d', '--detail', action='store_true', - help='''report differences for individual files rather than - packages''') -parser.add_argument('-t', '--threshold', type=int, - help='''ignore size differences smaller or equal than this - value (bytes)''') -parser.add_argument('old_file_size_csv', type=argparse.FileType('r'), - metavar='old-file-size-stats.csv', - help="""old CSV file with file and package size statistics, - generated by 'make graph-size'""") -parser.add_argument('new_file_size_csv', type=argparse.FileType('r'), - metavar='new-file-size-stats.csv', - help='new CSV file with file and package size statistics') -args = parser.parse_args() - -if args.detail: - keyword = 'file' -else: - keyword = 'package' - -old_sizes = read_file_size_csv(args.old_file_size_csv, args.detail) -new_sizes = read_file_size_csv(args.new_file_size_csv, args.detail) - -delta = compare_sizes(old_sizes, new_sizes) - -print('Size difference per %s (bytes), threshold = %s' % (keyword, args.threshold)) -print(80*'-') -print_results(delta, args.threshold) -print(80*'-') -print_results({'TOTAL': ('', sum(new_sizes.values()) - sum(old_sizes.values()))}, - threshold=None)
support/scripts/size-stats-compare new file +1 -0
@@ -0,0 +1 @@ +../../tools/size-stats-compare
tools/readme.txt +5 -0
@@ -17,6 +17,11 @@ get-developpers of Buildroot, so they can be Cc:ed on a mail. Accepts a patch as input, a package name or and architecture name. +size-stat-compare + a script to compare the rootfs size between two differnt Buildroot + configurations. This can be used to identify the size impact of + a specific option, or of a set of specific options. + test-pkg a script that tests a specific package against a set of various toolchains, with the goal to detect toolchain-related dependencies
tools/size-stats-compare new file +127 -0
127 lines not on this page · raw message
Signature · 1 line
2.11.0
PATCH v3 6/8 tools: move scancpan out of support/scripts/
In reply to Yann E. MORINMove it to the top-level tools/ directory, so that it is easier to find for users.
Add a legacy symlink for those users who already used them, so as not to break their habits.
--- support/scripts/scancpan | 859 +---------------------------------------------- tools/readme.txt | 4 + tools/scancpan | 858 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 863 insertions(+), 858 deletions(-) mode change 100755 => 120000 support/scripts/scancpan create mode 100755 tools/scancpan
support/scripts/scancpan deleted +0 -858
@@ -1,858 +0,0 @@ -#!/usr/bin/env perl - -# This chunk of stuff was generated by App::FatPacker. To find the original -# file's code, look for the end of this BEGIN block or the string 'FATPACK' -BEGIN { -my %fatpacked; - -$fatpacked{"MetaCPAN/API/Tiny.pm"} = <<'METACPAN_API_TINY'; - package MetaCPAN::API::Tiny; - { - $MetaCPAN::API::Tiny::VERSION = '1.131730'; - } - use strict; - use warnings; - # ABSTRACT: A Tiny API client for MetaCPAN - - use Carp; - use JSON::PP 'encode_json', 'decode_json'; - use HTTP::Tiny; - - - sub new { - my ($class, @args) = @_; - - $#_ % 2 == 0 - or croak 'Arguments must be provided as name/value pairs'; - - my %params = @args; - - die 'ua_args must be an array reference' - if $params{ua_args} && ref($params{ua_args}) ne 'ARRAY'; - - my $self = +{ - base_url => $params{base_url} || 'http://api.metacpan.org/v0', - ua => $params{ua} || HTTP::Tiny->new( - $params{ua_args} - ? @{$params{ua_args}} - : (agent => 'MetaCPAN::API::Tiny/' - . ($MetaCPAN::API::VERSION || 'xx'))), - }; - - return bless($self, $class); - } - - sub _build_extra_params { - my $self = shift; - - @_ % 2 == 0 - or croak 'Incorrect number of params, must be key/value'; - - my %extra = @_; - my $ua = $self->{ua}; - - foreach my $key (keys %extra) - { - # The implementation in HTTP::Tiny uses + instead of %20, fix that - $extra{$key} = $ua->_uri_escape($extra{$key}); - $extra{$key} =~ s/\+/%20/g; - } - - my $params = join '&', map { "$_=" . $extra{$_} } sort keys %extra; - - return $params; - } - - - # /source/{author}/{release}/{path} - sub source { - my $self = shift; - my %opts = @_ ? @_ : (); - my $url = ''; - my $error = "Provide 'author' and 'release' and 'path'"; - - %opts or croak $error; - - if ( - defined ( my $author = $opts{'author'} ) && - defined ( my $release = $opts{'release'} ) && - defined ( my $path = $opts{'path'} ) - ) { - $url = "source/$author/$release/$path"; - } else { - croak $error; - } - - $url = $self->{base_url} . "/$url"; - - my $result = $self->{ua}->get($url); - $result->{'success'} - or croak "Failed to fetch '$url': " . $result->{'reason'}; - - return $result->{'content'}; - } - - - # /release/{distribution} - # /release/{author}/{release} - sub release { - my $self = shift; - my %opts = @_ ? @_ : (); - my $url = ''; - my $error = "Either provide 'distribution', or 'author' and 'release', " . - "or 'search'"; - - %opts or croak $error; - - my %extra_opts = (); - - if ( defined ( my $dist = $opts{'distribution'} ) ) { - $url = "release/$dist"; - } elsif ( - defined ( my $author = $opts{'author'} ) && - defined ( my $release = $opts{'release'} ) - ) { - $url = "release/$author/$release"; - } elsif ( defined ( my $search_opts = $opts{'search'} ) ) { - ref $search_opts && ref $search_opts eq 'HASH' - or croak $error; - - %extra_opts = %{$search_opts}; - $url = 'release/_search'; - } else { - croak $error; - } - - return $self->fetch( $url, %extra_opts ); - } - - - # /pod/{module} - # /pod/{author}/{release}/{path} - sub pod { - my $self = shift; - my %opts = @_ ? @_ : (); - my $url = ''; - my $error = "Either provide 'module' or 'author and 'release' and 'path'"; - - %opts or croak $error; - - if ( defined ( my $module = $opts{'module'} ) ) { - $url = "pod/$module"; - } elsif ( - defined ( my $author = $opts{'author'} ) && - defined ( my $release = $opts{'release'} ) && - defined ( my $path = $opts{'path'} ) - ) { - $url = "pod/$author/$release/$path"; - } else { - croak $error; - } - - # check content-type - my %extra = (); - if ( defined ( my $type = $opts{'content-type'} ) ) { - $type =~ m{^ text/ (?: html|plain|x-pod|x-markdown ) $}x - or croak 'Incorrect content-type provided'; - - $extra{headers}{'content-type'} = $type; - } - - $url = $self->{base_url}. "/$url"; - - my $result = $self->{ua}->get( $url, \%extra ); - $result->{'success'} - or croak "Failed to fetch '$url': " . $result->{'reason'}; - - return $result->{'content'}; - } - - - # /module/{module} - sub module { - my $self = shift; - my $name = shift; - - $name or croak 'Please provide a module name'; - - return $self->fetch("module/$name"); - } - - - # file() is a synonym of module - sub file { goto &module } - - - # /author/{author} - sub author { - my $self = shift; - my ( $pause_id, $url, %extra_opts ); - - if ( @_ == 1 ) { - $url = 'author/' . shift; - } elsif ( @_ == 2 ) { - my %opts = @_; - - if ( defined $opts{'pauseid'} ) { - $url = "author/" . $opts{'pauseid'}; - } elsif ( defined $opts{'search'} ) { - my $search_opts = $opts{'search'}; - - ref $search_opts && ref $search_opts eq 'HASH' - or croak "'search' key must be hashref"; - - %extra_opts = %{$search_opts}; - $url = 'author/_search'; - } else { - croak 'Unknown option given'; - } - } else { - croak 'Please provide an author PAUSEID or a "search"'; - } - - return $self->fetch( $url, %extra_opts ); - } - - - - sub fetch { - my $self = shift; - my $url = shift; - my $extra = $self->_build_extra_params(@_); - my $base = $self->{base_url}; - my $req_url = $extra ? "$base/$url?$extra" : "$base/$url"; - - my $result = $self->{ua}->get($req_url); - return $self->_decode_result( $result, $req_url ); - } - - - sub post { - my $self = shift; - my $url = shift; - my $query = shift; - my $base = $self->{base_url}; - - defined $url - or croak 'First argument of URL must be provided'; - - ref $query and ref $query eq 'HASH' - or croak 'Second argument of query hashref must be provided'; - - my $query_json = encode_json( $query ); - my $result = $self->{ua}->request( - 'POST', - "$base/$url", - { - headers => { 'Content-Type' => 'application/json' }, - content => $query_json, - } - ); - - return $self->_decode_result( $result, $url, $query_json ); - } - - sub _decode_result { - my $self = shift; - my ( $result, $url, $original ) = @_; - my $decoded_result; - - ref $result and ref $result eq 'HASH' - or croak 'First argument must be hashref'; - - defined $url - or croak 'Second argument of a URL must be provided'; - - if ( defined ( my $success = $result->{'success'} ) ) { - my $reason = $result->{'reason'} || ''; - $reason .= ( defined $original ? " (request: $original)" : '' ); - - $success or croak "Failed to fetch '$url': $reason"; - } else { - croak 'Missing success in return value'; - } - - defined ( my $content = $result->{'content'} ) - or croak 'Missing content in return value'; - - eval { $decoded_result = decode_json $content; 1 } - or do { croak "Couldn't decode '$content': $@" }; - - return $decoded_result; - } - - 1; - - __END__ - - =pod - - =head1 NAME - - MetaCPAN::API::Tiny - A Tiny API client for MetaCPAN - - =head1 VERSION - - version 1.131730 - - =head1 DESCRIPTION - - This is the Tiny version of L<MetaCPAN::API>. It implements a compatible API - with a few notable exceptions: - - =over 4 - - =item Attributes are direct hash access - - The attributes defined using Mo(o|u)se are now accessed via the blessed hash - directly. There are no accessors defined to access this elements. - - =item Exception handling - - Instead of using Try::Tiny, raw evals are used. This could potentially cause - issues, so just be aware. - - =item Testing - - Test::Fatal was replaced with an eval implementation of exception(). - Test::TinyMocker usage is retained, but may be absorbed since it is pure perl - - =back - - =head1 CLASS_METHODS - - =head2 new - - new is the constructor for MetaCPAN::API::Tiny. In the non-tiny version of this - module, this is provided via Any::Moose built from the attributes defined. In - the tiny version, we define our own constructor. It takes the same arguments - and provides similar checks to MetaCPAN::API with regards to arguments passed. - - =head1 PUBLIC_METHODS - - =head2 source - - my $source = $mcpan->source( - author => 'DOY', - release => 'Moose-2.0201', - path => 'lib/Moose.pm', - ); - - Searches MetaCPAN for a module or a specific release and returns the plain source. - - =head2 release - - my $result = $mcpan->release( distribution => 'Moose' ); - - # or - my $result = $mcpan->release( author => 'DOY', release => 'Moose-2.0001' ); - - Searches MetaCPAN for a dist. - - You can do complex searches using 'search' parameter: - - # example lifted from MetaCPAN docs - my $result = $mcpan->release( - search => { - author => "OALDERS AND ", - filter => "status:latest", - fields => "name", - size => 1, - }, - ); - - =head2 pod - - my $result = $mcpan->pod( module => 'Moose' ); - - # or - my $result = $mcpan->pod( - author => 'DOY', - release => 'Moose-2.0201', - path => 'lib/Moose.pm', - ); - - Searches MetaCPAN for a module or a specific release and returns the POD. - - =head2 module - - my $result = $mcpan->module('MetaCPAN::API'); - - Searches MetaCPAN and returns a module's ".pm" file. - - =head2 file - - A synonym of L</module> - - =head2 author - - my $result1 = $mcpan->author('XSAWYERX'); - my $result2 = $mcpan->author( pauseid => 'XSAWYERX' ); - - Searches MetaCPAN for a specific author. - - You can do complex searches using 'search' parameter: - - # example lifted from MetaCPAN docs - my $result = $mcpan->author( - search => { - q => 'profile.name:twitter', - size => 1, - }, - ); - - =head2 fetch - - my $result = $mcpan->fetch('/release/distribution/Moose'); - - # with parameters - my $more = $mcpan->fetch( - '/release/distribution/Moose', - param => 'value', - ); - - This is a helper method for API implementations. It fetches a path from MetaCPAN, decodes the JSON from the content variable and returns it. - - You don't really need to use it, but you can in case you want to write your own extension implementation to MetaCPAN::API. - - It accepts an additional hash as "GET" parameters. - - =head2 post - - # /release&content={"query":{"match_all":{}},"filter":{"prefix":{"archive":"Cache-Cache-1.06"}}} - my $result = $mcpan->post( - 'release', - { - query => { match_all => {} }, - filter => { prefix => { archive => 'Cache-Cache-1.06' } }, - }, - ); - - The POST equivalent of the "fetch()" method. It gets the path and JSON request. - - =head1 THANKS - - Overall the tests and code were ripped directly from MetaCPAN::API and - tiny-fied. A big thanks to Sawyer X for writing the original module. - - =head1 AUTHOR - - Nicholas R. Perez <[email protected]> - - =head1 COPYRIGHT AND LICENSE - - This software is copyright (c) 2013 by Nicholas R. Perez <[email protected]>. - - This is free software; you can redistribute it and/or modify it under - the same terms as the Perl 5 programming language system itself. - - =cut -METACPAN_API_TINY - -s/^ //mg for values %fatpacked; - -unshift @INC, sub { - if (my $fat = $fatpacked{$_[1]}) { - if ($] < 5.008) { - return sub { - return 0 unless length $fat; - $fat =~ s/^([^\n]*\n?)//; - $_ = $1; - return 1; - }; - } - open my $fh, '<', \$fat - or die "FatPacker error loading $_[1] (could be a perl installation issue?)"; - return $fh; - } - return -}; - -} # END OF FATPACK CODE - - -use 5.010; -use strict; -use warnings; -use Fatal qw(open close); - -use Getopt::Long; -use Pod::Usage; -use File::Basename; -use Module::CoreList; -use HTTP::Tiny; -use Safe; -use MetaCPAN::API::Tiny; - -# Below, 5.024 should be aligned with the version of perl actually -# bundled in Buildroot: -die <<"MSG" if $] < 5.024; -This script needs a host perl with the same major version as Buildroot target perl. - -Your current host perl is: - $^X - version $] - -You may install a local one by running: - perlbrew install perl-5.24.0 -MSG - -my ($help, $man, $quiet, $force, $recommend, $test, $host); -my $target = 1; -GetOptions( 'help|?' => \$help, - 'man' => \$man, - 'quiet|q' => \$quiet, - 'force|f' => \$force, - 'host!' => \$host, - 'target!' => \$target, - 'recommend' => \$recommend, - 'test' => \$test -) or pod2usage(-exitval => 1); -pod2usage(-exitval => 0) if $help; -pod2usage(-exitval => 0, -verbose => 2) if $man; -pod2usage(-exitval => 1) if scalar @ARGV == 0; - -my %dist; # name -> metacpan data -my %need_target; # name -> 1 if target package is needed -my %need_host; # name -> 1 if host package is needed -my %need_dlopen; # name -> 1 if requires dynamic library -my %deps_build; # name -> list of host dependencies -my %deps_runtime; # name -> list of target dependencies -my %deps_optional; # name -> list of optional target dependencies -my %license_files; # name -> list of license files -my %checksum; # author -> list of checksum -my $mirror = 'http://cpan.metacpan.org'; # a CPAN mirror -my $mcpan = MetaCPAN::API::Tiny->new(base_url => 'http://fastapi.metacpan.org/v1'); -my $ua = HTTP::Tiny->new(); - -sub get_checksum { - my ($url) = @_; - my($path) = $url =~ m|^[^:/?#]+://[^/?#]*([^?#]*)|; - my($basename, $dirname) = fileparse( $path ); - unless ($checksum{$dirname}) { - my $url = $mirror . $dirname . q{CHECKSUMS}; - my $response = $ua->get($url); - $checksum{$dirname} = $response->{content}; - } - my $chksum = Safe->new->reval($checksum{$dirname}); - return $chksum->{$basename}, $basename; -} - -sub is_xs { - my ($manifest) = @_; - # This heuristic determines if a module is a native extension, by searching - # some file extension types in the MANIFEST of the distribution. - # It was inspired by http://deps.cpantesters.org/static/purity.html - return $manifest =~ m/\.(swg|xs|c|h|i)[\n\s]/; -} - -sub find_license_files { - my ($manifest) = @_; - my @license_files; - foreach (split /\n/, $manifest) { - next if m|/|; - push @license_files, $_ if m/(ARTISTIC|COPYING|COPYRIGHT|LICENSE)/i; - } - if (scalar @license_files == 0 && $manifest =~ m/(README)[\n\s]/i) { - @license_files = ($1); - } - return \@license_files; -} - -sub fetch { - my ($name, $need_target, $need_host, $top) = @_; - $need_target{$name} = $need_target if $need_target; - $need_host{$name} = $need_host if $need_host; - unless ($dist{$name} && !$top) { - say qq{fetch ${name}} unless $quiet; - my $result = $mcpan->release( distribution => $name ); - $dist{$name} = $result; - my $manifest = $mcpan->source( author => $result->{author}, - release => $name . q{-} . $result->{version}, - path => 'MANIFEST' ); - $need_dlopen{$name} = is_xs( $manifest ); - $license_files{$name} = find_license_files( $manifest ); - my %build = (); - my %runtime = (); - my %optional = (); - foreach my $dep (@{$result->{dependency}}) { - my $modname = ${$dep}{module}; - next if $modname eq q{perl}; - next if $modname =~ m|^Alien|; - next if $modname =~ m|^Win32|; - next if !($test && $top) && $modname =~ m|^Test|; - next if Module::CoreList::is_core( $modname, undef, $] ); - # we could use the host Module::CoreList data, because host perl and - # target perl have the same major version - next if ${$dep}{phase} eq q{develop}; - next if !($test && $top) && ${$dep}{phase} eq q{test}; - my $distname = $mcpan->module( $modname )->{distribution}; - if (${$dep}{phase} eq q{runtime}) { - if (${$dep}{relationship} eq q{requires}) { - $runtime{$distname} = 1; - } - else { - $optional{$distname} = 1 if $recommend && $top; - } - } - else { # configure, build - $build{$distname} = 1; - } - } - $deps_build{$name} = [keys %build]; - $deps_runtime{$name} = [keys %runtime]; - $deps_optional{$name} = [keys %optional]; - foreach my $distname (@{$deps_build{$name}}) { - fetch( $distname, 0, 1 ); - } - foreach my $distname (@{$deps_runtime{$name}}) { - fetch( $distname, $need_target, $need_host ); - $need_dlopen{$name} ||= $need_dlopen{$distname}; - } - foreach my $distname (@{$deps_optional{$name}}) { - fetch( $distname, $need_target, $need_host ); - } - } - return; -} - -foreach my $distname (@ARGV) { - # Command-line's distributions - fetch( $distname, !!$target, !!$host, 1 ); -} -say scalar keys %dist, q{ packages fetched.} unless $quiet; - -# Buildroot package name: lowercase -sub fsname { - my $name = shift; - $name =~ s|_|-|g; - return q{perl-} . lc $name; -} - -# Buildroot variable name: uppercase -sub brname { - my $name = shift; - $name =~ s|-|_|g; - return uc $name; -} - -while (my ($distname, $dist) = each %dist) { - my $fsname = fsname( $distname ); - my $dirname = q{package/} . $fsname; - my $cfgname = $dirname . q{/Config.in}; - my $mkname = $dirname . q{/} . $fsname . q{.mk}; - my $hashname = $dirname . q{/} . $fsname . q{.hash}; - my $brname = brname( $fsname ); - mkdir $dirname unless -d $dirname; - if ($need_target{$distname} && ($force || !-f $cfgname)) { - my $abstract = $dist->{abstract}; - my $homepage = $dist->{resources}->{homepage} || qq{https://metacpan.org/release/${distname}}; - say qq{write ${cfgname}} unless $quiet; - open my $fh, q{>}, $cfgname; - say {$fh} qq{config BR2_PACKAGE_${brname}}; - say {$fh} qq{\tbool "${fsname}"}; - say {$fh} qq{\tdepends on !BR2_STATIC_LIBS} if $need_dlopen{$distname}; - foreach my $dep (sort @{$deps_runtime{$distname}}) { - my $brdep = brname( fsname( $dep ) ); - say {$fh} qq{\tselect BR2_PACKAGE_${brdep}}; - } - say {$fh} qq{\thelp}; - say {$fh} qq{\t ${abstract}\n} if $abstract; - say {$fh} qq{\t ${homepage}}; - if ($need_dlopen{$distname}) { - say {$fh} qq{\ncomment "${fsname} needs a toolchain w/ dynamic library"}; - say {$fh} qq{\tdepends on BR2_STATIC_LIBS}; - } - close $fh; - } - if ($force || !-f $mkname) { - my $version = $dist->{version}; - my($path) = $dist->{download_url} =~ m|^[^:/?#]+://[^/?#]*([^?#]*)|; - # this URL contains only the scheme, auth and path parts (but no query and fragment parts) - # the scheme is not used, because the job is done by the BR download infrastructure - # the auth part is not used, because we use $(BR2_CPAN_MIRROR) - my($filename, $directories, $suffix) = fileparse( $path, q{tar.gz}, q{tgz} ); - $directories =~ s|/$||; - my $dependencies = join q{ }, map( { q{host-} . fsname( $_ ); } sort @{$deps_build{$distname}} ), - map( { fsname( $_ ); } sort @{$deps_runtime{$distname}} ); - my $host_dependencies = join q{ }, map { q{host-} . fsname( $_ ); } sort( @{$deps_build{$distname}}, - @{$deps_runtime{$distname}} ); - my $license = ref $dist->{license} eq 'ARRAY' - ? join q{ or }, @{$dist->{license}} - : $dist->{license}; - # BR requires license name as in http://spdx.org/licenses/ - $license =~ s|apache_2_0|Apache-2.0|; - $license =~ s|artistic_2|Artistic-2.0|; - $license =~ s|mit|MIT|; - $license =~ s|openssl|OpenSSL|; - $license =~ s|perl_5|Artistic or GPL-1.0+|; - my $license_files = join q{ }, @{$license_files{$distname}}; - say qq{write ${mkname}} unless $quiet; - open my $fh, q{>}, $mkname; - say {$fh} qq{################################################################################}; - say {$fh} qq{#}; - say {$fh} qq{# ${fsname}}; - say {$fh} qq{#}; - say {$fh} qq{################################################################################}; - say {$fh} qq{}; - say {$fh} qq{${brname}_VERSION = ${version}}; - say {$fh} qq{${brname}_SOURCE = ${distname}-\$(${brname}_VERSION).${suffix}}; - say {$fh} qq{${brname}_SITE = \$(BR2_CPAN_MIRROR)${directories}}; - say {$fh} qq{${brname}_DEPENDENCIES = ${dependencies}} if $need_target{$distname} && $dependencies; - say {$fh} qq{HOST_${brname}_DEPENDENCIES = ${host_dependencies}} if $need_host{$distname} && $host_dependencies; - say {$fh} qq{${brname}_LICENSE = ${license}} if $license && $license ne q{unknown}; - say {$fh} qq{${brname}_LICENSE_FILES = ${license_files}} if $license_files; - say {$fh} qq{}; - foreach (sort @{$deps_optional{$distname}}) { - next if grep { $_ eq $distname; } @{$deps_runtime{$_}}; # avoid cyclic dependencies - my $opt_brname = brname( $_ ); - my $opt_fsname = fsname( $_ ); - say {$fh} qq{ifeq (\$(BR2_PACKAGE_PERL_${opt_brname}),y)}; - say {$fh} qq{${brname}_DEPENDENCIES += ${opt_fsname}}; - say {$fh} qq{endif}; - say {$fh} qq{}; - } - say {$fh} qq{\$(eval \$(perl-package))} if $need_target{$distname}; - say {$fh} qq{\$(eval \$(host-perl-package))} if $need_host{$distname}; - close $fh; - } - if ($force || !-f $hashname) { - my($checksum, $filename) = get_checksum($dist->{download_url}); - my $md5 = $checksum->{md5}; - my $sha256 = $checksum->{sha256}; - say qq{write ${hashname}} unless $quiet; - open my $fh, q{>}, $hashname; - say {$fh} qq{# retrieved by scancpan from ${mirror}/}; - say {$fh} qq{md5 ${md5} ${filename}}; - say {$fh} qq{sha256 ${sha256} ${filename}}; - close $fh; - } -} - -my %pkg; -my $cfgname = q{package/Config.in}; -if (-f $cfgname) { - open my $fh, q{<}, $cfgname; - while (<$fh>) { - chomp; - $pkg{$_} = 1 if m|package/perl-|; - } - close $fh; -} - -foreach my $distname (keys %need_target) { - my $fsname = fsname( $distname ); - $pkg{qq{\tsource "package/${fsname}/Config.in"}} = 1; -} - -say qq{${cfgname} must contain the following lines:}; -say join qq{\n}, sort keys %pkg; - -__END__ - -=head1 NAME - -support/scripts/scancpan Try-Tiny Moo - -=head1 SYNOPSIS - -supports/scripts/scancpan [options] [distname ...] - - Options: - -help - -man - -quiet - -force - -target/-notarget - -host/-nohost - -recommend - -test - -=head1 OPTIONS - -=over 8 - -=item B<-help> - -Prints a brief help message and exits. - -=item B<-man> - -Prints the manual page and exits. - -=item B<-quiet> - -Executes without output - -=item B<-force> - -Forces the overwriting of existing files. - -=item B<-target/-notarget> - -Switches package generation for the target variant (the default is C<-target>). - -=item B<-host/-nohost> - -Switches package generation for the host variant (the default is C<-nohost>). - -=item B<-recommend> - -Adds I<recommended> dependencies. - -=item B<-test> - -Adds dependencies for test. - -=back - -=head1 DESCRIPTION - -This script creates templates of the Buildroot package files for all the -Perl/CPAN distributions required by the specified distnames. The -dependencies and metadata are fetched from https://metacpan.org/. - -After running this script, it is necessary to check the generated files. -You have to manually add the license files (PERL_FOO_LICENSE_FILES variable). -For distributions that link against a target library, you have to add the -buildroot package name for that library to the DEPENDENCIES variable. - -See the Buildroot documentation for details on the usage of the Perl -infrastructure. - -The major version of the host perl must be aligned on the target one, -in order to work with the right CoreList data. - -=head1 LICENSE - -Copyright (C) 2013-2016 by Francois Perrad <[email protected]> - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 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 -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -This script is a part of Buildroot. - -This script requires the module C<MetaCPAN::API::Tiny> (version 1.131730) -which was included at the beginning of this file by the tool C<fatpack>. - -See L<http://search.cpan.org/~nperez/MetaCPAN-API-Tiny-1.131730/>. - -See L<http://search.cpan.org/search?query=App-FatPacker&mode=dist>. - -These both libraries are free software and may be distributed under the same -terms as perl itself. - -And perl may be distributed under the terms of Artistic v1 or GPL v1 license. - -=cut
support/scripts/scancpan new file +1 -0
@@ -0,0 +1 @@ +../../tools/scancpan
tools/readme.txt +4 -0
@@ -17,6 +17,10 @@ get-developpers of Buildroot, so they can be Cc:ed on a mail. Accepts a patch as input, a package name or and architecture name. +scancpan + a script to create a Buildroot package by scanning a CPAN module + description. + size-stat-compare a script to compare the rootfs size between two differnt Buildroot configurations. This can be used to identify the size impact of
tools/scancpan new file +858 -0
858 lines not on this page · raw message
Signature · 1 line
2.11.0
PATCH v3 7/8 tools: move scanpypi out of support/scripts/
In reply to Yann E. MORINMove it to the top-level tools/ directory, so that it is easier to find for users.
Add a legacy symlink for those users who already used them, so as not to break their habits.
--- support/scripts/scanpypi | 654 +---------------------------------------------- tools/readme.txt | 4 + tools/scanpypi | 653 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 658 insertions(+), 653 deletions(-) mode change 100755 => 120000 support/scripts/scanpypi create mode 100755 tools/scanpypi
support/scripts/scanpypi deleted +0 -653
@@ -1,653 +0,0 @@ -#!/usr/bin/env python2 -""" - -Utility for building Buildroot packages for existing PyPI packages - -Any package built by scanpypi should be manually checked for -errors. -""" -from __future__ import print_function -import argparse -import json -import urllib2 -import sys -import os -import shutil -import StringIO -import tarfile -import zipfile -import errno -import hashlib -import re -import textwrap -import tempfile -import imp -from functools import wraps - -def setup_decorator(func, method): - """ - Decorator for distutils.core.setup and setuptools.setup. - Puts the arguments with which setup is called as a dict - Add key 'method' which should be either 'setuptools' or 'distutils'. - - Keyword arguments: - func -- either setuptools.setup or distutils.core.setup - method -- either 'setuptools' or 'distutils' - """ - - @wraps(func) - def closure(*args, **kwargs): - # Any python packages calls its setup function to be installed. - # Argument 'name' of this setup function is the package's name - BuildrootPackage.setup_args[kwargs['name']] = kwargs - BuildrootPackage.setup_args[kwargs['name']]['method'] = method - return closure - -# monkey patch -import setuptools -setuptools.setup = setup_decorator(setuptools.setup, 'setuptools') -import distutils -distutils.core.setup = setup_decorator(setuptools.setup, 'distutils') - -def find_file_upper_case(filenames, path='./'): - """ - List generator: - Recursively find files that matches one of the specified filenames. - Returns a relative path starting with path argument. - - Keyword arguments: - filenames -- List of filenames to be found - path -- Path to the directory to search - """ - for root, dirs, files in os.walk(path): - for file in files: - if file.upper() in filenames: - yield (os.path.join(root, file)) - - -def pkg_buildroot_name(pkg_name): - """ - Returns the Buildroot package name for the PyPI package pkg_name. - Remove all non alphanumeric characters except - - Also lowers the name and adds 'python-' suffix - - Keyword arguments: - pkg_name -- String to rename - """ - name = re.sub('[^\w-]', '', pkg_name.lower()) - prefix = 'python-' - pattern = re.compile('^(?!' + prefix + ')(.+?)$') - name = pattern.sub(r'python-\1', name) - return name - -class DownloadFailed(Exception): - pass - -class BuildrootPackage(): - """This class's methods are not meant to be used individually please - use them in the correct order: - - __init__ - - download_package - - extract_package - - load_module - - get_requirements - - create_package_mk - - create_hash_file - - create_config_in - - """ - setup_args = {} - - def __init__(self, real_name, pkg_folder): - self.real_name = real_name - self.buildroot_name = pkg_buildroot_name(self.real_name) - self.pkg_dir = os.path.join(pkg_folder, self.buildroot_name) - self.mk_name = self.buildroot_name.upper().replace('-', '_') - self.as_string = None - self.md5_sum = None - self.metadata = None - self.metadata_name = None - self.metadata_url = None - self.pkg_req = None - self.setup_metadata = None - self.tmp_extract = None - self.used_url = None - self.filename = None - self.url = None - self.version = None - - def fetch_package_info(self): - """ - Fetch a package's metadata from the python package index - """ - self.metadata_url = 'https://pypi.python.org/pypi/{pkg}/json'.format( - pkg=self.real_name) - try: - pkg_json = urllib2.urlopen(self.metadata_url).read().decode() - except urllib2.HTTPError as error: - print('ERROR:', error.getcode(), error.msg, file=sys.stderr) - print('ERROR: Could not find package {pkg}.\n' - 'Check syntax inside the python package index:\n' - 'https://pypi.python.org/pypi/ ' - .format(pkg=self.real_name)) - raise - except urllib2.URLError: - print('ERROR: Could not find package {pkg}.\n' - 'Check syntax inside the python package index:\n' - 'https://pypi.python.org/pypi/ ' - .format(pkg=self.real_name)) - raise - self.metadata = json.loads(pkg_json) - self.version = self.metadata['info']['version'] - self.metadata_name = self.metadata['info']['name'] - - def download_package(self): - """ - Download a package using metadata from pypi - """ - try: - self.metadata['urls'][0]['filename'] - except IndexError: - print( - 'Non-conventional package, ', - 'please check carefully after creation') - self.metadata['urls'] = [{ - 'packagetype': 'sdist', - 'url': self.metadata['info']['download_url'], - 'md5_digest': None}] - # In this case, we can't get the name of the downloaded file - # from the pypi api, so we need to find it, this should work - urlpath = urllib2.urlparse.urlparse( - self.metadata['info']['download_url']).path - # urlparse().path give something like - # /path/to/file-version.tar.gz - # We use basename to remove /path/to - self.metadata['urls'][0]['filename'] = os.path.basename(urlpath) - for download_url in self.metadata['urls']: - if 'bdist' in download_url['packagetype']: - continue - try: - print('Downloading package {pkg} from {url}...'.format( - pkg=self.real_name, url=download_url['url'])) - download = urllib2.urlopen(download_url['url']) - except urllib2.HTTPError as http_error: - download = http_error - else: - self.used_url = download_url - self.as_string = download.read() - if not download_url['md5_digest']: - break - self.md5_sum = hashlib.md5(self.as_string).hexdigest() - if self.md5_sum == download_url['md5_digest']: - break - else: - if download.__class__ == urllib2.HTTPError: - raise download - raise DownloadFailed('Failed to downloas package {pkg}' - .format(pkg=self.real_name)) - self.filename = self.used_url['filename'] - self.url = self.used_url['url'] - - def extract_package(self, tmp_path): - """ - Extract the package contents into a directrory - - Keyword arguments: - tmp_path -- directory where you want the package to be extracted - """ - as_file = StringIO.StringIO(self.as_string) - if self.filename[-3:] == 'zip': - with zipfile.ZipFile(as_file) as as_zipfile: - tmp_pkg = os.path.join(tmp_path, self.buildroot_name) - try: - os.makedirs(tmp_pkg) - except OSError as exception: - if exception.errno != errno.EEXIST: - print("ERROR: ", exception.message, file=sys.stderr) - return None, None - print('WARNING:', exception.message, file=sys.stderr) - print('Removing {pkg}...'.format(pkg=tmp_pkg)) - shutil.rmtree(tmp_pkg) - os.makedirs(tmp_pkg) - as_zipfile.extractall(tmp_pkg) - else: - with tarfile.open(fileobj=as_file) as as_tarfile: - tmp_pkg = os.path.join(tmp_path, self.buildroot_name) - try: - os.makedirs(tmp_pkg) - except OSError as exception: - if exception.errno != errno.EEXIST: - print("ERROR: ", exception.message, file=sys.stderr) - return None, None - print('WARNING:', exception.message, file=sys.stderr) - print('Removing {pkg}...'.format(pkg=tmp_pkg)) - shutil.rmtree(tmp_pkg) - os.makedirs(tmp_pkg) - as_tarfile.extractall(tmp_pkg) - - tmp_extract = '{folder}/{name}-{version}' - self.tmp_extract = tmp_extract.format( - folder=tmp_pkg, - name=self.metadata_name, - version=self.version) - - def load_setup(self): - """ - Loads the corresponding setup and store its metadata - """ - current_dir = os.getcwd() - os.chdir(self.tmp_extract) - sys.path.append(self.tmp_extract) - s_file, s_path, s_desc = imp.find_module('setup', [self.tmp_extract]) - setup = imp.load_module('setup', s_file, s_path, s_desc) - try: - self.setup_metadata = self.setup_args[self.metadata_name] - except KeyError: - # This means setup was not called which most likely mean that it is - # called through the if __name__ == '__main__' directive. - # In this case, we can only pray that it is called through a - # function called main() in setup.py. - setup.main([]) # Will raise AttributeError if not found - self.setup_metadata = self.setup_args[self.metadata_name] - # Here we must remove the module the hard way. - # We must do this because of a very specific case: if a package calls - # setup from the __main__ but does not come with a 'main()' function, - # for some reason setup.main([]) will successfully call the main - # function of a previous package... - sys.modules.pop('setup',None) - del setup - os.chdir(current_dir) - sys.path.remove(self.tmp_extract) - - def get_requirements(self, pkg_folder): - """ - Retrieve dependencies from the metadata found in the setup.py script of - a pypi package. - - Keyword Arguments: - pkg_folder -- location of the already created packages - """ - if 'install_requires' not in self.setup_metadata: - self.pkg_req = None - return set() - self.pkg_req = self.setup_metadata['install_requires'] - self.pkg_req = [re.sub('([-.\w]+).*', r'\1', req) - for req in self.pkg_req] - req_not_found = self.pkg_req - self.pkg_req = map(pkg_buildroot_name, self.pkg_req) - pkg_tuples = zip(req_not_found, self.pkg_req) - # pkg_tuples is a list of tuples that looks like - # ('werkzeug','python-werkzeug') because I need both when checking if - # dependencies already exist or are already in the download list - req_not_found = set( - pkg[0] for pkg in pkg_tuples - if not os.path.isdir(pkg[1]) - ) - return req_not_found - - def __create_mk_header(self): - """ - Create the header of the <package_name>.mk file - """ - header = ['#' * 80 + '\n'] - header.append('#\n') - header.append('# {name}\n'.format(name=self.buildroot_name)) - header.append('#\n') - header.append('#' * 80 + '\n') - header.append('\n') - return header - - def __create_mk_download_info(self): - """ - Create the lines refering to the download information of the - <package_name>.mk file - """ - lines = [] - version_line = '{name}_VERSION = {version}\n'.format( - name=self.mk_name, - version=self.version) - lines.append(version_line) - - targz = self.filename.replace( - self.version, - '$({name}_VERSION)'.format(name=self.mk_name)) - targz_line = '{name}_SOURCE = {filename}\n'.format( - name=self.mk_name, - filename=targz) - lines.append(targz_line) - - if self.filename not in self.url: - # Sometimes the filename is in the url, sometimes it's not - site_url = self.url - else: - site_url = self.url[:self.url.find(self.filename)] - site_line = '{name}_SITE = {url}'.format(name=self.mk_name, - url=site_url) - site_line = site_line.rstrip('/') + '\n' - lines.append(site_line) - return lines - - def __create_mk_setup(self): - """ - Create the line refering to the setup method of the package of the - <package_name>.mk file - - There are two things you can use to make an installer - for a python package: distutils or setuptools - distutils comes with python but does not support dependencies. - distutils is mostly still there for backward support. - setuptools is what smart people use, - but it is not shipped with python :( - """ - lines = [] - setup_type_line = '{name}_SETUP_TYPE = {method}\n'.format( - name=self.mk_name, - method=self.setup_metadata['method']) - lines.append(setup_type_line) - return lines - - def __create_mk_license(self): - """ - Create the lines referring to the package's license informations of the - <package_name>.mk file - - The license is found using the metadata from pypi. - In the metadata, the license can be found either with standard names in - the classifiers part or with naming from the packager in the "License" - part. - - From the classifiers, the license is "translated" according to - buildroot standards if need be (i.e. from Apache Software License to - Apache-2.0). - - From the License part, we cannot guess what formatting the packager - used. Hence, it is likely to be incorrect. (i.e. Apache License 2.0 - instead of Apache-2.0). - - The license's files are found by searching the package for files named - license or license.txt (case insensitive). - If more than one license file is found, the user is asked to select - which ones he wants to use. - """ - license_dict = { - 'Apache Software License': 'Apache-2.0', - 'BSD License': 'BSD', - 'European Union Public Licence 1.0': 'EUPL-1.0', - 'European Union Public Licence 1.1': 'EUPL-1.1', - "GNU General Public License": "GPL", - "GNU General Public License v2": "GPL-2.0", - "GNU General Public License v2 or later": "GPL-2.0+", - "GNU General Public License v3": "GPL-3.0", - "GNU General Public License v3 or later": "GPL-3.0+", - "GNU Lesser General Public License v2": "LGPL-2.1", - "GNU Lesser General Public License v2 or later": "LGPL-2.1+", - "GNU Lesser General Public License v3": "LGPL-3.0", - "GNU Lesser General Public License v3 or later": "LGPL-3.0+", - "GNU Library or Lesser General Public License": "LGPL-2.0", - "ISC License": "ISC", - "MIT License": "MIT", - "Mozilla Public License 1.0": "MPL-1.0", - "Mozilla Public License 1.1": "MPL-1.1", - "Mozilla Public License 2.0": "MPL-2.0", - "Zope Public License": "ZPL" - } - regexp = re.compile('^License :* *.* *:+ (.*)( \(.*\))?$') - classifiers_licenses = [regexp.sub(r"\1", lic) - for lic in self.metadata['info']['classifiers'] - if regexp.match(lic)] - licenses = map(lambda x: license_dict[x] if x in license_dict else x, - classifiers_licenses) - lines = [] - if not len(licenses): - print('WARNING: License has been set to "{license}". It is most' - ' likely wrong, please change it if need be'.format( - license=', '.join(licenses))) - licenses = [self.metadata['info']['license']] - license_line = '{name}_LICENSE = {license}\n'.format( - name=self.mk_name, - license=', '.join(licenses)) - lines.append(license_line) - - filenames = ['LICENCE', 'LICENSE', 'LICENSE.TXT', 'COPYING', - 'COPYING.TXT'] - license_files = list(find_file_upper_case(filenames, self.tmp_extract)) - license_files = [license.replace(self.tmp_extract, '')[1:] - for license in license_files] - if len(license_files) > 0: - if len(license_files) > 1: - print('More than one file found for license:', - ', '.join(license_files)) - license_files = [filename - for index, filename in enumerate(license_files)] - license_file_line = ('{name}_LICENSE_FILES =' - ' {files}\n'.format( - name=self.mk_name, - files=' '.join(license_files))) - lines.append(license_file_line) - else: - print('WARNING: No license file found,' - ' please specify it manually afterwards') - license_file_line = '# No license file found\n' - - return lines - - def __create_mk_requirements(self): - """ - Create the lines referring to the dependencies of the of the - <package_name>.mk file - - Keyword Arguments: - pkg_name -- name of the package - pkg_req -- dependencies of the package - """ - lines = [] - dependencies_line = ('{name}_DEPENDENCIES =' - ' {reqs}\n'.format( - name=self.mk_name, - reqs=' '.join(self.pkg_req))) - lines.append(dependencies_line) - return lines - - def create_package_mk(self): - """ - Create the lines corresponding to the <package_name>.mk file - """ - pkg_mk = '{name}.mk'.format(name=self.buildroot_name) - path_to_mk = os.path.join(self.pkg_dir, pkg_mk) - print('Creating {file}...'.format(file=path_to_mk)) - lines = self.__create_mk_header() - lines += self.__create_mk_download_info() - lines += self.__create_mk_setup() - lines += self.__create_mk_license() - - lines.append('\n') - lines.append('$(eval $(python-package))') - lines.append('\n') - with open(path_to_mk, 'w') as mk_file: - mk_file.writelines(lines) - - def create_hash_file(self): - """ - Create the lines corresponding to the <package_name>.hash files - """ - pkg_hash = '{name}.hash'.format(name=self.buildroot_name) - path_to_hash = os.path.join(self.pkg_dir, pkg_hash) - print('Creating {filename}...'.format(filename=path_to_hash)) - lines = [] - if self.used_url['md5_digest']: - md5_comment = '# md5 from {url}, sha256 locally computed\n'.format( - url=self.metadata_url) - lines.append(md5_comment) - hash_line = '{method}\t{digest} {filename}\n'.format( - method='md5', - digest=self.used_url['md5_digest'], - filename=self.filename) - lines.append(hash_line) - digest = hashlib.sha256(self.as_string).hexdigest() - hash_line = '{method}\t{digest} {filename}\n'.format( - method='sha256', - digest=digest, - filename=self.filename) - lines.append(hash_line) - - with open(path_to_hash, 'w') as hash_file: - hash_file.writelines(lines) - - def create_config_in(self): - """ - Creates the Config.in file of a package - """ - path_to_config = os.path.join(self.pkg_dir, 'Config.in') - print('Creating {file}...'.format(file=path_to_config)) - lines = [] - config_line = 'config BR2_PACKAGE_{name}\n'.format( - name=self.mk_name) - lines.append(config_line) - - bool_line = '\tbool "{name}"\n'.format(name=self.buildroot_name) - lines.append(bool_line) - if self.pkg_req: - for dep in self.pkg_req: - dep_line = '\tselect BR2_PACKAGE_{req} # runtime\n'.format( - req=dep.upper().replace('-', '_')) - lines.append(dep_line) - - lines.append('\thelp\n') - - help_lines = textwrap.wrap(self.metadata['info']['summary'], - initial_indent='\t ', - subsequent_indent='\t ') - - # make sure a help text is terminated with a full stop - if help_lines[-1][-1] != '.': - help_lines[-1] += '.' - - # \t + two spaces is 3 char long - help_lines.append('') - help_lines.append('\t ' + self.metadata['info']['home_page']) - help_lines = map(lambda x: x + '\n', help_lines) - lines += help_lines - - with open(path_to_config, 'w') as config_file: - config_file.writelines(lines) - - -def main(): - # Building the parser - parser = argparse.ArgumentParser( - description="Creates buildroot packages from the metadata of " - "an existing PyPI packages and include it " - "in menuconfig") - parser.add_argument("packages", - help="list of packages to be created", - nargs='+') - parser.add_argument("-o", "--output", - help=""" - Output directory for packages. - Default is ./package - """, - default='./package') - - args = parser.parse_args() - packages = list(set(args.packages)) - - # tmp_path is where we'll extract the files later - tmp_prefix = 'scanpypi-' - pkg_folder = args.output - tmp_path = tempfile.mkdtemp(prefix=tmp_prefix) - try: - for real_pkg_name in packages: - package = BuildrootPackage(real_pkg_name, pkg_folder) - print('buildroot package name for {}:'.format(package.real_name), - package.buildroot_name) - # First we download the package - # Most of the info we need can only be found inside the package - print('Package:', package.buildroot_name) - print('Fetching package', package.real_name) - try: - package.fetch_package_info() - except (urllib2.URLError, urllib2.HTTPError): - continue - if package.metadata_name.lower() == 'setuptools': - # setuptools imports itself, that does not work very well - # with the monkey path at the begining - print('Error: setuptools cannot be built using scanPyPI') - continue - - try: - package.download_package() - except urllib2.HTTPError as error: - print('Error: {code} {reason}'.format(code=error.code, - reason=error.reason)) - print('Error downloading package :', package.buildroot_name) - print() - continue - - # extract the tarball - try: - package.extract_package(tmp_path) - except (tarfile.ReadError, zipfile.BadZipfile): - print('Error extracting package {}'.format(package.real_name)) - print() - continue - - # Loading the package install info from the package - try: - package.load_setup() - except ImportError as err: - if 'buildutils' in err.message: - print('This package needs buildutils') - else: - raise - continue - except AttributeError: - print('Error: Could not install package {pkg}'.format( - pkg=package.real_name)) - continue - - # Package requirement are an argument of the setup function - req_not_found = package.get_requirements(pkg_folder) - req_not_found = req_not_found.difference(packages) - - packages += req_not_found - if req_not_found: - print('Added packages \'{pkgs}\' as dependencies of {pkg}' - .format(pkgs=", ".join(req_not_found), - pkg=package.buildroot_name)) - print('Checking if package {name} already exists...'.format( - name=package.pkg_dir)) - try: - os.makedirs(package.pkg_dir) - except OSError as exception: - if exception.errno != errno.EEXIST: - print("ERROR: ", exception.message, file=sys.stderr) - continue - print('Error: Package {name} already exists' - .format(name=package.pkg_dir)) - del_pkg = raw_input( - 'Do you want to delete existing package ? [y/N]') - if del_pkg.lower() == 'y': - shutil.rmtree(package.pkg_dir) - os.makedirs(package.pkg_dir) - else: - continue - package.create_package_mk() - - package.create_hash_file() - - package.create_config_in() - print() - # printing an empty line for visual confort - finally: - shutil.rmtree(tmp_path) - -if __name__ == "__main__": - main()
support/scripts/scanpypi new file +1 -0
@@ -0,0 +1 @@ +../../tools/scanpypi
tools/readme.txt +4 -0
@@ -21,6 +21,10 @@ scancpan a script to create a Buildroot package by scanning a CPAN module description. +scanpypi + a script to create a Buildroot package by scanning a PyPI package + description. + size-stat-compare a script to compare the rootfs size between two differnt Buildroot configurations. This can be used to identify the size impact of
tools/scanpypi new file +653 -0
653 lines not on this page · raw message
Signature · 1 line
2.11.0
PATCH v3 8/8 tools move xorg-release out of support/scripts/
In reply to Yann E. MORINMove it to the top-level tools/ directory, so that it is easier to find for users.
Add a legacy symlink for those users who already used them, so as not to break their habits.
--- support/scripts/xorg-release | 181 +------------------------------------------ tools/readme.txt | 4 + tools/xorg-release | 180 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 185 insertions(+), 180 deletions(-) mode change 100755 => 120000 support/scripts/xorg-release create mode 100755 tools/xorg-release
support/scripts/xorg-release deleted +0 -180
@@ -1,180 +0,0 @@ -#!/usr/bin/env python - -# This script generates a report on the packaging status of X.org -# releases in Buildroot. It does so by downloading the list of -# tarballs that are part of a given X.org release, and compare that -# with the packages that are available in Buildroot. - -import BeautifulSoup -import re -import os -import urllib -from distutils.version import LooseVersion - -# This can be customized -XORG_VERSION = "X11R7.7" - -# Key names in dictionaries -XORG_VERSION_KEY = "xorg-version" -BR_VERSION_KEY = "br-version" -BR_NAME_KEY = "br-name" - -# Packages part of X.org releases that we do not want to package in -# Buildroot (old drivers for hardware unlikely to be used in embedded -# contexts). -XORG_EXCEPTIONS = [ - 'xf86-video-suncg6', - 'xf86-video-sunffb', -] - -# Get the list of tarballs of a X.org release, parse it, and return a -# dictionary of dictionaries, of the form: -# -# { <name_of_package> : { XORG_VERSION_KEY: <version_of_package> }, -# <name_of_package2> : { XORG_VERSION_KEY: <version_of_package2> }} -# -def get_xorg_release_pkgs(): - u = urllib.URLopener().open("http://www.x.org/releases/%s/src/everything/" % XORG_VERSION) - b = BeautifulSoup.BeautifulSoup() - b.feed(u.read()) - links = b.findAll("a") - packages = {} - r = re.compile("(.*)-([0-9\.]*).tar.bz2") - # We now have a list of all links. - for link in links: - href = link.get("href") - # Skip everything but tarballs - if not href.endswith(".tar.bz2"): - continue - # Separate the name and the version - groups = r.match(href) - if not groups: - continue - name = groups.group(1) - version = groups.group(2) - # Skip packages we don't want to hear about - if name in XORG_EXCEPTIONS: - continue - packages[name] = { XORG_VERSION_KEY : version } - return packages - -# Files and directories in package/x11r7/ that should be ignored in -# our processing. -BUILDROOT_EXCEPTIONS = [ - "mcookie", # Code is directly in package directory - "x11r7.mk", - "Config.in", - "xdriver_xf86-input-tslib", # From Pengutronix, not part of X.org releases -] - -# Prefixes of directories in package/x11r7/ that must be stripped -# before trying to match Buildroot package names with X.org tarball -# names. -BUILDROOT_PREFIXES = [ - "xapp", - "xdriver", - "xfont", - "xlib", - "xserver", - "xutil", - "xproto", -] - -# From a Buildroot package name, try to see if a prefix should be -# stripped from it. For example, passing "xapp_xlsfonts" as argument -# to this function will return "xlsfonts". -def buildroot_strip_prefix(dirname): - for prefix in BUILDROOT_PREFIXES: - if dirname.startswith(prefix + "_"): - return dirname[len(prefix) + 1:] - return dirname - -# From a Buildroot package name, parse its .mk file to find the -# Buildroot version of the package by looking at the <foo>_VERSION -# line. -def buildroot_get_version(dirname): - f = open(os.path.join("package", "x11r7", dirname, dirname + ".mk")) - r = re.compile("^([A-Z0-9_]*)_VERSION = ([0-9\.]*)$") - for l in f.readlines(): - m = r.match(l) - if m: - return m.group(2) - return None - -# Augment the information of the X.org list of packages (given as -# argument) by details about their packaging in Buildroot. Those -# details are found by looking at the contents of package/x11r7/. -def get_buildroot_pkgs(packages): - dirs = os.listdir(os.path.join(os.getcwd(), "package", "x11r7")) - for d in dirs: - # Skip exceptions - if d in BUILDROOT_EXCEPTIONS: - continue - pkgname = buildroot_strip_prefix(d) - version = buildroot_get_version(d) - if packages.has_key(pkgname): - # There is a X.org package of the same name, so we just - # add information to the existing dict entry. - packages[pkgname]['br-version'] = version - packages[pkgname]['br-name'] = d - else: - # There is no X.org package with this name, so we add a - # new dict entry. - packages[pkgname] = { BR_VERSION_KEY: version, - BR_NAME_KEY : d } - return packages - -def show_summary(packages): - FORMAT_STRING = "%40s | %15s | %15s | %-30s" - print FORMAT_STRING % ("Package name", "Vers in BR", "Vers in X.org", "Action") - print FORMAT_STRING % ("-" * 40, "-" * 15, "-" * 15, "-" * 30) - pkgs = packages.keys() - pkgs.sort() - total_pkgs = 0 - upgrade_pkgs = 0 - add_pkgs = 0 - remove_pkgs = 0 - nothing_todo_pkgs = 0 - for pkgname in pkgs: - pkg = packages[pkgname] - total_pkgs += 1 - if pkg.has_key(XORG_VERSION_KEY) and not pkg.has_key(BR_VERSION_KEY): - xorg_version = pkg[XORG_VERSION_KEY] - br_version = "N/A" - action = "Add to Buildroot" - add_pkgs += 1 - elif not pkg.has_key(XORG_VERSION_KEY) and pkg.has_key(BR_VERSION_KEY): - br_version = pkg[BR_VERSION_KEY] - xorg_version = "N/A" - action = "Remove from Buildroot" - remove_pkgs += 1 - elif LooseVersion(pkg[XORG_VERSION_KEY]) > LooseVersion(pkg[BR_VERSION_KEY]): - br_version = pkg[BR_VERSION_KEY] - xorg_version = pkg[XORG_VERSION_KEY] - action = "Upgrade" - upgrade_pkgs += 1 - elif LooseVersion(pkg[XORG_VERSION_KEY]) < LooseVersion(pkg[BR_VERSION_KEY]): - br_version = pkg[BR_VERSION_KEY] - xorg_version = pkg[XORG_VERSION_KEY] - action = "More recent" - nothing_todo_pkgs += 1 - else: - br_version = pkg[BR_VERSION_KEY] - xorg_version = pkg[XORG_VERSION_KEY] - action = "" - nothing_todo_pkgs += 1 - - print FORMAT_STRING % (pkgname, br_version.center(15), xorg_version.center(15), action) - print FORMAT_STRING % ("-" * 40, "-" * 15, "-" * 15, "-" * 30) - STAT_FORMAT_STRING = "%40s : %3d" - print STAT_FORMAT_STRING % ("Total number of packages", total_pkgs) - print STAT_FORMAT_STRING % ("Packages to upgrade", upgrade_pkgs) - print STAT_FORMAT_STRING % ("Packages to add", add_pkgs) - print STAT_FORMAT_STRING % ("Packages to remove", remove_pkgs) - print STAT_FORMAT_STRING % ("Packages with nothing to do", nothing_todo_pkgs) - -packages = get_xorg_release_pkgs() -packages = get_buildroot_pkgs(packages) -# print packages -show_summary(packages) -
support/scripts/xorg-release new file +1 -0
@@ -0,0 +1 @@ +../../tools/xorg-release
tools/readme.txt +4 -0
@@ -34,3 +34,7 @@ test-pkg a script that tests a specific package against a set of various toolchains, with the goal to detect toolchain-related dependencies (wchar, threads...) + +xorg-release + a script to check which Xorg-related packages in Buildroot need + being updated or added, when a new Xorg release comes out.
tools/xorg-release new file +180 -0
180 lines not on this page · raw message
Signature · 1 line
2.11.0
PATCH v3 5/8 tools: move size-stat-compare out of support/scripts/
In reply to Yann E. MORINHi Yann,
2017-06-30 23:50 GMT+02:00 Yann E. MORIN <[email protected]>:
Quoted 18 lines
Move it to the top-level
tools/directory, so that it is easier to find for users.Add a legacy symlink for those users who already used them, so as not to break their habits.
Signed-off-by "Yann E. MORIN" <[email protected]>Cc Thomas De Schampheleire <[email protected]>Cc Thomas Petazzoni <[email protected]>Cc Arnout Vandecappelle <[email protected]>--- support/scripts/size-stats-compare | 128 +------------------------------------ tools/readme.txt | 5 ++ tools/size-stats-compare | 127 ++++++++++++++++++++++++++++++++++++ 3 files changed, 133 insertions(+), 127 deletions(-) mode change 100755 => 120000 support/scripts/size-stats-compare create mode 100755 tools/size-stats-compare
[..]
tools/readme.txt get-developpers · line 21
Quoted 10 lines
tools/readme.txt +2
-0@@ -17,6 +17,11 @@ get-developpers of Buildroot, so they can be Cc:ed on a mail. Accepts a patch as input, a package name or and architecture name. +size-stat-compare + a script to compare the rootfs size between two differnt Buildroot
different
tools/readme.txt get-developpers · line 23
Quoted 2 lines
tools/readme.txt +2
-0+ configurations. This can be used to identify the size impact of + a specific option, or of a set of specific options.
I would also add that it is useful when upgrading Buildroot release, as is done in the description inside the script.
This is in fact the use case I originally wrote it for.
Best regards,
Thomas
PATCH v3 1/8 tools: add a directory to store some useful user-facing tools
In reply to Yann E. MORINQuoted 66 lines · Yann E. MORIN
Add a tools directory to store useful little scripts, tools, etc... Users may add that directory in their PATH if they want to, but this is not mandatory.
Add the first tool: brmake, a small script that redirects the build output log to a file, keeping just Buildroot's own messages, with the date+time added at the start of the line.
We need to unbuffer the output of make so that, when the script is interrupted (SIGINT, ^C), there is no lingering output not yet digested by the logger loop.
Signed-off-by "Yann E. MORIN" <[email protected]>Cc Maxime Hadjinlian <[email protected]>Cc Arnout Vandecappelle <[email protected]>Cc Ricardo Martincoski <[email protected]>---
Changes v2 -> v3:
- detect unconfigured build tree (Ricardo)
- rename 00-README -> readme.txt (Thomas, Arnout)Changes v1 -> v2:
- rename contrib -> tools (Arnout)
- detect missing unbuffer (Arnout)Notes:
- Arnout suggested using 'stdbuf' instead of 'unbuffer', but that has some shortcomings in weird corner-cases because it usesLD_PRELOADto call a constructor that forces settings on stdout/stderr/stdin (it cost me three days to investigate a build failure because of that). So, I stuck with 'unbuffer'...
- I also tried to use bash' coproc, but it seems there was a regression in later bash versions that causes an incorrect redirect. So, I stuck with 'unbuffer'...--- docs/manual/writing-rules.txt | 5 ++-- tools/brmake | 62 +++++++++++++++++++++++++++++++++++++++++++ tools/readme.txt | 9 +++++++ 3 files changed, 74 insertions(+), 2 deletions(-) create mode 100755 tools/brmake create mode 100644 tools/readme.txtdocs/manual/writing-rules.txt +3
-2@@ -146,5 +146,6 @@ syntax, refer to http://www.methods.co.nz/asciidoc/userguide.html[]. === Support scripts -Some scripts in the +support/+ directory are written in Python and should follow -the https://www.python.org/dev/peps/pep-0008/[PEP8 Style Guide for Python Code]. +Some scripts in the +support/+ and +tools/+ directories are written in +Python and should follow the +https://www.python.org/dev/peps/pep-0008/[PEP8 Style Guide for Python Code].tools/brmake new file +4
-0@@ -0,0 +1,62 @@ +#!/bin/bash +# (C) 2016, "Yann E. MORIN" <[email protected]> +# License: WTFPL, https://spdx.org/licenses/WTFPL.html +
tools/brmake line 14
Quoted 10 lines
tools/brmake new file +10
-0+main() { + local found ret start d h m mf cdir odir + + if ! which unbuffer >/dev/null 2>&1; then + printf "you need to install 'unbuffer' (from package expect or expect-dev)\n" >&2 + exit 1 + fi + + # Crude parsing to find the directory with the .config + # and catch any configurator
I don't like it. It's making the script a lot more complicated, and we're not
even sure that there aren't some corner cases that we're missing here. So I would just remove from here...
Quoted 12 lines
tools/brmake new file +12
-0+ found=false + for i in "${@}"; do + ${found} && { cdir="${i}"; found=false; continue; } + case "${i}" in + (-C|--directory) found=true;; + (-C*) cdir="${i#-C}";; + (--directory=*) cdir="${i#--directory}";; + (O=*) odir="${i#O=}";; + # Other configurators are either non-interactive, or graphical + # apps, so their stdout can safely be redirected. + (config|menuconfig|nconfig|oldconfig) + printf "you can't use brmake for '%s'\n" "${i}" >&2
tools/brmake line 36
Quoted 10 lines
tools/brmake new file +10
-0+ exit 1 + ;; + esac + done + # We favour O= if specified, then -C, and fallback to cwd. + dir="${odir:-${cdir:-$(pwd)}}" + if [ ! -e "${dir}/.config" ]; then + # No .config, don't log as we need a terminal for menuconfig + exec make "${@}" + fi
... to here, and instead...
Quoted 32 lines
tools/brmake new file +26
-0+ + start=${SECONDS} + + ( exec 2>&1; unbuffer make "${@}"; ) \ + > >( while read line; do + printf "%(%Y-%m-%dT%H:%M:%S)T %s\n" -1 "${line}" + done \ + |tee -a br.log \ + |grep --colour=never -E '>>>' + ) + ret=${?} + + d=$((SECONDS-start)) + printf "Done in " + h=$((d/3600)) + d=$((d%3600)) + [ ${h} -eq 0 ] || { printf "%dh " ${h}; mf="02"; } + m=$((d/60)) + d=$((d%60)) + [ ${m} -eq 0 ] || { printf "%${mf}dmin " ${m}; sf="02"; } + printf "%${sf}ds\n" ${d} + + return ${ret} +} + +main "${@}"tools/readme.txt new file +0
-0
tools/readme.txt line 9
Quoted 9 lines
tools/readme.txt new file +9
-0@@ -0,0 +1,9 @@ +This directory contains various useful scripts and tools for working +with Buildroot. You need not add this directory in your PATH to use +any of those tools, but you may do so if you want. + +brmake + a script that can be run instead of make, that prepends the date in + front of each line, redirects all of the build output to a file + ("'br.log' in the current directory), and just outputs the Buildroot + messages (those lines starting with >>>) on stdout.
...add some text here:
Do not run this script for interactive configuration (e.g. menuconfig) or on an unconfigured directory. The output is redirected so you will see nothing.
Perhaps we should also remove the "feature" that menuconfig is the default
target on an unconfigured tree. I'll create a patch for that.
Regards,
Arnout
Signature · 6 lines
Arnout Vandecappelle arnout at mind be Senior Embedded Software Architect +32-16-286500 Essensium/Mind http://www.mind.be G.Geenslaan 9, 3001 Leuven, Belgium BE 872 984 063 RPR Leuven LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle GPG fingerprint: 7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF
PATCH v3 1/8 tools: add a directory to store some useful user-facing tools
In reply to Yann E. MORINHi Yann,
On Fri, Jun 30, 2017 at 11:50 PM, Yann E. MORIN <[email protected]> wrote:
[...]
Quoted 17 lines
tools/brmake new file +11
-0@@ -0,0 +1,62 @@ +#!/bin/bash +# (C) 2016, "Yann E. MORIN" <[email protected]> +# License: WTFPL, https://spdx.org/licenses/WTFPL.html + +main() { + local found ret start d h m mf cdir odir + + if ! which unbuffer >/dev/null 2>&1; then + printf "you need to install 'unbuffer' (from package expect or expect-dev)\n" >&2 + exit 1 + fi
tools/brmake line 21
Quoted 10 lines
tools/brmake new file +10
-0+ + # Crude parsing to find the directory with the .config + # and catch any configurator + found=false + for i in "${@}"; do + ${found} && { cdir="${i}"; found=false; continue; } + case "${i}" in + (-C|--directory) found=true;; + (-C*) cdir="${i#-C}";; + (--directory=*) cdir="${i#--directory}";;
You also need to strip the '='.
Quoted 59 lines
tools/brmake new file +41
-0+ (O=*) odir="${i#O=}";; + # Other configurators are either non-interactive, or graphical + # apps, so their stdout can safely be redirected. + (config|menuconfig|nconfig|oldconfig) + printf "you can't use brmake for '%s'\n" "${i}" >&2 + exit 1 + ;; + esac + done + # We favour O= if specified, then -C, and fallback to cwd. + dir="${odir:-${cdir:-$(pwd)}}" + if [ ! -e "${dir}/.config" ]; then + # No .config, don't log as we need a terminal for menuconfig + exec make "${@}" + fi + + start=${SECONDS} + + ( exec 2>&1; unbuffer make "${@}"; ) \ + > >( while read line; do + printf "%(%Y-%m-%dT%H:%M:%S)T %s\n" -1 "${line}" + done \ + |tee -a br.log \ + |grep --colour=never -E '>>>' + ) + ret=${?} + + d=$((SECONDS-start)) + printf "Done in " + h=$((d/3600)) + d=$((d%3600)) + [ ${h} -eq 0 ] || { printf "%dh " ${h}; mf="02"; } + m=$((d/60)) + d=$((d%60)) + [ ${m} -eq 0 ] || { printf "%${mf}dmin " ${m}; sf="02"; } + printf "%${sf}ds\n" ${d} + + return ${ret} +} + +main "${@}"tools/readme.txt new file +9
-1@@ -0,0 +1,9 @@ +This directory contains various useful scripts and tools for working +with Buildroot. You need not add this directory in your PATH to use +any of those tools, but you may do so if you want. + +brmake + a script that can be run instead of make, that prepends the date in + front of each line, redirects all of the build output to a file + ("'br.log' in the current directory), and just outputs the Buildroot + messages (those lines starting with >>>) on stdout. --2.11.0
Quoted 4 lines
_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot
Regards,
Signature · 1 line
Samuel