* [PATCH] cpupower: add checks for xgettext and msgfmt
@ 2024-10-15 16:38 Siddharth Menon
2024-10-15 17:49 ` John B. Wyatt IV
0 siblings, 1 reply; 4+ messages in thread
From: Siddharth Menon @ 2024-10-15 16:38 UTC (permalink / raw)
To: shuah, trenn, jwyatt, jkacur; +Cc: Siddharth Menon, linux-pm
Check whether xgettext and msgfmt are available on the system before
attempting to generate the .pot and .gmo files and generate.
In case of missing dependency, generate error message directing user
to install the necessary package.
Signed-off-by: Siddharth Menon <simeddon@gmail.com>
---
tools/power/cpupower/Makefile | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/tools/power/cpupower/Makefile b/tools/power/cpupower/Makefile
index 6c02f401069e..38e7daacecf4 100644
--- a/tools/power/cpupower/Makefile
+++ b/tools/power/cpupower/Makefile
@@ -220,12 +220,20 @@ endif
$(OUTPUT)po/$(PACKAGE).pot: $(UTIL_SRC)
$(ECHO) " GETTEXT " $@
- $(QUIET) xgettext --default-domain=$(PACKAGE) --add-comments \
- --keyword=_ --keyword=N_ $(UTIL_SRC) -p $(@D) -o $(@F)
+ $(QUIET) if ! command -v xgettext > /dev/null; then \
+ echo "Error: gettext not found. Please install gettext."; \
+ else \
+ xgettext --default-domain=$(PACKAGE) --add-comments \
+ --keyword=_ --keyword=N_ $(UTIL_SRC) -p $(@D) -o $(@F); \
+ fi
$(OUTPUT)po/%.gmo: po/%.po
$(ECHO) " MSGFMT " $@
- $(QUIET) msgfmt -o $@ po/$*.po
+ $(QUIET) if ! command -v msgfmt > /dev/null; then \
+ echo "Error: msgfmt not found. Make sure gettext is set up correctly."; \
+ else \
+ msgfmt -o $@ po/$*.po; \
+ fi
create-gmo: ${GMO_FILES}
--
2.39.5
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] cpupower: add checks for xgettext and msgfmt
2024-10-15 16:38 [PATCH] cpupower: add checks for xgettext and msgfmt Siddharth Menon
@ 2024-10-15 17:49 ` John B. Wyatt IV
2024-10-15 21:55 ` Sid
0 siblings, 1 reply; 4+ messages in thread
From: John B. Wyatt IV @ 2024-10-15 17:49 UTC (permalink / raw)
To: Siddharth Menon; +Cc: shuah, trenn, jkacur, linux-pm
On Tue, Oct 15, 2024 at 10:08:54PM +0530, Siddharth Menon wrote:
> Check whether xgettext and msgfmt are available on the system before
> attempting to generate the .pot and .gmo files and generate.
> In case of missing dependency, generate error message directing user
> to install the necessary package.
Thank you for your patch. Tried a quick few tests by running `make` without
gettext installed.
> $(OUTPUT)po/$(PACKAGE).pot: $(UTIL_SRC)
> $(ECHO) " GETTEXT " $@
> - $(QUIET) xgettext --default-domain=$(PACKAGE) --add-comments \
> - --keyword=_ --keyword=N_ $(UTIL_SRC) -p $(@D) -o $(@F)
> + $(QUIET) if ! command -v xgettext > /dev/null; then \
> + echo "Error: gettext not found. Please install gettext."; \
> + else \
> + xgettext --default-domain=$(PACKAGE) --add-comments \
> + --keyword=_ --keyword=N_ $(UTIL_SRC) -p $(@D) -o $(@F); \
> + fi
I tested this on a Fedora 40 server. I was not able to get this message to
print despite xgettext not being in the path.
>
> $(OUTPUT)po/%.gmo: po/%.po
> $(ECHO) " MSGFMT " $@
> - $(QUIET) msgfmt -o $@ po/$*.po
> + $(QUIET) if ! command -v msgfmt > /dev/null; then \
> + echo "Error: msgfmt not found. Make sure gettext is set up correctly."; \
> + else \
> + msgfmt -o $@ po/$*.po; \
> + fi
I was able to get this to print without the gettext pkg being installed
and it did not print with it installed. This ran fine.
--
Sincerely,
John Wyatt
Software Engineer, Core Kernel
Red Hat
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] cpupower: add checks for xgettext and msgfmt
2024-10-15 17:49 ` John B. Wyatt IV
@ 2024-10-15 21:55 ` Sid
2024-10-15 22:16 ` Shuah Khan
0 siblings, 1 reply; 4+ messages in thread
From: Sid @ 2024-10-15 21:55 UTC (permalink / raw)
To: John B. Wyatt IV; +Cc: shuah, trenn, jkacur, linux-pm
On Tue, 15 Oct 2024 at 23:19, John B. Wyatt IV <jwyatt@redhat.com> wrote:
>
> I tested this on a Fedora 40 server. I was not able to get this message to
> print despite xgettext not being in the path.
Thank you for testing out my patch. The .pot file for cpupower is required
in order to enter this code block.
Should I send in another patch to generate cpupower.pot in the makefile
itself?
Resending my previous response as I accidentally left text-only mode
disabled.
--
Sincerely,
Siddharth Menon
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] cpupower: add checks for xgettext and msgfmt
2024-10-15 21:55 ` Sid
@ 2024-10-15 22:16 ` Shuah Khan
0 siblings, 0 replies; 4+ messages in thread
From: Shuah Khan @ 2024-10-15 22:16 UTC (permalink / raw)
To: Sid, John B. Wyatt IV; +Cc: shuah, trenn, jkacur, linux-pm, Shuah Khan
On 10/15/24 15:55, Sid wrote:
> On Tue, 15 Oct 2024 at 23:19, John B. Wyatt IV <jwyatt@redhat.com> wrote:
>>
>> I tested this on a Fedora 40 server. I was not able to get this message to
>> print despite xgettext not being in the path.
> Thank you for testing out my patch. The .pot file for cpupower is required
> in order to enter this code block.
>
> Should I send in another patch to generate cpupower.pot in the makefile
> itself?
>
> Resending my previous response as I accidentally left text-only mode
> disabled.
>
As mentioned earlier multiple error messages clutter the output.
How about the following simpler fix:
===========================================================================
diff --git a/tools/power/cpupower/Makefile b/tools/power/cpupower/Makefile
index 6c02f401069e..d1171385b552 100644
--- a/tools/power/cpupower/Makefile
+++ b/tools/power/cpupower/Makefile
@@ -218,17 +218,28 @@ else
endif
$(QUIET) $(STRIPCMD) $@
+ifeq (, $(shell which xgettext))
+$(warning "Install xgettext to generate GNU gettext Language Translations")
+else
$(OUTPUT)po/$(PACKAGE).pot: $(UTIL_SRC)
$(ECHO) " GETTEXT " $@
$(QUIET) xgettext --default-domain=$(PACKAGE) --add-comments \
--keyword=_ --keyword=N_ $(UTIL_SRC) -p $(@D) -o $(@F)
+endif
+ifeq (, $(shell which msgfmt))
+$(warning "Install msgfmt to generate GNU gettext Language Translations")
+else
$(OUTPUT)po/%.gmo: po/%.po
$(ECHO) " MSGFMT " $@
$(QUIET) msgfmt -o $@ po/$*.po
+endif
create-gmo: ${GMO_FILES}
+ifeq (, $(shell which msgmerge))
+$(warning "Install msgmerge to generate GNU gettext Language Translations")
+else
update-po: $(OUTPUT)po/$(PACKAGE).pot
$(ECHO) " MSGMRG " $@
$(QUIET) @for HLANG in $(LANGUAGES); do \
@@ -241,6 +252,7 @@ update-po: $(OUTPUT)po/$(PACKAGE).pot
rm -f $(OUTPUT)po/$$HLANG.new.po; \
fi; \
done;
+endif
compile-bench: $(OUTPUT)libcpupower.so.$(LIB_MAJ)
@V=$(V) confdir=$(confdir) $(MAKE) -C bench O=$(OUTPUT)
===========================================================================
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-10-15 22:16 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-15 16:38 [PATCH] cpupower: add checks for xgettext and msgfmt Siddharth Menon
2024-10-15 17:49 ` John B. Wyatt IV
2024-10-15 21:55 ` Sid
2024-10-15 22:16 ` Shuah Khan
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 NNTP newsgroup(s).