commit update-desktop-files for openSUSE:Factory
Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package update-desktop-files for openSUSE:Factory checked in at 2024-10-29 14:31:52 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/update-desktop-files (Old) and /work/SRC/openSUSE:Factory/.update-desktop-files.new.2020 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "update-desktop-files" Tue Oct 29 14:31:52 2024 rev:105 rq:1218774 version:84.87 Changes: -------- --- /work/SRC/openSUSE:Factory/update-desktop-files/update-desktop-files.changes 2022-12-09 13:16:38.322637603 +0100 +++ /work/SRC/openSUSE:Factory/.update-desktop-files.new.2020/update-desktop-files.changes 2024-10-29 14:31:58.921639764 +0100 @@ -1,0 +2,7 @@ +Sat Oct 26 23:46:25 UTC 2024 - Stanislav Brabec <sbrabec@suse.com> + +- Generate files that allow easy upstreaming. (boo#1158957) +- Embed SUSE translations to the desktop file + (add suse_update_desktop_file_process_translations.py). + +------------------------------------------------------------------- New: ---- suse_update_desktop_file_process_translations.py ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ update-desktop-files.spec ++++++ --- /var/tmp/diff_new_pack.zOJIVd/_old 2024-10-29 14:32:02.233777236 +0100 +++ /var/tmp/diff_new_pack.zOJIVd/_new 2024-10-29 14:32:02.237777402 +0100 @@ -1,7 +1,7 @@ # # spec file for package update-desktop-files # -# Copyright (c) 2022 SUSE LLC +# Copyright (c) 2024 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -27,10 +27,14 @@ Source1: map-desktop-category.sh Source2: macro Source4: brp-trim-translations.sh +Source5: suse_update_desktop_file_process_translations.py # This is not true technically, but we do that to make the rpm macros from # desktop-file-utils available to most packages that ship a .desktop file # (since they already have a update-desktop-files BuildRequires). Requires: desktop-file-utils +Requires: desktop-translations-devel +Requires: gettext-tools +Requires: intltool BuildArch: noarch %description @@ -72,7 +76,7 @@ %install mkdir -p $RPM_BUILD_ROOT%_rpmconfigdir -install -m0755 %SOURCE0 %SOURCE1 $RPM_BUILD_ROOT%_rpmconfigdir +install -m0755 %SOURCE0 %SOURCE1 %SOURCE5 $RPM_BUILD_ROOT%_rpmconfigdir install -m0644 -D %SOURCE2 $RPM_BUILD_ROOT%_rpmmacrodir/macros.%name install -m0755 -D %SOURCE4 $RPM_BUILD_ROOT/usr/lib/rpm/brp-suse.d/brp-70-trim-translations install -m0755 -D brp-extract-translations $RPM_BUILD_ROOT/usr/lib/rpm/brp-suse.d/brp-70-extract-translations ++++++ suse_update_desktop_file.sh ++++++ --- /var/tmp/diff_new_pack.zOJIVd/_old 2024-10-29 14:32:02.297779893 +0100 +++ /var/tmp/diff_new_pack.zOJIVd/_new 2024-10-29 14:32:02.301780058 +0100 @@ -238,6 +238,24 @@ fi fi +#BEGIN Upstreaming help +DESKTOP_NAME=${APPLICATION##*/} +DESKTOP_PATH=${APPLICATION%$DESKTOP_NAME} +DESKTOP_NAME=${DESKTOP_NAME%.desktop} +if test -z "$DESKTOP_PATH" ; then + DESKTOP_PATH=$RPM_BUILD_ROOT/usr/share/applications/ +fi +# Get rid ugly but common slash duplication +DESKTOP_PATH=${DESKTOP_PATH//\/\//\/} + +# Set working directory always to $RPM_BUILD_DIR. It prevents placing +# the files inside BUILDROOT. And some packages are confused by new +# desktop files placed to its build directory. +SUDF_DIR=$RPM_BUILD_DIR + +mkdir -p $SUDF_DIR/suse_update_desktop_file/update-desktop-files/$DESKTOP_NAME +cp -v "$FILE" $SUDF_DIR/suse_update_desktop_file/update-desktop-files/$DESKTOP_NAME/$DESKTOP_NAME-upstream.desktop +#END Upstreaming help # # update Categories # @@ -355,6 +373,123 @@ fi fi +#BEGIN Upstreaming help +GENERIC_CHANGES=false +TRANSLATION_CHANGES=false +shopt -s nullglob +cp -v "$FILE" $SUDF_DIR/suse_update_desktop_file/update-desktop-files/$DESKTOP_NAME/$DESKTOP_NAME-downstream-no-translation.desktop +# Insert translations from the downstream +ORIG_DIR=$PWD +cd $SUDF_DIR/suse_update_desktop_file/update-desktop-files/$DESKTOP_NAME +if [ "$I18N" != "no" ]; then + sed "s@^Name=@_&Name($DESKTOP_NAME.desktop): @;s@^GenericName=@_&GenericName($DESKTOP_NAME.desktop): @;s@^Comment=@_&Comment($DESKTOP_NAME.desktop): @;s@^Keywords=@_&Keywords($DESKTOP_NAME.desktop): @" $FILE >$DESKTOP_NAME-downstream-no-translation-desktop_translations.desktop + intltool-merge /usr/share/desktop-translations/desktop_translations $DESKTOP_NAME-downstream-no-translation-desktop_translations.desktop $DESKTOP_NAME-downstream-translated-raw.desktop -d -u + sed -i "s@^Name=Name($DESKTOP_NAME.desktop): @Name=@;s@^GenericName=GenericName($DESKTOP_NAME.desktop): @GenericName=@;s@^Comment=Comment($DESKTOP_NAME.desktop): @Comment=@;s@^Keywords=Keywords($DESKTOP_NAME.desktop): @Keywords=@" $DESKTOP_NAME-downstream-translated-raw.desktop + ${0%.sh}_process_translations.py $DESKTOP_NAME + cp -a -v $DESKTOP_NAME-downstream-translated.desktop $FILE + if ! diff -u $DESKTOP_NAME-upstream.desktop $DESKTOP_NAME-downstream-translated.desktop >$DESKTOP_NAME-downstream-directly-translated.diff ; then + TRANSLATION_CHANGES=true + fi + sed -i "1,2s/$DESKTOP_NAME-\(upstream\|downstream-translated\).desktop/$DESKTOP_NAME.desktop/" $DESKTOP_NAME-downstream-directly-translated.diff + for DESKTOP in $DESKTOP_NAME-upstream $DESKTOP_NAME-downstream-no-translation ; do + sed "/\(Name\|GenericName\|Comment\|Keywords\)\[/d;s@^Name=@_Name=@;s@^GenericName=@_GenericName=@;s@^Comment=@_Comment=@;s@^Keywords=@_Keywords=@" $DESKTOP.desktop >$DESKTOP.desktop.in + done + if ! diff -u $DESKTOP_NAME-upstream.desktop.in $DESKTOP_NAME-downstream-no-translation.desktop.in >$DESKTOP_NAME-downstream-in-translated.diff ; then + GENERIC_CHANGES=true + fi + sed -i "1,2s/$DESKTOP_NAME-\(upstream\|downstream-no-translation\).desktop.in/$DESKTOP_NAME.desktop.in/" $DESKTOP_NAME-downstream-in-translated.diff + mkdir po + intltool-extract --type=gettext/ini $DESKTOP_NAME-downstream-no-translation-desktop_translations.desktop + xgettext --default-domain=$DESKTOP_NAME --add-comments --keyword=_ --keyword=N_ --keyword=U_ $DESKTOP_NAME-downstream-no-translation-desktop_translations.desktop.h -o po/$DESKTOP_NAME.pot + for PO in /usr/share/desktop-translations/desktop_translations/*.po ; do + LNG=${PO##*/} + LNG=${LNG%.po} + msgmerge $PO po/$DESKTOP_NAME.pot -o po/$LNG-pre.po + if test -f po/$LNG-pre.po ; then + msgattrib --no-obsolete po/$LNG-pre.po -o po/$LNG.po + fi + sed -i "s@\"\(Name\|GenericName\|Comment\|Keywords\)($DESKTOP_NAME.desktop): @\"@" po/$LNG.po + rm po/$LNG-pre.po + done + sed -i "s@\"\(Name\|GenericName\|Comment\|Keywords\)($DESKTOP_NAME.desktop): @\"@" po/$DESKTOP_NAME.pot + rm $DESKTOP_NAME-downstream-no-translation-desktop_translations.desktop $DESKTOP_NAME-downstream-no-translation-desktop_translations.desktop.h $DESKTOP_NAME-downstream-translated-raw.desktop +fi + +# Generate output in the OTHER directory +cd .. +RPM_OTHER_DIR=${RPM_BUILD_DIR%/BUILD*}/OTHER +if test -f $RPM_OTHER_DIR/update-desktop-files.tar.gz ; then + X=r +else + X=c +fi +cd .. +tar ${X}f $RPM_OTHER_DIR/update-desktop-files.tar.gz update-desktop-files + +EOF=EOF +cat <<EOF +========================= Deprecation notice ============================== + +%suse_update_desktop_file is deprecated and will be removed in the future. +It provides SUSE specific changes that were never sent to the upstream. +there is a time to change this now. + +Please follow +https://en.opensuse.org/openSUSE:Update-desktop-files_deprecation + +Are there any generic changes to upstream: $GENERIC_CHANGES +Are there any translation changes to upstream: $TRANSLATION_CHANGES + +Location of the upstreaming files during the build: +$SUDF_DIR/suse_update_desktop_file/$DESKTOP_NAME +- $DESKTOP_NAME-downstream-directly-translated.diff +- $DESKTOP_NAME-downstream-in-translated.diff +- $DESKTOP_NAME-downstream-no-translation.desktop +- $DESKTOP_NAME-downstream-no-translation.desktop.in +- $DESKTOP_NAME-downstream-translated.desktop +- $DESKTOP_NAME-upstream.desktop +- $DESKTOP_NAME-upstream.desktop.in + +Customized helpers for you: +cd update-desktop-files/$DESKTOP_NAME/po +for PO in *.po ; do + if test -f ../../../po/\$PO ; then + msgcat --use-first \$PO ../../../po/\$PO -o ../../../po/\$PO.new + mv ../../../po/\$PO.new ../../../po/\$PO + else + cp -a \$PO ../../../po/\$PO + fi +done + +Or swap arguments of msgcat according to the documentation: + msgcat --use-first ../../../po/\$PO \$PO -o ../../../po/\$PO.new + +sed "/\(Name\|GenericName\|Comment\|Keywords\)\[/d;s@^Name=@_Name=@;s@^GenericName=@_GenericName=@;s@^Comment=@_Comment=@;s@^Keywords=@_Keywords=@" <$DESKTOP_NAME.desktop >$DESKTOP_NAME.desktop.in +patch <$DESKTOP_NAME-downstream-in-translated.diff + +Source{number}: $DESKTOP_NAME.desktop.in +or +Source{number}: $DESKTOP_NAME.desktop + +cp %{SOURCE{NUMBER}} . + +%translate_suse_desktop $DESKTOP_NAME.desktop + +install -D -m 0644 $DESKTOP_NAME.desktop %{buildroot}${DESKTOP_PATH#$RPM_BUILD_ROOT}$DESKTOP_NAME.desktop + +osc add $DESKTOP_NAME.desktop.in +osc rm $DESKTOP_NAME.desktop + +if ! diff $DESKTOP_NAME.desktop %{SOURCE{number}} ; then +cat <<EOF +A new version of desktop file exists. Please update $DESKTOP_NAME.desktop +rpm source from $PWD to get translations to older products. +$EOF +-=========================================================================== +EOF +cd $ORIG_DIR +#END Upstreaming help + if [ "$I18N" = "no" ]; then # # this file will not get translated ++++++ suse_update_desktop_file_process_translations.py ++++++ #!/usr/bin/python3 import sys file = sys.argv[1] po_raw = open(file + '-downstream-translated-raw.desktop', 'r') po_clean = open(file + '-downstream-translated.desktop', 'w') lines = po_raw.readlines() items = dict() name_processing = False genericname_processing = False comment_processing = False keywords_processing = False for line in lines: if ( name_processing and not (line.startswith("Name[") or\ line.startswith("Name="))) or\ ( genericname_processing and not (line.startswith("GenericName[") or\ line.startswith("GenericName="))) or\ ( comment_processing and not (line.startswith("Comment[") or\ line.startswith("Comment="))) or\ ( keywords_processing and not (line.startswith("Keywords[") or\ line.startswith("Keywords="))): name_processing = False genericname_processing = False comment_processing = False keywords_processing = False for item in sorted(items): po_clean.write(items[item]) items = dict() # Why lang = "AAAA"? Untranslated string is supposed to be first, # but not all desktop files conform to this conventions. Expect it # anywhere, but move it to the beginning of the list. if line.startswith("Name["): name_processing = True lang = line[5:line.find(']')] items[lang] = line elif line.startswith("Name="): name_processing = True lang = "AAAA" items[lang] = line elif line.startswith("GenericName["): genericname_processing = True lang = line[12:line.find(']')] items[lang] = line elif line.startswith("GenericName="): genericname_processing = True lang = "AAAA" items[lang] = line elif line.startswith("Comment["): comment_processing = True lang = line[8:line.find(']')] items[lang] = line elif line.startswith("Comment="): comment_processing = True lang = "AAAA" items[lang] = line elif line.startswith("Keywords["): keywords_processing = True lang = line[9:line.find(']')] items[lang] = line elif line.startswith("Keywords="): keywords_processing = True lang = "AAAA" items[lang] = line else: po_clean.write(line)
participants (1)
-
Source-Sync