Debian Codegraph @

development/library_paths

raw
1 #!/usr/bin/perl
2 # This program will print the RTLD and shared libraries paths for all
3 # architectures.
4 # It provides the list of directories that need to be kept up to date
5 # in directories_to_merge() in convert-usrmerge and in setup_merged_usr()
6 # in debootstrap when new architectures are added to Debian.
7 #
8 # The command line argument is the path to the debian/sysdeps/ directory
9 # of the glibc package. It can be downloaded with the command:
10 # git clone --depth=1 https://salsa.debian.org/glibc-team/glibc.git
11
12 use warnings;
13 use strict;
14 use autodie;
15 use v5.16;
16
17 use File::Slurp;
18 use List::Util qw(uniq);
19
20 my $sysdeps_dir = $ARGV[0] || 'glibc/debian/sysdeps';
21 my @sysdeps_files = glob("$sysdeps_dir/*.mk")
22 or die "FATAL: $sysdeps_dir/*.mk is missing!\n";
23
24 my %directories;
25
26 foreach my $file (@sysdeps_files) {
27 doit($file);
28 }
29
30 print "\nconvert-usrmerge and debootstrap should list these directories:\n";
31 foreach my $arch (sort keys %directories) {
32 my @list =
33 sort { $a cmp $b }
34 map { s#^/##; $_ }
35 grep { $_ ne '/lib' }
36 map { s#/\$\(DEB_HOST_MULTIARCH\)/.+##; $_ }
37 uniq
38 @{ $directories{$arch} };
39 print "$arch\t@list\n" if @list;
40 }
41
42 sub doit {
43 my ($file) = @_;
44
45 say "==== $file ====";
46 my @lines = grep { !/^#/ } read_file($file, chomp => 1);
47 my @multilib = map { /\s*\+=\s*(\S+)/; $1 }
48 grep { /^GLIBC_PASSES\b/ } @lines;
49 unshift(@multilib, 'libc');
50
51 foreach my $arch (@multilib) {
52 my ($rtlddir) = map { /=\s*(\S+)/; $1 }
53 grep { /^${arch}_rtlddir\b/ } @lines;
54 my ($slibdir) = map { /=\s*(\S+)/; $1 }
55 grep { /^${arch}_slibdir\b/ } @lines;
56
57 next unless $rtlddir or $slibdir;
58 $rtlddir ||= ''; $slibdir ||= '';
59 say "$arch\tRTLD: $rtlddir\t\tSLIBDIR: $slibdir";
60 my ($dpkg_arch) = $file =~ m#/([^/]+)\.mk$#;
61 push(@{ $directories{$dpkg_arch} }, $rtlddir) if $rtlddir;
62 push(@{ $directories{$dpkg_arch} }, $slibdir) if $slibdir;
63 }
64 }
65