Commit Graph

334 Commits

Author SHA1 Message Date
Yann E. MORIN
39643530f5 utils/check-package: don't ignore check-package
Commit 32934b526b (utils/checkpackagelib: check for Upstream trailers)
introduced a new python module to check Upstream tags in patch files. In
doing so, it introduced a flake8 coding style issue. That was not caught
when applying the change, and neither was it caught by our daily checks,
because the .checkpackagefile was regenerated right just in the next
commit, to apply ignore patterns to existing patch files.

It is a bit sad that one of our checks does not itself passes all our
checks...

Fix that trivial issue now.

Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
(cherry picked from commit 81bb14a935)
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
2024-04-28 14:11:15 +02:00
Fabrice Fontaine
6ee61ef95b utils/genrandconfig: fix BR2_TOOLCHAIN_BARE_METAL_BUILDROOT_ARCH
Commit b7232c51dd added default setting
for bare-metal toolchain arch but unfortunately it used configlines.add
instead of configlines.append resulting in the following build failure:

/bin/sh: line 8: /home/autobuild/autobuild/instance-1/output-1/per-package/host-gcc-bare-metal/host/bin/-ar: No such file or directory

While at it, also append /n for consistency

Fixes: b7232c51dd
 - http://autobuild.buildroot.org/results/95ac565653ddb5c14ec71470c32a34ad10b048cb

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
2024-03-01 09:13:34 +01:00
Yann E. MORIN
fcf465d04b utils/checkpackagelib: add check for CPE variables set to default values
Now that we can specify that the default values for the CPE_ID variables
are valid, without having to actually set one (or more) to their
default, add a check-package check that validates that the CPE_ID
variables are indeed not set to their default.

It also validates that CPE_ID_VALID is not set when another CPE_ID
variable is set to a non-default value.

Add an anchor in the manual so that we can easily point to it.

Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
Cc: Fabrice Fontaine <fontaine.fabrice@gmail.com>
Cc: Ricardo Martincoski <ricardo.martincoski@gmail.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
2024-02-11 16:30:59 +01:00
Yann E. MORIN
dfed5acb56 utils/check-package: use https for the manual URL
Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
2024-02-11 16:28:10 +01:00
James Hilliard
c12e1c7b59 utils/scanpypi: use a set comprehension for dependencies
This ensures that we don't have duplicate dependencies.

Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
2024-02-07 19:58:28 +01:00
Thomas Petazzoni
b7232c51dd utils/genrandconfig: add default setting for bare-metal toolchain arch
We recently added support for building a bare-metal toolchain, and the
autobuilders are therefore trying to build such toolchains. However,
by default the BR2_TOOLCHAIN_BARE_METAL_BUILDROOT_ARCH option is
empty, causing the target tuple to be empty, and therefore
host-gcc-bare-metal tries to build a toolchain for the target
"x86_64-pc-linux-gnu", which isn't a bare-metal target, and fails
badly.

In order to properly test this bare-metal support, this commit adjusts
the genrandconfig script so that it injects a valid target
architecture tuple.

Fixes:

  http://autobuild.buildroot.net/results/6cb1514b19bfe056fb984d3538bdccdda5e174c1/

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
2024-02-07 10:23:48 +01:00
Neal Frager
7befbaaea7 toolchain/toolchain-bare-metal-buildroot: new toolchain
This patch adds a new virtual package for adding a bare-metal
toolchain to Buildroot. For now, it depends on nothing, so it will not
actually build anything, but it defines some options that will be
needed by the various packages that will be part of this toolchain
build process.

Signed-off-by: Neal Frager <neal.frager@amd.com>
Signed-off-by: Ibai Erkiaga <ibai.erkiaga-elorza@amd.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
2024-02-06 17:57:17 +01:00
Marcus Hoffmann
21d89a5b86 utils/readme.txt: document docker-run script
Signed-off-by: Marcus Hoffmann <buildroot@bubu1.eu>
[yann.morin.1998@free.fr: the default is an interactive shell]
Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
2024-02-06 17:02:03 +01:00
Marcus Hoffmann
fba40a9f39 utils/readme.txt: expand check-package description
check-package does a lot more by now than checking .mk and
Config.in files. Add this to the description.

Signed-off-by: Marcus Hoffmann <buildroot@bubu1.eu>
Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
2024-02-06 17:02:02 +01:00
James Hilliard
e241419490 utils/scanpypi: add flit package support
These packages don't have a setup.py so we instead need to parse their
pyproject.toml file.

