Skip to content

Instantly share code, notes, and snippets.

Created December 8, 2013 23:40
Show Gist options
  • Save hercynium/7865220 to your computer and use it in GitHub Desktop.
Save hercynium/7865220 to your computer and use it in GitHub Desktop.
RPM .spec file for building a specific version of perl to install under /opt
# This is a simple script to allow someone on an RPM-based
# system to build the custom opt-perl package defined by
# the RPM specfile in this same directory.
# @author: Stephen R. Scaffidi <>
# @date: Oct. 2012
# abort on any error
set -e
SCRIPTDIR=$(dirname $0)
if [[ "$(whoami)" == "root" ]]; then
echo "Please don't build RPMs as root!"
echo "Run this script as a normal user."
exit 1
# make sure we have the tools we need to build RPMs
if ! which rpmdev-setuptree &> /dev/null; then
echo "You need to install the rpmdevtools package."
echo "To do so automatically, please enter your password for sudo."
sudo yum -y install rpmdevtools
# create an RPM build tree
# download the perl source into the proper place in the build-tree
spectool --get-files -R "$SCRIPTDIR/opt-perl.spec"
# ask the RPM system where certain build-dirs will be
RPMDIR=$(rpm --eval "%{_rpmdir}")
SPECDIR=$(rpm --eval "%{_specdir}")
# copy the specfile into the build tree
# finally, build the rpm!
echo "Building the RPM, please wait..."
rpmbuild --quiet -ba "$SPECDIR/$SPECNAME"
echo "Your new perl RPM should be under $RPMDIR"
echo "Please ignore any debuginfo packages that are there."
%define perlver 5.16.1
%define perlname perl-%{perlver}
Name: opt-%{perlname}
Version: 1
Release: ta
Summary: Practical Extraction and Report Language - under /opt
Group: misc
License: GPLv1+
BuildRoot: %{_tmppath}/%{perlname}-%{release}-root-%(%{__id_u} -n)
AutoReq: no
AutoProv: no
# this is necessary to prevent the scanning for rpaths in built libs
%undefine __arch_install_post
A recent stable version of perl, installed under /opt
%setup -q -n %{perlname}
./Configure -des -DEBUGGING=none -Duserelocatableinc -Dprefix=/opt/%{perlname}
%__make -j3
#make test
rm -rf %{buildroot}
%__make install DESTDIR=%{buildroot}
chmod -R u+w %{buildroot}/*
rm -rf %{buildroot}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment