Blob Blame History Raw
#!/bin/bash
%define pkgname xfs

%define _x11fontdir	%{_datadir}/X11/fonts
%define _sysfontdir	%{_datadir}/fonts
%define _oldx11fontdir	/usr/X11R6/lib/X11/fonts

Summary: X.Org X11 xfs font server
Name: xorg-x11-%{pkgname}
Version: 0.99.2
Release: 4
# FIXME: Remove Epoch line if package gets renamed
Epoch: 1
License: MIT/X11
Group: System Environment/Daemons
URL: http://www.x.org
#Source0: %{pkgname}-%{version}.tar.bz2
Source0: http://xorg.freedesktop.org/releases/X11R7.0-RC1/everything/xfs-0.99.2.tar.bz2
Source1: http://xorg.freedesktop.org/releases/X11R7.0-RC1/everything/xfsinfo-0.99.1.tar.bz2
Source2: http://xorg.freedesktop.org/releases/X11R7.0-RC1/everything/fslsfonts-0.99.1.tar.bz2
Source3: http://xorg.freedesktop.org/releases/X11R7.0-RC1/everything/fstobdf-0.99.2.tar.bz2
Source4: http://xorg.freedesktop.org/releases/X11R7.0-RC1/everything/showfont-0.99.1.tar.bz2
Source10:  xfs.init
# NOTE: xfs config input file, processed via sed below.
Source11:  xfs.config.in
# FIXME: This is the original xfs.config from FC5 rawhide prior to modular X,
# included here for developmental comparison purposes during FC5 development,
# but can be dropped later on.
Source12:  xfs.config
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)

BuildRequires: pkgconfig
# xfs needs 'fontsproto' to build, as indicated by ./configure
BuildRequires: xorg-x11-proto-devel
# FIXME: xfs needs xtrans to build, but autotools doesn't detect it missing
BuildRequires: xorg-x11-xtrans-devel
BuildRequires: libFS-devel
# FIXME: The version specification can be removed from here in the future,
# as it is not really mandatory, but forces a bugfix workaround on people who
# are using pre-rawhide modular X.
BuildRequires: libXfont-devel >= 0.99.2-3
BuildRequires: libX11-devel
# FIXME: xfs needs freetype-devel to build, but autotools doesn't detect it missing
BuildRequires: freetype-devel

# FIXME: This Requires on libXfont can be removed from here in the future,
# as it is not really mandatory, but forces a bugfix workaround on people who
# are using pre-rawhide modular X.
Requires: libXfont >= 0.99.2-3

Provides: xfs

Obsoletes: XFree86-xfs
Requires(pre): /sbin/nologin, /usr/sbin/useradd
Requires(post): /sbin/chkconfig, grep, sed, coreutils
Requires(preun): /sbin/service, /sbin/chkconfig
Requires(postun): /sbin/service

# xfs initscript runtime dependencies
Requires: initscripts, fontconfig, sed, /usr/bin/find
Requires: /usr/sbin/chkfontpath, /bin/sort, /usr/bin/uniq
Requires: mkfontdir, mkfontscale, ttmkfdir
Requires: /sbin/restorecon
# end of xfs initscript runtime dependencies

%description
X.Org X11 xfs font server

%package utils
Summary: X.Org X11 font server utilities
Group: User Interface/X
#Requires: %{name} = %{version}-%{release}

# So upgrades from OS releases with XFree86 work, since the utilities were
# previously in the "xfs" subpackage instead of their own subpackage.
Obsoletes: XFree86-xfs
# FIXME: This conflict is because the utils moved from the xorg-x11-xfs
# subpackage to the xorg-x11-xfs-utils subpackage starting with 6.99.99.0.
# This may need to be updated in the future if the package major version
# changes in some way.  Review this again after X11R7 is completed, and
# prior to Fedora Core 5 being released to ensure the Conflict is set
# properly to avoid installation/upgrade problems.
Conflicts: xorg-x11-xfs < 6.99.99.0

%description utils
X.Org X11 font server utilities

%prep
%setup -q -c %{name}-%{version} -a1 -a2 -a3 -a4

%build
# Comment: Separate sections for each individual tarball rather than an
# iterative for loop, so that each can be customized easily in future.

# Build xfs
{
   pushd %{pkgname}-*
   %configure 
   # FIXME: Create patch for the following, and submit it upstream.
   # <daniels> mharris: uhm, just set configdir=$(sysconfdir) in Makefile.am
   # <mharris> daniels: Do you mean, change it in Makefile.am, and submit patch to fix?  Or patch it for local use?
   # <daniels> mharris: and submit patch to fix, yeah
   make configdir=%{_sysconfdir}/X11/fs
# CFLAGS='-DDEFAULT_CONFIG_FILE="/etc/X11/fs/config"'
   popd
}

for pkg in xfsinfo fslsfonts fstobdf showfont ; do
   pushd ${pkg}-*
   %configure
   make
   popd
done

%install
rm -rf $RPM_BUILD_ROOT
# Install xfs
{
   pushd %{pkgname}-*
   # FIXME: Create patch for the following, and submit it upstream.
   # <daniels> mharris: uhm, just set configdir=$(sysconfdir) in Makefile.am
   # <mharris> daniels: Do you mean, change it in Makefile.am, and submit patch to fix?  Or patch it for local use?
   # <daniels> mharris: and submit patch to fix, yeah
   %makeinstall configdir=$RPM_BUILD_ROOT%{_sysconfdir}/X11/fs
   popd
}

for pkg in xfsinfo fslsfonts fstobdf showfont ; do
   pushd ${pkg}-*
   %makeinstall
   popd
done

# Install the Red Hat xfs config file and initscript
{
   mkdir -p $RPM_BUILD_ROOT/etc/{X11/fs,rc.d/init.d}
   install -c -m 755 %{SOURCE10} $RPM_BUILD_ROOT%{_sysconfdir}/rc.d/init.d/xfs
#   install -c -m 644 %{SOURCE11} $RPM_BUILD_ROOT%{_sysconfdir}/X11/fs/config
   sed -e 's#@XFONTDIR@#%{_x11fontdir}#g;s#@SYSFONTDIR@#%{_sysfontdir}#g' < %{SOURCE11} > $RPM_BUILD_ROOT%{_sysconfdir}/X11/fs/config
   chmod 0644 $RPM_BUILD_ROOT%{_sysconfdir}/X11/fs/config
}

%clean
rm -rf $RPM_BUILD_ROOT

##### xfs scripts ####################################################
# triggerpostun xfs:
# - Work around a bug in the XFree86-xfs postun script, which results in
#   the special xfs user account being inadvertently removed, causing xfs
#   to run as the root user, and also resulting in xfs not being activated
#   by chkconfig,  This trigger executes right after the XFree86-xfs
#   postun script during upgrades from older OS releases that shipped
#   XFree86, and ensures that the xfs user exists, and that the xfs
#   initscript is properly activated with chkconfig (#118145,118818)
#
#   WARNING: THIS MUST BE LEFT HERE AS LONG AS WE SUPPORT UPGRADES FROM
#   Fedora Core 1, Red Hat Linux <any release>,
#   Red Hat Enterprise Linux 2.1, 3
%triggerpostun -- XFree86-xfs
{
  /usr/sbin/useradd -c "X Font Server" -r -s /sbin/nologin -u 43 -d /etc/X11/fs xfs || :
  /sbin/chkconfig --add xfs
  /sbin/service xfs condrestart || :
} &> /dev/null || :

%pre
{
  /usr/sbin/useradd -c "X Font Server" -r -s /sbin/nologin -u 43 -d /etc/X11/fs xfs || :
  # Upgrade path:
  if [ "$1" -ge "1" ] ; then
    if [ -e "/usr/X11R6/lib/X11/fs/config" ] ; then
      cat <<-EOF > "/etc/X11/fs/xfs-migrate"
	On upgrades, we now must determine if we are upgrading from monolithic
	xfs or modular xfs by checking for the existance of the old monolithic
	xfs config file.  If found, we know it is a monolith->modular upgrade,
	so we set this flag file in order for xfs.init to perform a "restart"
	instead of a "reload" in the 'condrestart'.  See bug #173271 for
	details.
EOF
    fi
  fi
} &> /dev/null || : # Silence output, and ignore errors (Bug #91822)

