commit 3fe2df2a60155ddaf17abcf9be1ede0bb53ca19534d687b5a6badf0a1855238d Author: Lars Vogdt Date: Fri Sep 30 10:00:41 2016 +0000 Accepting request 430587 from home:oertel new package as wanted in boo#996896 OBS-URL: https://build.opensuse.org/request/show/430587 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Tools/instsource-susedata?expand=0&rev=1 diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..9b03811 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,23 @@ +## Default LFS +*.7z filter=lfs diff=lfs merge=lfs -text +*.bsp filter=lfs diff=lfs merge=lfs -text +*.bz2 filter=lfs diff=lfs merge=lfs -text +*.gem filter=lfs diff=lfs merge=lfs -text +*.gz filter=lfs diff=lfs merge=lfs -text +*.jar filter=lfs diff=lfs merge=lfs -text +*.lz filter=lfs diff=lfs merge=lfs -text +*.lzma filter=lfs diff=lfs merge=lfs -text +*.obscpio filter=lfs diff=lfs merge=lfs -text +*.oxt filter=lfs diff=lfs merge=lfs -text +*.pdf filter=lfs diff=lfs merge=lfs -text +*.png filter=lfs diff=lfs merge=lfs -text +*.rpm filter=lfs diff=lfs merge=lfs -text +*.tbz filter=lfs diff=lfs merge=lfs -text +*.tbz2 filter=lfs diff=lfs merge=lfs -text +*.tgz filter=lfs diff=lfs merge=lfs -text +*.ttf filter=lfs diff=lfs merge=lfs -text +*.txz filter=lfs diff=lfs merge=lfs -text +*.whl filter=lfs diff=lfs merge=lfs -text +*.xz filter=lfs diff=lfs merge=lfs -text +*.zip filter=lfs diff=lfs merge=lfs -text +*.zst filter=lfs diff=lfs merge=lfs -text diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..57affb6 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.osc diff --git a/instsource-susedata-0.1.tar.bz2 b/instsource-susedata-0.1.tar.bz2 new file mode 100644 index 0000000..21f7d2f --- /dev/null +++ b/instsource-susedata-0.1.tar.bz2 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0a30111eacc949d8a4bdb27409f9e81ee3b6e679424aca5879980b4ca394a78c +size 9103 diff --git a/instsource-susedata-diskusage.patch b/instsource-susedata-diskusage.patch new file mode 100644 index 0000000..682b856 --- /dev/null +++ b/instsource-susedata-diskusage.patch @@ -0,0 +1,138 @@ +--- 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; + } + diff --git a/instsource-susedata.changes b/instsource-susedata.changes new file mode 100644 index 0000000..2155922 --- /dev/null +++ b/instsource-susedata.changes @@ -0,0 +1,37 @@ +------------------------------------------------------------------- +Tue Sep 27 17:41:40 CEST 2016 - ro@suse.de + +- use is_opensuse for requiring proper EULAs package + +------------------------------------------------------------------- +Tue Jul 26 12:32:44 CEST 2016 - ro@suse.de + +- add option "-p" for adding diskusage information to susedata + (fate#320517) + +------------------------------------------------------------------- +Wed Mar 12 11:30:26 CET 2014 - ro@suse.de + +- re-add missing function str2utf8xml + +------------------------------------------------------------------- +Tue Mar 4 15:05:34 CET 2014 - ro@suse.de + +- add appdata.xml.gz and app-icons.tar.gz if exising + +------------------------------------------------------------------- +Tue Mar 4 12:28:08 CET 2014 - ro@suse.de + +- drop use of BSUtil.pm +- drop private copy of ABXML.pm (will be added to inst-source-utils) + +------------------------------------------------------------------- +Wed Feb 26 01:25:46 CET 2014 - ro@suse.de + +- first working version + +------------------------------------------------------------------- +Tue Feb 25 13:49:54 CET 2014 - ro@suse.de + +- created initial package + diff --git a/instsource-susedata.spec b/instsource-susedata.spec new file mode 100644 index 0000000..0f07ec0 --- /dev/null +++ b/instsource-susedata.spec @@ -0,0 +1,56 @@ +# +# spec file for package instsource-susedata +# +# Copyright (c) 2016 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 +# 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: instsource-susedata +Summary: add susedata to repomd metadata +License: GPL-2.0 +Group: System/Management +Version: 0.1 +Release: 0 +Source: %{name}-%{version}.tar.bz2 +Patch0: instsource-susedata-diskusage.patch +BuildRoot: %{_tmppath}/%{name}-%{version}-build +%if 0%{?is_opensuse} +Requires: openSUSE-EULAs +%else +Requires: SLE-EULAs +%endif +Requires: perl-XML-Structured +Supplements: kiwi-instsource +BuildArch: noarch + +%description +scan repodata and add susedata and eulas where needed + +%prep +%setup -q +%patch0 -p0 + +%build +# empty because of rpmlint warning rpm-buildroot-usage + +%install +mkdir -p $RPM_BUILD_ROOT/usr/bin +install -m 755 add_product_susedata $RPM_BUILD_ROOT/usr/bin + +%files +%defattr(-, root, root) +%doc COPYING +/usr/bin/add_product_susedata + +%changelog