Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Gentoo: User

gawk and filefuncs

 

 

Gentoo user RSS feed   Index | Next | Previous | View Threaded


oss.elmar at googlemail

Sep 3, 2010, 1:31 PM

Post #1 of 6 (687 views)
Permalink
gawk and filefuncs

Can anybody explain the Gentoo handling of filefuncs in the gawk package?

Why isn't a simple patch used like in all other cases?

Al


shrdlu at unlimitedmail

Sep 3, 2010, 2:04 PM

Post #2 of 6 (659 views)
Permalink
Re: gawk and filefuncs [In reply to]

On Fri, 3 Sep 2010 22:31:01 +0200 Al <oss.elmar [at] googlemail> wrote:

> Can anybody explain the Gentoo handling of filefuncs in the gawk package?
>
> Why isn't a simple patch used like in all other cases?

gawk provides dynamic extension modules. This is explained here:

http://www.gnu.org/manual/gawk/gawk.html#Dynamic-Extensions

The gawk source distribution comes with a number of such extensions in the
(doh) extensions/ directory. filefuncs.c is such one extension, which
demonstrate how to add stat() and chdir() capabilities to awk.
The file is compiled into a .so file, which is then referenced from within
gawk to make the extended commands available.

A vanilla build of gawk does not have any dynamic extension.


Now, the Gentoo devs at some point in the past (very early) took that file
(filefuncs.c) and extended it to implement new commands like "symlink",
"unlink", "mkdir", "rmdir" and "stat", so those are callable from within
awk, effectively extending the language. (you can see the Gentoo copyright
in the file, look
into /usr/portage/sys-apps/gawk/files/filefuncs/filefuncs.c)

There are a number of Gentoo system scripts that use those awk extensions
(look into /lib/rcscripts and /lib/rcscripts/awk), which means that
compiling the expanded filefuncs.c (not the vanilla one) is mandatory on a
Gentoo system, because there are awk scripts that rely on the extended
functionaltiy provided by it. Hence Gentoo maintains the filefuncs.c file
independently, and the gawk ebuild, besides building gawk itself, also takes
care of building filefuncs.c containing the extensions.


oss.elmar at googlemail

Sep 3, 2010, 3:25 PM

Post #3 of 6 (676 views)
Permalink
Re: gawk and filefuncs [In reply to]

>
> The gawk source distribution comes with a number of such extensions in the
> (doh) extensions/ directory. filefuncs.c is such one extension, which
> demonstrate how to add stat() and chdir() capabilities to awk.
> The file is compiled into a .so file, which is then referenced from within
> gawk to make the extended commands available.
>
> A vanilla build of gawk does not have any dynamic extension.
>
>
> Now, the Gentoo devs at some point in the past (very early) took that file
> (filefuncs.c) and extended it to implement new commands like "symlink",
> "unlink", "mkdir", "rmdir" and "stat", so those are callable from within
> awk, effectively extending the language. (you can see the Gentoo copyright
> in the file, look
> into /usr/portage/sys-apps/gawk/files/filefuncs/filefuncs.c)
>
> There are a number of Gentoo system scripts that use those awk extensions
> (look into /lib/rcscripts and /lib/rcscripts/awk), which means that
> compiling the expanded filefuncs.c (not the vanilla one) is mandatory on a
> Gentoo system, because there are awk scripts that rely on the extended
> functionaltiy provided by it. Hence Gentoo maintains the filefuncs.c file
> independently, and the gawk ebuild, besides building gawk itself, also takes
> care of building filefuncs.c containing the extensions.
>
>

Thank you very much. That is the best explanation a read to this. It
should be deliverd with the sources.

Still the procedure is unusual. They could apply a patch to
extensions/ filefuncs.c and exclude it for vanilla.

I have a second issue. When compiling gawk on Cygwin, where is no
windows kernel, the Gentoo version of filefuncs breaks. I have to
disable it in the ebuild to get gawk compiled.

