After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 728506 - build: add AC_PROG_SED so we can define $SED
build: add AC_PROG_SED so we can define $SED
Status: RESOLVED FIXED
Product: gcr
Classification: Core
Component: General
3.12.x
Other OpenBSD
: Normal normal
: ---
Assigned To: GNOME keyring maintainer(s)
GNOME keyring maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2014-04-18 14:42 UTC by Antoine Jacoutot
Modified: 2019-02-22 11:58 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
add and use AC_PROG_SED (1.67 KB, patch)
2014-04-18 14:42 UTC, Antoine Jacoutot
none Details | Review
don't use non-portable sed -i shell command (2.87 KB, patch)
2014-04-19 15:32 UTC, Antoine Jacoutot
needs-work Details | Review
don't use non-portable sed -i shell command v2 (1.81 KB, patch)
2014-05-21 10:50 UTC, Antoine Jacoutot
committed Details | Review

Description Antoine Jacoutot 2014-04-18 14:42:23 UTC
Created attachment 274677 [details] [review]
add and use AC_PROG_SED

Hi.

Under at least OpenBSD and NetBSD, sed(1) does not support the `-i'
switch for inplace editing, but we can force them to use GNU sed by
setting SED to "gsed".
Comment 1 Allison Karlitskaya (desrt) 2014-04-19 11:49:22 UTC
In the past we've tried to work around these issues by removing the use of -i.  It's almost always unsafe when used in a Makefile anyway...

The typical idiom (as here) of:

  somecmd -o out
  sed -i .... out

is better replaced with

  somecmd -o out.tmp &&
    sed ... < out.tmp > out.tmp2 &&
    mv out.tmp2 out &&
    rm -f out.tmp out.tmp2

owing to the fact that with this approach, a failure part way through won't leave half-baked files around.
Comment 2 Antoine Jacoutot 2014-04-19 15:32:28 UTC
Created attachment 274731 [details] [review]
don't use non-portable sed -i shell command

Hi Ryan. Something like that maybe?
Comment 3 Antoine Jacoutot 2014-04-27 06:41:32 UTC
Hi Ryan. Any feedback?
Thanks.
Comment 4 Allison Karlitskaya (desrt) 2014-04-28 05:21:50 UTC
Review of attachment 274731 [details] [review]:

Please separate the unrelated cleanups to a separate patch.

It's not really my place to approve patches to this module...

::: gcr/Makefile.am
@@ +164,3 @@
+	$(AM_V_GEN) sed -e 's/gcr_dbus/_gcr_dbus/g' \
+		-e 's/temp-dbus-generated.h/gcr-dbus-generated.h/g' \
+		gcr/temp-dbus-generated.c > gcr/gcr-dbus-generated.c

This still doesn't follow the 'atomic' pattern of using mv to put the file in place only after it has been completely successfully created.

I wouldn't worry about splitting the 'temp' part out to a separate rule.  Just do it all as one shell fragment.
Comment 5 Antoine Jacoutot 2014-04-28 06:27:40 UTC
Hi Ryan.

> Please separate the unrelated cleanups to a separate patch.

What do you mean by unrelated?
These files must be cleaned because of this patch no?

> It's not really my place to approve patches to this module...
> 
> ::: gcr/Makefile.am
> @@ +164,3 @@
> +    $(AM_V_GEN) sed -e 's/gcr_dbus/_gcr_dbus/g' \
> +        -e 's/temp-dbus-generated.h/gcr-dbus-generated.h/g' \
> +        gcr/temp-dbus-generated.c > gcr/gcr-dbus-generated.c
> 
> This still doesn't follow the 'atomic' pattern of using mv to put the file in
> place only after it has been completely successfully created.
> 
> I wouldn't worry about splitting the 'temp' part out to a separate rule.  Just
> do it all as one shell fragment.

Well I really tried to match your libsecret commit
https://git.gnome.org/browse/libsecret/commit/?id=8d297361de86da651bf9caf809cf3f778cfad10e
because you told me about it; so the 'sed -e' line is similar and so is the temp part..
If there is something I missed, please amend the patch, it will be simpler.
Thanks.
Comment 6 Antoine Jacoutot 2014-05-21 07:41:01 UTC
Hi guys. Any other input on this sed patch?
Thanks.
Comment 7 Stef Walter 2014-05-21 08:56:30 UTC
Here's how the atomic pattern works:

sed ... > $(OUT).tmp && mv $(OUT).tmp $(OUT)

Obviously replace $(OUT) with the variable or literal of the output file name.

I agree with Ryan, that change would be good before we commit this patch.
Comment 8 Antoine Jacoutot 2014-05-21 10:50:10 UTC
Created attachment 276926 [details] [review]
don't use non-portable sed -i shell command v2

Hopefully this is what you guys had in mind...
Comment 9 Stef Walter 2014-05-21 11:01:23 UTC
Thanks. Pushed to git master.