From 3d447c9762bbfc2d22017dbe95c2f1ae272e5fe0 Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Mon, 28 Feb 2022 11:27:17 +0100 Subject: [PATCH] buildsys: add genpackage.pl script Signed-off-by: Wolfgang Bumiller --- scripts/genpackage.pl | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100755 scripts/genpackage.pl diff --git a/scripts/genpackage.pl b/scripts/genpackage.pl new file mode 100755 index 0000000..ee7d98b --- /dev/null +++ b/scripts/genpackage.pl @@ -0,0 +1,32 @@ +#!/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); +}