summaryrefslogtreecommitdiffstats
path: root/private/refresh-hwcap
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-14 13:42:30 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-14 13:42:30 +0000
commit75808db17caf8b960b351e3408e74142f4c85aac (patch)
tree7989e9c09a4240248bf4658a22208a0a52d991c4 /private/refresh-hwcap
parentInitial commit. (diff)
downloadlintian-upstream.tar.xz
lintian-upstream.zip
Adding upstream version 2.117.0.upstream/2.117.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'private/refresh-hwcap')
-rwxr-xr-xprivate/refresh-hwcap92
1 files changed, 92 insertions, 0 deletions
diff --git a/private/refresh-hwcap b/private/refresh-hwcap
new file mode 100755
index 0000000..62668bc
--- /dev/null
+++ b/private/refresh-hwcap
@@ -0,0 +1,92 @@
+#!/usr/bin/perl
+
+use v5.20;
+use warnings;
+use utf8;
+
+use IPC::Run3;
+use POSIX qw(strftime);
+use Unicode::UTF8 qw(encode_utf8);
+
+my $datadir = shift;
+my $man = shift // '/usr/share/man/man8/ld.so.8.gz';
+my (%caps, @keeps);
+
+die encode_utf8("Usage: $0 path/to/lintian/data.\n")
+ unless $datadir;
+
+my @command = ('zcat', $man);
+my $output;
+
+run3(\@command, \undef, \$output);
+my @lines = split(/\n/, $output);
+
+while (defined(my $line = shift @lines)) {
+ next
+ unless $line =~ /^\.S[SH] HARDWARE CAPABILITIES/i;
+ last;
+}
+
+while (defined(my $line = shift @lines)) {
+ next
+ unless $line =~ /^\.B/;
+ last;
+}
+
+while (defined(my $line = shift @lines)) {
+
+ last
+ if $line =~ /^\.S[SH] /;
+ next
+ if $line =~ /^\./;
+
+ $caps{$_} = 1 for split(/,\s*/, $line);
+}
+
+my $path = "$datadir/shared-libs/hwcap-dirs";
+my $date = strftime '%Y-%m-%d', gmtime;
+open(my $orig, '<', $path)
+ or die encode_utf8("Cannot open $path");
+
+while (my $line = <$orig>) {
+ chomp $line;
+
+ next
+ unless $line =~ m/^#\s*Keep:\s*(.*\S)\s*$/;
+
+ my $keep = $1;
+ push @keeps, $keep;
+
+ foreach my $val (split /\s*,\s*/, $keep) {
+ $caps{$val} = 1;
+ }
+}
+close($orig);
+
+open(my $fp, '>', $path)
+ or die encode_utf8("Cannot open $path");
+
+print {$fp} encode_utf8(<<"EOF");
+# List of all known hwcap.
+#
+# Last updated: $date
+# Generated by $0
+#
+# Lines to always be included:
+EOF
+foreach my $keep (@keeps) {
+ print {$fp} encode_utf8("# Keep: $keep\n");
+}
+
+print {$fp} encode_utf8("\n");
+
+foreach (sort keys %caps) {
+ print {$fp} encode_utf8("$_\n");
+}
+close($fp);
+
+# Local Variables:
+# indent-tabs-mode: nil
+# cperl-indent-level: 4
+# End:
+# vim: syntax=perl sw=4 sts=4 sr et