summaryrefslogtreecommitdiffstats
path: root/development
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-20 16:34:05 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-20 16:34:05 +0000
commit17910b92b762000663c665fedbab30f7b1d41bdf (patch)
tree2e8c4fbab094dac1e376dc9395e3cf1cc5e40639 /development
parentInitial commit. (diff)
downloadusrmerge-17910b92b762000663c665fedbab30f7b1d41bdf.tar.xz
usrmerge-17910b92b762000663c665fedbab30f7b1d41bdf.zip
Adding upstream version 39.upstream/39upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rwxr-xr-xdevelopment/check-contents73
-rwxr-xr-xdevelopment/library_paths65
-rwxr-xr-xdevelopment/test30
3 files changed, 168 insertions, 0 deletions
diff --git a/development/check-contents b/development/check-contents
new file mode 100755
index 0000000..01b1111
--- /dev/null
+++ b/development/check-contents
@@ -0,0 +1,73 @@
+#!/usr/bin/perl
+# wget http://ftp.it.debian.org/debian/dists/unstable/main/Contents-amd64.gz
+
+use warnings;
+use strict;
+use autodie;
+use feature qw(say);
+
+use Storable;
+
+my $data = read_data();
+
+my (@l1, @l2);
+
+# check all files in /bin /sbin /lib
+foreach (@{$data->{rootfiles}}) {
+ my ($name, $pkg) = @$_;
+
+ # is there one in /usr too?
+ next unless exists $data->{files}->{'usr/' . $name};
+ my $usrpkg = $data->{files}->{'usr/' . $name};
+
+ # and are they in the same package?
+ if ($pkg eq $usrpkg) {
+ push(@l1, [ $name, $pkg ]);
+ } else {
+ push(@l2, [ $name, $pkg, $usrpkg ]);
+ }
+}
+
+say 'Single packages shipping the same file in / and /usr:';
+say "$_->[1]\t$_->[0]" foreach sort { $a->[1] cmp $b->[1] } @l1;
+
+say '';
+say 'Multiple packages shipping the same file in / and /usr:';
+say "$_->[1]\t$_->[0]\t$_->[2]" foreach sort { $a->[1] cmp $b->[1] } @l2;
+
+exit 0;
+
+##############################################################################
+sub read_data {
+ my $cachefile = '/tmp/contents.storable';
+
+ return retrieve($cachefile) if -e $cachefile;
+
+ my $data = read_contents();
+ store($data, $cachefile);
+ return $data;
+}
+
+sub read_contents {
+ my (@rootfiles, %files);
+
+ open(my $fh, 'zcat Contents-amd64.gz |');
+ while (<$fh>) {
+ my ($file, $package) = split;
+ $package =~ s#(^|,)[a-z]+/#$1#g;
+
+ if ($file =~ m#^(?:s?bin|lib|libx?32|lib64)/#) {
+ push(@rootfiles, [$file, $package]);
+ } elsif ($file =~ m#^usr/#) {
+ if (exists $files{$file}) {
+ $files{$file} = $files{$file} . ',' . $package;
+ } else {
+ $files{$file} = $package;
+ }
+ }
+ }
+ close($fh) or die "close: $!";
+
+ return { rootfiles => \@rootfiles, files => \%files };
+}
+
diff --git a/development/library_paths b/development/library_paths
new file mode 100755
index 0000000..129e04d
--- /dev/null
+++ b/development/library_paths
@@ -0,0 +1,65 @@
+#!/usr/bin/perl
+# This program will print the RTLD and shared libraries paths for all
+# architectures.
+# It provides the list of directories that need to be kept up to date
+# in directories_to_merge() in convert-usrmerge and in setup_merged_usr()
+# in debootstrap when new architectures are added to Debian.
+#
+# The command line argument is the path to the debian/sysdeps/ directory
+# of the glibc package. It can be downloaded with the command:
+# git clone --depth=1 https://salsa.debian.org/glibc-team/glibc.git
+
+use warnings;
+use strict;
+use autodie;
+use v5.16;
+
+use File::Slurp;
+use List::Util qw(uniq);
+
+my $sysdeps_dir = $ARGV[0] || 'glibc/debian/sysdeps';
+my @sysdeps_files = glob("$sysdeps_dir/*.mk")
+ or die "FATAL: $sysdeps_dir/*.mk is missing!\n";
+
+my %directories;
+
+foreach my $file (@sysdeps_files) {
+ doit($file);
+}
+
+print "\nconvert-usrmerge and debootstrap should list these directories:\n";
+foreach my $arch (sort keys %directories) {
+ my @list =
+ sort { $a cmp $b }
+ map { s#^/##; $_ }
+ grep { $_ ne '/lib' }
+ map { s#/\$\(DEB_HOST_MULTIARCH\)/.+##; $_ }
+ uniq
+ @{ $directories{$arch} };
+ print "$arch\t@list\n" if @list;
+}
+
+sub doit {
+ my ($file) = @_;
+
+ say "==== $file ====";
+ my @lines = grep { !/^#/ } read_file($file, chomp => 1);
+ my @multilib = map { /\s*\+=\s*(\S+)/; $1 }
+ grep { /^GLIBC_PASSES\b/ } @lines;
+ unshift(@multilib, 'libc');
+
+ foreach my $arch (@multilib) {
+ my ($rtlddir) = map { /=\s*(\S+)/; $1 }
+ grep { /^${arch}_rtlddir\b/ } @lines;
+ my ($slibdir) = map { /=\s*(\S+)/; $1 }
+ grep { /^${arch}_slibdir\b/ } @lines;
+
+ next unless $rtlddir or $slibdir;
+ $rtlddir ||= ''; $slibdir ||= '';
+ say "$arch\tRTLD: $rtlddir\t\tSLIBDIR: $slibdir";
+ my ($dpkg_arch) = $file =~ m#/([^/]+)\.mk$#;
+ push(@{ $directories{$dpkg_arch} }, $rtlddir) if $rtlddir;
+ push(@{ $directories{$dpkg_arch} }, $slibdir) if $slibdir;
+ }
+}
+
diff --git a/development/test b/development/test
new file mode 100755
index 0000000..101f6a1
--- /dev/null
+++ b/development/test
@@ -0,0 +1,30 @@
+#!/bin/sh -e
+
+tmp_cleanup() {
+ [ -d "$BASE" ] || return
+ mountpoint -q "$BASE" || return
+ umount -l $BASE
+ rmdir $BASE
+}
+
+trap "tmp_cleanup" 0 1 2 3 15
+
+BASE=$(mktemp -d)
+mount -t tmpfs tmpfs $BASE -o mode=755,size=401276k
+mkdir $BASE/delta/ $BASE/.work/ $BASE/root/
+
+if [ "$1" ]; then
+ base_dir="$1"
+else
+ base_dir='/'
+fi
+
+mount -t overlay overlay $BASE/root/ \
+ -o workdir=$BASE/.work,lowerdir=$base_dir,upperdir=$BASE/delta
+
+systemd-nspawn --setenv=LANG=C.UTF-8 \
+ --tmpfs=/tmp/:mode=1777 \
+ --bind=/var/cache/apt/archives/ \
+ --register=no \
+ --directory=$BASE/root/ || true
+