Ravenports generated: 16 Jun 2017 21:59
[ravenports.git] / bucket_E7 / xorg-server
1 # Buildsheet autogenerated by ravenadm tool -- Do not edit.
2
3 NAMEBASE=               xorg-server
4 VERSION=                1.19.3
5 KEYWORDS=               x11_servers
6 VARIANTS=               standard virtual dmx xephyr nest wayland
7 SDESC[xephyr]=          X server from X.Org based on kdrive
8 SDESC[virtual]=         X virtual framebuffer server from X.Org
9 SDESC[wayland]=         X Clients under Wayland
10 SDESC[standard]=        X.Org X server and related programs
11 SDESC[dmx]=             Distributed Multihead X from X.Org
12 SDESC[nest]=            Nesting X server from X.Org
13 HOMEPAGE=               https://www.x.org/
14 CONTACT=                nobody
15
16 DOWNLOAD_GROUPS=        main
17 SITES[main]=            XORG/individual/xserver
18 DISTFILE[1]=            xorg-server-1.19.3.tar.bz2:main
19 DF_INDEX=               1
20 SPKGS[xephyr]=          single
21 SPKGS[virtual]=         single
22 SPKGS[wayland]=         single
23 SPKGS[standard]=        single
24 SPKGS[dmx]=             single
25 SPKGS[nest]=            single
26
27 OPTIONS_AVAILABLE=      XORG VIRTUAL DMX XEPHYR NEST WAYLAND DEVD SUID
28 OPTIONS_STANDARD=       XORG DEVD SUID
29 VOPTS[xephyr]=          XORG=OFF VIRTUAL=OFF DMX=OFF XEPHYR=ON NEST=OFF WAYLAND=OFF DEVD=OFF
30                         SUID=OFF
31 VOPTS[virtual]=         XORG=OFF VIRTUAL=ON DMX=OFF XEPHYR=OFF NEST=OFF WAYLAND=OFF DEVD=OFF
32                         SUID=OFF
33 VOPTS[wayland]=         XORG=OFF VIRTUAL=OFF DMX=OFF XEPHYR=OFF NEST=OFF WAYLAND=ON DEVD=OFF
34                         SUID=OFF
35 VOPTS[dmx]=             XORG=OFF VIRTUAL=OFF DMX=ON XEPHYR=OFF NEST=OFF WAYLAND=OFF DEVD=OFF
36                         SUID=OFF
37 VOPTS[nest]=            XORG=OFF VIRTUAL=OFF DMX=OFF XEPHYR=OFF NEST=ON WAYLAND=OFF DEVD=OFF
38                         SUID=OFF
39 OPT_ON[all]=            XORG SUID
40
41 BUILD_DEPENDS=          xorg-fontutil:single:standard
42                         xorg-xkbfile:single:standard
43 RUN_DEPENDS=            xorg-xkeyboard-config:single:standard
44                         xorg-xkbcomp:single:standard
45
46 USES=                   gmake libtool perl:build ssl
47 XORG_COMPONENTS=        bigreqsproto compositeproto damageproto dri2proto dri3proto fixesproto
48                         fontsproto glproto inputproto kbproto pixman presentproto randrproto
49                         recordproto renderproto resourceproto scrnsaverproto videoproto xtransproto
50                         xcmiscproto xextproto xf86driproto xineramaproto xproto xshmfence xau xdmcp
51                         xfont2
52
53 FPC_EQUIVALENT=         x11-servers/xorg-server
54
55 MUST_CONFIGURE=         gnu
56 CONFIGURE_ARGS=         --with-xkb-path={{LOCALBASE}}/share/X11/xkb
57                         --with-fontrootdir={{LOCALBASE}}/share/fonts
58                         --without-doxygen
59                         --without-xmlto
60                         --without-fop
61                         --localstatedir=/var
62                         --with-shared-memory-dir=/tmp
63                         --disable-config-hal
64                         --disable-config-udev
65                         --disable-config-udev-kms
66                         --disable-install-setuid
67                         --without-dtrace
68                         --enable-glamor
69                         --enable-xcsecurity
70
71 INSTALL_TARGET=         install-strip
72
73 [DEVD].DESCRIPTION=                     Use devd for autoconfiguration of input devices
74
75 [NEST].DESCRIPTION=                     Build as nesting X server
76 [NEST].BUILD_DEPENDS_ON=                libepoxy:single:standard
77                                         mesa:drivers:standard
78 [NEST].CONFIGURE_ENABLE_BOTH=           xnest
79 [NEST].USES_ON=                         mesa
80 [NEST].XORG_COMPONENTS_ON=              x11
81                                         xext
82
83 [XEPHYR].DESCRIPTION=                   Build as kdrive-base X server
84 [XEPHYR].BUILDRUN_DEPENDS_ON=           libdrm:single:standard
85                                         libepoxy:single:standard
86 [XEPHYR].BUILD_DEPENDS_ON=              mesa:drivers:standard
87 [XEPHYR].CONFIGURE_ENABLE_BOTH=         xephyr
88                                         kdrive
89 [XEPHYR].USES_ON=                       mesa
90 [XEPHYR].XORG_COMPONENTS_ON=            x11
91                                         xcb
92                                         xcb-util
93                                         xcb-util-image
94                                         xcb-util-wm
95                                         xcb-util-keysyms
96                                         xcb-render-util
97
98 [DMX].DESCRIPTION=                      Build as distributed multihead X server
99 [DMX].BUILD_DEPENDS_ON=                 libepoxy:single:standard
100                                         mesa:drivers:standard
101                                         xorg-xtst:single:standard
102                                         xorg-xres:single:standard
103 [DMX].CONFIGURE_ENABLE_BOTH=            dmx
104 [DMX].XORG_COMPONENTS_ON=               dmx
105                                         x11
106                                         xaw
107                                         xext
108                                         xfixes
109                                         xi
110                                         xmu
111                                         xpm
112                                         xrender
113                                         xt
114
115 [VIRTUAL].DESCRIPTION=                  Build as virtual framebuffer server
116 [VIRTUAL].BUILD_DEPENDS_ON=             libepoxy:single:standard
117                                         mesa:drivers:standard
118 [VIRTUAL].CONFIGURE_ENABLE_BOTH=        xvfb
119 [VIRTUAL].USES_ON=                      mesa
120
121 [XORG].DESCRIPTION=                     Build as X server (don't change setting!)
122 [XORG].BUILDRUN_DEPENDS_ON=             libdrm:single:standard
123                                         libepoxy:single:standard
124                                         mesa:drivers:standard
125 [XORG].CONFIGURE_ENABLE_BOTH=           docs
126                                         devel-docs
127                                         xorg
128 [XORG].SUB_FILES_ON=                    pkg-install
129                                         pkg-deinstall
130 [XORG].USES_ON=                         mesa
131 [XORG].XORG_COMPONENTS_ON=              pciaccess
132                                         xf86dgaproto
133                                         xf86vidmodeproto
134                                         xfont2
135
136 [WAYLAND].DESCRIPTION=                  Build Wayland X clients
137 [WAYLAND].BROKEN_ON=                    Wayland itself not yet implemented
138 [WAYLAND].BUILDRUN_DEPENDS_ON=          libdrm:single:standard
139                                         libepoxy:single:standard
140 [WAYLAND].BUILD_DEPENDS_ON=             mesa:drivers:standard
141 [WAYLAND].CONFIGURE_ARGS_ON=            --disable-xquartz
142                                         --disable-xwin
143 [WAYLAND].CONFIGURE_ENABLE_BOTH=        xwayland
144 [WAYLAND].XORG_COMPONENTS_ON=           x11
145                                         xext
146
147 [SUID].DESCRIPTION=                     Install the Xorg server with setuid bit set
148
149 post-patch:
150         @${REINPLACE_CMD} 's/test.*-traditional.*;/true;/' ${WRKSRC}/configure
151         # build libglx.so but don't install it yet. (done in pre-install)
152         @${REINPLACE_CMD} -e 's|@GLX_TRUE@GLXMODS =|@GLX_BOGUS@GLXMODS =|g' \
153                 -e 's|^LTLIBRARIES = |LTLIBRARIES = libglx.la |g' \
154                 ${WRKSRC}/hw/xfree86/dixmods/Makefile.in
155
156 do-install-XEPHYR-ON:
157         (cd ${WRKSRC}/hw/kdrive/ephyr && \
158                 DESTDIR=${STAGEDIR} ${MAKE_CMD} install)
159
160 do-install-WAYLAND-ON:
161         (cd ${WRKSRC}/hw/xwayland && \
162                 DESTDIR=${STAGEDIR} ${MAKE_CMD} install)
163
164 post-install-XORG-OFF:
165         ${RM} -r ${STAGEDIR}${PREFIX}/lib/xorg
166         ${RM} ${STAGEDIR}${PREFIX}/share/man/man1/Xserver.1
167
168 post-configure-DEVD-ON:
169         @${REINPLACE_CMD} -e 's|config\.c|config.c devd.c|g' \
170                 -e 's|config\.lo|config.lo devd.lo|g' \
171                 ${WRKSRC}/config/Makefile
172         @${REINPLACE_CMD} -e 's|^/\* #undef CONFIG_UDEV \*/|#define CONFIG_DEVD 1|' \
173                 ${WRKSRC}/include/dix-config.h
174
175 do-install-VIRTUAL-ON:
176         (cd ${WRKSRC}/hw/vfb && \
177                 DESTDIR=${STAGEDIR} ${MAKE_CMD} install)
178
179 do-install-NEST-ON:
180         (cd ${WRKSRC}/hw/xnest && \
181                 DESTDIR=${STAGEDIR} ${MAKE_CMD} install)
182
183 do-install-DMX-ON:
184         (cd ${WRKSRC}/hw/dmx && \
185                 DESTDIR=${STAGEDIR} ${MAKE_CMD} install)
186
187 post-install-XORG-ON:
188         # The .xorg dir because else the xorg-server might not load the
189         # correct libglx module.
190         @${MKDIR} ${STAGEDIR}${PREFIX}/lib/xorg/modules/extensions/.xorg
191         ${INSTALL_LIB} ${WRKSRC}/hw/xfree86/dixmods/.libs/libglx.so \
192                 ${STAGEDIR}${PREFIX}/lib/xorg/modules/extensions/.xorg/
193         @${MKDIR} ${STAGEDIR}${PREFIX}/etc/X11/xorg.conf.d
194         ${RM} -r ${STAGEDIR}/var
195
196 [FILE:71:descriptions/desc.single.standard]
197 This package contains the X.Org X server and some associated programs.
198
199
200 [FILE:60:descriptions/desc.single.virtual]
201 This package contains Xvfb, a virtual framebuffer X server.
202
203
204 [FILE:287:descriptions/desc.single.dmx]
205 Xdmx is proxy X server that provides multi-head support for multiple
206 displays attached to different machines (each of which is running a
207 typical X server).  When Xinerama is used with Xdmx, the multiple displays
208 on multiple machines are presented to the user as a single unified screen.
209
210
211 [FILE:173:descriptions/desc.single.xephyr]
212 Xephyr is a kdrive server that outputs to a window on a pre-existing
213 'host' X display.  Think Xnest but with support for modern extensions
214 like composite, damage and randr.
215
216
217 [FILE:78:descriptions/desc.single.nest]
218 This package contains Xnest, a nesting X Server that displays on an X
219 Server.
220
221
222 [FILE:148:descriptions/desc.single.wayland]
223 XWayland is an X Server running as a Wayland client, thus capable of
224 displaying native X11 client applications in a Wayland compositor
225 environment.
226
227
228 [FILE:105:distinfo]
229 677a8166e03474719238dfe396ce673c4234735464d6dadf2959b600d20e5a98      6050221 xorg-server-1.19.3.tar.bz2
230
231
232 [FILE:2433:manifests/plist.single.standard]
233 bin/
234  X
235 %%SUID-ON%%@(,,4555) bin/Xorg
236 %%SUID-OFF%%bin/Xorg
237  cvt
238  gtf
239 include/xorg/
240  BT.h
241  IBM.h
242  TI.h
243  XIstubs.h
244  Xprintf.h
245  callback.h
246  client.h
247  closestr.h
248  closure.h
249  colormap.h
250  colormapst.h
251  compiler.h
252  compositeext.h
253  cursor.h
254  cursorstr.h
255  damage.h
256  damagestr.h
257  dbestruct.h
258  dgaproc.h
259  displaymode.h
260  dix.h
261  dixaccess.h
262  dixevents.h
263  dixfont.h
264  dixfontstr.h
265  dixgrabs.h
266  dixstruct.h
267  dri.h
268  dri2.h
269  dri3.h
270  dristruct.h
271  edid.h
272  events.h
273  exa.h
274  exevents.h
275  extension.h
276  extinit.h
277  extnsionst.h
278  fb.h
279  fbdevhw.h
280  fboverlay.h
281  fbpict.h
282  fbrop.h
283  fourcc.h
284  gc.h
285  gcstruct.h
286  geext.h
287  geint.h
288  glamor.h
289  globals.h
290  glx_extinit.h
291  glyphstr.h
292  hotplug.h
293  i2c_def.h
294  input.h
295  inputstr.h
296  list.h
297  mi.h
298  micmap.h
299  micoord.h
300  migc.h
301  miline.h
302  mioverlay.h
303  mipict.h
304  mipointer.h
305  mipointrst.h
306  misc.h
307  miscstruct.h
308  mistruct.h
309  misync.h
310  misyncfd.h
311  misyncshm.h
312  misyncstr.h
313  mizerarc.h
314  nonsdk_extinit.h
315  opaque.h
316  optionstr.h
317  os.h
318  panoramiX.h
319  panoramiXsrv.h
320  picture.h
321  picturestr.h
322  pixmap.h
323  pixmapstr.h
324  present.h
325  presentext.h
326  privates.h
327  property.h
328  propertyst.h
329  ptrveloc.h
330  randrstr.h
331  region.h
332  regionstr.h
333  registry.h
334  resource.h
335  rgb.h
336  rrtransform.h
337  sarea.h
338  screenint.h
339  scrnintstr.h
340  selection.h
341  servermd.h
342  shadow.h
343  shadowfb.h
344  shmint.h
345  site.h
346  syncsdk.h
347  validate.h
348  vbe.h
349  vbeModes.h
350  vgaHW.h
351  wfbrename.h
352  window.h
353  windowstr.h
354  xaarop.h
355  xace.h
356  xacestr.h
357  xf86.h
358  xf86Crtc.h
359  xf86Cursor.h
360  xf86DDC.h
361  xf86Modes.h
362  xf86Module.h
363  xf86Opt.h
364  xf86Optionstr.h
365  xf86Optrec.h
366  xf86Parser.h
367  xf86Pci.h
368  xf86PciInfo.h
369  xf86Priv.h
370  xf86Privstr.h
371  xf86RamDac.h
372  xf86RandR12.h
373  xf86VGAarbiter.h
374  xf86Xinput.h
375  xf86_OSlib.h
376  xf86_OSproc.h
377  xf86cmap.h
378  xf86fbman.h
379  xf86i2c.h
380  xf86int10.h
381  xf86platformBus.h
382  xf86sbusBus.h
383  xf86str.h
384  xf86xv.h
385  xf86xvmc.h
386  xf86xvpriv.h
387  xisb.h
388  xkbfile.h
389  xkbrules.h
390  xkbsrv.h
391  xkbstr.h
392  xorg-server.h
393  xorgVersion.h
394  xserver_poll.h
395  xserver-properties.h
396  xvdix.h
397  xvmcext.h
398 lib/xorg/modules/drivers/modesetting_drv.so
399 lib/xorg/modules/extensions/.xorg/libglx.so
400 lib/xorg/modules/
401  libexa.so
402  libfb.so
403  libfbdevhw.so
404  libglamoregl.so
405  libint10.so
406  libshadow.so
407  libshadowfb.so
408  libvbe.so
409  libvgahw.so
410  libwfb.so
411 lib/xorg/protocol.txt
412 lib/pkgconfig/xorg-server.pc
413 share/man/man1/
414  Xorg.1.gz
415  Xserver.1.gz
416  cvt.1.gz
417  gtf.1.gz
418 share/man/man4/
419  exa.4.gz
420  fbdevhw.4.gz
421  modesetting.4.gz
422 share/man/man5/
423  xorg.conf.5.gz
424  xorg.conf.d.5.gz
425 share/aclocal/xorg-server.m4
426 @dir etc/X11/xorg.conf.d
427
428
429 [FILE:34:manifests/plist.single.virtual]
430 bin/Xvfb
431 share/man/man1/Xvfb.1.gz
432
433
434 [FILE:214:manifests/plist.single.dmx]
435 bin/
436  Xdmx
437  dmxaddinput
438  dmxaddscreen
439  dmxinfo
440  dmxreconfig
441  dmxresize
442  dmxrminput
443  dmxrmscreen
444  dmxtodmx
445  dmxwininfo
446  vdltodmx
447  xdmxconfig
448 share/man/man1/
449  Xdmx.1.gz
450  dmxtodmx.1.gz
451  vdltodmx.1.gz
452  xdmxconfig.1.gz
453
454
455 [FILE:38:manifests/plist.single.xephyr]
456 bin/Xephyr
457 share/man/man1/Xephyr.1.gz
458
459
460 [FILE:36:manifests/plist.single.nest]
461 bin/Xnest
462 share/man/man1/Xnest.1.gz
463
464
465 [FILE:13:manifests/plist.single.wayland]
466 bin/Xwayland
467
468
469 [FILE:293:patches/patch-config_config-backends.h]
470 --- config/config-backends.h.orig       2016-07-15 16:17:45 UTC
471 +++ config/config-backends.h
472 @@ -44,3 +44,8 @@ void config_hal_fini(void);
473  int config_wscons_init(void);
474  void config_wscons_fini(void);
475  #endif
476 +
477 +#ifdef CONFIG_DEVD
478 +int config_devd_init(void);
479 +void config_devd_fini(void);
480 +#endif
481
482
483 [FILE:537:patches/patch-config_config.c]
484 --- config/config.c.orig        2016-07-19 17:07:29 UTC
485 +++ config/config.c
486 @@ -55,6 +55,9 @@ config_init(void)
487  #elif defined(CONFIG_WSCONS)
488      if (!config_wscons_init())
489          ErrorF("[config] failed to initialise wscons\n");
490 +#elif defined(CONFIG_DEVD)
491 +    if (!config_devd_init())
492 +        ErrorF("[config] failed to initialise devd\n");
493  #endif
494  }
495  
496 @@ -67,6 +70,8 @@ config_fini(void)
497      config_hal_fini();
498  #elif defined(CONFIG_WSCONS)
499      config_wscons_fini();
500 +#elif defined(CONFIG_DEVD)
501 +    config_devd_fini();
502  #endif
503  }
504  
505
506
507 [FILE:12180:patches/patch-config_devd.c]
508 --- config/devd.c.orig  2017-01-19 15:20:42 UTC
509 +++ config/devd.c
510 @@ -0,0 +1,532 @@
511 +/*
512 + * Copyright (c) 2012 Baptiste Daroussin
513 + * Copyright (c) 2013, 2014 Alex Kozlov
514 + * Copyright (c) 2014 Robert Millan
515 + * Copyright (c) 2014 Jean-Sebastien Pedron
516 + *
517 + * Permission is hereby granted, free of charge, to any person obtaining a
518 + * copy of this software and associated documentation files (the "Software"),
519 + * to deal in the Software without restriction, including without limitation
520 + * the rights to use, copy, modify, merge, publish, distribute, sublicense,
521 + * and/or sell copies of the Software, and to permit persons to whom the
522 + * Software is furnished to do so, subject to the following conditions:
523 + *
524 + * The above copyright notice and this permission notice (including the next
525 + * paragraph) shall be included in all copies or substantial portions of the
526 + * Software.
527 + *
528 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
529 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
530 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
531 + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
532 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
533 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
534 + * DEALINGS IN THE SOFTWARE.
535 + *
536 + * Author: Baptiste Daroussin <bapt@FreeBSD.org>
537 + */
538 +
539 +#ifdef HAVE_DIX_CONFIG_H
540 +#include <dix-config.h>
541 +#endif
542 +
543 +#include <sys/types.h>
544 +#include <sys/kbio.h>
545 +#include <sys/socket.h>
546 +#include <sys/stat.h>
547 +#include <sys/sysctl.h>
548 +#include <sys/un.h>
549 +
550 +#include <ctype.h>
551 +#include <errno.h>
552 +#include <fcntl.h>
553 +#include <stdlib.h>
554 +#include <stdio.h>
555 +#include <stdbool.h>
556 +#include <unistd.h>
557 +
558 +#include "input.h"
559 +#include "inputstr.h"
560 +#include "hotplug.h"
561 +#include "config-backends.h"
562 +#include "os.h"
563 +
564 +#define DEVD_SOCK_PATH "/var/run/devd.pipe"
565 +
566 +#define DEVD_EVENT_ADD         '+'
567 +#define DEVD_EVENT_REMOVE      '-'
568 +
569 +#define RECONNECT_DELAY                5 * 1000
570 +
571 +static int sock_devd;
572 +static bool is_console_kbd = false;
573 +static bool is_kbdmux = false;
574 +static OsTimerPtr rtimer = NULL;
575 +
576 +struct hw_type {
577 +       const char *driver;
578 +       int flag;
579 +       const char *xdriver;
580 +};
581 +
582 +static struct hw_type hw_types[] = {
583 +       { "ukbd", ATTR_KEYBOARD, "kbd" },
584 +       { "atkbd", ATTR_KEYBOARD, "kbd" },
585 +       { "kbdmux", ATTR_KEYBOARD, "kbd" },
586 +       { "sysmouse", ATTR_POINTER, "mouse" },
587 +       { "ums", ATTR_POINTER, "mouse" },
588 +       { "psm", ATTR_POINTER, "mouse" },
589 +       { "vboxguest", ATTR_POINTER, "vboxmouse" },
590 +       { "joy", ATTR_JOYSTICK, NULL },
591 +       { "atp", ATTR_TOUCHPAD, NULL },
592 +       { "uep", ATTR_TOUCHSCREEN, NULL },
593 +       { NULL, -1, NULL },
594 +};
595 +
596 +static bool
597 +sysctl_exists(const struct hw_type *device, int unit,
598 +       char *devname, size_t devname_len)
599 +{
600 +       char sysctlname[PATH_MAX];
601 +       size_t len;
602 +       int ret;
603 +
604 +       if (device == NULL || device->driver == NULL)
605 +               return false;
606 +
607 +       /* Check if a sysctl exists. */
608 +       snprintf(sysctlname, sizeof(sysctlname), "dev.%s.%i.%%desc",
609 +           device->driver, unit);
610 +       ret = sysctlbyname(sysctlname, NULL, &len, NULL, 0);
611 +
612 +       if (ret == 0 && len > 0) {
613 +               snprintf(devname, devname_len, "%s%i", device->driver, unit);
614 +               return true;
615 +       }
616 +
617 +       return false;
618 +}
619 +
620 +static bool
621 +devpath_exists(const struct hw_type *device,
622 +       char *devname, size_t devname_len)
623 +{
624 +       char *devpath;
625 +       struct stat st;
626 +       int ret;
627 +
628 +       if (device == NULL || device->driver == NULL)
629 +               return false;
630 +
631 +       /* Check if /dev/$driver exists. */
632 +       asprintf(&devpath, "/dev/%s", device->driver);
633 +       if (devpath == NULL)
634 +               return false;
635 +
636 +       ret = stat(devpath, &st);
637 +       free(devpath);
638 +
639 +       if (ret == 0) {
640 +               strncpy(devname, device->driver, devname_len);
641 +               return true;
642 +       }
643 +
644 +       return false;
645 +}
646 +
647 +static char *
648 +sysctl_get_str(const char *sysctlname)
649 +{
650 +       char *dest = NULL;
651 +       size_t len;
652 +
653 +       if (sysctlname == NULL)
654 +               return NULL;
655 +
656 +       if (sysctlbyname(sysctlname, NULL, &len, NULL, 0) == 0) {
657 +               dest = malloc(len + 1);
658 +               if (dest) {
659 +                       if (sysctlbyname(sysctlname, dest, &len, NULL, 0) == 0)
660 +                               dest[len] = '\0';
661 +                       else {
662 +                               free(dest);
663 +                               dest = NULL;
664 +                       }
665 +               }
666 +       }
667 +
668 +       return dest;
669 +}
670 +
671 +static void
672 +device_added(const char *devname)
673 +{
674 +       char path[PATH_MAX];
675 +       char sysctlname[PATH_MAX];
676 +       char *vendor;
677 +       char *product = NULL;
678 +       char *config_info = NULL;
679 +       char *walk;
680 +       InputOption *options = NULL;
681 +       InputAttributes attrs = { };
682 +       DeviceIntPtr dev = NULL;
683 +       int i;
684 +       int fd;
685 +
686 +       for (i = 0; hw_types[i].driver != NULL; i++) {
687 +               size_t len;
688 +
689 +               len = strlen(hw_types[i].driver);
690 +               if (strcmp(devname, hw_types[i].driver) == 0 ||
691 +                       (strncmp(devname, hw_types[i].driver, len) == 0 &&
692 +                               isnumber(*(devname + len)))) {
693 +                       attrs.flags |= hw_types[i].flag;
694 +                       break;
695 +               }
696 +       }
697 +
698 +       if (hw_types[i].driver == NULL || hw_types[i].xdriver == NULL) {
699 +               LogMessage(X_INFO, "config/devd: ignoring device %s\n",
700 +                               devname);
701 +               return;
702 +       }
703 +
704 +       /* Skip keyboard devices if kbdmux is enabled */
705 +       if (is_kbdmux && is_console_kbd && hw_types[i].flag & ATTR_KEYBOARD) {
706 +               LogMessage(X_INFO, "config/devd: kbdmux is enabled, ignoring device %s\n",
707 +                               devname);
708 +               return;
709 +       }
710 +
711 +       snprintf(path, sizeof(path), "/dev/%s", devname);
712 +
713 +       options = input_option_new(NULL, "_source", "server/devd");
714 +       if (!options)
715 +               return;
716 +
717 +       snprintf(sysctlname, sizeof(sysctlname), "dev.%s.%s.%%desc",
718 +           hw_types[i].driver, devname + strlen(hw_types[i].driver));
719 +       vendor = sysctl_get_str(sysctlname);
720 +       if (vendor == NULL) {
721 +               options = input_option_new(options, "name", devname);
722 +       }
723 +       else {
724 +               if ((walk = strchr(vendor, ' ')) != NULL) {
725 +                       walk[0] = '\0';
726 +                       walk++;
727 +                       product = walk;
728 +                       if ((walk = strchr(product, ',')) != NULL)
729 +                               walk[0] = '\0';
730 +               }
731 +
732 +               attrs.vendor = strdup(vendor);
733 +               if (product) {
734 +                       attrs.product = strdup(product);
735 +                       options = input_option_new(options, "name", product);
736 +               }
737 +               else
738 +                       options = input_option_new(options, "name", "(unnamed)");
739 +
740 +               free(vendor);
741 +       }
742 +
743 +       /* XXX implement usb_id */
744 +       attrs.usb_id = NULL;
745 +       attrs.device = strdup(path);
746 +       options = input_option_new(options, "driver", hw_types[i].xdriver);
747 +
748 +       fd = open(path, O_RDONLY);
749 +       if (fd > 0) {
750 +               close(fd);
751 +               options = input_option_new(options, "device", path);
752 +       }
753 +       else {
754 +               if (attrs.flags & ~ATTR_KEYBOARD) {
755 +                       LogMessage(X_INFO, "config/devd: device %s already opened\n",
756 +                                        path);
757 +
758 +                       /*
759 +                        * Fail if cannot open device, it breaks AllowMouseOpenFail,
760 +                        * but it should not matter when config/devd enabled
761 +                        */
762 +                       goto unwind;
763 +               }
764 +
765 +               if (is_console_kbd) {
766 +                       /*
767 +                        * There can be only one keyboard attached to console and
768 +                        * it is already added.
769 +                        */
770 +                       LogMessage(X_WARNING, "config/devd: console keyboard is "
771 +                                       "already added, ignoring %s (%s)\n",
772 +                                       attrs.product, path);
773 +                       goto unwind;
774 +               }
775 +               else
776 +                       /*
777 +                        * Don't pass "device" option if the keyboard is already
778 +                        * attached to the console (ie. open() fails).
779 +                        * This would activate a special logic in xf86-input-keyboard.
780 +                        * Prevent any other attached to console keyboards being
781 +                        * processed. There can be only one such device.
782 +                        */
783 +                       is_console_kbd = true;
784 +       }
785 +
786 +       if (asprintf(&config_info, "devd:%s", devname) == -1) {
787 +               config_info = NULL;
788 +               goto unwind;
789 +       }
790 +
791 +       if (device_is_duplicate(config_info)) {
792 +               LogMessage(X_WARNING, "config/devd: device %s (%s) already added. "
793 +                               "ignoring\n", attrs.product, path);
794 +               goto unwind;
795 +       }
796 +
797 +       options = input_option_new(options, "config_info", config_info);
798 +       LogMessage(X_INFO, "config/devd: adding input device %s (%s)\n",
799 +                       attrs.product, path);
800 +
801 +       NewInputDeviceRequest(options, &attrs, &dev);
802 +
803 +unwind:
804 +       free(config_info);
805 +       input_option_free_list(&options);
806 +       free(attrs.usb_id);
807 +       free(attrs.product);
808 +       free(attrs.device);
809 +       free(attrs.vendor);
810 +}
811 +
812 +static void
813 +device_removed(char *devname)
814 +{
815 +       char *config_info;
816 +
817 +       if (asprintf(&config_info, "devd:%s", devname) == -1)
818 +               return;
819 +
820 +       remove_devices("devd", config_info);
821 +
822 +       free(config_info);
823 +}
824 +
825 +static bool is_kbdmux_enabled(void)
826 +{
827 +       /* Xorg uses /dev/ttyv0 as a console device */
828 +       /* const char device[]="/dev/console"; */
829 +       const char device[]="/dev/ttyv0";
830 +       keyboard_info_t info;
831 +       int fd;
832 +
833 +       fd = open(device, O_RDONLY);
834 +
835 +       if (fd < 0)
836 +               return false;
837 +
838 +       if (ioctl(fd, KDGKBINFO, &info) == -1) {
839 +               close(fd);
840 +               return false;
841 +       }
842 +
843 +       close(fd);
844 +
845 +       if (!strncmp(info.kb_name, "kbdmux", 6))
846 +               return true;
847 +
848 +       return false;
849 +}
850 +
851 +static void
852 +disconnect_devd(int sock)
853 +{
854 +       if (sock >= 0) {
855 +               RemoveGeneralSocket(sock);
856 +               close(sock);
857 +       }
858 +}
859 +
860 +static int
861 +connect_devd(void)
862 +{
863 +       struct sockaddr_un devd;
864 +       int sock;
865 +
866 +       sock = socket(AF_UNIX, SOCK_STREAM, 0);
867 +       if (sock < 0) {
868 +               LogMessage(X_ERROR, "config/devd: fail opening stream socket\n");
869 +               return -1;
870 +       }
871 +
872 +       devd.sun_family = AF_UNIX;
873 +       strlcpy(devd.sun_path, DEVD_SOCK_PATH, sizeof(devd.sun_path));
874 +
875 +       if (connect(sock, (struct sockaddr *) &devd, sizeof(devd)) < 0) {
876 +               close(sock);
877 +               LogMessage(X_ERROR, "config/devd: fail to connect to devd\n");
878 +               return -1;
879 +       }
880 +
881 +       AddGeneralSocket(sock);
882 +
883 +       return  sock;
884 +}
885 +
886 +static CARD32
887 +reconnect_handler(OsTimerPtr timer, CARD32 time, void *arg)
888 +{
889 +       int newsock;
890 +
891 +       if ((newsock = connect_devd()) > 0) {
892 +               sock_devd = newsock;
893 +               TimerFree(rtimer);
894 +               rtimer = NULL;
895 +               LogMessage(X_INFO, "config/devd: reopening devd socket\n");
896 +               return 0;
897 +       }
898 +
899 +       /* Try again after RECONNECT_DELAY */
900 +       return RECONNECT_DELAY;
901 +}
902 +
903 +static ssize_t
904 +socket_getline(int fd, char **out)
905 +{
906 +       char *buf, *newbuf;
907 +       ssize_t ret, cap, sz = 0;
908 +       char c;
909 +
910 +       cap = 1024;
911 +       buf = malloc(cap * sizeof(char));
912 +       if (!buf)
913 +               return -1;
914 +
915 +       for (;;) {
916 +               ret = read(sock_devd, &c, 1);
917 +               if (ret < 0) {
918 +                       if (errno == EINTR)
919 +                               continue;
920 +                       free(buf);
921 +                       return -1;
922 +               /* EOF - devd socket is lost */
923 +               } else if (ret == 0) {
924 +                       disconnect_devd(sock_devd);
925 +                       rtimer = TimerSet(NULL, 0, 1, reconnect_handler, NULL);
926 +                       LogMessage(X_WARNING, "config/devd: devd socket is lost\n");
927 +                       free(buf);
928 +                       return -1;
929 +               }
930 +               if (c == '\n')
931 +                       break;
932 +
933 +               if (sz + 1 >= cap) {
934 +                       cap *= 2;
935 +                       newbuf = realloc(buf, cap * sizeof(char));
936 +                       if (!newbuf) {
937 +                               free(buf);
938 +                               return -1;
939 +                       }
940 +                       buf = newbuf;
941 +               }
942 +               buf[sz] = c;
943 +               sz++;
944 +       }
945 +
946 +       buf[sz] = '\0';
947 +       if (sz >= 0)
948 +               *out = buf;
949 +       else
950 +               free(buf);
951 +
952 +       /* Number of bytes in the line, not counting the line break */
953 +       return sz;
954 +}
955 +
956 +static void
957 +wakeup_handler(void *data, int err, void *read_mask)
958 +{
959 +       char *line = NULL;
960 +       char *walk;
961 +
962 +       if (err < 0)
963 +               return;
964 +
965 +       if (FD_ISSET(sock_devd, (fd_set *) read_mask)) {
966 +               if (socket_getline(sock_devd, &line) < 0)
967 +                       return;
968 +
969 +               walk = strchr(line + 1, ' ');
970 +               if (walk != NULL)
971 +                       walk[0] = '\0';
972 +
973 +               switch (*line) {
974 +               case DEVD_EVENT_ADD:
975 +                       device_added(line + 1);
976 +                       break;
977 +               case DEVD_EVENT_REMOVE:
978 +                       device_removed(line + 1);
979 +                       break;
980 +               default:
981 +                       break;
982 +               }
983 +               free(line);
984 +       }
985 +}
986 +
987 +static void
988 +block_handler(void *data, struct timeval **tv, void *read_mask)
989 +{
990 +}
991 +
992 +int
993 +config_devd_init(void)
994 +{
995 +       char devicename[1024];
996 +       int i, j;
997 +
998 +       LogMessage(X_INFO, "config/devd: probing input devices...\n");
999 +
1000 +       /*
1001 +        * Add fake keyboard and give up on keyboards management
1002 +        * if kbdmux is enabled
1003 +        */
1004 +       if ((is_kbdmux = is_kbdmux_enabled()) == true)
1005 +               device_added("kbdmux");
1006 +
1007 +       for (i = 0; hw_types[i].driver != NULL; i++) {
1008 +               /* First scan the sysctl to determine the hardware */
1009 +               for (j = 0; j < 16; j++) {
1010 +                       if (sysctl_exists(&hw_types[i], j,
1011 +                                       devicename, sizeof(devicename)) != 0)
1012 +                               device_added(devicename);
1013 +               }
1014 +
1015 +               if (devpath_exists(&hw_types[i], devicename, sizeof(devicename)) != 0)
1016 +                       device_added(devicename);
1017 +       }
1018 +
1019 +       if ((sock_devd = connect_devd()) < 0)
1020 +               return 0;
1021 +
1022 +       RegisterBlockAndWakeupHandlers(block_handler, wakeup_handler, NULL);
1023 +
1024 +       return 1;
1025 +}
1026 +
1027 +void
1028 +config_devd_fini(void)
1029 +{
1030 +       LogMessage(X_INFO, "config/devd: terminating backend...\n");
1031 +
1032 +       if (rtimer) {
1033 +               TimerFree(rtimer);
1034 +               rtimer = NULL;
1035 +       }
1036 +
1037 +       disconnect_devd(sock_devd);
1038 +
1039 +       RemoveBlockAndWakeupHandlers(block_handler, wakeup_handler, NULL);
1040 +
1041 +       is_console_kbd = false;
1042 +}
1043
1044
1045 [FILE:372:patches/patch-configure]
1046 --- configure.orig      2017-03-15 18:05:39 UTC
1047 +++ configure
1048 @@ -23280,9 +23280,14 @@ $as_echo "#define USE_ALPHA_PIO 1" >>con
1049         esac
1050         GLX_ARCH_DEFINES="-D__GLX_ALIGN64 -mieee"
1051         ;;
1052 -  arm*)
1053 +  arm*|aarch64*)
1054         ARM_VIDEO=yes
1055         DEFAULT_INT10="stub"
1056 +       case $host_os in
1057 +               *freebsd*)
1058 +                       $as_echo "#define USE_DEV_IO 1" >>confdefs.h
1059 +                ;;
1060 +       esac
1061         ;;
1062    i*86)
1063         I386_VIDEO=yes
1064
1065
1066 [FILE:785:patches/patch-hw_xfree86_common_xf86AutoConfig.c]
1067 --- hw/xfree86/common/xf86AutoConfig.c.orig     2017-01-11 20:00:58 UTC
1068 +++ hw/xfree86/common/xf86AutoConfig.c
1069 @@ -276,7 +276,7 @@ listPossibleVideoDrivers(char *matches[]
1070          i += xf86PciMatchDriver(&matches[i], nmatches - i);
1071  #endif
1072  
1073 -#if defined(__linux__)
1074 +#if defined(__linux__) || defined(__FreeBSD__) || defined(__DragonFly__)
1075      matches[i++] = xnfstrdup("modesetting");
1076  #endif
1077  
1078 @@ -285,8 +285,10 @@ listPossibleVideoDrivers(char *matches[]
1079      if (i < (nmatches - 1)) {
1080  #if !defined(__linux__) && defined(__sparc__)
1081          matches[i++] = xnfstrdup("wsfb");
1082 -#else
1083 +#elif defined(__linux__)
1084          matches[i++] = xnfstrdup("fbdev");
1085 +#elif defined(__FreeBSD__)
1086 +        matches[i++] = xnfstrdup("scfb");
1087  #endif
1088      }
1089  #endif                          /* !__sun */
1090
1091
1092 [FILE:700:patches/patch-hw_xfree86_common_xf86Config.c]
1093 --- hw/xfree86/common/xf86Config.c.orig 2016-07-19 17:14:30 UTC
1094 +++ hw/xfree86/common/xf86Config.c
1095 @@ -1410,13 +1410,16 @@ checkCoreInputDevices(serverLayoutPtr se
1096      }
1097  
1098      if (!xf86Info.forceInputDevices && !(foundPointer && foundKeyboard)) {
1099 -#if defined(CONFIG_HAL) || defined(CONFIG_UDEV) || defined(CONFIG_WSCONS)
1100 +#if defined(CONFIG_HAL) || defined(CONFIG_UDEV) || defined(CONFIG_WSCONS) || \
1101 +               defined(CONFIG_DEVD)
1102          const char *config_backend;
1103  
1104  #if defined(CONFIG_HAL)
1105          config_backend = "HAL";
1106  #elif defined(CONFIG_UDEV)
1107          config_backend = "udev";
1108 +#elif defined(CONFIG_DEVD)
1109 +        config_backend = "devd";
1110  #else
1111          config_backend = "wscons";
1112  #endif
1113
1114
1115 [FILE:496:patches/patch-hw_xfree86_common_xf86Globals.c]
1116 --- hw/xfree86/common/xf86Globals.c.orig        2016-07-19 17:07:29 UTC
1117 +++ hw/xfree86/common/xf86Globals.c
1118 @@ -122,7 +122,8 @@ xf86InfoRec xf86Info = {
1119      .pmFlag = TRUE,
1120      .disableRandR = FALSE,
1121      .randRFrom = X_DEFAULT,
1122 -#if defined(CONFIG_HAL) || defined(CONFIG_UDEV) || defined(CONFIG_WSCONS)
1123 +#if defined(CONFIG_HAL) || defined(CONFIG_UDEV) || defined(CONFIG_WSCONS) || \
1124 +       defined(CONFIG_DEVD)
1125      .forceInputDevices = FALSE,
1126      .autoAddDevices = TRUE,
1127      .autoEnableDevices = TRUE,
1128
1129
1130 [FILE:688:patches/patch-hw_xfree86_common_xf86Xinput.c]
1131 --- hw/xfree86/common/xf86Xinput.c.orig 2016-07-19 17:07:29 UTC
1132 +++ hw/xfree86/common/xf86Xinput.c
1133 @@ -841,7 +841,7 @@ xf86NewInputDevice(InputInfoPtr pInfo, D
1134  {
1135      InputDriverPtr drv = NULL;
1136      DeviceIntPtr dev = NULL;
1137 -    Bool paused;
1138 +    Bool paused = 0;
1139      int rval;
1140      char *path = NULL;
1141  
1142 @@ -996,6 +996,7 @@ NewInputDeviceRequest(InputOption *optio
1143          if (strcmp(key, "_source") == 0 &&
1144              (strcmp(value, "server/hal") == 0 ||
1145               strcmp(value, "server/udev") == 0 ||
1146 +             strcmp(value, "server/devd") == 0 ||
1147               strcmp(value, "server/wscons") == 0)) {
1148              is_auto = 1;
1149              if (!xf86Info.autoAddDevices) {
1150
1151
1152 [FILE:450:patches/patch-hw_xfree86_os-support_bsd_bsd__init.c]
1153 --- hw/xfree86/os-support/bsd/bsd_init.c.orig   2016-07-19 17:07:29 UTC
1154 +++ hw/xfree86/os-support/bsd/bsd_init.c
1155 @@ -230,6 +230,9 @@ xf86OpenConsole()
1156               * Add cases for other *BSD that behave the same.
1157               */
1158  #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
1159 +#if defined(__sparc64__)
1160 +           pci_system_init_dev_mem(fd);
1161 +#endif
1162              uname(&uts);
1163              i = atof(uts.release) * 100;
1164              if (i >= 310)
1165
1166
1167 [FILE:315:patches/patch-hw_xfree86_os-support_bsd_i386__video.c]
1168 Index: programs/Xserver/hw/xfree86/os-support/bsd/i386_video.c
1169 --- hw/xfree86/os-support/bsd/i386_video.c.orig 2016-07-15 16:18:11 UTC
1170 +++ hw/xfree86/os-support/bsd/i386_video.c
1171 @@ -32,6 +32,7 @@
1172  #include "xf86Priv.h"
1173  
1174  #include <errno.h>
1175 +#include <sys/types.h>
1176  #include <sys/mman.h>
1177  
1178  #include "xf86_OSlib.h"
1179
1180
1181 [FILE:380:patches/patch-hw_xfree86_os-support_bsd_ppc__video.c]
1182 --- hw/xfree86/os-support/bsd/ppc_video.c.orig  2016-07-15 16:18:11 UTC
1183 +++ hw/xfree86/os-support/bsd/ppc_video.c
1184 @@ -79,7 +79,11 @@ xf86DisableIO()
1185  {
1186  
1187      if (ioBase != MAP_FAILED) {
1188 +#if defined(__FreeBSD__)
1189 +        munmap(__DEVOLATILE(unsigned char *, ioBase), 0x10000);
1190 +#else
1191          munmap(__UNVOLATILE(ioBase), 0x10000);
1192 +#endif
1193          ioBase = MAP_FAILED;
1194      }
1195  }
1196
1197
1198 [FILE:215:patches/patch-xkb_Makefile.in]
1199 --- xkb/Makefile.in.orig        2017-01-19 15:20:42 UTC
1200 +++ xkb/Makefile.in
1201 @@ -878,7 +878,7 @@ info: info-am
1202  
1203  info-am:
1204  
1205 -install-data-am: install-dist_xkbcompiledDATA
1206 +install-data-am:
1207  
1208  install-dvi: install-dvi-am
1209  
1210
1211
1212 [FILE:135:files/pkg-deinstall.in]
1213 #!/bin/sh
1214
1215 PREFIX="${PKG_PREFIX-/raven}"
1216
1217 case $2 in
1218 DEINSTALL)
1219         /bin/rm -rf ${PREFIX}/lib/xorg/modules/extensions/libglx.so*
1220         ;;
1221 esac
1222
1223
1224 [FILE:531:files/pkg-install.in]
1225 #!/bin/sh
1226
1227 PREFIX="${PKG_PREFIX-/raven}"
1228
1229 case $2 in
1230 POST-INSTALL)
1231         if [ -f ${PREFIX}/lib/xorg/modules/extensions/.nvidia/libglx.so.1 ]; then
1232           /bin/ln -f ${PREFIX}/lib/xorg/modules/extensions/.nvidia/libglx.so.1 \
1233                 ${PREFIX}/lib/xorg/modules/extensions/libglx.so
1234           /bin/ln -f ${PREFIX}/lib/xorg/modules/extensions/.nvidia/libglx.so.1 \
1235                 ${PREFIX}/lib/xorg/modules/extensions/libglx.so.1
1236         else
1237           /bin/ln -f ${PREFIX}/lib/xorg/modules/extensions/.xorg/libglx.so \
1238                 ${PREFIX}/lib/xorg/modules/extensions/libglx.so
1239         fi
1240         ;;
1241 esac
1242