filefuncs.o:filefuncs.c:(.text+0x1e): undefined reference to `_make_builtin'
[... lots of this ... ]
filefuncs.o:filefuncs.c:(.text+0x10f1): undefined reference to `_update_ERRNO'
collect2: ld returned 1 exit status
make: *** [filefuncs.so.0.0.1] Error 1

You say it is mandatory on a Gentoo system, because there are awk
scripts that rely on. Do this functions break because of the missing
kernel? What would be the workaround?

Thanks

Al


oss.elmar at googlemail

Sep 3, 2010, 3:26 PM

Post #4 of 6 (659 views)
Permalink
Re: gawk and filefuncs [In reply to]

> I have a second issue. When compiling gawk on Cygwin, where is no
> windows kernel, the Gentoo version of filefuncs breaks. I have to

Sure there is a windows kernel. The linux kernel is missing.

Al


shrdlu at unlimitedmail

Sep 4, 2010, 2:58 AM

Post #5 of 6 (655 views)
Permalink
Re: gawk and filefuncs [In reply to]

On Sat, 4 Sep 2010 00:25:32 +0200 Al <oss.elmar [at] googlemail> wrote:

> Thank you very much. That is the best explanation a read to this. It
> should be deliverd with the sources.
>
> Still the procedure is unusual. They could apply a patch to
> extensions/ filefuncs.c and exclude it for vanilla.

Since it's critical for Gentoo gawk, perhaps they didn't want to depend on
gawk's source distribution suddenly removing that file or otherwise
changing (and patches need to be maintained up-to-date against the
original, while a standalone file does not need maintenance).
But this is all just my guessing.

> I have a second issue. When compiling gawk on Cygwin, where is no
> windows kernel, the Gentoo version of filefuncs breaks. I have to
> disable it in the ebuild to get gawk compiled.
>
> filefuncs.o:filefuncs.c:(.text+0x1e): undefined reference to
> `_make_builtin' [... lots of this ... ]
> filefuncs.o:filefuncs.c:(.text+0x10f1): undefined reference to
> `_update_ERRNO' collect2: ld returned 1 exit status
> make: *** [filefuncs.so.0.0.1] Error 1
>
> You say it is mandatory on a Gentoo system, because there are awk
> scripts that rely on. Do this functions break because of the missing
> kernel? What would be the workaround?

How are you building it? It needs special commands because it needs to
become a shared object, not an executable.

Note that building that file is by no means necessary for a working gawk.

And, even if you built it, it wouldn't do anything unless you specifically
used the extension() gawk command to reference the object file and import
the extra definitions (see the link I posted in the first email for all
the gory details. Also the Makefile that comes with Gentoo's own
filefuncs.c may help).


oss.elmar at googlemail

Sep 4, 2010, 3:51 AM

Post #6 of 6 (652 views)
Permalink
Re: gawk and filefuncs [In reply to]

>> You say it is mandatory on a Gentoo system, because there are awk
>> scripts that rely on. Do this functions break because of the missing
>> kernel? What would be the workaround?
>
> How are you building it? It needs special commands because it needs to
> become a shared object, not an executable.
>

Here is how I am building it and the whole context:

http://en.gentoo-wiki.com/wiki/Prefix/Cygwin#gawk-3.1.7:_.5Bfilefuncs.so.0.0.1.5D_Error_1

emerge --oneshot gawk


> Note that building that file is by no means necessary for a working gawk.
>
> And, even if you built it, it wouldn't do anything unless you specifically
> used the extension() gawk command to reference the object file and import
> the extra definitions (see the link I posted in the first email for all
> the gory details. Also the Makefile that comes with Gentoo's own
> filefuncs.c may help).

I did understand, that it is an extension, which provides additional
commands for awk scripts and that the gentoo system makes use of them
especially of it's own additions.

Options:

1.) It would compile on Cygwin. I just made a mistake.
2.) It depends on the missing kernel. I have to rewrite Gentoos
filefuncs.c to work without a linux kernel.
3.) I can go with the original extension. Portage does not really
depend on Gentoos additions.
4.) I have to adapt all awk scripts that make use of it.

Al

Gentoo user RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.