File tgif.spec of Package tgif

#
# spec file for package tgif (Version 4.2.5)
#
# Copyright (c) 2007 SUSE LINUX Products GmbH, Nuernberg, Germany.
# This file and all modifications and additions to the pristine
# package are under the same license as the package itself.
#
# Please submit bugfixes or comments via http://bugs.opensuse.org/
#

# norootforbuild

Name:           tgif
BuildRequires:  update-desktop-files xorg-x11-devel libidn-devel
URL:            http://bourbon.usc.edu/tgif/
License:        QPL-1.0
Group:          Productivity/Graphics/Vector Editors
Autoreqprov:    on
Version:        4.2.5
Release:        lp152.250.71
Requires:       netpbm
Requires:       xrandr
Summary:        Vector-oriented drawing program
# This is the current best guess, from when on the high resolution solution should come into place.
%define _reslimit 3000
Source0:        %{name}-QPL-%{version}.tar.bz2
Source1:        tgif.desktop
Source2:        tgificon.png
Source3:        %{name}-%{version}-xbm-Highres.tar.bz2

Patch0:         %{name}-%{version}-tgif.Xdefaults.patch
Patch1:         %{name}-%{version}-Tgif.tmpl.patch
Patch2:         %{name}-%{version}-upstream.patch
Patch3:         %{name}-%{version}-arc.patch
Patch4:         %{name}-%{version}-locale.patch
Patch5:         %{name}-%{version}-locale-atof.patch
Patch6:         %{name}-%{version}-de-po.patch
Patch7:         %{name}-%{version}-symbol.patch
Patch8:         %{name}-%{version}-64Bit-issue.patch
Patch9:         %{name}-%{version}-xim-failure.patch
Patch10:        %{name}-%{version}-Highres.patch
Patch11:        %{name}-%{version}-warnings.patch
Patch12:        %{name}-%{version}-HAVE_IMLIB.patch
Patch13:        %{name}-%{version}-displayconf.patch
Patch14:        %{name}-%{version}-Highres-compile.patch
Patch15:        %{name}-%{version}-reconf.patch
Patch16:        %{name}-%{version}-discgeometry.patch
Patch17:        %{name}-%{version}-getaddrinfo.patch
BuildRoot:      %{_tmppath}/%{name}-%{version}-build

%description
This program has nothing to do with the GIF format. It is an extremely
powerful and easy to use vector-oriented drawing program which has
every feature you would expect in a drawing utility.

Authors:
--------
    William Chia-Wei Cheng <william@cs.UCLA.edu>

%prep
%setup -q -n %{name}-QPL-%{version}
%setup -T -D -n  -q -n %{name}-QPL-%{version} -a3
%patch0
%patch1
%patch2
%patch3
%patch4
%patch5
%patch6
%patch7
%patch8
%patch9
%patch10
%patch11
%patch12
%patch13
# %%patch14 is used as %%{P:14} below ... must not go in here (double %% due to rpmlint)
%patch15
%patch16
%patch17

%build
# suse 10.x uses older X11 directory structure
%if 0%{?suse_version} < 1100
%define xappdefs   /usr/X11R6/lib/X11/app-defaults
%else
%define xappdefs   /usr/share/X11/app-defaults
%endif
xmkmf -a
# seemingly xmkmf adds defines that should not be used any more -> let us replace them.
sed -i 's/\_BSD\_SOURCE/\_DEFAULT\_SOURCE/g;s/-D\_SVID\_SOURCE//g' Makefile
cp %{S:2} .
# No more warnings - no additional compiler switches required ...
make CCOPTIONS="$RPM_OPT_FLAGS"
# Try to fix a rpmlint warning. 
touch tgif.lang
cd po
xmkmf
make Makefile
make Makefiles
make depend
make all
cd ..

