
# X.Org will work without any xorg.conf now, so don't move anything
# into place by default.  Commenting out the block below:

## Use framebuffer by default if no xorg.conf is found:
#if [ ! -r etc/X11/xorg.conf -a -r etc/X11/xorg.conf-vesa ]; then
#  cp -a etc/X11/xorg.conf-vesa etc/X11/xorg.conf
#fi

( cd usr/lib/X11 ; rm -rf fonts )
( cd usr/lib/X11 ; ln -sf ../../share/fonts fonts )
# This setup should allow the following packages to install in a
# sane fashion, and should also allow third-party video drivers to
# find X in the old places.  However, anything you've installed in
# your /usr/X11R6 directory will be moved to /usr/X11R6.bak.
# Anything you really want want to keep will need to be merged back
# by hand.
if [ ! -L usr/X11R6/bin ]; then
  if [ -d usr/X11R6 ]; then
    mv usr/X11R6 usr/X11R6.bak
  fi
fi
mkdir -p usr/X11R6
( cd usr/X11R6
  for dir in ../bin ../include ../lib ../libexec ../man ../share ; do
    rm -rf $(basename $dir)
    ln -sf $dir .
  done
)
( cd usr ; rm -rf X11 )
( cd usr ; ln -sf X11R6 X11 )
( cd usr/bin ; rm -rf X11 )
( cd usr/bin ; ln -sf . X11 )
if [ -L usr/include/X11 ]; then
  ( cd usr/include ; rm -rf X11 )
fi
# x11-skell post installation script.
# Stuart Winter <mozes@slackware.com>
# Jan 2022

# Collapse all 32bit ARM & x86 variants of 'i?86' into a single
# platform: 'x86' and 'arm' respectively.
export ARCH=$( uname -m | sed -e 's%i[0-9]86%x86%g' -e 's?arm.*?arm?g' )

HWM=$( strings /proc/device-tree/model 2>/dev/null )
# Exit silently if we don't detect the Hardware Model.
# This avoids warnings/errors.
# We may need to surface these at some point but for the moment it's not
# a concern.
[ -z "${HWM}" ] && exit 0

# Location of the system Xorg config file:
XORGCONF=etc/X11/xorg.conf.d/xorg.conf

# Determine any xorg config file for the Hardware Model we find ourselves
# running upon:
# The Rpi4 no longer requires a config since work on the VC4 driver
# has progressed.
#case "${HWM}" in
#   "Raspberry Pi 4"*)
#      # To accommodate future divergence:
#      #HWM_XORGCONF=bcm2711/xorg.conf.rpi4 ;;
#      HWM_XORGCONF=generic/xorg.conf.fbdev0 ;;
## The Raspberry Pi 3 uses Xorg auto detection and configuration.
## No need to supply an Xorg config.
##   "Raspberry Pi 3"*)
##      #HWM_XORGCONF=bcm2837/xorg.conf.rpi3 ;;
##      HWM_XORGCONF=generic/xorg.conf.fbdev0 ;;
#esac

# Slackware ARM does not ship an xorg.conf by default, so
# if we find one it means that the user installed it, or it was
# installed from this package.
# Either way, for now we'll do nothing since I don't want to modify
# anybody's config.
# In the future we can install this with the '.new' suffix, but the
# user can always pull it from /usr/share/x11-skel/platform.
[ ! -f $XORGCONF ] && {
   [ -f usr/share/x11-skel/platform/$ARCH/$HWM_XORGCONF ] && \
   install -pm644 usr/share/x11-skel/platform/$ARCH/$HWM_XORGCONF $XORGCONF
}
