File eso-midas.spec of Package eso-midas

#
# spec file for package eso-midas
#
# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany.
# Copyright (c) 2007-2012 Matwey V. Kornilov
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via http://bugs.opensuse.org/
#

%define prefix %{_libdir}/eso-midas

BuildRequires:	-post-build-checks
BuildRequires:  binutils
BuildRequires:  bzip2
BuildRequires:  chrpath
BuildRequires:  dos2unix
BuildRequires:  gcc
BuildRequires:  gcc-fortran
BuildRequires:  libtirpc-devel
BuildRequires:  ncurses-devel
BuildRequires:  openmotif-devel
BuildRequires:  procmail
BuildRequires:  readline-devel
BuildRequires:  time
BuildRequires:  tar
BuildRequires:  vim
BuildRequires:  xorg-x11-devel
%if 0%{?suse_version} > 1030
BuildRequires:  ncurses-utils
%endif
%if 0%{?suse_version} > 1020
BuildRequires:  fdupes
%endif
Name:           eso-midas
Version:        19FEBpl1.1
Release:        0
Summary:        European Southern Observatory Munich Image Data Analysis System
License:        GPL-2.0-or-later
Group:          Productivity/Scientific/Astronomy
Url:            http://www.eso.org/sci/software/esomidas/
Source0:        ftp://ftp.eso.org/pub/midaspub/19FEB/sources/%{version}.tar.bz2
Source1:        calib_src.tar.bz2
Source3:        agldoc.tar.bz2
Source4:        daophot.ps.bz2
Source5:        env.ps.bz2
Source6:        ididoc.ps.bz2
Source7:        installunix.ps.bz2
Source8:        installvms.ps.bz2
Source9:        midas-faq.doc.bz2
Source10:       README.doc
Source11:       volume_a.html.tar.bz2
Source12:       volume_a.ps.bz2
Source13:       volume_b.html.tar.bz2
Source14:       volume_b.ps.bz2
# PATCH-FIX-UPSTREAM fix_size_t.patch - matwey.kornilov@gmail.com -- Fix building for 12.3
Patch0:         fix-size_t.patch
# PATCH-FIX-UPSTREAM end-of-non-void-function.patch - matwey.kornilov@gmail.com -- Fix building for Factory
Patch1:         end-of-non-void-function.patch
# PATCH-FIX-UPSTREAM no-return-statement.patch - matwey.kornilov@gmail.com -- Fix building for Factory
Patch2:         no-return-statement.patch
# xwininfo executed by display
Requires:       xwininfo
BuildRoot:      %{_tmppath}/%{name}-%{version}-build

%description
The ESO-MIDAS(tm) system provides general tools for image processing and data
reduction with emphasis on astronomical applications including imaging and
special reduction packages for ESO instrumentation at La Silla and the VLT at
Paranal. In addition it contains applications packages for stellar and surface
photometry, image sharpening and decomposition, statistics and various others.

%package -n eso-midas-doc
Summary:        Documentation for ESO-MIDAS(tm)
Group:          Documentation/Other

%description -n eso-midas-doc
This package contains the documentation for ESO-MIDAS(tm):

 * ASTRONET Graphics library
 * DAOPHOT II
 * MIDAS Environment
 * Image Display Interface
 * Installation of MIDAS on UNIX Systems
 * Installation of MIDAS on VMS Systems
 * MIDAS FAQ
 * MIDAS User Guide Volume A
 * MIDAS User Guide Volume B

%package -n eso-midas-calib
Summary:        Calibration data for ESO-MIDAS(tm)
Group:          Productivity/Scientific/Astronomy
Requires:       eso-midas = %{version}

%description -n eso-midas-calib
This package contains the calibration data for ESO-MIDAS(tm).

%package -n eso-midas-devel
Summary:        ESO-MIDAS(tm) - development files
Group:          Development/Libraries/C and C++
Requires:       eso-midas = %{version}

%description -n eso-midas-devel
This package contains the headers, static libraries for ESO-MIDAS(tm).

%prep
%setup -q -c -n midas -a 1
%patch0 -p1
%patch1 -p1
%patch2 -p1

%build
%define _lto_cflags %{nil}

##
## MIDAS
##
# Installation of MIDAS on UNIX Systems
# 2.4 The Config Script
export MIDVERS=%{version}
export MIDASHOME=`pwd`
pushd %{version}/install/unix
# 2.5 Preinstallation of MIDAS
./preinstall -a
echo 'STRIP=echo' >> ../../local/make_options
echo 'DEBUG=-g' >> ../../local/make_options
sed -i -e '/^SLIB=/ s/$/ -ltirpc/' ../../local/make_options
sed -i -e '/^F_OPT=/ s/$/ %{optflags}/' ../../local/make_options
sed -i -e '/^C_OPT=/ s/$/ %{optflags}/' ../../local/make_options
# 2.6 Selection of optional packages
./select all
# 2.7 Installation of MIDAS
./install1 -a
# printout install log
cat ../../tmp/install.*
# 2.9 Setup of MIDAS
./setup -a
# 2.10 Running MIDAS for the first time
mkdir tmp
pushd tmp
cat <<EOF | ../../../system/unix/inmidas
@ compile.all

