When building ipmitool 1.8.16 on Alpine Linux, the build fails:
imbapi.c:100:24: fatal error: asm/socket.h: No such file or directory
Apparently configure.ac does not check for the presence of that file and imbapi.c then just blindly assumes its presence.
You should be able to reproduce using following Dockerfile:
FROM alpine:latest
RUN apk -U add curl file gcc libgcc libc-dev make automake autoconf libtool
COPY build.sh .
RUN ./build.sh
And build.sh:
#!/bin/bash
set -e
set -x
PN=ipmitool
PV=1.8.16
P="${PN}-${PV}"
SRC_URI="http://downloads.sourceforge.net/project/${PN}/${PN}/${PV}/${P}.tar.bz2"
SHA256SUM=3c5da6b067abf475bc24685120ec79f6e4ef6b3ea606aaa267e462023861223e
S="${PWD}/${P}"
A="${SRC_URI##*/}"
curl -L -o "${A}" "${SRC_URI}"
echo "${SHA256SUM} ${A}" | sha256sum -c
tar -xjf "${A}"
cd "${S}"
./configure LDFLAGS=-static
make
There are three more errors, which I overlooked initially:
Attached patches fix all of them, including the originally reported one.
All patches and build scripts are also available on GitHub: https://github.com/urzds/ipmitool-docker
Hello,
all attached files have 0 Bytes. Also, I don't understand why you do compile IMB (API) on Linux since it's a Windows thing.
Z.
Weird... Neither my browser nor SF complained about that. (The files on disk are not empty.)
I did not decide to do that. In fact I have no clue what IMB is and just ran
./configure && make.There are definitely Linux specific portions in the code, which is why I never noticed that it is Windows only. E.g. imbapi.c:223:
#else /* LINUX, SCO_UW, etc. */Last edit: Dennis Schridde 2016-03-04
You must run bootstrap first.
The release tarball I downloaded contains no such file:
I see and I don't know what else to say than: well, that sucks :-s
I added a little bit of error handling to the PAGESIZE patch.
Hello,
some comments on my side:
% git format-patch;to get a credit. Actually, it'd be great to get patches that way :) ~ https://sourceforge.net/p/ipmitool/wiki/Home/#include <wchar.h>, in my opinion, because eg.stddef.his empty on my Linux box. Also, http://pubs.opengroup.org/onlinepubs/009695399/basedefs/wchar.h.html suggestswchar.hshould contain the required definition and is standardized(?)_SC_PAGESIZE. But this is honestly just a gut-feeling/guess. However, that man page says that PAGESIZE must not be less than 1. Therefore, those checks should beif (pagesize < 1)Please, let me know.
Thanks,
Z.
Last edit: Zdenek Styblik 2016-03-07
I will prepare a branch during the next days. Please give me some time - there seem to be some more potential bugs that I would like to fix.
Sure, no problem. No pressure.
btw I'm not sure if it makes sense to fix errors which are caused by not running bootstrap, resp. commands in it(as far as my understanding goes, it's necessary to setup environment/configure) On the other hand, I don't know what exactly you're fixing.
Also, if you have any questions or need to discuss something, please, post a message here.
Z.
Hello, any progress?
I submitted merge-request #10: https://sourceforge.net/p/ipmitool/source/merge-requests/10/
Merge-request #11 contains even more fixes, but those only fix the most suspicious warnings: https://sourceforge.net/p/ipmitool/source/merge-requests/11/
I did not fix all warnings and the type-punning warnings in particular should be looked at. Sadly I didn't have time to do that, yet. Would be great if at some point the whole tool would compile without warnings.
Last edit: Dennis Schridde 2016-04-11
Hello Dennis,
I've reviewed PR/MR#10. Please, could we do without
#ifdefforPAGESIZE? It's part of POSIX.1, so it really should be available and no checks should be required. I mean, POSIX.1 is 15 years old now. Thoughts?I will give a look to the other PR/MR tomorrow. But it seems it contains commits from the previous PR/MR. Is this correct?
Thanks,
Z.
Well, one of the original problems was this:
So PAGESIZE was not defined. sysconf(3) says one should check how to determine the value of this using the method described in posixoptions(7). But the latter does not mention PAGESIZE at all. Thus I opted for substituting the test for _POSIX_PAGESIZE==-1,0, at compile time (as described by posixoptions(7) for the general case) with a test for the existence of PAGESIZE (as posixoptions(7) fails to define POSIX_PAGESIZE, as it does for many other _SC options). If you have a better suggestion, please tell me.
PR#11 indeed builds on top of PR#10, as the fixes there are needed to get ipmitool to compile at all. I would be unable to test PR#11 on its own, thus I opted not to rebase it onto master (instead of letting it live on top of PR#10).
As to why PAGESIZE might be not be defined by posixoptions(7), I cite getpagesize(2):
So according to that, it makes no sense at all to determine PAGESIZE at compile time, which is why I originally replaced it with a call to
sysconf(_SC_PAGESIZE)as described in getpagesize(2), and did not bother to guard it with#ifdef.When I added the
#ifdefs according to point 3 of your comment from 2016-03-07, I was assuming you needed a code path that uses plain old PAGESIZE (without sysconf) for pre-POSIX.1 legacy systems.Last edit: Dennis Schridde 2016-04-12
Uh-huh. I'm a bit confused. I meant to use
sysconf(_SC_PAGESIZE)orsysconf(PAGESIZE)and drop whole#ifdefthing.Ok, I misunderstood that.
What is your understanding of this part of sysconf(3)?
I read that as:
sysconf(_SC_PAGESIZE)to determine the value at run time.sysconf(_SC_PAGESIZE)to determine the value at run time.As _POSIX_PAGESIZE does not exist at all, I understand that we need to use
sysconf(_SC_PAGESIZE).The next paragraph again details this:
IMO that kind of contradicts the previous paragraph. _PAGESIZE might contain an upper limit on the page size, but this paragraph also explains that _POSIX_PAGESIZE might do the same (but in the previous paragraph it was said that it would be defined to the POSIX version defining the constant).
In any case, this paragraph again says that calls to
sysconf()need to be made using_SC_PAGESIZEand not_PAGESIZE.sysconf(3p) (POSIX Programmer's Manual) again confirms that PAGESIZE and PAGE_SIZE should be queried using _SC_PAGESIZE and _SC_PAGE_SIZE, respectively.
Thus I cannot find any evidence, that it would be allowed to call
sysconf(PAGESIZE)orsysconf(PAGE_SIZE).Last edit: Dennis Schridde 2016-04-12
My reaction to this is: it's a mess;, but you're right and there unfortunately seems to be no way around it. Ok.
I can change the commit to use only
sysconf(_SC_PAGESIZE)(and fallback tosysconf(_SC_PAGE_SIZE), if _SC_PAGESIZE is not defined), just as I did initially (minus the< 0bug, which was caused by only having in mind the generic parts of sysconf(3)).Shall I do that?
Last edit: Dennis Schridde 2016-04-12
Let's leave it like this. I've merged both PRs. Thanks.
Thanks!