Development/Tasks/Packaging/Tools/rpmmacros
From Mandriva Community Wiki
# This .rpmmacros is set up so that you can just configure the
# parameters below, and then by default you will have official
# mandrake releases (default), PLF releases (plf) and your own RPMs
# kept seperately.
#
# To make your own RPMS (with your name as vendor and your own rpm extension)
# run 'rpm --eval %_my_ext' to see what it is. Use that output as the
# suffix to the release number (ie 1myext instead of 1mdk), and the rest will
# be done automatically. If you want to customise the extension (say myext),
# replace the line starting with %_my_ext with:
# %_my_ext myext
# Otherwise, the first 3 letters of your username will be used
#
# The directory structure is by default like this:
# ~/rpm/{tmp,BUILD,SOURCES}
# ~/rpm/mdk/{SRPMS.$REL,RPMS.$REL/{i586,noarch},SPECS.$REL}
# ~/rpm/plf/{src,$REL/{i586,noarch},SPECS}
# ~/rpm/%_my_ext/{SRPMS.$REL,RPMS.$REL/{i586,noarch},SPECS.$REL}
#
# A macro has been added though to check if the directories exist, and if they
# do not exist, they will be made for you.
# These you should configure for yourself, but defaults should be reasonable
%_my_homedir %(echo $HOME)
# Where scripts are found (like find-requires-nonvidia)
%_my_bindir %{_my_homedir}/bin
# %_my_rpmdir %{_my_homedir}/rpm
%_my_rpmdir /home/bgmilne/rpm.test
# Use the comment field of the passwd entry as name:
%_my_name %(getent passwd $USER|awk -F: '{print $5}')
# Use this if you workstation has working mail:
%_my_mail %(echo $USER@`hostname`)
# Or use your real email address:
# %_my_mail user@domain.com
# Use this if your machines have working mail for their domain:
# %_my_mail %(echo $USER@`hostname -d`)
# If you have a Mandrake account, assume it's with the same username:
# %_mdk_mail %(echo $USER@linux-mandrake.com)
# Otherwise, use _my_mail
%_mdk_mail %_my_mail
%_plf_mail %_my_mail
%_my_ext %(echo $USER|cut -b1-3)
# Check for optional script to avoid false NVidia requires:
# If you use the NVidia binary drivers, you should make a script
# ~/bin/find-requires-nonvidia that contains this (remove the "# "'s)
# #!/bin/bash
# /usr/lib/rpm/find-requires $@|sed "s/libGLcore.so.1//g"
%__find_requires_path %(if [ -x %{_my_bindir}/find-requires-nonvidia ];then echo %{_my_bindir}/find-requires-nonvidia;else echo /usr/lib/rpm/find-requires;fi)
# You should not need to change anything below this line
%_mdk_vendor MandrakeSoft
%_plf_ext plf
%_plf_vendor Penguin Liberation Front
%_target linux
%vendor %(echo %release | awk --source '{v = "%_mdk_vendor"} /plf$/ { v = "%_plf_vendor" } /%_my_ext$/ { v = "%_my_realname" } { print v}')
%distro_rel %(awk '{print $4}' /etc/mandrake-release)
%distro mdk%{distro_rel}
# Macro to test existence of build directories:
%chkdir() %( [ -d %{1} ]||mkdir -p %{1}; [ -w %{1} ] && echo %{1})
# Define pseudo directories, we will test for them later
%__topdir %(echo %release | awk '{v = "%{_my_rpmdir}/mdk"} /plf$/ { v = "%{_my_rpmdir}/%{_plf_ext}" } /%{_my_ext}$/ { v = "%{_my_rpmdir}/%{_my_ext}" } { print v}')
%__rpmdir %(echo %release | awk '{v = "%_topdir/RPMS.%distro"} /plf$/ { v = "%_topdir/%distro_rel" } { print v}')
%__srcrpmdir %(echo %release | awk '{v = "%_topdir/SRPMS.%distro"} /plf$/ { v = "%_topdir/src" } { print v}')
# Have only one directory of each of these:
%__tmppath %{_my_rpmdir}/tmp
%__builddir %{_my_rpmdir}/BUILD
%__sourcedir %{_my_rpmdir}/SOURCES
%_topdir %chkdir %__topdir
%_rpmdir %chkdir %__rpmdir
%_srcrpmdir %chkdir %__srcrpmdir
%_tmppath %chkdir %__tmppath
%_builddir %chkdir %__builddir
%_sourcedir %chkdir %__sourcedir
%packager %(echo %release | awk '{v = "%{_my_name} <%{_my_mail}>"} /mdk$/ { v = "%{_my_name} <%{_mdk_mail}>" } { print v}')
%_signature gpg
%_gpg_name %{_my_name}
%_gpg_path ~/.gnupg
%distribution Mandrake Linux
%__find_requires %__find_requires_path %{?buildroot:%{buildroot}} %{?_target_cpu:%{_target_cpu}}