It is possible that such a package does not define a project_urls config
item, so ensure we do not choke on it (None.get() would raise).

Note that this currently doesn't handle flit package dependency
resolution.

Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
Reviewed-by: Yegor Yefremov <yegorslists@googlemail.com>
[yann.morin.1998@free.fr:
  - add sentence about the project_urls rewrite
  - fix flake8 errors
]
Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
2023-11-25 12:47:10 +01:00
Peter Korsgaard
4984d0f230 utils/add-custom-hashes: add script to manage global patch dir hashes
Add a script to manage the .hash files in the BR2_GLOBAL_PATCH_DIR for
packages using custom versions.

To use it, run in a configured Buildroot directory, E.G.

  make foo_defconfig; ./utils/add-custom-hashes

We support multiple patch directories in BR2_GLOBAL_PATCH_DIR.  If multiple
directories are specified then use the last one as that is likely to be the
most specific one.

Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
[Peter: silence command -v invocation]
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
2023-11-12 11:59:27 +01:00
Yann E. MORIN
8f60241530 utils/docker-run: propagate user's proxy settings
When dealing with enterprise-grade networks, it is more often than not
the case that the wider internet is unreachable but through proxies.

There is a usual set of variables that users can set in the
environment to point various tools (curl, git...) to use those
proxies.

Propagate those variables inside the container.

Note that there are a few tools (e.g. cvs, svn) that may not recognise
those variables; instead, they require custom setup that is too
complex to handle, so is left as an exercise to interested parties.

Similarly, there are other types of proxy, socks4 or socks5, that also
require custom setup that is not trivial to replicate in a container,
so is also left out as an exercise for interested parties.

In the large majority of cases, those few variables are enough to Make
Things Work™.

Signed-off-by: Yann E. MORIN <yann.morin@orange.com>
Cc: Ricardo Martincoski <ricardo.martincoski@datacom.com.br>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
2023-11-04 18:42:48 +01:00
Yann E. MORIN
893bd56974 utils/docker: use host's network setup
Our utils/docker-run wrapper is needed to provide a reproducible build
environment: tools, variables, etc... but is not meant for
isolation. As such, we do not care which network configuration is
used.

In some settings (e.g. enterprise networks), it is often the case that
a VPN is in use, especially in those wonderful times of widespread
remote work.

Letting Docker decide on the network setup will most usually lead to
it creating a private network that is NATed onto the principal network
interface, leading to non-functional network in the container when a
VPN is in use.

As such, always use the host network configuration, and do not let
Docker create a private network for the container.

Signed-off-by: Yann E. MORIN <yann.morin@orange.com>
Cc: Ricardo Martincoski <ricardo.martincoski@datacom.com.br>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
2023-11-04 18:42:13 +01:00
Daniel Lang
7bc5ea80c7 utils/getdeveloperlib.py: handle file removal
If a patch only removes files, it is ignored. Meaning, that the
registered developer isn't automatically picked up when calling
get-developer.
Fix this by also checking if the line starts with ---, as a patch
removing a file has a line starting with --- with the name of the
removed file and one started with +++ /dev/null.
A set is used to store the changed files, which doesn't allow
duplicates. Therefore normal patches aren't affected by this change.

Signed-off-by: Daniel Lang <dalang@gmx.at>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
2023-09-11 22:08:22 +02:00
James Knight
2be2ccb487 utils/check-package: cleanup line reading
Cleanup the implementation for reading lines by having files processed
in context managers and utilizing the iterable file object for line
reading (instead of needing to call `readlines()`).

Signed-off-by: James Knight <james.d.knight@live.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
2023-09-02 17:47:48 +02:00
Yann E. MORIN
2423d9f16b Release 2023.08-rc2
-----BEGIN PGP SIGNATURE-----
 
 iG8EABECADAWIQSrB9gG0s50H7iG7lCwJbqLWcNjGQUCZOKHvRIcamFjbWV0QHVj
 bGliYy5vcmcACgkQsCW6i1nDYxn1/QCg2un/vUk0HEIbpn4d1fMRZFBDSlwAmKRp
 iO+4qkBgt1h+2LxZSJmNbPY=
 =nvGJ
 -----END PGP SIGNATURE-----

Merge tag '2023.08-rc2' into next