%install
# clean old stuff away
[ -d %{buildroot} -a "%{buildroot}" != "" ] && rm -rf  %{buildroot}
# and create buildroot again
mkdir %buildroot
# first we build the standard - resolution version with standard icons ....
mv xbm xbm.Stdres
ln -s xbm.Stdres xbm
make "DESTDIR=$RPM_BUILD_ROOT" install
strip ${RPM_BUILD_ROOT}/usr/bin/tgif
mv ${RPM_BUILD_ROOT}/%{_bindir}/tgif ${RPM_BUILD_ROOT}/%{_bindir}/tgif.Stdres
make "DESTDIR=$RPM_BUILD_ROOT" install.man
cd po
make "DESTDIR=$RPM_BUILD_ROOT" install
%find_lang %name
# second we build the high - resolution version with double size icons ....
cd ..
patch -p0 < %{P:14}
rm -f xbm
ln -s xbm.Highres xbm
make
strip tgif
mv tgif  ${RPM_BUILD_ROOT}/%{_bindir}/tgif.Highres
(cd ${RPM_BUILD_ROOT}/%{_bindir}; ln -s tgif.Stdres tgif)
# This can be used to reconfigure the graphics resolution of tgif at any time ....
install -D -m 0755 tgif-reconf -T ${RPM_BUILD_ROOT}/%{_bindir}/tgif-reconf
TGIFPATH=`sed '/^TGIFDIR/!d; s/.*\ \//\//g' Tgif.tmpl`
mv tgif.Xdefaults tgif.Xdefaults.Stdres
CONFIGFILE=tgif.Xdefaults.Stdres
mv ${CONFIGFILE} ${CONFIGFILE}.new  
sed s\!Tgif.IconPixmap.*\!Tgif.IconPixmap:\	\	$TGIFPATH/tgificon.xpm\!g\;\
s\!Tgif.WMIconPixmap.*\!Tgif.WMIconPixmap:\	\	$TGIFPATH/tgificon.xpm\!g\;\
s\!Tgif.ColorFromXPixmap.*\!Tgif.ColorFromXPixmap:\	\	$TGIFPATH/tgificon.xpm\!g\;\
s\!Tgif.TGIFICON.*\!Tgif.TGIFICON:\	\	\	$TGIFPATH/tgificon.obj\!g \
${CONFIGFILE}.new > ${CONFIGFILE}
rm -f ${CONFIGFILE}.new
cp -av spice $RPM_BUILD_ROOT/%{_datadir}/tgif
cp tgificon.png $RPM_BUILD_ROOT/%{_datadir}/tgif
cp tgif.Xdefaults.Highres $RPM_BUILD_ROOT/%{_datadir}/tgif
cp tgif.Xdefaults.Stdres $RPM_BUILD_ROOT/%{_datadir}/tgif
mkdir -p $RPM_BUILD_ROOT/%{_docdir}/tgif
cp tgif.Xdefaults.Highres $RPM_BUILD_ROOT/%{_docdir}/tgif
cp README.tgif.Xdefaults.Highres $RPM_BUILD_ROOT/%{_docdir}/tgif
install -d -m 755 $RPM_BUILD_ROOT/%{xappdefs}
cp -av tgif.Xdefaults.Stdres $RPM_BUILD_ROOT/%{xappdefs}/Tgif.Stdres
cp -av tgif.Xdefaults.Highres $RPM_BUILD_ROOT/%{xappdefs}/Tgif.Highres
mkdir -p $RPM_BUILD_ROOT/%{_datadir}/icons/hicolor
(cd icons; tar cvf - ./* | (cd $RPM_BUILD_ROOT/%{_datadir}/icons/hicolor; tar xvf -))
rm -rf $RPM_BUILD_ROOT/%{_datadir}/%{name}/hicolor
rm -f $RPM_BUILD_ROOT/%{_datadir}/X11/tgif/{LICENSE.QPL,Copyright}  
rm -f $RPM_BUILD_ROOT/%{_datadir}/tgif/{LICENSE.QPL,Copyright}  
cp tgif-reconf.1x $RPM_BUILD_ROOT/%{_mandir}/man1

%suse_update_desktop_file -i tgif Graphics VectorGraphics

%post
# Determine x-value of current display resolution ....
# xwininfo and xdpyinfo show the sum of the resolutions of all monitors. This would 
# give erratic results. The way below refers to the primary monitor only. This should be 
# the somewhat optimum choice.
VAL=`xrandr 2>/dev/null | sed '/\ connected primary/!d; s/^.*primary\ //g;s/+.*//g'`
XVAL=`echo ${VAL} | sed 's/x.*//g'`
YVAL=`echo ${VAL} | sed 's/.*x//g'`
# Check whether the result is a number, if not, assign 0 to avoid trouble ...
case ${XVAL} in
    ''|*[!0-9]*) XVAL=0 ;;
    *) ;;
esac
case ${YVAL} in
    ''|*[!0-9]*) YVAL=0 ;;
    *) ;;
esac

# Check whether the link to Tgif already exists in xappdefs ...
if [ -f %{xappdefs}/Tgif ]; then
	rm -f %{xappdefs}/Tgif
fi
if [ "${XVAL}" -gt "%{_reslimit}" ]; then 
        (cd %{xappdefs}; ln -s Tgif.Highres Tgif)
        (cd %{_bindir}; test -f tgif && rm -f tgif; ln -s tgif.Highres tgif)
else
        (cd %{xappdefs}; ln -s Tgif.Stdres Tgif)
        (cd %{_bindir}; test -f tgif && rm -f tgif; ln -s tgif.Stdres tgif)
fi

