User:ChristTrekker/AUX
From NetBSD Wiki
This is a scratch area for my efforts of getting pkgsrc to run on A/UX. The goal is to get pkgsrc up and running while installing as little precompiled software as possible—letting pkgsrc do its own bootstrapping. A/UX has never had a package management system, so this would be pretty cool to have working.
Contents |
Updating headers
Updated /usr/include/sys/dir.h, /usr/include/sys/file.h, /usr/include/sys/param.h, and /usr/include/sys/types.h as described in the A/UX FAQ.
Useful libraries
Get libUTIL.a and put it in /opt/lib, put associated headers regex.h and sysexits.h in /opt/include.
It looks like the gcc 2.7.2 tarball online already includes the libUTIL.a and updated libgcc.a that are in the libUTIL tarball. However, the .h files are not included with the gcc package, so you must still unpack the libUTIL tarball to get those. Remember to put /opt/include in the include search path with -I when compiling.
Question: I'm thinking it would be a good idea to always link libbsd, libposix, and libUTIL, to maximize compatibility. How do I specify this during the bootstrap process? ⇔ ChristTrekker 22:00, 21 July 2008 (CEST)
Definitions in core pkgsrc files
Obviously, pkgtools/bootstrap-mk-files/files/mods/AUX.sys.mk, mk/bsd.prefs.mk, mk/platform/AUX.mk, mk/tools/bootstrap.mk, and mk/tools/tools.AUX.mk need to be created or updated. I've taken a stab at this, but have not been able to test anything yet.
Bootstrapping
Using the right tools
A/UX mkdir does not have a -p option. Thus it creates a -p directory and gives errors when trying to create directories that already exist. If you run ./bootstrap multiple times (until it creates all the -p subdirs) it will continue past that point. ⇔ ChristTrekker 21:20, 20 June 2008 (CEST)
The bootstrap script should run under /bin/ksh for A/UX because its /bin/sh sucks. ⇔ ChristTrekker 21:33, 20 June 2008 (CEST)
- We can't just change it to ksh for everyone, so I've now changed this so that if it's A/UX it restarts itself as a ksh script. As we want to avoid an infinite loop, a temp file is used to mark whether this is already done, since there doesn't seem to be any way to tell what the current shell is. Meaning, if bootstrap aborts, you have to remove that file to start it up properly again. ⇔ ChristTrekker 14:50, 29 September 2008 (UTC)
Attempting to bootstrap got as far as "checking for grep that handles long lines and -e" but it fails at this point. ⇔ ChristTrekker 23:34, 27 May 2008 (CEST)
The GNU grep 2.0 tarball for A/UX found online is source-only. Compiling with A/UX's cc fails. If you install the c89 tarball found online (in /, which will overwrite your /lib/libposix.a so make a backup), you can compile with that. Just state CC=c89 during configuration. The last Spencer test fails, but that may be due to the suckiness of A/UX's awk. Touch the check.done file so that make install will work. ⇔ ChristTrekker 16:21, 28 May 2008 (CEST)
Using GNU grep allows bootstrap to almost complete configuration. Maybe this is due to limitations of A/UX's sed? ⇔ ChristTrekker 16:30, 28 May 2008 (CEST)
libnbcompat
Using GNU sed 3.02 gets past this error, but the first compilation of libnbcompat (bits.c) dies on line 88 after a bunch of errors starting on line 77. Descending to the libnbcompat directory to manually configure with CC=c89 helps. A/UX sys/types.h doesn't define 64-bit types, so I commented out the corresponding line of nbcompat/nbtypes.h to bypass that error. ⇔ ChristTrekker 18:00, 28 May 2008 (CEST)
Very annoying, but the bootstrap script does not pass the chosen compiler to the libnbcompat configuration. Neither the --compiler option nor $CC if set. So, I changed the script to do so. Also to set the shell program (shprog) to ksh for A/UX since the A/UX sh stinks. ⇔ ChristTrekker 23:29, 28 May 2008 (CEST)
Build of libnbcompat dies with an internal compiler error when using c89, so it looks like there is no choice but to try gcc. ⇔ ChristTrekker 21:59, 29 May 2008 (CEST)
Using gcc, we get as far as compiling statvfs.c, where it dies because struct statfs has no member f_flags. A/UX's statfs is defined in sys/vfs.h but it is not what is expected. Linux's statfs is almost identical to the one on A/UX, so how does bootstrap work there?
Also note that when using gcc it is not necessary to comment out the 64-bit type as was mentioned above. ⇔ ChristTrekker 16:52, 30 May 2008 (CEST)
I think that the configure step should set up a HAVE_STRUCT_STATFS_F_FLAGS variable. Make execution of the f_flags code conditional on whether or not the OS has this—if there is no sfs->f_flags then leave vfs->f_flag at 0, and pray it works. ⇔ ChristTrekker 22:11, 24 June 2008 (CEST)
I've done some housecleaning in the bootstrap script too. ⇔ ChristTrekker 22:37, 24 June 2008 (CEST)
Added the suggested HAVE_STRUCT_STATFS_F_FLAGS check in libnbcompat's configure.ac and statvfs.c. It works! Now the problem is undeclared vars endgrent and endpwent in pwcache.c. ⇔ ChristTrekker 04:56, 25 June 2008 (CEST)
Turns out that endgrent and endpwent are actually functions (normally) defined in grp.h and pwd.h, but A/UX doesn't have them. Will try to set up a conditional (as above) and define them in nbcompat versions. ⇔ ChristTrekker 15:54, 25 June 2008 (CEST)
Creating these definitions worked in grp.h and pwd.h, and libnbcompat.a successfully compiles. (I'm not yet sure if it works though.) ⇔ ChristTrekker 21:21, 25 June 2008 (CEST)
bmake
After configuring bmake, arch.c will not compile because nonints.h includes util.h. Seems that emalloc() is detected erroneously, so util.h (which does not exist on A/UX) is included rather than just providing function declarations there. I need to figure out why the emalloc() test is succeeding. ⇔ ChristTrekker 21:21, 25 June 2008 (CEST)
Changing configure.in and nonints.h bypassed that problem. (I didn't fix the emalloc() check; instead I added a util.h check so it's not included if it doesn't exist.) I'm not sure it's the best solution, but it works here. Now there are problems in compat.c, regarding requests for w_S and w_T from non-structure/non-union items. Not sure what that's about. ⇔ ChristTrekker 18:40, 21 July 2008 (CEST)
The macros in question (I think) are WIFSTOPPED(reason) (w_S) and WIFEXITED(reason) (w_S and w_T). The variable reason is a WAIT_T, which is defined in wait.h if not already defined. In wait.h, if UNION_WAIT is defined, then it's a union wait (which is from <sys/wait.h>), else it's simply an int. The WAIT_STATUS() macro takes either the w_status element of the union, or the int, depending on which it is. In <sys/wait.h>, union wait (as well as WIFSTOPPED(x) and WIFEXITED(x) as numerical comparisons) is defined if _BSD_SOURCE is, but if _POSIX_SOURCE is defined then we get no union and those macros are bitfield operations instead. It appears that in AUX/config.h _POSIX_SOURCE is undefined, but nowhere is _BSD_SOURCE defined either, so we have none of these defined?? That can't be right, because otherwise it wouldn't know about w_S and w_T at all, but that's what it looks like. Square peg (an int WAIT_T), round hole (macros expecting union wait). The solution may be hacking A/UX's header files, and there is precedent for that, but I'd prefer to avoid it. ⇔ ChristTrekker 20:50, 28 July 2008 (CEST)
An old post by Jim Jagielski explains why I am getting the _BSD_SOURCE block—gcc and A/UX cc always define it. Seems to me the problem is that checking for UNION_WAIT definition is the wrong idea...you have union wait if using the BSD-style definition. This should check for _BSD_SOURCE definition. ⇔ ChristTrekker 23:45, 29 July 2008 (CEST)
Now I get the opposite problem…aggregate value used where an integer was expected! Need to check where/how WEXITSTATUS(reason) is defined. ⇔ ChristTrekker 16:12, 30 July 2008 (CEST)
WEXITSTATUS(x) is defined in wait.h—assuming x as an int, POSIX-like—if not already defined (in <sys/wait.h>). In <sys/wait.h> it is only defined in the _POSIX_SOURCE block. This means that this code is inherently requires POSIX compatibility. I'll remove my changes from wait.h and instead try to figure out how to make bootstrap "automatically" compile in POSIX-compat mode. ⇔ ChristTrekker 20:09, 30 July 2008 (CEST)
Final linking of bmake.boot gives undefined symbol errors: estrdup (arch.o), srandom (main.o), estrndup (var.o). AFAICT these are not contained in libUTIL either, but I'll try linking it anyway. ⇔ ChristTrekker 21:41, 30 July 2008 (CEST)
Conditional includes/definitions are a little sloppy. Cleaning them up should fix this. Specifically, things like a check for one function serving as a check for several. ⇔ ChristTrekker 21:49, 31 July 2008 (CEST)
Done with that, but now I get lots of "assignment makes pointer from integer without a cast" warnings. Looks like it goes into a second stage, using the bmake.boot it just compiled. Now those warnings are treated as errors and it dies.
Also, and unrelated, the A/UX date command is a joke. It doesn't accept %Y, so I changed the Makefile to use 20%y on A/UX. I once wrote the dateset utility because of this, but porting a better date command would be better. ⇔ ChristTrekker 23:41, 31 July 2008 (CEST)
The cast warnings are fixed. (Actually they were uncast void pointers, not ints.) Now I've got undefined symbols sigprocmask, sigfillset, sigdelset, sigemptyset, sigaction, sigaddset, sigismember, and sigsuspend. Hopefully, this will be the last thing holding back bmake. ⇔ ChristTrekker 17:31, 1 August 2008 (CEST)
__STDC__ must not be defined, as these function declarations should be set up in <signal.h>. However, when __STDC__ is not defined, it is only the sigX() version, not the sigX(args) version. (Apparently—a non-matching function signature would cause this error.) But since gcc normally does define it, I'm not sure what's happening. ⇔ ChristTrekker 18:19, 1 August 2008 (CEST)
After another edit to the bootstrap script to allow for extra LIBS (so that LIBS come after the LDFLAGS and object files), bmake compiles. The unit tests are failing though, so that's the next thing. ⇔ ChristTrekker 23:53, 1 August 2008 (CEST)
The failing tests seem to be export-all (which has two errors: "COMPILE.c=gcc -O -D_POSIX_SOURCE -I/opt/include -I../../libnbcompat -c: is not an identifier", which seems to originate in sys.mk AFAICT, and "Assertion failed: depth_sigsetmask < 2, file /usr/pkgsrc/bootstrap/work/bmake/sigcompat.c, line 241") and dotwait (which apparently doesn't run at all). ⇔ ChristTrekker 21:45, 6 August 2008 (CEST)
I've added A/UX to the OSs that skip the unit-tests. Evidently Solaris and IRIX have problems there, too. ⇔ ChristTrekker 17:00, 7 August 2008 (CEST)
other bootstrapped apps
No problem building awk, sed, pkgtools, etc. ⇔ ChristTrekker 17:00, 7 August 2008 (CEST)
Installing
Using the bootstrap versions to build the "real" packages fails in build_packages(). The first error is sh: syntax error at line 1: `end of file' unexpected. Kind of like the shell can't grok "&&"? ⇔ ChristTrekker 17:00, 7 August 2008 (CEST)
bmake: "../../mk/../../mk/bsd.prefs.mk" line 577: warning: "cd /usr/pkgsrc/pkgtools/bootstrap-mk-files/../.. && " returned non-zero status
I think it's because I haven't created some of the platform-dependent files needed by the pkgsrc framework. After creating a couple of them, this error moved to a different line. ⇔ ChristTrekker 20:17, 7 August 2008 (CEST)
I've not yet finished the AUX.mk file (there's a lot to it!) but it exists. Now I seem to have struck an impasse with the aforementioned mkdir -p problem that simply "running it again" does not solve. Therefore, I will need to 1) somehow test that mkdir -p works and set $MKDIR_P appropriately, 2) (in the cases where it does not) supply a wrapper script (mkdir-p-sh) that does the same job, 3) update the whole bootstrap process to use $MKDIR_P rather than "mkdir -p". Note that there already is an mkdir-sh script that is created if you set need_mkdir=yes, so maybe I could modify that instead of #2. I'd still need to do #3 at least, but since there is an explicit flag I may be relieved of #1 too. ⇔ ChristTrekker 19:42, 11 August 2008 (CEST)
I think I've improved the mkdir-sh script so that it is usable in these situations, as well. ⇔ ChristTrekker 18:35, 23 September 2008 (UTC)
AFAICT so far, the mkdir-sh script is working. The problem I'm seeing now is TOOLS_IGNORE.basename=: is not an identifier. I can't find any .mk file that has this identifier directly, or indirectly via a replacement. So where is it from, and how to fix? ⇔ ChristTrekker 21:20, 10 November 2008 (UTC)
Just realized that /var doesn't exist on A/UX, so /var/db/pkg will need to be created by bootstrap as soon as the mkdir-sh is installed. ⇔ ChristTrekker 15:02, 14 November 2008 (UTC)
Summary so far
- Use GNU grep 2.0 instead of A/UX grep
- Use GNU sed 3.02 instead of A/UX sed
- Use GNU gcc 2.7.2
- Patches…
- bootstrap: change the bootstrap script to run as /bin/ksh, and change shprog to ksh as well
- devel/bmake: Makefile.in, arch.c, buf.c, config.h.in, configure.in, configure, dir.c, for.c, hash.c, job.c, main.c, nonints.h, parse.c, str.c, suff.c, targ.c, util.c, var.c
- mk: bsd.prefs.mk, AUX.mk, bootstrap.mk, tools.AUX.mk
- pkgtools/bootstrap-extras: mkdir-sh
- pkgtools/bootstrap-mk-files: AUX.sys.mk
- pkgtools/libnbcompat: configure.ac, configure, statvfs.c, grp.h, pwd.h (changes committed 2008-09-08)
Acknowledgments
Thank you to pee-air, SAQ, and nekonoko for volunteering shell accounts for development and testing.