EOF
cat <<EOF | ../../../system/unix/gomidas
@ ascii_bin
bye

EOF
# 2.11 Verifying MIDAS
cat <<EOF | ../../../system/unix/inmidas
@ vericopy
@@ veriall

EOF

popd
rm -rf tmp

##
## Calib
##
pushd $RPM_BUILD_DIR/midas/calib/install
source ./dbassign.sh
cat <<EOF | $RPM_BUILD_DIR/midas/%{version}/system/unix/inmidas
@@ caldb
@@ filters
bye
EOF
popd
rm -rf $RPM_BUILD_DIR/midas/calib/raw $RPM_BUILD_DIR/midas/calib/install

# Black magic
for F in inmidas helpmidas drs
do
	cat ../../system/unix/$F | sed -e 's|'$RPM_BUILD_DIR'/midas|%{prefix}|g' > $F.t
	chmod 0755 $F.t
	mv $F.t ../../system/unix/$F
done

# Black magic
rm -rf $RPM_BUILD_DIR/midas/calib/data/emos
rm -rf $RPM_BUILD_DIR/midas/calib/data/inst/uves/stisanneal # elf32-sparc precompiled binary
rm -rf $RPM_BUILD_DIR/midas/%{version}/context/\*.ctx # strange *.ctx dead-link
ln -snf ./ftoc-new ../../system/good-ftoc
ln -snf ./ftoc-new ../../libsrc/ftoc
find $RPM_BUILD_DIR/midas/%{version} -perm 0666 -exec chmod 0644 '{}' \;
find $RPM_BUILD_DIR/midas/%{version} -perm 0664 -exec chmod 0644 '{}' \;
find $RPM_BUILD_DIR/midas/%{version} -perm 0775 -exec chmod 0755 '{}' \;
dos2unix $RPM_BUILD_DIR/midas/%{version}/prim/proc/bbmod.pl
find $RPM_BUILD_DIR/midas/%{version} -name *.exe -exec chrpath -r %{prefix}/%{version}/lib '{}' \;
find $RPM_BUILD_DIR/midas/%{version} -name *.so* -exec chrpath -r %{prefix}/%{version}/lib '{}' \;
%if 0%{?suse_version} < 1310
# enable debug for 13.1
find $RPM_BUILD_DIR/midas/%{version} -name *.exe -exec strip '{}' \;
%endif
find $RPM_BUILD_DIR/midas/%{version} -name .cvsignore -exec rm '{}' \;
popd

##
## Documentation
##
mkdir agldoc
tar -jxf   %{S:3} -C agldoc         # ASTRONET Graphics library
bunzip2 -c %{S:4}  > daophot.ps     # DAOPHOT II
bunzip2 -c %{S:5}  > env.ps         # MIDAS Environment
bunzip2 -c %{S:6}  > ididoc.ps      # Image Display Interface
bunzip2 -c %{S:7}  > installunix.ps # Installation of MIDAS on UNIX Systems
bunzip2 -c %{S:8}  > installvms.ps  # Installation of MIDAS on VMS Systems
bunzip2 -c %{S:9}  > midas-faq.doc  # MIDAS FAQ
cp         %{S:10} README.doc
mkdir html
tar -jxf   %{S:11} -C html          # MIDAS User Guide Volume A
bunzip2 -c %{S:12} > volume_a.ps    #
tar -jxf   %{S:13} -C html          # MIDAS User Guide Volume B
bunzip2 -c %{S:14} > volume_b.ps    #
# Black magic
find html/volb -name '*.html.bak' -exec rm '{}' \;
chmod 0644 html/vola/IMG_PARAMS.pag html/vola/IMG_PARAMS.dir html/volb/IMG_PARAMS.pag html/volb/IMG_PARAMS.dir
mv $RPM_BUILD_DIR/midas/calib/README.calib .

%install
# Install MIDAS
mkdir -p %{buildroot}/%{prefix}
cp -pr $RPM_BUILD_DIR/midas/%{version} %{buildroot}/%{prefix}

# Install calib
mkdir -p %{buildroot}/%{prefix}
cp -pr $RPM_BUILD_DIR/midas/calib %{buildroot}/%{prefix}

# 2.12 Cleaning MIDAS
pushd %{buildroot}%{prefix}/%{version}/install/unix
cat <<EOF | ./cleanm
2
y
y
q
EOF
cat <<EOF | ../../system/unix/cleanmidas
y
EOF
popd

# Install binaries
mkdir -p %{buildroot}%{_bindir}
ln -s %{prefix}/%{version}/system/unix/inmidas   %{buildroot}%{_bindir}/inmidas
ln -s %{prefix}/%{version}/system/unix/gomidas   %{buildroot}%{_bindir}/gomidas
ln -s %{prefix}/%{version}/system/unix/helpmidas %{buildroot}%{_bindir}/helpmidas
ln -s %{prefix}/%{version}/system/unix/drs       %{buildroot}%{_bindir}/drs

# Install man pages
mkdir -p %{buildroot}%{_mandir}/man1
gzip -9 -n %{buildroot}%{prefix}/%{version}/system/unix/man1/inmidas.1
gzip -9 -n %{buildroot}%{prefix}/%{version}/system/unix/man1/gomidas.1
gzip -9 -n %{buildroot}%{prefix}/%{version}/system/unix/man1/helpmidas.1
gzip -9 -n %{buildroot}%{prefix}/%{version}/system/unix/man1/readline.1
ln -s %{prefix}/%{version}/system/unix/man1/inmidas.1.gz   %{buildroot}%{_mandir}/man1/inmidas.1.gz
ln -s %{prefix}/%{version}/system/unix/man1/gomidas.1.gz   %{buildroot}%{_mandir}/man1/gomidas.1.gz
ln -s %{prefix}/%{version}/system/unix/man1/helpmidas.1.gz %{buildroot}%{_mandir}/man1/helpmidas.1.gz
ln -s %{prefix}/%{version}/system/unix/man1/readline.1.gz  %{buildroot}%{_mandir}/man1/readline.1.gz

( find %{buildroot}%{prefix}/%{version} -name *.h ;
find %{buildroot}%{prefix}/%{version} -name *.a ;
find %{buildroot}%{prefix}/%{version} -name makefile ;
find %{buildroot}%{prefix}/%{version} -name *.mk ;
find %{buildroot}%{prefix}/%{version}/libsrc ! -type d;
find %{buildroot}%{prefix}/%{version}/libsrc -type d -printf '%%%%dir %p\n' ;
echo %{buildroot}%{prefix}/%{version}/lib/libgmidas.so ;
echo %{buildroot}%{prefix}/%{version}/lib/libmidas.so ;
echo %{buildroot}%{prefix}/calib/data/datatrans/efosc2/save/read.c ; ) | sed -e 's|'%{buildroot}'||g' | sort | uniq > ./eso-midas-devel.manifest

( find %{buildroot}%{prefix}/%{version} ! -type d ;
find %{buildroot}%{prefix}/%{version} -type d -printf '%%%%dir %p\n' ; ) | sed -e 's|'%{buildroot}'||g' | sort | uniq > ./eso-midas.manifest

diff ./eso-midas-devel.manifest ./eso-midas.manifest | grep '^>' | cut -c3- > ./eso-midas.manifest.t; mv ./eso-midas.manifest.t ./eso-midas.manifest

%fdupes %{buildroot}%{_prefix}
%fdupes -s html

%post
/sbin/ldconfig

%postun
/sbin/ldconfig

%files -f eso-midas.manifest
%defattr(-,root,root)
%attr(0755,root,root) %{_bindir}/inmidas
%attr(0755,root,root) %{_bindir}/gomidas
%attr(0755,root,root) %{_bindir}/helpmidas
%attr(0755,root,root) %{_bindir}/drs
%{_mandir}/man1/inmidas.1.gz
%{_mandir}/man1/gomidas.1.gz
%{_mandir}/man1/helpmidas.1.gz
%{_mandir}/man1/readline.1.gz
%dir %{prefix}

%files -n eso-midas-doc
%defattr(0644,root,root,0755)
%doc agldoc
%doc daophot.ps
%doc env.ps
%doc ididoc.ps
%doc installunix.ps
%doc installvms.ps
%doc midas-faq.doc
%doc README.doc
%doc html/vola
%doc volume_a.ps
%doc html/volb
%doc volume_b.ps

%files -n eso-midas-calib
%defattr(-,root,root)
%doc README.calib
%dir %{prefix}/calib
%{prefix}/calib/*
# The following file is included into eso-midas-devel package
%exclude %{prefix}/calib/data/datatrans/efosc2/save/read.c

%files -n eso-midas-devel -f eso-midas-devel.manifest
%defattr(-,root,root)

%changelog
openSUSE Build Service is sponsored by