# Ok. Now if the values are meaningful let us preset a resolution that might fit to the current setup.
# User might modify accordingly at any time he likes to.
if [[ "${XVAL}" != "0" && "${YVAL}" != "0" ]]; then
	# I initially wanted to use 0.85 but 0.84 provides smaller int-multiplication values ....
        # 0.84=84/100=21/25 ....
        NEWXVAL=$[${XVAL}*21/25]
        NEWYVAL=$[${YVAL}*21/25]
        XOFFS=$[(${XVAL} - ${NEWXVAL})/2]
        YOFFS=$[(${YVAL} - ${NEWYVAL})/2]
	GEOMETRY="${NEWXVAL}x${NEWYVAL}+${XOFFS}+${YOFFS}"
	TGIFGEOMETRY="Tgif.Geometry:			${GEOMETRY}"
	# sed -i converts the link to a regular file -> this should not happen!
	# we keep the initial value just for reference.
	if [ "${XVAL}" -gt "%{_reslimit}" ]; then 
		sed -i "/^!Tgif\.Geometry/d; s/^Tgif\.Geometry/!Tgif\.Geometry/g; /^!Tgif\.Geometry/a ${TGIFGEOMETRY}" %{xappdefs}/Tgif.Highres
	else
		sed -i "/^!Tgif\.Geometry/d; s/^Tgif\.Geometry/!Tgif\.Geometry/g; /^!Tgif\.Geometry/a ${TGIFGEOMETRY}" %{xappdefs}/Tgif.Stdres
	fi
fi

%postun
# Remove Tgif only if tgif got actually removed ...
if [ ! -f %{_bindir}/tgif ]; then
	rm -f %{xappdefs}/Tgif
fi

%files -f %name.lang
%defattr(-,root,root,755)
%doc README README.libidn HISTORY Copyright LICENSE.QPL README.tgif.Xdefaults.Highres tgif.Xdefaults.Highres
%{_datadir}/applications/*.desktop
%{_bindir}/tgif*
%dir %{xappdefs}
%{xappdefs}/Tgif*
%dir %{_datadir}/tgif
%{_datadir}/tgif/*
%dir %{_datadir}/icons/hicolor
%{_datadir}/icons/hicolor/*
%lang(de) /usr/share/locale/de/LC_MESSAGES/tgif.mo
%lang(fr) /usr/share/locale/fr/LC_MESSAGES/tgif.mo
%lang(ja) /usr/share/locale/ja/LC_MESSAGES/tgif.mo
%lang(ru) /usr/share/locale/ru/LC_MESSAGES/tgif.mo
%doc /%{_mandir}/man1/*

%changelog
* Tue Jan 19 2021 dieter.jurzitza@t-online.de
- switch to getaddrinfo()
* Sat Jan 16 2021 dieter.jurzitza@t-online.de
- add a manpage for tgif-reconf.
* Sun Jan 10 2021 dieter.jurzitza@t-online.de
- Bill fixed a bug in disk - symbol creation where the lower right corner was off by one.
  Integrated as a patch.
- Keep a backup of the initial resolution setting within Tgif.
* Sat Jan 09 2021 dieter.jurzitza@t-online.de
- reworked the icons of the menu (made them bolder).
* Wed Jan 06 2021 dieter.jurzitza@t-online.de
- Create two variants, one for standard res, one for high res displays.
- integrate that into the rpm package.
- Provide a reconfiguration - tool (tgif-reconf).
* Sun Jan 03 2021 dieter.jurzitza@t-online.de
- This version is capable of using the dynamic library libidn as I would expect it to be used.
  The "normal" linux distribution is therefore somewhat simplified. Returning to the
  original behavior is easy during compiletime, please see README.libidn.
* Sat Jan 02 2021 dieter.jurzitza@t-online.de
- This version is the first one to directly use the libidn function and hence contains 
  a decent simplification. Please refer to tgif-4.2.5-libidn.patch.
* Wed Dec 30 2020 dieter.jurzitza@t-online.de
- Finally fix all warnings for now, support user with resolution dependent configuration
  during installation.
* Mon Dec 28 2020 dieter.jurzitza@t-online.de
- add an appropriate app-defaults file for high resolution displays.
* Sat May 19 2018 dieter.jurzitza@t-online.de
- revert one fix that had had caused issues
* Thu Mar 21 2013 dieter.jurzitza@t-online.de
- fix some issues with latest release
  - > make input of "Umlaute" possible again,
  - > fix character and color selection box issues.
* Mon Mar 18 2013 meissner@suse.com
- updated to 4.2.25 QPL, submitted by
  "Dr. Ing. Dieter Jurzitza" <dieter.jurzitza@t-online.de>
  Lots of changes
  German language support.
* Thu Sep 13 2012 meissner@suse.com
- a vector oriented drawing program
openSUSE Build Service is sponsored by