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