Blob Blame Raw
# Bootstrap option, we have to build astrometry before we can generate index
# files, but later package will require them for tests at build time
%global bootstrap 1

Name:           astrometry
Version:        0.72
Release:        3%{?dist}
Summary:        Blind astrometric calibration of arbitrary astronomical images

# Software is BSD with some GPL code
# Here we asked to fix source headers:
# Licensing breakdown
# ===================
# See also: file CREDITS in source folder
# General license for astrometry code: 3-clause BSD
# GPLv2+:
#    qfits-an/*
#    include/astrometry/qfits*
#    catalogs/ucac4-fits.h
#    libkd/an-fls.h
#    util/makefile.jpeg
#    util/md5.c
#    Makefile
#    doc/UCAC3_guide/* (not used for build and not shipped)
#    doc/UCAC4_guide/* (not used for build and not shipped)
#    2MASS data files index-42xx.fits
# GPLv3+:
#    blind/an_mm_malloc.h
#    util/ctmf.c
License:        BSD and GPLv2+ and GPLv3+

# Upstream sources contains nonfree stuff so we must clean them
# Download original sources from:
# Source0:{name}.net-%%{version}.tar.gz
# Then use the provided script to clean them with
# ./generate-tarball %%{version}
Source0:        %{name}.net-%{version}-clean.tar.xz
Source1:        %{name}

# 2MASS data files

# Patches from Ole Streicher <> used on Debian to
#  * disable build of nonfree stuff removed from sources
#  * have a proper versioned soname
#  * use system libraries properly
#  * use dynamical linking
Patch0:         %{name}
Patch1:         %{name}
Patch2:         %{name}-Fix-issues-when-using-Debian-libs-instead-of-convienience.patch
Patch3:         %{name}-Call-python-scripts-as-modules-instead-of-executables.patch
Patch4:         %{name}-Don-t-install-non-free-files-images-and-NGC2000.0-catalog.patch

BuildRequires:  netpbm-devel
BuildRequires:  python2-numpy
BuildRequires:  python2-astropy
BuildRequires:  python2-devel
BuildRequires:  swig
BuildRequires:  xorg-x11-proto-devel

BuildRequires:  pkgconfig
BuildRequires:  pkgconfig(cairo)
BuildRequires:  pkgconfig(cfitsio)
BuildRequires:  pkgconfig(fontconfig)
BuildRequires:  pkgconfig(gsl)
BuildRequires:  pkgconfig(libjpeg)
BuildRequires:  pkgconfig(libpng)
BuildRequires:  pkgconfig(wcslib)
BuildRequires:  pkgconfig(xrender)
BuildRequires:  pkgconfig(zlib)

%if ! 0%{?bootstrap}
BuildRequires:  astrometry-tycho2

Requires:       %{name}-data = %{version}-%{release}
Requires:       %{name}-libs%{?_isa} = %{version}-%{release}
Requires:       netpbm-progs
Requires:       python2-%{name} = %{version}-%{release}

# User could use own set of index files or another set from upstream.
# Therefore we suggest and not require astrometry-tycho2 here
Suggests:     astrometry-tycho2

The astrometry engine will take any image and return the astrometry
world coordinate system (WCS), a standards-based description of the
transformation between image coordinates and sky coordinates.

Other tools included in the astrometry package can do much more, like
plotting astronomic information over solved images, convertion utilities
or generate statistics from FITS images.

%package data
Summary:        2MASS catalog index files for astrometry (wide-field)
License:        GPLv2+
BuildArch:      noarch
Requires:       %{name} = %{version}-%{release}

%description data
2MASS index files 4208-4219 (wide-field) for astrometry.

%package devel
Summary:        Development files for %{name}
Requires:       %{name}-libs%{?_isa} = %{version}-%{release}

%description devel

%package libs
Summary:        Libraries for %{name}

%description libs
Libraries for %{name}

%package -n python2-%{name}
Summary:        Python modules from %{name}
Requires:       python2-astropy
Provides:       %{name}-python2 = %{version}-%{release}
Obsoletes:      %{name}-python2 < %{version}-%{release}

%description -n python2-%{name}

%autosetup -p1 -b0 -n %{name}.net-%{version}

# Fix Wrong FSF address - reported upstream
grep -rl '59 Temple Place, Suite 330, Boston, MA  02111-1307  USA' * | xargs -i@ sed -i 's/59 Temple Place, Suite 330, Boston, MA  02111-1307  USA/51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA./g' @

# Weird symlink required... (also in upstream git)
ln -sf . astrometry

# Astrometry doesn't automatically find netpbm
export NETPBM_INC=-I%{_includedir}/netpbm
export NETPBM_LIB="-L%{_libdir} -lnetpbm"

# Apply mandatory ld flags
export LDFLAGS="%__global_ldflags"

# Parallel make flags on break build
make SYSTEM_GSL=yes all py extra ARCH_FLAGS="%{optflags}"

%{make_install} SYSTEM_GSL=yes \
                INSTALL_DIR=%{buildroot}%{_prefix} \
                PY_BASE_INSTALL_DIR=%{buildroot}%{python2_sitearch}/%{name} \
                INCLUDE_INSTALL_DIR=%{buildroot}%{_includedir}/%{name} \
                LIB_INSTALL_DIR=%{buildroot}%{_libdir} \
                BIN_INSTALL_DIR=%{buildroot}%{_bindir} \
                DATA_INSTALL_DIR=%{buildroot}%{_datadir}/%{name}/data \
                PY_BASE_LINK_DIR=%{python2_sitearch}/%{name} \
                ETC_INSTALL_DIR=%{buildroot}%{_sysconfdir} \
                MAN1_INSTALL_DIR=%{buildroot}%{_mandir}/man1 \
                DOC_INSTALL_DIR=%{buildroot}%{_docdir}/%{name} \

# We need to correct the data dir link in config file
sed -i \
    "s:%{buildroot}%{_prefix}/data:%{_datadir}/%{name}/data:" \

install -m0644 %{SOURCE2} %{buildroot}%{_datadir}/%{name}/data
install -m0644 %{SOURCE3} %{buildroot}%{_datadir}/%{name}/data
install -m0644 %{SOURCE4} %{buildroot}%{_datadir}/%{name}/data
install -m0644 %{SOURCE5} %{buildroot}%{_datadir}/%{name}/data
install -m0644 %{SOURCE6} %{buildroot}%{_datadir}/%{name}/data
install -m0644 %{SOURCE7} %{buildroot}%{_datadir}/%{name}/data
install -m0644 %{SOURCE8} %{buildroot}%{_datadir}/%{name}/data
install -m0644 %{SOURCE9} %{buildroot}%{_datadir}/%{name}/data
install -m0644 %{SOURCE10} %{buildroot}%{_datadir}/%{name}/data
install -m0644 %{SOURCE11} %{buildroot}%{_datadir}/%{name}/data
install -m0644 %{SOURCE12} %{buildroot}%{_datadir}/%{name}/data
install -m0644 %{SOURCE13} %{buildroot}%{_datadir}/%{name}/data

# Rename generic named executables with known conflict
pushd %{buildroot}%{_bindir}
for exec in tabmerge tablist; do
        mv $exec astrometry-$exec

# Remove unuseful file
rm -f %{buildroot}%{_docdir}/%{name}/report.txt

# We don't ship static libraries so we remove them
rm -f %{buildroot}%{_libdir}/*.a

# Fix wrong python interpreter
pushd %{buildroot}%{_bindir}
for exec in degtohms image2pnm removelines text2fits hmstodeg votabletofits uniformize merge-columns; do
        sed -i "s,/usr/bin/env python,%{__python2},g" $exec
find %{buildroot}/%{python2_sitearch}/%{name} -name '*.py' | xargs sed -i '1s|^#!.*|#!%{__python2}|'

# LICENSE file is managed by %%license scriptlet
rm -f %{buildroot}%{_docdir}/%{name}/LICENSE

make test ARCH_FLAGS="%{optflags}"

%post libs -p /sbin/ldconfig
%postun libs -p /sbin/ldconfig

%license LICENSE
%exclude %{_bindir}/*.py
%dir %{_datadir}/astrometry
%dir %{_datadir}/astrometry/data
%config(noreplace) %{_sysconfdir}/astrometry.cfg

%files data

%files devel

%files libs
%license LICENSE

%files -n python2-%{name}

* Mon Oct 16 2017 Christian Dersch <> - 0.72-3
- Added data subpackage containing the wide-field 2MASS indices

* Mon Sep 25 2017 Christian Dersch <> - 0.72-2
- Move libs to subpackage to be multiarch compatible

* Tue Sep 12 2017 Christian Dersch <> - 0.72-1
- Initial SCM import (#1470436)

* Wed Jul 12 2017 Christian Dersch <> - 0.72-0.1
- initial spec (using the packaging effort from Mattia Verga, RHBZ  #1299139)