public inbox for debugedit@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] find-debuginfo: Check RPM environment variables are there
@ 2021-07-26 22:23 Mark Wielaard
  2021-07-26 22:32 ` Dmitry V. Levin
  0 siblings, 1 reply; 3+ messages in thread
From: Mark Wielaard @ 2021-07-26 22:23 UTC (permalink / raw)
  To: debugedit; +Cc: Mark Wielaard

find-debuginfo relies on a couple of RPM environment variables.
Ideally we provide command line arguments to set them. But they are
somewhat tied to how rpm sets things up.  So for now just warn and
exit if they aren't set.

See also https://sourceware.org/bugzilla/show_bug.cgi?id=27637

Signed-off-by: Mark Wielaard <mark@klomp.org>
---
 scripts/find-debuginfo.in | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/scripts/find-debuginfo.in b/scripts/find-debuginfo.in
index 828fd09..971218a 100755
--- a/scripts/find-debuginfo.in
+++ b/scripts/find-debuginfo.in
@@ -146,6 +146,24 @@ n_jobs=1
 # exit early on --version or --help
 done=false
 
+# Currently this scripts depends on some RPM environment variables
+# being set.  RPM_BUILD_ROOT as the installation root directory.
+# RPM_BUILD_DIR as the top build dir (usually one above BUILDDIR).
+# And RPM_PACKAGE_NAME, RPM_PACKAGE_VERSION, RPM_PACKAGE_RELEASE,
+# RPM_ARCH to create an unique (dir) name. Warn if they aren't set.
+if test -z "${RPM_BUILD_ROOT}"; then
+    echo "RPM_BUILD_ROOT not set"
+    exit 1;
+fi
+if test -z "${RPM_BUILD_DIR}"; then
+    echo "RPM_BUILD_DIR not set"
+    exit 1;
+fi
+if test -z "${RPM_PACKAGE_NAME}"; then
+    echo "RPM_PACKAGE_NAME not set"
+    exit 1;
+fi
+
 BUILDDIR=.
 out=debugfiles.list
 srcout=
-- 
2.32.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] find-debuginfo: Check RPM environment variables are there
  2021-07-26 22:23 [PATCH] find-debuginfo: Check RPM environment variables are there Mark Wielaard
@ 2021-07-26 22:32 ` Dmitry V. Levin
  2021-07-26 22:51   ` Mark Wielaard
  0 siblings, 1 reply; 3+ messages in thread
From: Dmitry V. Levin @ 2021-07-26 22:32 UTC (permalink / raw)
  To: debugedit

On Tue, Jul 27, 2021 at 12:23:11AM +0200, Mark Wielaard wrote:
> find-debuginfo relies on a couple of RPM environment variables.
> Ideally we provide command line arguments to set them. But they are
> somewhat tied to how rpm sets things up.  So for now just warn and
> exit if they aren't set.
> 
> See also https://sourceware.org/bugzilla/show_bug.cgi?id=27637
> 
> Signed-off-by: Mark Wielaard <mark@klomp.org>
> ---
>  scripts/find-debuginfo.in | 18 ++++++++++++++++++
>  1 file changed, 18 insertions(+)
> 
> diff --git a/scripts/find-debuginfo.in b/scripts/find-debuginfo.in
> index 828fd09..971218a 100755
> --- a/scripts/find-debuginfo.in
> +++ b/scripts/find-debuginfo.in
> @@ -146,6 +146,24 @@ n_jobs=1
>  # exit early on --version or --help
>  done=false
>  
> +# Currently this scripts depends on some RPM environment variables
> +# being set.  RPM_BUILD_ROOT as the installation root directory.
> +# RPM_BUILD_DIR as the top build dir (usually one above BUILDDIR).
> +# And RPM_PACKAGE_NAME, RPM_PACKAGE_VERSION, RPM_PACKAGE_RELEASE,
> +# RPM_ARCH to create an unique (dir) name. Warn if they aren't set.
> +if test -z "${RPM_BUILD_ROOT}"; then
> +    echo "RPM_BUILD_ROOT not set"
> +    exit 1;
> +fi
> +if test -z "${RPM_BUILD_DIR}"; then
> +    echo "RPM_BUILD_DIR not set"
> +    exit 1;
> +fi
> +if test -z "${RPM_PACKAGE_NAME}"; then
> +    echo "RPM_PACKAGE_NAME not set"
> +    exit 1;
> +fi

Three redundant trailing semicolons here.
How about this version instead:

for n in RPM_BUILD_ROOT RPM_BUILD_DIR RPM_PACKAGE_NAME; do
	if eval test -z \"\${$n-}\"; then
		echo >&2 "$n is not set"
		exit 1
	fi
done


-- 
ldv

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] find-debuginfo: Check RPM environment variables are there
  2021-07-26 22:32 ` Dmitry V. Levin
@ 2021-07-26 22:51   ` Mark Wielaard
  0 siblings, 0 replies; 3+ messages in thread
From: Mark Wielaard @ 2021-07-26 22:51 UTC (permalink / raw)
  To: Dmitry V. Levin; +Cc: debugedit

Hi Dmitry,

On Tue, Jul 27, 2021 at 01:32:59AM +0300, Dmitry V. Levin wrote:
> > +# Currently this scripts depends on some RPM environment variables
> > +# being set.  RPM_BUILD_ROOT as the installation root directory.
> > +# RPM_BUILD_DIR as the top build dir (usually one above BUILDDIR).
> > +# And RPM_PACKAGE_NAME, RPM_PACKAGE_VERSION, RPM_PACKAGE_RELEASE,
> > +# RPM_ARCH to create an unique (dir) name. Warn if they aren't set.
> > +if test -z "${RPM_BUILD_ROOT}"; then
> > +    echo "RPM_BUILD_ROOT not set"
> > +    exit 1;
> > +fi
> > +if test -z "${RPM_BUILD_DIR}"; then
> > +    echo "RPM_BUILD_DIR not set"
> > +    exit 1;
> > +fi
> > +if test -z "${RPM_PACKAGE_NAME}"; then
> > +    echo "RPM_PACKAGE_NAME not set"
> > +    exit 1;
> > +fi
> 
> Three redundant trailing semicolons here.
> How about this version instead:
> 
> for n in RPM_BUILD_ROOT RPM_BUILD_DIR RPM_PACKAGE_NAME; do
> 	if eval test -z \"\${$n-}\"; then
> 		echo >&2 "$n is not set"
> 		exit 1
> 	fi
> done

Much nicer. I added that. And moved the check after the option
handling. As the buildbot pointed out, this broke --help and
--version. Oops.

Double checked the new version still works as a drop-n replacement for
rpm script.

Thanks,

Mark


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-07-26 22:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-26 22:23 [PATCH] find-debuginfo: Check RPM environment variables are there Mark Wielaard
2021-07-26 22:32 ` Dmitry V. Levin
2021-07-26 22:51   ` Mark Wielaard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).