[PATCH 3/3] find-debuginfo: Add -O/--output-dir switch
Mark Wielaard
mark@klomp.org
Wed Jan 14 22:50:31 GMT 2026
Hi Michal,
On Wed, Oct 29, 2025 at 04:11:55PM +0100, Michal Domonkos via Debugedit wrote:
> Originally, as it seems, the meaning of the builddir argument was that
> of an *output* directory (for the list files), since that's all it was
> used for. The actual *build* directory is pointed to by $RPM_BUILD_DIR.
>
> However, since commit a8c7efeae67856e144897efb7c40516588b811ee, we have
> been passing the builddir argument to "debugedit --base-dir" when unique
> dirs are requested, effectively making the argument live up to its name.
That was my commit from 2017... I doubt I thought about this
implication back then.
> Thus, the output directory currently equals the builddir and cannot be
> set independently when needed. Fix that by adding a new switch to allow
> just that.
>
> This switch will be useful in RPM's %{__find_debuginfo} macro where we
> can prevent "rpmbuild --build-in-place" from polluting the source tree
> (since builddir points to $PWD in that mode).
>
> Use -p and -o in the included test to also cover that code path.
O, nice. That is what I was worried about in the previous test.
> Signed-off-by: Michal Domonkos <mdomonko@redhat.com>
> ---
> scripts/find-debuginfo.in | 13 ++++++++++++-
> tests/find-debuginfo.at | 26 ++++++++++++++++++++++++++
> 2 files changed, 38 insertions(+), 1 deletion(-)
>
> diff --git a/scripts/find-debuginfo.in b/scripts/find-debuginfo.in
> index 8bb688a..d061630 100755
> --- a/scripts/find-debuginfo.in
> +++ b/scripts/find-debuginfo.in
> @@ -33,6 +33,7 @@ Options:
> [-j N] [--jobs N]
> [-o debugfiles.list]
> [-S debugsourcefiles.list]
> +[-O PATH] [--output-dir PATH]
> [--run-dwz] [--dwz-low-mem-die-limit N]
> [--dwz-max-die-limit N]
> [--dwz-single-file-mode]
> @@ -74,6 +75,10 @@ the -l filelist file, or whose names match the -p pattern.
> The -p argument is an grep -E -style regexp matching the a file name,
> and must not use anchors (^ or $).
>
> +The -O or --output-dir PATH flag instructs find-debuginfo to store all output
> +files in the PATH directory. If not given, all output files will be stored in
> +builddir.
> +
Thank for documenting. Now this is also covered in the man page.
> The --run-dwz flag instructs find-debuginfo to run the dwz utility
> if available, and --dwz-low-mem-die-limit and --dwz-max-die-limit
> provide detailed limits. See dwz(1) -l and -L option for details.
> @@ -183,6 +188,7 @@ fi
>
>
> BUILDDIR=.
> +OUTDIR=
> out=debugfiles.list
> srcout=
> nout=0
> @@ -241,6 +247,10 @@ while [ $# -gt 0 ]; do
> fi
> shift
> ;;
> + -O|--output-dir)
> + OUTDIR=$2
> + shift
> + ;;
> -l)
> lists[$nout]="${lists[$nout]} $2"
> shift
> @@ -330,7 +340,7 @@ fi
>
> $quiet || echo "find-debuginfo: starting" 2>&1
>
> -OUTDIR=$BUILDDIR
> +[ -z "$OUTDIR" ] && OUTDIR=$BUILDDIR
OK. -O sets OUTDIR, otherwise OUTDIR is BUILDDIR.
>
> i=0
> while ((i < nout)); do
> @@ -348,6 +358,7 @@ SOURCEFILE="$OUTDIR/debugsources.list"
> LINKSFILE="$OUTDIR/debuglinks.list"
> ELFBINSFILE="$OUTDIR/elfbins.list"
>
> +mkdir -p "$OUTDIR"
OK. OUTDIR doesn't have to exist yet.
> > "$SOURCEFILE"
> > "$LISTFILE"
> > "$LINKSFILE"
> diff --git a/tests/find-debuginfo.at b/tests/find-debuginfo.at
> index 834f1af..59c15b9 100644
> --- a/tests/find-debuginfo.at
> +++ b/tests/find-debuginfo.at
> @@ -428,3 +428,29 @@ AT_CHECK([env RPM_BUILD_DIR=${PWD} \
> # Check builddir against the snapshot
> AT_CHECK([ls subdir_build | sort], [0], [expout], [])
> AT_CLEANUP
> +
> +# Run find-debuginfo on a small build and check all output files (and only
> +# those) were created in the supplied output directory
> +AT_SETUP([find-debuginfo output files (custom dir)])
> +AT_KEYWORDS([find-debuginfo] [sources] [debugdata] [gdb-index])
Same as previously, lets just use [find-debuginfo] and [output] as
keywords.
> +FIND_DEBUGINFO_PKG_BUILD_SETUP
> +# Make a snapshot of builddir
> +AT_CHECK([ls subdir_build | sort > expout], [0], [], [])
OK "snapshot" builddir.
> +# We need to set some environment variables for running find-debuginfo
> +# normally set by rpmbuild.
> +AT_CHECK([env RPM_BUILD_DIR=${PWD} \
> + RPM_BUILD_ROOT=${PWD} \
> + RPM_PACKAGE_NAME=pkg \
> + RPM_PACKAGE_VERSION=ver \
> + RPM_PACKAGE_RELEASE=rel \
> + RPM_ARCH=arch \
> + find-debuginfo -p '.*' -o allfiles.list \
> + -O ${PWD}/output ${PWD}/subdir_build],
> + [0], [ignore], [])
Both -O and -o used (after -p so should create a new output file).
> +# Check builddir against the snapshot
> +AT_CHECK([ls subdir_build | sort], [0], [expout], [])
OK, shouldn't have changed.
> +# Check the output directory against the expected list
> +AT_CHECK([(echo allfiles.list; echo "FIND_DEBUGINFO_OUTPUT_FILES") |
> + sort > expout], [0], [], [])
> +AT_CHECK([ls output | sort], [0], [expout], [])
OK, should now contain all expected files.
> +AT_CLEANUP
Looks good.
Thanks,
Mark
More information about the Debugedit
mailing list