Hello community,

here is the log from the commit of package brp-extract-appdata for 
openSUSE:Factory checked in at 2012-02-16 16:11:29
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/brp-extract-appdata (Old)
 and      /work/SRC/openSUSE:Factory/.brp-extract-appdata.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "brp-extract-appdata", Maintainer is ""

Changes:
--------
New Changes file:

--- /dev/null   2010-08-26 16:28:41.000000000 +0200
+++ 
/work/SRC/openSUSE:Factory/.brp-extract-appdata.new/brp-extract-appdata.changes 
    2012-02-16 16:11:31.000000000 +0100
@@ -0,0 +1,10 @@
+-------------------------------------------------------------------
+Thu Feb 16 13:07:10 UTC 2012 - co...@suse.com
+
+- adding an escape function to please vuntz
+
+-------------------------------------------------------------------
+Tue Feb 14 10:52:01 UTC 2012 - co...@suse.com
+
+- initial package
+

New:
----
  brp-extract-appdata.changes
  brp-extract-appdata.sh
  brp-extract-appdata.spec
  create-appdata-xml.pl

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ brp-extract-appdata.spec ++++++
#
# spec file for package update-desktop-files
#
# Copyright (c) 2011 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via http://bugs.opensuse.org/
#


Name:           brp-extract-appdata
Version:        2012.02.13
Release:        0
Summary:        Extract appdata.xml
License:        MIT
Group:          Development/Tools/Building
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
Source0:        %{name}.sh
Source1:        create-appdata-xml.pl
BuildArch:      noarch

%description
Extract appdata.xml from all .deskop files found in build root

%prep

%build

%install
install -m0755 -D %SOURCE0 
$RPM_BUILD_ROOT%_rpmconfigdir/brp-suse.d/brp-72-extract-appdata
install -m0755 -D %SOURCE1 
$RPM_BUILD_ROOT/usr/lib/build/checks/72-translate-appdata

%files
%defattr(-,root,root)
%_rpmconfigdir/brp-suse.d
/usr/lib/build

%changelog
++++++ brp-extract-appdata.sh ++++++
#! /bin/sh

# Copyright 2012 Stephan Kulow, SUSE Linux Products GmbH

#
# find files and extract them for later processing
#
BASEDIR=`dirname $RPM_SOURCE_DIR`/OTHER

set -e

if ! test -f /.buildenv; then
   # this looks fishy, skip it
   echo "WARNING: I better not trim without a /.buildenv around"
   exit 0
fi

if ! test -w $BASEDIR; then
   echo "WARNING: Can't write to $BASEDIR, skipping"
   exit 0
fi

