nixpkgs/pkgs/by-name/mo/monoDLLFixer/dll-fixer.pl
aleksana 571c71e6f7 treewide: migrate packages to pkgs/by-name, take 1
We are migrating packages that meet below requirements:

1. using `callPackage`
2. called path is a directory
3. overriding set is empty (`{ }`)
4. not containing path expressions other than relative path (to
makenixpkgs-vet happy)
5. not referenced by nix files outside of the directory, other
than`pkgs/top-level/all-packages.nix`
6. not referencing nix files outside of the directory
7. not referencing `default.nix` (since it's changed to `package.nix`)
8. `outPath` doesn't change after migration

The tool is here: https://github.com/Aleksanaa/by-name-migrate.
2024-11-09 20:04:51 +08:00

33 lines
643 B
Perl

#! @perl@ -w
use strict;
my @paths = split ' ', $ENV{"ALL_INPUTS"};
open IN, "<$ARGV[0]" or die;
open OUT, ">$ARGV[0].tmp" or die;
while (<IN>) {
# !!! should use a real XML library here.
if (!/<dllmap dll="(.*)" target="(.*)"\/>/) {
print OUT;
next;
}
my $dll = $1;
my $target = $2;
foreach my $path (@paths) {
my $fullPath = "$path/lib/$target";
if (-e "$fullPath") {
$target = $fullPath;
last;
}
}
print OUT " <dllmap dll=\"$dll\" target=\"$target\"/>\n";
}
close IN;
rename "$ARGV[0].tmp", "$ARGV[0]" or die "cannot rename $ARGV[0]";