Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix util shell scripts to be compatible with BSD #5774

Merged
merged 7 commits into from
Jan 3, 2024

Conversation

lcheylus
Copy link
Contributor

@lcheylus lcheylus commented Jan 2, 2024

  • util: use env to call bash in shell scripts (in case where bash is not installed as /usr/bin/bash)
  • build-gnu.sh: modify script to be compatible with BSD OS (use GNU coreutils and GNU sed instead of OS system commands)
  • show-utils.sh: modify script to be compatible with BSD OS (use GNU coreutils instead of OS system commands)
  • util: modify scripts for code coverage to be compatible with BSD OS (use GNU coreutils instead of OS system commands)
  • run-gnu-test.sh: modify script to be compatible with BSD OS (use GNU coreutils instead of OS system commands)
  • CI: install GNU coreutils package for FreeBSD workflow (needed in style job for util/show-utils.sh script)
  • DEVELOPMENT.md: on FreeBSD, install GNU coreutils package to build/run tests

Fix #5598


Tested on Linux (Debian testing), FreeBSD 14.0 and OpenBSD-current (amd64):

  • build GNU coreutils OK with util/build-gnu.sh script
  • tests from GNU coreutils OK with util/run-gnu-test.sh script

Copy link

github-actions bot commented Jan 2, 2024

GNU testsuite comparison:

Skip an intermittent issue tests/tail/inotify-dir-recreate (fails in this run but passes in the 'main' branch)

  - For shell scripts using bash, use #!/usr/bin/env bash instead of #!/bin/bash.
    On some OS, bash is not the default shell and is not installed as /bin/bash

Signed-off-by: Laurent Cheylus <foxy@free.fr>
  - Define variables for GNU version of make, nproc, readlink and sed and use them on BSD.
  - In specific cases (option -z not available on BSD and with command /c), use GNU sed instead of
    BSD sed.
  - For xargs, --no-run-if-empty option is a GNU extension. Replace it by -r to be compatible with
    FreeBSD and OpenBSD xargs command.

Signed-off-by: Laurent Cheylus <foxy@free.fr>
  - Use /usr/bin/env bash instead of /bin/sh to define OSTYPE
  - Use GNU realpath on BSD OS (FreeBSD and OpenBSD)

Signed-off-by: Laurent Cheylus <foxy@free.fr>
  - Use /usr/bin/env bash instead of /bin/sh to use OSTYPE
  - Use readlink from GNU coreutils on BSD OS in util/build-code_coverage.sh and
    util/show-code_coverage.sh scripts

Signed-off-by: Laurent Cheylus <foxy@free.fr>
  - Use /usr/bin/env bash instead of /bin/sh to use OSTYPE
  - Define variables for GNU version of make, nproc, readlink and use them on BSD.

Signed-off-by: Laurent Cheylus <foxy@free.fr>
  - util/show-utils.sh script is used by FreeBSD workflow => use realpath
    command from GNU coreutils instead of FreeBSD realpath.
  - install GNU coreutils (FreeBSD package coreutils) in style job

Signed-off-by: Laurent Cheylus <foxy@free.fr>
…n tests

Signed-off-by: Laurent Cheylus <foxy@free.fr>
@cakebaker cakebaker merged commit 442da9a into uutils:main Jan 3, 2024
57 of 58 checks passed
@cakebaker
Copy link
Contributor

Good job, thanks!

@lcheylus lcheylus deleted the bsd-scripts branch January 3, 2024 11:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support BSD in util Bash scripts
2 participants