Skip to content

Instantly share code, notes, and snippets.

@yuga
Last active December 10, 2015 10:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yuga/4421064 to your computer and use it in GitHub Desktop.
Save yuga/4421064 to your computer and use it in GitHub Desktop.

GHC/Haskell Platform 独自RPM作成手順

注意: あくまで独自仕様です。Fedoraなどで提供されているものとは著しく異なります。

ディレクトリ作成

mkdir -p /home/yuga/haskell/rpmbuild/BUILD
mkdir -p /home/yuga/haskell/rpmbuild/BUILDROOT
mkdir -p /home/yuga/haskell/rpmbuild/SOURCES
mkdir -p /home/yuga/haskell/rpmbuild/SPECS
mkdir -p /home/yuga/haskell/rpmbuild/SRPMS
mkdir -p /home/yuga/haskell/rpmbuild/RPMS

素材ダウンロード

curl -L -o /home/yuga/haskell/rpmbuild/SOURCES/ghc-7.4.2-x86_64-unknown-linux.tar.bz2 http://www.haskell.org/ghc/dist/7.4.2/ghc-7.4.2-x86_64-unknown-linux.tar.bz2
curl -L -o /home/yuga/haskell/rpmbuild/SOURCES/haskell-platform-2012.4.0.0.tar.gz http://lambda.haskell.org/platform/download/2012.4.0.0/haskell-platform-2012.4.0.0.tar.gz
curl -L -o /home/yuga/haskell/rpmbuild/SOURCES/haskell-platform-2012.4.0.0.install.sh.patch https://gist.github.com/raw/4421064/haskell-platform-2012.4.0.0.install.sh.patch
curl -L -o /home/yuga/haskell/rpmbuild/SPECS/ghc.spec https://gist.github.com/raw/4421064/ghc.spec
curl -L -o /home/yuga/haskell/rpmbuild/SPECS/haskell-platform.spec https://gist.github.com/raw/4421064/haskell-platform.sh

GHC(についてくるライブラリ)をビルド

rpmbuild --define="_topdir /home/yuga/haskell/rpmbuild" -ba SPECS/ghc.spec --target=x86_64

GHCをインストール

su
[password]
yum install -y RPMS/x86_64/ghc-7.4.2-1.el6.x86_64.rpm

haddockのためhscolourをインストール

curl -L -o hscolour-1.20.3.tar.gz http://hackage.haskell.org/packages/archive/hscolour/1.20.3/hscolour-1.20.3.tar.gz
tar xf hscolour-1.20.3.tar.gz
cd hscolour-1.20.3
runhaskell Setup.hs configure --prefix=/usr
runhaskell Setup.hs build
runhaskell Setup.hs haddock --hyperlink-source
runhaskell Setup.hs install
exit

Haskell Platformをビルド

rpmbuild --define="_topdir /home/yuga/haskell/rpmbuild" -ba SPECS/haskell-platform.spec --target=x86_64

Hskell Platformをインストール

su
[password]
yum install -y RPMS/x86_64/haskell-platform-2012.4.0.0-1.el6.x86_64.rpm
exit

参考

