summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSíle Ekaterin Liszka <sheila@vulpine.house>2022-08-19 15:41:21 +0000
committerZach van Rijn <me@zv.io>2022-10-21 18:34:02 -0500
commit418e17b52ea216c53b9ecff96470c132d28ed356 (patch)
tree52d7caa3d67da03349bb6d0d995e465ca6671de8
parent2c283b9ef35e3c67a4f72d3488ae21a5c3f4c2eb (diff)
downloadpackages-418e17b52ea216c53b9ecff96470c132d28ed356.tar.gz
packages-418e17b52ea216c53b9ecff96470c132d28ed356.tar.bz2
packages-418e17b52ea216c53b9ecff96470c132d28ed356.tar.xz
packages-418e17b52ea216c53b9ecff96470c132d28ed356.zip
scripts/cargo.pl: helper script for maintaining rust-based packages
-rwxr-xr-xscripts/cargo.pl32
1 files changed, 32 insertions, 0 deletions
diff --git a/scripts/cargo.pl b/scripts/cargo.pl
new file mode 100755
index 000000000..54d716e47
--- /dev/null
+++ b/scripts/cargo.pl
@@ -0,0 +1,32 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+use feature qw(:5.22);
+
+open my $cargo, '<', $ARGV[0] or die "can't open $ARGV[0]: $!\n";
+my $data = '';
+# This block reads in the entire file.
+{
+ local $/;
+ $data = <$cargo>;
+}
+
+my $name = '';
+my %cargo = ();
+my @lines = split /\r?\n/, $data;
+
+# 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;
+ }
+}
+
+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};
+}