%post
{
  # Install section
  /sbin/chkconfig --add xfs
  #------------------------------------------------------------------------
  # Upgrade section
  if [ "$1" -ge "1" ] ; then
    XORG_CONFIG=/etc/X11/xorg.conf
    XFSCONFIG=/etc/X11/fs/config

    if [ -f $XORG_CONFIG ] ; then
      # If the X server is configured to use UNIX socket for font server
      if grep -q 'unix/:' $XORG_CONFIG &> /dev/null ; then
        # Disable legacy font path element in X server config
        if grep -q '/usr/X11R6/lib/X11/fonts/TrueType' $XORG_CONFIG &> /dev/null ; then
          sed -ie 's|FontPath[ ]*"/usr/X11R6/lib/X11/fonts/TrueType"|#FontPath "/usr/X11R6/lib/X11/fonts/TrueType"|g' $XORG_CONFIG
        fi

        # Convert config to use modern unix socket
        sed -ie 's#unix/:-1#unix/:7100#g' $XORG_CONFIG

        # Disable TCP listen by default for xfs
        if [ -f $XFSCONFIG ] && ! grep -q "no-listen" $XFSCONFIG &> /dev/null ; then
          echo -e "# For security, don't listen to TCP ports by default.\nno-listen = tcp\n" >> $XFSCONFIG
        fi
      fi
    fi

    # XFS config file upgrade munging
    if [ -f $XFSCONFIG ] ; then
      # Remove Speedo font directories from xfs config if present to avoid
      # bug reports about xfs complaining about empty directories in syslog.
      sed -ie '\#^.*/.*/Speedo.*#d' $XFSCONFIG

      # On upgrades, remove /usr/X11R6 font path elements from the XFS config file
      if grep -q "/usr/X11R6/lib/X11/fonts" $XFSCONFIG &> /dev/null ; then
        for fpe in misc:unscaled 75dpi:unscaled 100dpi:unscaled Type1 ; do
          sed -ie "s#/usr/X11R6/lib/X11/fonts/${fpe}#%{_x11fontdir}/${fpe}#g" $XFSCONFIG
        done
      fi
    fi
  fi ; # End Upgrade section
}

%preun
{
  if [ "$1" = "0" ]; then
    /sbin/service xfs stop &> /dev/null || :
# FIXME: The chkconfig call below works properly if uninstalling the package,
#        but it will cause xfs to be de-chkconfig'd if upgrading from one X11
#        implementation to another, as witnessed in the transition from
#        XFree86 to Xorg X11.  If this call is removed however, then xfs will
#        remain visible in ntsysv and similar utilities even after xfs is
#        uninstalled from the system in non-upgrade scenarios.  Not sure how
#        to fix this yet.
    /sbin/chkconfig --del xfs || :
# userdel/groupdel removed because they cause the user/group to get destroyed
# when upgrading from one X11 implementation to another, ie: XFree86 -> Xorg
#    /usr/sbin/userdel xfs 2>/dev/null || :
#    /usr/sbin/groupdel xfs 2>/dev/null || :
  fi
}

%postun
{
  if [ "$1" -ge "1" ]; then
    /sbin/service xfs condrestart &> /dev/null || :
  fi
}

%files
%defattr(-,root,root,-)
%doc
%dir %{_bindir}
%{_bindir}/xfs
%dir %{_bindir}
%dir %{_sysconfdir}/X11
%dir %{_sysconfdir}/X11/fs
# NOTE: We intentionally override the upstream default config file location
# during build.
# FIXME: Create patch for the following, and submit it upstream.
# <daniels> mharris: uhm, just set configdir=$(sysconfdir) in Makefile.am
# <mharris> daniels: Do you mean, change it in Makefile.am, and submit patch to fix?  Or patch it for local use?
# <daniels> mharris: and submit patch to fix, yeah
%config(noreplace) %verify(not md5 size mtime) %{_sysconfdir}/X11/fs/config
%dir %{_mandir}
%dir %{_mandir}/man1x
# FIXME: The manpage incorrectly points to /usr/X11R6/...
%{_mandir}/man1x/xfs.1x*
%{_sysconfdir}/rc.d/init.d/xfs

%files utils
%dir %{_bindir}
%{_bindir}/fslsfonts
%{_bindir}/fstobdf
%{_bindir}/showfont
%{_bindir}/xfsinfo
%dir %{_mandir}
%dir %{_mandir}/man1x
%{_mandir}/man1x/fslsfonts.1x*
%{_mandir}/man1x/fstobdf.1x*
%{_mandir}/man1x/showfont.1x.gz
%{_mandir}/man1x/xfsinfo.1x*

%changelog
* Tue Nov 15 2005 Jeremy Katz <katzj@redhat.com> - 1:0.99.2-4
- require initscripts instead of /etc/init.d/functions

* Tue Nov 15 2005 Mike A. Harris <mharris@redhat.com> 0.99.2-3
- Updated xfs pre script to check for the existance of the old monolithic
  /usr/X11R6/lib/X11/fs/config xfs config file, and set a migration flag
  file.
- Updated xfs.init to check for the existance of the migration flag file,
  and perform an xfs 'restart' instead of a 'reload' if migrating.  Users
  will now have to restart their X server, or reconnect the xfs server to
  the X server after a migration to modular X.
- Changed upgrade comparison typo from 2 to 1 in xfs post script.

* Mon Nov 14 2005 Mike A. Harris <mharris@redhat.com> 0.99.2-2
- Added temporary "BuildRequires: libXfont-devel >= 0.99.2-3" and
  "Requires: libXfont-devel >= 0.99.2-3" to ensure early-testers of
  pre-rawhide modular X have installed the work around for (#172997).

* Fri Nov 11 2005 Mike A. Harris <mharris@redhat.com> 0.99.2-1
- Updated to xdm-0.99.2 and fstobdf-0.99.2 from X11R7 RC2
- Added Epoch 1 to package, and set the version number to the xfs 0.99.2
  version.

* Thu Nov 10 2005 Mike A. Harris <mharris@redhat.com> 6.99.99.901-2
- Added showfont-0.99.1 from X11R7 RC1 release.

* Wed Nov 9 2005 Mike A. Harris <mharris@redhat.com> 6.99.99.901-1
- Updated all packages to version 0.99.1 from X11R7 RC1.
- Bump package version to 6.99.99.901 (the RC1 CVS tag).
- Change manpage location to 'man1x' in file manifest.
- Converted xfs.config to xfs.config.in, and added code to spec file to
  generate xfs.config depending on what the system _x11fontdir is.
- Complete and total rewrite of xfs postinstall script to use "sed -i"
  and complete restructuring, which removed a lot of the super craptasticness
  that had been sitting there for years.

* Wed Oct 3 2005 Mike A. Harris <mharris@redhat.com> 6.99.99.0-4
- Use Fedora-Extras style BuildRoot tag
- Update BuildRequires to use new library package names
- Remove unnecessary BuildRequires on 'install', and fix pkgconfig dep

* Thu Aug 25 2005 Mike A. Harris <mharris@redhat.com> 6.99.99.0-3
- Install the initscript and xfs config file in the correct location as they
  were inadvertently interchanged in previous builds.

* Wed Aug 24 2005 Mike A. Harris <mharris@redhat.com> 6.99.99.0-2
- Ported the xfs related rpm scripts over from monolithic packaging, and
  added up to date Requires(*) dependencies for all of them.
- Flagged xfs config file as config(noreplace)
- Added build and runtime dependencies to xfs subpackage as best as could be
  determined by analyzing ./configure output, and building in minimalized
  build root environment.

* Wed Aug 24 2005 Mike A. Harris <mharris@redhat.com> 6.99.99.0-1
- Initial build.