Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 7 Jan 2019 19:12:54 -0700
From:      Gavin Howard <gavin.d.howard@gmail.com>
To:        cem@freebsd.org
Cc:        Stefan Esser <se@freebsd.org>, "freebsd-arch@freebsd.org" <freebsd-arch@freebsd.org>
Subject:   Re: GNU-compatible, BSD-licensed bc
Message-ID:  <CAF=dzROSJ6FT9iXAiz3zfk_Zm71_jjbtHJ-zt=MsibB8eQauEQ@mail.gmail.com>
In-Reply-To: <CAG6CVpVe7yMrV1T9W1Qm5rMsTqq3T2LsYJkMKDd0EabAdDj=uQ@mail.gmail.com>
References:  <CAF=dzRNnurahLBOaKgq8_bDXNuM8biYPFbj6F2vp0t58Ejp8bg@mail.gmail.com> <A6C4B09B-4156-47A4-89B0-80E8688D59FC@FreeBSD.org> <CAG6CVpU-rgUVvWYDA%2B2qw62hzK1xOEqVwmXGSx2yrfqNMX8e7w@mail.gmail.com> <CAF=dzRNJMvNq0yiPPdWNk-F8--RPX3D6aydLpmLLX3xyvMAoQw@mail.gmail.com> <1e025f53-fc5e-5b1e-013d-ab9330a0e9db@freebsd.org> <CAG6CVpVe7yMrV1T9W1Qm5rMsTqq3T2LsYJkMKDd0EabAdDj=uQ@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help

On Mon, Jan 7, 2019 at 5:59 PM Conrad Meyer <cem@freebsd.org> wrote:
>
> Hi Stefan,
>
> I don't think there's any reason to put this in ports instead of base.
> If you're arguing that we shouldn't ship any bc in base, that's a fine
> argument to make, but it's off-topic for this discussion.
>
> If at some point after that you want to remove bc from base and fix
> all of the fallout of that much larger change, you are welcome to take
> on that (much larger) project.
>
> Best,
> Conrad

I would be plenty happy to just get my bc into ports, but I would be
*ecstatic* to have it in base. Personally, I think it should be in
base because POSIX requires it, and this bc would be more useful to a
wide array of users.

That said, I am not a FreeBSD contributor (yet), so my opinion should
not really matter.

> On Mon, Jan 7, 2019 at 2:06 PM Stefan Esser <se@freebsd.org> wrote:
> >
> > Am 07.01.19 um 20:45 schrieb Gavin Howard:
> > >  On Mon, Jan 7, 2019 at 11:06 AM Dimitry Andric <dim@freebsd.org> wrote:
> > >>
> > >> On 7 Jan 2019, at 19:35, Gavin Howard <gavin.d.howard@gmail.com> wrote:
> > >>>
> > >>> I am the author of a GNU-compatible, BSD-licensed bc
> > >>> (https://github.com/gavinhoward/bc). I noticed (on
> > >>> https://wiki.freebsd.org/GPLinBase) that FreeBSD used to use the GNU
> > >>> bc until it was taken out because of the GPL. My bc is not licensed
> > >>> under the GPL; it is under the 0BSD license. Thus, I think my bc might
> > >>> be a great fit for FreeBSD.
> > >>>
> > >>> My bc is well-tested. I make sure that every single memory bug that I
> > >>> can find is out before every single release. I also make sure that my
> > >>> bc's math is correct by running millions of random math problems
> > >>> before every release.
> > >>>
> > >>> My bc is extremely portable; it easily builds on any POSIX
> > >>> platform. And it includes a full dc as well (except for the "!"
> > >>> command).
> > >>>
> > >>> I would love to work with the core team to get my bc into FreeBSD, if
> > >>> there is interest. I am about to do a release, and I am willing to
> > >>> delay the release to get it up to par for FreeBSD.
> > >>>
> > >>> Would there be interest?
> > >>
> > >> You are 9 years late. :-)
> > >>
> > >> https://github.com/freebsd/freebsd/commit/bc4e1f6f87a770761be30eb708cbef88bc4d9536
> > >>
> > >> That said, are you aware of any great differences between your bc and
> > >> the one originally from OpenBSD?
> > >
> > > Yes. See below for the important one.
> > >
> > > The non-important ones include the fact that I support *every* GNU
> > > extension. That includes array references, void functions, the "halt"
> > > keyword, etc.
> > >
> > > On Mon, Jan 7, 2019 at 12:24 PM Conrad Meyer <cem@freebsd.org> wrote:
> > >>
> > >> Thanks Gavin,
> > >>
> > >> I think this could be valuable for us.  Our bc is not GNU-compatible
> > >> today and that causes some pain.
> > >>
> > >> For example, fusefs-lkl requires the gnubc port to build because the
> > >> base bc lacks some functionality that GNU has, and of course lkl uses
> > >> the gnu bc functionality.  So a BSDL bc that is actually
> > >> GNU-compatible seems attractive to me.
> > >>
> > >> The script in question can be found here:
> > >> https://github.com/torvalds/linux/blob/master/kernel/time/timeconst.bc
> > >> and it is invoked like: "echo 100 | bc -q path/to/timeconst.bc".
> > >>
> > >> It can be reduced to the following short test case with the same invocation:
> > >>
> > >>     a = read();
> > >>     print "a: ", a, "\n"
> > >>
> > >> In-tree BSD bc prints "dc: not a string" on stderr and with the
> > >> simplified test case, "a: 0\n100\n" on stdout.
> > >>
> > >> GNU bc prints "a: 100\n" on stdout, as expected.  (I have not tried Gavin's bc.)
> > >>
> > >> Best,
> > >> Conrad
> > >
> > > My bc handles the Linux timeconst.bc script with aplomb from 0 to (at
> > > least) 1000. It is part of my test suite, actually.
> > >
> > > You can try it out by running the following command after building my
> > > bc (where BC_ROOT is the root directory of my bc):
> > >
> > > $ "$BC_ROOT/tests/bc/timeconst.sh" /location/of/timeconst.bc
> > >
> > > It won't have any output besides "Running timeconst.bc..." unless it
> > > didn't pass the test.
> > >
> > > Also, this bc builds out of the box on FreeBSD. I have already made
> > > sure of that. Just use:
> > >
> > > $ cd "$BC_ROOT"
> > > $ ./configure.sh -O3
> > > $ make
> >
> > To be able to provide binary packages we'd need this "bc" in ports.
> >
> > Creating a port should be very simple and I'd be willing to work on
> > getting a port committed tomorrow.
> >
> > Ports that currently depend on GNU bc from ports could be converted
> > to use this version instead.
> >
> > Even if it was imported into base today, there'd be supported releases
> > without that bc version for quite some time to come.
> >
> > A simple port Makefile that works for me is:
> >
> > # $FreeBSD$
> >
> >
> >
> > PORTNAME=       gh-bc
> > PORTVERSION=    1.0
> > CATEGORIES=     math
> >
> > MAINTAINER=     se@FreeBSD.org
> > COMMENT=        GNU compatible bc/dc calculator
> >
> > LICENSE=        BSD
> > LICENSE_FILE=   ${WRKSRC}/LICENSE.md
> >
> > USES=           gmake
> >
> > USE_GITHUB=     yes
> > GH_ACCOUNT=     gavinhoward
> > GH_PROJECT=     bc
> >
> > PLIST_FILES=    bin/bc bin/dc
> >
> > do-install:
> >                 ${INSTALL_PROGRAM} ${WRKSRC}/bin/bc ${STAGEDIR}${PREFIX}/bin/
> >                 ${LN} ${STAGEDIR}${PREFIX}/bin/bc ${STAGEDIR}${PREFIX}/bin/dc
> >
> > .include <bsd.port.mk>
> >
> > It could probably made to not require GNU make, but I did not bother to
> > try this for this quickly written port Makefile.

I have a Makefile that works without GNU make:

```
# $FreeBSD$

PORTNAME=        gh-bc
PORTVERSION=     1.1rc3
CATEGORIES=      math

MAINTAINER=      se@FreeBSD.org
COMMENT=         GNU compatible bc/dc calculator

LICENSE=         BSD
LICENSE_FILE=    ${WRKSRC}/LICENSE.md

USE_GITHUB=      yes
GH_ACCOUNT=      gavinhoward
GH_PROJECT=      bc

HAS_CONFIGURE=   yes
CONFIGURE_ARGS=  -O3

PLIST_FILES=     bin/bc bin/dc

do-install:
                 ${INSTALL_PROGRAM} ${WRKSRC}/bin/bc ${STAGEDIR}${PREFIX}/bin/
                 ${LN} ${STAGEDIR}${PREFIX}/bin/bc ${STAGEDIR}${PREFIX}/bin/dc

.include <bsd.port.mk>
```

There is only one thing I could not get to work: running `make
package` as a user. It always gave me permissions issues, and I am a
FreeBSD noob, so I did not know how to fix it.

For the `pkg-descr` file, I mostly copied the one from gnubc:

```
bc is an arbitrary precision numeric processing language.  Its syntax is similar
to C but differs in many substantial areas.  It supports interactive execution
of statements. The bc utility is included in the POSIX 1003.1-2008 standard.

WWW: https://github.com/gavinhoward/bc
```

> > There are 2 open points:
> >
> > 1) There is no 0BSD license - I have set the license name to BSD and the
> >    LICENSE.md file is included in the package, but I do not think that
> >    this is completely right.

Ah, yes, sorry. There *is* one (https://spdx.org/licenses/0BSD.html),
but SPDX only added it in December, IIRC.

> > 2) I have used the release tag 1.0, which does not include the latest
> >    changes committed to Github. If the port should actually be based on
> >    a later code base, a new release tag would be beneficial.

To make the above Makefile work, I put out a release candidate. When I
do an actual release (within two or three weeks), we can update it to
the *actual* version 1.1. But the Makefile above uses my current build
system, so changing it for the new version should be as simple as
removing "rc3" from the version.

Also, the build sequence changed for git clones:

$ ./configure -O3
$ make

(I decided to make the port easier to do by renaming `configure.sh` to
the more standard `configure`.)

> > To distinguish this port from other bc implementations I'd suggest to
> > name it "math/gh-bc" ...

Whatever works. That was the name I put into the Makefile itself.

Gavin Howard



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAF=dzROSJ6FT9iXAiz3zfk_Zm71_jjbtHJ-zt=MsibB8eQauEQ>