Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 210625 - app-portage/portage-utils-0.1.29: please add Solaris support
Summary: app-portage/portage-utils-0.1.29: please add Solaris support
Status: RESOLVED FIXED
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Tools (show other bugs)
Hardware: All Solaris
: High normal (vote)
Assignee: Portage Utils Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-02-18 21:33 UTC by Fabian Groffen
Modified: 2010-01-24 21:34 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
the Solaris patch (portage-utils-0.1.29-solaris.patch,20.55 KB, patch)
2008-02-18 21:34 UTC, Fabian Groffen
Details | Diff
compat.diff (compat.diff,4.53 KB, patch)
2008-03-15 03:30 UTC, solar (RETIRED)
Details | Diff
solaris patch when using gnulib (portage-utils-0.1.29-solaris.patch,3.03 KB, patch)
2008-07-31 13:44 UTC, Michael Haubenwallner (RETIRED)
Details | Diff
patch for aix when using gnulib (portage-utils-0.1.29-aix.patch,522 bytes, patch)
2008-07-31 13:47 UTC, Michael Haubenwallner (RETIRED)
Details | Diff
solaris patch when using gnulib against CVS (solaris.patch,2.79 KB, patch)
2008-09-13 17:28 UTC, Fabian Groffen
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Fabian Groffen gentoo-dev 2008-02-18 21:33:48 UTC
See attached patch.  Tested to work fine with 0.1.28 and 0.1.29 on Linux (x86, amd64), Solaris (sparc, sparc64, x86, amd64), Darwin (x86, ppc) and FreeBSD (x86)
Comment 1 Fabian Groffen gentoo-dev 2008-02-18 21:34:41 UTC
Created attachment 143902 [details, diff]
the Solaris patch
Comment 2 Fabian Groffen gentoo-dev 2008-02-18 21:37:11 UTC
by the way, there is just one warning that remains:

i386-pc-solaris2.10-gcc -O3 -pipe -std=gnu99 main.c -o q
In file included from include_applets.h:10,
                 from main.c:1050:
quse.c: In function ‘quse_main’:
quse.c:348: warning: the address of ‘buf0’ will never be NULL
>>> Source compiled.
Comment 3 solar (RETIRED) gentoo-dev 2008-03-15 03:30:37 UTC
Created attachment 146182 [details, diff]
compat.diff

If we can Let's not litter all over the place with #ifdef __sun__ 
Perhaps we can try to put as much as we can in compat files..
I'd really like to avoid having to prefix a (const char *) with (char *)..
Perhaps we can define an alternative structs in compat.c/.h ?
Attached is the incomplete idea.
Comment 4 Michael Haubenwallner (RETIRED) gentoo-dev 2008-07-31 13:44:34 UTC
Created attachment 161838 [details, diff]
solaris patch when using gnulib

I've had much success when using the missing GNU things from dev-libs/gnulib.
So the solaris patch can be reduced to this one, when -Ignulib/include is in CFLAGS and libgnulib.a on LDFLAGS.

Patch-Description what is still necessary:
LDFLAGS must come after main.c on the linkline, or gnulib-symbols would be thrown away too early.
The 'regex' symbol is still predefined and should be renamed.
Haven't found <sys/dir.h> in gnulib.
Works on aix too when using 'dirent' instead of 'direct'.
Haven't found S_BLKSIZE in gnulib.
Comment 5 Michael Haubenwallner (RETIRED) gentoo-dev 2008-07-31 13:47:01 UTC
Created attachment 161842 [details, diff]
patch for aix when using gnulib

When using dev-libs/gnulib, for AIX only this patch is necessary.

Still no S_BLKSIZE in gnulib.
How wonder, AIX (5.3) understands _LINUX_SOURCE_COMPAT in its headers.
Comment 6 Michael Haubenwallner (RETIRED) gentoo-dev 2008-07-31 16:02:15 UTC
Uhm, just have seen on the solaris2.9 box here, that - unlike solaris2.10 - it does have neither scandir() nor alphasort() in libc (/usr/include/dirent.h).

And gnulib does have neither scandir() nor alphasort() too.

gnulib only provides opendir() and closedir(), while solaris2.9 has readdir(), opendir(), fdopendir(), telldir(), seekdir(), rewinddir(), closedir().
Comment 7 solar (RETIRED) gentoo-dev 2008-07-31 16:20:50 UTC
When attaching diffs please do so to the CVS version as I'm pretty sure we fixed solaris support already. 

cvs -d :pserver:anonymous@anoncvs.gentoo.org:/var/cvsroot co gentoo-projects/portage-utils
Comment 8 Fabian Groffen gentoo-dev 2008-07-31 19:06:45 UTC
I recall we had a bug on it with Solaris 9.  Our gnulib thing might solve #209237 as well.  Seems I'm confused with pax-utils (bug #201131) on the Solaris 9 thing.
Comment 9 Fabian Groffen gentoo-dev 2008-09-13 15:40:46 UTC
haubi, we shouldn't be using LDFLAGS for -lgnu, but LIBADD instead.  Your reordering upsets --as-needed people.
Comment 10 Fabian Groffen gentoo-dev 2008-09-13 15:43:57 UTC
@solar: in revision 1.155 of main.c you introduced a strnlen call.  strnlen isn't posix, but a GNU addition.
Comment 11 Fabian Groffen gentoo-dev 2008-09-13 15:54:14 UTC
(I'm on windows so can't attach a file, sorry)

This patch removes the strnlen usage.  In fact the strnlen was useless anyway, since the array was supposed to be NULL-terminated by the if-block.  However, an off-by-one error was in there, possibly resulting in a buffer overflow write.


Index: main.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/portage-utils/main.c,v
retrieving revision 1.155
diff -u -r1.155 main.c
--- main.c      11 May 2008 17:25:00 -0000      1.155
+++ main.c      13 Sep 2008 15:50:21 -0000
@@ -482,14 +482,14 @@
                        strncat(portroot, "/", sizeof(portroot));

        f = 0;
-       profilelen = readlink("/etc/make.profile", profile, sizeof(profile));
+       profilelen = readlink("/etc/make.profile", profile, sizeof(profile) - 1);
        if (profilelen == -1)
                strcpy(profile, "/etc/make.profile");
        else
                profile[profilelen]='\0';

        if (profile[0] != '/') {
-               memmove(profile+5, profile, strnlen(profile, (size_t)profilelen)+1);
+               memmove(profile+5, profile, strlen(profile)+1);
                memcpy(profile, "/etc/", 5);
        }
        do {
Comment 12 Fabian Groffen gentoo-dev 2008-09-13 15:59:21 UTC
The compiler isn't amused by the pointer mismatches (* vs ** I guess), but I don't see why one wouldn't use void * here in this case anyway.


Index: qcache.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/portage-utils/qcache.c,v
retrieving revision 1.33
diff -u -r1.33 qcache.c
--- qcache.c    15 Mar 2008 16:28:06 -0000      1.33
+++ qcache.c    13 Sep 2008 15:57:51 -0000
@@ -440,10 +440,10 @@
  *   1 (OLDER)
  *   0 (SAME)
  */
-int qcache_vercmp(const void *x, const void *y);
-int qcache_vercmp(const void *x, const void *y)
+int qcache_vercmp(const struct dirent **x, const struct dirent **y);
+int qcache_vercmp(const struct dirent **x, const struct dirent **y)
 {
-       switch (atom_compare_str((*((const struct dirent **)x))->d_name, (*((const struct dirent **)y))->d_name)) {
+       switch (atom_compare_str((*x)->d_name, (*y)->d_name)) {
                case NEWER: return -1;
                case OLDER: return  1;
                default:    return  0;
Comment 13 Fabian Groffen gentoo-dev 2008-09-13 16:01:39 UTC
This is the last patch that's required for compilation with gnulib on Solaris.

@solar: if you agree with the patches I can commit them if you want.  I'll try to do the aix patch "cleaner" later


Index: libq/compat.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/portage-utils/libq/compat.c,v
retrieving revision 1.2
diff -u -r1.2 compat.c
--- libq/compat.c       12 Apr 2008 17:25:59 -0000      1.2
+++ libq/compat.c       13 Sep 2008 15:59:42 -0000
@@ -8,18 +8,6 @@

 #define S_BLKSIZE DK_DEVID_BLKSIZE

-/* strcasestr is a GNU extention */
-static char* strcasestr(const char *big, const char *little) {
-       char* b = alloca((strlen(big) + 1) * sizeof(char));
-       char* l = alloca((strlen(little) + 1) * sizeof(char));
-       char* off;
-       size_t i;
-       for (i = 0; big[i]; i++) b[i] = (char)tolower(big[i]);
-       for (i = 0; little[i]; i++) l[i] = (char)tolower(little[i]);
-       off = strstr(b, l);
-       return(off == NULL ? off : (char*)(big + (off - b)));
-}
-
 #undef  xasprintf
 #define xasprintf(strp, fmt, args...) \
        do { /* xasprintf() */ \
Comment 14 Fabian Groffen gentoo-dev 2008-09-13 17:28:35 UTC
Created attachment 165344 [details, diff]
solaris patch when using gnulib against CVS

Here's the patch as proper file.  The longer I look at the code, the more I'd like to get rid of gnulib and GNU extensions and just make it POSIX compatible, though...
Comment 15 solar (RETIRED) gentoo-dev 2008-09-13 17:54:09 UTC
Just add yourself to the portage-utils@ alias and add the patches that fix other 
arches. I think you know our code well enough from this and pax-utils. "Just fix anything you break for others". Please test your compiles on a linux box as well as a uclibc chroot if you have one. Commit whatever you feel is required for the arches you want it supported on. And push a 0.1.30 when you are ready.
Comment 16 Michael Haubenwallner (RETIRED) gentoo-dev 2008-09-14 06:52:33 UTC
(In reply to comment #14)
> solaris patch when using gnulib against CVS

(sorry, I'm low on time recently, but...)

Is the use of scandir/alphasort removed in CVS (not available on solaris2.9)?

Because gnulib still does not provide them AFAICT.
Comment 17 Fabian Groffen gentoo-dev 2008-09-14 08:16:50 UTC
I've started hacking the sources yesterday to make them POSIX compliant.  scandir/alphasort are untouched though.  Any idea how that has to be done for Solaris 8 and 9?
Comment 18 solar (RETIRED) gentoo-dev 2008-09-14 15:43:45 UTC
(In reply to comment #17)
> I've started hacking the sources yesterday to make them POSIX compliant. 
> scandir/alphasort are untouched though.  Any idea how that has to be done for
> Solaris 8 and 

readdir() + malloc() + qsort() 
Comment 19 Fabian Groffen gentoo-dev 2009-10-19 20:56:45 UTC
afaict I committed all patches that we had, so that should render this bug fixed