1
0
Fork
You've already forked bsdutils
0
forked from dcantrell/bsdutils
Alternative to GNU coreutils using software from FreeBSD
  • C 70.3%
  • Roff 25.4%
  • Yacc 2.5%
  • Meson 1%
  • Lex 0.3%
  • Other 0.4%
2025年10月22日 16:01:55 -04:00
.copr Patch FreeBSD 14.3 code so it builds on Linux 2025年10月17日 09:29:40 -04:00
.github/workflows Use verbose build output on Alpine Linux musl CI 2023年01月04日 14:19:15 -05:00
compat Patch FreeBSD 14.3 code so it builds on Linux 2025年10月17日 09:29:40 -04:00
include Initial import of FreeBSD 14.3-RELEASE code 2025年09月09日 11:32:13 -04:00
src Add the 'sdiff' program from FreeBSD and patch for Linux. 2025年10月22日 16:01:55 -04:00
utils Add the 'sdiff' program from FreeBSD and patch for Linux. 2025年10月22日 16:01:55 -04:00
.gitignore gitignore: add Makefile.bsd 2021年06月27日 12:42:35 -04:00
.mailmap Patch FreeBSD 14.3 code so it builds on Linux 2025年10月17日 09:29:40 -04:00
AUTHORS.md Patch FreeBSD 14.3 code so it builds on Linux 2025年10月17日 09:29:40 -04:00
bsdutils.spec.in Handle the *b man page stuff in the package spec file 2023年01月05日 15:25:06 -05:00
COPYRIGHT Begin import and porting of FreeBSD 13.0-RELEASE code 2021年04月27日 22:18:00 -04:00
DIFFERENCES Patch FreeBSD 14.3 code so it builds on Linux 2025年10月17日 09:29:40 -04:00
GNUmakefile Rename Makefile to GNUmakefile 2024年02月23日 10:32:49 -05:00
LICENSE Update top level documentation 2021年07月05日 13:43:02 -04:00
meson.build Patch FreeBSD 14.3 code so it builds on Linux 2025年10月17日 09:29:40 -04:00
meson_options.txt Allow specifying extra search paths for fts and rpmatch 2022年08月01日 13:27:25 -04:00
README.md Update README.md to reflect how I'm importing source and handling patches 2024年02月23日 22:28:59 -05:00
TODO Add the 'sdiff' program from FreeBSD and patch for Linux. 2025年10月22日 16:01:55 -04:00
TRADEOFFS Update top level documentation 2021年07月05日 13:43:02 -04:00
upstream.conf Initial import of FreeBSD 14.3-RELEASE code 2025年09月09日 11:32:13 -04:00

bsdutils

This project contains a GNU coreutils-like collection of utilities from the FreeBSD source code tree.

The project began in October 2017 and initially ported code from the OpenBSD source tree. The original objective was to see how much work was involved and to compare relative sizes of built executables with those found in GNU coreutils and other projects. In an effort to gain more featureful BSD commands and to possibly work more easily with dotfiles for users on MacOS X systems, the project started over by porting the commands from FreeBSD in April 2021.

Importing A New Release Of FreeBSD

When a new release of FreeBSD is made, the 'make import' target should be used.

  1. Create a new branch to do the import work. The convention is to make the branch from main and name it after the FreeBSD release you are importing from. For example, branch 13.2-RELEASE when importing from 13.2-RELEASE.

  2. Switch to this new branch.

  3. Change VER in upstream.conf to match what you are importing, e.g. 13.2-RELEASE.

  4. Verify URL in upstream.conf works (FreeBSD may move things around).

  5. Run 'make import'

NOTE: 'make import' may fail if the source tree has been reorganized. For example, in 13.2-RELEASE the timeout(1) command source moved from usr.bin/timeout to bin/timeout. Look for these failures and modify utils/import-src.sh as necessary. Do a 'git checkout -- src && git checkout -- compat' and run the import process again until it succeeds.

  1. Commit all these changes on the branch. And tag the branch as the import point. e.g., for 13.2-RELEASE the tag would be:

    git tag -s 13.2-RELEASE-import
    

    NOTE: Be sure to not commit the Makefile.bsd files.

  2. Now bring all the patches forward that get it working on Linux. To do this I generate a diff from the previous import point to the tagged release. For example, for 13.1-RELEASE, I do:

    git diff 13.1-RELEASE-import v13.1 > ~/patches
    cd ~
    mkdir p
    cd p
    splitdiff -a -d ../patches
    

    From here I begin building bsdutils on the branch and bringing over patches as needed. Some may no longer be valid. There may need to be meson.build file changes too if new source files have been introduced. This is the trial and error part of porting, but should not take long.

  3. Once bsdutils builds on the branch, commit the changes on the branch. Push to upstream.

  4. Now on main, merge the 13.2-RELEASE branch on to main. Once you have done that, make sure it builds again and tag it:

    git tag -s v13.2
    

    The main branch now contains the latest stable released bsdutils.

Push the changes and check that CI passes. After some testing, it's probably time for a release.

Build Requirements

You will need GNU-compatible C and C++ compilers, typically gcc/g++ or clang/clang++. You will also need flex (or some other lex as long as it is compatible with flex), byacc or bison, meson and ninja/samurai. If you wish to use the top-level Makefile (which is just a simple wrapper around meson), you will need GNU make. Most distributions have all these tools already available in their repositories.

gcc/g++ https://gcc.gnu.org/
clang/clang++ https://llvm.org/
GNU make https://www.gnu.org/software/make/
meson https://mesonbuild.com/
ninja https://ninja-build.org/
flex https://github.com/westes/flex
byacc https://invisible-island.net/byacc/byacc.html

Additionally you will need the following shared libraries to build all of the programs in this project:

terminfo https://invisible-mirror.net/archives/ncurses/
libedit http://thrysoee.dk/editline/
openssl https://www.openssl.org/
libxo https://github.com/Juniper/libxo

The terminfo library may be either standalone (libtinfo) or a part of the curses library, dependending on build. The ls(1) command needs this. bc(1) needs libedit, which is the BSD alternative to GNU readline. dc(1) uses libcrypto which comes from OpenSSL. seq(1) needs libm, but that comes from your C library. df(1) and wc(1) use libxo for outputting to multiple formats.

Users of musl-based Linux systems also need libfts and librpmatch installed.

Bugs

Probably. The FreeBSD code is pretty solid. But remember this project is a port of that code to Linux systems. Pull requests welcome for any bugs found. Also you can just open an issue on the project page and we will try to get to it.