Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Alexander_Naumov:SLE-12:Update
brp-extract-appdata
create-appdata-xml.pl
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File create-appdata-xml.pl of Package brp-extract-appdata
#!/usr/bin/perl -w # read appsteam imput data and distribute the data into the # matching rpms use strict; use Data::Dumper; use File::Glob; sub escape { my ($d) = @_; $d =~ s/&/&/sg; $d =~ s/</</sg; $d =~ s/>/>/sg; $d =~ s/"/"/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\n"; my $content = do { local $/; <APPDATA> }; close APPDATA; unlink $appdata; # remove start and end tags $content =~ s/.*\n<applications[^\n]*>\n//s; $content =~ s/<\/applications>\n$//s; # split into application chunks my @appdatas = split(/<application/, $content); for (@appdatas) { $_ = " <application$_"; s/ *$//s; } my %appmatches; for my $ad (@appdatas) { next unless $ad =~ /^ <pkgname>appdata\((.*)\)<\/pkgname>$/m; $appmatches{"/usr/share/appdata/$1"} = $ad; } exit 0 unless %appmatches; my %appresults; for my $rpm (@rpms) { next if $rpm =~ m/-debuginfo/ || $rpm =~ m/-debugsource/ || $rpm =~ /src\.rpm$/; open (FILES, "chroot $build_root rpm -qp --qf '[%{NAME} %{FILENAMES}\n]' $rpm|"); my @files = <FILES>; chomp @files; close FILES; # ignore empty rpm as rpmlint will catch them @files = grep {!/^\(none\)/} @files; for my $file (@files) { next unless $file =~ /^(\S+) (.*)$/; my $rpmname = $1; my $rpmfile = $2; my $ad = $appmatches{$rpmfile}; next unless $ad; my $rpmnamex = escape($rpmname); next unless $ad =~ s/^ <pkgname>appdata\((.*)\)<\/pkgname>$/ <pkgname>$rpmnamex<\/pkgname>/m; push @{$appresults{$rpmname}}, $ad; } } for my $rpmname (sort keys %appresults) { my $output = "$build_root$TOPDIR/OTHER/$rpmname-appdata.xml"; open(APPDATA, '>', $output) || die "can't write to $output"; print APPDATA "<?xml version='1.0'?>\n"; print APPDATA "<applications version='0.1'>\n"; print APPDATA $_ for @{$appresults{$rpmname}}; print APPDATA "</applications>\n"; close APPDATA; }
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor