Accepting request 136524 from home:vuntz:branches:GNOME:Factory
Move SuSEconfig script to desktop-file-utils; note: can't go in G:S:3.6 OBS-URL: https://build.opensuse.org/request/show/136524 OBS-URL: https://build.opensuse.org/package/show/GNOME:Factory/glib2?expand=0&rev=208
This commit is contained in:
parent
11fafa6e51
commit
d63f462382
243
SuSEconfig.glib2
243
SuSEconfig.glib2
@ -1,243 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
#
|
|
||||||
# SuSEconfig.glib2 - create default application ordering for MIME associations
|
|
||||||
#
|
|
||||||
# Copyright (C) 2012 Guido Berhoerster <gber@opensuse.org>
|
|
||||||
#
|
|
||||||
# Permission to use, copy, modify, and distribute this software for any
|
|
||||||
# purpose with or without fee is hereby granted, provided that the above
|
|
||||||
# copyright notice and this permission notice appear in all copies.
|
|
||||||
#
|
|
||||||
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
||||||
# TORTIOUS ACTION, ARISING OUT OF PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
#
|
|
||||||
|
|
||||||
export LC_ALL=C
|
|
||||||
|
|
||||||
# reset XDG_DATA_DIRS so it can be trusted
|
|
||||||
unset XDG_DATA_DIRS
|
|
||||||
if [ "${PROFILEREAD}" != "true" ]; then
|
|
||||||
. $r/etc/profile
|
|
||||||
fi
|
|
||||||
|
|
||||||
for desktop in gnome xfce lxde; do
|
|
||||||
awk -vdesktop=${desktop} '
|
|
||||||
# print a warning to stderr
|
|
||||||
function warn(msg, cmd) {
|
|
||||||
cmd = "cat >&2"
|
|
||||||
print msg | cmd
|
|
||||||
close(cmd)
|
|
||||||
}
|
|
||||||
|
|
||||||
# print an error message and exit with the given exit status
|
|
||||||
function err(status, msg)
|
|
||||||
{
|
|
||||||
warn(msg)
|
|
||||||
exit_status = status
|
|
||||||
exit exit_status
|
|
||||||
}
|
|
||||||
|
|
||||||
# delete all elements of an array
|
|
||||||
function delete_array(arr, i) {
|
|
||||||
for (i in arr) {
|
|
||||||
delete arr[i]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# find preferred combination of mimetype and category
|
|
||||||
function find_preferred_category(mimetypes_categories, categories, mimetype,
|
|
||||||
i) {
|
|
||||||
for (i = 1; i in categories; i++) {
|
|
||||||
if (mimetype SUBSEP categories[i] in mimetypes_categories) {
|
|
||||||
return mimetypes_categories[mimetype,categories[i]]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# sort keys of an array by index (using the awk default comparison)
|
|
||||||
function asorti2(src, dest, key, len) {
|
|
||||||
len = 0
|
|
||||||
delete_array(dest)
|
|
||||||
for (key in src) {
|
|
||||||
dest[len++] = key
|
|
||||||
}
|
|
||||||
|
|
||||||
_qsorti(dest, 0, len - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
function array_swap(arr, i, j, tmp) {
|
|
||||||
tmp = arr[i]
|
|
||||||
arr[i] = arr[j]
|
|
||||||
arr[j] = tmp
|
|
||||||
}
|
|
||||||
|
|
||||||
# Based on Bentley, J. L., 2000. Programming Pearls. 2nd ed. Reading, MA:
|
|
||||||
# Addison-Wesley Professional.
|
|
||||||
function _qsorti(dest, l, u, val, i, j) {
|
|
||||||
if (l >= u) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
array_swap(dest, l, l + int(rand() * (u - l)))
|
|
||||||
val = dest[l]
|
|
||||||
i = l
|
|
||||||
j = u + 1
|
|
||||||
while (1) {
|
|
||||||
do { i++ } while (i <= u && dest[i] < val)
|
|
||||||
do { j-- } while (dest[j] > val)
|
|
||||||
if (i > j) {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
array_swap(dest, i, j)
|
|
||||||
}
|
|
||||||
array_swap(dest, l, j)
|
|
||||||
|
|
||||||
_qsorti(dest, l, j - 1)
|
|
||||||
_qsorti(dest, j + 1, u)
|
|
||||||
}
|
|
||||||
|
|
||||||
BEGIN {
|
|
||||||
desktop = desktop != "" ? desktop : "gnome"
|
|
||||||
if (desktop == "gnome") {
|
|
||||||
categories_list = "GNOME,GTK"
|
|
||||||
} else if (desktop == "xfce") {
|
|
||||||
categories_list = "XFCE,GTK"
|
|
||||||
} else if (desktop == "lxde") {
|
|
||||||
categories_list = "GTK"
|
|
||||||
}
|
|
||||||
split(categories_list, categories, /,/)
|
|
||||||
root = ENVIRON["r"]
|
|
||||||
defaults_conf = root "/etc/" desktop "_defaults.conf"
|
|
||||||
|
|
||||||
# parse desktop defaults preferences
|
|
||||||
lineno = 0
|
|
||||||
while ((getline < defaults_conf) > 0) {
|
|
||||||
lineno++
|
|
||||||
if (NF == 0 || $1 ~ /^#/) {
|
|
||||||
# skip comments and empty lines
|
|
||||||
continue
|
|
||||||
} else if (NF != 1) {
|
|
||||||
err(1, "syntax error in " defaults_conf " line " lineno)
|
|
||||||
} else if (split($1, arr, /=/) == 2) {
|
|
||||||
# handle MIME type defaults
|
|
||||||
mimetype_default_apps[arr[1]] = arr[2]
|
|
||||||
} else if ($1 ~ /^!.+\.desktop$/) {
|
|
||||||
# handle preferred default applications
|
|
||||||
preferred_default_apps[substr($1, 2)] = substr($1, 2)
|
|
||||||
} else if ($1 ~ /^.+\.desktop$/) {
|
|
||||||
# handle regular default applications
|
|
||||||
default_apps[$1] = $1
|
|
||||||
} else {
|
|
||||||
err(1, "syntax error in " defaults_conf ", line " lineno)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
close(defaults_conf)
|
|
||||||
|
|
||||||
# find all desktop files
|
|
||||||
for (i = split("XDG_DATA_DIRS" in ENVIRON ? ENVIRON["XDG_DATA_DIRS"] : \
|
|
||||||
"/usr/local/share:/usr/share", xdg_data_dirs, /:/); i > 0; i--) {
|
|
||||||
# XDG_DATA_DIRS is trusted here because it has been reset
|
|
||||||
cmd = "ls -1 -- \"" root xdg_data_dirs[i] "/applications/\"*.desktop " \
|
|
||||||
"2>/dev/null"
|
|
||||||
while ((cmd | getline desktopfile) > 0) {
|
|
||||||
l = split(desktopfile, arr, "/")
|
|
||||||
desktopfiles[arr[l]] = desktopfile
|
|
||||||
}
|
|
||||||
close(cmd)
|
|
||||||
}
|
|
||||||
|
|
||||||
# process all desktop files in alphabetical order
|
|
||||||
asorti2(desktopfiles, desktopfiles_keys)
|
|
||||||
for (i = 0; i in desktopfiles_keys; i++) {
|
|
||||||
# parse a desktop file
|
|
||||||
desktopfile = desktopfiles_keys[i]
|
|
||||||
delete_array(desktopfile_mimetypes)
|
|
||||||
delete_array(desktopfile_categories)
|
|
||||||
lineno = 0
|
|
||||||
in_desktop_entry = 0
|
|
||||||
while ((getline < desktopfiles[desktopfile]) > 0) {
|
|
||||||
lineno++
|
|
||||||
if (NF == 0 || $1 ~ /^#/) {
|
|
||||||
# skip comments and empty lines
|
|
||||||
continue
|
|
||||||
} else if (in_desktop_entry == 0 && \
|
|
||||||
$0 ~ /^\[Desktop Entry\][\t ]*$/) {
|
|
||||||
# desktop entry group
|
|
||||||
in_desktop_entry = 1
|
|
||||||
} else if (in_desktop_entry == 1) {
|
|
||||||
if (in_desktop_entry == 1 && $1 ~ /^\[/) {
|
|
||||||
# quit when a different group starts, "Desktop Entry" must
|
|
||||||
# come first
|
|
||||||
break
|
|
||||||
} else if ($0 ~ /^MimeType *=/ && split($0, arr, /=/) == 2) {
|
|
||||||
# handle MimeTypes
|
|
||||||
gsub(/(^ *|; *$)/, "", arr[2])
|
|
||||||
split(arr[2], desktopfile_mimetypes, /;/)
|
|
||||||
} else if ($0 ~ /^Categories *=/ && split($0, arr, /=/) == 2) {
|
|
||||||
# handle Categories
|
|
||||||
gsub(/(^ *|; *$)/, "", arr[2])
|
|
||||||
split(arr[2], desktopfile_categories, /;/)
|
|
||||||
} else if ($0 ~ /^[A-Za-z0-9\[\]@_-]+ *=/) {
|
|
||||||
# skip other keys
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
warn("syntax error in " desktopfiles[desktopfile] ", line " \
|
|
||||||
lineno)
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
close(desktopfiles[desktopfile])
|
|
||||||
|
|
||||||
# store the results
|
|
||||||
for (j = 1; j in desktopfile_mimetypes; j++) {
|
|
||||||
if (desktopfile_mimetypes[j] in mimetype_default_apps && \
|
|
||||||
mimetype_default_apps[desktopfile_mimetypes[j]] == \
|
|
||||||
desktopfile) {
|
|
||||||
mimetype_defaults[desktopfile_mimetypes[j]] = desktopfile
|
|
||||||
}
|
|
||||||
if (desktopfile in preferred_default_apps) {
|
|
||||||
preferred_defaults[desktopfile_mimetypes[j]] = desktopfile
|
|
||||||
}
|
|
||||||
if (desktopfile in default_apps) {
|
|
||||||
defaults[desktopfile_mimetypes[j]] = desktopfile
|
|
||||||
}
|
|
||||||
for (k = 1; k in desktopfile_categories; k++) {
|
|
||||||
mimetypes_categories[desktopfile_mimetypes[j], \
|
|
||||||
desktopfile_categories[k]] = desktopfile
|
|
||||||
}
|
|
||||||
generic_mimetypes[desktopfile_mimetypes[j]] = desktopfile
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# determine default mimetype handlers
|
|
||||||
for (mimetype in generic_mimetypes) {
|
|
||||||
if (mimetype in mimetype_defaults) {
|
|
||||||
defaults_list[mimetype] = mimetype_defaults[mimetype]
|
|
||||||
} else if (mimetype in preferred_defaults) {
|
|
||||||
defaults_list[mimetype] = preferred_defaults[mimetype]
|
|
||||||
} else if (mimetype in defaults) {
|
|
||||||
defaults_list[mimetype] = defaults[mimetype]
|
|
||||||
} else if ((desktopfile = \
|
|
||||||
find_preferred_category(mimetypes_categories, categories, \
|
|
||||||
mimetype)) != "") {
|
|
||||||
defaults_list[mimetype] = desktopfile
|
|
||||||
} else if (mimetype in generic_mimetypes) {
|
|
||||||
defaults_list[mimetype] = generic_mimetypes[mimetype]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
print "# generated by SuSEconfig --module glib2 from " defaults_conf
|
|
||||||
print "[Default Applications]"
|
|
||||||
asorti2(defaults_list, defaults_list_keys)
|
|
||||||
for (i = 0; i in defaults_list_keys; i++) {
|
|
||||||
mimetype = defaults_list_keys[i]
|
|
||||||
printf("%s=%s\n", mimetype, defaults_list[mimetype])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
' >$r/var/cache/gio-2.0/${desktop}-defaults.list
|
|
||||||
done
|
|
@ -8,7 +8,7 @@
|
|||||||
# distribution wise GNOME defaults.
|
# distribution wise GNOME defaults.
|
||||||
#
|
#
|
||||||
# After any change of this file run
|
# After any change of this file run
|
||||||
# SuSEconfig --module glib2
|
# suse-update-mime-defaults
|
||||||
#
|
#
|
||||||
# This list is a source for defaults.list.
|
# This list is a source for defaults.list.
|
||||||
#
|
#
|
||||||
|
@ -1,3 +1,14 @@
|
|||||||
|
-------------------------------------------------------------------
|
||||||
|
Mon Oct 1 11:26:58 UTC 2012 - vuntz@opensuse.org
|
||||||
|
|
||||||
|
- Drop SuSEconfig.glib2: since SuSEconfig is now dead, this can't
|
||||||
|
work anymore. Instead, this script is moved to desktop-file-utils
|
||||||
|
and macros defined there will automatically call it.
|
||||||
|
- Update glib2-upstream-gnome_defaults.conf to mention
|
||||||
|
suse-update-mime-defaults script instead of "SuSEconfig --module
|
||||||
|
glib2".
|
||||||
|
- All of this fixes bnc#782120.
|
||||||
|
|
||||||
-------------------------------------------------------------------
|
-------------------------------------------------------------------
|
||||||
Mon Sep 24 07:06:48 UTC 2012 - dimstar@opensuse.org
|
Mon Sep 24 07:06:48 UTC 2012 - dimstar@opensuse.org
|
||||||
|
|
||||||
|
@ -30,7 +30,6 @@ Url: http://www.gtk.org/
|
|||||||
Source: http://download.gnome.org/sources/glib/2.34/%{_name}-%{version}.tar.xz
|
Source: http://download.gnome.org/sources/glib/2.34/%{_name}-%{version}.tar.xz
|
||||||
Source1: glib2.sh
|
Source1: glib2.sh
|
||||||
Source2: glib2.csh
|
Source2: glib2.csh
|
||||||
Source3: SuSEconfig.glib2
|
|
||||||
# Not upstream file. Only proposes upstream packages:
|
# Not upstream file. Only proposes upstream packages:
|
||||||
Source4: glib2-upstream-gnome_defaults.conf
|
Source4: glib2-upstream-gnome_defaults.conf
|
||||||
# Some documentation for people writing branding packages, shipped in the branding-upstream package
|
# Some documentation for people writing branding packages, shipped in the branding-upstream package
|
||||||
@ -262,7 +261,7 @@ translation-update-upstream
|
|||||||
%patch11 -p1
|
%patch11 -p1
|
||||||
%patch12 -p1
|
%patch12 -p1
|
||||||
%patch13 -p1
|
%patch13 -p1
|
||||||
cp -a %{S:1} %{S:2} %{S:3} %{S:5} .
|
cp -a %{S:1} %{S:2} %{S:5} .
|
||||||
cp -a %{S:4} gnome_defaults.conf
|
cp -a %{S:4} gnome_defaults.conf
|
||||||
if ! test -f %{_datadir}/aclocal/gtk-doc.m4 ; then
|
if ! test -f %{_datadir}/aclocal/gtk-doc.m4 ; then
|
||||||
cp -a %{S:7} m4macros/
|
cp -a %{S:7} m4macros/
|
||||||
@ -299,7 +298,6 @@ NOCONFIGURE=1 ./autogen.sh
|
|||||||
mkdir -p %{buildroot}%{_sysconfdir}/profile.d
|
mkdir -p %{buildroot}%{_sysconfdir}/profile.d
|
||||||
install -D -m0644 glib2.sh %{buildroot}%{_sysconfdir}/profile.d/zzz-glib2.sh
|
install -D -m0644 glib2.sh %{buildroot}%{_sysconfdir}/profile.d/zzz-glib2.sh
|
||||||
install -D -m0644 glib2.csh %{buildroot}%{_sysconfdir}/profile.d/zzz-glib2.csh
|
install -D -m0644 glib2.csh %{buildroot}%{_sysconfdir}/profile.d/zzz-glib2.csh
|
||||||
install -D -m0755 SuSEconfig.glib2 %{buildroot}/sbin/conf.d/SuSEconfig.glib2
|
|
||||||
install -D -m0644 gnome_defaults.conf %{buildroot}%{_sysconfdir}/gnome_defaults.conf
|
install -D -m0644 gnome_defaults.conf %{buildroot}%{_sysconfdir}/gnome_defaults.conf
|
||||||
# default apps magic
|
# default apps magic
|
||||||
mkdir -p %{buildroot}%{_localstatedir}/cache/gio-2.0 %{buildroot}%{_datadir}/applications
|
mkdir -p %{buildroot}%{_localstatedir}/cache/gio-2.0 %{buildroot}%{_datadir}/applications
|
||||||
@ -404,7 +402,6 @@ rm -rf %{buildroot}
|
|||||||
# have a better home... The zzz-glib2 scripts could arguably be in
|
# have a better home... The zzz-glib2 scripts could arguably be in
|
||||||
# libglib-2_0-0 but that would break the shared library policy.
|
# libglib-2_0-0 but that would break the shared library policy.
|
||||||
%{_sysconfdir}/profile.d/zzz-glib2.*
|
%{_sysconfdir}/profile.d/zzz-glib2.*
|
||||||
/sbin/conf.d/SuSEconfig.glib2
|
|
||||||
|
|
||||||
%files -n gio-branding-upstream
|
%files -n gio-branding-upstream
|
||||||
%defattr(-,root,root)
|
%defattr(-,root,root)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user