Compare commits

...

14 Commits

Author SHA1 Message Date
Jens Petersen c9e900862d minor backport: licensedir, macros.ghc-os and cabal-tweak-drop-dep 2018-07-28 11:11:45 +09:00
Jens Petersen 5422ec3f6d workaround unversioned _pkgdocdir in RHEL 7.3 (#1392354) 2016-12-01 13:17:55 +09:00
Jens Petersen bdfdce2c98 sync with 1.2.20.fc21, adding aarch64 and ppc64le 2016-10-27 11:42:00 +09:00
Jens Petersen 6370860655 rebuild 2016-10-26 18:35:36 +09:00
Jens Petersen 1d8516e2d8 rename ghc-rpm-macros.ghc to macros.ghc & ghc-rpm-macros.ghc-extra to macros.ghc-extra 2015-10-08 19:56:14 +09:00
Jens Petersen 6bac1af8a1 backport some improvements from F21
- cabal macro now sets utf8 locale
- introduce ghc_pkgdocdir since no _pkgdocdir in RHEL 7 and earlier
- add cabal_test macro
- improve ghc_fix_dynamic_rpath
- add new names ghc_html_dir, ghc_html_libraries_dir, and ghc_html_pkg_dir
- correct cabal-tweak-flag error message for missing flag (#1184508)
- use rpm fileattr's for bin and lib files
- require ghc-compiler for ghc_version
- ghc-deps.sh: support ghc-pkg for ghc builds <= 7.4.2 as well
- drop -O2: it often uses too much build mem
- condition use of execstack since no prelink on ppc64le or arm64
2015-10-08 19:52:14 +09:00
Jens Petersen 23b924fc73 re-version to 1.0.7.4
source is now identical to current F20
2014-06-20 16:20:45 +09:00
Jens Petersen 16381a38a3 merge latest f20 changes
- do bcond cabal configure --enable-tests also for Bin packages
- enable configure bcond check for tests
- use -O2 also for executable (Bin) packages and allow it to be overrided
- set Url field when generating subpackages
- update license tag to GPLv3+
- handle no _pkgdocdir in RHEL7 and docdir path different to F20+
- abort ghc_fix_dynamic_rpath if no chrpath
- Install macros to %%{_rpmconfigdir}/macros.d.
- set datasubdir in cabal_configure for ghc-7.8

now identical to f20 1.0.7.4
2014-05-17 17:17:26 +09:00
Jens Petersen 1c2b26b493 rebase to backport from F20 for ghc-7.6
- add ghc-rpm-macros-extra subpackage
- fix ghc-deps.sh for ghc-pkg-7.6.3 and 7.8
- add ghcpkgdocdir (versioned)
- add ghc_clear_execstack
- static only archs also gain base lib subpkgs
2014-03-28 18:26:56 +09:00
Jens Petersen 933ac5650d backport changes from 1.0.7.3
- ghc_fix_dynamic_rpath: abort for non-existent executable name with error msg
- cabal-tweak-flag: add manual field to enforce flag changes
- fix ghc-deps.sh when bootstrapping a new ghc version
- use objdump -p instead of ldd to read executable dependencies
- add --global to cabal_configure if not subpackaging libs

move --htmldir (should be no-op)
2014-03-26 17:58:50 +09:00
Jens Petersen 049fb825b4 add ghcpkgdocdir and drop ghc_docdir 2013-10-25 17:21:01 +09:00
Jens Petersen 396a1b8acd add ghc_docdir for package docdir
this should allow portability between versioned and unversioned docdir
2013-07-26 15:25:21 +09:00
Jens Petersen 5dc374da41 add ghc_clear_execstack to ghc_bin_install and ghc_lib_install; ghc_without_shared cleanup
- require prelink for execstack
- create lib base package also when ghc_without_shared is set (#983137)
2013-07-11 10:45:03 +09:00
Jens Petersen d204890e6a backport some changes for new simplified Packaging from rawhide
- ghc_fix_dynamic_rpath fix
- packaging for without_shared is now done the same way as shared
- remove deprecated ghc_exclude_docdir
2013-06-20 18:04:41 +09:00
10 changed files with 458 additions and 354 deletions

30
cabal-tweak-drop-dep Executable file
View File

@ -0,0 +1,30 @@
#!/bin/sh
set -e +x
USAGE="Usage: $0 dep"
if [ $# -ne 1 ]; then
echo "$USAGE"
exit 1
fi
DEP=$1
CABALFILE=$(ls *.cabal)
if [ $(echo $CABALFILE | wc -w) -ne 1 ]; then
echo "There needs to be one .cabal file in the current dir!"
exit 1
fi
if [ ! -f $CABALFILE.orig ]; then
BACKUP=.orig
fi
if grep "$DEP" $CABALFILE | sed -e "s/$DEP//" | grep -q -e "[A-Za-z]"; then
echo "$0: deleting whole $DEP lines not safe - try more precise pattern"
exit 1
fi
sed -i$BACKUP -e "/$DEP/d" $CABALFILE

View File

@ -29,7 +29,7 @@ if [ $(echo $CABALFILE | wc -w) -ne 1 ]; then
fi
if ! grep -q -i "^flag *$FLAG" $CABALFILE; then
echo "$CABALFILE does have flag $FLAG"
echo "$CABALFILE does not have flag $FLAG"
exit 1
fi
@ -47,4 +47,4 @@ if [ ! -f $CABALFILE.orig ]; then
BACKUP=.orig
fi
sed -i$BACKUP -e "/[Ff]lag *$FLAG/,/[Dd]efault: *$OLD/ s/\([Dd]efault: *\)$OLD/\1$NEW/" $CABALFILE
sed -i$BACKUP -e "/[Ff]lag *$FLAG/,/[Dd]efault: *$OLD/ s/\( \+\)\([Dd]efault:[ \t]*\)$OLD/\1\2$NEW\n\1manual: True/" $CABALFILE

View File

@ -1,22 +1,32 @@
#!/bin/sh
# find rpm provides and requires for Haskell GHC libraries
# To use add the following lines to spec file:
# %define _use_internal_dependency_generator 0
# %define __find_requires /usr/lib/rpm/ghc-deps.sh --requires %{buildroot}%{ghclibdir}
# %define __find_provides /usr/lib/rpm/ghc-deps.sh --provides %{buildroot}%{ghclibdir}
[ $# -ne 2 ] && echo "Usage: `basename $0` [--provides|--requires] %{buildroot}%{ghclibdir}" && exit 1
set +x
MODE=$1
PKGBASEDIR=$2
PKGCONFDIR=$PKGBASEDIR/package.conf.d
GHC_VER=$(basename $PKGBASEDIR | sed -e s/ghc-//)
if [ ! -x "/usr/bin/ghc-pkg-${GHC_VER}" -a -x "$PKGBASEDIR/ghc-pkg" ]; then
GHC_PKG="$PKGBASEDIR/ghc-pkg --global-conf=$PKGCONFDIR"
# for a ghc build use the new ghc-pkg
INPLACE_GHCPKG=$PKGBASEDIR/../../bin/ghc-pkg-$GHC_VER
if [ -x "$INPLACE_GHCPKG" ]; then
case $GHC_VER in
7.8.*)
GHC_PKG="$PKGBASEDIR/bin/ghc-pkg --global-package-db=$PKGCONFDIR"
;;
7.6.*)
GHC_PKG="$PKGBASEDIR/ghc-pkg --global-package-db=$PKGCONFDIR"
;;
*)
GHC_PKG="$PKGBASEDIR/ghc-pkg --global-conf=$PKGCONFDIR"
;;
esac
else
GHC_PKG="/usr/bin/ghc-pkg"
GHC_PKG="/usr/bin/ghc-pkg-${GHC_VER}"
fi
case $MODE in
@ -29,14 +39,10 @@ if [ -d "$PKGBASEDIR" ]; then
SHARED=$(find $PKGBASEDIR -type f -name '*.so')
fi
GHCVERSION=$(ghc --numeric-version)
files=$(cat)
#set -x
for i in $files; do
LIB_FILE=$(echo $i | grep /libHS | egrep -v "$PKGBASEDIR/libHS")
LIB_FILE=$(echo $i | grep /libHS | egrep -v "/libHSrts")
if [ "$LIB_FILE" ]; then
if [ -d "$PKGCONFDIR" ]; then
META=""
@ -68,7 +74,7 @@ for i in $files; do
fi
elif [ "$MODE" = "--requires" ]; then
if file $i | grep -q 'executable, .* dynamically linked'; then
BIN_DEPS=$(ldd $i | grep libHS | grep -v libHSrts | sed -e "s%^\\tlibHS\(.*\)-ghc${GHCVERSION}.so =.*%\1%")
BIN_DEPS=$(objdump -p $i | grep NEEDED | grep libHS | grep -v libHSrts | sed -e "s%^ *NEEDED *libHS\(.*\)-ghc${GHC_VER}\.so%\1%")
if [ -d "$PKGCONFDIR" ]; then
PACKAGE_CONF_OPT="--package-conf=$PKGCONFDIR"
fi
@ -79,5 +85,3 @@ for i in $files; do
fi
fi
done
echo $files | tr [:blank:] '\n' | /usr/lib/rpm/rpmdeps $MODE

View File

@ -1,316 +0,0 @@
# RPM Macros for packaging Haskell cabalized packages -*-rpm-spec-*-
# see https://fedoraproject.org/wiki/PackagingDrafts/Haskell for more details
# "cabal"
%cabal [ -x Setup ] || ghc --make %{!?ghc_user_conf:-no-user-package-conf} %{!?ghc_without_dynamic:-dynamic} Setup\
./Setup
# check ghc version was rebuilt against self
%ghc_check_bootstrap\
if [ ! "$(ghc --info | grep \\"Booter\\ version\\",\\"%{ghc_version}\\")" ]; then\
echo "Warning: this ghc build is not self-bootstrapped."\
%if %{undefined ghc_bootstrapping}\
echo "The ghc package should be rebuilt against its current version before\
proceeding, to avoid dependency ABI breakage from a future ghc rebuild."\
echo "To override set ghc_bootstrapping."\
echo "Aborting."\
exit 1\
%endif\
fi
# configure
%cabal_configure\
%ghc_check_bootstrap\
%cabal configure --prefix=%{_prefix} --libdir=%{_libdir} --docdir=%{_docdir}/%{name}-%{version} %{?pkg_name:--htmldir=%{ghclibdocdir}/%{pkg_name}-%{version}} --libsubdir='$compiler/$pkgid' --ghc %{!?ghc_without_dynamic:--enable-executable-dynamic} %{?cabal_configure_options} $cabal_configure_extra_options
# install
%cabal_install %cabal copy --destdir=%{buildroot} -v
# root dir for ghc docs
%ghcdocbasedir %{_docdir}/ghc/html
# libraries doc dir
%ghclibdocdir %{ghcdocbasedir}/libraries
# top library dir
%ghclibdir %{_libdir}/ghc-%{ghc_version}
# ghc_gen_filelists [name] [version]
%ghc_gen_filelists()\
%define pkgname %{?1}%{!?1:%{pkg_name}}\
%define pkgver %{?2}%{!?2:%{version}}\
%define pkgnamever %{pkgname}-%{pkgver}\
%define basepkg ghc-%{pkgname}\
%define pkgdir %{ghclibdir}/%{pkgnamever}\
%define docdir %{ghclibdocdir}/%{pkgnamever}\
rm -f %{basepkg}.files %{basepkg}-devel.files\
if [ -d "%{buildroot}%{pkgdir}" ]; then\
echo "%dir %{pkgdir}" >> %{basepkg}%{?ghc_without_shared:-devel}.files\
%if %{undefined ghc_without_shared}\
echo "%attr(755,root,root) %{pkgdir}/libHS%{pkgnamever}-ghc%{ghc_version}.so" >> %{basepkg}.files\
%endif\
fi\
%if %{defined ghc_without_shared}\
if [ "%{name}" = "%{basepkg}" -o -n "%{?1}" ]; then\
if [ -d "%{buildroot}%{_docdir}/%{basepkg}-%{pkgver}" ]; then\
mv %{buildroot}%{_docdir}/%{basepkg}-%{pkgver} %{buildroot}%{_docdir}/%{basepkg}-devel-%{pkgver}\
%if %{undefined ghc_exclude_docdir}\
echo "%{_docdir}/%{basepkg}-devel-%{version}" >> %{basepkg}-devel.files\
%endif\
fi\
fi\
%endif\
%if %{undefined ghc_exclude_docdir}\
if [ -d "%{buildroot}%{_docdir}/%{name}-%{version}" ]; then\
echo "%{_docdir}/%{name}-%{version}" >> %{basepkg}%{?ghc_without_shared:-devel}.files\
elif [ -d "%{buildroot}%{_docdir}/ghc-%{pkgnamever}" ]; then\
echo "%{_docdir}/ghc-%{pkgnamever}" >> %{basepkg}%{?ghc_without_shared:-devel}.files\
fi\
%endif\
echo "%{ghclibdir}/package.conf.d/%{pkgnamever}*.conf" >> %{basepkg}-devel.files\
if [ -d "%{buildroot}%{pkgdir}" ]; then\
find %{buildroot}%{pkgdir} -mindepth 1 -type d | sed "s/^/%dir /" >> %{basepkg}-devel.files\
find %{buildroot}%{pkgdir} ! \\( -type d -o -name "libHS*.so" \\) >> %{basepkg}-devel.files\
fi\
if [ -d "%{buildroot}%{docdir}" ]; then\
echo "%{docdir}" >> %{basepkg}-devel.files\
fi\
for i in %{!?ghc_without_shared:%{basepkg}.files} %{basepkg}-devel.files; do\
if [ -f "$i" ]; then\
sed -i -e "s!%{buildroot}!!g" $i\
fi\
done\
%{nil}
%ghc_add_basepkg_file()\
%define basepkg ghc-%{pkg_name}\
echo "%*" >> %{basepkg}%{?ghc_without_shared:-devel}.files
# compiler version
%ghc_version %{!?ghc_version_override:%(ghc --numeric-version)}%{?ghc_version_override}
# create and install package.conf file
# cabal_pkg_conf [name] [version]
%cabal_pkg_conf()\
%define pkgname %{?1}%{!?1:%{pkg_name}}\
%define pkgver %{?2}%{!?2:%{version}}\
%define pkgnamever %{pkgname}-%{pkgver}\
%cabal register --gen-pkg-config\
mkdir -p %{buildroot}%{ghclibdir}/package.conf.d\
install --mode=0644 %{pkgnamever}.conf %{buildroot}%{ghclibdir}/package.conf.d\
%{nil}
# devel pkg basic requires
%ghc_devel_requires Requires: ghc-compiler = %{ghc_version}\
Requires(post): ghc-compiler = %{ghc_version}\
Requires(postun): ghc-compiler = %{ghc_version}\
%if %{undefined ghc_without_shared} && 0%{!?-m:1}\
Requires: ghc-%{?pkg_name}%{!?pkg_name:%{pkgname}} = %{?pkgver}%{!?pkgver:%{version}}-%{release}\
%endif
%ghc_shared_files\
%if %{undefined ghc_without_shared}\
%files -n %{basepkg} -f %{basepkg}.files\
%{?base_doc_files:%doc %base_doc_files}\
%endif\
%{nil}
# ghc_lib_package [-c cdepslist] [-h pkgdepslist]
%ghc_lib_package(c:h:)\
%define pkgname %{?1}%{!?1:%{pkg_name}}\
%define basepkg ghc-%{pkgname}\
%ghc_shared_files\
\
%ghc_package_devel\
%{nil}
# ghc_package [-l licensetag] [name] [version]
%ghc_package(l:)\
%define pkgname %{?1}%{!?1:%{pkg_name}}\
%define pkgver %{?2}%{!?2:%{version}}\
%define basepkg ghc-%{pkgname}\
%package -n %{basepkg}\
Summary: %{?common_summary}%{!?common_summary:Haskell %{pkgname} library}\
Group: System Environment/Libraries\
%{?1:Version: %{pkgver}}\
%{-l:License: %{-l*}}\
%{?ghc_pkg_obsoletes:Obsoletes: %(echo "%{ghc_pkg_obsoletes}" | sed -e "s/\\(ghc-[^, ]*\\)-devel/\\1/g")}
# ghc_description [name] [version]
%ghc_description()\
%define pkgname %{?1}%{!?1:%{pkg_name}}\
%define basepkg ghc-%{pkgname}\
%description -n %{basepkg}\
%{?common_description}%{!?common_description:Haskell %{pkgname} library.}\
%if %{defined ghc_version} && %{undefined ghc_without_shared}\
This package provides the shared library.\
%endif
# ghc_lib_subpackage [-c cdepslist] [-h pkgdepslist] [-l licensetag] [-x] [name] [version]
%ghc_lib_subpackage(c:h:l:x)\
%define pkgname %{?1}%{!?1:%{pkg_name}}\
%define pkgver %{?2}%{!?2:%{version}}\
%define pkgnamever %{pkgname}-%{pkgver}\
%{!-x:%{?1:%global ghc_packages_list %{?ghc_packages_list} %{pkgnamever}}}\
%define basepkg ghc-%{pkgname}\
%ghc_package\
\
%ghc_description\
\
%ghc_lib_package\
%{nil}
%ghc_pkg_recache %{_bindir}/ghc-pkg recache --no-user-package-conf || :
# (deprecated) for docs post and postun
%ghc_reindex_haddock :
%ghc_devel_files\
%files -n %{basepkg}-devel -f %{basepkg}-devel.files\
%if %{defined ghc_without_shared}\
%{?base_doc_files:%doc %base_doc_files}\
%endif\
%{?devel_doc_files:%doc %devel_doc_files}\
%{nil}
%ghc_files()\
%{?1:%define base_doc_files %*}\
%define basepkg ghc-%{pkg_name}\
%ghc_shared_files\
\
%ghc_devel_files\
%{nil}
# ghc_devel_package [-c cdepslist] [-h pkgdepslist] [-l licensetag] [-m] [name] [version]
# -m : meta-package
%ghc_devel_package(c:h:l:m)\
%define pkgname %{?1}%{!?1:%{pkg_name}}\
%define pkgver %{?2}%{!?2:%{version}}\
%define basepkg ghc-%{pkgname}\
%package -n %{basepkg}-devel\
Summary: %{?common_summary}%{!?common_summary:Haskell %{pkgname} library} development files\
Group: Development/Libraries\
%{?1:Version: %{pkgver}}\
%{-l:License: %{-l*}}\
%{?ghc_devel_requires}\
%{-h:Requires: %{-h*}}\
%{?ghc_pkg_c_deps:Requires: %{ghc_pkg_c_deps}}\
%{-c:Requires: %{-c*}}\
%{?ghc_pkg_obsoletes:Obsoletes: %{ghc_pkg_obsoletes}}\
%{?ghc_pkg_obsoletes:Obsoletes: %(echo "%{ghc_pkg_obsoletes}" | sed -e "s/\\(ghc-[^, ]*\\)-devel/\\1-doc/g")}\
Obsoletes: %{basepkg}-doc < %{pkgver}-%{release}\
Provides: %{basepkg}-doc = %{pkgver}-%{release}\
Obsoletes: %{basepkg}-prof < %{pkgver}-%{release}\
%if %{undefined without_prof}\
Provides: %{basepkg}-prof = %{pkgver}-%{release}\
%endif
# ghc_devel_description
%ghc_devel_description()\
%define pkgname %{?1}%{!?1:%{pkg_name}}\
%define basepkg ghc-%{pkgname}\
%description -n %{basepkg}-devel\
%{?common_description}%{!?common_description:Haskell %{pkgname} library.}\
\
This package contains the development files.
# ghc_devel_post_postun
%ghc_devel_post_postun()\
%define pkgname %{?1}%{!?1:%{pkg_name}}\
%define basepkg ghc-%{pkgname}\
%post -n %{basepkg}-devel\
%ghc_pkg_recache\
\
%postun -n %{basepkg}-devel\
%ghc_pkg_recache
# ghc_package_devel [-c cdepslist] [-h pkgdepslist] [-l licensetag] [name] [version]
%ghc_package_devel(c:h:l:)\
%define pkgname %{?1}%{!?1:%{pkg_name}}\
%define basepkg ghc-%{pkgname}\
%ghc_devel_package\
\
%ghc_devel_description\
\
%ghc_devel_post_postun\
\
%ghc_devel_files\
%{nil}
# ghc_strip_dynlinked
%ghc_strip_dynlinked\
%if %{undefined __debug_package}\
find %{buildroot} -type f -exec sh -c "file {} | grep -q 'dynamically linked'" \\; -exec strip "{}" \\;\
%endif
# ghc_bin_build
%ghc_bin_build\
%global debug_package %{nil}\
%cabal_configure\
%cabal build
# ghc_lib_build_without_haddock [name] [version]
%ghc_lib_build_without_haddock()\
%global debug_package %{nil}\
%cabal_configure %{!?without_prof:-p} %{!?ghc_without_shared:--enable-shared} %{?1:--docdir=%{_docdir}/ghc-%1-%2 --htmldir=%{ghclibdocdir}/%1-%2} %{?ghc_with_lib_for_ghci:--enable-library-for-ghci}\
%cabal build\
%{nil}
# ghc_lib_build [name] [version]
%ghc_lib_build()\
%ghc_lib_build_without_haddock\
%if %{undefined without_haddock}\
%cabal haddock --html %{!?without_hscolour:%(if [ -x %{_bindir}/HsColour ]; then echo --hyperlink-source; fi)} --hoogle\
%endif\
%{nil}
# install bin package
%ghc_bin_install()\
%global _use_internal_dependency_generator 0\
%global __find_requires %{_rpmconfigdir}/ghc-deps.sh --requires %{buildroot}%{ghclibdir}\
%cabal_install\
%{!?1:%ghc_strip_dynlinked}\
%{nil}
# ghc_lib_install [name] [version]
%ghc_lib_install()\
%global _use_internal_dependency_generator 0\
%global __find_provides %{_rpmconfigdir}/ghc-deps.sh --provides %{buildroot}%{ghclibdir}\
%global __find_requires %{_rpmconfigdir}/ghc-deps.sh --requires %{buildroot}%{ghclibdir}\
%cabal_install\
%cabal_pkg_conf\
%ghc_gen_filelists\
%{!?1:%ghc_strip_dynlinked}\
%{nil}
# ghc_fix_dynamic_rpath prog ...
%ghc_fix_dynamic_rpath()\
%if %{undefined ghc_without_dynamic}\
PDIR=$(cd ..; pwd)\
for i in %*; do\
PROG=%{buildroot}%{_bindir}/$i\
RPATH=$(chrpath $PROG| sed -e "s@^$PROG: RPATH=@@")\
case $RPATH in\
$PDIR*)\
NEWRPATH=$(echo $RPATH | sed -e "s@$PDIR@%{ghclibdir}@g" -e "s@/dist/build@@g")\
chrpath -r $NEWRPATH $PROG\
;;\
esac\
done\
%endif\
%{nil}
# - without_hscolour, without_testsuite, and ghc_bootstrapping
# need to be set locally in the spec file
# skip prof libs, and documentation
%ghc_test\
%global without_prof 1\
%global without_haddock 1\
%global without_manual 1
# skip shared and prof libs, documentation, and testsuite
%ghc_bootstrap\
%global ghc_without_shared 1\
%global ghc_without_dynamic 1\
%ghc_test
%ghc_exclude_docdir 1

View File

@ -1,35 +1,45 @@
%global debug_package %{nil}
%global macros_file %{_sysconfdir}/rpm/macros.ghc
%if 0%{?fedora} || 0%{?rhel} >= 7
%global macros_dir %{_rpmconfigdir}/macros.d
%else
%global macros_dir %{_sysconfdir}/rpm
%endif
# uncomment to bootstrap without hscolour
#%%global without_hscolour 1
Name: ghc-rpm-macros
Version: 0.98.1
Release: 4%{?dist}
Summary: Macros for building packages for GHC
Version: 1.0.11
Release: 1%{?dist}
Summary: RPM macros for building Haskell packages for GHC
Group: Development/Libraries
License: GPLv3
URL: https://fedoraproject.org/wiki/Haskell_SIG
# This is a Fedora maintained package, originally made for
# the distribution. Hence the source is currently only available
# from this package. But it could be hosted on fedorahosted.org
# for example if other rpm distros would prefer that.
Source0: ghc-rpm-macros.ghc
License: GPLv3+
URL: https://github.com/fedora-haskell/ghc-rpm-macros
# Currently source is only in git but tarballs could be made if it helps
Source0: macros.ghc
Source1: COPYING
Source2: AUTHORS
Source3: ghc-deps.sh
Source4: cabal-tweak-dep-ver
Source5: cabal-tweak-flag
Source6: macros.ghc-extra
Source7: ghc_bin.attr
Source8: ghc_lib.attr
Source9: macros.ghc-os
Source11: cabal-tweak-drop-dep
Requires: redhat-rpm-config
# for ghc_version
Requires: ghc-compiler
%if %{undefined without_hscolour}
BuildRequires: redhat-rpm-config
ExclusiveArch: %{ghc_arches}
%ifarch %{ix86} x86_64 ppc ppc64 alpha sparcv9 armv7hl armv5tel s390 s390x ppc64le aarch64
Requires: hscolour
%endif
%endif
# for execstack (hack not needed for ghc-7.8)
%ifnarch ppc64le aarch64
Requires: prelink
%endif
%description
A set of macros for building GHC packages following the Haskell Guidelines
@ -37,6 +47,15 @@ of the Fedora Haskell SIG. ghc needs to be installed in order to make use of
these macros.
%package extra
Summary: Extra RPM macros for building Haskell library subpackages
Requires: %{name} = %{version}-%{release}
%description extra
Extra macros used for subpackaging of Haskell libraries,
for example in ghc and haskell-platform.
%prep
%setup -c -T
cp %{SOURCE1} %{SOURCE2} .
@ -47,17 +66,21 @@ echo no build stage needed
%install
install -p -D -m 0644 %{SOURCE0} ${RPM_BUILD_ROOT}/%{macros_file}
install -p -D -m 0644 %{SOURCE0} %{buildroot}/%{macros_dir}/macros.ghc
install -p -D -m 0644 %{SOURCE6} %{buildroot}/%{macros_dir}/macros.ghc-extra
install -p -D -m 0644 %{SOURCE9} %{buildroot}/%{macros_dir}/macros.ghc-os
install -p -D -m 0755 %{SOURCE3} %{buildroot}/%{_prefix}/lib/rpm/ghc-deps.sh
install -p -D -m 0644 %{SOURCE7} %{buildroot}/%{_prefix}/lib/rpm/fileattrs/ghc_bin.attr
install -p -D -m 0644 %{SOURCE8} %{buildroot}/%{_prefix}/lib/rpm/fileattrs/ghc_lib.attr
install -p -D -m 0755 %{SOURCE4} %{buildroot}/%{_bindir}/cabal-tweak-dep-ver
install -p -D -m 0755 %{SOURCE5} %{buildroot}/%{_bindir}/cabal-tweak-flag
install -p -D -m 0755 %{SOURCE11} %{buildroot}/%{_bindir}/cabal-tweak-drop-dep
# this is why this package is now arch-dependent:
# turn off shared libs and dynamic linking on secondary archs
%ifnarch %{ix86} x86_64
cat >> %{buildroot}/%{macros_file} <<EOF
cat >> %{buildroot}/%{macros_dir}/macros.ghc <<EOF
# shared libraries are only supported on primary intel archs
%%ghc_without_dynamic 1
@ -67,14 +90,127 @@ EOF
%files
%doc COPYING AUTHORS
%{macros_file}
%license COPYING
%doc AUTHORS
%{macros_dir}/macros.ghc
%{macros_dir}/macros.ghc-os
%{_prefix}/lib/rpm/fileattrs/ghc_bin.attr
%{_prefix}/lib/rpm/fileattrs/ghc_lib.attr
%{_prefix}/lib/rpm/ghc-deps.sh
%{_bindir}/cabal-tweak-dep-ver
%{_bindir}/cabal-tweak-drop-dep
%{_bindir}/cabal-tweak-flag
%files extra
%{macros_dir}/macros.ghc-extra
%changelog
* Sat Jul 28 2018 Jens Petersen <petersen@redhat.com> - 1.0.11-1
- update url
- add macros.ghc-os and cabal-tweak-drop-dep
- install licenses (Cabal docdir) in licenses dir
* Thu Dec 1 2016 Jens Petersen <petersen@redhat.com> - 1.0.10-1
- workaround unversioned _pkgdocdir in RHEL 7.3 (see #1392354)
* Thu Oct 27 2016 Jens Petersen <petersen@redhat.com> - 1.0.7.5-3
- sync with 1.2.20.fc21
- add aarch64 and ppc64le until RHEL 7.3 redhat-rpm-config
* Wed Oct 26 2016 Jens Petersen <petersen@redhat.com> - 1.0.7.5-2
- rebuild
* Thu Oct 8 2015 Jens Petersen <petersen@redhat.com> - 1.0.7.5-1
- cabal macro now sets utf8 locale
- introduce ghc_pkgdocdir since no _pkgdocdir in RHEL 7 and earlier
- add cabal_test macro
- ghc_fix_dynamic_rpath: on ARMv7 RPATH is RUNPATH
- add new names ghc_html_dir, ghc_html_libraries_dir, and ghc_html_pkg_dir
- correct cabal-tweak-flag error message for missing flag (#1184508)
- split ghc.attr into ghc_lib.attr and ghc_bin.attr for finer grained handling
- require ghc-compiler for ghc_version
- ghc-deps.sh: support ghc-pkg for ghc builds <= 7.4.2 as well
- ghc.attr needs to handle requires for /usr/bin files too
- improve ghc_fix_dynamic_rpath not to assume cwd = pkg_name
- drop -O2: it often uses too much build mem
- add an rpm .attr file for ghc-deps.sh rather than running it
as an external dep generator (#1132275)
(see http://rpm.org/wiki/PackagerDocs/DependencyGenerator)
- condition use of execstack since no prelink on ppc64le or arm64
* Sat May 17 2014 Jens Petersen <petersen@redhat.com> - 1.0.7.4-1
- do bcond cabal configure --enable-tests also for Bin packages
- enable configure bcond check for tests
- use -O2 also for executable (Bin) packages and allow it to be overrided
- set Url field when generating subpackages
- update license tag to GPLv3+
- handle no _pkgdocdir in RHEL7 and docdir path different to F20+
- abort ghc_fix_dynamic_rpath if no chrpath
- Install macros to %%{_rpmconfigdir}/macros.d.
- set datasubdir in cabal_configure for ghc-7.8
* Fri Mar 28 2014 Jens Petersen <petersen@redhat.com> - 1.0.4.1-1
- backport recent changes from F20:
- quote the ghc_fix_dynamic_rpath error message
- ghc_fix_dynamic_rpath: abort for non-existent executable name
- cabal-tweak-flag: add manual field to enforce flag changes
- ghc-deps.sh: fix ghc-pkg path when bootstrapping new ghc version
- fix ghc-deps.sh when bootstrapping a new ghc version
- use objdump -p instead of ldd to read executable dependencies
- update ghc-deps.sh to handling ghc-7.8 rts
- ghcpkgdocdir should be versioned (for F20 and earlier)
- add ghcpkgdocdir, which like _pkgdocdir allows for unversioned haddock dirs
* Thu Jul 11 2013 Jens Petersen <petersen@redhat.com> - 1.0.4-1
- check for bindir before looking for executables in ghc_clear_execstack
* Wed Jul 10 2013 Jens Petersen <petersen@redhat.com> - 1.0.3-1
- add ghc_clear_execstack and use it also in ghc_lib_install (#973512)
and require prelink for execstack
* Tue Jul 9 2013 Jens Petersen <petersen@redhat.com> - 1.0.2-1
- drop doc and prof obsoletes and provides from ghc_lib_subpackage
- clear executable stack flag when installing package executables (#973512)
* Thu Jun 20 2013 Jens Petersen <petersen@redhat.com> - 1.0.1-1
- only configure with --global if not subpackaging libs
* Thu Jun 20 2013 Jens Petersen <petersen@redhat.com> - 1.0-3
- reenable hscolour
* Thu Jun 20 2013 Jens Petersen <petersen@redhat.com> - 1.0-2
- turn off hscolour for bootstrap
* Wed Jun 19 2013 Jens Petersen <petersen@redhat.com> - 1.0-1
- add --global to cabal_configure
* Mon Jun 17 2013 Jens Petersen <petersen@redhat.com> - 0.99.4-1
- merge remaining extra macros into ghc_lib_subpackage
* Thu Jun 6 2013 Jens Petersen <petersen@redhat.com> - 0.99.3-1
- configure builds with ghc -O2 (#880135)
* Wed Jun 5 2013 Jens Petersen <petersen@redhat.com> - 0.99.2-1
- drop -h option from extra macros and make -m work again
* Fri May 17 2013 Jens Petersen <petersen@redhat.com> - 0.99.1-1
- drop new ghc_compiler macro since it is not good for koji
- ghc_fix_dynamic_rpath: do not assume first RPATH
* Tue Apr 23 2013 Jens Petersen <petersen@redhat.com> - 0.99-1
- update for simplified revised Haskell Packaging Guidelines
(https://fedorahosted.org/fpc/ticket/194)
- packaging for without_shared is now done the same way as shared
to make non-shared arch packages same as shared ones:
so all archs will now have base library binary packages
- move spec section metamacros and multiple library packaging macros still
needed for ghc and haskell-platform to new extra subpackage
- drop ghc_add_basepkg_file macro and ghc_exclude_docdir
- for ghc-7.6 --global-package-db replaces --global-conf and
--no-user-package-db deprecates --no-user-package-conf
* Wed Mar 20 2013 Ralf Corsépius <corsepiu@fedoraproject.org> - 0.98.1-4
- Remove %%config from %%{_sysconfdir}/rpm/macros.*
(https://fedorahosted.org/fpc/ticket/259).

3
ghc_bin.attr Normal file
View File

@ -0,0 +1,3 @@
%__ghc_bin_requires %{_rpmconfigdir}/ghc-deps.sh --requires %{buildroot}%{ghclibdir}
%__ghc_bin_magic executable, .* dynamically linked
%__ghc_bin_flags exeonly

3
ghc_lib.attr Normal file
View File

@ -0,0 +1,3 @@
%__ghc_lib_provides %{_rpmconfigdir}/ghc-deps.sh --provides %{buildroot}%{ghclibdir}
%__ghc_lib_requires %{_rpmconfigdir}/ghc-deps.sh --requires %{buildroot}%{ghclibdir}
%__ghc_lib_path ^%{ghclibdir}/.*/libHS.*\\.(so|a)$

197
macros.ghc Normal file
View File

@ -0,0 +1,197 @@
# RPM Macros for packaging Haskell cabalized packages -*-rpm-spec-*-
# see https://fedoraproject.org/wiki/Packaging:Haskell for more details
# "cabal"
%cabal [ -x Setup ] || ghc --make %{!?ghc_user_conf:-no-user-package-db} %{!?ghc_without_dynamic:-dynamic} Setup\
LANG=en_US.utf8\
./Setup
# check ghc version was rebuilt against self
%ghc_check_bootstrap\
if [ ! "$(ghc --info | grep \\"Booter\\ version\\",\\"%{ghc_version}\\")" ]; then\
echo "Warning: this ghc build is not self-bootstrapped."\
%if %{undefined ghc_bootstrapping}\
echo "The ghc package should be rebuilt against its current version before\
proceeding, to avoid dependency ABI breakage from a future ghc rebuild."\
echo "To override set ghc_bootstrapping."\
echo "Aborting."\
exit 1\
%endif\
fi
# configure
%cabal_configure\
%ghc_check_bootstrap\
%cabal configure --prefix=%{_prefix} --libdir=%{_libdir} --docdir=%{_ghcdocdir} --libsubdir='$compiler/$pkgid' --datasubdir='$pkgid' --ghc %{!?ghc_without_dynamic:--enable-executable-dynamic} %{?with_tests:--enable-tests} %{?cabal_configure_options} $cabal_configure_extra_options
# install
%cabal_install %cabal copy --destdir=%{buildroot} -v
# tests
%cabal_test\
%if %{with tests}\
%cabal test\
%endif
# _pkgdocdir misdefined unversioned in RHEL 7.3
%ghc_pkgdocdir %{_docdir}/%{name}-%{version}
# root dir for ghc docs (used by ghc.spec)
%ghc_html_dir %{_docdir}/ghc/html
# deprecates
%ghcdocbasedir %{_docdir}/ghc/html
# libraries doc dir (internal)
%ghc_html_libraries_dir %{ghc_html_dir}/libraries
# deprecates
%ghclibdocdir %{ghcdocbasedir}/libraries
# pkg doc dir
%ghc_html_pkg_dir %{ghc_html_libraries_dir}/%{pkg_name}-%{version}
# deprecates
%ghcpkgdocdir %{ghclibdocdir}/%{pkg_name}-%{version}
# top library dir
%ghclibdir %{_libdir}/ghc-%{ghc_version}
%_ghclicensedir %{?_defaultlicensedir}%{!?_defaultlicensedir:%_docdir}
# ghc_gen_filelists [name] [version]
%ghc_gen_filelists()\
%define pkgname %{?1}%{!?1:%{pkg_name}}\
%define pkgver %{?2}%{!?2:%{version}}\
%define pkgnamever %{pkgname}-%{pkgver}\
%define basepkg ghc-%{pkgname}\
%define pkgdir %{ghclibdir}/%{pkgnamever}\
%define docdir %{ghclibdocdir}/%{pkgnamever}\
rm -f %{basepkg}.files %{basepkg}-devel.files\
touch %{basepkg}.files %{basepkg}-devel.files\
if [ -d "%{buildroot}%{pkgdir}" ]; then\
echo "%dir %{pkgdir}" >> %{basepkg}.files\
%if %{undefined ghc_without_shared}\
echo "%attr(755,root,root) %{pkgdir}/libHS%{pkgnamever}-ghc%{ghc_version}.so" >> %{basepkg}.files\
%endif\
fi\
echo "%{ghclibdir}/package.conf.d/%{pkgnamever}*.conf" >> %{basepkg}-devel.files\
if [ -d "%{buildroot}%{pkgdir}" ]; then\
find %{buildroot}%{pkgdir} -mindepth 1 -type d | sed "s/^/%dir /" >> %{basepkg}-devel.files\
find %{buildroot}%{pkgdir} ! \\( -type d -o -name "libHS*.so" \\) >> %{basepkg}-devel.files\
fi\
if [ -d "%{buildroot}%{docdir}" ]; then\
echo "%{docdir}" >> %{basepkg}-devel.files\
fi\
for i in %{basepkg}.files %{basepkg}-devel.files; do\
if [ -f "$i" ]; then\
sed -i -e "s!%{buildroot}!!g" $i\
fi\
done\
%{nil}
# compiler version
%ghc_version %{!?ghc_version_override:%(ghc --numeric-version)}%{?ghc_version_override}
# create and install package.conf file
# cabal_pkg_conf [name] [version]
%cabal_pkg_conf()\
%define pkgname %{?1}%{!?1:%{pkg_name}}\
%define pkgver %{?2}%{!?2:%{version}}\
%define pkgnamever %{pkgname}-%{pkgver}\
%cabal register --gen-pkg-config\
install -D --mode=0644 %{pkgnamever}.conf %{buildroot}%{ghclibdir}/package.conf.d/%{pkgnamever}.conf\
%{nil}
# ghc_bin_build
%ghc_bin_build\
%global debug_package %{nil}\
%cabal_configure\
%cabal build
# ghc_lib_build_without_haddock [name] [version]
%ghc_lib_build_without_haddock()\
%global debug_package %{nil}\
%cabal_configure %{!?without_prof:-p} %{!?ghc_without_shared:--enable-shared} %{?pkg_name:--htmldir=%{ghclibdocdir}/%{pkg_name}-%{version}} %{?1:--docdir=%{_docdir}/ghc-%1%{!?fedora:-%2} --htmldir=%{ghclibdocdir}/%1-%2} %{!?1:--global} %{?ghc_with_lib_for_ghci:--enable-library-for-ghci}\
%cabal build\
%{nil}
# ghc_lib_build [name] [version]
%ghc_lib_build()\
%ghc_lib_build_without_haddock\
%if %{undefined without_haddock}\
%define pkgname %{?1}%{!?1:%{pkg_name}}\
%define pkgver %{?2}%{!?2:%{version}}\
if [ -f dist/build/libHS%{pkgname}-%{pkgver}.a ]; then\
%cabal haddock --html %{!?without_hscolour:%(if [ -x %{_bindir}/HsColour ]; then echo --hyperlink-source; fi)} --hoogle\
fi\
%endif\
%{nil}
# ghc_strip_dynlinked
%ghc_strip_dynlinked\
%if %{undefined __debug_package}\
find %{buildroot} -type f -exec sh -c "file {} | grep -q 'dynamically linked'" \\; -exec strip "{}" \\;\
%endif
# ghc_clear_execstack
%ghc_clear_execstack\
if [ -d "%{buildroot}%{_bindir}" -a -x "%{_bindir}/execstack" ]; then\
find %{buildroot}%{_bindir} -type f -exec sh -c "file {} | grep -q ' ELF '" \\; -exec %{_bindir}/execstack -c "{}" \\;\
fi
# install bin package
%ghc_bin_install()\
%cabal_install\
%{!?1:%ghc_strip_dynlinked}\
%{!?1:%ghc_clear_execstack}\
%{nil}
# ghc_lib_install [name] [version]
%ghc_lib_install()\
%cabal_install\
%cabal_pkg_conf\
%ghc_gen_filelists\
%{!?1:%ghc_strip_dynlinked}\
%{!?1:%ghc_clear_execstack}\
%{nil}
# ghc_fix_dynamic_rpath prog ...
%ghc_fix_dynamic_rpath()\
%if %{undefined ghc_without_dynamic}\
if ! type chrpath > /dev/null; then exit 1; fi\
PDIR=$(pwd)\
for i in %*; do\
case $i in\
/*) PROG=%{buildroot}$i ;;\
*) PROG=%{buildroot}%{_bindir}/$i ;;\
esac\
if [ -x "$PROG" ]; then\
RPATH=$(chrpath $PROG | sed -e "s@^$PROG: R.*PATH=@@")\
case $RPATH in\
*$PDIR*)\
NEWRPATH=$(echo $RPATH | sed -e "s@$PDIR/dist/build@%{ghclibdir}/%{pkg_name}-%{version}@g")\
chrpath -r $NEWRPATH $PROG\
;;\
esac\
else\
echo "%%ghc_fix_dynamic_rpath: no such file $PROG"\
exit 1\
fi\
done\
%endif\
%{nil}
%ghc_pkg_recache %{_bindir}/ghc-pkg-%{ghc_version} recache --no-user-package-db || :
# - without_hscolour, without_testsuite, and ghc_bootstrapping
# need to be set locally in the spec file
# skip prof libs, and documentation
%ghc_test\
%global without_prof 1\
%global without_haddock 1\
%global without_manual 1
# skip shared and prof libs, documentation, and testsuite
%ghc_bootstrap\
%global ghc_without_shared 1\
%global ghc_without_dynamic 1\
%ghc_test

44
macros.ghc-extra Normal file
View File

@ -0,0 +1,44 @@
# RPM Macros for packaging Haskell packages with multiple libs -*-rpm-spec-*-
# ghc_lib_subpackage [-c cdepslist] [-l licensetag] [-x] [name] [version]
%ghc_lib_subpackage(c:l:x)\
%define pkgname %{?1}%{!?1:%{pkg_name}}\
%define pkgver %{?2}%{!?2:%{version}}\
%{!-x:%{?1:%global ghc_packages_list %{?ghc_packages_list} %{pkgname}-%{pkgver}}}\
%define basepkg ghc-%{pkgname}\
%package -n %{basepkg}\
Summary: Haskell %{pkgname} library\
%{?1:Version: %{pkgver}}\
%{-l:License: %{-l*}}\
Url: http://hackage.haskell.org/package/%{pkgname}\
%{?ghc_pkg_obsoletes:Obsoletes: %(echo "%{ghc_pkg_obsoletes}" | sed -e "s/\\(ghc-[^, ]*\\)-devel/\\1/g")}\
\
%description -n %{basepkg}\
This package provides the Haskell %{pkgname} library.\
\
%package -n %{basepkg}-devel\
Summary: Haskell %{pkgname} library development files\
%{?1:Version: %{pkgver}}\
%{-l:License: %{-l*}}\
Requires(post): ghc-compiler = %{ghc_version}\
Requires(postun): ghc-compiler = %{ghc_version}\
Requires: ghc-%{pkgname}%{?_isa} = %{pkgver}-%{release}\
%{?ghc_pkg_c_deps:Requires: %{ghc_pkg_c_deps}}\
%{-c:Requires: %{-c*}}\
%{?ghc_pkg_obsoletes:Obsoletes: %{ghc_pkg_obsoletes}}\
\
%description -n %{basepkg}-devel\
This package provides the Haskell %{pkgname} library development files.\
\
%post -n %{basepkg}-devel\
%ghc_pkg_recache\
\
%postun -n %{basepkg}-devel\
%ghc_pkg_recache\
\
%files -n %{basepkg} -f %{basepkg}.files\
%{?base_doc_files:%doc %base_doc_files}\
\
%files -n %{basepkg}-devel -f %{basepkg}-devel.files\
%{?devel_doc_files:%doc %devel_doc_files}\
%{nil}

3
macros.ghc-os Normal file
View File

@ -0,0 +1,3 @@
# OS specific settings
%_ghcdocdir %{_ghclicensedir}/%{name}-%{version}