cd /$RPM_BUILD_ROOT
find ./usr/share/applications/ \
   -name *.desktop 2>/dev/null | while read FILE; do

        # save for backup 
        NFILE=${FILE#.}
        echo "<<$NFILE>>" >> $BASEDIR/$RPM_PACKAGE_NAME.applications
        cat $FILE >> $BASEDIR/$RPM_PACKAGE_NAME.applications

done

++++++ create-appdata-xml.pl ++++++
#!/usr/bin/perl -w
# search for files packaged more than once
# it is an error if such a file exists but the packages do not conflict
#
use strict;
use Data::Dumper;
use File::Glob;

sub _e {
  my ($d) = @_;
  $d =~ s/&/&amp;/sg;
  $d =~ s/</&lt;/sg;
  $d =~ s/>/&gt;/sg;
  $d =~ s/"/&quot;/sg;
  return $d;
}

my $build_root = $::ENV{BUILD_ROOT} || '/';

my $TOPDIR = '/usr/src/packages';
$TOPDIR = '/.build.packages' if -d "$build_root/.build.packages";

open (ALL_RPMS, "chroot $build_root find $TOPDIR/RPMS/ -name \"*.rpm\" |");
my @rpms = <ALL_RPMS>;
chomp @rpms;
close ALL_RPMS;

my @appdata = glob("$build_root$TOPDIR/OTHER/*.applications");
if (@appdata != 1) {
  print STDERR "DEBUG: there is not a single *.applications file\n";
  exit 0;
}
my $appdata = shift @appdata;
open(APPDATA, "$appdata") || die "can't open $appdata";
my $currentfile = '';
my $indesktopentry = 0;
my %apphash;
while ( <APPDATA> ) {
  chomp;
 
  if (m/^<<(.*)>>$/) {
     $currentfile = $1;
     next;
  }
  
  unless ($currentfile) {
     print "ERROR: haven't seen a file before $_";
     exit 0;
  }

  if (m/^\[Desktop Entry\]\s*$/) {
     if ($indesktopentry) {
        print "ERROR: 2 desktop entries? I'm out";
        exit 0;
     }
     $indesktopentry = 1;
     next;
  } elsif (m/^\[/) {
    $indesktopentry = 0; 
    next;
  }
  next unless $indesktopentry;
  next unless (m/^([^=]*)=(.*)$/);
  my $key = lc($1);
  my $val = $2;
  $apphash{$currentfile}->{$key} = $val;
}

for my $rpm (@rpms) {
    next if ($rpm =~ m/-debuginfo/ || $rpm =~ m/-debugsource/);
    open (FILES, "chroot $build_root rpm -qp --qf '[%{NAME} %{FILENAMES}\n]' 
$rpm|");
    my @files = <FILES>;
    chomp @files;
    close FILES;
    open (URL, "chroot $build_root rpm -qp --qf '%{URL}' $rpm|");
    chomp(my $url = <URL>);
    close URL; 
    # ignore empty rpm as rpmlint will catch them
    @files = grep {!/^\(none\)/} @files;
    for my $file (@files) {
        next unless $file =~ /^(\S+) (.*)$/;
        my $rpmname = $1;
        my $filename = $2;
        if (defined $apphash{$filename}) {
                $apphash{$filename}->{pkgname} = $rpmname;
                $apphash{$filename}->{homepage} ||= $url;
                print "DEBUG " . Dumper($apphash{$filename});
        }
    }
}

open(APPDATA, ">", "$appdata.xml") || die "can't write to $appdata.xml";
print APPDATA "<?xml version='1.0'?>\n";
print APPDATA "<applications version='0.1'>\n";

while (my ($file, $hash) = each(%apphash)) {
   print APPDATA "  <application>\n";
   print APPDATA "    <id type='application'>" . _e($file) . "</id>\n";
   print APPDATA "    <pkgname>" . _e($hash->{pkgname}) . "</pkgname>\n";
   if ($hash->{name}) {
     print APPDATA "    <name>" . _e($hash->{name}) . "</name>\n";
   }
   if ($hash->{comment}) {
     print APPDATA "    <summary>" . _e($hash->{comment}) . "</summary>\n";
   }
   if ($hash->{keywords}) {
     print APPDATA "    <keywords>\n";
     for my $keyword (split(/\s*;\s*/, $hash->{keywords})) {
       print APPDATA "      <keyword>" . _e($keyword) . "</keyword>\n";
     }
     print APPDATA "    </keywords>\n";
   }
   if ($hash->{icon}) {
     print APPDATA "    <icon type='local'>" . _e($hash->{icon}) . "</icon>\n";
   }
   print APPDATA "    <appcategories>\n";
   for my $keyword (split(/\s*;\s*/, $hash->{categories})) {
     print APPDATA  "      <appcategory>" . _e($keyword) . "</appcategory>\n";
   }
   print APPDATA "    </appcategories>\n";
   if ($hash->{mimetype}) {
     print APPDATA "    <mimetypes>\n";
     for my $keyword (split(/\s*;\s*/, $hash->{mimetype})) {
        print APPDATA  "      <mimetype>" . _e($keyword) . "</mimetype>\n";
     }
     print APPDATA "    </mimetypes>\n";
   }
   if ($hash->{homepage}) {
        print APPDATA "    <url type='homepage'>". _e($hash->{homepage}) . 
"</url>\n"
   }
   print APPDATA "  </application>\n";
}

print APPDATA "</applications>\n";
close(APPDATA);

# just for debug
open(APPDATA, "<", "$build_root$TOPDIR/OTHER/appdata.xml");
while ( <APPDATA> ) {
  print "XML: $_";
}
close(APPDATA);
# we don't need to keep this around - beside for debugging
unlink $appdata;
exit 0;
-- 
To unsubscribe, e-mail: opensuse-commit+unsubscr...@opensuse.org
For additional commands, e-mail: opensuse-commit+h...@opensuse.org

Reply via email to