######################################################################
# settings
%define ghc_deploy /usr
######################################################################
# basic informations
Name: ghc
Version: 7.4.2
Release: 1%{?dist}
Summary: Haskell Platform
Group: Development/Languages
License: BSD
URL: http://www.haskell.org/ghc/
Source0: ghc-%{version}-%{_arch}-unknown-linux.tar.bz2
BuildRequires: coreutils,gcc,make
Requires: coreutils,gcc,make,gmp-devel
%description
The Glasgow Haskell Compiler is a state-of-the-art, open source compiler
and interactive environment for the functional language Haskell.
%changelog
#################### clean / prepare for packaging ###################
%prep
# extract %{source0}
rm -rf %_builddir/%{name}
%setup -q -n %{name}/source -c
########################### make(compile) part #######################
%build
# rpmbuild/
# BUILD/ <== %{_builddir} | BUILD_DIR
# ghc/ <== BUILD_BASE_DIR
# source/
# ghc-x.x.x <== BUILD_SRC_DIR
# environment path setting
BUILD_DIR=%_builddir
BUILD_BASE_DIR=${BUILD_DIR}/%{name}
BUILD_SRC_DIR=${BUILD_BASE_DIR}/source/%{name}-%{version}
# build ghc
PWD=`pwd`
cd ${BUILD_SRC_DIR}
#./configure --prefix=%{ghc_deploy} \
# --docdir=%{ghc_deploy}/share/doc/%{name}-%{version}
./configure \
--prefix=%{_prefix} \
--exec-prefix=%{_exec_prefix} \
--bindir=%{_bindir} \
--sbindir=%{_sbindir} \
--sysconfdir=%{_sysconfdir} \
--datadir=%{_datadir} \
--includedir=%{_includedir} \
--libdir=%{_libdir} \
--libexecdir=%{_libexecdir} \
--localstatedir=%{_localstatedir} \
--sharedstatedir=%{_sharedstatedir} \
--mandir=%{_mandir} \
--infodir=%{_infodir}
cd ${PWD}
############################## after build ###########################
%clean
rm -rf %{buildroot}
########################### packaging part ###########################
%install
# rpmbuild/
# BUILD/ <== %{_builddir} | BUILD_DIR
# ghc/ <== BUILD_BASE_DIR
# source/
# ghc-x.x.x <== BUILD_SRC_DIR
# BUILDROOT/ <== %{buildroot}
# usr/
# bin/
# lib/
# ghc-x.x.x
# share/
# doc/
# ghc-x.x.x
# man/
# environment path setting
BUILD_DIR=%_builddir
BUILD_BASE_DIR=${BUILD_DIR}/%{name}
BUILD_SRC_DIR=${BUILD_BASE_DIR}/source/%{name}-%{version}
# delete all staff left by previous session.
rm -rf %{buildroot}
# make directories into which we will place arbitrary files.
mkdir -p %{buildroot}
# copy files
make --directory=${BUILD_SRC_DIR} DESTDIR=%{buildroot} install
############################## files part ############################
%files
# /usr
# bin/
# lib/
# ghc-x.x.x
# share/
# doc/
# ghc-x.x.x
# man
%{_prefix}
%doc
diff -Naru haskell-platform-2012.4.0.0.orig/scripts/install.sh haskell-platform-2012.4.0.0/scripts/install.sh
--- haskell-platform-2012.4.0.0.orig/scripts/install.sh 2012-10-17 15:11:33.000000000 +0900
+++ haskell-platform-2012.4.0.0/scripts/install.sh 2012-12-29 11:30:04.396778227 +0900
@@ -14,40 +14,65 @@
. scripts/common.sh
install_pkg () {
- PKG=$1
+ IDX=$1
+ PKG=$2
cd "packages/${PKG}" 2> /dev/null \
|| die "The directory for the component ${PKG} is missing"
[ -x Setup ] || die "The ${PKG}/Setup script does not exist or cannot be run"
- ./Setup copy ${VERBOSE} \
- || die "Installing the ${PKG} component failed"
- ./Setup register ${VERBOSE} --gen-pkg-config="${PKG}.conf" \
- || die "Generating the registration information for the package ${PKG} failed"
+ if [ -n "${DESTDIR}" ]; then
- if [ -f ${PKG}.conf ]; then
- if test "${USER_INSTALL}" = "YES"; then
- GHC_PKG_DB="--user"
- else
- GHC_PKG_DB="--global"
- fi
- ${GHC_PKG} update ${GHC_PKG_DB} "${PKG}.conf" \
- || die "Registering the package ${PKG} failed"
+ ./Setup copy ${VERBOSE} --destdir=${DESTDIR} \
+ || die "Installing the ${PKG} component failed"
+
+ ./Setup register ${VERBOSE} --gen-pkg-config="${DESTDIR}/package.conf.d/${IDX}-${PKG}.conf" \
+ || die "Generating the registration information for the package ${PKG} failed"
+
+ else
+
+ ./Setup copy ${VERBOSE} \
+ || die "Installing the ${PKG} component failed"
+
+ ./Setup register ${VERBOSE} --gen-pkg-config="${PKG}.conf" \
+ || die "Generating the registration information for the package ${PKG} failed"
+
+ if [ -f ${PKG}.conf ]; then
+ if test "${USER_INSTALL}" = "YES"; then
+ GHC_PKG_DB="--user"
+ else
+ GHC_PKG_DB="--global"
+ fi
+ ${GHC_PKG} update ${GHC_PKG_DB} "${PKG}.conf" \
+ || die "Registering the package ${PKG} failed"
+ fi
+
+ ./Setup copy ${VERBOSE} \
+ || die "Installing the ${PKG} component failed"
+
fi
+
cd ../..
}
+if [ -f DESTDIR ]; then
+ DESTDIR=$(cat DESTDIR)
+ mkdir -p ${DESTDIR}/package.conf.d
+fi
+
# Actually do something!
+i=000
for pkg in `cat packages/platform.packages`; do
if is_pkg_installed "${pkg}"; then
true
else
echo "Installing ${pkg}..."
- install_pkg ${pkg}
+ install_pkg ${i} ${pkg}
fi
+ i=$(printf "%03d" $(expr ${i} + 1))
done
echo
######################################################################
# settings
######################################################################
# basic informations
Name: haskell-platform
Version: 2012.4.0.0
Release: 1%{?dist}
Summary: Haskell Platform
Group: Development/Languages
License: BSD
URL: http://www.haskell.org/platform/
Source0: %{name}-%{version}.tar.gz
Patch0: %{name}-%{version}.install.sh.patch
BuildArch: x86_64
BuildRequires: coreutils,gcc,make,ghc,zlib-devel
Requires: coreutils,gcc,make,gmp-devel,ghc,zlib-devel
%description
Community-supported versions of the Haskell Platform on Linux.
These distributions offer the Haskell Platform in their package repositories.
%changelog
#################### clean / prepare for packaging ###################
%prep
# extract %{source0}
rm -rf %_builddir/%{name}
%setup -q -n %{name}/source -c
# apply %{patch0}
%patch0 -p0
########################### make(compile) part #######################
%build
# rpmbuild/
# BUILD/ <== %{_builddir} | BUILD_DIR
# ghc/ <== BUILD_BASE_DIR
# source/
# haskell-platform-x.x.x <== BUILD_SRC_DIR
# environment path setting
BUILD_DIR=%_builddir
BUILD_BASE_DIR=${BUILD_DIR}/%{name}
BUILD_SRC_DIR=${BUILD_BASE_DIR}/source/%{name}-%{version}
# build ghc
PWD=`pwd`
cd ${BUILD_SRC_DIR}
./configure \
--prefix=%{_prefix}/%{name}-%{version}
make
cd ${PWD}
############################## after build ###########################
%clean
rm -rf %{buildroot}
########################### packaging part ###########################
%install
# rpmbuild/
# BUILD/ <== %{_builddir} | BUILD_DIR
# ghc/ <== BUILD_BASE_DIR
# source/
# haskell-platform-x.x.x <== BUILD_SRC_DIR
# BUILDROOT/
# haskell-platform-xxxx.x.x.elx.arch <== %{buildroot}
# pkg.conf.d/ <== PKG_CONF_DIR
# usr/ <== %{_prefix}
# bin/
# haskell-platform-xxxx.x.x <== %{name}-%{version} | DEPLOY_DIR
# bin/
# lib/
# share/
# environment path setting
BUILD_DIR=%_builddir
BUILD_BASE_DIR=${BUILD_DIR}/%{name}
BUILD_SRC_DIR=${BUILD_BASE_DIR}/source/%{name}-%{version}
DEPLOY_DIR=%{buildroot}%{_prefix}/%{name}-%{version}
PKG_CONF_DIR=%{buildroot}/package.conf.d
# delete all staff left by previous session.
rm -rf %{buildroot}
# make directories into which we will place arbitrary files.
mkdir -p %{buildroot}
mkdir -p %{buildroot}%{_prefix}/bin
mkdir -p ${PKG_CONF_DIR}
mkdir -p ${DEPLOY_DIR}/bin
# copy files
make --directory=${BUILD_SRC_DIR} DESTDIR=%{buildroot} install
# make symbolic links
mv ${PKG_CONF_DIR} ${DEPLOY_DIR}
for file in $(find ${DEPLOY_DIR}/bin -type f); do
ln -s %{_prefix}/%{name}-%{version}/bin/${file##*/} %{buildroot}%{_prefix}/bin/${file##*/}
done
############################## files part ############################
%files
# /usr/
# bin
# haskell-platform-xxxx.x.x/
# bin/
# lib/
# package.conf.d/
# share/
%{_prefix}/bin
%{_prefix}/%{name}-%{version}
%doc
########################## after install part ########################
%post
# /usr/
# haskell-platform-xxxx.x.x/
# bin/
# lib/
# package.conf.d/
# share/
for conf in $(ls %{_prefix}/%{name}-%{version}/package.conf.d/*.conf | sort); do
if test "${USER_INSTALL}" = "YES"; then
GHC_PKG_DB="--user"
else
GHC_PKG_DB="--global"
fi
ghc-pkg update ${GHC_PKG_DB} ${conf}
done
########################## before uninstall part ######################
%preun
for conf in $(ls %{_prefix}/%{name}-%{version}/package.conf.d/*.conf | sort -r); do
if test "${USER_INSTALL}" = "YES"; then
GHC_PKG_DB="--user"
else
GHC_PKG_DB="--global"
fi
a=${conf##*/}
b=${a#*-}
c=${b%.*}
ghc-pkg unregister ${GHC_PKG_DB} ${c}
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment