summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorSíle Ekaterin Liszka <sheila@vulpine.house>2024-06-03 01:20:24 +0000
committerZach van Rijn <me@zv.io>2024-06-03 01:21:09 +0000
commitfbea575a49e483e5e124f1b0767730accc97227f (patch)
tree03ade9d1149e45d2af3cbba73011422d3a72c1a8 /scripts
parent17a4ba56f15d6d553ab574c85dec05eaaced491c (diff)
downloadpackages-fbea575a49e483e5e124f1b0767730accc97227f.tar.gz
packages-fbea575a49e483e5e124f1b0767730accc97227f.tar.bz2
packages-fbea575a49e483e5e124f1b0767730accc97227f.tar.xz
packages-fbea575a49e483e5e124f1b0767730accc97227f.zip
scripts/cargo.pl: enhancements.
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/cargo.pl31
1 files changed, 21 insertions, 10 deletions
diff --git a/scripts/cargo.pl b/scripts/cargo.pl
index 54d716e47..93e365620 100755
--- a/scripts/cargo.pl
+++ b/scripts/cargo.pl
@@ -2,7 +2,7 @@
use strict;
use warnings;
-use feature qw(:5.22);
+use feature qw(:5.34);
open my $cargo, '<', $ARGV[0] or die "can't open $ARGV[0]: $!\n";
my $data = '';
@@ -12,21 +12,32 @@ my $data = '';
$data = <$cargo>;
}
-my $name = '';
-my %cargo = ();
-my @lines = split /\r?\n/, $data;
+my @lines = split /(\r?\n){2,}/, $data;
+my @cargo;
# Parse the file; we just want the name and version.
foreach my $line (@lines) {
- if ($line =~ /^name = "(.*?)"$/) {
- $name = $1;
- } elsif ($line =~ /^version = "(.*?)"$/) {
- $cargo{$name} = $1;
+ $line =~ /^name = "(.*?)"$/m;
+ my $name = $1;
+ next unless defined($name);
+
+ $line =~ /^version = "(.*?)"$/m;
+ my $version = $1;
+ next unless defined($version);
+
+ next unless $line =~ /^source /m;
+ $line =~ /^source = "(.*?)"$/m;
+ my $source = $1;
+ next unless defined($source);
+
+ if ($source ne 'registry+https://github.com/rust-lang/crates.io-index') {
+ warn "Warning: $name lacks a supported registry.\n";
}
+ push @cargo, "$name $version";
}
open my $file, '>', 'crates.txt' or die "can't open output file: $!\n";
# Print the data we pulled out above to a file.
-foreach my $pkg (keys %cargo) {
- say $file $pkg . ' ' . $cargo{$pkg};
+foreach my $pkg (sort @cargo) {
+ say $file $pkg;
}