While both fedora-buildrpmtree and fedora-wipebuildtree check for the presence of %_topdir in ~/.rpmmacros, they fail to actually use any value it may contain and instead blithely assume that ~/rpmbuild is the correct directory.
Right, thanks for the catch. I am undecided what to do about this. Perhaps I'd be slightly leaning towards removing both of these scripts from the package as they fit a very specific setup currently (albeit one that fits many), deal only with %{_topdir} not taking %{_srcrpmdir} and friends into account, and it would be quite a lot of work to make them "universally" applicable. Warren, WDYT? IIRC these scripts are sort of "yours" in fedora-rpmdevtools. Maybe remove them from fedora-rpmdevtools, and provide a Wiki doc page instead.
FWIW, you can use 'rpm --showrc | grep -- "-14: _topdir" | cut -b14-' to get the current value of %_topdir.
Better to just do a "rpm --eval '%{_topdir}'", I think. But that's not the issue.
I would prefer to keep both scripts in the package with this bugfix. They are useful as both teaching tools and quick package testing/building on any box.
Created attachment 110690 [details] Patch for dirs for buildrpmtree and wipebuildtree How about this patch?
wipebuildtree: it still checks for hardcoded "rpmbuild" and "redhat" dirs and bails out in case of no match. Shouldn't all the tests from it just be removed; just go ahead and empty the %{_*dir}s? buildrpmtree: with the other changes, testing/creating/cd'ing to %{_topdir} at the end of the script doesn't seem necessary to me any more.
Created attachment 110691 [details] Revised patch for dirs for buildrpmtree and wipebuildtree Agreed on both counts. I also did a bit of terminology cleanup, hope you don't mind.
Created attachment 110693 [details] Improved version Still some comments, buildrpmtree: the 0.06 commentary is no longer accurate, as the paths are not necessarily defined in ~/.rpmmacros. $RHDIR can also be removed, it's unused. $TOPDIR and $ISTOP don't seem to add any value to the debug info. wipebuildtree: by removing the tests, I meant _removing all the tests_. Maybe it's good to keep the superuser check, or to verify that the dirs to rm -rf'd don't look like "/". Additionally, your latest patch changes things so that it will remove the actual _srcrpmdir and friends, instead of their contents. This will break setups until fedora-buildrpmtree is run again, or the dirs manually recreated. Also, I don't see why wipebuildtree should care if ~/.rpmmacros exists or not. Per-user %{_topdir} can also be defined eg. in /etc/rpm/macros. Revised patch attached, unless there are objections, I'll commit this one.
Works for me. I was just working within the context of the existing script. Except for that silly "remove the actual _srcrpmdir" thing of course.
Committed to fedora.us CVS (that's where the development tree for this package still resides). Expect a 0.3.1 release containing this fix in Extras next week. Thanks.