FreeBSD Port: sysutils/consolekit2
Robin Seggelmann
robin at seggelmann.com
Fri Aug 18 09:50:39 UTC 2017
Hi,
I’m trying to build consolekit2 as a dependency for xfce4 on FreeBSD 10.3 on a PowerPC G4, but came across two compilation errors I’d like to report:
ck-sysdeps-unix.c: In function 'ck_get_socket_peer_credentials':
ck-sysdeps-unix.c:176: error: 'for' loop initial declaration used outside C99 mode
gmake[5]: *** [Makefile:1276: ck-sysdeps-unix.lo] Error 1
The section of the corresponding file looks like that:
#ifdef __FreeBSD__
kd = kvm_openfiles (NULL, _PATH_DEVNULL, NULL, O_RDONLY, errbuf);
if (kd == NULL) {
g_warning ("kvm_openfiles failed: %s", errbuf);
return FALSE;
}
prc = kvm_getprocs (kd, KERN_PROC_UID, uid_read, &cnt);
for (int i = 0; i < cnt; i++) {
if(strncmp (prc[i].ki_comm, "Xorg", 4) == 0) {
pid_read = prc[i].ki_pid;
break;
}
}
kvm_close(kd);
#endif /* __FreeBSD__ */
This can be fixed with the following patch:
--- work/ConsoleKit2-1.2.0/src/ck-sysdeps-unix.c.orig 2017-08-18 11:32:04.192493000 +0200
+++ work/ConsoleKit2-1.2.0/src/ck-sysdeps-unix.c 2017-08-18 11:32:24.414818000 +0200
@@ -173,7 +173,8 @@
}
prc = kvm_getprocs (kd, KERN_PROC_UID, uid_read, &cnt);
- for (int i = 0; i < cnt; i++) {
+ int i;
+ for (i = 0; i < cnt; i++) {
if(strncmp (prc[i].ki_comm, "Xorg", 4) == 0) {
pid_read = prc[i].ki_pid;
break;
After this fix the next error shows up, basically the same issue:
ck-get-x11-display-device.c: In function 'get_tty_for_pid':
ck-get-x11-display-device.c:87: error: 'for' loop initial declaration used outside C99 mode
gmake[4]: *** [Makefile:996: ck-get-x11-display-device.o] Error 1
The part of the corresponding file:
#ifdef __FreeBSD__
#include <libprocstat.h>
static char *
get_tty_for_pid (int pid)
{
gchar *device = NULL;
gboolean res;
char errstr[_POSIX2_LINE_MAX];
int cnt = 0;
struct vnstat vn;
struct filestat_list *head;
struct filestat *fst;
kvm_t* kd;
struct kinfo_proc * prc;
struct procstat *procstat;
kd = kvm_openfiles (NULL, "/dev/null", NULL, O_RDONLY, errstr);
prc = kvm_getprocs (kd, KERN_PROC_PID, pid, &cnt);
procstat = procstat_open_sysctl ();
for (int i = 0; i < cnt; i++) {
head = procstat_getfiles (procstat,&prc[i], 0);
STAILQ_FOREACH (fst, head, next) {
if (fst->fs_type == PS_FST_TYPE_VNODE) {
procstat_get_vnode_info (procstat, fst, &vn, NULL);
if (vn.vn_type == PS_FST_VTYPE_VCHR) {
char *ctty = devname( prc[i].ki_tdev,S_IFCHR);
const char * pre = "ttyv";
if(strncmp (pre, vn.vn_devname, strlen (pre)) == 0 && strncmp (vn.vn_devname, ctty, strlen(ctty)) != 0) {
device = g_strdup_printf ("/dev/%s", vn.vn_devname);
procstat_freefiles (procstat, head);
res = TRUE;
return device;
}
}
}
}
}
procstat_freefiles(procstat, head);
return device;
}
#else /* __FreeBSD__ */
The patch for this is also similar:
--- work/ConsoleKit2-1.2.0/tools/ck-get-x11-display-device.c.orig 2017-08-18 11:42:01.953620000 +0200
+++ work/ConsoleKit2-1.2.0/tools/ck-get-x11-display-device.c 2017-08-18 11:42:21.864176000 +0200
@@ -84,7 +84,8 @@
prc = kvm_getprocs (kd, KERN_PROC_PID, pid, &cnt);
procstat = procstat_open_sysctl ();
- for (int i = 0; i < cnt; i++) {
+ int i;
+ for (i = 0; i < cnt; i++) {
head = procstat_getfiles (procstat,&prc[i], 0);
STAILQ_FOREACH (fst, head, next) {
After that the build is successful and the package installs. I have also attached the entire build output.
Best regards,
Robin
More information about the freebsd-gnome
mailing list