- extract mimehandler provides from .desktop files

- preliminaries for extracting font provides (not enabled yet)
- dont classify font metrics data as fonts
- only run script dep extraction once per file, duh
This commit is contained in:
Panu Matilainen 2009-02-04 14:50:56 +00:00
parent 0b7fe47218
commit c66608cfaa
3 changed files with 118 additions and 5 deletions

21
desktop-file.prov Executable file
View File

@ -0,0 +1,21 @@
#!/bin/sh
#
# Transform desktop mimetype info into RPM mimehandler(type) provides
#
# Author: Richard Hughes <richard@hughsie.com>
# Based on other provides scripts from RPM
OLD_IFS="$IFS"
while read instfile ; do
case "$instfile" in
*.desktop)
mime=`cat $instfile | grep MimeType= | cut -d'=' -f2`
IFS=';'
for type in $mime ; do
echo 'mimehandler('$type')'
done
;;
esac
done
IFS=$OLD_IFS

View File

@ -0,0 +1,83 @@
diff -up rpm-4.6.0-rc4/build/rpmfc.c.extra-prov rpm-4.6.0-rc4/build/rpmfc.c
--- rpm-4.6.0-rc4/build/rpmfc.c.extra-prov 2009-02-04 15:18:05.000000000 +0200
+++ rpm-4.6.0-rc4/build/rpmfc.c 2009-02-04 15:20:46.000000000 +0200
@@ -485,6 +485,7 @@ static const struct rpmfcTokens_s const
{ "RPM v4", RPMFC_ARCHIVE|RPMFC_INCLUDE },
{ " image", RPMFC_IMAGE|RPMFC_INCLUDE },
+ { " font metrics", RPMFC_WHITE|RPMFC_INCLUDE },
{ " font", RPMFC_FONT|RPMFC_INCLUDE },
{ " Font", RPMFC_FONT|RPMFC_INCLUDE },
@@ -1189,6 +1190,31 @@ exit:
#endif
}
+static int rpmfcMISC(rpmfc fc)
+{
+ struct stat st;
+ int rc = -1;
+ const char *what = NULL;
+ const char * fn = fc->fn[fc->ix];
+ /* this part is enumerated, compare equality not bit flags */
+ int ftype = fc->fcolor->vals[fc->ix] & 0x000F0000;
+
+ if (ftype == RPMFC_FONT) {
+ what = "fontconfig";
+ } else if (ftype == RPMFC_TEXT && rpmFileHasSuffix(fn, ".desktop")) {
+ what = "desktop";
+ }
+
+ if (what == NULL || stat(fn, &st) < 0 || !S_ISREG(st.st_mode)) {
+ goto exit;
+ }
+
+ (void) rpmfcHelper(fc, 'P', what);
+ rc = 0;
+
+exit:
+ return rc;
+}
typedef const struct rpmfcApplyTbl_s {
int (*func) (rpmfc fc);
int colormask;
@@ -1198,12 +1224,11 @@ typedef const struct rpmfcApplyTbl_s {
*/
static const struct rpmfcApplyTbl_s const rpmfcApplyTable[] = {
{ rpmfcELF, RPMFC_ELF },
- { rpmfcSCRIPT, (RPMFC_SCRIPT|RPMFC_PERL) },
- { rpmfcSCRIPT, (RPMFC_SCRIPT|RPMFC_PYTHON) },
- { rpmfcSCRIPT, (RPMFC_SCRIPT|RPMFC_PKGCONFIG) },
- { rpmfcSCRIPT, (RPMFC_SCRIPT|RPMFC_LIBTOOL) },
- { rpmfcSCRIPT, RPMFC_MONO },
- { rpmfcSYMLINK, RPMFC_SYMLINK },
+ { rpmfcSCRIPT, (RPMFC_SCRIPT|RPMFC_BOURNE|
+ RPMFC_PERL|RPMFC_PYTHON|RPMFC_MONO|
+ RPMFC_PKGCONFIG|RPMFC_LIBTOOL) },
+ { rpmfcMISC, RPMFC_FONT|RPMFC_TEXT },
+ { rpmfcSYMLINK, RPMFC_SYMLINK },
{ NULL, 0 }
};
@@ -1322,7 +1347,7 @@ rpmRC rpmfcClassify(rpmfc fc, ARGV_t arg
size_t slen;
int fcolor;
int xx;
- int msflags = MAGIC_CHECK; /* XXX MAGIC_COMPRESS flag? */
+ int msflags = MAGIC_CHECK | MAGIC_COMPRESS;
magic_t ms = NULL;
if (fc == NULL || argv == NULL)
diff -up rpm-4.6.0-rc4/macros.in.extra-prov rpm-4.6.0-rc4/macros.in
--- rpm-4.6.0-rc4/macros.in.extra-prov 2009-02-04 15:18:05.000000000 +0200
+++ rpm-4.6.0-rc4/macros.in 2009-02-04 15:18:05.000000000 +0200
@@ -463,6 +463,9 @@ print (t)\
%__pkgconfig_provides @RPMCONFIGDIR@/pkgconfigdeps.sh --provides
%__pkgconfig_requires @RPMCONFIGDIR@/pkgconfigdeps.sh --requires
+#%__fontconfig_provides /usr/lib/rpm/fontconfig.prov
+%__desktop_provides /usr/lib/rpm/desktop-file.prov
+
#==============================================================================
# ---- Database configuration macros.
# Macros used to configure Berkley db parameters.

View File

@ -18,13 +18,14 @@
Summary: The RPM package management system
Name: rpm
Version: %{rpmver}
Release: 0.%{snapver}.2%{?dist}
Release: 0.%{snapver}.3%{?dist}
Group: System Environment/Base
Url: http://www.rpm.org/
Source0: http://rpm.org/releases/testing/%{name}-%{srcver}.tar.bz2
%if %{with int_bdb}
Source1: db-%{bdbver}.tar.gz
%endif
Source10: desktop-file.prov
Patch0: rpm-4.5.90-devel-autodep.patch
Patch1: rpm-4.5.90-pkgconfig-path.patch
@ -34,7 +35,7 @@ Patch2: rpm-4.5.90-gstreamer-provides.patch
Patch200: rpm-4.6.0-rc1-defaultdocdir.patch
# These are not yet upstream
Patch300: rpm-4.5.90-posttrans.patch
Patch300: rpm-4.6.0-extra-provides.patch
# Partially GPL/LGPL dual-licensed and some bits with BSD
# SourceLicense: (GPLv2+ and LGPLv2+ with exceptions) and BSD
@ -169,8 +170,7 @@ that will manipulate RPM packages and databases.
# upstream but not on 4.6.x branch yet, oops
%patch200 -p1 -b .defaultdocdir
# needs a bit of upstream love first...
#%patch300 -p1 -b .posttrans
%patch300 -p1 -b .extra-prov
%if %{with int_bdb}
ln -s db-%{bdbver} db
@ -213,6 +213,8 @@ install -m 755 scripts/rpm.daily ${RPM_BUILD_ROOT}%{_sysconfdir}/cron.daily/rpm
mkdir -p ${RPM_BUILD_ROOT}%{_sysconfdir}/logrotate.d
install -m 644 scripts/rpm.log ${RPM_BUILD_ROOT}%{_sysconfdir}/logrotate.d/rpm
install -p -m 755 %{SOURCE10} ${RPM_BUILD_ROOT}%{rpmhome}/
mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/rpm
mkdir -p $RPM_BUILD_ROOT/var/lib/rpm
@ -341,6 +343,7 @@ exit 0
%{rpmhome}/config.sub
%{rpmhome}/mkinstalldirs
%{rpmhome}/rpmdiff*
%{rpmhome}/desktop-file.prov
%{rpmhome}/macros.perl
%{rpmhome}/macros.python
@ -367,7 +370,13 @@ exit 0
%doc doc/librpm/html/*
%changelog
* Sat Jan 31 2009 Panu Matilainen <pmatilai@redhat.com>
* Wed Feb 04 2009 Panu Matilainen <pmatilai@redhat.com> - 4.6.0-0.rc4.3
- extract mimehandler provides from .desktop files
- preliminaries for extracting font provides (not enabled yet)
- dont classify font metrics data as fonts
- only run script dep extraction once per file, duh
* Sat Jan 31 2009 Panu Matilainen <pmatilai@redhat.com> - 4.6.0-0.rc4.2
- change platform sharedstatedir to something more sensible (#185862)
- add rpmdb_foo links to db utils for documentation compatibility