diff -Nru debmirror-2.27ubuntu1/debian/changelog debmirror-2.27ubuntu2.20.04.1/debian/changelog --- debmirror-2.27ubuntu1/debian/changelog 2017-07-22 01:09:37.000000000 +0000 +++ debmirror-2.27ubuntu2.20.04.1/debian/changelog 2020-12-02 16:36:09.000000000 +0000 @@ -1,3 +1,12 @@ +debmirror (1:2.27ubuntu2.20.04.1) focal; urgency=medium + + * Cherry-pick upstream command-not-found changes (version 1:2.32). + + [ Jamie Strandboge ] + * Support downloading command-not-found metadata (LP: #1821251). + + -- Valters Jansons Wed, 02 Dec 2020 18:36:09 +0200 + debmirror (1:2.27ubuntu1) artful; urgency=medium * Resynchronise with Debian. Remaining changes: diff -Nru debmirror-2.27ubuntu1/debmirror debmirror-2.27ubuntu2.20.04.1/debmirror --- debmirror-2.27ubuntu1/debmirror 2017-07-22 01:09:37.000000000 +0000 +++ debmirror-2.27ubuntu2.20.04.1/debmirror 2020-12-02 16:36:09.000000000 +0000 @@ -691,6 +691,10 @@ # also get registered in %files. my %dep11_get; +# Hash to record which command-not-found metadata files need to be downloaded. +# Files also get registered in %files. +my %cnf_get; + # Separate hash for files belonging to Debian Installer images. # This data is not cached. my %di_files; @@ -1166,6 +1170,7 @@ foreach my $section (@sections) { i18n_from_release($dist,"$section/i18n"); dep11_from_release($dist,"$section/dep11"); + cnf_from_release($dist,"$section/cnf"); } } @@ -1347,6 +1352,7 @@ get_contents_files() if ($getcontents); get_i18n_files(); get_dep11_files(); +get_cnf_files(); # Pre-mirror cleanup if ($pre_cleanup) { @@ -2504,6 +2510,61 @@ $mirrordir, $tempdir); } + } + } +} + +sub cnf_from_release { + my ($dist,$distpath) = @_; + my $subdir = "dists/$dist/$distpath"; + my $compdir = $tempdir."/".$subdir; + my ($size, $filename); + my $exclude = "(".join("|", @excludes).")" if @excludes; + my $include = "(".join("|", @includes).")" if @includes; + + # Create cnf directories + make_dir($subdir); + make_dir($compdir); + + # Search for comand-not-found files in file_lists + foreach my $path (keys %file_lists) { + next if length($compdir)+1>length($path); # the +1 stands for the slash after $compdir + next if substr($path, 0, length($compdir)) ne $compdir; + + my $filename = substr($path, length($compdir)+1, length($path)-length($compdir)-1); + next if $filename !~ /\.(?:gz|bz2|xz)$/; + my $all_arches = "(".join("|", map(quotemeta, @arches)).")"; + next if $filename =~ /^Commands-/ and $filename !~ /^Commands-$all_arches\./; + + my $size = $file_lists{$path}{size}; + if(!(defined($include) && ($subdir."/".$filename)=~/$include/o)) { + next if (defined($exclude) && ($subdir."/".$filename)=~/$exclude/o); + } + + $files{"$subdir/$filename"}=1; + $files{$tempdir."/"."$subdir/$filename"}=1; + if (!check_lists("$tempdir/$subdir/$filename")) { + $bytes_to_get += $size; + $cnf_get{"$subdir/$filename"}{dist} = $dist; + $cnf_get{"$subdir/$filename"}{distpath} = $distpath; + $cnf_get{"$subdir/$filename"}{filename} = $filename; + } + } +} + +sub get_cnf_files { + say("Get command-not-found metadata files ..."); + foreach my $file (sort keys %cnf_get) { + if (!check_lists("$tempdir/$file")) { + remote_get($file); + if ($debmarshal) { + link_auxfile_into_snapshot($file, + $cnf_get{$file}{dist}, + $cnf_get{$file}{distpath}, + $cnf_get{$file}{filename}, + $mirrordir, + $tempdir); + } } } }