proxmox-perl-rs/scripts/genpackage.pl
Wolfgang Bumiller 3d447c9762 buildsys: add genpackage.pl script
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2022-03-01 10:54:15 +01:00

33 lines
656 B
Perl
Executable File

#!/usr/bin/env perl
# Create a perl package given a product and package name.
use strict;
use warnings;
use File::Path qw(make_path);
my $product = shift @ARGV or die "missing product name (PVE, PMG or Common)\n";
die "missing package name\n" if !@ARGV;
for my $package (@ARGV) {
my $path = ($package =~ s@::@/@gr) . ".pm";
print "Generating $path\n";
$path =~ m@^(.*)/[^/]+@;
make_path($1, { mode => 0755 });
open(my $fh, '>', $path) or die "failed to open '$path' for writing: $!\n";
print {$fh} <<"EOF";
package $package;
use base 'Proxmox::Lib::$product';
BEGIN { __PACKAGE__->bootstrap(); }
1;
EOF
close($fh);
}