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