:: Re: [DNG] netman-autostart_0.1.1
トップ ページ
このメッセージを削除
このメッセージに返信
著者: Edward Bartolo
日付:  
To: Rainer Weikusat
CC: dng
題目: Re: [DNG] netman-autostart_0.1.1
Hi Rainer, Aitor and All,

netman-gui.postinst now is debugged to behave properly when
dpkg-reconfigure is used on netman-gui.

sed is still adding an unneccessary leading space in lines Exec= and
Comment= in both .desktop files.

I was suggested to drop one of the .desktop files and use a symlink
instead. I think this is a good idea, but I have been coding for 10
hours 30 minutes now, so it is time for me to go to sleep.

Edward

On 06/01/2016, Rainer Weikusat <rainerweikusat@???> wrote:
> Edward Bartolo <edbarx@???> writes:
>> Enjoy yourself, I am working on it. I think, I got a way of putting it
>> right. There are two .desktop files that control how netman gui
>> behaves:
>> a) /etc/xdg/autostart/netman.desktop
>> b) /usr/share/applications/netman.desktop
>>
>> The netman-gui.postinst script has to modify both of them.
>
> In this case, you shouldn't copy the file but create a symlink to
> it. This means there's only one copy which has to be modified.
>
> [...]
>
>> The sed command in the postinst script also has to
>> make sure no multiple Exec= and Comment= lines are added to both
>> .desktop files.
>
> sed is generally the wrong choice for editing files (as it's the 'stream
> editor'). ed can be used for that (needs to become a package dependency
> as 'certain people in the Debian project' were hit by a pine at a
> formative age and are thus opposed to using sensibly-working text
> editors).
>
> The following shell function should be sufficient for your use-case
>
> -------
> change_line()
> {
>     file="$1"
>     new="`echo $2 | sed 's/\(.\)/\\\\\1/g'`"
>     key=`expr "$2" : "\([^=]\+=\)."`
>     ed "$file" <<EOF
> /^$key/s/.*/$new
> wq
> EOF
> }
> -------

>
> This takes a file as first argument and the new line as second
> argument. If a line with the same 'keyword' (text before the first =)
> already exists, it's replaced. Otherwise, nothing happens.
>
> NB: Like all shell code (or most), this won't work with 'suitably
> crafted input'. But shell programming is an exercise in inventing 'good
> enough' solutions for fairly well-defined problems.
> _______________________________________________
> Dng mailing list
> Dng@???
> https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng
>