Conflicts:
  - .checkpackageignore
  - Makefile
  - board/versal/post-image.sh
  - package/sentry-cli/0001-Disable-SSL-support-for-the-curl-module.patch
      => keep version in next

  - Config.in.legacy
      => merge, introduce legacy comment for 2023.11

  - toolchain/toolchain-external/toolchain-external-bootlin/Config.in.options
      => regenerate, drop dependency on inexistant BR2_ARCH_NEEDS_GCC_AT_LEAST_14

Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
2023-08-21 21:36:17 +02:00
Thomas Petazzoni
80a1e728b0 utils/docker-run: allow IMAGE to be passed in the environment
It is sometimes useful to use docker-run, but with a different image
than the default one. This commit allows to override the image being
used by only defining IMAGE if not already passed in the environment.

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
[yann.morin.1998@free.fr: s/\t/    /g]
Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
2023-08-20 16:20:57 +02:00
Yann E. MORIN
3b877dc7c2 utils/docker-run: make it compatible with SELinux
After switching to a fresh Fedora 38 installation with SELinux disabled,
we noticed that utils/docker-run doesn't work as the applications
running inside the container are not allowed to accept the data mounted
through the bind mount.

Since we do not really need to isolate and confine the build, but rather
to provide a known environment, we don;t really need to enforce any
SELinux confinment in the container.

So, we tell docker to turn off label confinement for the container:

    https://manpages.org/docker-run

    --security-opt=[]
      Security Options
        [...]
        "label=disable"     : Turn off label confinement for the container

Suggested-by: Antoine Tenart <atenart@kernel.org>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
[yann.morin.1998@free.fr: use Antoine's proposal]
Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
2023-08-20 16:20:54 +02:00
Yann E. MORIN
db777eef13 utils/docker-run: also mount current working directory
Currently, using utils/docker-run expects that the current working
directory is the working copy. This means that it is not possible
to use docker-run with an out-of-tree build (one using O=).

Add the current working directory to the list of mountpoints, and
use that as working directory in the container.

Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
2023-08-20 16:20:51 +02:00
Nicolas Boichat
e71fb8f71c utils/docker-run: bind mount .git/objects if needed
If buildroot is checked out as part of a 'repo' manifest, docker-run
doesn't fully bind mount the .git directory, leading to commands such
as `utils/docker-run make check-package` to fail.

Signed-off-by: Nicolas Boichat <drinkcat@google.com>
[yann.morin.1998@free.fr: use newly introduced mountpoints list]
Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
2023-08-20 16:20:48 +02:00
Thomas Petazzoni
7fddbe2530 utils/docker-run: mount the download directory if specified
If the user has defined $BR2_DL_DIR in the environment, it would be
nice to have it accessible inside the Docker container, and the
BR2_DL_DIR environment variable set to access it.

This commit does exactly this: it mounts the host $BR2_DL_DIR as /dl
in the container, and sets BR2_DL_DIR=/dl in the container.

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
[yann.morin.1998@free.fr: use the new mountpoints list]
Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
2023-08-20 16:20:45 +02:00
Yann E. MORIN
f4b798120b utils/docker-run: introduce sorted list of mountpoints
For now, we only ever mount two mountpoints, the main directory (i.e.
the working copy), and the git directory.

To pave the way for adding new mountpoints, we introduce a list of them,
that we sort to ensure that we never mount a shallower mounpoint after a
deeper one (that would shadow the deeper mountpoint).

Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
2023-08-20 16:20:42 +02:00
Fabrice Fontaine
283e6859f1 utils/genrandconfig: add ubi handling
Add a custom case to make sure that a random configuration with an empty
configuration file for ubi doesn't fail.

ubinize: error!: no sections found the ini-file "/home/buildroot/autobuild/instance-2/output-1/build/ubinize.cfg"

Fixes:
 - http://autobuild.buildroot.org/results/f678c17cc4df06fb2737467e769cd8f72a3ea420

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
2023-08-12 22:06:21 +02:00
Yann E. MORIN
a845276757 utils/genradconfig: drop legacy lpc32xxcdl exclusion
Commit 503252d8b0 (boot/lpc32xxcdl: remove package) forgot to remove
the special handling in genrandconfig. Since the package no longer
exists, we don't need to special-case its symbol anymore, so drop it
now.

Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
2023-08-10 19:45:19 +02:00
Thomas Petazzoni
503252d8b0 boot/lpc32xxcdl: remove package
This package has dubious licensing conditions (not even documented in
the .mk file), and is a bootloader for very old platforms. The
defconfigs making use of it have been removed in Buildroot in 2014, in
commit c6a410964b ("configs: remove
lpc32xx defconfigs"), so let's get rid of the package.

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Acked-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
[yann.morin.1998@free.fr: remove reference in test]
Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
2023-08-10 19:41:42 +02:00
Yann E. MORIN
5b559109ee utils/docker-run: fix running when CWD is not MAIN_DIR
Commit 9079079092 (utils/docker-run: fix support for git-worktrees)
got last-minute changes when it was applied, and the case when the
current working directory is not the top of the current working copy
got broken.

Fix that by duplicating (and thus reinstating) the 'cd MAIN_DIR' to
match what is done when retrieving the git-common-dir.

Fixes: 9079079092

Reported-by: Brandon Maier <Brandon.Maier@collins.com>
Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
2023-07-31 20:56:57 +02:00
Brandon Maier
9079079092 utils/docker-run: fix support for git-worktrees
The docker-run script attempts to support git-new-workdirs and
git-worktrees by resolving the symlink at '$GIT_DIR/config' to get the
true $GIT_DIR. However this does not work for git-worktrees as they do
not use symlinks, instead they change the $GIT_DIR into a regular file
that contains the path to the real $GIT_DIR. To complicate things
further, we actually want the $GIT_COMMON_DIR which is the superset of a
worktree's $GIT_DIR.

git-rev-parse supports the '--git-common-dir' which will resolve the
$GIT_COMMON_DIR for us. However it does not work for git-new-workdirs,
so we still need to detect and handle them.

'--git-common-dir' also appeared only with git 2.10.0, released in 2016,
so it will not be available in older "enterprise-grade" distributions.
In that case, 'git rev-parse --git-common-dir' would return the option
flag '--git-common-dir' as-is, which is incorrect. So, we instruct it to
never return flags.

'--git-common-dir' also returns just '.git' for the main working copy,
but 'docker run' want an absolute path, so we canonicalise it.

Signed-off-by: Brandon Maier <brandon.maier@collins.com>
[yann.morin.1998@free.fr:
  - support git versions before --git-common-dir was introduced
  - don't mount GIT_DIR if unknown (i.e. not needed)
  - fix expanding MAIN_DIR
]
Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
2023-07-29 17:22:40 +02:00
Bernd Kuhls
9b31b64382 utils/genrandconfig: increase default target ubifs image size
The new value is calculated based on:
ROOTFS_SIZE = 5G (see commit 3c98eb26db)
BR2_TARGET_ROOTFS_UBIFS_LEBSIZE = 0x1f800

5G / 0x1f800 = 41610

Fixes:
http://autobuild.buildroot.net/results/f72/f72918d63510b170e5da01bfa9c247cf9dcf507f/

Signed-off-by: Bernd Kuhls <bernd@kuhls.net>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
2023-07-14 23:26:09 +02:00
Bernd Kuhls
af5ccec266 utils/genrandconfig: disable cramfs images
Fixes build error:

  warning: estimate of required size (upper bound) is 1374MB, but
  maximum image size is 272MB, we might die prematurely
  mkcramfs: filesystem too big

Fixes:
http://autobuild.buildroot.net/results/d47/d47f9b462707dffe1b6665f143701303b04e2adc/

Signed-off-by: Bernd Kuhls <bernd@kuhls.net>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
2023-07-09 18:30:10 +02:00
Yann E. MORIN
791c163b2f utils/docker-run: make it work in workdirs/woktrees
It is quite customary to use a single repository with multiple workdirs,
one for each active branch, with either the aging 'git new-workdir' or
the more recent 'git worktree'.

However, in a workdir/worktree, most entries in .git/ are only symlinks
to the actual files in the main repository.

Currently, utils/docker-run only bind-mounts the current working copy.
If that is a workdir/worktree, then it is going to be missing the actual
git data, resulting in errors like:

    $ ./utils/docker-run make check-package
    fatal: not a git repository (or any parent up to mount point [....]/buildroot)
    Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
    No files to check style
    make: *** [Makefile:1257: check-package] Error 1

So, we also bind-mount the actual git directory. If that is a subdir
of the current working copy, then it is already mounted and thus the
bind-mount is superfluous but harmless; for simplicity, we mount it
unconditionally.

Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
Cc: Ricardo Martincoski <ricardo.martincoski@datacom.com.br>
2023-05-13 12:09:32 +02:00
Yann E. MORIN
5eac4f81eb utils/check-package: check ignored files exist
When an ignored file is removed (e.g. a package patch is no longer
needed after a version bump), the corresponding entry in the ignore list
is no longer needed.

However, we currently only validate that an ignored *test* still fails,
not that a ignore files is now missing.

Add a new test to check-package that does that check, and add a
test-case for that check.

Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
Cc: Ricardo Martincoski <ricardo.martincoski@gmail.com>
2023-05-13 12:08:25 +02:00
Yann E. MORIN
a3e796b74e utils/check-package: fix grammar
The past participle for "to fix" is "fix". The "did you forget" got
eluded into "forget", so again a past participle.

Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
2023-04-23 21:49:46 +02:00
Yann E. MORIN
3d8212c4b2 utils/docker-run: allow running without a tty
Currently, utils/docker-run spawns a container with a tty, so that he
user can interact properly in the container.

However, that requires a tty when calling docker-run, which is not
always guaranteed, e.g. if called from a git hook.

Since the script is a bash script already, we can use an array to store
options passed to docker, and only add the -t option when there is
actually a tty available.

Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
Cc: Ricardo Martincoski <ricardo.martincoski@gmail.com>
2023-04-23 19:34:00 +02:00
Vincent Fazio
32934b526b utils/checkpackagelib: check for Upstream trailers
Implement a check-package check for an Upstream: trailer in patches
being applied to packages per a mailing list discussion [0].

No strict formatting checks are implemented for the contents within the
trailer as the needed level of detail will vary patch-to-patch.

Tested with: `./utils/docker-run python3 -m pytest utils/checkpackagelib`

[0] https://lists.buildroot.org/pipermail/buildroot/2023-March/666016.html

Signed-off-by: Vincent Fazio <vfazio@gmail.com>
Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
2023-04-15 19:36:50 +02:00
Vincent Fazio
b7d4ae98fa utils/check-package: drop six usage
The shebang in check-package now defines python3. There is no longer a
need to maintain support with python 2.x.

See-also: 02b165dc71 (check-package: fix Python3 support)

Signed-off-by: Vincent Fazio <vfazio@gmail.com>
Tested-by: James Knight <james.d.knight@live.com>
Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
2023-04-10 21:02:35 +02:00
Ricardo Martincoski
29a0dd4a30 utils/checkpackagelib: warn about $(HOST_DIR)/usr
It's been ages (5 years at the next release) that we've not installed
host packages in $(HOST_DIR)/usr, but we still have a few packages that
reference it or install things in there. See [1]

Add a new check_function that warns when a file is added installing to
or referencing $(HOST_DIR)/usr .

[1] "d9ff62c4cd pacakge: drop remnants of $(HOST_DIR)/usr"

Cc: Yann E. MORIN <yann.morin.1998@free.fr>
Signed-off-by: Ricardo Martincoski <ricardo.martincoski@gmail.com>
[Arnout: exclude skeleton.mk with disable comment instead of explicit
         code]
Signed-off-by: Arnout Vandecappelle <arnout@mind.be>
2023-04-09 22:56:16 +02:00
Ricardo Martincoski
9df6503ed0 Makefile: merge check-flake8 into check-package
Teach check-package to detect python files by type and check them using
flake8.
Do not use subprocess to call 'python3 -m flake8' in order to avoid too
many spawned shells, which in its turn would slow down the check for
multiple files. (make check-package takes twice the time using a shell
for each flake8 call, when compared of importing the main application)

Expand the runtime test and the unit tests for check-package.

Remove check-flake8 from the makefile and also from the GitLab CI
because the exact same checks become part of check-package.

Suggested-by: Arnout Vandecappelle <arnout@mind.be>
Signed-off-by: Ricardo Martincoski <ricardo.martincoski@gmail.com>
[Arnout: add a comment to x-python to explain its purpose]
Signed-off-by: Arnout Vandecappelle <arnout@mind.be>
2023-04-09 22:33:24 +02:00
Ricardo Martincoski
60fdaf56fe utils/check-package: check files in support/
The .mk files inside both support/dependencies and support/misc are not
package recipes, similar to package/pkg-*.mk. The check-package don't
apply to them. Therefore ignore such files.

In the test infra, some br2-externals are used as fixtures to provide
(sometimes) failure cases, so ignore files in these directories.

Files inside support/kconfig are files copied from linux upstream, so do
not generate warnings for them.

support/gnuconfig contains auto-generated config.{guess,sub} files,
so do not generate shellcheck warnings for them.

Signed-off-by: Ricardo Martincoski <ricardo.martincoski@gmail.com>
Signed-off-by: Arnout Vandecappelle <arnout@mind.be>
2023-04-09 21:59:04 +02:00
Ricardo Martincoski
29d6f319a0 utils/check-package: check files in board/
When a SysV init script is inside package/ it doesn't need to be
executable. However, when an init script is inside a fs_overlay, it
*does* need to be executable. Therefore, skip the NotExecutable test for
init scripts. We detect them based on the directory /etc/init.d

Signed-off-by: Ricardo Martincoski <ricardo.martincoski@gmail.com>
[Arnout: update .checkpackageignore]
Signed-off-by: Arnout Vandecappelle <arnout@mind.be>
2023-04-09 21:51:11 +02:00
Fabrice Fontaine
ad4982d18e utils/genrandconfig: add boot-wrapper-aarch64 handling
Fix the following build failure raised since the addition of the package
in commit 7689b72e00:

configure: error: Could not find DTB file: /home/autobuild/autobuild/instance-9/output-1/build/linux-6.1.9/arch/arm64/boot/dts/.dtb

Fixes:
 - http://autobuild.buildroot.org/results/44287ccc8cc9767704642919e6d928d1f57b436d

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
2023-02-27 16:22:54 +01:00
Fabrice Fontaine
5e1a50e4e6 utils/genrandconfig: add lpc32xxcdl handling
Fix the following build failure raised since the addition of the package
in commit 20695936ad:

make[2]: *** /tmp/instance-0/output-1/build/lpc32xxcdl-2.11/csps/lpc32xx/bsps//source: No such file or directory.  Stop.

Fixes:
 - http://autobuild.buildroot.org/results/72c9a4080318b1b247ca3517c95c689dff1068d2

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
2023-02-25 21:53:48 +01:00
Fabrice Fontaine
02b6af2663 utils/genrandconfig: add ti-k3-r5-loader handling
Fix the following build failure raised since the addition of the package
in commit 0189bcb47c:

make[2]: *** No rule to make target '_defconfig'.  Stop.

Fixes:
 - http://autobuild.buildroot.org/results/d7449b2b2f2349af672bfeee832b89a223a7d9cc

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
2023-02-25 10:39:05 +01:00
Ricardo Martincoski
2b021bc1d7 utils/check-package: check files in utils/
All the errors in existing scripts in utils/ have been fixed, so nothing
needs to be added to .checkpackageignore.

Signed-off-by: Ricardo Martincoski <ricardo.martincoski@gmail.com>
Signed-off-by: Arnout Vandecappelle <arnout@mind.be>
2023-02-08 15:28:33 +01:00
Arnout Vandecappelle
dab7a87714 utils/docker-run: fix shellcheck errors
In utils/test-pkg line 8:
    if [ ! -z "${TEMP_CONF}" ]; then
         ^-- SC2236: Use -n instead of ! -z.

In utils/test-pkg line 75:
        TEMP_CONF=$(mktemp /tmp/test-${pkg}-config.XXXXXX)
                                     ^----^ SC2086: Double quote to prevent globbing and word splitting.

Did you mean:
        TEMP_CONF=$(mktemp /tmp/test-"${pkg}"-config.XXXXXX)

In utils/test-pkg line 76:
        echo "${pkg_br_name}=y" > ${TEMP_CONF}
                                  ^----------^ SC2086: Double quote to prevent globbing and word splitting.

Did you mean:
        echo "${pkg_br_name}=y" > "${TEMP_CONF}"

In utils/test-pkg line 86:
    if [ ${random} -gt 0 ]; then
         ^-------^ SC2086: Double quote to prevent globbing and word splitting.

Did you mean:
    if [ "${random}" -gt 0 ]; then

In utils/test-pkg line 90:
    if [ ${number} -gt 0 ]; then
         ^-------^ SC2086: Double quote to prevent globbing and word splitting.

Did you mean:
    if [ "${number}" -gt 0 ]; then

In utils/test-pkg line 109:
    toolchains=($(sed -r -e 's/,.*//; /internal/d; /^#/d; /^$/d;' "${toolchains_csv}" \
                ^-- SC2207: Prefer mapfile or read -a to split command output (or quote to avoid splitting).

In utils/test-pkg line 110:
                  |if [ ${random} -gt 0 ]; then \
                        ^-------^ SC2086: Double quote to prevent globbing and word splitting.

Did you mean:
                  |if [ "${random}" -gt 0 ]; then \

In utils/test-pkg line 111:
                      sort -R |head -n ${random}
                                       ^-------^ SC2086: Double quote to prevent globbing and word splitting.

Did you mean:
                      sort -R |head -n "${random}"

In utils/test-pkg line 121:
    if [ ${nb_tc} -eq 0 ]; then
         ^------^ SC2086: Double quote to prevent globbing and word splitting.

Did you mean:
    if [ "${nb_tc}" -eq 0 ]; then

In utils/test-pkg line 134:
        printf "%40s [%*d/%d]: " "${toolchain}" ${#nb_tc} ${nb} ${nb_tc}
                                                          ^---^ SC2086: Double quote to prevent globbing and word splitting.
                                                                ^------^ SC2086: Double quote to prevent globbing and word splitting.

Did you mean:
        printf "%40s [%*d/%d]: " "${toolchain}" ${#nb_tc} "${nb}" "${nb_tc}"

In utils/test-pkg line 146:
        ${nb} ${nb_skip} ${nb_fail} ${nb_legal} ${nb_show}
        ^---^ SC2086: Double quote to prevent globbing and word splitting.
              ^--------^ SC2086: Double quote to prevent globbing and word splitting.
                         ^--------^ SC2086: Double quote to prevent globbing and word splitting.
                                    ^---------^ SC2086: Double quote to prevent globbing and word splitting.
                                                ^--------^ SC2086: Double quote to prevent globbing and word splitting.

Did you mean:
        "${nb}" "${nb_skip}" "${nb_fail}" "${nb_legal}" "${nb_show}"

In utils/test-pkg line 160:
    CONFIG_= support/kconfig/merge_config.sh -O "${dir}" \
            ^-- SC1007: Remove space after = if trying to assign a value (for empty string, use var='' ... ).

In utils/test-pkg line 181:
    if [ ${prepare_only} -eq 1 ]; then
         ^-------------^ SC2086: Double quote to prevent globbing and word splitting.

Did you mean:
    if [ "${prepare_only}" -eq 1 ]; then

For more information:
  https://www.shellcheck.net/wiki/SC1007 -- Remove space after = if trying to...
  https://www.shellcheck.net/wiki/SC2207 -- Prefer mapfile or read -a to spli...
  https://www.shellcheck.net/wiki/SC2086 -- Double quote to prevent globbing ...

The suggestions from shellcheck can be applied.

This script already uses bash so we can rely on mapfile.

The warning about CONFIG_= assignment misinterpreted the intention: we
don't want to assign to CONFIG_, we want to clear it from the
environment. Spell this as CONFIG_="".

Signed-off-by: Arnout Vandecappelle <arnout@mind.be>
2023-02-08 15:28:32 +01:00
Arnout Vandecappelle
2c3466bbee utils/docker-run: fix shellcheck errors
In utils/docker-run line 10:
    --user $(id -u):$(id -g) \
           ^------^ SC2046: Quote this to prevent word splitting.
                    ^------^ SC2046: Quote this to prevent word splitting.

The suggestions from shellcheck can be applied.

Signed-off-by: Arnout Vandecappelle <arnout@mind.be>
2023-02-08 15:28:31 +01:00
Arnout Vandecappelle
7150edc790 utils/config: fix shellcheck errors
In utils/config line 54:
                ARG="`echo $ARG | tr a-z- A-Z_`"
                     ^------------------------^ SC2006: Use $(...) notation instead of legacy backticked `...`.
                           ^--^ SC2086: Double quote to prevent globbing and word splitting.

Did you mean:
                ARG="$(echo "$ARG" | tr a-z- A-Z_)"

In utils/config line 87:
        local tmpfile="$infile.swp"
              ^-----^ SC2034: tmpfile appears unused. Verify use (or export if used externally).

In utils/config line 182:
                        if [ $? != 0 ] ; then
                             ^-- SC2181: Check exit code directly with e.g. 'if mycmd;', not indirectly with $?.

For more information:
  https://www.shellcheck.net/wiki/SC2034 -- tmpfile appears unused. Verify us...
  https://www.shellcheck.net/wiki/SC2086 -- Double quote to prevent globbing ...
  https://www.shellcheck.net/wiki/SC2006 -- Use $(...) notation instead of le...

The suggestions from shellcheck can be applied.

The unused variable tmpfile in fact occurs in several functions, all of
them can be removed.

For the check exit code, the condition is swapped to avoid negative
logic.

Signed-off-by: Arnout Vandecappelle <arnout@mind.be>
2023-02-08 15:28:30 +01:00
Arnout Vandecappelle
dc364c6ae6 utils/brmake: fix shellcheck errors
In utils/brmake line 6:
    local found ret start d h m mf
          ^---^ SC2034: found appears unused. Verify use (or export if used externally).

In utils/brmake line 16:
    > >( while read line; do
               ^--^ SC2162: read without -r will mangle backslashes.

For both, the suggestions from shellcheck can be applied.

Signed-off-by: Arnout Vandecappelle <arnout@mind.be>
2023-02-08 15:28:28 +01:00
Ricardo Martincoski
c5a3dfb9a4 utils/check-package: check all shell scripts
Currently only SysV init scripts are checked using shellcheck and a few
other rules (e.g. variable naming, file naming).

Extend the check using shellcheck to all shell scripts in the tree.
This is actually limited to the list of directories that check-package
knows that can check, but that list can be expanded later.

In order to apply the check to all shell scripts, use python3-magic to
determine the file type. Unfortunately, there are two different python
modules called "magic". Support both by detecting which one is installed
and defining get_filetype accordingly.

Keep testing first for name pattern, and only in the case there is no
match, check the file type. This ensures, for instance, that SysV
init scripts follow specific rules.

Apply these checks for shell scripts:
 - shellcheck;
 - trailing space;
 - consecutive empty lines;
 - empty last line on file;
 - newline at end of file.

Update the list of ignored warnings.

Do not add unit tests since no function was added, they were just
reused.
But expand the runtime test for check-package using as fixture a file
that generates a shellcheck warning.

Signed-off-by: Ricardo Martincoski <ricardo.martincoski@gmail.com>
[Arnout: support both variants of the "magic" module]
Signed-off-by: Arnout Vandecappelle <arnout@mind.be>
2023-02-08 13:31:06 +01:00
Sébastien Szymanski
09ac5a9e18 utils/test-pkg: proper output on host without jq installed
On host without jq installed, test-pkg's output is as following:

$ ./utils/test-pkg -p mmc-utils
                    bootlin-armv5-uclibc [1/6]: which: no jq in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin:/usr/lib/llvm/14/bin:/usr/lib/llvm/13/bin:/usr/lib64/opencascade/bin)
JQ IS
OK
                     bootlin-armv7-glibc [2/6]: which: no jq in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin:/usr/lib/llvm/14/bin:/usr/lib/llvm/13/bin:/usr/lib64/opencascade/bin)
JQ IS
OK
                   bootlin-armv7m-uclibc [3/6]: which: no jq in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin:/usr/lib/llvm/14/bin:/usr/lib/llvm/13/bin:/usr/lib64/opencascade/bin)
...

Since test-pkg handles this case we can hide this error message and have
proper output:

$ ./utils/test-pkg -p mmc-utils
                    bootlin-armv5-uclibc [1/6]: OK
                     bootlin-armv7-glibc [2/6]: OK
                   bootlin-armv7m-uclibc [3/6]: OK

Signed-off-by: Sébastien Szymanski <sebastien.szymanski@armadeus.com>
Reviewed-by: Romain Naour <romain.naour@smile.fr>
Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
2023-02-07 17:48:42 +01:00
Ricardo Martincoski
de03312db0 utils/get-developers: print error for correct line
Start counting the line numbers in 1 instead of 0, in case an error
must be printed.

Both the error about a developer entry with no file entry and the error
about a file entry with no developer entry actually belong to the
non-empty line previous the one being analysed, so in these cases print
the line number from the line before.

Also count empty and comment lines, so a developer fixing the file can
jump to the correct line (or the nearest one).

At same time standardize the messages, printing the line number
also in the case of a warning for a file that is not in the tree
anymore.

Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Signed-off-by: Ricardo Martincoski <ricardo.martincoski@gmail.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
2023-02-07 09:24:16 +01:00