[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: dpkg: scripts/mk: add fragment to preen env



Hi!

Many thanks for your work!

> diff --git a/scripts/mk/buildenv.mk b/scripts/mk/buildenv.mk
> new file mode 100644
> index 000000000..dc6f61428
> --- /dev/null
> +++ b/scripts/mk/buildenv.mk
> @@ -0,0 +1,29 @@
> +# This Makefile fragment (since dpkg 1.22.0) sanitizes the environment
> +# variables.
> +#
> +# It unexports and undefines the following variables:
> +#
> +# POSIXLY_CORRECT
> +#
> +# And sets the following to C.UTF-8 on Debian and derivatives or C otherwose:
> +#
> +# LC_COLLATE
> +#
> +
> +dpkg_datadir = $(srcdir)/mk
> +include $(dpkg_datadir)/vendor.mk
> +
> +dpkg_reset_envvars := \
> + POSIXLY_CORRECT \
> + # EOL
> +
> +unexport $(dpkg_reset_envvars)
> +$(foreach v,$(dpkg_reset_envvars),\
> + $(eval override undefine $(v)))
> +
> +ifeq ($(call dpkg_vendor_derives_from_v1,debian),yes)
> +LC_COLLATE = C.UTF-8
> +else
> +LC_COLLATE = C
> +endif
> +export LC_COLLATE

I'd suggest adding function for "unexport/override undefine" (in order
to make it available to manual invocation) either setting
"dpkg_reset_envvars" less strict (e.g. "?=" or "+=" instead of ":=").

Anyway - thanks for replying and have a nice day!

вс, 29 янв. 2023 г. в 20:35, Guillem Jover <guillem@debian.org>:
>
> Hi!
>
> On Thu, 2023-01-05 at 08:48:59 +0300, Konstantin Demin wrote:
> > I'd like to contribute a Makefile fragment to ease env "preen".
>
> Thanks for the patch!
>
> > diff --git a/scripts/mk/env-default.mk b/scripts/mk/env-default.mk
> > new file mode 100644
> > index 00000000..54f4af30
> > --- /dev/null
> > +++ b/scripts/mk/env-default.mk
> > @@ -0,0 +1,12 @@
> > +define dpkg_flush_vars=
> > +$(foreach i,$(1),$(eval unexport $(i)))
> > +$(foreach i,$(1),$(eval override undefine $(i)))
> > +endef
> > +
> > +$(call dpkg_flush_vars, LANGUAGE LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE )
> > +$(call dpkg_flush_vars, LC_MONETARY LC_MESSAGES LC_PAPER LC_NAME LC_ADDRESS )
> > +$(call dpkg_flush_vars, LC_TELEPHONE LC_MEASUREMENT LC_IDENTIFICATION )
> > +$(call dpkg_flush_vars, POSIXLY_CORRECT )
> > +
> > +export LC_ALL :=C.UTF-8
> > +export LANG   :=C.UTF-8
>
> Related to this there was #843776, which matches my thinking on why we
> should not be globally resetting locale variables.
>
> At the time I ended up adding support for that bug report as a vendor
> setting, to be enabled explicitly via dpkg-buildpackage option. But I
> guess a make fragment file works too.
>
> So I started playing with this, and I think we should at most set
> LC_COLLATE, and perhaps remove POSIXLY_CORRECT, but given that this
> one has the potential of making packages regress on portability pushed
> upstream, I'm not sure it should be globally set?
>
> In any case what I've for now got is attached. (This would be
> targeted for dpkg 1.22.x once that opens up.)
>
> Thanks,
> Guillem



-- 
SY,
Konstantin Demin


Reply to: