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