From 418e17b52ea216c53b9ecff96470c132d28ed356 Mon Sep 17 00:00:00 2001 From: Síle Ekaterin Liszka Date: Fri, 19 Aug 2022 15:41:21 +0000 Subject: scripts/cargo.pl: helper script for maintaining rust-based packages --- scripts/cargo.pl | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100755 scripts/cargo.pl 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}; +} -- cgit v1.2.3-70-g09d2