build
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Tools/instsource-susedata?expand=0&rev=5
This commit is contained in:
parent
6eb2262d0f
commit
f9deccaf9a
17
_service
Normal file
17
_service
Normal file
@ -0,0 +1,17 @@
|
||||
<services>
|
||||
<service name="obs_scm" mode="disabled">
|
||||
<param name="url">https://github.com/openSUSE/instsource-susedata.git</param>
|
||||
<param name="scm">git</param>
|
||||
<param name="version">0.2</param>
|
||||
<param name="revision">0.2</param>
|
||||
<param name="extract">instsource-susedata.changes</param>
|
||||
<param name="extract">instsource-susedata.spec</param>
|
||||
</service>
|
||||
<service mode="disabled" name="set_version" />
|
||||
|
||||
<service mode="buildtime" name="tar" />
|
||||
<service mode="buildtime" name="recompress">
|
||||
<param name="file">*.tar</param>
|
||||
<param name="compression">xz</param>
|
||||
</service>
|
||||
</services>
|
@ -1,3 +0,0 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:0a30111eacc949d8a4bdb27409f9e81ee3b6e679424aca5879980b4ca394a78c
|
||||
size 9103
|
3
instsource-susedata-0.2.obscpio
Normal file
3
instsource-susedata-0.2.obscpio
Normal file
@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:249fe4e1cfa6a10cb1f5383f560581fc1016b26a905ee9b685cc2a5cf00561d6
|
||||
size 33803
|
@ -1,138 +0,0 @@
|
||||
--- add_product_susedata
|
||||
+++ add_product_susedata
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
use XML::Structured ':bytes';
|
||||
use ABXML;
|
||||
+use RPMQ;
|
||||
use Digest;
|
||||
use Getopt::Std;
|
||||
use Compress::Zlib;
|
||||
@@ -99,13 +100,15 @@
|
||||
our $opt_d;
|
||||
our $opt_u;
|
||||
our $opt_h;
|
||||
+our $opt_p;
|
||||
|
||||
-&getopts("k:e:d:uh") || die "ERROR: No such option. -h for help\n";
|
||||
+&getopts("k:e:d:uph") || die "ERROR: No such option. -h for help\n";
|
||||
&usage if ($opt_h);
|
||||
|
||||
sub usage(){
|
||||
print "\nUsage: $0 [-h][-u][-v VERSION][-k KWDFILE][-e EULADIR][-d REPOPATH]\n\n";
|
||||
print " -u use unique filenames\n";
|
||||
+ print " -p add diskusage data\n";
|
||||
print " -k = path to keyword file\n";
|
||||
print " -e = path to eula directory\n";
|
||||
print " -d = path to repository\n";
|
||||
@@ -149,15 +152,87 @@
|
||||
return $result;
|
||||
}
|
||||
|
||||
+sub calcdudata {
|
||||
+ my ($rpm, $maxdepth) = @_;
|
||||
+ my %q = RPMQ::rpmq_many($rpm, 1027, 1028, 1030, 1095, 1096, 1116, 1117, 1118);
|
||||
+ if (!$q{1027}) {
|
||||
+ $q{1027} = $q{1117} || [];
|
||||
+ my @di = @{$q{1116} || []};
|
||||
+ $_ = $q{1118}->[shift @di] . $_ for @{$q{1027}};
|
||||
+ }
|
||||
+ my @modes = @{$q{1030} || []};
|
||||
+ my @devs = @{$q{1095} || []};
|
||||
+ my @inos = @{$q{1096} || []};
|
||||
+ my @names = @{$q{1027} || []};
|
||||
+ my @sizes = @{$q{1028} || []};
|
||||
+ my %seen;
|
||||
+ my %dirnum;
|
||||
+ my %subdirnum;
|
||||
+ my %dirsize;
|
||||
+ my %subdirsize;
|
||||
+ my ($name, $first);
|
||||
+ for $name (@names) {
|
||||
+ my $mode = shift @modes;
|
||||
+ my $dev = shift @devs;
|
||||
+ my $ino = shift @inos;
|
||||
+ my $size = shift @sizes;
|
||||
+ # strip leading slash
|
||||
+ # prefix is either empty or ends in /
|
||||
+ $name = "usr/src/packages/$name" unless $name =~ s/^\///;
|
||||
+
|
||||
+ # check if regular file
|
||||
+ next if ($mode & 0170000) != 0100000;
|
||||
+ # don't count hardlinks twice
|
||||
+ next if $seen{"$dev $ino"};
|
||||
+ $seen{"$dev $ino"} = 1;
|
||||
+
|
||||
+ # rounded size in kbytes
|
||||
+ $size = int ($size / 1024) + 1;
|
||||
+
|
||||
+ $name = '' unless $name =~ s/\/[^\/]*$//;
|
||||
+ if (($name =~ tr/\///) < $maxdepth) {
|
||||
+ $dirsize{"$name/"} += $size;
|
||||
+ $dirnum{"$name/"} += 1;
|
||||
+ $subdirsize{"$name/"} ||= 0; # so we get all keys
|
||||
+ }
|
||||
+ # traverse though path stripping components from the back
|
||||
+ $name =~ s/\/[^\/]*$// while ($name =~ tr/\///) > $maxdepth;
|
||||
+
|
||||
+ while ($name ne '') {
|
||||
+ $name = '' unless $name =~ s/\/[^\/]*$//;
|
||||
+ $subdirsize{"$name/"} += $size;
|
||||
+ $subdirnum{"$name/"} += 1;
|
||||
+ }
|
||||
+ }
|
||||
+ my @dulist;
|
||||
+ for $name (sort keys %subdirsize) {
|
||||
+ next unless $dirsize{$name} || $subdirsize{$name};
|
||||
+ $dirsize{$name} ||= 0;
|
||||
+ $subdirsize{$name} ||= 0;
|
||||
+ $dirnum{$name} ||= 0;
|
||||
+ $subdirnum{$name} ||= 0;
|
||||
+ # SUSETAGS: "$name $dirsize{$name} $subdirsize{$name} $dirnum{$name} $subdirnum{$name}";
|
||||
+
|
||||
+ # workaround for libsolv parser bug, make sure dir starts with '/'
|
||||
+ my $xname = $name;
|
||||
+ $xname = "/$xname" unless $xname =~ /^\//;
|
||||
+ push @dulist, { 'name' => $xname, 'size' => $dirsize{$name} + $subdirsize{$name}, 'count' => $dirnum{$name} + $subdirnum{$name} };
|
||||
+ }
|
||||
+ return { 'dirs' => { 'dir' => \@dulist } };
|
||||
+}
|
||||
+
|
||||
+
|
||||
my $eula_dir;
|
||||
my $kwd_file;
|
||||
my $repo_dir;
|
||||
my $unique_filenames;
|
||||
+my $diskusage;
|
||||
|
||||
$eula_dir = $opt_e if $opt_e;
|
||||
$kwd_file = $opt_k if $opt_k;
|
||||
$repo_dir = $opt_d if $opt_d;
|
||||
$unique_filenames = 1 if $opt_u;
|
||||
+$diskusage = 1 if $opt_p;
|
||||
|
||||
die "no repository specified" unless $repo_dir;
|
||||
unless ($eula_dir || $kwd_file) {
|
||||
@@ -212,9 +287,9 @@
|
||||
print "INFO: processing packages from primary\n";
|
||||
my @suse;
|
||||
for my $pack (@{$primary->{'package'}}) {
|
||||
- next unless $keyword_data->{$pack->{'name'}};
|
||||
my $data;
|
||||
my $pkgid = (grep {$_->{'pkgid'}} @{$pack->{'checksum'}})[0]->{'_content'};
|
||||
+ my $pkgpath = $pack->{'location'}->{'href'};
|
||||
$data->{'pkgid'} = $pkgid;
|
||||
for my $field (qw(name arch version)) {
|
||||
$data->{$field} = $pack->{$field};
|
||||
@@ -223,6 +298,11 @@
|
||||
push @{$data->{'keyword'}}, { '_content' => $_ } for @{$keyword_data->{$pack->{'name'}}};
|
||||
}
|
||||
$data->{'eula'} = str2utf8xml($eula_data->{$pack->{'name'}}) if $eula_data && $eula_data->{$pack->{'name'}};
|
||||
+ if ($pkgpath && $diskusage) {
|
||||
+ my $du = calcdudata("$repo_dir/$pkgpath", 3);
|
||||
+ $data->{'diskusage'} = $du if $du;
|
||||
+ }
|
||||
+ next unless $data->{'keyword'} || $data->{'eula'} || $data->{'diskusage'};
|
||||
push @suse, $data;
|
||||
}
|
||||
|
@ -1,3 +1,10 @@
|
||||
-------------------------------------------------------------------
|
||||
Tue Mar 13 12:23:40 UTC 2018 - adrian@suse.de
|
||||
|
||||
- update to version 0.2
|
||||
* creates i18n susedata files
|
||||
- transfer source into git
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Mon Oct 17 11:01:28 UTC 2016 - jengelh@inai.de
|
||||
|
||||
|
5
instsource-susedata.obsinfo
Normal file
5
instsource-susedata.obsinfo
Normal file
@ -0,0 +1,5 @@
|
||||
name: instsource-susedata
|
||||
version: 0.2
|
||||
mtime: 1520943610
|
||||
commit: 54a4b9fe3a2aa29270c15a86e5de9cff16b3e2d6
|
||||
|
@ -1,7 +1,7 @@
|
||||
#
|
||||
# spec file for package instsource-susedata
|
||||
#
|
||||
# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany.
|
||||
# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany.
|
||||
#
|
||||
# All modifications and additions to the file contributed by third parties
|
||||
# remain the property of their copyright owners, unless otherwise agreed
|
||||
@ -18,9 +18,9 @@
|
||||
|
||||
Name: instsource-susedata
|
||||
Summary: Utility to add susedata to repomd metadata
|
||||
License: GPL-2.0
|
||||
License: GPL-2.0-only
|
||||
Group: System/Management
|
||||
Version: 0.1
|
||||
Version: 0.2
|
||||
Release: 0
|
||||
Source: %{name}-%{version}.tar.bz2
|
||||
Patch0: instsource-susedata-diskusage.patch
|
||||
@ -30,6 +30,7 @@ Requires: openSUSE-EULAs
|
||||
%else
|
||||
Requires: SLE-EULAs
|
||||
%endif
|
||||
Requires: inst-source-utils
|
||||
Requires: perl-XML-Structured
|
||||
Supplements: kiwi-instsource
|
||||
BuildArch: noarch
|
||||
|
Loading…
x
Reference in New Issue
Block a user