By default, Bugzilla does not search the list of RESOLVED bugs.
You can force it to do so by putting the upper-case word ALL in front of your search query, e.g.: ALL tdelibs
We recommend searching for bugs this way, as you may discover that your bug has already been resolved and fixed in a later release.
Bug 1776 - r14-xdg-update overwrites OnlyShowIn=KDE; in desktop files intended for KDE4
Summary: r14-xdg-update overwrites OnlyShowIn=KDE; in desktop files intended for KDE4
Status: RESOLVED FIXED
Alias: None
Product: TDE
Classification: Unclassified
Component: tdebase (show other bugs)
Version: R14.0.0 [Trinity]
Hardware: Other Linux
: P1 critical
Assignee: Slávek Banko
URL:
Depends on: 1805
Blocks:
  Show dependency treegraph
 
Reported: 2013-12-20 18:54 CST by Darrell
Modified: 2014-01-05 21:30 CST (History)
3 users (show)

See Also:
Compiler Version:
TDE Version String:
Application Version:
Application Name:


Attachments
Updated r14-xdg-update script for approval (38.08 KB, application/x-shellscript)
2014-01-01 14:06 CST, Slávek Banko
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Darrell 2013-12-20 18:54:40 CST
I've been hit by this minor bug for a long time, but not every time I built a new Trinity package set. Today I finally dug into what was happening. The bug occurs when the script variable $SCRIPT_VERSION is updated, which happened only a few days ago.

To update *.desktop files, at line 329 of the r14-xdg-update script we have the following:

xargs -r0 sed -i -e "s|X-KDE-|X-TDE-|g" -e "s|KDE;|TDE;|g"

In my $HOME/.local/share/applications directory, I have some desktop files that are only for KDE4. I sometimes toggle to KDE4 for comparative testing with Trinity. These specific desktop files populate my KDE4 menu. I have the following in those specific desktop files:

OnlyShowIn=KDE;

The sed replacement at line 329 of the r14-xdg-update script changes the desktop files to:

OnlyShowIn=TDE;

When I next start Trinity and the variable $SCRIPT_VERSION was updated, these KDE4 specific desktop files then end up in the Lost+Found section of the Trinity menu.

I then repair the desktop files only to be hammered the next time the variable $SCRIPT_VERSION was updated.

I admit this is a KDE4 corner case. I realize in Trinity releases prior to R14, having desktop files with OnlyShowIn=KDE; will normal and should be converted to TDE. I don't know how to distinguish KDE4 desktop files.

Although I am a tester and update my Trinity package set often, regular users will be hit by this same bug with each subsequent Trinity maintenance release, if they also have KDE4-specific desktop files and the r14-xdg-update script is updated between Trinity releases, which is likely to happen.

I'm adding this bug report to the R14 etherpad.
Comment 1 Darrell 2013-12-20 19:50:22 CST
Looks like the problem is not the r14-xdg-update script but the starttde script. At line 293 of starttde:

if [ "$R14_UPDATED" != "true" ] || [ "$R14_VERSION" -lt "$R14_SCRIPT" ]; then

A person already running git packages has long ago updated any existing KDE3 or Trinity 3.5.x profile to the latest R14 standards. Although we might still find a few missing items that should be added to the r14-xdg-update script, likely subsequent updates are no longer needed or desired by present git users.

The same will apply to all users who update to the official R14.0.0. Any change to the r14-xdg-update script will do exactly as I described with my intentional KDE4 desktop files.

Perhaps the test at line 293 in starttde should be changed to a logical AND:

if [ "$R14_UPDATED" != "true" ] && [ "$R14_VERSION" -lt "$R14_SCRIPT" ]; then

With this change any existing git user will always see $R14_UPDATED == true, which will stop that snippet of code from executing, even when [ $R14_VERSION -lt $R14_SCRIPT ]. Likewise, future R14.0.0 users also will no longer see any execution of the r14-xdg-update script.
Comment 2 Slávek Banko 2014-01-01 14:06:50 CST
Created attachment 1815 [details]
Updated r14-xdg-update script for approval

Note 1: Is there any idea how to tell which files is suitable for replacement X-KDE-=> X-TDE and KDE; => TDE; and which are not?

Note 2: I'm not sure if in the future will not follow any other renaming, and therefore prefer to assume that they will. I therefore propose a different modification of the script. Thanks to the mark with the script version it is possible on next run execute only the newly added rules.

Note 3: I modified the method of logging messages, so that might not always be Message_Prefix => echo. The newly prepared function Log also allows multi-line messages, where Message_Prefix is added before each line of the message.

See the attached updated script.
Comment 3 Darrell 2014-01-01 16:01:39 CST
What is significant about the date 201309150? Perhaps that date should be set at the beginning of the script as a variable with comments explaining the meaning or origin of the date?

>Is there any idea how to tell which files is suitable for replacement
>X-KDE-=> X-TDE and KDE; => TDE; and which are not?
That was the first thing I investigated after I understood what was happening. There is no dependable way using the contents of the desktop files. Yet I have considered a possible detection method.

When a user adds custom items to the launcher menu, whether in Trinity or KDE4, an associated desktop file is created. Also a custom menu is created in $HOME/.config/menus.

The related desktop files will be itemized in the user's custom menu.

At the moment, Trinity and KDE4 use the same name for the custom menu name: applications-kmenuedit.menu.

This is not good. I will open a bug report to change the name to applications-tdemenuedit.menu. I have been aware of this conflict for a long time and should have opened a bug report long ago.

In my particular use case, because I have custom menus for both Trinity and KDE4, I use a pre-login script to help me toggle between the two desktops. At the moment I name the two menus applications-kmenuedit.menu.trinity and applications-kmenuedit.menu.kde. As necessary my pre-login script copies and overwrites one or the other menu to applications-kmenuedit.menu.

Most users will have not have such an elaborate configuration. At most they will have only one custom menu: applications-kmenuedit.menu. We use that menu to detect whether desktop files should be updated in .local/applications.

When a user updates from 3.5.x to R14.0.0, there will be at most only one applications-kmenuedit.menu, if any custom menu exists. After we resolve the problem that both KDE4 and Trinity both use the custom menu name of applications-kmenuedit.menu, in r14.xdg-update we then rename applications-kmenuedit.menu to applications-tdemenuedit.menu. A one-time event.

Should any Trinity user thereafter also use KDE4 and customize the KDE4 menu, the KDE4 custom menu will be named applications-kmenuedit.menu. No conflicts with menu names but there might be conflicts with desktop files belonging to the KDE4 custom menu rather than the Trinity custom menu.

Because the custom menus now have different file names, we have r14-xdg-update grep any existing applications-tdemenuedit.menu for the existence of any desktop file found in .local/applications. When the desktop file is found in the custom menu we presume the desktop file is part of the Trinity custom menu. When the desktop file is not found in applications-tdemenuedit.menu we presume a KDE4 menu item.
Comment 4 Slávek Banko 2014-01-01 16:19:22 CST
(Odpověď na komentář #3)
> What is significant about the date 201309150? Perhaps that date should be set
> at the beginning of the script as a variable with comments explaining the
> meaning or origin of the date?
> 

The tag 201309150 is only interesting that it was the first to be used => we are unable to distinguish updates performed before this tag. Therefore, most of the conditions is with this tag.

I did not add to the file the list of used tags with comments because it would duplicate the changelog, which is available in git.

I am not sure whether to put on top of the file comment like this: "When you edit the file, be sure to update tag indicating the version. When you add more rules, use for them condition relating to the new tag." I see it as a comment to the programmer, not for the user.
Comment 5 Slávek Banko 2014-01-01 16:30:17 CST
I believe that the proposed script modification in attachment 1815 [details]
can be pushed regardless of bug 1805. What do you think?
Comment 6 Darrell 2014-01-01 16:53:12 CST
>I am not sure whether to put on top of the file comment like this:
I did not explain my self well. I meant add 201309150 as a variable at the beginning/top of the script and add a comment only about that variable. Like this:

===============================
# The variable $SCRIPT_GO_LIVE_DATE is when we first used
# this script in a production manner. Detecting changes
# performed before this date is not possible, although only
# affecting git users. The date is a script "go live"
# reference point, something like "epoch zero." :)
SCRIPT_GO_LIVE_DATE="201309150"
===============================

>I believe that the proposed script modification in attachment 1815 [details]
>can be pushed regardless of bug 1805. What do you think?
Yes, although I'd rather see 201309150 as a variable, as just described. Not critical, just nice to my eyes and thinking. :)

I am creating patches for bug 1805. I can't proceed with patching r14-xdg-update until the changes proposed here are pushed to git.
Comment 7 Darrell 2014-01-01 17:19:41 CST
Do we still need to modify starttde (refer to comment 1)?
Comment 8 Slávek Banko 2014-01-01 17:21:16 CST
(Odpověď na komentář #6)
> >I am not sure whether to put on top of the file comment like this:
> I did not explain my self well. I meant add 201309150 as a variable at the
> beginning/top of the script and add a comment only about that variable. Like
> this:
> 
> ===============================
> # The variable $SCRIPT_GO_LIVE_DATE is when we first used
> # this script in a production manner. Detecting changes
> # performed before this date is not possible, although only
> # affecting git users. The date is a script "go live"
> # reference point, something like "epoch zero." :)
> SCRIPT_GO_LIVE_DATE="201309150"
> ===============================
> 
> >I believe that the proposed script modification in attachment 1815 [details]
> >can be pushed regardless of bug 1805. What do you think?
> Yes, although I'd rather see 201309150 as a variable, as just described. Not
> critical, just nice to my eyes and thinking. :)
> 
> I am creating patches for bug 1805. I can't proceed with patching
> r14-xdg-update until the changes proposed here are pushed to git.

Using variables for a single date/tag does not seem a good idea. As you can see in the script are already used tags: 201309150, 201310050, 201310190 and 201312160. Create a variable for all used tags is nonsense. And use in some conditions variable, while in the other will be a particular tag, in such a case could be confusing.

In addition, variable gives the impression that it's something that can be changed. But that's for this variable a fundamental mistake.

I considered whether to put into the script your explanatory comment - not for the variable, but for this one specific tag. But it could then give the question, why are not comments also for other tags. And now we are back - it would be a duplication of GIT changelog.
Comment 9 Slávek Banko 2014-01-01 17:29:35 CST
(Odpověď na komentář #7)
> Do we still need to modify starttde (refer to comment 1)?

No, the change in starttde is undesirable. We should expect updates that may require repeated run of the r14-xdg-update. And script r14-xdg-update will be ready to handle only new rules.
Comment 10 Darrell 2014-01-01 18:15:21 CST
>No, the change in starttde is undesirable.
Then we'll see how the new r14-xdg-update script works.
Comment 11 Slávek Banko 2014-01-01 18:19:04 CST
(Odpověď na komentář #10)
> >No, the change in starttde is undesirable.
> Then we'll see how the new r14-xdg-update script works.

So I am going to push the proposed modification.
Comment 12 Slávek Banko 2014-01-01 18:24:05 CST
Comment on attachment 1815 [details]
Updated r14-xdg-update script for approval

Pushed to GIT in hash 30038436.
Comment 13 Darrell 2014-01-05 20:53:40 CST
After performing several tests in bug 1805 along with a revamped r14-xdg-update script, we can close this bug report as soon as all patches in bug 1805 are pushed to git.