topdir macro

Elan Ruusamäe glen at pld-linux.org
Tue May 12 09:18:12 CEST 2009


On Tuesday 12 May 2009 09:57, Adam Gołębiowski wrote:
> As for now, it looks like that builder supports packages/ layout while
> rpmbuild the old one. It is not a perfect solution (some magic to detect
> the layout would be nice), but better than no support for
> ~/rpm/{SPECS,SOURCES}/ .

here's my (current) ~/.rpmmacros, which allows you ~/rpm/SPECS, ~/rpm/something/SPECS, ~/rpm/packages/%{name}, ~/rpm/something/%{name} layouts
there could be bugs, but the description matches the goal. likely the ~/rpm/SPECS needs more changes to builder script

# topdir is where builder script lives, fallback to old style if builder script was not found and
# SPECS/SOURCES dirs exist (XXX: should be reverse?)
%_topdir    %{expand:%%global _topdir %(d=;\
    d=${d:-$([ -x builder -a ! -L builder ] && pwd)};\
    d=${d:-$([ -x ../builder -a ! -L ../builder ] && (cd ..; pwd))};\
    d=${d:-$([ -d ../SPECS -a -d ../SOURCES ] && (cd .. && pwd))};\
    echo ${d:-$HOME/rpm};\
)}%_topdir

%_specdir       %{_topdir}/%{name}
%_sourcedir     %{_specdir}

# BUILD/RPMS/SRPMS are one same level by default as packages dir, if these exist
# if they don't exist assume we are having custom topdir (which is not named as
# "packages", i.e ~/rpm/kde/{kdelibs,BUILD/RPMS/SRPMS})
%_builddir      %{expand:%%global _builddir %([ -d %{_topdir}/../BUILD ] && (cd %{_topdir}/../BUILD; pwd) || echo %{_topdir}/BUILD)}%_builddir
%_rpmdir        %{expand:%%global _rpmdir %([ -d %{_topdir}/../RPMS ] && (cd %{_topdir}/../RPMS; pwd) || echo %{_topdir}/RPMS)}%_rpmdir
%_srcrpmdir     %{expand:%%global _srcrpmdir %([ -d %{_topdir}/../SRPMS ] && (cd %{_topdir}/../SRPMS; pwd) || echo %{_topdir}/SRPMS)}%_srcrpmdir

requires such changes to buider too:

diff -u -r1.582 builder
--- builder     8 May 2009 11:02:54 -0000       1.582
+++ builder     12 May 2009 07:14:36 -0000
@@ -659,8 +660,8 @@

        if [ "$NOINIT" != "yes" ] ; then
                TOP_DIR=$(eval $RPM $RPMOPTS --eval '%{_topdir}')
-               REPO_DIR=$TOP_DIR/packages
-               PACKAGE_DIR=$TOP_DIR/packages/$ASSUMED_NAME
+               REPO_DIR=$TOP_DIR
+               PACKAGE_DIR=$REPO_DIR/$ASSUMED_NAME
        else
                REPO_DIR="."
                PACKAGE_DIR="."


-- 
glen


More information about the pld-devel-en mailing list