Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 7 Jan 2019 23:06:06 +0100
From:      Stefan Esser <se@freebsd.org>
To:        Gavin Howard <gavin.d.howard@gmail.com>, cem@freebsd.org
Cc:        Dimitry Andric <dim@freebsd.org>, "freebsd-arch@freebsd.org" <freebsd-arch@freebsd.org>
Subject:   Re: GNU-compatible, BSD-licensed bc
Message-ID:  <1e025f53-fc5e-5b1e-013d-ab9330a0e9db@freebsd.org>
In-Reply-To: <CAF=dzRNJMvNq0yiPPdWNk-F8--RPX3D6aydLpmLLX3xyvMAoQw@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>

next in thread | previous in thread | raw e-mail | index | archive | help
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.

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.

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 distinguish this port from other bc implementations I'd suggest to
name it "math/gh-bc" ...

Regards, STefan



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1e025f53-fc5e-5b1e-013d-ab9330a0e9db>